@regle/core 1.26.1 → 1.27.0-beta.2

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
- * @regle/core v1.26.1
2
+ * @regle/core v1.27.0-beta.2
3
3
  * (c) 2026 Victor Garcia
4
4
  * @license MIT
5
5
  */
@@ -759,7 +759,6 @@ const REGLE_FLAGS = { REGLE_STATIC: "__regle_static" };
759
759
  function isRegleDevtoolsTestEnv() {
760
760
  return Boolean(typeof globalThis !== "undefined" && ("__vitest_worker__" in globalThis || "__JEST_GLOBAL__" in globalThis || typeof window !== "undefined" && "Cypress" in window || typeof process !== "undefined" && process.env && (process.env.VITEST || process.env.JEST_WORKER_ID || process.env.NODE_ENV === "test" || process.env.PLAYWRIGHT_TEST)));
761
761
  }
762
- /*#__PURE__*/
763
762
  function useRegleDevtoolsRegistry() {
764
763
  const loggedWarning = ref(false);
765
764
  const devtoolsApi = shallowRef();
@@ -767,6 +766,7 @@ function useRegleDevtoolsRegistry() {
767
766
  const watchers = shallowRef(/* @__PURE__ */ new Map());
768
767
  const idCounters = shallowRef(/* @__PURE__ */ new Map());
769
768
  const looseIdCounter = ref(0);
769
+ let pendingNotifyFrame;
770
770
  function setApi(api) {
771
771
  devtoolsApi.value = api;
772
772
  }
@@ -784,11 +784,17 @@ function useRegleDevtoolsRegistry() {
784
784
  componentName: options?.componentName,
785
785
  filePath: options?.filePath
786
786
  });
787
- const stopHandle = watch(() => r$, () => notifyDevtools(), {
787
+ const stopHandle = watch([
788
+ () => r$.$value,
789
+ () => r$.$errors,
790
+ () => r$.$externalErrors,
791
+ () => r$.$issues,
792
+ () => r$.$externalIssues
793
+ ], () => scheduleNotifyDevtools(), {
788
794
  deep: true,
789
795
  flush: "post"
790
796
  });
791
- regleDevtoolsRegistry.addWatcher(id, stopHandle);
797
+ watchers.value.set(id, stopHandle);
792
798
  window.requestAnimationFrame(() => {
793
799
  notifyDevtools();
794
800
  });
@@ -797,6 +803,13 @@ function useRegleDevtoolsRegistry() {
797
803
  function notifyDevtools() {
798
804
  if (devtoolsApi.value) emitInspectorState(devtoolsApi.value);
799
805
  }
806
+ function scheduleNotifyDevtools() {
807
+ if (pendingNotifyFrame != null) return;
808
+ pendingNotifyFrame = window.requestAnimationFrame(() => {
809
+ pendingNotifyFrame = void 0;
810
+ notifyDevtools();
811
+ });
812
+ }
800
813
  function unregister(id) {
801
814
  const watcher = watchers.value.get(id);
802
815
  if (watcher) {
@@ -818,9 +831,6 @@ function useRegleDevtoolsRegistry() {
818
831
  instances.value.clear();
819
832
  notifyDevtools();
820
833
  }
821
- function addWatcher(id, stopHandle) {
822
- watchers.value.set(id, stopHandle);
823
- }
824
834
  return {
825
835
  devtoolsApi,
826
836
  register,
@@ -828,13 +838,11 @@ function useRegleDevtoolsRegistry() {
828
838
  getAll,
829
839
  get,
830
840
  clear,
831
- addWatcher,
832
841
  setApi,
833
842
  notifyDevtools,
834
843
  loggedWarning
835
844
  };
836
845
  }
837
- /*#__PURE__*/
838
846
  const regleDevtoolsRegistry = useRegleDevtoolsRegistry();
839
847
  /**
840
848
  * To be used by `useRegle` like composables.
@@ -1127,7 +1135,10 @@ function handleEditInspectorState(payload) {
1127
1135
  const instance = regleDevtoolsRegistry.get(instanceId);
1128
1136
  if (instance && instance.r$.$fields) {
1129
1137
  const fieldStatus = resolveFieldByPath(instance.r$.$fields, fieldPath);
1130
- if (fieldStatus && "$value" in fieldStatus) fieldStatus.$value = state.value;
1138
+ if (fieldStatus && "$value" in fieldStatus) {
1139
+ fieldStatus.$value = state.value;
1140
+ regleDevtoolsRegistry.notifyDevtools();
1141
+ }
1131
1142
  }
1132
1143
  }
1133
1144
  async function emitInspectorState(api) {
@@ -1357,7 +1368,7 @@ function filterInspectorTree(nodes, filter) {
1357
1368
  }
1358
1369
  return filtered;
1359
1370
  }
1360
- var version$1 = "1.26.1";
1371
+ var version$1 = "1.27.0-beta.2";
1361
1372
  function createDevtools(app) {
1362
1373
  setupDevtoolsPlugin({
1363
1374
  id: "regle-devtools",
@@ -1545,15 +1556,18 @@ function useStorage() {
1545
1556
  };
1546
1557
  }
1547
1558
  }
1548
- if (getCurrentScope()) onScopeDispose(() => {
1559
+ function clearAll() {
1549
1560
  ruleDeclStorage.value.clear();
1550
1561
  fieldsStorage.value.clear();
1551
1562
  collectionsStorage.value.clear();
1552
1563
  dirtyStorage.value.clear();
1553
1564
  ruleStatusStorage.value.clear();
1565
+ additionalRulesStorage.value.clear();
1554
1566
  arrayStatusStorage.value.clear();
1555
- });
1567
+ }
1568
+ if (getCurrentScope()) onScopeDispose(clearAll);
1556
1569
  return {
1570
+ clearAll,
1557
1571
  addRuleDeclEntry,
1558
1572
  setDirtyEntry,
1559
1573
  checkRuleDeclEntry,
@@ -1590,17 +1604,23 @@ function extractRulesIssues({ field, silent = false }) {
1590
1604
  })));
1591
1605
  return acc;
1592
1606
  }, []);
1593
- const externalIssues = field.$error && field.$externalErrors && Array.isArray(field.$externalErrors) ? field.$externalErrors.map((error) => ({
1607
+ const externalErrorIssues = field.$error && field.$externalErrors && Array.isArray(field.$externalErrors) && !field.$externalIssues?.length ? field.$externalErrors.map((error) => ({
1594
1608
  $message: error,
1595
1609
  $property: field.fieldName,
1596
1610
  $rule: "external",
1597
1611
  $type: void 0
1598
1612
  })) : [];
1613
+ const externalIssues = field.$error && field.$externalIssues && Array.isArray(field.$externalIssues) ? field.$externalIssues.map((issue) => ({
1614
+ ...issue,
1615
+ $property: issue.$property ?? field.fieldName,
1616
+ $rule: issue.$rule ?? "external"
1617
+ })) : [];
1599
1618
  let schemaIssues = [];
1600
1619
  if (field.$schemaErrors && field.$error) if (!Array.isArray(field.$schemaErrors) && "$self" in field.$schemaErrors) schemaIssues = field.$schemaErrors.$self ?? [];
1601
1620
  else schemaIssues = field.$schemaErrors ?? [];
1602
1621
  return [
1603
1622
  ...ruleIssues,
1623
+ ...externalErrorIssues,
1604
1624
  ...externalIssues,
1605
1625
  ...schemaIssues
1606
1626
  ];
@@ -1891,7 +1911,7 @@ function shouldApplyFieldImmediateDirty(mode, value, rootValue, isRootField = fa
1891
1911
  return false;
1892
1912
  }
1893
1913
  const DEFAULT_DEBOUNCE_TIME = 200;
1894
- function createReactiveFieldStatus({ state, rulesDef, customMessages, path, cachePath, fieldName, storage, options, externalErrors, schemaErrors, schemaMode, onUnwatch, $isArray, initialState, rootInitialState, originalState, shortcuts, overrides, onValidate }) {
1914
+ function createReactiveFieldStatus({ state, rulesDef, customMessages, path, cachePath, fieldName, storage, options, externalErrors, externalIssues, schemaErrors, schemaMode, onUnwatch, $isArray, initialState, rootInitialState, originalState, shortcuts, overrides, onValidate }) {
1895
1915
  let scope = effectScope();
1896
1916
  let scopeState;
1897
1917
  let fieldScopes = [];
@@ -2074,6 +2094,7 @@ function createReactiveFieldStatus({ state, rulesDef, customMessages, path, cach
2074
2094
  $rules: $rules.value,
2075
2095
  $error: $error.value,
2076
2096
  $externalErrors: externalErrors?.value,
2097
+ $externalIssues: externalIssues?.value,
2077
2098
  $schemaErrors: schemaErrors?.value,
2078
2099
  fieldName: $name.value
2079
2100
  } });
@@ -2084,6 +2105,7 @@ function createReactiveFieldStatus({ state, rulesDef, customMessages, path, cach
2084
2105
  $rules: $rules.value,
2085
2106
  $error: $error.value,
2086
2107
  $externalErrors: externalErrors?.value,
2108
+ $externalIssues: externalIssues?.value,
2087
2109
  $schemaErrors: schemaErrors?.value,
2088
2110
  fieldName: $name.value
2089
2111
  },
@@ -2122,7 +2144,7 @@ function createReactiveFieldStatus({ state, rulesDef, customMessages, path, cach
2122
2144
  return false;
2123
2145
  });
2124
2146
  const $invalid = computed(() => {
2125
- if (externalErrors?.value?.length || schemaErrors?.value?.length) return true;
2147
+ if (externalErrors?.value?.length || externalIssues?.value?.length || schemaErrors?.value?.length) return true;
2126
2148
  else if ($inactive.value) return false;
2127
2149
  else return Object.values($rules.value).some((ruleResult) => !ruleResult.$valid || ruleResult.$maybePending);
2128
2150
  });
@@ -2131,7 +2153,7 @@ function createReactiveFieldStatus({ state, rulesDef, customMessages, path, cach
2131
2153
  return !schemaMode && !Object.keys($rules.value).some((key) => !key.startsWith("$"));
2132
2154
  });
2133
2155
  const $correct = computed(() => {
2134
- if (externalErrors?.value?.length) return false;
2156
+ if (externalErrors?.value?.length || externalIssues?.value?.length) return false;
2135
2157
  else if ($inactive.value) return false;
2136
2158
  else if ($isDebouncing.value) return false;
2137
2159
  else if ($dirty.value && !isEmpty(state.value) && !$validating.value && !$pending.value) if (schemaMode) return !schemaErrors?.value?.length;
@@ -2170,6 +2192,7 @@ function createReactiveFieldStatus({ state, rulesDef, customMessages, path, cach
2170
2192
  result.value = value(reactive({
2171
2193
  $dirty,
2172
2194
  $externalErrors: externalErrors?.value ?? [],
2195
+ $externalIssues: externalIssues?.value ?? [],
2173
2196
  $value: state,
2174
2197
  $silentValue,
2175
2198
  $rules,
@@ -2258,7 +2281,10 @@ function createReactiveFieldStatus({ state, rulesDef, customMessages, path, cach
2258
2281
  }
2259
2282
  if (rulesDef.value instanceof Function) createReactiveRulesResult();
2260
2283
  if (!scopeState.$silent.value || scopeState.$rewardEarly.value && scopeState.$error.value) $commit();
2261
- if (scopeState.$clearExternalErrorsOnChange.value) $clearExternalErrors();
2284
+ if (scopeState.$clearExternalErrorsOnChange.value) {
2285
+ $clearExternalErrors();
2286
+ $clearExternalIssues();
2287
+ }
2262
2288
  }, { deep: scopeState.$isArrayOrRegleStatic.value ? true : isVueSuperiorOrEqualTo3dotFive ? 1 : true });
2263
2289
  }
2264
2290
  async function $commitHandler() {
@@ -2276,6 +2302,7 @@ function createReactiveFieldStatus({ state, rulesDef, customMessages, path, cach
2276
2302
  function $reset(options, fromParent) {
2277
2303
  abortCommit();
2278
2304
  $clearExternalErrors();
2305
+ $clearExternalIssues();
2279
2306
  scopeState.$dirty.value = false;
2280
2307
  storage.setDirtyEntry(cachePath, false);
2281
2308
  if (!fromParent) if (options?.toOriginalState) {
@@ -2289,7 +2316,10 @@ function createReactiveFieldStatus({ state, rulesDef, customMessages, path, cach
2289
2316
  initialState.value = cloneDeep(newInitialState);
2290
2317
  state.value = cloneDeep(newInitialState);
2291
2318
  } else initialState.value = isObject(state.value) && !isStatic(state.value) ? cloneDeep(state.value) : Array.isArray(state.value) ? [...state.value] : state.value;
2292
- if (options?.clearExternalErrors) $clearExternalErrors();
2319
+ if (options?.clearExternalErrors) {
2320
+ $clearExternalErrors();
2321
+ $clearExternalIssues();
2322
+ }
2293
2323
  if (!fromParent && !options?.keepValidationState) for (const rule of Object.values($rules.value)) rule.$reset();
2294
2324
  if (!scopeState.$lazy.value && !scopeState.$silent.value && !fromParent) for (const rule of Object.values($rules.value)) rule.$parse();
2295
2325
  applyImmediateDirty();
@@ -2337,6 +2367,10 @@ function createReactiveFieldStatus({ state, rulesDef, customMessages, path, cach
2337
2367
  issues: scopeState.$issues.value
2338
2368
  };
2339
2369
  const data = state.value;
2370
+ if (scopeState.$clearExternalErrorsOnValidate.value) {
2371
+ $clearExternalErrors();
2372
+ $clearExternalIssues();
2373
+ }
2340
2374
  if (scopeState.$autoDirty.value && !scopeState.$silent.value && scopeState.$dirty.value && !scopeState.$validating.value && !scopeState.$pending.value && !$isDebouncing.value && !isEmpty($rules.value)) return {
2341
2375
  valid: !scopeState.$invalid.value,
2342
2376
  data,
@@ -2380,6 +2414,10 @@ function createReactiveFieldStatus({ state, rulesDef, customMessages, path, cach
2380
2414
  if (forceValues) state.value = forceValues;
2381
2415
  if (!scopeState.$dirty.value) scopeState.$dirty.value = true;
2382
2416
  if (schemaMode) return false;
2417
+ if (scopeState.$clearExternalErrorsOnValidate.value) {
2418
+ $clearExternalErrors();
2419
+ $clearExternalIssues();
2420
+ }
2383
2421
  return Object.values($rules.value).map((rule) => rule.$parseSync()).every((result) => !!result);
2384
2422
  } catch {
2385
2423
  return false;
@@ -2392,16 +2430,25 @@ function createReactiveFieldStatus({ state, rulesDef, customMessages, path, cach
2392
2430
  }
2393
2431
  function $setExternalErrors(errors) {
2394
2432
  if (externalErrors) externalErrors.value = errors;
2433
+ $clearExternalIssues();
2395
2434
  }
2396
2435
  function $clearExternalErrors() {
2397
2436
  if (externalErrors?.value?.length) externalErrors.value = [];
2398
2437
  }
2438
+ function $setExternalIssues(issues) {
2439
+ if (externalIssues) externalIssues.value = issues;
2440
+ $clearExternalErrors();
2441
+ }
2442
+ function $clearExternalIssues() {
2443
+ if (externalIssues?.value?.length) externalIssues.value = [];
2444
+ }
2399
2445
  if (!scopeState.$lazy.value && !scopeState.$dirty.value && !scopeState.$silent.value) $commitHandler();
2400
2446
  applyImmediateDirty();
2401
2447
  const { $shortcuts, $validating, $autoDirty, $rewardEarly, $clearExternalErrorsOnChange, $clearExternalErrorsOnValidate, $haveAnyAsyncRule, $debounce, $lazy, ...restScope } = scopeState;
2402
2448
  const fullStatus = reactive({
2403
2449
  ...restScope,
2404
2450
  $externalErrors: externalErrors,
2451
+ $externalIssues: externalIssues,
2405
2452
  $value: state,
2406
2453
  $output: state,
2407
2454
  $initialValue: initialState,
@@ -2419,18 +2466,20 @@ function createReactiveFieldStatus({ state, rulesDef, customMessages, path, cach
2419
2466
  $watch,
2420
2467
  $extractDirtyFields,
2421
2468
  $clearExternalErrors,
2469
+ $clearExternalIssues,
2422
2470
  $abort,
2423
2471
  $addRules,
2424
2472
  addRules,
2425
2473
  $schemaMode: schemaMode,
2426
2474
  "~modifiers": scopeState.$modifiers,
2427
2475
  $setExternalErrors,
2476
+ $setExternalIssues,
2428
2477
  ...createStandardSchema($validate)
2429
2478
  });
2430
2479
  Object.defineProperty(fullStatus, Symbol.for("regle:instance"), { value: true });
2431
2480
  return fullStatus;
2432
2481
  }
2433
- function createCollectionElement({ $id, path, cachePath, index, options, storage, stateValue, customMessages, rules, externalErrors, schemaErrors, initialState, originalState, shortcuts, fieldName, schemaMode, overrides, currentIndexes }) {
2482
+ function createCollectionElement({ $id, path, cachePath, index, options, storage, stateValue, customMessages, rules, externalErrors, externalIssues, schemaErrors, initialState, originalState, shortcuts, fieldName, schemaMode, overrides, currentIndexes }) {
2434
2483
  const computedRules = computed(() => toValue(rules));
2435
2484
  const $fieldId = stateValue.value?.$id ?? computedRules.value.$key ?? randomId();
2436
2485
  let $cachePath = `${cachePath}.${String($fieldId)}`;
@@ -2455,6 +2504,7 @@ function createCollectionElement({ $id, path, cachePath, index, options, storage
2455
2504
  storage,
2456
2505
  options,
2457
2506
  externalErrors: toRef(externalErrors?.value ?? [], index),
2507
+ externalIssues: toRef(externalIssues?.value ?? [], index),
2458
2508
  schemaErrors: computed(() => schemaErrors?.value?.[currentIndex.value]),
2459
2509
  initialState,
2460
2510
  originalState,
@@ -2471,7 +2521,7 @@ function createCollectionElement({ $id, path, cachePath, index, options, storage
2471
2521
  if (stateValue.value && (!isObject(stateValue.value) || isStatic(stateValue.value)) && schemaMode) $status?.$touch();
2472
2522
  return $status;
2473
2523
  }
2474
- function createReactiveCollectionStatus({ state, rulesDef, customMessages, path, cachePath, storage, options, externalErrors, schemaErrors, schemaMode, initialState, originalState, shortcuts, fieldName, overrides }) {
2524
+ function createReactiveCollectionStatus({ state, rulesDef, customMessages, path, cachePath, storage, options, externalErrors, externalIssues, schemaErrors, schemaMode, initialState, originalState, shortcuts, fieldName, overrides }) {
2475
2525
  let scope = effectScope();
2476
2526
  let scopeState;
2477
2527
  let immediateScope = effectScope();
@@ -2515,6 +2565,7 @@ function createReactiveCollectionStatus({ state, rulesDef, customMessages, path,
2515
2565
  if (scope) collectionScopes.push(scope);
2516
2566
  const initialStateRef = toRef(initialState.value ?? [], index);
2517
2567
  const $externalErrors = toRef(externalErrors?.value ?? {}, `$each`);
2568
+ const $externalIssues = toRef(externalIssues?.value ?? {}, `$each`);
2518
2569
  const $schemaErrors = computed(() => schemaErrors?.value?.$each);
2519
2570
  const element = createCollectionElement({
2520
2571
  $id: $id.value,
@@ -2527,6 +2578,7 @@ function createReactiveCollectionStatus({ state, rulesDef, customMessages, path,
2527
2578
  options,
2528
2579
  storage,
2529
2580
  externalErrors: $externalErrors,
2581
+ externalIssues: $externalIssues,
2530
2582
  schemaErrors: $schemaErrors,
2531
2583
  initialState: initialStateRef,
2532
2584
  originalState,
@@ -2552,6 +2604,7 @@ function createReactiveCollectionStatus({ state, rulesDef, customMessages, path,
2552
2604
  storage,
2553
2605
  options,
2554
2606
  externalErrors: toRef(externalErrors?.value ?? {}, `$self`),
2607
+ externalIssues: toRef(externalIssues?.value ?? {}, `$self`),
2555
2608
  schemaErrors: computed(() => schemaErrors?.value?.$self),
2556
2609
  $isArray: true,
2557
2610
  initialState,
@@ -2582,6 +2635,7 @@ function createReactiveCollectionStatus({ state, rulesDef, customMessages, path,
2582
2635
  const { scope, unwrapped } = unwrapGetter(rulesDef.value.$each, currentValue, index);
2583
2636
  if (scope) collectionScopes.push(scope);
2584
2637
  const $externalErrors = toRef(externalErrors?.value ?? {}, `$each`);
2638
+ const $externalIssues = toRef(externalIssues?.value ?? {}, `$each`);
2585
2639
  const $schemaErrors = computed(() => schemaErrors?.value?.$each ?? []);
2586
2640
  const element = createCollectionElement({
2587
2641
  $id: $id.value,
@@ -2594,6 +2648,7 @@ function createReactiveCollectionStatus({ state, rulesDef, customMessages, path,
2594
2648
  options,
2595
2649
  storage,
2596
2650
  externalErrors: $externalErrors,
2651
+ externalIssues: $externalIssues,
2597
2652
  schemaErrors: $schemaErrors,
2598
2653
  initialState: toRef(initialState.value ?? [], index),
2599
2654
  originalState,
@@ -2854,7 +2909,10 @@ function createReactiveCollectionStatus({ state, rulesDef, customMessages, path,
2854
2909
  initialState.value = cloneDeep(newInitialState);
2855
2910
  state.value = cloneDeep(newInitialState);
2856
2911
  } else initialState.value = cloneDeep(state.value);
2857
- if (options?.clearExternalErrors) $clearExternalErrors();
2912
+ if (options?.clearExternalErrors) {
2913
+ $clearExternalErrors();
2914
+ $clearExternalIssues();
2915
+ }
2858
2916
  if (!options?.keepValidationState) {
2859
2917
  $selfStatus.value.$reset(options, fromParent);
2860
2918
  $eachStatus.value.forEach(($each) => {
@@ -2915,7 +2973,8 @@ function createReactiveCollectionStatus({ state, rulesDef, customMessages, path,
2915
2973
  }
2916
2974
  }
2917
2975
  function $setExternalErrors(errors) {
2918
- if (externalErrors?.value) externalErrors.value = errors;
2976
+ if (externalErrors) externalErrors.value = errors;
2977
+ $clearExternalIssues();
2919
2978
  }
2920
2979
  function $clearExternalErrors() {
2921
2980
  $selfStatus.value.$clearExternalErrors();
@@ -2923,6 +2982,16 @@ function createReactiveCollectionStatus({ state, rulesDef, customMessages, path,
2923
2982
  $each.$clearExternalErrors();
2924
2983
  });
2925
2984
  }
2985
+ function $setExternalIssues(issues) {
2986
+ if (externalIssues) externalIssues.value = issues;
2987
+ $clearExternalErrors();
2988
+ }
2989
+ function $clearExternalIssues() {
2990
+ $selfStatus.value.$clearExternalIssues();
2991
+ $eachStatus.value.forEach(($each) => {
2992
+ $each.$clearExternalIssues();
2993
+ });
2994
+ }
2926
2995
  function $extractDirtyFields(filterNullishValues = true) {
2927
2996
  let dirtyFields = $eachStatus.value.map(($each) => {
2928
2997
  if (isNestedRulesStatus($each)) return $each.$extractDirtyFields(filterNullishValues);
@@ -2955,20 +3024,22 @@ function createReactiveCollectionStatus({ state, rulesDef, customMessages, path,
2955
3024
  $abort,
2956
3025
  $extractDirtyFields,
2957
3026
  $clearExternalErrors,
3027
+ $clearExternalIssues,
2958
3028
  $setExternalErrors,
3029
+ $setExternalIssues,
2959
3030
  "~modifiers": scopeState.$modifiers,
2960
3031
  ...createStandardSchema($validate)
2961
3032
  });
2962
3033
  }
2963
- function createReactiveNestedStatus({ rulesDef, state, path = "", cachePath, rootRules, externalErrors, schemaErrors, rootInitialState, rootSchemaErrors, validationGroups, initialState, originalState, fieldName, nestedReactiveRules, ...commonArgs }) {
3034
+ function createReactiveNestedStatus({ rulesDef, state, path = "", cachePath, rootRules, externalErrors, externalIssues, schemaErrors, rootInitialState, rootSchemaErrors, validationGroups, initialState, originalState, fieldName, nestedReactiveRules, ...commonArgs }) {
2964
3035
  let scope = effectScope();
2965
3036
  let scopeState;
2966
3037
  let nestedScopes = [];
2967
3038
  let $unwatchRules = null;
2968
3039
  let $unwatchSchemaErrors = null;
2969
3040
  let $unwatchExternalErrors = null;
3041
+ let $unwatchExternalIssues = null;
2970
3042
  let $unwatchState = null;
2971
- let $unwatchGroups = null;
2972
3043
  const $selfStatus = ref(void 0);
2973
3044
  async function createReactiveFieldsStatus(watchSources = true) {
2974
3045
  const mapOfRulesDef = Object.entries(rulesDef.value).filter(([key]) => key !== "$self");
@@ -2977,6 +3048,7 @@ function createReactiveNestedStatus({ rulesDef, state, path = "", cachePath, roo
2977
3048
  const stateRef = toRef(state.value ?? {}, statePropKey);
2978
3049
  const statePropRulesRef = toRef(() => statePropRules);
2979
3050
  const $externalErrors = toRef(externalErrors?.value ?? {}, statePropKey);
3051
+ const $externalIssues = toRef(externalIssues?.value ?? {}, statePropKey);
2980
3052
  const $schemaErrors = computed(() => schemaErrors?.value?.[statePropKey]);
2981
3053
  const initialStateRef = toRef(initialState?.value ?? {}, statePropKey);
2982
3054
  acc.push([statePropKey, createReactiveChildrenStatus({
@@ -2985,6 +3057,7 @@ function createReactiveNestedStatus({ rulesDef, state, path = "", cachePath, roo
2985
3057
  path: path ? `${path}.${statePropKey}` : statePropKey,
2986
3058
  cachePath: cachePath ? `${cachePath}.${statePropKey}` : statePropKey,
2987
3059
  externalErrors: $externalErrors,
3060
+ externalIssues: $externalIssues,
2988
3061
  schemaErrors: $schemaErrors,
2989
3062
  initialState: initialStateRef,
2990
3063
  originalState: originalState?.[statePropKey],
@@ -2993,9 +3066,10 @@ function createReactiveNestedStatus({ rulesDef, state, path = "", cachePath, roo
2993
3066
  })]);
2994
3067
  return acc;
2995
3068
  }, []));
2996
- const externalRulesStatus = Object.fromEntries(Object.entries(toValue(externalErrors) ?? {}).filter(([key, errors]) => !(key in rulesDef.value) && !!errors).map(([key]) => {
3069
+ const externalRulesStatus = Object.fromEntries(Array.from(new Set([...Object.keys(toValue(externalErrors) ?? {}), ...Object.keys(toValue(externalIssues) ?? {})])).filter((key) => !(key in rulesDef.value)).map((key) => {
2997
3070
  const stateRef = toRef(state.value ?? {}, key);
2998
3071
  const $externalErrors = toRef(externalErrors?.value ?? {}, key);
3072
+ const $externalIssues = toRef(externalIssues?.value ?? {}, key);
2999
3073
  const $schemaErrors = computed(() => schemaErrors?.value?.[key]);
3000
3074
  const initialStateRef = toRef(initialState?.value ?? {}, key);
3001
3075
  const computedPath = path ? `${path}.${key}` : key;
@@ -3006,6 +3080,7 @@ function createReactiveNestedStatus({ rulesDef, state, path = "", cachePath, roo
3006
3080
  path: computedPath,
3007
3081
  cachePath: computedCachePath,
3008
3082
  externalErrors: $externalErrors,
3083
+ externalIssues: $externalIssues,
3009
3084
  schemaErrors: $schemaErrors,
3010
3085
  initialState: initialStateRef,
3011
3086
  originalState: originalState?.[key],
@@ -3018,6 +3093,7 @@ function createReactiveNestedStatus({ rulesDef, state, path = "", cachePath, roo
3018
3093
  const computedCachePath = cachePath ? `${cachePath}.${key}` : key;
3019
3094
  const stateRef = toRef(state.value ?? {}, key);
3020
3095
  const $externalErrors = toRef(externalErrors?.value ?? {}, key);
3096
+ const $externalIssues = toRef(externalIssues?.value ?? {}, key);
3021
3097
  const $schemaErrors = computed(() => schemaErrors?.value?.[key]);
3022
3098
  const initialStateRef = toRef(initialState?.value ?? {}, key);
3023
3099
  return [key, createReactiveChildrenStatus({
@@ -3026,6 +3102,7 @@ function createReactiveNestedStatus({ rulesDef, state, path = "", cachePath, roo
3026
3102
  path: computedPath,
3027
3103
  cachePath: computedCachePath,
3028
3104
  externalErrors: $externalErrors,
3105
+ externalIssues: $externalIssues,
3029
3106
  schemaErrors: $schemaErrors,
3030
3107
  initialState: initialStateRef,
3031
3108
  originalState: originalState?.[key],
@@ -3036,6 +3113,7 @@ function createReactiveNestedStatus({ rulesDef, state, path = "", cachePath, roo
3036
3113
  const statesWithNoRules = Object.fromEntries(Object.entries(state.value ?? {}).filter(([key]) => !(key in rulesDef.value) && !(key in (externalRulesStatus ?? {})) && !(key in (schemasRulesStatus ?? {}))).map(([key]) => {
3037
3114
  const stateRef = toRef(state.value ?? {}, key);
3038
3115
  const $externalErrors = toRef(externalErrors?.value ?? {}, key);
3116
+ const $externalIssues = toRef(externalIssues?.value ?? {}, key);
3039
3117
  const $schemaErrors = computed(() => schemaErrors?.value?.[key]);
3040
3118
  const initialStateRef = toRef(initialState?.value ?? {}, key);
3041
3119
  return [key, createReactiveChildrenStatus({
@@ -3044,6 +3122,7 @@ function createReactiveNestedStatus({ rulesDef, state, path = "", cachePath, roo
3044
3122
  path: path ? `${path}.${key}` : key,
3045
3123
  cachePath: cachePath ? `${cachePath}.${key}` : key,
3046
3124
  externalErrors: $externalErrors,
3125
+ externalIssues: $externalIssues,
3047
3126
  schemaErrors: $schemaErrors,
3048
3127
  initialState: initialStateRef,
3049
3128
  originalState: originalState?.[key],
@@ -3066,9 +3145,10 @@ function createReactiveNestedStatus({ rulesDef, state, path = "", cachePath, roo
3066
3145
  path,
3067
3146
  cachePath,
3068
3147
  externalErrors: ref(void 0),
3148
+ externalIssues: ref(void 0),
3069
3149
  schemaErrors: ref(void 0),
3070
- initialState: toRef(initialState?.value ?? {}, `$self`),
3071
- originalState: originalState?.[`$self`],
3150
+ initialState: initialState ?? ref(void 0),
3151
+ originalState,
3072
3152
  fieldName: `$self`,
3073
3153
  ...commonArgs
3074
3154
  });
@@ -3082,11 +3162,21 @@ function createReactiveNestedStatus({ rulesDef, state, path = "", cachePath, roo
3082
3162
  createReactiveFieldsStatus();
3083
3163
  }, { deep: true });
3084
3164
  }
3165
+ function define$WatchExternalIssues() {
3166
+ if (externalIssues) $unwatchExternalIssues = watch(externalIssues, () => {
3167
+ $unwatch();
3168
+ createReactiveFieldsStatus();
3169
+ }, { deep: true });
3170
+ }
3085
3171
  function define$watchState() {
3086
3172
  $unwatchState = watch(state, () => {
3087
3173
  $unwatch();
3088
3174
  createReactiveFieldsStatus();
3089
3175
  if (scopeState.$autoDirty.value && !scopeState.$silent.value) $touch(false, true);
3176
+ if (scopeState.$clearExternalErrorsOnChange.value) {
3177
+ $clearExternalErrors();
3178
+ $clearExternalIssues();
3179
+ }
3090
3180
  }, { flush: "post" });
3091
3181
  }
3092
3182
  function $watch() {
@@ -3100,6 +3190,7 @@ function createReactiveNestedStatus({ rulesDef, state, path = "", cachePath, roo
3100
3190
  flush: "pre"
3101
3191
  });
3102
3192
  define$WatchExternalErrors();
3193
+ define$WatchExternalIssues();
3103
3194
  }
3104
3195
  if (rootSchemaErrors) {
3105
3196
  $unwatchSchemaErrors?.();
@@ -3117,6 +3208,10 @@ function createReactiveNestedStatus({ rulesDef, state, path = "", cachePath, roo
3117
3208
  state.value = value;
3118
3209
  createReactiveFieldsStatus();
3119
3210
  if (scopeState.$autoDirty.value && !scopeState.$silent.value) $touch(false, true);
3211
+ if (scopeState.$clearExternalErrorsOnChange.value) {
3212
+ $clearExternalErrors();
3213
+ $clearExternalIssues();
3214
+ }
3120
3215
  }
3121
3216
  });
3122
3217
  const $output = readonly($value);
@@ -3196,7 +3291,7 @@ function createReactiveNestedStatus({ rulesDef, state, path = "", cachePath, roo
3196
3291
  });
3197
3292
  const $clearExternalErrorsOnChange = computed(() => {
3198
3293
  if (toValue(commonArgs.options.clearExternalErrorsOnChange) != null) return toValue(commonArgs.options.clearExternalErrorsOnChange) === true;
3199
- return false;
3294
+ return true;
3200
3295
  });
3201
3296
  const $clearExternalErrorsOnValidate = computed(() => {
3202
3297
  if (toValue(commonArgs.options.clearExternalErrorsOnValidate) != null) return toValue(commonArgs.options.clearExternalErrorsOnValidate) === true;
@@ -3321,6 +3416,7 @@ function createReactiveNestedStatus({ rulesDef, state, path = "", cachePath, roo
3321
3416
  $errors,
3322
3417
  $silentErrors,
3323
3418
  $clearExternalErrorsOnValidate,
3419
+ $clearExternalErrorsOnChange,
3324
3420
  $ready,
3325
3421
  $name,
3326
3422
  $shortcuts,
@@ -3341,19 +3437,28 @@ function createReactiveNestedStatus({ rulesDef, state, path = "", cachePath, roo
3341
3437
  function $unwatch() {
3342
3438
  $unwatchRules?.();
3343
3439
  $unwatchExternalErrors?.();
3440
+ $unwatchExternalIssues?.();
3344
3441
  $unwatchState?.();
3345
- $unwatchGroups?.();
3346
3442
  $unwatchSchemaErrors?.();
3443
+ nestedScopes.forEach((s) => s.stop());
3347
3444
  nestedScopes = [];
3348
3445
  scopeState = {};
3349
3446
  if ($fields.value) for (const field of Object.values($fields.value)) field?.$unwatch();
3350
3447
  }
3351
3448
  function $setExternalErrors(errors) {
3352
3449
  if (externalErrors) externalErrors.value = errors;
3450
+ $clearExternalIssues();
3353
3451
  }
3354
3452
  function $clearExternalErrors() {
3355
3453
  if (externalErrors && !isEmpty(externalErrors.value)) externalErrors.value = {};
3356
3454
  }
3455
+ function $setExternalIssues(issues) {
3456
+ if (externalIssues) externalIssues.value = issues;
3457
+ $clearExternalErrors();
3458
+ }
3459
+ function $clearExternalIssues() {
3460
+ if (externalIssues && !isEmpty(externalIssues.value)) externalIssues.value = {};
3461
+ }
3357
3462
  function applyImmediateDirty() {
3358
3463
  if (!scopeState) return;
3359
3464
  if (scopeState.$immediateDirty.value !== "lazy-non-empty" && shouldApplyImmediateDirty(scopeState.$immediateDirty.value, initialState.value, rootInitialState?.value ?? initialState.value)) $touch(true, false);
@@ -3376,8 +3481,12 @@ function createReactiveNestedStatus({ rulesDef, state, path = "", cachePath, roo
3376
3481
  for (const field of Object.values($fields.value)) field?.$reset(options, true);
3377
3482
  $selfStatus.value?.$reset(options, true);
3378
3483
  }
3379
- if (options?.clearExternalErrors === false) $clearExternalErrors();
3484
+ if (options?.clearExternalErrors === false) {
3485
+ $clearExternalErrors();
3486
+ $clearExternalIssues();
3487
+ }
3380
3488
  define$WatchExternalErrors();
3489
+ define$WatchExternalIssues();
3381
3490
  if (!fromParent) {
3382
3491
  createReactiveFieldsStatus();
3383
3492
  applyImmediateDirty();
@@ -3426,7 +3535,10 @@ function createReactiveNestedStatus({ rulesDef, state, path = "", cachePath, roo
3426
3535
  else {
3427
3536
  const data = state.value;
3428
3537
  $abort();
3429
- if (scopeState.$clearExternalErrorsOnValidate.value) $clearExternalErrors();
3538
+ if (scopeState.$clearExternalErrorsOnValidate.value) {
3539
+ $clearExternalErrors();
3540
+ $clearExternalIssues();
3541
+ }
3430
3542
  const validatePromises = [...Object.values($fields.value).map((statusOrField) => statusOrField.$validateWithoutRaceconditions()), ...$selfStatus.value ? [$selfStatus.value?.$validateWithoutRaceconditions()] : []];
3431
3543
  return {
3432
3544
  valid: (await Promise.allSettled(validatePromises)).every((value) => value.status === "fulfilled" && value?.value?.valid === true),
@@ -3455,7 +3567,10 @@ function createReactiveNestedStatus({ rulesDef, state, path = "", cachePath, roo
3455
3567
  function $validateSync(forceValues) {
3456
3568
  try {
3457
3569
  if (forceValues) state.value = forceValues;
3458
- if (scopeState.$clearExternalErrorsOnValidate.value) $clearExternalErrors();
3570
+ if (scopeState.$clearExternalErrorsOnValidate.value) {
3571
+ $clearExternalErrors();
3572
+ $clearExternalIssues();
3573
+ }
3459
3574
  return [...Object.values($fields.value).map((statusOrField) => statusOrField.$validateSync()), ...$selfStatus.value ? [$selfStatus.value?.$validateSync()] : []].every((result) => !!result);
3460
3575
  } catch {
3461
3576
  return false;
@@ -3471,6 +3586,7 @@ function createReactiveNestedStatus({ rulesDef, state, path = "", cachePath, roo
3471
3586
  $originalValue: originalState,
3472
3587
  $self: $selfStatus,
3473
3588
  $externalErrors: externalErrors,
3589
+ $externalIssues: externalIssues,
3474
3590
  $fields,
3475
3591
  $reset,
3476
3592
  $touch,
@@ -3478,7 +3594,9 @@ function createReactiveNestedStatus({ rulesDef, state, path = "", cachePath, roo
3478
3594
  $unwatch,
3479
3595
  $watch,
3480
3596
  $setExternalErrors,
3597
+ $setExternalIssues,
3481
3598
  $clearExternalErrors,
3599
+ $clearExternalIssues,
3482
3600
  $extractDirtyFields,
3483
3601
  $abort,
3484
3602
  $validateSync,
@@ -3528,6 +3646,89 @@ function createReactiveChildrenStatus({ rulesDef, ...properties }) {
3528
3646
  ...properties
3529
3647
  });
3530
3648
  }
3649
+ function normalizeExternalValue(value) {
3650
+ if (value && isObject(value) && Object.keys(value).some((key) => key.includes("."))) return dotPathObjectToNested(value);
3651
+ return value;
3652
+ }
3653
+ function hasExternalValue(value) {
3654
+ if (Array.isArray(value)) return value.length > 0;
3655
+ return isObject(value) && Object.keys(value).length > 0;
3656
+ }
3657
+ function emptyExternalValue(value) {
3658
+ return Array.isArray(value) ? [] : {};
3659
+ }
3660
+ function createExternalChannels(options) {
3661
+ const externalErrors = ref();
3662
+ const externalIssues = ref();
3663
+ let unwatchOptionErrors;
3664
+ let unwatchInternalErrors;
3665
+ let unwatchOptionIssues;
3666
+ let unwatchInternalIssues;
3667
+ let syncing = false;
3668
+ function clearIssues() {
3669
+ const emptyIssues = emptyExternalValue(externalIssues.value ?? options.externalIssues?.value);
3670
+ externalIssues.value = emptyIssues;
3671
+ if (options.externalIssues) options.externalIssues.value = emptyIssues;
3672
+ }
3673
+ function clearErrors() {
3674
+ const emptyErrors = emptyExternalValue(externalErrors.value ?? options.externalErrors?.value);
3675
+ externalErrors.value = emptyErrors;
3676
+ if (options.externalErrors) options.externalErrors.value = emptyErrors;
3677
+ }
3678
+ function syncErrors(newErrors, updateOptionRef = false) {
3679
+ if (syncing) return;
3680
+ syncing = true;
3681
+ const normalizedErrors = normalizeExternalValue(newErrors);
3682
+ externalErrors.value = normalizedErrors;
3683
+ if (updateOptionRef && options.externalErrors) options.externalErrors.value = normalizedErrors;
3684
+ if (hasExternalValue(normalizedErrors)) clearIssues();
3685
+ syncing = false;
3686
+ }
3687
+ function syncIssues(newIssues, updateOptionRef = false) {
3688
+ if (syncing) return;
3689
+ syncing = true;
3690
+ const normalizedIssues = normalizeExternalValue(newIssues);
3691
+ externalIssues.value = normalizedIssues;
3692
+ if (updateOptionRef && options.externalIssues) options.externalIssues.value = normalizedIssues;
3693
+ if (hasExternalValue(normalizedIssues)) clearErrors();
3694
+ syncing = false;
3695
+ }
3696
+ function watchOptionRefs() {
3697
+ unwatchOptionErrors?.();
3698
+ unwatchOptionIssues?.();
3699
+ unwatchOptionErrors = watch(() => options.externalErrors?.value, (errors) => syncErrors(errors), { deep: true });
3700
+ unwatchOptionIssues = watch(() => options.externalIssues?.value, (issues) => syncIssues(issues), { deep: true });
3701
+ }
3702
+ function watchInternalRefs() {
3703
+ unwatchInternalErrors?.();
3704
+ unwatchInternalIssues?.();
3705
+ unwatchInternalErrors = watch(() => externalErrors.value, (errors) => syncErrors(errors, true), { deep: true });
3706
+ unwatchInternalIssues = watch(() => externalIssues.value, (issues) => syncIssues(issues, true), { deep: true });
3707
+ }
3708
+ function start() {
3709
+ stop();
3710
+ syncErrors(options.externalErrors?.value);
3711
+ syncIssues(options.externalIssues?.value);
3712
+ watchInternalRefs();
3713
+ }
3714
+ function stop() {
3715
+ unwatchInternalErrors?.();
3716
+ unwatchOptionErrors?.();
3717
+ unwatchInternalIssues?.();
3718
+ unwatchOptionIssues?.();
3719
+ unwatchInternalErrors = void 0;
3720
+ unwatchOptionErrors = void 0;
3721
+ unwatchInternalIssues = void 0;
3722
+ unwatchOptionIssues = void 0;
3723
+ }
3724
+ return {
3725
+ externalErrors,
3726
+ externalIssues,
3727
+ start,
3728
+ watchOptionRefs,
3729
+ stop
3730
+ };
3731
+ }
3531
3732
  /**
3532
3733
  * @internal
3533
3734
  * This is the internal function that creates the root storage for the Regle instance.
@@ -3539,37 +3740,18 @@ function useRootStorage({ initialState, originalState, options, scopeRules, stat
3539
3740
  const attachedScopes = /* @__PURE__ */ new Set();
3540
3741
  let rootScope;
3541
3742
  const regle = ref();
3542
- const computedExternalErrors = ref();
3543
- let $unwatchExternalErrors;
3544
- let $unwatchComputedExternalErrors;
3743
+ const externalChannels = createExternalChannels(options);
3545
3744
  let $unwatchDisabled;
3546
3745
  function defineDisabledWatchSource() {
3547
3746
  $unwatchDisabled = watch(() => toValue(options.disabled), async (disabled) => {
3548
3747
  if (disabled) unwatchRegle();
3549
3748
  else {
3550
3749
  createRegleInstance();
3551
- defineExternalErrorsWatchSource();
3750
+ externalChannels.start();
3751
+ externalChannels.watchOptionRefs();
3552
3752
  }
3553
3753
  });
3554
3754
  }
3555
- function handleExternalErrorsChange(newErrors) {
3556
- $unwatchComputedExternalErrors?.();
3557
- if (newErrors) if (isObject(newErrors) && Object.keys(newErrors).some((key) => key.includes("."))) computedExternalErrors.value = dotPathObjectToNested(newErrors);
3558
- else if (Array.isArray(newErrors)) computedExternalErrors.value = newErrors;
3559
- else computedExternalErrors.value = newErrors ?? {};
3560
- defineComputedExternalErrorsWatchSource();
3561
- }
3562
- function defineExternalErrorsWatchSource() {
3563
- $unwatchExternalErrors = watch(() => options.externalErrors?.value, handleExternalErrorsChange, { deep: true });
3564
- }
3565
- function defineComputedExternalErrorsWatchSource() {
3566
- $unwatchComputedExternalErrors = watch(() => computedExternalErrors.value, (newErrors) => {
3567
- $unwatchExternalErrors?.();
3568
- if (options.externalErrors?.value) options.externalErrors.value = newErrors;
3569
- handleExternalErrorsChange(newErrors);
3570
- defineExternalErrorsWatchSource();
3571
- }, { deep: true });
3572
- }
3573
3755
  function createRegleInstance() {
3574
3756
  if (isNestedRulesDef(state, scopeRules)) regle.value = createReactiveNestedStatus({
3575
3757
  rootRules: scopeRules,
@@ -3579,7 +3761,8 @@ function useRootStorage({ initialState, originalState, options, scopeRules, stat
3579
3761
  storage,
3580
3762
  options,
3581
3763
  rootInitialState: initialState,
3582
- externalErrors: computedExternalErrors,
3764
+ externalErrors: externalChannels.externalErrors,
3765
+ externalIssues: externalChannels.externalIssues,
3583
3766
  validationGroups: options.validationGroups,
3584
3767
  initialState,
3585
3768
  originalState,
@@ -3600,7 +3783,8 @@ function useRootStorage({ initialState, originalState, options, scopeRules, stat
3600
3783
  storage,
3601
3784
  options,
3602
3785
  rootInitialState: initialState,
3603
- externalErrors: computedExternalErrors,
3786
+ externalErrors: externalChannels.externalErrors,
3787
+ externalIssues: externalChannels.externalIssues,
3604
3788
  initialState,
3605
3789
  originalState,
3606
3790
  shortcuts,
@@ -3614,26 +3798,23 @@ function useRootStorage({ initialState, originalState, options, scopeRules, stat
3614
3798
  });
3615
3799
  }
3616
3800
  function clearWatchHandles() {
3617
- $unwatchComputedExternalErrors = void 0;
3618
- $unwatchExternalErrors = void 0;
3619
3801
  $unwatchDisabled = void 0;
3620
3802
  }
3621
3803
  function unwatchRegle() {
3622
3804
  regle.value?.$unwatch();
3623
- $unwatchComputedExternalErrors?.();
3624
- $unwatchExternalErrors?.();
3805
+ externalChannels.stop();
3625
3806
  }
3626
3807
  function startRootStorage() {
3627
3808
  if (isEnabled.value) return;
3628
3809
  isEnabled.value = true;
3629
3810
  rootScope = effectScope(true);
3630
3811
  rootScope.run(() => {
3631
- handleExternalErrorsChange(options.externalErrors?.value);
3812
+ externalChannels.start();
3632
3813
  createRegleInstance();
3633
3814
  if (toValue(options.disabled)) nextTick().then(() => {
3634
3815
  regle.value?.$unwatch();
3635
3816
  });
3636
- else defineExternalErrorsWatchSource();
3817
+ else externalChannels.watchOptionRefs();
3637
3818
  defineDisabledWatchSource();
3638
3819
  });
3639
3820
  }
@@ -3645,6 +3826,8 @@ function useRootStorage({ initialState, originalState, options, scopeRules, stat
3645
3826
  clearWatchHandles();
3646
3827
  rootScope?.stop();
3647
3828
  rootScope = void 0;
3829
+ regle.value = void 0;
3830
+ storage.clearAll();
3648
3831
  }
3649
3832
  function bindToCurrentScope() {
3650
3833
  const currentScope = getCurrentScope();
@@ -3733,7 +3916,9 @@ function createUseRegleComposable(options) {
3733
3916
  shortcuts,
3734
3917
  overrides
3735
3918
  });
3736
- return { r$: toReactive(regle, isDisabled, bindToCurrentScope) };
3919
+ return { r$: toReactive(regle, isDisabled, () => {
3920
+ if (!regle.value) bindToCurrentScope();
3921
+ }) };
3737
3922
  }
3738
3923
  return useRegle;
3739
3924
  }
@@ -3908,7 +4093,9 @@ function createUseRulesComposable(options) {
3908
4093
  shortcuts,
3909
4094
  overrides
3910
4095
  });
3911
- return toReactive(regle, isDisabled, bindToCurrentScope);
4096
+ return toReactive(regle, isDisabled, () => {
4097
+ if (!regle.value) bindToCurrentScope();
4098
+ });
3912
4099
  }
3913
4100
  return useRules;
3914
4101
  }
@@ -4275,11 +4462,21 @@ function mergeRegles(regles, _scoped) {
4275
4462
  regle.$setExternalErrors(errors);
4276
4463
  });
4277
4464
  }
4465
+ function $setExternalIssues(issues) {
4466
+ Object.values(regles).forEach((regle) => {
4467
+ regle.$setExternalIssues(issues);
4468
+ });
4469
+ }
4278
4470
  function $clearExternalErrors() {
4279
4471
  Object.values(regles).forEach((regle) => {
4280
4472
  regle.$clearExternalErrors();
4281
4473
  });
4282
4474
  }
4475
+ function $clearExternalIssues() {
4476
+ Object.values(regles).forEach((regle) => {
4477
+ regle.$clearExternalIssues();
4478
+ });
4479
+ }
4283
4480
  function $validateSync(forceValues) {
4284
4481
  try {
4285
4482
  if (forceValues) $value.value = forceValues;
@@ -4338,7 +4535,9 @@ function mergeRegles(regles, _scoped) {
4338
4535
  $validateSync,
4339
4536
  $extractDirtyFields,
4340
4537
  $clearExternalErrors,
4341
- $setExternalErrors
4538
+ $clearExternalIssues,
4539
+ $setExternalErrors,
4540
+ $setExternalIssues
4342
4541
  });
4343
4542
  watchEffect(() => {
4344
4543
  if (scoped) return;