From 0414f82d53ec2b784c0652affa94492ce1d5519f Mon Sep 17 00:00:00 2001 From: axolotle Date: Fri, 5 Jul 2024 17:02:53 +0200 Subject: [PATCH] refactor: AdressItem typing --- .../globals/formItems/AdressItem.vue | 85 ++++++++++--------- app/src/composables/form.ts | 5 ++ app/src/types/form.ts | 28 ++++++ 3 files changed, 79 insertions(+), 39 deletions(-) create mode 100644 app/src/composables/form.ts create mode 100644 app/src/types/form.ts diff --git a/app/src/components/globals/formItems/AdressItem.vue b/app/src/components/globals/formItems/AdressItem.vue index 6d6a0a4d..5e2caf72 100644 --- a/app/src/components/globals/formItems/AdressItem.vue +++ b/app/src/components/globals/formItems/AdressItem.vue @@ -1,35 +1,36 @@ @@ -37,32 +38,38 @@ function onInput(key: 'localPart' | 'domain', modelValue: string | null) { diff --git a/app/src/composables/form.ts b/app/src/composables/form.ts new file mode 100644 index 00000000..ff2b6803 --- /dev/null +++ b/app/src/composables/form.ts @@ -0,0 +1,5 @@ +import type { InjectionKey } from 'vue' + +export const ValidationTouchSymbol = Symbol() as InjectionKey< + (key?: string) => void +> diff --git a/app/src/types/form.ts b/app/src/types/form.ts new file mode 100644 index 00000000..0ac585ad --- /dev/null +++ b/app/src/types/form.ts @@ -0,0 +1,28 @@ +import type { BaseValidation } from '@vuelidate/core' +type StateValidation = false | null + +// WRITABLE + +type BaseWritableItemProps = { + id?: string + name?: string + placeholder?: string + touchKey?: string +} + +export type BaseItemComputedProps = { + ariaDescribedby?: string | string[] + modelValue?: MV + state?: StateValidation + validation?: BaseValidation +} + +export type AdressItemProps = BaseWritableItemProps & { + choices: string[] + type?: 'domain' | 'email' +} +export type AdressModelValue = { + localPart: string | null + separator: string + domain: string | null +}