@tempots/beatui 0.69.0 → 0.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ar-aMLQTGVh.js → ar-BbgpGwJp.js} +1 -1
- package/dist/auth/index.cjs.js +1 -1
- package/dist/auth/index.es.js +106 -105
- package/dist/beatui.css +401 -0
- package/dist/beatui.tailwind.css +401 -0
- package/dist/{de-DBFOC44R.js → de-R7lPfyZ4.js} +1 -1
- package/dist/deep-merge-CQQCMLwG.js +1636 -0
- package/dist/deep-merge-DZxfgKqX.cjs +1 -0
- package/dist/duration-input-D-SIoDoo.cjs +1 -0
- package/dist/duration-input-DKxZ6OCa.js +277 -0
- package/dist/{es-C4xOThaT.js → es-DV0Jr_BZ.js} +1 -1
- package/dist/{fa-B7X_xydY.js → fa-DXvHejs9.js} +1 -1
- package/dist/{fr-AmjzbxN_.js → fr-D8FOMX0o.js} +1 -1
- package/dist/{he-DY-9yiOC.js → he-B19Qsx-u.js} +1 -1
- package/dist/{hi-Clkyp5Fu.js → hi-DozFnE3b.js} +1 -1
- package/dist/{index-GLoRnI6r.js → index-CYb1YxDX.js} +1 -1
- package/dist/{index-CzuXAuLZ.js → index-DdpYvBeh.js} +3 -3
- package/dist/index.cjs.js +4 -4
- package/dist/index.es.js +2852 -3104
- package/dist/{it-BC32WmGF.js → it-But8uzNi.js} +1 -1
- package/dist/{ja-JNSZS_Hv.js → ja-DkwTnFdU.js} +1 -1
- package/dist/json-schema/index.cjs.js +7 -7
- package/dist/json-schema/index.es.js +3814 -3609
- package/dist/json-structure/index.cjs.js +1 -0
- package/dist/json-structure/index.es.js +3157 -0
- package/dist/{ko-B8l0TJp0.js → ko-Cqv-IjhX.js} +1 -1
- package/dist/modal-5P9mU_a4.cjs +1 -0
- package/dist/{modal-DJWj5M5e.js → modal-MofsfmAe.js} +2 -2
- package/dist/{nl-BpYESHP8.js → nl-YSiU3rFI.js} +1 -1
- package/dist/notice-Cqq8g17n.js +209 -0
- package/dist/notice-DP209Ed8.cjs +1 -0
- package/dist/{pl-_sWhGdrs.js → pl-DXmHc2Nh.js} +1 -1
- package/dist/prosemirror/index.es.js +1 -1
- package/dist/{pt-BmiQvHUz.js → pt-Bf3z_-26.js} +1 -1
- package/dist/{ru-DacnqexG.js → ru-Sy00qUeG.js} +1 -1
- package/dist/tailwind/vite-plugin.es.js +1 -0
- package/dist/{toolbar-Bk5-22ln.js → toolbar-C_Ec0_XC.js} +1 -1
- package/dist/{tr-BSS5b_v6.js → tr-BDxG3qd6.js} +1 -1
- package/dist/{translations-zGwuSQWQ.js → translations-BmsRhth7.js} +1 -1
- package/dist/{translations-BUTBIDsS.js → translations-DQxouiBG.js} +24 -24
- package/dist/types/components/form/index.d.ts +1 -0
- package/dist/types/components/form/utils/deep-merge.d.ts +27 -0
- package/dist/types/components/form/utils/index.d.ts +1 -0
- package/dist/types/components/json-schema/controls/null-control.d.ts +1 -1
- package/dist/types/components/json-schema/index.d.ts +1 -0
- package/dist/types/components/json-schema/json-schema-form.d.ts +22 -3
- package/dist/types/components/json-schema/schema-defaults.d.ts +39 -0
- package/dist/types/components/json-structure/controls/any-control.d.ts +15 -0
- package/dist/types/components/json-structure/controls/array-control.d.ts +15 -0
- package/dist/types/components/json-structure/controls/binary-control.d.ts +15 -0
- package/dist/types/components/json-structure/controls/boolean-control.d.ts +15 -0
- package/dist/types/components/json-structure/controls/choice-control.d.ts +19 -0
- package/dist/types/components/json-structure/controls/decimal-control.d.ts +17 -0
- package/dist/types/components/json-structure/controls/deprecation-utils.d.ts +14 -0
- package/dist/types/components/json-structure/controls/enum-const-controls.d.ts +22 -0
- package/dist/types/components/json-structure/controls/generic-control.d.ts +31 -0
- package/dist/types/components/json-structure/controls/index.d.ts +21 -0
- package/dist/types/components/json-structure/controls/integer-control.d.ts +18 -0
- package/dist/types/components/json-structure/controls/map-control.d.ts +17 -0
- package/dist/types/components/json-structure/controls/object-control.d.ts +17 -0
- package/dist/types/components/json-structure/controls/set-control.d.ts +15 -0
- package/dist/types/components/json-structure/controls/string-control.d.ts +15 -0
- package/dist/types/components/json-structure/controls/temporal-control.d.ts +18 -0
- package/dist/types/components/json-structure/controls/tuple-control.d.ts +19 -0
- package/dist/types/components/json-structure/controls/union-control.d.ts +15 -0
- package/dist/types/components/json-structure/controls/uri-control.d.ts +15 -0
- package/dist/types/components/json-structure/controls/uuid-control.d.ts +15 -0
- package/dist/types/components/json-structure/extends-utils.d.ts +36 -0
- package/dist/types/components/json-structure/index.d.ts +25 -0
- package/dist/types/components/json-structure/json-structure-form.d.ts +96 -0
- package/dist/types/components/json-structure/ref-utils.d.ts +55 -0
- package/dist/types/components/json-structure/structure-context.d.ts +176 -0
- package/dist/types/components/json-structure/structure-defaults.d.ts +46 -0
- package/dist/types/components/json-structure/structure-types.d.ts +173 -0
- package/dist/types/components/json-structure/validation/error-transform.d.ts +56 -0
- package/dist/types/components/json-structure/validation/index.d.ts +5 -0
- package/dist/types/components/json-structure/validation/sdk-validator.d.ts +46 -0
- package/dist/types/components/json-structure/widgets/default-widgets.d.ts +27 -0
- package/dist/types/components/json-structure/widgets/index.d.ts +6 -0
- package/dist/types/components/json-structure/widgets/widget-registry.d.ts +143 -0
- package/dist/types/components/json-structure/widgets/widget-utils.d.ts +79 -0
- package/dist/types/json-structure/index.d.ts +9 -0
- package/dist/{ur-C6Ky6OCl.js → ur-55zdT2TQ.js} +1 -1
- package/dist/{notice-Um1LwKBF.js → use-form-B7A865EM.js} +329 -532
- package/dist/use-form-DVJXMMoN.cjs +2 -0
- package/dist/{vi-Bx2gx2S0.js → vi-C7K7W0hM.js} +1 -1
- package/dist/widget-customization-29Hl2gKT.js +1171 -0
- package/dist/widget-customization-BXiewbt-.cjs +1 -0
- package/dist/{zh-eixtg-Ce.js → zh-DvJBV9D8.js} +1 -1
- package/package.json +10 -2
- package/dist/modal-D_paG9Sr.cjs +0 -1
- package/dist/notice-CgT9ma2m.cjs +0 -2
- package/dist/widget-customization-BcbRhAAR.cjs +0 -1
- package/dist/widget-customization-D6Y_Qm7o.js +0 -2788
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const r=require("@tempots/dom"),T=require("./translations-hMQlZmD4.cjs"),P=new Map;function I(e){const t=P.get(e)??0;return P.set(e,t+1),`${e}-${t}`}const f={notAsked:{type:"NotAsked"},loading(e=void 0){return{type:"Loading",previousValue:e}},success(e){return{type:"AsyncSuccess",value:e}},failure(e){return{type:"AsyncFailure",error:e}},isSuccess(e){return e.type==="AsyncSuccess"},isFailure(e){return e.type==="AsyncFailure"},isNotAsked(e){return e.type==="NotAsked"},isLoading(e){return e.type==="Loading"},getOrElse(e,t){return f.isSuccess(e)?e.value:t},getOrElseLazy(e,t){return f.isSuccess(e)?e.value:t()},getOrNull(e){return f.isSuccess(e)?e.value:null},getOrUndefined(e){return f.isSuccess(e)?e.value:void 0},getUnsafe:e=>{if(f.isSuccess(e))return e.value;throw f.isFailure(e)?e.error:new Error("Cannot get value from a not-asked or loading result")},match:(e,{success:t,failure:s,loading:n,notAsked:a=n})=>f.isSuccess(e)?t(e.value):f.isFailure(e)?s(e.error):f.isNotAsked(e)?a():n(e.previousValue),whenSuccess:(e,t)=>(f.isSuccess(e)&&t(e.value),e),whenFailure:(e,t)=>(f.isFailure(e)&&t(e.error),e),equals:(e,t,s={valueEquals:(n,a)=>n===a,errorEquals:(n,a)=>n===a})=>e.type==="AsyncSuccess"&&t.type==="AsyncSuccess"?s.valueEquals(e.value,t.value):e.type==="AsyncFailure"&&t.type==="AsyncFailure"?s.errorEquals(e.error,t.error):e.type==="Loading"&&t.type==="Loading"?s.valueEquals(e.previousValue,t.previousValue):e.type==="NotAsked"&&t.type==="NotAsked",all:e=>{const t=[];for(const s of e)if(f.isSuccess(s))t.push(s.value);else return s;return f.success(t)},ofPromise:async e=>{try{const t=await e;return f.success(t)}catch(t){return f.failure(t instanceof Error?t:new Error(String(t)))}}},E=(e,t)=>e===t||e!==e&&t!==t,b={valid:{type:"valid"},invalid(e){return{type:"invalid",error:e}},isValid(e){return e.type==="valid"},isInvalid(e){return e.type==="invalid"},match:(e,t,s)=>b.isValid(e)?t():s(e.error),toResult:(e,t)=>b.match(e,()=>d.success(t),s=>d.failure(s)),whenValid:(e,t)=>(b.isValid(e)&&t(),e),whenInvalid:(e,t)=>(b.isInvalid(e)&&t(e.error),e)},d={success(e){return{type:"Success",value:e}},failure(e){return{type:"Failure",error:e}},map:(e,t)=>e.type==="Success"?d.success(t(e.value)):e,flatMap:(e,t)=>e.type==="Success"?t(e.value):e,toAsync(e){return d.match(e,t=>f.success(t),t=>f.failure(t))},toValidation(e){return d.match(e,()=>b.valid,t=>b.invalid(t))},isSuccess(e){return e.type==="Success"},isFailure(e){return e.type==="Failure"},getOrElse(e,t){return d.isSuccess(e)?e.value:t},getOrElseLazy(e,t){return d.isSuccess(e)?e.value:t()},getOrNull(e){return d.isSuccess(e)?e.value:null},getOrUndefined(e){return d.isSuccess(e)?e.value:void 0},getUnsafe:e=>{if(d.isSuccess(e))return e.value;throw e.error},match:(e,t,s)=>d.isSuccess(e)?t(e.value):s(e.error),whenSuccess:(e,t)=>(d.isSuccess(e)&&t(e.value),e),whenFailure:(e,t)=>(d.isFailure(e)&&t(e.error),e),combine:(e,t,s,n)=>d.match(e,a=>d.match(t,i=>d.success(s(a,i)),i=>d.failure(i)),a=>d.match(t,i=>d.failure(a),i=>d.failure(n(a,i)))),equals:(e,t,s={valueEquals:(n,a)=>n===a,errorEquals:(n,a)=>n===a})=>e.type==="Success"&&t.type==="Success"?s.valueEquals(e.value,t.value):e.type==="Failure"&&t.type==="Failure"?s.errorEquals(e.error,t.error):!1,all:e=>{const t=[];for(const s of e)if(d.isSuccess(s))t.push(s.value);else return s;return d.success(t)}};function Z({size:e="sm",icon:t="line-md:close",disabled:s,roundedness:n="full",color:a="base",onClick:i,label:o},...l){return r.Use(T.BeatUII18n,c=>{const p=r.coalesce(o,c.$.closeModal);return T.Button({variant:"text",size:e,roundedness:n,disabled:s,color:a,onClick:i},r.attr.title(p),r.aria.label(p),...l,T.Icon({icon:t,size:e??"sm"}))})}function O(e){return`bc-label bc-label--${e}`}const ee=(...e)=>r.html.span(r.attr.class(O("emphasis")),...e),$=(...e)=>r.html.span(r.attr.class(O("default")),...e),q=(...e)=>r.html.span(r.attr.class(O("muted")),...e),te=(...e)=>r.html.span(r.attr.class(O("danger")),...e),se=e=>{const{value:t,onBlur:s,onChange:n,placeholder:a,disabled:i,id:o,checkedIcon:l,uncheckedIcon:c,iconSize:p="lg"}=e,u=o??I("checkbox"),m=`${u}-label`,v=()=>{if(r.Value.get(i??!1))return;const h=r.Value.get(t);n?.(!h)},k=h=>{r.Value.get(i??!1)||(h.key===" "||h.key==="Enter")&&(h.preventDefault(),v())};return T.InputContainer({baseContainer:!0,growInput:!1,...e,input:r.html.span(r.attr.class("bc-checkbox-input"),r.html.span(r.attr.class("bc-checkbox-input__checkbox"),r.attr.class(r.Value.map(t,h=>h?"bc-checkbox-input__checkbox--checked":"bc-checkbox-input__checkbox--unchecked")),r.attr.class(r.Value.map(i??!1,h=>h?"bc-checkbox-input__checkbox--disabled":"")),r.attr.id(u),r.attr.role("checkbox"),r.attr.tabindex(r.Value.map(i??!1,h=>h?-1:0)),r.aria.checked(t),r.aria.disabled(i),a!=null?r.aria.labelledby(m):r.Empty,r.on.keydown(k),s!=null?r.on.blur(s):r.Empty,T.Icon({icon:r.computedOf(t,l,c)((h,g,w)=>h?g??"akar-icons/check-box-fill":w??"akar-icons/box"),accessibility:"decorative",size:p})),a!=null?r.html.label(r.attr.class("bc-checkbox-input__label"),r.attr.id(m),r.attr.for(u),q(a)):r.Empty)},r.on.click(v))},j=r.html.span(r.attr.class("bc-input-wrapper__required")," *");function re(e){const t=["bc-input-wrapper"];return e!=="vertical"&&t.push(`bc-input-wrapper--${e}`),t.join(" ")}function ne(e,t){const s=["bc-input-wrapper__label-text"];return e?s.push("bc-input-wrapper__label-text--error"):t?s.push("bc-input-wrapper__label-text--disabled"):s.push("bc-input-wrapper__label-text--default"),s.join(" ")}function ae(e,t){if(e==="horizontal-fixed"&&t!=null)return`--input-wrapper-label-width: ${t}`}const L=({fullWidth:e=!1,required:t,label:s,labelChildren:n,context:a,description:i,content:o,error:l,labelFor:c,hasError:p,disabled:u,layout:m,labelWidth:v},...k)=>{const h=p??l!=null,g=u??!1,w=m??"vertical",D=I("input-wrapper"),A=i?`${D}-description`:void 0,_=l!=null?`${D}-error`:void 0,N=r.computedOf(w)(y=>y!=="vertical"),Y=r.computedOf(w,v??void 0)((y,C)=>ae(y,C));return r.html.div(r.attr.class(r.Value.map(w,y=>re(y))),r.attr.class(r.Value.map(e,y=>y?"bc-input-wrapper--full-width":"")),r.attr.style(Y),s!=null||a!=null?r.html.div(r.attr.class("bc-input-wrapper__header"),r.html.div(r.attr.class("bc-input-wrapper__label-section"),r.html.label(r.attr.class("bc-input-wrapper__label"),c!=null?r.attr.for(c):r.Empty,r.html.span(r.attr.class(r.computedOf(h,g)((y,C)=>ne(y??!1,C??!1))),s),s!=null&&t?j:r.Empty),r.When(r.computedOf(N,i)((y,C)=>y&&C!=null),()=>r.html.div(r.attr.class("bc-input-wrapper__description bc-input-wrapper__description--under-label"),r.attr.id(A),i))),a!=null?$(a):r.Empty,n):r.Empty,r.html.div(r.attr.class("bc-input-wrapper__content"),[A,_].filter(Boolean).length>0?r.dataAttr.describedby([A,_].filter(Boolean).join(" ")):r.Empty,t?r.dataAttr.required("true"):r.Empty,r.When(h,()=>r.dataAttr.invalid("true")),o),r.When(r.computedOf(N,i)((y,C)=>!y&&C!=null),()=>r.html.div(r.attr.class("bc-input-wrapper__description"),r.attr.id(A),i)),r.When(h,()=>r.html.div(r.attr.class("bc-input-wrapper__error"),r.attr.id(_),r.aria.live("polite"),r.attr.role("alert"),l)),...k)};function ie(...e){return r.html.div(r.attr.class("bc-stack"),...e)}const H=(e,t)=>()=>{e.markTouched(),t?.()},M=(e,t)=>s=>{e.change(s),t?.(s)};function x(e,t){const{controller:s,onBlur:n,onChange:a,id:i,triggerOn:o,...l}=t;return e({id:i??s.name,disabled:s.disabled,value:s.signal,hasError:s.errorVisible,name:s.name,...l,onInput:o==="input"?M(s,a):void 0,onChange:o!=="input"?M(s,a):void 0,onBlur:H(s,n)})}function le(e,{id:t,labelFor:s,...n},...a){const i=t??n.controller.name??I("control"),o=s??i;return L({...n,hasError:n.controller.errorVisible,error:r.TextNode(n.controller.error.map(l=>l??"")),labelFor:o,content:x(l=>e({...l,id:i}),n)},...a)}function W(e,t){const{toInput:s,fromInput:n,controller:a,...i}=t,o=a.transform(s,n);return x(e,{...i,controller:o})}function oe(e,{id:t,labelFor:s,...n},...a){const i=t??n.controller.name??I("control");return L({...n,labelFor:s??i,content:W(e,{...n,id:i})},...a)}function ce(e){return e.split(".").map(s=>{const n=s.match(/^\[(\d+)\]$/);return n?Number(n[1]):s})}function z(e){return typeof e=="number"?`[${e}]`:`.${e}`}function U(e){if(e.length===0)return"";const[t,...s]=e;return[typeof t=="number"?`[${t}]`:t,...s.map(z)].join("")}function V(e){return function(s){if(s.type==="valid")return s;let n=s.error;for(const a of e)if(n=n?.dependencies?.[a],n==null)return b.valid;return b.invalid(n)}}class S{path;change;signal;status;error;hasError;touched;errorVisible;dirty;dependencyErrors;#e={disabled:r.prop(!1),touched:r.prop(!1)};#s;#t=r.prop(void 0);parent;disabled;#r=[];disabledOrHasErrors;constructor(t,s,n,a,i,o=E){this.path=t,this.change=s,this.signal=n,this.status=a,this.#s=o,this.#t.set(n.value),this.error=a.map(l=>l?.type==="invalid"?l.error?.message:void 0),this.hasError=this.error.map(l=>l!=null),this.touched=this.#e.touched,i.validationMode?this.errorVisible=r.computedOf(this.hasError,this.touched,i.validationMode)((l,c,p)=>p==="eager"?!!l:!!l&&!!c):this.errorVisible=r.computedOf(this.hasError,this.touched)((l,c)=>!!l&&!!c),this.dirty=r.computedOf(this.signal,this.#t)((l,c)=>!this.#s(l,c)),this.dependencyErrors=a.map(l=>l?.type==="invalid"?l.error?.dependencies:void 0),this.parent=i,this.disabled=r.computedOf(this.#e.disabled,i.disabled)((l,c)=>l||c),this.disabledOrHasErrors=r.computedOf(this.disabled,this.hasError)((l,c)=>l||c),this.onDispose(()=>{this.#e.disabled.dispose(),this.#e.touched.dispose(),this.disabled.dispose(),this.error.dispose(),this.errorVisible.dispose(),this.dirty.dispose(),this.#t.dispose(),this.dependencyErrors.dispose(),this.disabledOrHasErrors.dispose()})}get name(){return U(this.path)}onDispose=t=>{this.#r.push(t)};dispose=()=>{for(const t of this.#r)try{t()}catch(s){console.error("Error in dispose callback:",s)}this.#r.length=0};setDisabled=t=>{this.#e.disabled.set(t)};disable=()=>this.setDisabled(!0);enable=()=>this.setDisabled(!1);markTouched=()=>{this.#e.touched.set(!0)};resetTouched=()=>{this.#e.touched.set(!1)};markPristine=()=>{this.#t.set(this.signal.value)};reset=()=>{this.change(this.#t.value)};array=(t=E)=>new K(this.path,this.change,this.signal,this.status,this.parent,t);object=(t=E)=>new R(this.path,this.change,this.signal,this.status,this.parent,t);transform=(t,s,n=[],a=E)=>new S([...this.path,...n],i=>this.change(s(i)),this.signal.map(t,a),this.status.map(V(n)),this.parent,a);asyncTransform=(t,s,n,a=[],i=E)=>new S([...this.path,...a],o=>{s(o).then(l=>this.change(l))},this.signal.mapAsync(t,n,void 0,i),this.status.map(V(a)),this.parent,i)}class R extends S{#e=new Map;#s=new Map;#t=new Map;#r=r.prop(!1);touchedDeep=this.#r;#a=new Map;#n=new Map;#l=r.prop(!1);dirtyDeep=this.#l;#c;#u;#o=()=>{let t=!1;for(const s of this.#s.values())if(s){t=!0;break}this.#r.set(this.touched.value||t)};constructor(t,s,n,a,i,o){super(t,s,n.map(c=>c??{},o),a,i,o),this.#c=this.touched.on(()=>{this.#o()}),this.#u=this.dirty.on(()=>{this.#i()});const l=this.signal.on(()=>this.#i());this.onDispose(()=>{for(const c of this.#e.values())c.dispose();this.#e.clear();for(const c of this.#t.values())c();this.#t.clear(),this.#s.clear(),this.#r.dispose();for(const c of this.#n.values())c();this.#n.clear(),this.#a.clear(),this.#l.dispose(),this.#c(),this.#u(),l()})}field=t=>{if(this.#e.has(t))return this.#e.get(t);const s=async o=>{this.change({...this.signal.value,[t]:o})},n=new S([...this.path,t],s,this.signal.map(o=>o[t]),this.status.map(V([t])),{disabled:this.disabled,validationMode:this.parent.validationMode});this.#e.set(t,n);const a=n.touched.on(o=>{this.#s.set(t,o),this.#o()});this.#t.set(t,a);const i=n.dirty.on(o=>{this.#a.set(t,o),this.#i()});return this.#n.set(t,i),n};markAllTouched=()=>{this.markTouched();const t=this.signal.value;for(const s of Object.keys(t))this.field(s).markTouched();for(const s of this.#e.values())s.markTouched()};markAllPristine=()=>{this.markPristine();const t=this.signal.value;for(const s of Object.keys(t))this.field(s).markPristine?.();for(const s of this.#e.values())s.markPristine?.()};#i=()=>{let t=!1;for(const s of this.#a.values())if(s){t=!0;break}this.#l.set(this.dirty.value||t)}}class K extends S{#e=new Array;length;#s=new Map;#t=new Map;#r=r.prop(!1);touchedDeep=this.#r;#a=new Map;#n=new Map;#l=r.prop(!1);dirtyDeep=this.#l;#c;#u;#o=()=>{let t=!1;for(const s of this.#s.values())if(s){t=!0;break}this.#r.set(this.touched.value||t)};constructor(t,s,n,a,i,o){const l=n.map(u=>u??[],o);super(t,s,l,a,i,o);const c=l.on(u=>{const m=this.#e.length-u.length;m>0&&(this.#e.splice(u.length,m).forEach((v,k)=>{const h=u.length+k;v.dispose(),this.#t.get(h)?.(),this.#t.delete(h),this.#s.delete(h),this.#n.get(h)?.(),this.#n.delete(h),this.#a.delete(h)}),this.#o(),this.#i())});this.length=l.map(u=>u.length),this.#c=this.touched.on(()=>{this.#o()}),this.#u=this.dirty.on(()=>{this.#i()});const p=this.signal.on(()=>this.#i());this.onDispose(()=>{for(const u of this.#e)u.dispose();this.length.dispose(),this.#e.length=0,c(),l.dispose();for(const u of this.#t.values())u();this.#t.clear(),this.#s.clear(),this.#r.dispose();for(const u of this.#n.values())u();this.#n.clear(),this.#a.clear(),this.#l.dispose(),this.#c(),this.#u(),p()})}item=t=>{if(this.#e[t])return this.#e[t];const s=async o=>{const l=this.signal.value.slice();l[t]=o,this.change(l)},n=new S([...this.path,t],s,this.signal.map(o=>o[t]),this.status.map(V([t])),{disabled:this.disabled,validationMode:this.parent.validationMode});this.#e[t]=n;const a=n.touched.on(o=>{this.#s.set(t,o),this.#o()});this.#t.set(t,a);const i=n.dirty.on(o=>{this.#a.set(t,o),this.#i()});return this.#n.set(t,i),n};push=(...t)=>{this.change([...this.signal.value,...t])};pop=()=>{this.splice(this.signal.value.length-1,1)};shift=()=>{this.splice(0,1)};unshift=(...t)=>{this.change([...t,...this.signal.value])};removeAt=t=>{this.splice(t,1)};splice=(t,s)=>{const n=this.signal.value.slice();n.splice(t,s),this.change(n)};move=(t,s,n=1)=>{if(n<1||t===s)return;const a=this.signal.value.slice(),i=a.splice(t,n);a.splice(s,0,...i),this.change(a)};markAllTouched=()=>{this.markTouched();const t=this.signal.value.length;for(let s=0;s<t;s++)this.item(s).markTouched()};markAllPristine=()=>{this.markPristine();const t=this.signal.value.length;for(let s=0;s<t;s++)this.item(s).markPristine?.()};#i=()=>{let t=!1;for(const s of this.#a.values())if(s){t=!0;break}this.#l.set(this.dirty.value||t)}}function G(e){function t(s){return typeof s=="number"?s:s.toString()}return e.map(s=>typeof s=="object"&&s.key!=null?t(s.key):t(s))}function J(e){const t=e.filter(a=>a.path==null||a.path.length===0).map(a=>a.message),s=e.filter(a=>a.path!=null&&a.path.length>0).reduce((a,i)=>{const o=G(i.path),l=o.pop();let c=a;for(const p of o)c.dependencies==null&&(c.dependencies={}),c.dependencies[p]==null&&(c.dependencies[p]={}),c=c.dependencies[p];return c.dependencies==null&&(c.dependencies={}),c.dependencies[l]={message:i.message},a},{}),n=t.join(`
|
|
2
|
+
`);return{...s,message:n!=""?n:void 0}}function Q({initialValue:e,onChange:t,validate:s,equals:n,validationMode:a,validateDebounceMs:i}){const o=r.Value.deriveProp(e),l=r.prop(b.valid),c=r.prop(!1),p=r.prop(a??"onTouched"),u=g=>{l.set(g)};let m;const v=async g=>{if(s!=null){const w=await s(g);u(w)}},k=async g=>{o.set(g),t?.(g);const w=p.value;if(s!=null){if(w==="onSubmit")return;const D=i??0;D>0?(m&&clearTimeout(m),m=setTimeout(()=>{v(g)},D)):await v(g)}},h=new S([],k,o,l,{disabled:c,validationMode:p},n??E);return h.onDispose(()=>{c.dispose(),o.dispose(),l.dispose(),p.dispose(),m&&clearTimeout(m)}),{controller:h,setStatus:u}}function B(e){return r.Fragment(r.attr.disabled(e.disabled),r.attr.name(e.name))}function ue(e,{triggerOn:t="change"}={}){return r.Fragment(B(e),r.attr.value(e.signal),(t==="input"?r.on.input:r.on.change)(r.emitValue(e.change)))}function he(e,{triggerOn:t="change"}={}){return r.Fragment(B(e),r.attr.valueAsNumber(e.signal),(t==="input"?r.on.input:r.on.change)(r.emitValueAsNumber(e.change)))}function F(e){return e.issues!=null?b.invalid(J(e.issues)):b.valid}async function de({task:e,errorMessage:t,errorPath:s=["root"],validation:n}){try{const a=await e();return n!=null?n(a):b.valid}catch(a){const i=t??(a instanceof Error?a.message:"Operation failed");return s.length===1&&s[0]==="root"?b.invalid({message:i}):b.invalid({dependencies:X(s,i)})}}function X(e,t){if(e.length===1)return{[e[0]]:{message:t}};const[s,...n]=e;return{[s]:{dependencies:X(n,t)}}}function pe({initialValue:e={},schema:t,onSubmit:s=async()=>b.valid,validationMode:n,validateDebounceMs:a}){const{controller:i,setStatus:o}=Q({initialValue:e,validationMode:n??"onTouched",validateDebounceMs:a,validate:(n??"onTouched")==="onSubmit"||t==null?void 0:async u=>F(await t["~standard"].validate(u))}),l=r.prop(!1),c=i.object();return c.onDispose(l.dispose),{controller:c,setStatus:o,submit:async u=>{if(l.set(!0),u?.preventDefault(),c.markAllTouched(),t!=null){const v=c.signal.value,k=F(await t["~standard"].validate(v));if(o(k),k.type==="invalid"){l.set(!1);return}}const m=await s(c.signal.value);l.set(!1),m.type==="invalid"&&o(m)},submitting:l}}exports.ArrayController=K;exports.BaseControl=x;exports.BaseMappedControl=W;exports.CheckboxInput=se;exports.CloseButton=Z;exports.Control=le;exports.Controller=S;exports.DangerLabel=te;exports.EmphasisLabel=ee;exports.InputWrapper=L;exports.Label=$;exports.MappedControl=oe;exports.MutedLabel=q;exports.O=E;exports.ObjectController=R;exports.RequiredSymbol=j;exports.Stack=ie;exports.a=b;exports.connectCommonAttributes=B;exports.connectNumberInput=he;exports.connectStringInput=ue;exports.convertStandardSchemaIssues=J;exports.convertStandardSchemaPathToPath=G;exports.makeMapValidation=V;exports.makeOnBlurHandler=H;exports.makeOnChangeHandler=M;exports.parsePath=ce;exports.pathToString=U;exports.sessionId=I;exports.standardSchemaResultToValidation=F;exports.taskToValidation=de;exports.useController=Q;exports.useForm=pe;exports.wrapSegment=z;
|