@regle/schemas 1.23.1 → 1.23.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/schemas v1.23.1
2
+ * @regle/schemas v1.23.2
3
3
  * (c) 2026 Victor Garcia
4
4
  * @license MIT
5
5
  */
@@ -336,4 +336,4 @@ declare module '@regle/core' {
336
336
  'regle-schemas-field-status': RegleSchemaFieldStatus<T, any>;
337
337
  }
338
338
  }
339
- export { type InferRegleSchemaStatusType, type RegleSchema, type RegleSchemaBehaviourOptions, type RegleSchemaCollectionStatus, type RegleSchemaFieldStatus, type RegleSchemaResult, type RegleSchemaStatus, type RegleSingleFieldSchema, createScopedUseRegleSchema, defineRegleSchemaConfig, inferSchema, useCollectSchemaScope, useRegleSchema, useScopedRegleSchema, withDeps };
339
+ export { type InferRegleSchemaStatusType, type MaybeSchemaVariantStatus, type RegleSchema, type RegleSchemaBehaviourOptions, type RegleSchemaCollectionStatus, type RegleSchemaFieldStatus, type RegleSchemaResult, type RegleSchemaStatus, type RegleSingleFieldSchema, createScopedUseRegleSchema, defineRegleSchemaConfig, inferSchema, useCollectSchemaScope, useRegleSchema, useScopedRegleSchema, withDeps };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @regle/schemas v1.23.1
2
+ * @regle/schemas v1.23.2
3
3
  * (c) 2026 Victor Garcia
4
4
  * @license MIT
5
5
  */
