@regle/schemas 1.12.0 → 1.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.
@@ -4,19 +4,19 @@ import * as vue0 from "vue";
4
4
  import { MaybeRef, Raw, UnwrapNestedRefs } from "vue";
5
5
  import { StandardSchemaV1 } from "@standard-schema/spec";
6
6
  import { EmptyObject, IsUnion, PartialDeep, UnionToTuple } from "type-fest";
7
- type MaybeSchemaVariantStatus<TState extends Record<string, any> | undefined = Record<string, any>, TShortcuts extends RegleShortcutDefinition = {}, TRoot extends boolean = false> = IsUnion<NonNullable<TState>> extends true ? Omit<RegleSchemaStatus<TState, TShortcuts, TRoot>, '$fields'> & {
7
+ type MaybeSchemaVariantStatus<TState extends Record<string, any> | undefined = Record<string, any>, TSchema extends StandardSchemaV1 = StandardSchemaV1, TShortcuts extends RegleShortcutDefinition = {}, TRoot extends boolean = false> = IsUnion<NonNullable<TState>> extends true ? Omit<RegleSchemaStatus<TState, TSchema, TShortcuts, TRoot>, '$fields'> & {
8
8
  $fields: ProcessChildrenFields<TState, TShortcuts>[keyof ProcessChildrenFields<TState, TShortcuts>];
9
- } & (HasNamedKeys<TState> extends true ? ProcessChildrenFields<TState, TShortcuts>[keyof ProcessChildrenFields<TState, TShortcuts>] : {}) : RegleSchemaStatus<TState, TShortcuts, TRoot>;
9
+ } & (HasNamedKeys<TState> extends true ? ProcessChildrenFields<TState, TShortcuts>[keyof ProcessChildrenFields<TState, TShortcuts>] : {}) : RegleSchemaStatus<TState, TSchema, TShortcuts, TRoot>;
10
10
  type ProcessChildrenFields<TState extends Record<string, any> | undefined, TShortcuts extends RegleShortcutDefinition = {}> = { [TIndex in keyof TupleToPlainObj<UnionToTuple<TState>>]: TIndex extends `${infer TIndexInt extends number}` ? { [TKey in keyof UnionToTuple<TState>[TIndexInt] as NonNullable<UnionToTuple<TState>[TIndexInt]>[TKey] extends UnionToTuple<TState>[TIndexInt][TKey] ? TKey : never]-?: InferRegleSchemaStatusType<NonNullable<UnionToTuple<TState>[TIndexInt]>[TKey], TShortcuts> } & { [TKey in keyof UnionToTuple<TState>[TIndexInt] as NonNullable<UnionToTuple<TState>[TIndexInt]>[TKey] extends UnionToTuple<TState>[TIndexInt][TKey] ? never : TKey]?: InferRegleSchemaStatusType<NonNullable<UnionToTuple<TState>[TIndexInt]>[TKey], TShortcuts> } : {} };
