From 50fda7861dfbc5e824a039e68c0a7d9a1465fc71 Mon Sep 17 00:00:00 2001 From: axolotle Date: Sat, 6 Jul 2024 12:26:06 +0200 Subject: [PATCH] refactor: FormFieldReadonly ts + composition --- .../components/globals/FormFieldReadonly.vue | 34 +++++++++---------- app/src/types/form.ts | 17 ++++++++++ 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/app/src/components/globals/FormFieldReadonly.vue b/app/src/components/globals/FormFieldReadonly.vue index 09703414..6214a32e 100644 --- a/app/src/components/globals/FormFieldReadonly.vue +++ b/app/src/components/globals/FormFieldReadonly.vue @@ -1,27 +1,27 @@ - diff --git a/app/src/types/form.ts b/app/src/types/form.ts index 8e840bc0..b32fb606 100644 --- a/app/src/types/form.ts +++ b/app/src/types/form.ts @@ -5,6 +5,8 @@ import type { } from '@vuelidate/core' import type { RouteLocationRaw } from 'vue-router' +import type { Cols } from '@/types/commons' + type StateValidation = false | null type StateVariant = 'success' | 'info' | 'warning' | 'danger' @@ -194,8 +196,23 @@ export type FormField< readonly?: false } +type FormFieldReadonly< + C extends AnyWritableComponents = AnyWritableComponents, +> = BaseFormField & { + label: string + cols?: Cols + readonly: true +} + export type FormFieldProps< C extends AnyWritableComponents, MV extends any, > = Omit, 'hr' | 'visible' | 'readonly'> & BaseFormFieldComputedProps + +export type FormFieldReadonlyProps< + C extends AnyWritableComponents, + MV extends any, +> = Omit, 'hr' | 'visible' | 'readonly'> & { + modelValue?: MV +}