From 233d3f6b096e23fed962c0b2f1227027c8ae81ef Mon Sep 17 00:00:00 2001 From: Nozomu Ikuta <16436160+NozomuIkuta@users.noreply.github.com> Date: Thu, 4 Jan 2024 03:41:42 +0900 Subject: [PATCH] chore!: make some composable properties read-only --- packages/vue-v8n/src/composables/useV7d.ts | 41 +++++++++++----------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/packages/vue-v8n/src/composables/useV7d.ts b/packages/vue-v8n/src/composables/useV7d.ts index 871ee12..bf77b6d 100644 --- a/packages/vue-v8n/src/composables/useV7d.ts +++ b/packages/vue-v8n/src/composables/useV7d.ts @@ -8,10 +8,9 @@ export function useV7d(value: MaybeRef, rules: MaybeRefOrGetter() const _value = toRef(value) const _rules = toRef(rules) - const touched = ref(immediate) - const error = ref('') - const errors = ref([]) - const hasError = computed(() => !!errors.value.length) + const _touched = ref(immediate) + const _error = ref('') + const _errors = ref([]) watch(el, () => { el.value?.removeEventListener('focus', touch) @@ -23,9 +22,9 @@ export function useV7d(value: MaybeRef, rules: MaybeRefOrGetter(value: MaybeRef, rules: MaybeRefOrGetter _touched.value), + error: computed(() => _error.value), + errors: computed(() => _errors.value), + hasError: computed(() => !!_errors.value.length), touch, validate, reset