11
- type RegleSchema<TState extends Record<string, any>, TShortcuts extends RegleShortcutDefinition = {}, TAdditionalReturnProperties extends Record<string, any> = {}> = {
11
+ type RegleSchema<TState extends Record<string, any>, TSchema extends StandardSchemaV1, TShortcuts extends RegleShortcutDefinition = {}, TAdditionalReturnProperties extends Record<string, any> = {}> = {
12
12
  /**
13
13
  * r$ is a reactive object containing the values, errors, dirty state and all the necessary validations properties you'll need to display information.
14
14
  *
15
15
  * To see the list of properties: {@link https://reglejs.dev/core-concepts/validation-properties}
16
16
  */
17
- r$: Raw<MaybeSchemaVariantStatus<TState, TShortcuts, true>>;
17
+ r$: Raw<MaybeSchemaVariantStatus<TState, TSchema, TShortcuts, true>>;
18
18
  } & TAdditionalReturnProperties;
19
- type RegleSingleFieldSchema<TState extends Maybe<PrimitiveTypes>, TShortcuts extends RegleShortcutDefinition = {}, TAdditionalReturnProperties extends Record<string, any> = {}> = {
19
+ type RegleSingleFieldSchema<TState extends Maybe<PrimitiveTypes>, TSchema extends StandardSchemaV1, TShortcuts extends RegleShortcutDefinition = {}, TAdditionalReturnProperties extends Record<string, any> = {}> = {
20
20
  /**
21
21
  * r$ is a reactive object containing the values, errors, dirty state and all the necessary validations properties you'll need to display information.
22
22
  *
@@ -24,7 +24,7 @@ type RegleSingleFieldSchema<TState extends Maybe<PrimitiveTypes>, TShortcuts ext
24
24
  */
25
25
  r$: Raw<RegleSchemaFieldStatus<TState, TShortcuts> & {
26
26
  /** Sets all properties as dirty, triggering all rules. It returns a promise that will either resolve to false or a type safe copy of your form state. Values that had the required rule will be transformed into a non-nullable value (type only). */
27
- $validate: (forceValues?: TState extends EmptyObject ? any : HasNamedKeys<TState> extends true ? TState : any) => Promise<RegleSchemaResult<TState>>;
27
+ $validate: (forceValues?: TState extends EmptyObject ? any : HasNamedKeys<TState> extends true ? TState : any) => Promise<RegleSchemaResult<StandardSchemaV1.InferOutput<TSchema>>>;
28
28
  }>;
29
29
  } & TAdditionalReturnProperties;
30
30
  type RegleSchemaResult<TSchema extends unknown> = {
@@ -42,7 +42,7 @@ type ProcessNestedFields<TState extends Record<string, any> | undefined, TShortc
42
42
  /**
43
43
  * @public
44
44
  */
45
- type RegleSchemaStatus<TState extends Record<string, any> | undefined = Record<string, any>, TShortcuts extends RegleShortcutDefinition = {}, IsRoot extends boolean = false> = Omit<RegleCommonStatus<TState>, IsRoot extends false ? '$pending' : ''> & {
45
+ type RegleSchemaStatus<TState extends Record<string, any> | undefined = Record<string, any>, TSchema extends StandardSchemaV1 = StandardSchemaV1, TShortcuts extends RegleShortcutDefinition = {}, IsRoot extends boolean = false> = Omit<RegleCommonStatus<TState>, IsRoot extends false ? '$pending' : ''> & {
46
46
  /** Represents all the children of your object. You can access any nested child at any depth to get the relevant data you need for your form. */
47
47
  readonly $fields: ProcessNestedFields<TState, TShortcuts>;
48
48
  /** Collection of all issues, collected for all children properties and nested forms.
@@ -59,12 +59,12 @@ type RegleSchemaStatus<TState extends Record<string, any> | undefined = Record<s
59
59
  $extractDirtyFields: (filterNullishValues?: boolean) => PartialDeep<TState>;
60
60
  } & ProcessNestedFields<TState, TShortcuts> & (IsRoot extends true ? {
61
61
  /** Sets all properties as dirty, triggering all rules. It returns a promise that will either resolve to false or a type safe copy of your form state. Values that had the required rule will be transformed into a non-nullable value (type only). */
62
- $validate: (forceValues?: TState extends EmptyObject ? (HasNamedKeys<TState> extends true ? TState : any) : TState) => Promise<RegleSchemaResult<TState>>;
62
+ $validate: (forceValues?: TState extends EmptyObject ? (HasNamedKeys<TState> extends true ? TState : any) : TState) => Promise<RegleSchemaResult<StandardSchemaV1.InferOutput<TSchema>>>;
63
63
  } : {}) & ([TShortcuts['nested']] extends [never] ? {} : { [K in keyof TShortcuts['nested']]: ReturnType<NonNullable<TShortcuts['nested']>[K]> });
64
64
  /**
65
65
  * @public
66
66
  */
67
- type InferRegleSchemaStatusType<TState extends unknown, TShortcuts extends RegleShortcutDefinition = {}> = NonNullable<TState> extends Array<infer A> ? A extends Record<string, any> ? RegleSchemaCollectionStatus<NonNullable<TState>, TShortcuts> : RegleSchemaFieldStatus<TState, TShortcuts> : NonNullable<TState> extends Date | File ? RegleSchemaFieldStatus<TState, TShortcuts> : unknown extends TState ? RegleSchemaFieldStatus<TState extends EmptyObject ? unknown : TState, TShortcuts> : NonNullable<TState> extends Record<string, any> ? NonNullable<NonNullable<TState>> extends RegleStaticImpl<infer U> ? RegleSchemaFieldStatus<Raw<U>, TShortcuts> : MaybeSchemaVariantStatus<NonNullable<TState> extends Record<string, any> ? NonNullable<TState> : {}, TShortcuts> : RegleSchemaFieldStatus<TState, TShortcuts>;
67
+ type InferRegleSchemaStatusType<TState extends unknown, TShortcuts extends RegleShortcutDefinition = {}> = NonNullable<TState> extends Array<infer A> ? A extends Record<string, any> ? RegleSchemaCollectionStatus<NonNullable<TState>, TShortcuts> : RegleSchemaFieldStatus<TState, TShortcuts> : NonNullable<TState> extends Date | File ? RegleSchemaFieldStatus<TState, TShortcuts> : unknown extends TState ? RegleSchemaFieldStatus<TState extends EmptyObject ? unknown : TState, TShortcuts> : NonNullable<TState> extends Record<string, any> ? NonNullable<NonNullable<TState>> extends RegleStaticImpl<infer U> ? RegleSchemaFieldStatus<Raw<U>, TShortcuts> : MaybeSchemaVariantStatus<NonNullable<TState> extends Record<string, any> ? NonNullable<TState> : {}, StandardSchemaV1, TShortcuts> : RegleSchemaFieldStatus<TState, TShortcuts>;
68
68
  /**
69
69
  * @public
70
70
  */
@@ -151,7 +151,7 @@ interface useRegleSchemaFn<TShortcuts extends RegleShortcutDefinition<any> = nev
151
151
  recurseIntoArrays: true;
152
152
  }>> | DeepReactiveState<PartialDeep<NoInferLegacy<TState>, {
153
153
  recurseIntoArrays: true;
154
- }>>, rulesFactory: MaybeRef<TSchema>, ...(HaveAnyRequiredProps<useRegleSchemaFnOptions<TAdditionalOptions>> extends true ? [options: useRegleSchemaFnOptions<TAdditionalOptions>] : [options?: useRegleSchemaFnOptions<TAdditionalOptions>])]): NonNullable<TState> extends PrimitiveTypes ? RegleSingleFieldSchema<NonNullable<TState>, TShortcuts, TAdditionalReturnProperties> : RegleSchema<UnwrapNestedRefs<NonNullable<TState>>, TShortcuts, TAdditionalReturnProperties>;
154
+ }>>, rulesFactory: MaybeRef<TSchema>, ...(HaveAnyRequiredProps<useRegleSchemaFnOptions<TAdditionalOptions>> extends true ? [options: useRegleSchemaFnOptions<TAdditionalOptions>] : [options?: useRegleSchemaFnOptions<TAdditionalOptions>])]): NonNullable<TState> extends PrimitiveTypes ? RegleSingleFieldSchema<NonNullable<TState>, TSchema, TShortcuts, TAdditionalReturnProperties> : RegleSchema<UnwrapNestedRefs<NonNullable<TState>>, TSchema, TShortcuts, TAdditionalReturnProperties>;
155
155
  }
