refactor(date-converter): improved ux and layout

This commit is contained in:
Corentin Thomasset 2023-04-12 23:01:21 +02:00 committed by Corentin THOMASSET
parent 5fa811a583
commit fd9ab59172
7 changed files with 346 additions and 76 deletions

View file

@ -25,7 +25,15 @@ export type ValidationAttrs = {
validationStatus: string | undefined;
};
export function useValidation<T>({ source, rules }: { source: Ref<T>; rules: UseValidationRule<T>[] }) {
export function useValidation<T>({
source,
rules,
watch: watchRefs = [],
}: {
source: Ref<T>;
rules: UseValidationRule<T>[];
watch?: Ref<unknown>[];
}) {
const state = reactive<{
message: string;
status: undefined | 'error';
@ -42,7 +50,7 @@ export function useValidation<T>({ source, rules }: { source: Ref<T>; rules: Use
});
watch(
[source],
[source, ...watchRefs],
() => {
state.message = '';
state.status = undefined;