Skip to content

Commit

Permalink
fix(consts): move constants to central location
Browse files Browse the repository at this point in the history
  • Loading branch information
EdieLemoine committed Sep 28, 2023
1 parent 801ab1b commit 3469e2a
Show file tree
Hide file tree
Showing 19 changed files with 55 additions and 59 deletions.
4 changes: 2 additions & 2 deletions libs/core/src/components/FormElementWrapper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {type Component, type PropType, Teleport, defineComponent, h, provide} from 'vue';
import {type Component, defineComponent, h, type PropType, provide, Teleport} from 'vue';
import {type AnyElementInstance} from '../types';
import {INJECT_ELEMENT} from '../services';
import {type FormInstance} from '../form';
import {INJECT_ELEMENT} from '../data';
import {useTestAttributes} from '../composables';
import FormElement from './FormElement.vue';

Expand Down
10 changes: 5 additions & 5 deletions libs/core/src/components/MagicForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
</template>

<script lang="ts">
import { type PropType, computed, defineComponent, onMounted, provide, ref } from 'vue';
import { get } from '@vueuse/core';
import { INJECT_FORM } from '../services';
import { FORM_HOOKS, type FormHook, type FormInstance } from '../form';
import { useLifecycleHooks } from '../composables';
import {computed, defineComponent, onMounted, type PropType, provide, ref} from 'vue';
import {get} from '@vueuse/core';
import {type FormInstance} from '../form';
import {FORM_HOOKS, type FormHook, INJECT_FORM} from '../data';
import {useLifecycleHooks} from '../composables';
import Fragment from './Fragment.vue';
import FormElementWrapper from './FormElementWrapper';
Expand Down
2 changes: 1 addition & 1 deletion libs/core/src/composables/useElement.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {inject} from 'vue';
import {type AnyElementInstance} from '../types';
import {INJECT_ELEMENT} from '../services';
import {INJECT_ELEMENT} from '../data';

export const useElement = (): AnyElementInstance => {
const element = inject(INJECT_ELEMENT);
Expand Down
2 changes: 1 addition & 1 deletion libs/core/src/composables/useForm.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {inject} from 'vue';
import {INJECT_FORM} from '../services';
import {type FormInstance} from '../form';
import {INJECT_FORM} from '../data';

export const useForm = (): FormInstance => {
const form = inject(INJECT_FORM);
Expand Down
11 changes: 0 additions & 11 deletions libs/core/src/data/componentLifecycleHooks.ts

This file was deleted.

40 changes: 40 additions & 0 deletions libs/core/src/data/hooks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
export enum FormHook {
BeforeValidate = 'beforeValidate',
AfterValidate = 'afterValidate',

BeforeSubmit = 'beforeSubmit',
AfterSubmit = 'afterSubmit',

BeforeReset = 'beforeReset',
AfterReset = 'afterReset',

ElementChange = 'afterElementChange',

BeforeAddElement = 'beforeAddElement',
AfterAddElement = 'afterAddElement',
}

export const FORM_HOOKS = Object.freeze(Object.values(FormHook));

export const COMPONENT_LIFECYCLE_HOOKS = [
'onCreated',
'onActivated',
'onBeforeMount',
'onBeforeUnmount',
'onBeforeUpdate',
'onDeactivated',
'onMounted',
'onUnmounted',
'onUpdated',
] as const;

export const PLAIN_ELEMENT_HOOKS = ['blur', 'click', 'focus', ...COMPONENT_LIFECYCLE_HOOKS] as const;

export const INTERACTIVE_ELEMENT_HOOKS = [
'blur',
'focus',
'sanitize',
'update',
'validate',
...PLAIN_ELEMENT_HOOKS,
] as const;
3 changes: 2 additions & 1 deletion libs/core/src/data/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './componentLifecycleHooks';
export * from './hooks';
export * from './provides';
File renamed without changes.
2 changes: 1 addition & 1 deletion libs/core/src/form/Form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import {createHookManager} from '@myparcel-vfb/hook-manager';
import {isOfType} from '@myparcel/ts-utils';
import {markComponentAsRaw} from '../utils';
import {type AnyElementConfiguration, type AnyElementInstance, type ComponentOrHtmlElement} from '../types';
import {FORM_HOOKS, FormHook} from '../data';
import {PlainElement, type PlainElementInstance} from './plain-element';
import {
InteractiveElement,
type InteractiveElementConfiguration,
type InteractiveElementInstance,
} from './interactive-element';
import {FORM_HOOKS, FormHook} from './hooks';
import {type FormHooks, type FormInstance, type InstanceFormConfiguration} from './Form.types';

// noinspection JSUnusedGlobalSymbols
Expand Down
2 changes: 1 addition & 1 deletion libs/core/src/form/Form.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
type ComponentOrHtmlElement,
type ElementName,
} from '../types';
import {FormHook} from '../data';
import {type InteractiveElementInstance} from './interactive-element';
import {FormHook} from './hooks';

/**
* The input configuration for a Form.
Expand Down
17 changes: 0 additions & 17 deletions libs/core/src/form/hooks.ts

This file was deleted.

1 change: 0 additions & 1 deletion libs/core/src/form/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ export * from './Form.types';
export * from './defaultFormConfiguration';
export * from './defineField';
export * from './defineForm';
export * from './hooks';
export * from './interactive-element';
export * from './plain-element';
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {PlainElement} from '../plain-element';
import {type FormInstance} from '../Form.types';
import {useDynamicWatcher} from '../../utils';
import {type AnyElementInstance, type ComponentOrHtmlElement} from '../../types';
import {INTERACTIVE_ELEMENT_HOOKS} from './hooks';
import {INTERACTIVE_ELEMENT_HOOKS} from '../../data';
import {type InteractiveElementConfiguration, type InteractiveElementInstance} from './InteractiveElement.types';

// noinspection JSUnusedGlobalSymbols
Expand Down
10 changes: 0 additions & 10 deletions libs/core/src/form/interactive-element/hooks.ts

This file was deleted.

1 change: 0 additions & 1 deletion libs/core/src/form/interactive-element/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from '../validator';
export * from './InteractiveElement';
export * from './InteractiveElement.types';
export * from './hooks';
2 changes: 1 addition & 1 deletion libs/core/src/form/plain-element/PlainElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {createHookManager} from '@myparcel-vfb/hook-manager';
import {type FormInstance} from '../Form.types';
import {useDynamicWatcher} from '../../utils';
import {type AnyElementConfiguration, type ComponentOrHtmlElement, type ElementName} from '../../types';
import {PLAIN_ELEMENT_HOOKS} from './hooks';
import {PLAIN_ELEMENT_HOOKS} from '../../data';
import {type PlainElementInstance} from './PlainElement.types';

// noinspection JSUnusedGlobalSymbols
Expand Down
3 changes: 0 additions & 3 deletions libs/core/src/form/plain-element/hooks.ts

This file was deleted.

1 change: 0 additions & 1 deletion libs/core/src/form/plain-element/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from './PlainElement';
export * from './PlainElement.types';
export * from './hooks';
1 change: 0 additions & 1 deletion libs/core/src/services/index.ts

This file was deleted.

0 comments on commit 3469e2a

Please sign in to comment.