156
156
  /**
157
157
  * useRegle serves as the foundation for validation logic.
@@ -213,11 +213,13 @@ function createUseRegleSchemaComposable(options, shortcuts) {
213
213
  computeErrors();
214
214
  onValidate = async () => {
215
215
  try {
216
+ const result = await computeErrors(true);
217
+ regle?.regle?.$touch();
216
218
  return {
217
- valid: !(await computeErrors(true)).issues?.length,
219
+ valid: !result.issues?.length,
218
220
  data: processedState.value,
219
- errors: {},
220
- issues: {}
221
+ errors: regle?.regle?.$errors,
222
+ issues: customErrors.value
221
223
  };
222
224
  } catch (e) {
223
225
  return Promise.reject(e);
@@ -226,7 +228,7 @@ function createUseRegleSchemaComposable(options, shortcuts) {
226
228
  if (getCurrentScope()) onScopeDispose(() => {
227
229
  unWatchState();
228
230
  });
229
- return { r$: useRootStorage({
231
+ const regle = useRootStorage({
230
232
  scopeRules: computed(() => ({})),
231
233
  state: processedState,
232
234
  options: resolvedOptions,
@@ -236,7 +238,8 @@ function createUseRegleSchemaComposable(options, shortcuts) {
236
238
  shortcuts,
237
239
  schemaMode: true,
238
240
  onValidate
239
- }).regle };
241
+ });
242
+ return { r$: regle.regle };
240
243
  }
241
244
  return useRegleSchema$1;
242
245
  }
@@ -1 +1 @@
1
- import{createScopedUseRegle as e,useRootStorage as t}from"@regle/core";import{computed as n,getCurrentScope as r,isRef as i,onScopeDispose as a,ref as o,unref as s,watch as c}from"vue";function l(e){return e?.constructor?.name==`File`||e?.constructor?.name==`FileList`}function u(e,t=!0){return e==null?!0:e instanceof Date?isNaN(e.getTime()):l(e)?e.size<=0:Array.isArray(e)?t?e.length===0:!1:typeof e==`object`&&e?Object.keys(e).length===0:!String(e).length}function d(e){if(typeof e.source.flags==`string`)return e.source.flags;{let t=[];return e.global&&t.push(`g`),e.ignoreCase&&t.push(`i`),e.multiline&&t.push(`m`),e.sticky&&t.push(`y`),e.unicode&&t.push(`u`),t.join(``)}}function f(e,t=0){if(t>20)return e;let n=e,r={}.toString.call(e).slice(8,-1);if(r==`Set`&&(n=new Set([...e].map(e=>f(e,t++)))),r==`Map`&&(n=new Map([...e].map(e=>[f(e[0]),f(e[1])]))),r==`Date`&&(n=new Date(e.getTime())),r==`RegExp`&&(n=RegExp(e.source,d(e))),r==`Array`||r==`Object`)for(let r in n=Array.isArray(e)?[]:{},e)n[r]=f(e[r],t++);return n}function p(e){return e&&(e instanceof Date||e.constructor.name==`File`||e.constructor.name==`FileList`)?!1:typeof e==`object`&&!!e&&!Array.isArray(e)}function m(e,t,n,r){var i,a;if(Array.isArray(t)&&(i=t.slice(0)),typeof t==`string`&&(i=t.split(`.`)),typeof t==`symbol`&&(i=[t]),!Array.isArray(i))throw Error(`props arg must be an array, a string or a symbol`);if(a=i.pop(),!a)return!1;g(a);for(var o;o=i.shift();)if(g(o),isNaN(parseInt(o))?(e[o]===void 0&&(e[o]={}),e=e[o]):(e.$each??=[],u(e.$each[o])&&(e.$each[o]={}),e=e.$each[o]),!e||typeof e!=`object`)return!1;return r?e[a]?e[a].$self=(e[a].$self??=[]).concat(n):e[a]={$self:n}:Array.isArray(e[a])?e[a]=e[a].concat(n):e[a]=n,!0}function h(e,t,n){if(!e)return n;var r,i;if(Array.isArray(t)&&(r=t.slice(0)),typeof t==`string`&&(r=t.split(`.`)),typeof t==`symbol`&&(r=[t]),!Array.isArray(r))throw Error(`props arg must be an array, a string or a symbol`);for(;r.length;)if(i=r.shift(),!e||!i||(e=e[i],e===void 0))return n;return e}function g(e){if(e==`__proto__`||e==`constructor`||e==`prototype`)throw Error(`setting of prototype values not supported`)}function _(e,...t){for(var n=[].slice.call(arguments),r,i=n.length;r=n[i-1],i--;)if(!r||typeof r!=`object`&&typeof r!=`function`)throw Error(`expected object, got `+r);for(var a=n[0],o=n.slice(1),s=o.length,i=0;i<s;i++){var c=o[i];for(var l in c)a[l]=c[l]}return a}function v(e,l){let u={autoDirty:e?.autoDirty,lazy:e?.lazy,rewardEarly:e?.rewardEarly,clearExternalErrorsOnChange:e?.clearExternalErrorsOnChange};function d(e,d,g){let v=n(()=>s(d)),{syncState:y={onUpdate:!1,onValidate:!1},...b}=g??{},{onUpdate:x=!1,onValidate:S=!1}=y,C={...u,...b},w=n(()=>!p(T.value)),T=i(e)?e:o(e),E=o(p(T.value)?{...f(T.value)}:f(T.value)),D=p(T.value)?{...f(T.value)}:f(T.value),O=o({}),k=o([]),A;function j(e){return e.path?.map(e=>typeof e==`object`?e.key:e.toString()).join(`.`)??``}if(!v.value?.[`~standard`])throw Error(`Only "standard-schema" compatible libraries are supported`);function M(e,t=!1){return!t&&C.rewardEarly?k.value.length?k.value.filter(t=>e.some(e=>j(e)===j(t))):[]:e}function N(e,t=!1){let n={},r=M(e.issues??[],t);if(e.issues?.length){let e=r.map(e=>{let t=j(e),n=e.path?.[e.path.length-1],r=typeof n==`object`?n.key:n,i=(typeof n==`object`&&`value`in n?Array.isArray(n.value):!1)||(`type`in e?e.type===`array`:!1)||Array.isArray(h(T.value,t));return!i&&typeof r==`number`&&(t=e.path?.slice(0,e.path.length-1)?.map(e=>typeof e==`object`?e.key:e.toString()).join(`.`)??``),{...e,$path:t,isArray:i,$property:r,$rule:`schema`,$message:e.message}});e.forEach(({isArray:e,$path:t,...r})=>{m(n,t,[r],e)}),k.value=e}else k.value=[];return n}async function P(e=!1){let t=v.value[`~standard`].validate(T.value);return t instanceof Promise&&(t=await t),w.value?O.value=M(t.issues??[],e)?.map(e=>({$message:e.message,$property:e.path?.[e.path.length-1]?.toString()??`-`,$rule:`schema`,...e}))??[]:O.value=N(t,e),t.issues||(e&&S||!e&&x)&&(F?.(),p(T.value)?T.value=_(T.value,t.value):T.value=t.value,I()),t}let F;function I(){F=c([T,v],()=>{C.silent||P()},{deep:!0})}return I(),P(),A=async()=>{try{return{valid:!(await P(!0)).issues?.length,data:T.value,errors:{},issues:{}}}catch(e){return Promise.reject(e)}},r()&&a(()=>{F()}),{r$:t({scopeRules:n(()=>({})),state:T,options:C,schemaErrors:O,initialState:E,originalState:D,shortcuts:l,schemaMode:!0,onValidate:A}).regle}}return d}const y=v();function b(e,t){return e}function x(){function e(e,t){return t}return e}const S=x();function C({modifiers:e,shortcuts:t}){return{useRegleSchema:v(e,t),inferSchema:x()}}const{useCollectScope:w,useScopedRegle:T}=e({customUseRegle:y}),E=t=>{let{customStore:n,customUseRegle:r=y,asRecord:i=!1}=t??{};return e({customStore:n,customUseRegle:r,asRecord:i})};export{E as createScopedUseRegleSchema,C as defineRegleSchemaConfig,S as inferSchema,w as useCollectSchemaScope,y as useRegleSchema,T as useScopedRegleSchema,b as withDeps};
1
+ import{createScopedUseRegle as e,useRootStorage as t}from"@regle/core";import{computed as n,getCurrentScope as r,isRef as i,onScopeDispose as a,ref as o,unref as s,watch as c}from"vue";function l(e){return e?.constructor?.name==`File`||e?.constructor?.name==`FileList`}function u(e,t=!0){return e==null?!0:e instanceof Date?isNaN(e.getTime()):l(e)?e.size<=0:Array.isArray(e)?t?e.length===0:!1:typeof e==`object`&&e?Object.keys(e).length===0:!String(e).length}function d(e){if(typeof e.source.flags==`string`)return e.source.flags;{let t=[];return e.global&&t.push(`g`),e.ignoreCase&&t.push(`i`),e.multiline&&t.push(`m`),e.sticky&&t.push(`y`),e.unicode&&t.push(`u`),t.join(``)}}function f(e,t=0){if(t>20)return e;let n=e,r={}.toString.call(e).slice(8,-1);if(r==`Set`&&(n=new Set([...e].map(e=>f(e,t++)))),r==`Map`&&(n=new Map([...e].map(e=>[f(e[0]),f(e[1])]))),r==`Date`&&(n=new Date(e.getTime())),r==`RegExp`&&(n=RegExp(e.source,d(e))),r==`Array`||r==`Object`)for(let r in n=Array.isArray(e)?[]:{},e)n[r]=f(e[r],t++);return n}function p(e){return e&&(e instanceof Date||e.constructor.name==`File`||e.constructor.name==`FileList`)?!1:typeof e==`object`&&!!e&&!Array.isArray(e)}function m(e,t,n,r){var i,a;if(Array.isArray(t)&&(i=t.slice(0)),typeof t==`string`&&(i=t.split(`.`)),typeof t==`symbol`&&(i=[t]),!Array.isArray(i))throw Error(`props arg must be an array, a string or a symbol`);if(a=i.pop(),!a)return!1;g(a);for(var o;o=i.shift();)if(g(o),isNaN(parseInt(o))?(e[o]===void 0&&(e[o]={}),e=e[o]):(e.$each??=[],u(e.$each[o])&&(e.$each[o]={}),e=e.$each[o]),!e||typeof e!=`object`)return!1;return r?e[a]?e[a].$self=(e[a].$self??=[]).concat(n):e[a]={$self:n}:Array.isArray(e[a])?e[a]=e[a].concat(n):e[a]=n,!0}function h(e,t,n){if(!e)return n;var r,i;if(Array.isArray(t)&&(r=t.slice(0)),typeof t==`string`&&(r=t.split(`.`)),typeof t==`symbol`&&(r=[t]),!Array.isArray(r))throw Error(`props arg must be an array, a string or a symbol`);for(;r.length;)if(i=r.shift(),!e||!i||(e=e[i],e===void 0))return n;return e}function g(e){if(e==`__proto__`||e==`constructor`||e==`prototype`)throw Error(`setting of prototype values not supported`)}function _(e,...t){for(var n=[].slice.call(arguments),r,i=n.length;r=n[i-1],i--;)if(!r||typeof r!=`object`&&typeof r!=`function`)throw Error(`expected object, got `+r);for(var a=n[0],o=n.slice(1),s=o.length,i=0;i<s;i++){var c=o[i];for(var l in c)a[l]=c[l]}return a}function v(e,l){let u={autoDirty:e?.autoDirty,lazy:e?.lazy,rewardEarly:e?.rewardEarly,clearExternalErrorsOnChange:e?.clearExternalErrorsOnChange};function d(e,d,g){let v=n(()=>s(d)),{syncState:y={onUpdate:!1,onValidate:!1},...b}=g??{},{onUpdate:x=!1,onValidate:S=!1}=y,C={...u,...b},w=n(()=>!p(T.value)),T=i(e)?e:o(e),E=o(p(T.value)?{...f(T.value)}:f(T.value)),D=p(T.value)?{...f(T.value)}:f(T.value),O=o({}),k=o([]),A;function j(e){return e.path?.map(e=>typeof e==`object`?e.key:e.toString()).join(`.`)??``}if(!v.value?.[`~standard`])throw Error(`Only "standard-schema" compatible libraries are supported`);function M(e,t=!1){return!t&&C.rewardEarly?k.value.length?k.value.filter(t=>e.some(e=>j(e)===j(t))):[]:e}function N(e,t=!1){let n={},r=M(e.issues??[],t);if(e.issues?.length){let e=r.map(e=>{let t=j(e),n=e.path?.[e.path.length-1],r=typeof n==`object`?n.key:n,i=(typeof n==`object`&&`value`in n?Array.isArray(n.value):!1)||(`type`in e?e.type===`array`:!1)||Array.isArray(h(T.value,t));return!i&&typeof r==`number`&&(t=e.path?.slice(0,e.path.length-1)?.map(e=>typeof e==`object`?e.key:e.toString()).join(`.`)??``),{...e,$path:t,isArray:i,$property:r,$rule:`schema`,$message:e.message}});e.forEach(({isArray:e,$path:t,...r})=>{m(n,t,[r],e)}),k.value=e}else k.value=[];return n}async function P(e=!1){let t=v.value[`~standard`].validate(T.value);return t instanceof Promise&&(t=await t),w.value?O.value=M(t.issues??[],e)?.map(e=>({$message:e.message,$property:e.path?.[e.path.length-1]?.toString()??`-`,$rule:`schema`,...e}))??[]:O.value=N(t,e),t.issues||(e&&S||!e&&x)&&(F?.(),p(T.value)?T.value=_(T.value,t.value):T.value=t.value,I()),t}let F;function I(){F=c([T,v],()=>{C.silent||P()},{deep:!0})}I(),P(),A=async()=>{try{let e=await P(!0);return L?.regle?.$touch(),{valid:!e.issues?.length,data:T.value,errors:L?.regle?.$errors,issues:O.value}}catch(e){return Promise.reject(e)}},r()&&a(()=>{F()});let L=t({scopeRules:n(()=>({})),state:T,options:C,schemaErrors:O,initialState:E,originalState:D,shortcuts:l,schemaMode:!0,onValidate:A});return{r$:L.regle}}return d}const y=v();function b(e,t){return e}function x(){function e(e,t){return t}return e}const S=x();function C({modifiers:e,shortcuts:t}){return{useRegleSchema:v(e,t),inferSchema:x()}}const{useCollectScope:w,useScopedRegle:T}=e({customUseRegle:y}),E=t=>{let{customStore:n,customUseRegle:r=y,asRecord:i=!1}=t??{};return e({customStore:n,customUseRegle:r,asRecord:i})};export{E as createScopedUseRegleSchema,C as defineRegleSchemaConfig,S as inferSchema,w as useCollectSchemaScope,y as useRegleSchema,T as useScopedRegleSchema,b as withDeps};
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@regle/schemas",
3
- "version": "1.12.0",
3
+ "version": "1.12.1",
4
4
  "description": "Schemas adapter for Regle",
5
5
  "dependencies": {
6
6
  "@standard-schema/spec": "1.0.0",
7
7
  "type-fest": "5.2.0",
8
- "@regle/rules": "1.12.0",
9
- "@regle/core": "1.12.0"
8
+ "@regle/core": "1.12.1",
9
+ "@regle/rules": "1.12.1"
10
10
  },
11
11
  "peerDependencies": {
12
12
  "valibot": "^1.0.0",