@teamnovu/kit-vue-forms 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -286,8 +286,11 @@ function he(r, e) {
286
286
  errors: f(e.errors) ?? m.errors
287
287
  });
288
288
  F(() => f(e.errors), async () => {
289
- const l = await o();
290
- n(l.errors);
289
+ if (t.isValidated) {
290
+ const l = await o();
291
+ n(l.errors);
292
+ } else
293
+ n();
291
294
  }, { immediate: !0 }), F(
292
295
  [() => t.validators],
293
296
  async (l) => {
@@ -324,7 +327,7 @@ function he(r, e) {
324
327
  isValid: c
325
328
  };
326
329
  }
327
- const n = (l) => {
330
+ const n = (l = m.errors) => {
328
331
  t.errors = S(f(e.errors) ?? m.errors, l);
329
332
  }, h = async () => {
330
333
  const l = await o();
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Reference counter for fields
3
+ */
1
4
  export declare class Rc {
2
5
  private drop?;
3
6
  private rc;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamnovu/kit-vue-forms",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -124,9 +124,13 @@ export function useValidation<T extends FormDataDefault>(
124
124
 
125
125
  // Watch for changes in the error bag and update validation state
126
126
  watch(() => unref(options.errors), async () => {
127
- const validationResults = await getValidationResults()
127
+ if (validationState.isValidated) {
128
+ const validationResults = await getValidationResults()
128
129
 
129
- updateErrors(validationResults.errors)
130
+ updateErrors(validationResults.errors)
131
+ } else {
132
+ updateErrors()
133
+ }
130
134
  }, { immediate: true })
131
135
 
132
136
  // Watch for changes in validation function or schema
@@ -194,7 +198,7 @@ export function useValidation<T extends FormDataDefault>(
194
198
  }
195
199
  }
196
200
 
197
- const updateErrors = (newErrors: ErrorBag) => {
201
+ const updateErrors = (newErrors: ErrorBag = SuccessValidationResult.errors) => {
198
202
  validationState.errors = mergeErrors(unref(options.errors) ?? SuccessValidationResult.errors, newErrors)
199
203
  }
200
204
 
package/src/utils/rc.ts CHANGED
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Reference counter for fields
3
+ */
1
4
  export class Rc {
2
5
  private rc: number = 1
3
6