@@ -418,7 +418,7 @@ function createUseRegleSchemaComposable(params) {
418
418
  regle?.regle.value?.$touch();
419
419
  return {
420
420
  valid: !result.issues?.length,
421
- data: processedState.value,
421
+ data: !result.issues ? result.value : processedState.value,
422
422
  errors: regle?.regle.value?.$errors,
423
423
  issues: customErrors.value
424
424
  };
@@ -1,7 +1,7 @@
1
1
  /**
2
- * @regle/schemas v1.23.1
2
+ * @regle/schemas v1.23.2
3
3
  * (c) 2026 Victor Garcia
4
4
  * @license MIT
5
5
  */
6
6
 
7
- import{createScopedUseRegle as e,useRootStorage as t}from"@regle/core";import{computed as n,effectScope as r,getCurrentInstance as i,getCurrentScope as a,isRef as o,nextTick as s,onMounted as c,onScopeDispose as l,reactive as u,ref as d,toValue as f,unref as p,watch as m}from"vue";function h(e){return e?.constructor?.name==`File`}function g(e){return e&&(e instanceof Date||e.constructor.name==`File`||e.constructor.name==`FileList`)?!1:typeof e==`object`&&!!e&&!Array.isArray(e)}function _(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;y(a);for(var o;o=i.shift();)if(y(o),isNaN(parseInt(o))?(e[o]===void 0&&(e[o]={}),e=e[o]):(e.$each??=[],x(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}:isNaN(parseInt(a))?Array.isArray(e[a])?e[a]=e[a].concat(n):e[a]=n:(e.$each??=[],e.$each[a]=(e.$each[a]??=[]).concat(n)),!0}function v(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 y(e){if(e==`__proto__`||e==`constructor`||e==`prototype`)throw Error(`setting of prototype values not supported`)}function b(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 x(e,t=!0,n=!0){return e==null?!0:e instanceof Date?isNaN(e.getTime()):h(e)?e.size<=0:Array.isArray(e)?t?e.length===0:!1:g(e)?e==null?!0:n?Object.keys(e).length===0:!1:!String(e).length}function S(e){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 C(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=>C(e,t++)))),r==`Map`&&(n=new Map([...e].map(e=>[C(e[0]),C(e[1])]))),r==`Date`&&(n=new Date(e.getTime())),r==`RegExp`&&(n=RegExp(e.source,S(e))),r==`Array`||r==`Object`){n=Array.isArray(e)?[]:{};for(let r in e)n[r]=C(e[r],t++)}return n}function w(e,t,n){if(!o(e))return n?.(),u(e);let r=d(!1);return i()&&c(async()=>{await s(),typeof window<`u`&&window.requestAnimationFrame(()=>{r.value=!0})}),u(new Proxy({},{get(i,a,o){if(n?.(),t.value&&a!==`$value`&&r.value)return Reflect.get(i,a,o);if(e.value!==void 0)return p(Reflect.get(e.value,a,o))},set(t,r,i){return n?.(),o(e.value[r])&&!o(i)?e.value[r].value=i:e.value[r]=i,!0},deleteProperty(t,r){return n?.(),Reflect.deleteProperty(e.value,r)},has(t,r){return n?.(),e.value===void 0?!1:Reflect.has(e.value,r)},ownKeys(){return n?.(),e.value===void 0?[]:Object.keys(e.value)},getOwnPropertyDescriptor(){return n?.(),{enumerable:!0,configurable:!0}}}))}function T(e){return e.path?.map(e=>typeof e==`object`?e.key:e.toString()).join(`.`)??``}function E(e){let t=e.path?.at(-1);return typeof t==`object`?t.key:t}function D(e){let t=e.path?.at(-1),n=typeof t==`object`?typeof t.key==`string`:typeof t==`string`,r=e.path?.findLastIndex(e=>typeof e==`object`?typeof e.key==`number`:typeof e==`number`);if(!(!n&&r===-1)&&r!=null){let t=e.path?.slice(0,r+1);return{...e,path:t}}}function O(e,t){let n=T(e),r=e.path?.[e.path.length-1],i=typeof r==`object`?r.key:r;return{isArray:(typeof r==`object`&&`value`in r?Array.isArray(r.value):!1)||(`type`in e?e.type===`array`:!1)||Array.isArray(v(t.value,n)),$path:n,lastItemKey:i,lastItem:r}}function k(e,t,n,r=!1){return!r&&n?t.value.length?t.value.reduce((t,n)=>{if(`$currentArrayValue`in n&&g(n.$currentArrayValue)&&`$id`in n.$currentArrayValue){let r=n.$currentArrayValue.$id,i=E(n),a=e.find(e=>e?.$currentArrayValue?.$id===r&&E(e)===i);a&&t.push({...n,path:a?.path??[]})}else e.some(e=>T(e)===T(n))&&t.push(n);return t},[]):[]:e}function A(e,t,n,r=!1){return k(e,t,n,r)?.map(e=>({$message:e.message,$property:e.path?.[e.path.length-1]?.toString()??`-`,$rule:`schema`,...e}))??[]}function j({result:e,previousIssues:t,processedState:n,rewardEarly:r,isValidate:i=!1}){let a={},o=e.issues?.map(e=>{let t=D(e);if(t){let r=v(n.value,T(t));Object.defineProperty(e,`$currentArrayValue`,{value:r,enumerable:!0,configurable:!0,writable:!0})}return e}),s=k(o??[],t,r,i);if(o?.length){let e=s.map(e=>{let{isArray:t,$path:r,lastItemKey:i}=O(e,n);return{...e,$path:r,isArray:t,$property:i,$rule:`schema`,$message:e.message}});e.forEach(({isArray:e,$path:t,...n})=>{_(a,t,[n],e)}),t.value=e}else t.value=[];return a}function M(e){let t=o(e)?e:d(e);return{processedState:t,isSingleField:n(()=>!g(t.value)),initialState:d(g(t.value)?{...C(t.value)}:C(t.value)),originalState:g(t.value)?{...C(t.value)}:C(t.value)}}function N({processedState:e,getSchema:t,isSingleField:n,customErrors:r,previousIssues:i,resolvedOptions:a,syncOnUpdate:o,syncOnValidate:s}){let c;function l(){u(),c=m([e,t],()=>{a.silent||t()[`~standard`].vendor!==`regle`&&d()},{deep:!0})}function u(){c?.(),c=void 0}async function d(c=!1){let d=t()[`~standard`].validate(e.value);return d instanceof Promise&&(d=await d),n.value?r.value=A(d.issues??[],i,f(a.rewardEarly),c):r.value=j({result:d,previousIssues:i,processedState:e,rewardEarly:f(a.rewardEarly),isValidate:c}),d.issues||(c&&s||!c&&o)&&(u(),g(e.value)?e.value=b(e.value,d.value):e.value=d.value,l()),d}return{computeErrors:d,defineWatchState:l,stopWatching:u}}function P(e){let{options:i,shortcuts:o,overrides:c}=e??{};function u(e,u,h){if(!p(u)?.[`~standard`])throw Error(`Only "standard-schema" compatible libraries are supported`);let{syncState:g={onUpdate:!1,onValidate:!1},..._}=h??{},{onUpdate:v=!1,onValidate:y=!1}=g,b={...i,..._},{processedState:x,isSingleField:S,initialState:C,originalState:T}=M(e),E=d({}),D=d([]),O=new Set,k=!1,A,j,P;function F(){return N({processedState:x,getSchema:()=>p(u),isSingleField:S,customErrors:E,previousIssues:D,resolvedOptions:b,syncOnUpdate:v,syncOnValidate:y})}function I(){A?.stop(),A=r(),A.run(()=>{j=F(),j.defineWatchState(),j.computeErrors()})}function L(){j?.stopWatching(),j=void 0,A?.stop(),A=void 0}function R(){k||(k=!0,I(),P=m(()=>f(b.disabled),e=>{e?L():I()}),f(b.disabled)&&s().then(()=>{L()}))}function z(){k&&(k=!1,P?.(),P=void 0,L())}let B,V=async()=>{try{let e=await(j??F()).computeErrors(!0);return B?.regle.value?.$touch(),{valid:!e.issues?.length,data:x.value,errors:B?.regle.value?.$errors,issues:E.value}}catch(e){return Promise.reject(e)}};function H(){let e=a();!e||O.has(e)||(k||R(),O.add(e),l(()=>{O.delete(e),O.size||z()}))}let U=n(()=>f(b.disabled)??!1);return R(),B=t({scopeRules:n(()=>({})),state:x,options:b,schemaErrors:E,initialState:C,originalState:T,shortcuts:o,schemaMode:!0,onValidate:V,overrides:c}),H(),{r$:w(B.regle,U,()=>{H(),B?.bindToCurrentScope()})}}return u}const F=P();function I(e,t){return e}function L(){function e(e,t){return t}return e}const R=L();function z({modifiers:e,shortcuts:t,overrides:n}){return{useRegleSchema:P({options:e,shortcuts:t,overrides:n}),inferSchema:L()}}const B=t=>{let{customStore:n,customUseRegle:r=F,asRecord:i=!1}=t??{};return e({customStore:n,customUseRegle:r,asRecord:i})},{useCollectScope:V,useScopedRegle:H}=e({customUseRegle:F}),U=V,W=H;export{B as createScopedUseRegleSchema,z as defineRegleSchemaConfig,R as inferSchema,U as useCollectSchemaScope,F as useRegleSchema,W as useScopedRegleSchema,I as withDeps};
7
+ import{createScopedUseRegle as e,useRootStorage as t}from"@regle/core";import{computed as n,effectScope as r,getCurrentInstance as i,getCurrentScope as a,isRef as o,nextTick as s,onMounted as c,onScopeDispose as l,reactive as u,ref as d,toValue as f,unref as p,watch as m}from"vue";function h(e){return e?.constructor?.name==`File`}function g(e){return e&&(e instanceof Date||e.constructor.name==`File`||e.constructor.name==`FileList`)?!1:typeof e==`object`&&!!e&&!Array.isArray(e)}function _(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;y(a);for(var o;o=i.shift();)if(y(o),isNaN(parseInt(o))?(e[o]===void 0&&(e[o]={}),e=e[o]):(e.$each??=[],x(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}:isNaN(parseInt(a))?Array.isArray(e[a])?e[a]=e[a].concat(n):e[a]=n:(e.$each??=[],e.$each[a]=(e.$each[a]??=[]).concat(n)),!0}function v(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 y(e){if(e==`__proto__`||e==`constructor`||e==`prototype`)throw Error(`setting of prototype values not supported`)}function b(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 x(e,t=!0,n=!0){return e==null?!0:e instanceof Date?isNaN(e.getTime()):h(e)?e.size<=0:Array.isArray(e)?t?e.length===0:!1:g(e)?e==null?!0:n?Object.keys(e).length===0:!1:!String(e).length}function S(e){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 C(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=>C(e,t++)))),r==`Map`&&(n=new Map([...e].map(e=>[C(e[0]),C(e[1])]))),r==`Date`&&(n=new Date(e.getTime())),r==`RegExp`&&(n=RegExp(e.source,S(e))),r==`Array`||r==`Object`){n=Array.isArray(e)?[]:{};for(let r in e)n[r]=C(e[r],t++)}return n}function w(e,t,n){if(!o(e))return n?.(),u(e);let r=d(!1);return i()&&c(async()=>{await s(),typeof window<`u`&&window.requestAnimationFrame(()=>{r.value=!0})}),u(new Proxy({},{get(i,a,o){if(n?.(),t.value&&a!==`$value`&&r.value)return Reflect.get(i,a,o);if(e.value!==void 0)return p(Reflect.get(e.value,a,o))},set(t,r,i){return n?.(),o(e.value[r])&&!o(i)?e.value[r].value=i:e.value[r]=i,!0},deleteProperty(t,r){return n?.(),Reflect.deleteProperty(e.value,r)},has(t,r){return n?.(),e.value===void 0?!1:Reflect.has(e.value,r)},ownKeys(){return n?.(),e.value===void 0?[]:Object.keys(e.value)},getOwnPropertyDescriptor(){return n?.(),{enumerable:!0,configurable:!0}}}))}function T(e){return e.path?.map(e=>typeof e==`object`?e.key:e.toString()).join(`.`)??``}function E(e){let t=e.path?.at(-1);return typeof t==`object`?t.key:t}function D(e){let t=e.path?.at(-1),n=typeof t==`object`?typeof t.key==`string`:typeof t==`string`,r=e.path?.findLastIndex(e=>typeof e==`object`?typeof e.key==`number`:typeof e==`number`);if(!(!n&&r===-1)&&r!=null){let t=e.path?.slice(0,r+1);return{...e,path:t}}}function O(e,t){let n=T(e),r=e.path?.[e.path.length-1],i=typeof r==`object`?r.key:r;return{isArray:(typeof r==`object`&&`value`in r?Array.isArray(r.value):!1)||(`type`in e?e.type===`array`:!1)||Array.isArray(v(t.value,n)),$path:n,lastItemKey:i,lastItem:r}}function k(e,t,n,r=!1){return!r&&n?t.value.length?t.value.reduce((t,n)=>{if(`$currentArrayValue`in n&&g(n.$currentArrayValue)&&`$id`in n.$currentArrayValue){let r=n.$currentArrayValue.$id,i=E(n),a=e.find(e=>e?.$currentArrayValue?.$id===r&&E(e)===i);a&&t.push({...n,path:a?.path??[]})}else e.some(e=>T(e)===T(n))&&t.push(n);return t},[]):[]:e}function A(e,t,n,r=!1){return k(e,t,n,r)?.map(e=>({$message:e.message,$property:e.path?.[e.path.length-1]?.toString()??`-`,$rule:`schema`,...e}))??[]}function j({result:e,previousIssues:t,processedState:n,rewardEarly:r,isValidate:i=!1}){let a={},o=e.issues?.map(e=>{let t=D(e);if(t){let r=v(n.value,T(t));Object.defineProperty(e,`$currentArrayValue`,{value:r,enumerable:!0,configurable:!0,writable:!0})}return e}),s=k(o??[],t,r,i);if(o?.length){let e=s.map(e=>{let{isArray:t,$path:r,lastItemKey:i}=O(e,n);return{...e,$path:r,isArray:t,$property:i,$rule:`schema`,$message:e.message}});e.forEach(({isArray:e,$path:t,...n})=>{_(a,t,[n],e)}),t.value=e}else t.value=[];return a}function M(e){let t=o(e)?e:d(e);return{processedState:t,isSingleField:n(()=>!g(t.value)),initialState:d(g(t.value)?{...C(t.value)}:C(t.value)),originalState:g(t.value)?{...C(t.value)}:C(t.value)}}function N({processedState:e,getSchema:t,isSingleField:n,customErrors:r,previousIssues:i,resolvedOptions:a,syncOnUpdate:o,syncOnValidate:s}){let c;function l(){u(),c=m([e,t],()=>{a.silent||t()[`~standard`].vendor!==`regle`&&d()},{deep:!0})}function u(){c?.(),c=void 0}async function d(c=!1){let d=t()[`~standard`].validate(e.value);return d instanceof Promise&&(d=await d),n.value?r.value=A(d.issues??[],i,f(a.rewardEarly),c):r.value=j({result:d,previousIssues:i,processedState:e,rewardEarly:f(a.rewardEarly),isValidate:c}),d.issues||(c&&s||!c&&o)&&(u(),g(e.value)?e.value=b(e.value,d.value):e.value=d.value,l()),d}return{computeErrors:d,defineWatchState:l,stopWatching:u}}function P(e){let{options:i,shortcuts:o,overrides:c}=e??{};function u(e,u,h){if(!p(u)?.[`~standard`])throw Error(`Only "standard-schema" compatible libraries are supported`);let{syncState:g={onUpdate:!1,onValidate:!1},..._}=h??{},{onUpdate:v=!1,onValidate:y=!1}=g,b={...i,..._},{processedState:x,isSingleField:S,initialState:C,originalState:T}=M(e),E=d({}),D=d([]),O=new Set,k=!1,A,j,P;function F(){return N({processedState:x,getSchema:()=>p(u),isSingleField:S,customErrors:E,previousIssues:D,resolvedOptions:b,syncOnUpdate:v,syncOnValidate:y})}function I(){A?.stop(),A=r(),A.run(()=>{j=F(),j.defineWatchState(),j.computeErrors()})}function L(){j?.stopWatching(),j=void 0,A?.stop(),A=void 0}function R(){k||(k=!0,I(),P=m(()=>f(b.disabled),e=>{e?L():I()}),f(b.disabled)&&s().then(()=>{L()}))}function z(){k&&(k=!1,P?.(),P=void 0,L())}let B,V=async()=>{try{let e=await(j??F()).computeErrors(!0);return B?.regle.value?.$touch(),{valid:!e.issues?.length,data:e.issues?x.value:e.value,errors:B?.regle.value?.$errors,issues:E.value}}catch(e){return Promise.reject(e)}};function H(){let e=a();!e||O.has(e)||(k||R(),O.add(e),l(()=>{O.delete(e),O.size||z()}))}let U=n(()=>f(b.disabled)??!1);return R(),B=t({scopeRules:n(()=>({})),state:x,options:b,schemaErrors:E,initialState:C,originalState:T,shortcuts:o,schemaMode:!0,onValidate:V,overrides:c}),H(),{r$:w(B.regle,U,()=>{H(),B?.bindToCurrentScope()})}}return u}const F=P();function I(e,t){return e}function L(){function e(e,t){return t}return e}const R=L();function z({modifiers:e,shortcuts:t,overrides:n}){return{useRegleSchema:P({options:e,shortcuts:t,overrides:n}),inferSchema:L()}}const B=t=>{let{customStore:n,customUseRegle:r=F,asRecord:i=!1}=t??{};return e({customStore:n,customUseRegle:r,asRecord:i})},{useCollectScope:V,useScopedRegle:H}=e({customUseRegle:F}),U=V,W=H;export{B as createScopedUseRegleSchema,z as defineRegleSchemaConfig,R as inferSchema,U as useCollectSchemaScope,F as useRegleSchema,W as useScopedRegleSchema,I as withDeps};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@regle/schemas",
3
- "version": "1.23.1",
3
+ "version": "1.23.2",
4
4
  "description": "Schemas adapter for Regle",
5
5
  "homepage": "https://reglejs.dev/",
6
6
  "license": "MIT",
@@ -37,8 +37,8 @@
37
37
  "dependencies": {
38
38
  "@standard-schema/spec": "1.1.0",
39
39
  "type-fest": "5.6.0",
40
- "@regle/core": "1.23.1",
41
- "@regle/rules": "1.23.1"
40
+ "@regle/core": "1.23.2",
41
+ "@regle/rules": "1.23.2"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@total-typescript/ts-reset": "0.6.1",