vee-validate 4.12.0-alpha.1 → 4.12.1

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * vee-validate v4.12.0-alpha.1
2
+ * vee-validate v4.12.1
3
3
  * (c) 2023 Abdelrahman Awad
4
4
  * @license MIT
5
5
  */
@@ -487,8 +487,7 @@
487
487
  return result;
488
488
  }
489
489
  latestRun = undefined;
490
- onDone(result, args);
491
- return result;
490
+ return onDone(result, args);
492
491
  };
493
492
  }
494
493
  function computedDeep({ get, set }) {
@@ -990,7 +989,7 @@
990
989
  if (!init.form) {
991
990
  const { errors, setErrors } = createFieldErrors();
992
991
  const id = ID_COUNTER >= Number.MAX_SAFE_INTEGER ? 0 : ++ID_COUNTER;
993
- const meta = createFieldMeta(value, initialValue, errors);
992
+ const meta = createFieldMeta(value, initialValue, errors, init.schema);
994
993
  function setState(state) {
995
994
  var _a;
996
995
  if ('value' in state) {
@@ -1022,6 +1021,7 @@
1022
1021
  label: init.label,
1023
1022
  type: init.type,
1024
1023
  validate: init.validate,
1024
+ schema: init.schema,
1025
1025
  });
1026
1026
  const errors = vue.computed(() => state.errors);
1027
1027
  function setState(state) {
@@ -1066,7 +1066,7 @@
1066
1066
  modelRef.value = value;
1067
1067
  return;
1068
1068
  }
1069
- form.stageInitialValue(vue.unref(path), value, true);
1069
+ form.setFieldInitialValue(vue.unref(path), value, true);
1070
1070
  }
1071
1071
  const initialValue = vue.computed(resolveInitialValue);
1072
1072
  // if no form is associated, use a regular ref.
@@ -1117,11 +1117,14 @@
1117
1117
  /**
1118
1118
  * Creates meta flags state and some associated effects with them
1119
1119
  */
1120
- function createFieldMeta(currentValue, initialValue, errors) {
1120
+ function createFieldMeta(currentValue, initialValue, errors, schema) {
1121
+ var _a, _b;
1122
+ const isRequired = (_b = (_a = schema === null || schema === void 0 ? void 0 : schema.describe) === null || _a === void 0 ? void 0 : _a.call(schema).required) !== null && _b !== void 0 ? _b : false;
1121
1123
  const meta = vue.reactive({
1122
1124
  touched: false,
1123
1125
  pending: false,
1124
1126
  valid: true,
1127
+ required: isRequired,
1125
1128
  validated: !!vue.unref(errors).length,
1126
1129
  initialValue: vue.computed(() => vue.unref(initialValue)),
1127
1130
  dirty: vue.computed(() => {
@@ -1184,6 +1187,7 @@
1184
1187
  label,
1185
1188
  type,
1186
1189
  validate: validator.value ? validate$1 : undefined,
1190
+ schema: isTypedSchema(rules) ? rules : undefined,
1187
1191
  });
1188
1192
  const errorMessage = vue.computed(() => errors.value[0]);
1189
1193
  if (syncVModel) {
@@ -1206,7 +1210,8 @@
1206
1210
  async function validateCurrentValue(mode) {
1207
1211
  var _a, _b;
1208
1212
  if (form === null || form === void 0 ? void 0 : form.validateSchema) {
1209
- return (_a = (await form.validateSchema(mode)).results[vue.toValue(name)]) !== null && _a !== void 0 ? _a : { valid: true, errors: [] };
1213
+ const { results } = await form.validateSchema(mode);
1214
+ return (_a = results[vue.toValue(name)]) !== null && _a !== void 0 ? _a : { valid: true, errors: [] };
1210
1215
  }
1211
1216
  if (validator.value) {
1212
1217
  return validate(value.value, validator.value, {
@@ -1224,7 +1229,7 @@
1224
1229
  return validateCurrentValue('validated-only');
1225
1230
  }, result => {
1226
1231
  if (flags.pendingUnmount[field.id]) {
1227
- return;
1232
+ return result;
1228
1233
  }
1229
1234
  setState({ errors: result.errors });
1230
1235
  meta.pending = false;
@@ -1660,6 +1665,10 @@
1660
1665
  };
1661
1666
  }
1662
1667
  ctx.expose({
1668
+ value,
1669
+ meta,
1670
+ errors,
1671
+ errorMessage,
1663
1672
  setErrors,
1664
1673
  setTouched,
1665
1674
  reset: resetField,
@@ -1706,7 +1715,7 @@
1706
1715
  let FORM_COUNTER = 0;
1707
1716
  const PRIVATE_PATH_STATE_KEYS = ['bails', 'fieldsCount', 'id', 'multiple', 'type', 'validate'];
1708
1717
  function resolveInitialValues(opts) {
1709
- const providedValues = vue.unref(opts === null || opts === void 0 ? void 0 : opts.initialValues) || {};
1718
+ const providedValues = vue.toValue((opts === null || opts === void 0 ? void 0 : opts.initialValues) || {});
1710
1719
  const schema = vue.unref(opts === null || opts === void 0 ? void 0 : opts.validationSchema);
1711
1720
  if (schema && isTypedSchema(schema) && isCallable(schema.cast)) {
1712
1721
  return klona(schema.cast(providedValues) || {});
@@ -1824,10 +1833,9 @@
1824
1833
  var _a, _b;
1825
1834
  const initialValue = vue.computed(() => getFromPath(initialValues.value, vue.toValue(path)));
1826
1835
  const pathStateExists = pathStateLookup.value[vue.toValue(path)];
1827
- if (pathStateExists) {
1828
- if ((config === null || config === void 0 ? void 0 : config.type) === 'checkbox' || (config === null || config === void 0 ? void 0 : config.type) === 'radio') {
1829
- pathStateExists.multiple = true;
1830
- }
1836
+ const isCheckboxOrRadio = (config === null || config === void 0 ? void 0 : config.type) === 'checkbox' || (config === null || config === void 0 ? void 0 : config.type) === 'radio';
1837
+ if (pathStateExists && isCheckboxOrRadio) {
1838
+ pathStateExists.multiple = true;
1831
1839
  const id = FIELD_ID_COUNTER++;
1832
1840
  if (Array.isArray(pathStateExists.id)) {
1833
1841
  pathStateExists.id.push(id);
@@ -1841,6 +1849,17 @@
1841
1849
  }
1842
1850
  const currentValue = vue.computed(() => getFromPath(formValues, vue.toValue(path)));
1843
1851
  const pathValue = vue.toValue(path);
1852
+ const isRequired = vue.computed(() => {
1853
+ var _a, _b, _c, _d, _e, _f;
1854
+ if (isTypedSchema(schema)) {
1855
+ return (_c = (_b = (_a = schema).describe) === null || _b === void 0 ? void 0 : _b.call(_a, vue.toValue(path)).required) !== null && _c !== void 0 ? _c : false;
1856
+ }
1857
+ // Path own schema
1858
+ if (isTypedSchema(config === null || config === void 0 ? void 0 : config.schema)) {
1859
+ return (_f = (_e = (_d = (config === null || config === void 0 ? void 0 : config.schema)).describe) === null || _e === void 0 ? void 0 : _e.call(_d).required) !== null && _f !== void 0 ? _f : false;
1860
+ }
1861
+ return false;
1862
+ });
1844
1863
  const id = FIELD_ID_COUNTER++;
1845
1864
  const state = vue.reactive({
1846
1865
  id,
@@ -1849,6 +1868,7 @@
1849
1868
  pending: false,
1850
1869
  valid: true,
1851
1870
  validated: !!((_a = initialErrors[pathValue]) === null || _a === void 0 ? void 0 : _a.length),
1871
+ required: isRequired,
1852
1872
  initialValue,
1853
1873
  errors: vue.shallowRef([]),
1854
1874
  bails: (_b = config === null || config === void 0 ? void 0 : config.bails) !== null && _b !== void 0 ? _b : false,
@@ -1894,7 +1914,9 @@
1894
1914
  const debouncedSilentValidation = debounceAsync(_validateSchema, 5);
1895
1915
  const debouncedValidation = debounceAsync(_validateSchema, 5);
1896
1916
  const validateSchema = withLatest(async (mode) => {
1897
- return (await mode) === 'silent' ? debouncedSilentValidation() : debouncedValidation();
1917
+ return (await (mode === 'silent'
1918
+ ? debouncedSilentValidation()
1919
+ : debouncedValidation()));
1898
1920
  }, (formResult, [mode]) => {
1899
1921
  // fields by id lookup
1900
1922
  // errors fields names, we need it to also check if custom errors are updated
@@ -1905,14 +1927,16 @@
1905
1927
  ...new Set([...keysOf(formResult.results), ...pathStates.value.map(p => p.path), ...currentErrorsPaths]),
1906
1928
  ].sort();
1907
1929
  // aggregates the paths into a single result object while applying the results on the fields
1908
- return paths.reduce((validation, _path) => {
1909
- const path = _path;
1910
- const pathState = findPathState(path) || findHoistedPath(path);
1911
- const messages = (formResult.results[path] || { errors: [] }).errors;
1912
- const fieldResult = {
1913
- errors: messages,
1914
- valid: !messages.length,
1915
- };
1930
+ const results = paths.reduce((validation, _path) => {
1931
+ var _a;
1932
+ const expectedPath = _path;
1933
+ const pathState = findPathState(expectedPath) || findHoistedPath(expectedPath);
1934
+ const messages = ((_a = formResult.results[expectedPath]) === null || _a === void 0 ? void 0 : _a.errors) || [];
1935
+ // This is the real path of the field, because it might've been a hoisted field
1936
+ const path = (vue.toValue(pathState === null || pathState === void 0 ? void 0 : pathState.path) || expectedPath);
1937
+ // It is possible that multiple paths are collected across loops
1938
+ // We want to merge them to avoid overriding any iteration's results
1939
+ const fieldResult = mergeValidationResults({ errors: messages, valid: !messages.length }, validation.results[path]);
1916
1940
  validation.results[path] = fieldResult;
1917
1941
  if (!fieldResult.valid) {
1918
1942
  validation.errors[path] = fieldResult.errors[0];
@@ -1937,6 +1961,7 @@
1937
1961
  setFieldError(pathState, fieldResult.errors);
1938
1962
  return validation;
1939
1963
  }, { valid: formResult.valid, results: {}, errors: {} });
1964
+ return results;
1940
1965
  });
1941
1966
  function mutateAllPathState(mutation) {
1942
1967
  pathStates.value.forEach(mutation);
@@ -2053,14 +2078,16 @@
2053
2078
  delete pathStateLookup.value[path];
2054
2079
  }
2055
2080
  }
2056
- function markForUnmount(path) {
2057
- return mutateAllPathState(s => {
2058
- if (s.path.startsWith(path)) {
2059
- keysOf(s.__flags.pendingUnmount).forEach(id => {
2060
- s.__flags.pendingUnmount[id] = true;
2061
- });
2081
+ function destroyPath(path) {
2082
+ keysOf(pathStateLookup.value).forEach(key => {
2083
+ if (key.startsWith(path)) {
2084
+ delete pathStateLookup.value[key];
2062
2085
  }
2063
2086
  });
2087
+ pathStates.value = pathStates.value.filter(s => !s.path.startsWith(path));
2088
+ vue.nextTick(() => {
2089
+ rebuildPathLookup();
2090
+ });
2064
2091
  }
2065
2092
  const formCtx = {
2066
2093
  formId,
@@ -2087,6 +2114,10 @@
2087
2114
  resetForm,
2088
2115
  resetField,
2089
2116
  handleSubmit,
2117
+ useFieldModel,
2118
+ defineInputBinds,
2119
+ defineComponentBinds: defineComponentBinds,
2120
+ defineField,
2090
2121
  stageInitialValue,
2091
2122
  unsetInitialValue,
2092
2123
  setFieldInitialValue,
@@ -2096,7 +2127,7 @@
2096
2127
  removePathState,
2097
2128
  initialValues: initialValues,
2098
2129
  getAllPathStates: () => pathStates.value,
2099
- markForUnmount,
2130
+ destroyPath,
2100
2131
  isFieldTouched,
2101
2132
  isFieldDirty,
2102
2133
  isFieldValid,
@@ -2195,7 +2226,7 @@
2195
2226
  if (pathState) {
2196
2227
  pathState.__flags.pendingReset = true;
2197
2228
  }
2198
- setFieldInitialValue(field, klona(newValue));
2229
+ setFieldInitialValue(field, klona(newValue), true);
2199
2230
  setFieldValue(field, newValue, false);
2200
2231
  setFieldTouched(field, (_a = state === null || state === void 0 ? void 0 : state.touched) !== null && _a !== void 0 ? _a : false);
2201
2232
  setFieldError(field, (state === null || state === void 0 ? void 0 : state.errors) || []);
@@ -2209,8 +2240,9 @@
2209
2240
  * Resets all fields
2210
2241
  */
2211
2242
  function resetForm(resetState, opts) {
2212
- let newValues = (resetState === null || resetState === void 0 ? void 0 : resetState.values) ? resetState.values : originalInitialValues.value;
2243
+ let newValues = klona((resetState === null || resetState === void 0 ? void 0 : resetState.values) ? resetState.values : originalInitialValues.value);
2213
2244
  newValues = isTypedSchema(schema) && isCallable(schema.cast) ? schema.cast(newValues) : newValues;
2245
+ newValues = (opts === null || opts === void 0 ? void 0 : opts.force) ? newValues : merge(originalInitialValues.value, newValues);
2214
2246
  setInitialValues(newValues);
2215
2247
  mutateAllPathState(state => {
2216
2248
  var _a;
@@ -2303,8 +2335,11 @@
2303
2335
  setInPath(originalInitialValues.value, path, klona(value));
2304
2336
  }
2305
2337
  }
2306
- function setFieldInitialValue(path, value) {
2338
+ function setFieldInitialValue(path, value, updateOriginal = false) {
2307
2339
  setInPath(initialValues.value, path, klona(value));
2340
+ if (updateOriginal) {
2341
+ setInPath(originalInitialValues.value, path, klona(value));
2342
+ }
2308
2343
  }
2309
2344
  async function _validateSchema() {
2310
2345
  const schemaValue = vue.unref(schema);
@@ -2354,7 +2389,8 @@
2354
2389
  // Provide injections
2355
2390
  vue.provide(FormContextKey, formCtx);
2356
2391
  function defineField(path, config) {
2357
- const pathState = (findPathState(vue.toValue(path)) || createPathState(path));
2392
+ const label = isCallable(config) ? undefined : config === null || config === void 0 ? void 0 : config.label;
2393
+ const pathState = (findPathState(vue.toValue(path)) || createPathState(path, { label }));
2358
2394
  const evalConfig = () => (isCallable(config) ? config(omit(pathState, PRIVATE_PATH_STATE_KEYS)) : config || {});
2359
2395
  function onBlur() {
2360
2396
  var _a;
@@ -2396,10 +2432,54 @@
2396
2432
  }
2397
2433
  return base;
2398
2434
  });
2399
- return [createModel(path, () => { var _a; return (_a = evalConfig().validateOnModelUpdate) !== null && _a !== void 0 ? _a : true; }), props];
2435
+ const model = createModel(path, () => { var _a; return (_a = evalConfig().validateOnModelUpdate) !== null && _a !== void 0 ? _a : true; });
2436
+ return [model, props];
2437
+ }
2438
+ function useFieldModel(pathOrPaths) {
2439
+ if (!Array.isArray(pathOrPaths)) {
2440
+ return createModel(pathOrPaths);
2441
+ }
2442
+ return pathOrPaths.map(p => createModel(p, true));
2443
+ }
2444
+ /**
2445
+ * @deprecated use defineField instead
2446
+ */
2447
+ function defineInputBinds(path, config) {
2448
+ const [model, props] = defineField(path, config);
2449
+ function onBlur(e) {
2450
+ props.value.onBlur(e);
2451
+ }
2452
+ function onInput(e) {
2453
+ const value = normalizeEventValue(e);
2454
+ setFieldValue(vue.toValue(path), value, false);
2455
+ props.value.onInput(e);
2456
+ }
2457
+ function onChange(e) {
2458
+ const value = normalizeEventValue(e);
2459
+ setFieldValue(vue.toValue(path), value, false);
2460
+ props.value.onChange(e);
2461
+ }
2462
+ return vue.computed(() => {
2463
+ return Object.assign(Object.assign({}, props.value), { onBlur,
2464
+ onInput,
2465
+ onChange, value: model.value });
2466
+ });
2467
+ }
2468
+ /**
2469
+ * @deprecated use defineField instead
2470
+ */
2471
+ function defineComponentBinds(path, config) {
2472
+ const [model, props] = defineField(path, config);
2473
+ const pathState = findPathState(vue.toValue(path));
2474
+ function onUpdateModelValue(value) {
2475
+ model.value = value;
2476
+ }
2477
+ return vue.computed(() => {
2478
+ const conf = isCallable(config) ? config(omit(pathState, PRIVATE_PATH_STATE_KEYS)) : config || {};
2479
+ return Object.assign({ [conf.model || 'modelValue']: model.value, [`onUpdate:${conf.model || 'modelValue'}`]: onUpdateModelValue }, props.value);
2480
+ });
2400
2481
  }
2401
- return Object.assign(Object.assign({}, formCtx), { values: vue.readonly(formValues), handleReset: () => resetForm(), submitForm,
2402
- defineField });
2482
+ return Object.assign(Object.assign({}, formCtx), { values: vue.readonly(formValues), handleReset: () => resetForm(), submitForm });
2403
2483
  }
2404
2484
  /**
2405
2485
  * Manages form meta aggregation
@@ -2437,7 +2517,6 @@
2437
2517
  */
2438
2518
  function useFormInitialValues(pathsState, formValues, opts) {
2439
2519
  const values = resolveInitialValues(opts);
2440
- const providedValues = opts === null || opts === void 0 ? void 0 : opts.initialValues;
2441
2520
  // these are the mutable initial values as the fields are mounted/unmounted
2442
2521
  const initialValues = vue.ref(values);
2443
2522
  // these are the original initial value as provided by the user initially, they don't keep track of conditional fields
@@ -2465,21 +2544,21 @@
2465
2544
  setInPath(formValues, state.path, klona(newValue));
2466
2545
  });
2467
2546
  }
2468
- if (vue.isRef(providedValues)) {
2469
- vue.watch(providedValues, value => {
2470
- if (value) {
2471
- setInitialValues(value, true);
2472
- }
2473
- }, {
2474
- deep: true,
2475
- });
2476
- }
2477
2547
  return {
2478
2548
  initialValues,
2479
2549
  originalInitialValues,
2480
2550
  setInitialValues,
2481
2551
  };
2482
2552
  }
2553
+ function mergeValidationResults(a, b) {
2554
+ if (!b) {
2555
+ return a;
2556
+ }
2557
+ return {
2558
+ valid: a.valid && b.valid,
2559
+ errors: [...a.errors, ...b.errors],
2560
+ };
2561
+ }
2483
2562
 
2484
2563
  const FormImpl = /** #__PURE__ */ vue.defineComponent({
2485
2564
  name: 'Form',
@@ -2523,12 +2602,11 @@
2523
2602
  },
2524
2603
  },
2525
2604
  setup(props, ctx) {
2526
- const initialValues = vue.toRef(props, 'initialValues');
2527
2605
  const validationSchema = vue.toRef(props, 'validationSchema');
2528
2606
  const keepValues = vue.toRef(props, 'keepValues');
2529
2607
  const { errors, errorBag, values, meta, isSubmitting, isValidating, submitCount, controlledValues, validate, validateField, handleReset, resetForm, handleSubmit, setErrors, setFieldError, setFieldValue, setValues, setFieldTouched, setTouched, resetField, } = useForm({
2530
2608
  validationSchema: validationSchema.value ? validationSchema : undefined,
2531
- initialValues,
2609
+ initialValues: props.initialValues,
2532
2610
  initialErrors: props.initialErrors,
2533
2611
  initialTouched: props.initialTouched,
2534
2612
  validateOnMount: props.validateOnMount,
@@ -2655,7 +2733,7 @@
2655
2733
  }
2656
2734
  let entryCounter = 0;
2657
2735
  function getCurrentValues() {
2658
- return getFromPath(form === null || form === void 0 ? void 0 : form.values, vue.unref(arrayPath), []) || [];
2736
+ return getFromPath(form === null || form === void 0 ? void 0 : form.values, vue.toValue(arrayPath), []) || [];
2659
2737
  }
2660
2738
  function initFields() {
2661
2739
  const currentValues = getCurrentValues();
@@ -2686,7 +2764,7 @@
2686
2764
  key,
2687
2765
  value: computedDeep({
2688
2766
  get() {
2689
- const currentValues = getFromPath(form === null || form === void 0 ? void 0 : form.values, vue.unref(arrayPath), []) || [];
2767
+ const currentValues = getFromPath(form === null || form === void 0 ? void 0 : form.values, vue.toValue(arrayPath), []) || [];
2690
2768
  const idx = fields.value.findIndex(e => e.key === key);
2691
2769
  return idx === -1 ? value : currentValues[idx];
2692
2770
  },
@@ -2697,7 +2775,7 @@
2697
2775
  }
2698
2776
  update(idx, value);
2699
2777
  },
2700
- }),
2778
+ }), // will be auto unwrapped
2701
2779
  isFirst: false,
2702
2780
  isLast: false,
2703
2781
  };
@@ -2709,7 +2787,7 @@
2709
2787
  form === null || form === void 0 ? void 0 : form.validate({ mode: 'silent' });
2710
2788
  }
2711
2789
  function remove(idx) {
2712
- const pathName = vue.unref(arrayPath);
2790
+ const pathName = vue.toValue(arrayPath);
2713
2791
  const pathValue = getFromPath(form === null || form === void 0 ? void 0 : form.values, pathName);
2714
2792
  if (!pathValue || !Array.isArray(pathValue)) {
2715
2793
  return;
@@ -2717,7 +2795,7 @@
2717
2795
  const newValue = [...pathValue];
2718
2796
  newValue.splice(idx, 1);
2719
2797
  const fieldPath = pathName + `[${idx}]`;
2720
- form.markForUnmount(fieldPath);
2798
+ form.destroyPath(fieldPath);
2721
2799
  form.unsetInitialValue(fieldPath);
2722
2800
  setInPath(form.values, pathName, newValue);
2723
2801
  fields.value.splice(idx, 1);
@@ -2725,7 +2803,7 @@
2725
2803
  }
2726
2804
  function push(initialValue) {
2727
2805
  const value = klona(initialValue);
2728
- const pathName = vue.unref(arrayPath);
2806
+ const pathName = vue.toValue(arrayPath);
2729
2807
  const pathValue = getFromPath(form === null || form === void 0 ? void 0 : form.values, pathName);
2730
2808
  const normalizedPathValue = isNullOrUndefined(pathValue) ? [] : pathValue;
2731
2809
  if (!Array.isArray(normalizedPathValue)) {
@@ -2739,7 +2817,7 @@
2739
2817
  afterMutation();
2740
2818
  }
2741
2819
  function swap(indexA, indexB) {
2742
- const pathName = vue.unref(arrayPath);
2820
+ const pathName = vue.toValue(arrayPath);
2743
2821
  const pathValue = getFromPath(form === null || form === void 0 ? void 0 : form.values, pathName);
2744
2822
  if (!Array.isArray(pathValue) || !(indexA in pathValue) || !(indexB in pathValue)) {
2745
2823
  return;
@@ -2759,7 +2837,7 @@
2759
2837
  }
2760
2838
  function insert(idx, initialValue) {
2761
2839
  const value = klona(initialValue);
2762
- const pathName = vue.unref(arrayPath);
2840
+ const pathName = vue.toValue(arrayPath);
2763
2841
  const pathValue = getFromPath(form === null || form === void 0 ? void 0 : form.values, pathName);
2764
2842
  if (!Array.isArray(pathValue) || pathValue.length < idx) {
2765
2843
  return;
@@ -2773,14 +2851,14 @@
2773
2851
  afterMutation();
2774
2852
  }
2775
2853
  function replace(arr) {
2776
- const pathName = vue.unref(arrayPath);
2854
+ const pathName = vue.toValue(arrayPath);
2777
2855
  form.stageInitialValue(pathName, arr);
2778
2856
  setInPath(form.values, pathName, arr);
2779
2857
  initFields();
2780
2858
  afterMutation();
2781
2859
  }
2782
2860
  function update(idx, value) {
2783
- const pathName = vue.unref(arrayPath);
2861
+ const pathName = vue.toValue(arrayPath);
2784
2862
  const pathValue = getFromPath(form === null || form === void 0 ? void 0 : form.values, pathName);
2785
2863
  if (!Array.isArray(pathValue) || pathValue.length - 1 < idx) {
2786
2864
  return;
@@ -2790,20 +2868,20 @@
2790
2868
  }
2791
2869
  function prepend(initialValue) {
2792
2870
  const value = klona(initialValue);
2793
- const pathName = vue.unref(arrayPath);
2871
+ const pathName = vue.toValue(arrayPath);
2794
2872
  const pathValue = getFromPath(form === null || form === void 0 ? void 0 : form.values, pathName);
2795
2873
  const normalizedPathValue = isNullOrUndefined(pathValue) ? [] : pathValue;
2796
2874
  if (!Array.isArray(normalizedPathValue)) {
2797
2875
  return;
2798
2876
  }
2799
2877
  const newValue = [value, ...normalizedPathValue];
2800
- form.stageInitialValue(pathName + `[${newValue.length - 1}]`, value);
2801
2878
  setInPath(form.values, pathName, newValue);
2879
+ form.stageInitialValue(pathName + `[0]`, value);
2802
2880
  fields.value.unshift(createEntry(value));
2803
2881
  afterMutation();
2804
2882
  }
2805
2883
  function move(oldIdx, newIdx) {
2806
- const pathName = vue.unref(arrayPath);
2884
+ const pathName = vue.toValue(arrayPath);
2807
2885
  const pathValue = getFromPath(form === null || form === void 0 ? void 0 : form.values, pathName);
2808
2886
  const newValue = isNullOrUndefined(pathValue) ? [] : [...pathValue];
2809
2887
  if (!Array.isArray(pathValue) || !(oldIdx in pathValue) || !(newIdx in pathValue)) {
@@ -2833,7 +2911,7 @@
2833
2911
  };
2834
2912
  form.fieldArrays.push(Object.assign({ path: arrayPath, reset: initFields }, fieldArrayCtx));
2835
2913
  vue.onBeforeUnmount(() => {
2836
- const idx = form.fieldArrays.findIndex(i => vue.unref(i.path) === vue.unref(arrayPath));
2914
+ const idx = form.fieldArrays.findIndex(i => vue.toValue(i.path) === vue.toValue(arrayPath));
2837
2915
  if (idx >= 0) {
2838
2916
  form.fieldArrays.splice(idx, 1);
2839
2917
  }
@@ -2860,7 +2938,7 @@
2860
2938
  },
2861
2939
  },
2862
2940
  setup(props, ctx) {
2863
- const { push, remove, swap, insert, replace, update, prepend, move, fields } = useFieldArray(vue.toRef(props, 'name'));
2941
+ const { push, remove, swap, insert, replace, update, prepend, move, fields } = useFieldArray(() => props.name);
2864
2942
  function slotProps() {
2865
2943
  return {
2866
2944
  fields: fields.value,
@@ -3256,8 +3334,10 @@
3256
3334
  exports.Form = Form;
3257
3335
  exports.FormContextKey = FormContextKey;
3258
3336
  exports.IS_ABSENT = IS_ABSENT;
3337
+ exports.cleanupNonNestedPath = cleanupNonNestedPath;
3259
3338
  exports.configure = configure;
3260
3339
  exports.defineRule = defineRule;
3340
+ exports.isNotNestedPath = isNotNestedPath;
3261
3341
  exports.normalizeRules = normalizeRules;
3262
3342
  exports.useField = useField;
3263
3343
  exports.useFieldArray = useFieldArray;