@golemui/core 0.0.2 → 0.12.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/README.md +15 -6
- package/index.d.ts +10 -6
- package/index.js +1336 -1018
- package/index.umd.cjs +8 -8
- package/lib/context/form.context.d.ts +9 -4
- package/lib/context/widget-registry.d.ts +6 -1
- package/lib/errors.d.ts +10 -0
- package/lib/form-validator.d.ts +2 -7
- package/lib/form-widget.d.ts +1 -0
- package/lib/form.d.ts +19 -2
- package/lib/i18n.d.ts +19 -3
- package/lib/middleware/devtools/devtools.middleware.d.ts +17 -0
- package/lib/middleware/index.d.ts +1 -2
- package/lib/shared.d.ts +21 -0
- package/lib/store/actions.d.ts +18 -2
- package/lib/store/model.d.ts +19 -10
- package/lib/store/reducers/index.d.ts +2 -1
- package/lib/store/reducers/set-meta.d.ts +3 -0
- package/lib/store/reducers/utils.d.ts +0 -2
- package/lib/store/reducers/validate-all.d.ts +2 -1
- package/lib/store/selectors.d.ts +5 -1
- package/lib/utils/array.d.ts +60 -0
- package/lib/utils/assert-no-prop-collisions.d.ts +9 -0
- package/lib/utils/dev-mode.d.ts +2 -0
- package/lib/utils/form.d.ts +59 -0
- package/lib/utils/justin.d.ts +3 -0
- package/lib/utils/object.d.ts +4 -2
- package/lib/utils/repeater.d.ts +31 -1
- package/package.json +6 -1
- package/CHANGELOG.md +0 -517
- package/lib/middleware/json-schema/json-schema.d.ts +0 -67
- package/lib/middleware/json-schema/json-schema.middleware.d.ts +0 -19
- package/lib/utils/dot-path.d.ts +0 -16
package/index.umd.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
`),n=r.pop(),
|
|
3
|
-
${
|
|
4
|
-
`,""+
|
|
5
|
-
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},
|
|
6
|
-
`,"/*":"*/"};let
|
|
7
|
-
`)for(;
|
|
8
|
-
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},Ct=()=>{const e=[];for(let t="",r;(r=y.charCodeAt(h))!==Ae;)r?r===Gr?(O(),t+=Mr[y[h]]||y[h],O()):r===Br&&y.charCodeAt(h+1)===Hr?(t&&e.push([,t]),t="",O(2),e.push(E(0,125))):(t+=y[h],O(),r=y.charCodeAt(h),r===Ae&&t&&e.push([,t])):L("Unterminated template");return O(),e},Jr=T[Ae];T[Ae]=(e,t)=>e&&t<Vr?$.asi&&$.newline?void 0:(O(),["``",e,...Ct()]):e?Jr?.(e,t):(O(),(r=>r.length<2&&r[0]?.[0]===void 0?r[0]||[,""]:["`",...r])(Ct())),l("`",(...e)=>(e=e.map(d),t=>e.map(r=>r(t)).join(""))),l("``",(e,...t)=>{e=d(e);const r=[],n=[];for(const i of t)Array.isArray(i)&&i[0]===void 0?r.push(i[1]):n.push(d(i));const o=Object.assign([...r],{raw:r});return i=>e(i)(o,...n.map(s=>s(i)))}),$.string["'"]=!0,$.number={"0x":16,"0b":2,"0o":8};const z=e=>{let t=e.formDef.states;if(!t||Object.keys(t).length===0||e.formHealth.status==="errored")return e;t=Kr(t);let r=[],n={status:"ok"};try{r=Object.keys(t).map(o=>{const i=t[o],s=$(i);return d(s)({$form:e.data,$log:(f,A)=>(A?console.log(A,f):console.log(f),f)})===!0?o:void 0}).filter(o=>o!==void 0)}catch(o){n={status:"errored",message:o.message}}return{...e,currentStates:r,formHealth:n}};function Kr(e){const t={};function r(n){const o=n.split(":"),i=[];for(let s=0;s<o.length;s++)i.push(o.slice(0,s+1).join(":"));return i}for(const[n,o]of Object.entries(e)){const i=r(n),s=[];for(const u of i)e[u]&&s.push(`(${e[u]})`);t[n]=s.join(" && ")}return t}const Se=(e,t)=>r=>e(r)?t(r):r,Xr=e=>t=>{const r=t.touchedControls[e];return t.touched&&r},b=e=>e!==void 0&&typeof e=="object"&&e!==null&&"when"in e,x=e=>({...e,widgetFlags:Qr(e)});function Qr(e){return Object.values(e.flatForm).map(t=>{if(se(t)){const r=t({$form:e.data,errors:void 0,touched:void 0,translate:void 0});return r.uid=t.uid,r}return t}).filter(t=>!!(t.include&&("in"in t.include||t.include)||t.exclude&&("from"in t.exclude||"when"in t.exclude)||W(t)||ie(t)&&b(t.disabled)||W(t)&&b(t.readonly))).reduce((t,r)=>(t[r.uid]=t[r.uid]||{},r.include&&"in"in r.include?t[r.uid].hidden=!r.include.in.some(n=>e.currentStates.includes(n)):r.include&&"when"in r.include&&(t[r.uid].hidden=!$e(r.include.when,e.data)),r.exclude&&"from"in r.exclude?t[r.uid].hidden=r.exclude.from.some(n=>e.currentStates.includes(n)):r.exclude&&"when"in r.exclude&&(t[r.uid].hidden=$e(r.exclude.when,e.data)),(W(r)||ie(r))&&b(r.disabled)&&(t[r.uid].disabled=$e(r.disabled.when,e.data)),W(r)&&b(r.readonly)&&(t[r.uid].readonly=$e(r.readonly.when,e.data)),t),{})}function $e(e,t){const r=$(e);return d(r)({$form:t,$log:(i,s)=>(s?console.log(s,i):console.log(i),i)})===!0}const Et=e=>!(typeof e!="object"||e===null||typeof e.key!="string");function Zr(e){const t=new Intl.Locale(e).maximize().script;return["Arab","Hebr","Thaa","Syrc","Tfng","Adlm","Rohg"].includes(t||"")?"rtl":"ltr"}const vt=(e=navigator.language||"en-US")=>({get lang(){return e},translate(t){return t},subscribe(){return()=>{}}}),qr=e=>typeof e=="string"&&!e.includes(" ")&&(e.startsWith("$form.")||e.startsWith("$error.")||e.startsWith("$meta.")),V=(e,t)=>{if(e===void 0)throw new Error("obj is undefined");return t.split(".").reduce((r,n)=>r===void 0||n===""?r:Array.isArray(r)?r[parseInt(n,10)]:r[n],e)},ee=(e,t,r)=>{if(e===null)throw new Error("object is null");if(e===void 0)throw new Error("object is undefined");if(t==="")throw new Error("path cannot be empty");const n=t.split(".");let o=e;for(let s=0;s<n.length-1;s++){const u=n[s],c=n[s+1];(o[u]==null||typeof o[u]!="object")&&(o[u]=Yr(c)?[]:{}),o=o[u]}const i=n[n.length-1];return o[i]=r,e};function Yr(e){const t=Number(e);return Number.isInteger(t)&&t>=0&&t.toString()===e}const te=(e,t)=>(delete e[t],e);function jr(e){return JSON.parse(JSON.stringify(e))}const K=e=>t=>({...t,calculatedWidgets:br(t,e)}),zr=(e,t)=>({source:e,previous:t,current:{},changed:!1});function Ke(e){return Array.from(new Set(e.map(t=>t.split(".")[0])))}function br(e,t){return Object.keys(e.calculatedWidgets).reduce((r,n)=>{if(e.widgetFlags[n]!==void 0&&e.widgetFlags[n].hidden)return r;const o=e.calculatedWidgets[n],i=o.source;if(se(i))return o.previous=o.current,o.current=i({$form:e.data,errors:i.path?e.validations[i.path]:void 0,touched:i.path?e.touchedControls[i.path]:void 0,translate:t.translate}),o.current.uid=n,r[n]={...o},r;const s=zr(i,o.current);Ke(Object.keys(i)).filter(c=>c!=="props"&&c!=="on").forEach(c=>{Xe({currentStates:e.currentStates,widgetPropOverrides:e.widgetPropOverrides,derivedWidget:s,property:c,$form:e.data,widgetFlags:e.widgetFlags,localization:t})});const u={...i.props||{},...e.widgetPropOverrides[i.uid]};if(Ke(Object.keys(u)).forEach(c=>{Xe({currentStates:e.currentStates,widgetPropOverrides:e.widgetPropOverrides,derivedWidget:s,property:"props",subProp:c,$form:e.data,widgetFlags:e.widgetFlags,localization:t})}),(W(i)||ie(i))&&Ke(Object.keys(i.on||{})).forEach(c=>{Xe({currentStates:e.currentStates,widgetPropOverrides:e.widgetPropOverrides,derivedWidget:s,property:"on",subProp:c,$form:e.data,widgetFlags:e.widgetFlags,localization:t})}),ve(i)){const c=s.previous.children||[],f=i.children.filter(A=>!e.widgetFlags[A.uid]||e.widgetFlags[A.uid].hidden!==!0);s.current.children=f,s.changed=c.length!==f.length||!f.every((A,p)=>c[p]&&c[p].uid===f[p].uid)}return r[n]=s.changed?s:o,delete r[n].changed,r},{})}function Xe({currentStates:e,widgetPropOverrides:t,derivedWidget:r,property:n,subProp:o,$form:i,widgetFlags:s,localization:u}){const c=e.sort((p,C)=>C.length-p.length).find(p=>(o?r.source?.[n]?.[`${o}.${p}`]:r.source[`${n}.${p}`])!==void 0);let f;c===void 0?f=o?r.source[n]?.[o]:r.source[n]:f=o?r.source[n]?.[`${o}.${c}`]:r.source[`${n}.${c}`];const A=o?`${n}.${o}`:n;typeof f=="function"?ee(r.current,A,f({$form:i,translate:u.translate})):(Et(f)&&(f=u.translate(f.key,xr(f.params,i),f.default)),(n==="disabled"||n==="readonly")&&b(f)&&(f=s[r.current.uid][n]),ee(r.current,A,f)),n==="props"&&o&&t[r.source.uid]&&t[r.source.uid][o]!==void 0&&ee(r.current,A,t[r.source.uid][o]),V(r.previous,A)!==V(r.current,A)&&(r.changed=!0)}const xr=(e,t)=>e&&Object.keys(e).reduce((r,n)=>{const o=String(e[n]);if(qr(o)){const i=o.replace("$form.","");r[n]=V(t,i)||o}else r[n]=o;return r},{});function It(e){return e.flatMap(t=>[t,...ve(t)?It(t.children):[]])}const en=({lang:e},t)=>{const r={...Fe(e),formName:t.payload.formName};let n=t.payload.formDef,o={status:"ok"};if(typeof n=="string"){try{n=JSON.parse(n)}catch(s){o={status:"errored",message:s.message}}if(o.status==="errored")return{...r,formHealth:o}}if(Array.isArray(n.form)){const s=n,u=s.form;s.form={uid:"",type:"flex",kind:"layout",children:u}}const i=we.decode(n);if(i.isOk()){o={status:"ok"};let s={};try{s=It([i.value.form]).reduce((u,c)=>{if(u[c.uid])throw{existingWidget:u[c.uid],newWidget:c};return u[c.uid]=c,u},{})}catch(u){o={status:"errored",message:tn(u.existingWidget,u.newWidget)},s={}}return{...r,formDef:i.value,flatForm:s,formHealth:o}}return{...r,formHealth:{status:"errored",message:i.error}}};function tn(e,t){const r=n=>W(n)?` at "${n.path}"`:"";return`Duplicate UID "${t.uid}": Assigned to widget "${e.type}"${r(e)} and "${t.type}"${r(t)}.`}function rn(e,t){return{...e,injectedValidations:{...e.injectedValidations,[t.payload.path]:t.payload.issues}}}const nn=(e,{payload:t})=>{const r=Object.values(e.calculatedWidgets).find(({source:o})=>W(o)&&o.path===t.path);if(!r)return console.warn(`Control "${t.path}" not found`),e;const n=e.widgetPropOverrides[r.source.uid]||{};return{...e,widgetPropOverrides:{[r.source.uid]:{...n,[t.prop]:t.value}}}};function on(e,t){return{...e,widgetFlags:{...te(e.widgetFlags,t.payload.uid)},calculatedWidgets:{...te(e.calculatedWidgets,t.payload.uid)},widgetPropOverrides:{...te(e.widgetPropOverrides,t.payload.uid)},touchedControls:{...k(e.touchedControls,r=>{const n=e.flatForm[t.payload.uid];return n&&W(n)?te(r,n.path):r})}}}const sn=(e,t)=>({...e,data:{...t.payload.data}}),dn=(e,t)=>{const r=V(e.data,t.payload.path);return t.type==="SET_WIDGET_DATA"||t.type==="SET_WIDGET_INITIAL_DATA"&&r===void 0?{...e,data:{...ee(e.data,t.payload.path,t.payload.data)}}:e},un=(e,t)=>({...e,formHealth:t.payload.formHealth}),cn=(e,t)=>({...e,lang:t.payload.lang});function Ot(e,t){const r=e["~standard"].validate(t);if(r instanceof Promise)throw new TypeError("Schema validation must be synchronous");return r}function Dt(e){return e.issues===void 0}const wt=Symbol("filterMap.skip");function ln(e,t){const r=[];for(let n=0;n<e.length;n++){const o=t(e[n],n,e);o!==wt&&r.push(o)}return r}function an(e,t,r){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!r(e[n],t[n],n,e,t))return!1;return!0}const Qe=e=>t=>{const r=ln(Object.values(t.calculatedWidgets),({current:o})=>W(o)?o:wt),n=t.validations;return{...t,validations:r.reduce((o,i)=>{if(o[i.path]=null,i.validator){const s=e(i.validator),u=V(t.data,i.path),c=Ot(s,u);o[i.path]=Dt(c)?null:c.issues.map(f=>f.message)}return Array.isArray(o[i.path])&&Array.isArray(n[i.path])&&an(o[i.path],n[i.path],(s,u)=>s===u)&&(o[i.path]=n[i.path]),o},{})}},fn=({validators:e,validateOn:t,localization:r})=>(n,o)=>{switch(o.type){case"INITIALIZE":return en(n,o);case"SET_DATA":return k(sn(n,o),z,x,K(r));case"SET_LANGUAGE":return k(cn(n,o),K(r));case"ADD_WIDGET":return k(rr(n,o),Se(Ze,z),Se(Ze,x),Se(Ze,K(r)));case"REMOVE_WIDGET":return k(on(n,o),z,x,K(r));case"SET_WIDGET_INITIAL_DATA":case"SET_WIDGET_DATA":return k(dn(n,o),z,x,K(r));case"OVERRIDE_WIDGET_PROP":return k(nn(n,o),z,x,K(r),Se(Xr(o.payload.path),Qe(e)));case"SET_FORM_HEALTH":return un(n,o);case"VALIDATE_ALL":return k({...n,touched:!0,touchedControls:Object.keys(n.calculatedWidgets).reduce((i,s)=>{const u=n.calculatedWidgets[s].source;return W(u)&&(i[u.path]=!0),i},{})},Qe(e));case"ATTEMPT_VALIDATION":{const i=o.payload.reason,s=o.payload.path;return t==="eager"||i===t||t.includes(i)?k({...n,touched:!0,touchedControls:{...n.touchedControls,[s]:!0}},Qe(e),c=>{const f=o.payload.uid,A=c.calculatedWidgets[f],p=A.source;if(se(p)){const C=p({$form:c.data,errors:c.validations[s],touched:!0,translate:r.translate});return{...c,calculatedWidgets:{...c.calculatedWidgets,[f]:{...A,previous:A.current,current:C}}}}return c}):n}case"INJECT_VALIDATION_ISSUES":return rn(n,o);default:return er(o)}},Ze=e=>e.formHealth.status==="ok";function Ft(e=[],t,r,n){const o=new a.BehaviorSubject(Fe(n.lang)),i=o.asObservable().pipe(a.distinctUntilChanged()),s=fn({validators:t,validateOn:r,localization:n});function u(p){const C=o.getValue(),B=s(C,p);o.next(B)}let c=u;const f={getState:()=>o.getValue(),dispatch:p=>c(p)};return c=e.map(p=>p(f)).reduceRight((p,C)=>C(p),u),{state$:i,dispatch:c,getState:()=>o.getValue()}}const hn=a.pipe(a.map(e=>e.data),a.distinctUntilChanged()),pn=e=>a.pipe(hn,a.map(t=>V(t,e)),a.distinctUntilChanged()),gn=a.pipe(a.filter(e=>e.touched===!0),a.map(e=>e.validations),a.distinctUntilChanged()),yn=e=>a.pipe(gn,a.map(t=>t[e]),a.distinctUntilChanged()),mn=a.pipe(a.filter(e=>e.touched===!0),a.map(e=>e.injectedValidations),a.distinctUntilChanged()),An=e=>a.pipe(mn,a.map(t=>t[e]),a.distinctUntilChanged(),a.startWith(null)),Wt=a.pipe(a.map(e=>e.calculatedWidgets),a.distinctUntilChanged()),Sn=e=>a.pipe(Wt,a.map(t=>t[e]),a.filter(t=>t!==void 0),a.map(t=>t.current),a.distinctUntilChanged()),$n=e=>a.pipe(Wt,a.map(t=>t[e]),a.filter(t=>t!==void 0),a.map(t=>t.current.children),a.distinctUntilChanged()),Tt=a.pipe(a.map(e=>e.widgetFlags),a.distinctUntilChanged()),Cn=e=>a.pipe(Tt,a.map(t=>t[e]),a.distinctUntilChanged()),En=a.pipe(a.map(e=>e.touchedControls),a.distinctUntilChanged()),vn=e=>a.pipe(En,a.map(t=>t[e]),a.distinctUntilChanged()),In=a.pipe(a.map(e=>e.formHealth),a.distinctUntilChanged((e,t)=>!(e.status!==t.status||e.status==="errored"))),On=e=>e.pipe(In);class kt{constructor(){this.registry={},this.widgetLoaders={},this._ready=!1}get ready(){return this._ready}setWidgetLoaders(t){this.widgetLoaders=t,this._ready=!0}async loadWidget(t){return this.registry[t]??(this.registry[t]=await this.widgetLoaders[t]())}}class Dn{constructor(){this.widgetRegistry=new kt,this.store={},this.events$=new a.Subject,this.uuid=crypto.randomUUID(),this.itemRenderers={}}initialize(t,r=[],n,o,i,s=vt()){this.localization=s,this.widgetRegistry.setWidgetLoaders(t),this.itemRenderers=i,this.store=Ft(r,n,o,s)}emitEvent(t,r,n){const i=this.store.getState().currentStates.filter(s=>r.on?.[`${t}.${s}`]!==void 0);if(i.length>0)i.forEach(s=>{const u=r.on?.[`${t}.${s}`];this.attemptValidation(t,u,r),u&&this.events$.next({name:u,data:this.store.getState().data,detail:n??void 0,callback:c=>{this.store.dispatch(c)}})});else{const s=r.on?.[t];this.attemptValidation(t,s,r),s&&this.events$.next({name:s,data:this.store.getState().data,detail:n,callback:u=>{this.store.dispatch(u)}})}}attemptValidation(t,r,n){n.kind!=="layout"&&(t==="change"?this.store.dispatch({type:"ATTEMPT_VALIDATION",payload:{reason:"change",path:n.path,uid:n.uid}}):t==="click"&&r==="submit"&&this.store.dispatch({type:"VALIDATE_ALL"}))}}function Pt(e){return e.$schema!==void 0&&e.$schema.startsWith("https://json-schema.org/draft")}const wn=e=>t=>r=>n=>{if(n.type==="INITIALIZE"){let o=n.payload.formDef==="string"?JSON.parse(n.payload.formDef):n.payload.formDef;Pt(o)&&(o=re(o,e,()=>{throw new Error("Ref resolving not implemented")}),o={form:o}),r({...n,payload:{...n.payload,formDef:o}})}else r(n)};function re(e,t,r,n=[]){if(e.$ref){const i=r(e.$ref);return re(i,t,r,n)}if(e.oneOf)return{...t.oneOf(e),props:{},children:e.oneOf.map(s=>re(s,t,r,n))};if(e.anyOf)return{...t.anyOf(e),props:{},children:e.anyOf.map(s=>re(s,t,r,n))};if(e.type==="object"){const i=[];if(e.properties)for(const[s,u]of Object.entries(e.properties)){const c=[...n,s],f=re(u,t,r,c);i.push(f)}return t.object(e,i)}if(e.type==="array")throw new Error(`Arrays not supported yet at path: ${n.join(".")}`);if(e.enum)return t.enum(e,n.join("."));const o=t[e.type];return o?o(e,n.join(".")):t.fallback(e)}const Fn={log:(e,t)=>(t?console.log(t,e):console.log(e),e)};function Wn(e,t){const r=Tn(e.uid,t);return W(e)?{...e,uid:r,path:kn(e.path,t)}:{...e,uid:r}}function Tn(e,t){if(t===-1)throw new Error("-1 is an invalid Repeater index");return`${e}[${t}]`}function kn(e,t){if(t===-1)throw new Error("-1 is an invalid Repeater index");return e.replace(".items.",`.${t}.`)}g.Debug=Fn,g.FormContext=Dn,g.WidgetRegistry=kt,g.calculatedLayoutChildrenByUid$=$n,g.calculatedWidgetsByUid$=Sn,g.cloneObject=jr,g.compose=tr,g.createFormStore=Ft,g.createInitialState=Fe,g.dataByPath$=pn,g.defineForm=xt,g.deleteKey=te,g.formDefDecoder=we,g.formHealth=On,g.get=V,g.getDirectionFromLanguage=Zr,g.identityTranslator=vt,g.injectedValidationByPath$=An,g.isActionWidget=ie,g.isDisplayWidget=Jt,g.isFunctionWidget=se,g.isInputWidget=W,g.isJsonSchema=Pt,g.isLayoutWidget=ve,g.isStandardValidateSuccess=Dt,g.isTranslationConfig=Et,g.jsonSchemaMiddleware=wn,g.layoutWidgetDecoder=le,g.makeRepeaterItemConfig=Wn,g.pipe=k,g.selectWidgetFlags=Tt,g.set=ee,g.shortUUID=Ee,g.standardValidate=Ot,g.touchedControlsByPath$=vn,g.validationByPath$=yn,g.widgetFlagsByUid$=Cn,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(f,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("rxjs")):typeof define=="function"&&define.amd?define(["exports","rxjs"],a):(f=typeof globalThis<"u"?globalThis:f||self,a(f.core={},f.rxjs))})(this,(function(f,a){"use strict";const q=class q{constructor(){this.widgetLoaders={},this._ready=!1}get ready(){return this._ready}setWidgetLoaders(t){this.widgetLoaders=t,this._ready=!0}async loadWidget(t){const r=this.widgetLoaders[t];if(!q.sharedCache.has(r)){const n=r().catch(i=>(q.sharedCache.delete(r),Promise.reject(i)));q.sharedCache.set(r,n)}return q.sharedCache.get(r)}};q.sharedCache=new Map;let ae=q;var rr=class{constructor(e){this.value=e}map(e){return T(e(this.value))}isOk(){return!0}},nr=class{constructor(e){this.error=e}map(e){return C(this.error)}isOk(){return!1}};function T(e){return new rr(e)}function C(e){return new nr(e)}var W=class ct{constructor(t){this.decodeFn=t,this["~standard"]={version:1,vendor:"ts.data.json",validate:r=>{let n=this.decode(r);return n.isOk()?{value:n.value}:{issues:[{message:n.error}]}}},this.decodeToPromise=this.decodePromise,this.chain=this.flatMap}parse(t){let r=this.decode(t);if(r.isOk())return r.value;throw r.error}decode(t){return this.decodeFn(t)}decodePromise(t){return new Promise((r,n)=>{let i=this.decode(t);return i.isOk()?r(i.value):n(i.error)})}map(t){return new ct(r=>{let n=this.decodeFn(r);return n.isOk()?T(t(n.value)):C(n.error)})}flatMap(t){return new ct(r=>{let n=this.decodeFn(r);return n.isOk()?t(n.value).decode(r):C(n.error)})}},ir=(e,t,r)=>`<${e}> decoder failed at index "${t}" with error: ${r}`,Y=(e,t)=>`${JSON.stringify(e)} is not a valid ${t}`;function Te(e,t){return new W(r=>{if(r instanceof Array){let n=[];for(let i=0;i<r.length;i++){let o=e.decode(r[i]);if(o.isOk())n.push(o.value);else return C(ir(t,i,o.error))}return T(n)}else return C(Y(r,"array"))})}function or(){return new W(e=>typeof e=="boolean"?T(e):C(Y(e,"boolean")))}function sr(e){return new W(t=>e().decode(t))}var dr=(e,t)=>`${JSON.stringify(e)} is not exactly ${JSON.stringify(t)}`;function fe(e){return new W(t=>t===e?T(e):C(dr(t,e)))}function he(){return new W(e=>typeof e=="number"?T(e):C(Y(e,"number")))}var ur=(e,t,r)=>`<${e}> decoder failed at key "${t}" with error: ${r}`;function te(e,t){return new W(r=>{if(r!==null&&typeof r=="object"){let n={};for(let i in e)if(Object.prototype.hasOwnProperty.call(e,i)){let o,s=e[i];if(s instanceof W?o=s.decode(r[i]):o=s.decoder.decode(r[s.fromKey]),o.isOk())n[i]=o.value;else return C(ur(t,i,o.error))}return T(n)}else return C(Y(r,t))})}var cr=(e,t)=>`<${e}> decoder failed because ${JSON.stringify(t)} can't be decoded with any of the provided oneOf decoders`;function Z(e,t){return new W(r=>{for(let n=0;n<e.length;n++){let i=e[n].decode(r);if(i.isOk())return i}return C(cr(t,r))})}function S(e){return new W(t=>t===void 0?T(void 0):e.decode(t))}var lr=(e,t,r)=>`<${e}> record decoder failed at key "${t}" with error: ${r}`;function ar(e,t){return new W(r=>{if(r!==null&&typeof r=="object"){let n={};for(let i in r)if(Object.prototype.hasOwnProperty.call(r,i)){let o=e.decode(r[i]);if(o.isOk())n[i]=o.value;else return C(lr(t,i,o.error))}return T(n)}else return C(Y(r,t))})}function O(){return new W(e=>typeof e=="string"?T(e):C(Y(e,"string")))}function X(){return new W(e=>T(e))}function re(e,t){return new W(r=>{if(typeof r!="object"||r===null)return C(`<${t}> failed. Expected object literal, got "${typeof r}"`);const n={};for(const[i,o]of Object.entries(e)){const s=o.decoder.decode(r[i]);if(!s.isOk())return C(`<${t}> failed at "${i}" with ${s.error}`);if(n[i]=s.value,o.suffixed){for(const[u,c]of Object.entries(r))if(u.startsWith(i+".")){const g=o.decoder.decode(c);if(!g.isOk())return C(`<${t}> failed at "${u}" with ${g.error}`);n[u]=g.value}}}return T(n)})}const Re=()=>crypto.randomUUID().slice(0,8),lt=e=>typeof e!="function"&&e.kind==="display",j=e=>typeof e!="function"&&e.kind==="action",F=e=>typeof e!="function"&&e.kind==="input",pe=e=>typeof e!="function"&&e.kind==="layout",b=e=>typeof e=="function",fr=te({in:Te(O(),"In[]")},"In"),ke=te({when:O()},"When"),ge=Z([fr,ke],"In | When"),hr=te({from:Te(O(),"From[]")},"From"),me=Z([hr,ke],"Exclude"),_e=Z([or(),ke],"Bool | When"),pr=new W(e=>{const t=typeof e;return t==="function"?T(e):C(`Expected a function, got '${t}'`)}),M=e=>Z([e,pr],""),Ue=re({load:{suffixed:!0,decoder:M(S(O()))},click:{suffixed:!0,decoder:M(S(O()))},change:{suffixed:!0,decoder:M(S(O()))},filter:{suffixed:!0,decoder:M(S(O()))},blur:{suffixed:!0,decoder:M(S(O()))}},"On"),gr=te({key:O(),default:S(O()),params:X()},"TranslationConfig"),at=Z([O(),gr],"Localizable"),ye=S(O()).map(e=>e||Re()),mr=re({kind:{decoder:fe("display")},uid:{decoder:ye},type:{decoder:O()},size:{suffixed:!0,decoder:S(he())},include:{decoder:S(ge)},exclude:{decoder:S(me)},props:{decoder:S(X())}},"DisplayWidget"),yr=re({kind:{decoder:fe("action")},uid:{decoder:ye},type:{decoder:O()},size:{suffixed:!0,decoder:S(he())},include:{decoder:S(ge)},exclude:{decoder:S(me)},label:{suffixed:!0,decoder:M(at)},disabled:{suffixed:!0,decoder:S(_e)},on:{decoder:S(Ue)},props:{decoder:S(X())}},"ActionWidget"),$r=new W(e=>{const t=typeof e;if(t==="function"){const r=e,n=r(void 0);return r.uid=n.uid||Re(),r.type=n.type,r.path=n.path,T(r)}else return C(`Expected a function, got '${t}'`)}),Ar=re({kind:{decoder:fe("input")},uid:{decoder:ye},type:{decoder:O()},size:{suffixed:!0,decoder:S(he())},include:{decoder:S(ge)},exclude:{decoder:S(me)},disabled:{suffixed:!0,decoder:S(_e)},readonly:{suffixed:!0,decoder:S(_e)},on:{decoder:S(Ue)},props:{decoder:S(X())},label:{suffixed:!0,decoder:M(S(at))},path:{decoder:O()},defaultValue:{decoder:S(X())},validator:{suffixed:!0,decoder:M(S(X()))}},"InputWidget").map(e=>{const t={...e};if(e.uid||(t.uid=`${e.path}-${e.type}`),e.type==="repeater"){const r=e.props;r.template=$e.parse(r.template)}return t}),Sr=sr(()=>Z([$r,Ar,$e,mr,yr],"FormWidget")),$e=re({kind:{decoder:fe("layout")},uid:{decoder:ye},type:{decoder:O()},size:{suffixed:!0,decoder:S(he())},include:{decoder:S(ge)},exclude:{decoder:S(me)},props:{decoder:S(X())},on:{decoder:S(Ue)},children:{decoder:Te(Sr,"FormWidget[]")}},"LayoutWidget");function Er(e){return{...e,form:{uid:"",type:"flex",kind:"layout",children:e.form}}}const Ne=te({states:S(ar(O(),"states")),form:$e},"FormDef"),Le=e=>({formName:"",formDef:Ne.parse({form:{kind:"layout",type:"flex",children:[]}}),flatForm:{},currentStates:[],calculatedWidgets:{},validations:{},touchedControls:{},injectedValidations:{},widgetFlags:{},widgetPropOverrides:{},data:{},meta:{},formHealth:{status:"ok"},touched:!1,lang:e}),vr=e=>{throw new Error(`Unhandled case: ${JSON.stringify(e)}`)};function U(e,...t){return t.reduce((r,n)=>n(r),e)}function Ir(...e){return t=>e.reduceRight((r,n)=>n(r),t)}function Cr(e,t){return{...e,calculatedWidgets:{...e.calculatedWidgets,[t.payload.widget.uid]:{source:t.payload.widget,current:{}}}}}const ne={calculateCurrentStateError:10,initializeParseError:20,initializeUidCollisionError:21,initializeUnknownError:22,widgetCouldNotBeLoaded:30},k=(e,t)=>{if(e===void 0)throw new Error("obj is undefined");return t.split(".").reduce((r,n)=>r===void 0||n===""?r:Array.isArray(r)?r[parseInt(n,10)]:r[n],e)},Ae=(e,t,r)=>{if(e===null)throw new Error("object is null");if(e===void 0)throw new Error("object is undefined");if(t==="")throw new Error("path cannot be empty");const n=t.split(".");let i=e;for(let s=0;s<n.length-1;s++){const u=n[s],c=n[s+1];(i[u]==null||typeof i[u]!="object")&&(i[u]=Or(c)?[]:{}),i=i[u]}const o=n[n.length-1];return i[o]=r,e};function Or(e){const t=Number(e);return Number.isInteger(t)&&t>=0&&t.toString()===e}const ie=(e,t)=>(delete e[t],e);function Me(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(r=>Me(r));const t={};for(const r of Object.keys(e))t[r]=Me(e[r]);return t}const D={FORM:"$form",META:"$meta",ERRORS:"$errors",FORM_IS_INVALID:"$formIsInvalid"},wr=e=>typeof e=="string"&&!e.includes(" ")&&(e.startsWith(`${D.FORM}.`)||e.startsWith(`${D.META}.`)||e.startsWith(`${D.ERRORS}.`)||e===D.FORM_IS_INVALID),Fr=[D.FORM,D.META,D.ERRORS].map(e=>e.replace("$","\\$")).join("|"),Dr=new RegExp(`\\{\\{(?:(?<scope>${Fr})\\.(?<path>[^}]+)|(?<isInvalid>\\${D.FORM_IS_INVALID}))\\}\\}`,"g"),Pr=(e,t)=>typeof e!="string"||!e.includes("{{$")?e:e.replace(Dr,(r,...n)=>{const i=n[n.length-1],{scope:o,path:s,isInvalid:u}=i;try{if(u===D.FORM_IS_INVALID)return t.resolveFormIsInvalid();if(o&&s)switch(o){case D.FORM:return t.resolveFormPath(s);case D.META:return t.resolveMetaPath(s);case D.ERRORS:return t.resolveErrorsPath(s);default:return r}}catch(c){return console.error(`Error resolving Expression: '${e}'`,c),r}return r}),Wr=(e,t)=>{const r=`${D.FORM}.`;if(e.startsWith(r))return t.resolveFormPath(e.replace(r,""));const n=`${D.META}.`;if(e.startsWith(n))return t.resolveMetaPath(e.replace(n,""));const i=`${D.ERRORS}.`;if(e.startsWith(i))return t.resolveErrorsPath(e.replace(i,""));if(e===D.FORM_IS_INVALID)return t.resolveFormIsInvalid()};function Ve(e){return e.flatMap(t=>[t,...pe(t)?Ve(t.children):[]])}function Be(e){return Object.entries(e.validations).reduce((r,[n,i])=>(i!==null&&(r.$formIsInvalid=!0,Ae(r.$errors,n,[...i])),r),{$formIsInvalid:!1,$errors:{}})}const He=32;let Ge,h,m,$=e=>(h=0,m=e,$.newline=!1,e=v(),m[h]?z():e||""),z=(e="Unexpected token",t=h,r=m.slice(0,t).split(`
|
|
2
|
+
`),n=r.pop(),i=m.slice(Math.max(0,t-40),t),o="̭",s=(m[t]||" ")+o,u=m.slice(t+1,t+20))=>{throw SyntaxError(`${e} at ${r.length+1}:${n.length+1}
|
|
3
|
+
${m[t-41]!==`
|
|
4
|
+
`,""+i}${s}${u}`)},ft=(e,t=h)=>(Array.isArray(e)&&(e.loc=t),e),x=(e,t=h,r)=>{for(;r=e(m.charCodeAt(h));)h+=r;return m.slice(t,h)},w=(e=1)=>m[h+=e],Ke=e=>h=e,v=(e=0,t)=>{let r,n,i,o,s;for(t&&$.asi&&($.newline=!1);(r=$.space())&&(s=$.newline,1)&&r!==t&&(i=(n&&r===91&&Ge&&$.asi?.(n,e,v)||null)??((o=_[r])&&o(n,e))??(n&&s&&$.asi?.(n,e,v))??(!n&&x($.id)));)n=i;return t&&(r==t?(h++,t===125&&$.asi&&($.newline=!0)):z("Unclosed "+String.fromCharCode(t-(t>42?2:1)))),n},V=(e,t=h)=>{for(Ge=!1;(e=m.charCodeAt(h))<=He;)$.asi&&e===10&&($.newline=Ge=!0),h++;return e},Tr=(e=h)=>{for(;m.charCodeAt(e)<=He;)e++;return m.charCodeAt(e)};$.id=e=>e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e==36||e==95||e>=192&&e!=215&&e!=247;let Rr=(e,t=e.length)=>m.substr(h,t)===e&&!$.id(m.charCodeAt(h+t)),_=[],ht={},R=(e,t=He,r,n=e.charCodeAt(0),i=e.length,o=_[n],s=e.toUpperCase()!==e,u,c)=>(t=ht[e]=!o&&ht[e]||t,_[n]=(g,E,y,p=h)=>(u=y,(y?e==y:(i<2||e.charCodeAt(1)===m.charCodeAt(h+1)&&(i<3||m.substr(h,i)==e))&&(!s||!$.id(m.charCodeAt(h+i)))&&(u=y=e))&&E<t&&(h+=i,(c=r(g))?ft(c,p):(h=p,u=0,!s&&!o&&!g&&z()),c)||o?.(g,E,u))),A=(e,t,r=!1)=>R(e,t,n=>n&&(i=>i&&[e,n,i])(v(t-(r?.5:0)))),B=(e,t,r)=>R(e,t,n=>!n&&(n=v(t-.5))&&[e,n]),oe=(e,t)=>R(e,200,r=>!r&&[,t]),pt=(e,t,r)=>R(e,t,(n,i)=>(i=v(t-(r?.5:0)),n?.[0]!==e&&(n=[e,n||null]),i?.[0]===e?n.push(...i.slice(1)):n.push(i||null),n)),Xe=(e,t)=>R(e[0],t,r=>!r&&[e,v(0,e.charCodeAt(1))||null]),gt=(e,t)=>R(e[0],t,r=>r&&[e,r,v(0,e.charCodeAt(1))||null]),se=(e,t,r,n=e.charCodeAt(0),i=e.length,o=_[n],s)=>_[n]=(u,c,g,E=h)=>!u&&(g?e==g:(i<2||m.substr(h,i)==e)&&(g=e))&&c<t&&!$.id(m.charCodeAt(h+i))&&(!$.prop||$.prop(h+i))&&(Ke(h+i),(s=r())?ft(s,E):Ke(E),s)||o?.(u,c,g);Object.defineProperty($,"space",{configurable:!0,enumerable:!0,get:()=>V,set:e=>V=e});const ze={},l=(e,t,r=ze[e])=>ze[e]=(...n)=>t(...n)||r?.(...n),d=e=>Array.isArray(e)?e[0]==null?(t=>()=>t)(e[1]):ze[e[0]]?.(...e.slice(1))??z(`Unknown operator: ${e[0]}`,e?.loc):e===void 0?()=>{}:t=>t?.[e],Se=46,de=48,Ee=57,kr=69,_r=101,Ur=43,Nr=45,ve=95,mt=110,Lr=97,Mr=102,Vr=65,Br=70,yt=e=>e.indexOf("_")<0?e:e.replaceAll("_",""),Qe=e=>{let t=yt(x(r=>r===Se&&m.charCodeAt(h+1)!==Se||r>=de&&r<=Ee||r===ve||((r===kr||r===_r)&&((r=m.charCodeAt(h+1))>=de&&r<=Ee||r===Ur||r===Nr)?2:0)));return m.charCodeAt(h)===mt?(w(),[,BigInt(t)]):(e=+t)!=e?z():[,e]},Hr={2:e=>e===48||e===49||e===ve,8:e=>e>=48&&e<=55||e===ve,16:e=>e>=de&&e<=Ee||e>=Lr&&e<=Mr||e>=Vr&&e<=Br||e===ve};$.number=null,_[Se]=e=>!e&&m.charCodeAt(h+1)!==Se&&Qe();for(let e=de;e<=Ee;e++)_[e]=t=>t?void 0:Qe();_[de]=e=>{if(e)return;const t=$.number;if(t){for(const[r,n]of Object.entries(t))if(r[0]==="0"&&m[h+1]?.toLowerCase()===r[1]){w(2);const i=yt(x(Hr[n]));return m.charCodeAt(h)===mt?(w(),[,BigInt("0"+r[1]+i)]):[,parseInt(i,n)]}}return Qe()};const Gr=92,$t=34,At=39,Kr={n:`
|
|
5
|
+
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},St=e=>(t,r,n="")=>{if(!(t||!$.string?.[String.fromCharCode(e)]))return w(),x(i=>i-e&&(i===Gr?(n+=Kr[m[h+1]]||m[h+1],2):(n+=m[h],1))),m[h]===String.fromCharCode(e)?w():z("Bad string"),[,n]};_[$t]=St($t),_[At]=St(At),$.string={'"':!0};const Xr=20;"= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map(e=>A(e,Xr,!0));const Et=(e,t,r,n)=>typeof e=="string"?i=>t(i,e,i):e[0]==="."?(r=d(e[1]),n=e[2],i=>t(r(i),n,i)):e[0]==="[]"&&e.length===3?(r=d(e[1]),n=d(e[2]),i=>t(r(i),n(i),i)):e[0]==="()"&&e.length===2?Et(e[1],t):(()=>{throw Error("Invalid assignment target")})(),vt={"=":(e,t,r)=>e[t]=r,"+=":(e,t,r)=>e[t]+=r,"-=":(e,t,r)=>e[t]-=r,"*=":(e,t,r)=>e[t]*=r,"/=":(e,t,r)=>e[t]/=r,"%=":(e,t,r)=>e[t]%=r,"|=":(e,t,r)=>e[t]|=r,"&=":(e,t,r)=>e[t]&=r,"^=":(e,t,r)=>e[t]^=r,">>=":(e,t,r)=>e[t]>>=r,"<<=":(e,t,r)=>e[t]<<=r};for(const e in vt)l(e,(t,r)=>(r=d(r),Et(t,(n,i,o)=>vt[e](n,i,r(o)))));const zr=30,Qr=40;B("!",140),A("||",zr),A("&&",Qr),l("!",e=>(e=d(e),t=>!e(t))),l("||",(e,t)=>(e=d(e),t=d(t),r=>e(r)||t(r))),l("&&",(e,t)=>(e=d(e),t=d(t),r=>e(r)&&t(r)));const Jr=50,qr=60,Yr=70,It=100,Zr=140;A("|",Jr),A("&",Yr),A("^",qr),A(">>",It),A("<<",It),B("~",Zr),l("~",e=>(e=d(e),t=>~e(t))),l("|",(e,t)=>(e=d(e),t=d(t),r=>e(r)|t(r))),l("&",(e,t)=>(e=d(e),t=d(t),r=>e(r)&t(r))),l("^",(e,t)=>(e=d(e),t=d(t),r=>e(r)^t(r))),l(">>",(e,t)=>(e=d(e),t=d(t),r=>e(r)>>t(r))),l("<<",(e,t)=>(e=d(e),t=d(t),r=>e(r)<<t(r)));const Ie=90;A("<",Ie),A(">",Ie),A("<=",Ie),A(">=",Ie),l(">",(e,t)=>(e=d(e),t=d(t),r=>e(r)>t(r))),l("<",(e,t)=>(e=d(e),t=d(t),r=>e(r)<t(r))),l(">=",(e,t)=>(e=d(e),t=d(t),r=>e(r)>=t(r))),l("<=",(e,t)=>(e=d(e),t=d(t),r=>e(r)<=t(r)));const Ct=80;A("==",Ct),A("!=",Ct),l("==",(e,t)=>(e=d(e),t=d(t),r=>e(r)==t(r))),l("!=",(e,t)=>(e=d(e),t=d(t),r=>e(r)!=t(r)));const Ot=110,Je=120,wt=140;A("+",Ot),A("-",Ot),A("*",Je),A("/",Je),A("%",Je),B("+",wt),B("-",wt),l("+",(e,t)=>t!==void 0?(e=d(e),t=d(t),r=>e(r)+t(r)):(e=d(e),r=>+e(r))),l("-",(e,t)=>t!==void 0?(e=d(e),t=d(t),r=>e(r)-t(r)):(e=d(e),r=>-e(r))),l("*",(e,t)=>(e=d(e),t=d(t),r=>e(r)*t(r))),l("/",(e,t)=>(e=d(e),t=d(t),r=>e(r)/t(r))),l("%",(e,t)=>(e=d(e),t=d(t),r=>e(r)%t(r)));const Ce=150;R("++",Ce,e=>e?["++",e,null]:["++",v(Ce-1)]),R("--",Ce,e=>e?["--",e,null]:["--",v(Ce-1)]);const qe=(e,t,r,n)=>typeof e=="string"?i=>t(i,e):e[0]==="."?(r=d(e[1]),n=e[2],i=>t(r(i),n)):e[0]==="[]"&&e.length===3?(r=d(e[1]),n=d(e[2]),i=>t(r(i),n(i))):e[0]==="()"&&e.length===2?qe(e[1],t):(()=>{throw Error("Invalid increment target")})();l("++",(e,t)=>qe(e,t===null?(r,n)=>r[n]++:(r,n)=>++r[n])),l("--",(e,t)=>qe(e,t===null?(r,n)=>r[n]--:(r,n)=>--r[n]));const jr=5;pt(",",10),pt(";",jr,!0);const Ft=(...e)=>(e=e.map(d),t=>{let r;for(const n of e)r=n(t);return r});l(",",Ft),l(";",Ft),Xe("()",170);const H=e=>e?.[0]==="_"&&e[1]==="_"||e==="constructor"||e==="prototype",Ye=170;gt("[]",Ye),A(".",Ye),gt("()",Ye);const Oe=e=>{throw Error(e)};l("[]",(e,t)=>t===void 0?(e=e?e[0]===","?e.slice(1):[e]:[],e=e.map(r=>r==null?(()=>{}):r[0]==="..."?(r=d(r[1]),n=>r(n)):(r=d(r),n=>[r(n)])),r=>e.flatMap(n=>n(r))):(t==null&&Oe("Missing index"),e=d(e),t=d(t),r=>{const n=t(r);return H(n)?void 0:e(r)[n]})),l(".",(e,t)=>(e=d(e),t=t[0]?t:t[1],H(t)?()=>{}:r=>e(r)[t])),l("()",(e,t)=>{if(t===void 0)return e==null?Oe("Empty ()"):d(e);const r=i=>i?.[0]===","&&i.slice(1).some(o=>o==null||r(o));r(t)&&Oe("Empty argument");const n=t?t[0]===","?(t=t.slice(1).map(d),i=>t.map(o=>o(i))):(t=d(t),i=>[t(i)]):()=>[];return Ze(e,(i,o,s)=>i[o](...n(s)))});const Q=e=>typeof e=="string"||Array.isArray(e)&&(e[0]==="."||e[0]==="?."||e[0]==="[]"&&e.length===3||e[0]==="?.[]"||e[0]==="()"&&e.length===2&&Q(e[1])||e[0]==="{}"),Ze=(e,t,r,n)=>e==null?Oe("Empty ()"):e[0]==="()"&&e.length==2?Ze(e[1],t):typeof e=="string"?i=>t(i,e,i):e[0]==="."?(r=d(e[1]),n=e[2],i=>t(r(i),n,i)):e[0]==="?."?(r=d(e[1]),n=e[2],i=>{const o=r(i);return o==null?void 0:t(o,n,i)}):e[0]==="[]"&&e.length===3?(r=d(e[1]),n=d(e[2]),i=>t(r(i),n(i),i)):e[0]==="?.[]"?(r=d(e[1]),n=d(e[2]),i=>{const o=r(i);return o==null?void 0:t(o,n(i),i)}):(e=d(e),i=>t([e(i)],0,i)),ee=Ze,br=32,xr=$.space;$.comment??={"//":`
|
|
6
|
+
`,"/*":"*/"};let je;$.space=()=>{je||(je=Object.entries($.comment).map(([i,o])=>[i,o,i.charCodeAt(0)]));for(var e;e=xr();){for(var t=0,r;r=je[t++];)if(e===r[2]&&m.substr(h,r[0].length)===r[0]){var n=h+r[0].length;if(r[1]===`
|
|
7
|
+
`)for(;m.charCodeAt(n)>=br;)n++;else{for(;m[n]&&m.substr(n,r[1].length)!==r[1];)n++;m[n]&&(n+=r[1].length)}Ke(n),e=0;break}if(e)return e}return e};const Dt=80;A("===",Dt),A("!==",Dt),l("===",(e,t)=>(e=d(e),t=d(t),r=>e(r)===t(r))),l("!==",(e,t)=>(e=d(e),t=d(t),r=>e(r)!==t(r))),A("??",30),l("??",(e,t)=>(e=d(e),t=d(t),r=>e(r)??t(r)));const en=130,tn=20;A("**",en,!0),A("**=",tn,!0),l("**",(e,t)=>(e=d(e),t=d(t),r=>e(r)**t(r)));const rn=e=>{throw Error(e)};l("**=",(e,t)=>(Q(e)||rn("Invalid assignment target"),t=d(t),ee(e,(r,n,i)=>r[n]**=t(i))));const Pt=90;A("in",Pt),A("of",Pt),l("in",(e,t)=>(e=d(e),t=d(t),r=>e(r)in t(r)));const nn=20,on=100,sn=e=>{throw Error(e)};A(">>>",on),A(">>>=",nn,!0),l(">>>",(e,t)=>(e=d(e),t=d(t),r=>e(r)>>>t(r))),l(">>>=",(e,t)=>(Q(e)||sn("Invalid assignment target"),t=d(t),ee(e,(r,n,i)=>r[n]>>>=t(i))));const be=5,dn=10,un=20,cn=e=>e[0]?.[0]===","?e[0].slice(1):e,we=(e,t,r)=>{if(typeof e=="string"){r[e]=t;return}const[n,...i]=e,o=cn(i);if(n==="{}"){const s=[];for(const u of o){if(Array.isArray(u)&&u[0]==="..."){const p={};for(const P in t)s.includes(P)||(p[P]=t[P]);r[u[1]]=p;break}let c,g,E;typeof u=="string"?c=g=u:u[0]==="="?(typeof u[1]=="string"?c=g=u[1]:[,c,g]=u[1],E=u[2]):[,c,g]=u,s.push(c);let y=t[c];y===void 0&&E&&(y=d(E)(r)),we(g,y,r)}}else if(n==="[]"){let s=0;for(const u of o){if(u===null){s++;continue}if(Array.isArray(u)&&u[0]==="..."){r[u[1]]=t.slice(s);break}let c=u,g;Array.isArray(u)&&u[0]==="="&&([,c,g]=u);let E=t[s++];E===void 0&&g&&(E=d(g)(r)),we(c,E,r)}}},Wt=e=>{let t=v(dn-1);return t?.[0]==="in"||t?.[0]==="of"?[t[0],[e,t[1]],t[2]]:t?.[0]===","?[e,...t.slice(1)]:[e,t]};se("let",be+1,()=>Wt("let")),se("const",be+1,()=>Wt("const")),se("var",be,()=>(V(),["var",v(un)]));const Tt=(...e)=>(e=e.map(t=>{if(typeof t=="string")return r=>{r[t]=void 0};if(t[0]==="="){const[,r,n]=t,i=d(n);return typeof r=="string"?o=>{o[r]=i(o)}:o=>we(r,i(o),o)}return d(t)}),t=>{for(const r of e)r(t)});l("let",Tt),l("const",Tt),l("var",e=>typeof e=="string"?t=>{t[e]=void 0}:()=>{});const xe=20,Fe=e=>{throw Error(e)};A("||=",xe,!0),A("&&=",xe,!0),A("??=",xe,!0),l("=",(e,t)=>{if(Array.isArray(e)&&(e[0]==="let"||e[0]==="const"||e[0]==="var")){const r=e[1];return t=d(t),typeof r=="string"?n=>{n[r]=t(n)}:n=>we(r,t(n),n)}return Q(e)||Fe("Invalid assignment target"),t=d(t),ee(e,(r,n,i)=>r[n]=t(i))}),l("||=",(e,t)=>(Q(e)||Fe("Invalid assignment target"),t=d(t),ee(e,(r,n,i)=>r[n]||=t(i)))),l("&&=",(e,t)=>(Q(e)||Fe("Invalid assignment target"),t=d(t),ee(e,(r,n,i)=>r[n]&&=t(i)))),l("??=",(e,t)=>(Q(e)||Fe("Invalid assignment target"),t=d(t),ee(e,(r,n,i)=>r[n]??=t(i)))),oe("true",!0),oe("false",!1),oe("null",null),se("undefined",200,()=>[]),oe("NaN",NaN),oe("Infinity",1/0);const et=20;R("?",et,(e,t,r)=>e&&(t=v(et-1))&&x(n=>n===58)&&(r=v(et-1),["?",e,t,r])),l("?",(e,t,r)=>(e=d(e),t=d(t),r=d(r),n=>e(n)?t(n):r(n)));const ln=[];A("=>",20,!0),l("=>",(e,t)=>{e=e?.[0]==="()"?e[1]:e;const r=e?e[0]===","?e.slice(1):[e]:[];let n=-1,i=null;const o=r[r.length-1];Array.isArray(o)&&o[0]==="..."&&(n=r.length-1,i=o[1],r.length--);const s=t?.[0]==="{}";return t=d(s?["{",t[1]]:t),u=>(...c)=>{const g={};r.forEach((y,p)=>g[y]=c[p]),i&&(g[i]=c.slice(n));const E=new Proxy(g,{get:(y,p)=>p in y?y[p]:u?.[p],set:(y,p,P)=>((p in y?y:u)[p]=P,!0),has:(y,p)=>p in y||(u?p in u:!1)});try{const y=t(E);return s?void 0:y}catch(y){if(y===ln)return y[0];throw y}}}),B("...",140),l("...",e=>(e=d(e),t=>Object.entries(e(t))));const Rt=170;R("?.",Rt,(e,t)=>{if(!e)return;const r=V();return r===40?(w(),["?.()",e,v(0,41)||null]):r===91?(w(),["?.[]",e,v(0,93)]):(t=v(Rt),t?["?.",e,t]:void 0)}),l("?.",(e,t)=>(e=d(e),H(t)?()=>{}:r=>e(r)?.[t])),l("?.[]",(e,t)=>(e=d(e),t=d(t),r=>{const n=t(r);return H(n)?void 0:e(r)?.[n]})),l("?.()",(e,t)=>{const r=t?t[0]===","?(t=t.slice(1).map(d),i=>t.map(o=>o(i))):(t=d(t),i=>[t(i)]):()=>[];if(e[0]==="?."){const i=d(e[1]),o=e[2];return H(o)?()=>{}:s=>i(s)?.[o]?.(...r(s))}if(e[0]==="?.[]"){const i=d(e[1]),o=d(e[2]);return s=>{const u=i(s),c=o(s);return H(c)?void 0:u?.[c]?.(...r(s))}}if(e[0]==="."){const i=d(e[1]),o=e[2];return H(o)?()=>{}:s=>i(s)?.[o]?.(...r(s))}if(e[0]==="[]"&&e.length===3){const i=d(e[1]),o=d(e[2]);return s=>{const u=i(s),c=o(s);return H(c)?void 0:u?.[c]?.(...r(s))}}const n=d(e);return i=>n(i)?.(...r(i))});const ue=140;B("typeof",ue),B("void",ue),B("delete",ue),se("new",ue,()=>Rr(".target")?(w(7),["new.target"]):["new",v(ue)]),l("typeof",e=>(e=d(e),t=>typeof e(t))),l("void",e=>(e=d(e),t=>(e(t),void 0))),l("delete",e=>{if(e[0]==="."){const t=d(e[1]),r=e[2];return n=>delete t(n)[r]}if(e[0]==="[]"){const t=d(e[1]),r=d(e[2]);return n=>delete t(n)[r(n)]}return()=>!0}),l("new",e=>{const t=d(e?.[0]==="()"?e[1]:e),r=e?.[0]==="()"?e[2]:null,n=r?r[0]===","?(i=>o=>i.map(s=>s(o)))(r.slice(1).map(d)):(i=>o=>[i(o)])(d(r)):()=>[];return i=>new(t(i))(...n(i))});const tt=Symbol("accessor"),rt=20,an=40,kt=41,_t=123,Ut=125,Nt=e=>t=>{if(t)return;V();const r=x($.id);if(!r||(V(),m.charCodeAt(h)!==an))return!1;w();const n=v(0,kt);return V(),m.charCodeAt(h)!==_t?!1:(w(),[e,r,n,v(0,Ut)])};R("get",rt-1,Nt("get")),R("set",rt-1,Nt("set")),R("(",rt-1,e=>{if(!e||typeof e!="string")return;const t=v(0,kt)||null;if(V(),m.charCodeAt(h)===_t)return w(),[":",e,["=>",["()",t],v(0,Ut)||null]]}),l("get",(e,t)=>(t=t?d(t):()=>{},r=>[[tt,e,{get:function(){const n=Object.create(r||{});return n.this=this,t(n)}}]])),l("set",(e,t,r)=>(r=r?d(r):()=>{},n=>[[tt,e,{set:function(i){const o=Object.create(n||{});o.this=this,o[t]=i,r(o)}}]]));const fn=20,Lt=200;$.prop=e=>Tr(e)!==58;const hn=e=>e==null||typeof e=="string"||[":",",","...","get","set"].includes(e[0]);Xe("[]",Lt),Xe("{}",Lt),A(":",fn-1,!0),l("{}",(e,t)=>{if(t!==void 0)return;if(!hn(e))return d(["{",e]);e=e?e[0]!==","?[e]:e.slice(1):[];const r=e.map(n=>d(typeof n=="string"?[":",n,n]:n));return n=>{const i={},o={};for(const s of r.flatMap(u=>u(n)))if(s[0]===tt){const[,u,c]=s;o[u]={...o[u],...c,configurable:!0,enumerable:!0}}else i[s[0]]=s[1];for(const s in o)Object.defineProperty(i,s,o[s]);return i}}),l("{",e=>(e=e?d(e):()=>{},t=>e(Object.create(t)))),l(":",(e,t)=>(t=d(t),Array.isArray(e)?(e=d(e),r=>[[e(r),t(r)]]):r=>[[e,t(r)]]));const pn=170,De=96,gn=36,mn=123,yn=92,$n={n:`
|
|
8
|
+
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},Mt=()=>{const e=[];for(let t="",r;(r=m.charCodeAt(h))!==De;)r?r===yn?(w(),t+=$n[m[h]]||m[h],w()):r===gn&&m.charCodeAt(h+1)===mn?(t&&e.push([,t]),t="",w(2),e.push(v(0,125))):(t+=m[h],w(),r=m.charCodeAt(h),r===De&&t&&e.push([,t])):z("Unterminated template");return w(),e},An=_[De];_[De]=(e,t)=>e&&t<pn?$.asi&&$.newline?void 0:(w(),["``",e,...Mt()]):e?An?.(e,t):(w(),(r=>r.length<2&&r[0]?.[0]===void 0?r[0]||[,""]:["`",...r])(Mt())),l("`",(...e)=>(e=e.map(d),t=>e.map(r=>r(t)).join(""))),l("``",(e,...t)=>{e=d(e);const r=[],n=[];for(const o of t)Array.isArray(o)&&o[0]===void 0?r.push(o[1]):n.push(d(o));const i=Object.assign([...r],{raw:r});return o=>e(o)(i,...n.map(s=>s(o)))}),$.string["'"]=!0,$.number={"0x":16,"0b":2,"0o":8};const Vt={log:(e,t)=>(t?console.log(t,e):console.log(e),e)};function N(e,t,r,n,i){const o=$(Sn(e));return d(o)({$form:t,$meta:r,$errors:n,$formIsInvalid:i,$log:Vt.log})===!0}function Sn(e){return e.replace(/\?\.(\d+)/g,"?.[$1]").replace(/\.(\d+)/g,"[$1]")}const G=e=>{let t=e.formDef.states;if(!t||Object.keys(t).length===0||e.formHealth.status==="errored")return e;const{$formIsInvalid:r,$errors:n}=Be(e);t=En(t);let i=[],o={status:"ok"};try{i=Object.keys(t).map(s=>{const u=t[s];let c;try{c=N(u,e.data,e.meta,n,r)}catch{c=!1}return c===!0?s:void 0}).filter(s=>s!==void 0)}catch(s){const u=s,c=ne.calculateCurrentStateError;o={status:"errored",message:`[${c}] ${u.message}`,code:c}}return{...e,currentStates:i,formHealth:o}};function En(e){const t={};function r(n){const i=n.split(":"),o=[];for(let s=0;s<i.length;s++)o.push(i.slice(0,s+1).join(":"));return o}for(const[n,i]of Object.entries(e)){const o=r(n),s=[];for(const u of o)e[u]&&s.push(`(${e[u]})`);t[n]=s.join(" && ")}return t}const Pe=Symbol("filterMap.skip");function nt(e,t){const r=[];for(let n=0;n<e.length;n++){const i=t(e[n],n,e);i!==Pe&&r.push(i)}return r}function vn(e,t,r){for(let n=0;n<e.length;n++)t(e[n],n,e)&&r(e[n],n,e)}function Bt(e,t,r,n){let i=n;for(let o=0;o<e.length;o++)t(e[o],o,e)&&(i=r(i,e[o],o,e));return i}function Ht(e,t,r){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!r(e[n],t[n],n,e,t))return!1;return!0}function Gt(e,t){const r=it(e.uid,t);return F(e)?{...e,uid:r,path:In(e.path,t)}:{...e,uid:r}}function it(e,t){if(t.length===0)throw new Error("Repeater indexes cannot be an empty array");const r=t.reduce((n,i)=>`${n}[${i}]`,"");return`${e}${r}`}function In(e,t){if(t.length===0)throw new Error("Repeater indexes cannot be an empty array");const r="items",n=e.split(`.${r}`),i=n.length-1;if(i!==t.length)throw new Error(`Path contains ${i} '${r}' occurrences, but ${t.length} indexes were provided.`);return n.reduce((o,s,u)=>u===0?s:`${o}.${t[u-1]}${s}`)}function ce(e,t){let r=0;return e.replace(/\.items(\??)\./g,(n,i)=>{const o=t[r++];return o===void 0?n:`.${o}${i}.`})}const We=(e,t)=>r=>e(r)?t(r):r,J=e=>e!==void 0&&typeof e=="object"&&e!==null&&"when"in e,K=e=>{const{$formIsInvalid:t,$errors:r}=Be(e);return{...e,widgetFlags:{...Cn(e,r,t),...On(e,r,t)}}};function Cn(e,t,r){return nt(Object.values(e.flatForm),n=>{if(n.uid?.includes("["))return Pe;if(b(n)){const i=n({$form:e.data,errors:void 0,touched:void 0,translate:void 0});return i.uid=n.uid,i}return n}).filter(n=>!!(n.include&&("in"in n.include||"when"in n.include)||n.exclude&&("from"in n.exclude||"when"in n.exclude)||(F(n)||j(n))&&J(n.disabled)||F(n)&&J(n.readonly))).reduce((n,i)=>(n[i.uid]=n[i.uid]||{},i.include&&"in"in i.include?n[i.uid].hidden=!i.include.in.some(o=>e.currentStates.includes(o)):i.include&&"when"in i.include&&(n[i.uid].hidden=!N(i.include.when,e.data,e.meta,t,r)),i.exclude&&"from"in i.exclude?n[i.uid].hidden=i.exclude.from.some(o=>e.currentStates.includes(o)):i.exclude&&"when"in i.exclude&&(n[i.uid].hidden=N(i.exclude.when,e.data,e.meta,t,r)),(F(i)||j(i))&&J(i.disabled)&&(n[i.uid].disabled=N(i.disabled.when,e.data,e.meta,t,r)),F(i)&&J(i.readonly)&&(n[i.uid].readonly=N(i.readonly.when,e.data,e.meta,t,r)),n),{})}function On(e,t,r){return Bt(Object.values(e.flatForm),n=>!b(n)&&n.type==="repeater",(n,i)=>({...n,...Kt(e,i,[],t,r)}),{})}function Kt(e,t,r,n,i){const o=t.props.template,s=k(e.data,t.path);if(!Array.isArray(s))return{};const u={};return s.forEach((c,g)=>{const E=[...r,g];Ve([o]).forEach(y=>{let p;if(b(y)?(p=y({$form:e.data,errors:void 0,touched:void 0,translate:void 0}),p.uid=y.uid):p=y,p.type==="repeater"){const le=Gt(p,E);Object.assign(u,Kt(e,le,E,n,i));return}const P=it(p.uid,E);u[P]=u[P]||{},p.include&&"in"in p.include?u[P].hidden=!p.include.in.some(le=>e.currentStates.includes(le)):p.include&&"when"in p.include&&(u[P].hidden=!N(ce(p.include.when,E),e.data,e.meta,n,i)),p.exclude&&"from"in p.exclude?u[P].hidden=p.exclude.from.some(le=>e.currentStates.includes(le)):p.exclude&&"when"in p.exclude&&(u[P].hidden=N(ce(p.exclude.when,E),e.data,e.meta,n,i)),(F(p)||j(p))&&J(p.disabled)&&(u[P].disabled=N(ce(p.disabled.when,E),e.data,e.meta,n,i)),F(p)&&J(p.readonly)&&(u[P].readonly=N(ce(p.readonly.when,E),e.data,e.meta,n,i))})}),u}const Xt=e=>!(typeof e!="object"||e===null||typeof e.key!="string");function wn(e){const t=new Intl.Locale(e).maximize().script;return["Arab","Hebr","Thaa","Syrc","Tfng","Adlm","Rohg"].includes(t||"")?"rtl":"ltr"}const zt=(e=navigator.language||"en-US")=>{const t=new Set;return{get lang(){return e},translate(n){return n},subscribe(n){return t.add(n),()=>{t.delete(n)}},setLang(n){e=n,t.forEach(i=>i(e))}}},L=e=>t=>({...t,calculatedWidgets:Fn(t,e)});function Fn(e,t){const{$formIsInvalid:r,$errors:n}=Be(e),i=Xn(e,t,r,n),o={};for(const s of Object.keys(e.calculatedWidgets)){if(e.widgetFlags[s]?.hidden)continue;const u=e.calculatedWidgets[s],c=u.source;if(b(c)){o[s]=Dn(s,c,e,t);continue}o[s]=Pn(u,c,e,i)}return o}function Dn(e,t,r,n){const i=t({$form:r.data,errors:t.path?r.validations[t.path]:void 0,touched:t.path?r.touchedControls[t.path]:void 0,translate:n.translate});return i.uid=e,{source:t,current:i}}function Pn(e,t,r,n){const i=new Kn(t,e.current);return i.write("uid",t.uid),i.write("type",t.type),i.write("kind",t.kind),lt(t)?Wn(i,n):j(t)?Tn(i,n):F(t)?Rn(i,n):pe(t)&&kn(i,n),_n(t,i,n,r),(j(t)||F(t))&&Un(t,i,n),pe(t)&&Nn(t,i,r),i.changed?{source:e.source,current:i.current}:e}function Wn(e,t){I(e,t,"size"),I(e,t,"include"),I(e,t,"exclude")}function Tn(e,t){I(e,t,"size"),I(e,t,"include"),I(e,t,"exclude"),I(e,t,"label"),I(e,t,"disabled")}function Rn(e,t){I(e,t,"size"),I(e,t,"include"),I(e,t,"exclude"),I(e,t,"label"),I(e,t,"disabled"),I(e,t,"readonly"),I(e,t,"validator"),I(e,t,"path"),I(e,t,"defaultValue")}function kn(e,t){I(e,t,"size"),I(e,t,"include"),I(e,t,"exclude")}function _n(e,t,r,n){const i=n.widgetPropOverrides[e.uid]??{},o={...e.props??{},...i};for(const s of qt(Object.keys(o)))Ln(t,r,s)}function Un(e,t,r){const n=e.on??{};for(const i of qt(Object.keys(n)))Mn(t,r,i)}function Nn(e,t,r){const n=Jn(e.uid),i=Qn(e.children,n,r.widgetFlags);t.current.children=i;const o=t.previous.children??[];o.length===i.length&&i.every((u,c)=>o[c]&&o[c].uid===i[c].uid)||t.markChanged()}function I(e,t,r){const n=e.source;if(!zn(n,r))return;const i=st(n,r,t.sortedStates);let o;switch(r){case"disabled":case"readonly":o=Bn(i,t,e.source.uid,r);break;default:o=Jt(i,t)}e.write(r,o)}function Ln(e,t,r){const n=e.source.props,i=st(n,r,t.sortedStates);let o=Jt(i,t);const s=t.widgetPropOverrides[e.source.uid]?.[r];s!==void 0&&(o=s),e.write(`props.${r}`,o)}function Mn(e,t,r){const n=e.source.on,i=st(n,r,t.sortedStates);e.write(`on.${r}`,Hn(i,t))}function ot(e,t){return e({$form:t.$form,translate:t.localization.translate})}function Vn(e,t){return t.localization.translate(e.key,Gn(e.params,t),e.default)}function Qt(e,t){return Pr(e,{resolveFormPath:r=>k(t.$form,r)??e,resolveMetaPath:r=>k(t.$meta,r)??e,resolveErrorsPath:r=>k(t.$errors,r)??e,resolveFormIsInvalid:()=>String(t.$formIsInvalid)})}function Jt(e,t){return typeof e=="function"?ot(e,t):Xt(e)?Vn(e,t):typeof e=="string"?Qt(e,t):e}function Bn(e,t,r,n){return typeof e=="function"?ot(e,t):J(e)?t.widgetFlags[r]?.[n]:typeof e=="string"?Qt(e,t):e}function Hn(e,t){return typeof e=="function"?ot(e,t):e}function st(e,t,r){if(e){for(const n of r){const i=e[`${t}.${n}`];if(i!==void 0)return i}return e[t]}}function Gn(e,t){return e&&Object.keys(e).reduce((r,n)=>{const i=String(e[n]);return wr(i)?r[n]=Wr(i,{resolveFormPath:o=>k(t.$form,o)??i,resolveMetaPath:o=>k(t.$meta,o)??i,resolveErrorsPath:o=>k(t.$errors,o)??i,resolveFormIsInvalid:()=>t.$formIsInvalid}):r[n]=i,r},{})}class Kn{constructor(t,r){this._changed=!1,this.source=t,this.previous=r,this.current={}}get changed(){return this._changed}markChanged(){this._changed=!0}write(t,r){Ae(this.current,t,r),k(this.previous,t)!==r&&(this._changed=!0)}}function Xn(e,t,r,n){return{sortedStates:[...e.currentStates].sort((i,o)=>o.length-i.length),widgetPropOverrides:e.widgetPropOverrides,widgetFlags:e.widgetFlags,$form:e.data,$meta:e.meta,$formIsInvalid:r,$errors:n,localization:t}}function zn(e,t){if(t in e)return!0;const r=`${t}.`;return Object.keys(e).some(n=>n.startsWith(r))}function qt(e){return Array.from(new Set(e.map(t=>t.split(".")[0])))}function Qn(e,t,r){const n=t.map(i=>`[${i}]`).join("");return e.filter(i=>{const o=i.uid+n,s=r[o];return!s||s.hidden!==!0})}const Jn=e=>[...e.matchAll(/\[(\d+)\]/g)].map(t=>parseInt(t[1],10)),qn=({lang:e},t)=>{const r={...Le(e),formName:t.payload.formName};let n=t.payload.formDef,i={status:"ok"};if(typeof n=="string"){try{n=JSON.parse(n)}catch(u){const c=u,g=ne.initializeParseError;i={status:"errored",message:`[${g}] ${c.message}`,code:g}}if(i.status==="errored")return{...r,formHealth:i}}if(Array.isArray(n.form)){const u=n,c=u.form;u.form={uid:"",type:"flex",kind:"layout",children:c}}const o=Ne.decode(n);if(o.isOk()){i={status:"ok"};let u={};try{u=Ve([o.value.form]).reduce((c,g)=>{if(c[g.uid])throw{existingWidget:c[g.uid],newWidget:g};return c[g.uid]=g,c},{})}catch(c){const g=ne.initializeUidCollisionError;i={status:"errored",message:`[${g}] ${Yn(c.existingWidget,c.newWidget)}`,code:g},u={}}return{...r,formDef:o.value,flatForm:u,formHealth:i}}const s=ne.initializeUnknownError;return{...r,formHealth:{status:"errored",message:`[${s}] ${o.error}`,code:s}}};function Yn(e,t){const r=n=>F(n)?` at "${n.path}"`:"";return`Duplicate UID "${t.uid}": Assigned to widget "${e.type}"${r(e)} and "${t.type}"${r(t)}.`}function Zn(e,t){return{...e,injectedValidations:{...e.injectedValidations,[t.payload.path]:t.payload.issues}}}const jn=(e,{payload:t})=>{let r;if("path"in t){if(r=Object.values(e.calculatedWidgets).find(({source:i})=>F(i)&&i.path===t.path),!r)return console.warn(`Input with path "${t.path}" not found`),e}else if(r=e.calculatedWidgets[t.uid],!r)return console.warn(`Widget with uid "${t.uid}" not found`),e;const n=e.widgetPropOverrides[r.source.uid]||{};return{...e,widgetPropOverrides:{...e.widgetPropOverrides,[r.source.uid]:{...n,[t.prop]:t.value}}}};function bn(e,t){return{...e,widgetFlags:{...ie(e.widgetFlags,t.payload.uid)},calculatedWidgets:{...ie(e.calculatedWidgets,t.payload.uid)},widgetPropOverrides:{...ie(e.widgetPropOverrides,t.payload.uid)},touchedControls:{...U(e.touchedControls,r=>{const n=e.flatForm[t.payload.uid];return n&&F(n)?ie(r,n.path):r})}}}const xn=(e,t)=>({...e,data:{...t.payload.data}}),ei=(e,t)=>({...e,formHealth:t.payload.formHealth}),ti=(e,t)=>({...e,lang:t.payload.lang}),ri=(e,t)=>({...e,meta:{...t.payload.meta}}),ni=(e,t)=>{const r=k(e.data,t.payload.path);return t.type==="SET_WIDGET_DATA"||t.type==="SET_WIDGET_INITIAL_DATA"&&r===void 0?{...e,data:{...Ae(e.data,t.payload.path,t.payload.data)}}:e};function Yt(e,t){const r=e["~standard"].validate(t);if(r instanceof Promise)throw new TypeError("Schema validation must be synchronous");return r}function Zt(e){return e.issues===void 0}const dt=(e,t)=>r=>{const n=nt(Object.values(r.calculatedWidgets),({current:o})=>F(o)?o:Pe),i=r.validations;return{...r,validations:n.reduce((o,s)=>{if(o[s.path]=null,s.validator){const u=e(s.validator,t),c=k(r.data,s.path),g=Yt(u,c);o[s.path]=Zt(g)?null:g.issues.map(E=>E.message)}return Array.isArray(o[s.path])&&Array.isArray(i[s.path])&&Ht(o[s.path],i[s.path],(u,c)=>u===c)&&(o[s.path]=i[s.path]),o},{})}},ii=({validators:e,validateOn:t,localization:r})=>(n,i)=>{switch(i.type){case"INITIALIZE":return qn(n,i);case"SET_DATA":return U(xn(n,i),G,K,L(r));case"SET_META":return U(ri(n,i),G,K,L(r));case"SET_LANGUAGE":return U(ti(n,i),L(r));case"ADD_WIDGET":return U(Cr(n,i),We(ut,G),We(ut,K),We(ut,L(r)));case"REMOVE_WIDGET":return U(bn(n,i),G,K,L(r));case"SET_WIDGET_INITIAL_DATA":case"SET_WIDGET_DATA":return U(ni(n,i),G,K,L(r));case"OVERRIDE_WIDGET_PROP":return U(jn(n,i),G,K,L(r),We(o=>{let s=!1,u="";"path"in i.payload?(s=!0,u=i.payload.path):F(o.calculatedWidgets[i.payload.uid].current)&&(s=!0,u=o.calculatedWidgets[i.payload.uid].current.path);const c=s&&o.touchedControls[u];return o.touched&&c},dt(e,r)));case"SET_FORM_HEALTH":return ei(n,i);case"VALIDATE_ALL":return U({...n,touched:!0,touchedControls:Object.keys(n.calculatedWidgets).reduce((o,s)=>{const u=n.calculatedWidgets[s].source;return F(u)&&(o[u.path]=!0),o},{})},dt(e,r),G,K,L(r));case"ATTEMPT_VALIDATION":{const o=i.payload.reason,s=i.payload.path;return t==="eager"||o===t||t.includes(o)?U({...n,touched:!0,touchedControls:{...n.touchedControls,[s]:!0}},dt(e,r),G,K,L(r),c=>{const g=i.payload.uid,E=c.calculatedWidgets[g],y=E.source;if(b(y)){const p=y({$form:c.data,errors:c.validations[s],touched:!0,translate:r.translate});return{...c,calculatedWidgets:{...c.calculatedWidgets,[g]:{source:E.source,current:p}}}}return c}):n}case"INJECT_VALIDATION_ISSUES":return Zn(n,i);default:return vr(i)}},ut=e=>e.formHealth.status==="ok";function jt(e=[],t,r,n){const i=new a.BehaviorSubject(Le(n.lang)),o=i.asObservable().pipe(a.distinctUntilChanged()),s=ii({validators:t,validateOn:r,localization:n});function u(y){const p=i.getValue(),P=s(p,y);i.next(P)}let c=u;const g={getState:()=>i.getValue(),dispatch:y=>c(y)};return c=e.map(y=>y(g)).reduceRight((y,p)=>p(y),u),{state$:o,dispatch:c,getState:()=>i.getValue()}}class oi{constructor(){this.widgetRegistry=new ae,this.store={},this.events$=new a.Subject,this.uuid=crypto.randomUUID(),this.itemRenderers={},this.dependencies={}}initialize(t,r=[],n,i,o,s=zt(),u){this.localization=s,this.dependencies=u,this.widgetRegistry.setWidgetLoaders(t),this.itemRenderers=o,this.store=jt(r,n,i,s)}emitEvent(t,r,n){const o=this.store.getState().currentStates.filter(s=>r.on?.[`${t}.${s}`]!==void 0);if(o.length>0)o.forEach(s=>{const u=r.on?.[`${t}.${s}`];this.attemptValidation(t,u,r),u&&this.events$.next({name:u,data:this.store.getState().data,detail:n??void 0,callback:c=>{this.store.dispatch(c)}})});else{const s=r.on?.[t];this.attemptValidation(t,s,r),s&&this.events$.next({name:s,data:this.store.getState().data,detail:n,callback:u=>{this.store.dispatch(u)}})}}attemptValidation(t,r,n){n.kind!=="layout"&&(t==="change"?this.store.dispatch({type:"ATTEMPT_VALIDATION",payload:{reason:"change",path:n.path,uid:n.uid}}):t==="click"&&r==="submit"&&this.store.dispatch({type:"VALIDATE_ALL"}))}}function si(e="GolemUI Form Store"){return t=>{const n=(typeof window<"u"?window.__REDUX_DEVTOOLS_EXTENSION__:void 0)?.connect({name:e});return n?.init(t.getState()),i=>o=>{i(o),n&&n.send(o,t.getState())}}}const di=a.pipe(a.map(e=>e.data),a.distinctUntilChanged()),ui=e=>a.pipe(di,a.map(t=>k(t,e)),a.distinctUntilChanged()),ci=a.pipe(a.filter(e=>e.touched===!0),a.map(e=>e.validations),a.distinctUntilChanged()),li=e=>a.pipe(ci,a.map(t=>t[e]),a.distinctUntilChanged()),ai=a.pipe(a.filter(e=>e.touched===!0),a.map(e=>e.injectedValidations),a.distinctUntilChanged()),fi=e=>a.pipe(ai,a.map(t=>t[e]),a.distinctUntilChanged(),a.startWith(null)),hi=a.pipe(a.map(e=>e.lang),a.distinctUntilChanged()),bt=a.pipe(a.map(e=>e.calculatedWidgets),a.distinctUntilChanged()),pi=e=>t=>a.combineLatest([t.pipe(hi),t.pipe(bt)]).pipe(a.map(([r,n])=>({lang:r,widget:n[e]})),a.filter(r=>r.widget!==void 0),a.distinctUntilChanged((r,n)=>r.lang===n.lang&&r.widget===n.widget),a.map(r=>r.widget.current)),gi=e=>a.pipe(bt,a.map(t=>t[e]),a.filter(t=>t!==void 0),a.map(t=>t.current.children),a.distinctUntilChanged()),xt=a.pipe(a.map(e=>e.widgetFlags),a.distinctUntilChanged()),mi=e=>a.pipe(xt,a.map(t=>t[e]),a.distinctUntilChanged()),yi=a.pipe(a.map(e=>e.touchedControls),a.distinctUntilChanged()),$i=e=>a.pipe(yi,a.map(t=>t[e]),a.distinctUntilChanged()),Ai=a.pipe(a.map(e=>e.formHealth),a.distinctUntilChanged((e,t)=>!(e.status!==t.status||e.status==="errored"))),Si=e=>e.pipe(Ai);let er=!1;function Ei(){er=!0}function tr(){return er}function vi(e,t,r){if(!tr())return;const n=Object.keys(t??{}).filter(i=>i in r);if(n.length>0)throw new Error(`[GolemUI] Widget "${e}": prop keys [${n.join(", ")}] collide with widget fields`)}f.Debug=Vt,f.FormContext=oi,f.SKIP=Pe,f.WidgetRegistry=ae,f.assertNoPropCollisions=vi,f.calculatedLayoutChildrenByUid$=gi,f.calculatedWidgetsByUid$=pi,f.cloneObject=Me,f.compose=Ir,f.createFormStore=jt,f.createInitialState=Le,f.dataByPath$=ui,f.defineForm=Er,f.deleteKey=ie,f.devToolsMiddleware=si,f.enableDevMode=Ei,f.errorCodes=ne,f.filterMap=nt,f.filterReduce=Bt,f.filterTap=vn,f.formDefDecoder=Ne,f.formHealth=Si,f.get=k,f.getDirectionFromLanguage=wn,f.identityTranslator=zt,f.injectedValidationByPath$=fi,f.isActionWidget=j,f.isDevMode=tr,f.isDisplayWidget=lt,f.isFunctionWidget=b,f.isInputWidget=F,f.isLayoutWidget=pe,f.isStandardValidateSuccess=Zt,f.isTranslationConfig=Xt,f.layoutWidgetDecoder=$e,f.makeRepeaterItemConfig=Gt,f.pipe=U,f.selectWidgetFlags=xt,f.set=Ae,f.shortUUID=Re,f.standardValidate=Yt,f.toRepeaterItemUid=it,f.touchedControlsByPath$=$i,f.transformRepeaterItemWhenExpression=ce,f.validationByPath$=li,f.widgetFlagsByUid$=mi,f.zipEvery=Ht,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Subject } from 'rxjs';
|
|
2
|
-
import { ActionWidget, InputWidget, LayoutWidget, On } from '../form-widget';
|
|
3
2
|
import { FormStore } from '../form-store';
|
|
4
3
|
import { ValidatorFn } from '../form-validator';
|
|
4
|
+
import { ActionWidget, InputWidget, LayoutWidget, On } from '../form-widget';
|
|
5
5
|
import { I18nTranslator } from '../i18n';
|
|
6
6
|
import { ItemRenderer } from '../item-renderer';
|
|
7
|
-
import {
|
|
7
|
+
import { FormEvent, ValidateOn } from '../shared';
|
|
8
8
|
import { Action } from '../store/actions';
|
|
9
9
|
import { Middleware, State } from '../store/model';
|
|
10
10
|
import { WidgetLoaders, WidgetRegistry } from './widget-registry';
|
|
@@ -15,7 +15,12 @@ export declare class FormContext<ComponentType> {
|
|
|
15
15
|
uuid: `${string}-${string}-${string}-${string}-${string}`;
|
|
16
16
|
itemRenderers: Record<string, ItemRenderer>;
|
|
17
17
|
localization: I18nTranslator;
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Dependencies are any 3rd party service components may need internally.
|
|
20
|
+
* e.g. a markdown parser for the Markdown component
|
|
21
|
+
*/
|
|
22
|
+
dependencies: Record<string, unknown>;
|
|
23
|
+
initialize(widgetLoaders: WidgetLoaders<ComponentType>, middlewares: Middleware<State, Action>[] | undefined, validators: ValidatorFn<any>, validateOn: ValidateOn, itemRenderers: Record<string, ItemRenderer>, localization: I18nTranslator | undefined, dependencies: Record<string, unknown>): void;
|
|
19
24
|
emitEvent(eventType: keyof On<string>, widget: InputWidget<any, string> | ActionWidget<string> | LayoutWidget<string>, detail?: any): void;
|
|
20
|
-
attemptValidation
|
|
25
|
+
private attemptValidation;
|
|
21
26
|
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { NonFunctionWidget } from '../form-widget';
|
|
2
2
|
export type WidgetLoaders<ComponentType, Widget extends string = NonFunctionWidget['type']> = Record<Widget, () => Promise<ComponentType>>;
|
|
3
3
|
export declare class WidgetRegistry<ComponentType> {
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Shared across all instances, keyed by loader function reference.
|
|
6
|
+
* Loader functions must be stable references (module-scope constants).
|
|
7
|
+
* Failed requests are automatically cleared so you can retry them later.
|
|
8
|
+
*/
|
|
9
|
+
private static sharedCache;
|
|
5
10
|
private widgetLoaders;
|
|
6
11
|
private _ready;
|
|
7
12
|
/**
|
package/lib/errors.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Errors in the < 1000 range are core
|
|
3
|
+
*/
|
|
4
|
+
export declare const errorCodes: {
|
|
5
|
+
calculateCurrentStateError: number;
|
|
6
|
+
initializeParseError: number;
|
|
7
|
+
initializeUidCollisionError: number;
|
|
8
|
+
initializeUnknownError: number;
|
|
9
|
+
widgetCouldNotBeLoaded: number;
|
|
10
|
+
};
|
package/lib/form-validator.d.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
booleanValidator: () => V;
|
|
5
|
-
numberValidator: () => V;
|
|
6
|
-
integerValidator: () => V;
|
|
7
|
-
};
|
|
8
|
-
export type ValidatorFn<V> = (validator: V) => StandardSchemaV1;
|
|
2
|
+
import { I18nTranslator } from './i18n';
|
|
3
|
+
export type ValidatorFn<V> = (validator: V, localization?: I18nTranslator) => StandardSchemaV1;
|
|
9
4
|
export declare function standardValidate<T extends StandardSchemaV1>(schema: T, input: StandardSchemaV1.InferInput<T>): StandardSchemaV1.InferOutput<T>;
|
|
10
5
|
export declare function isStandardValidateSuccess<O>(result: StandardSchemaV1.Result<O>): result is StandardSchemaV1.SuccessResult<O>;
|
package/lib/form-widget.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export type On<StateKeys extends UiState = never, FormType extends Record<string
|
|
|
17
17
|
click?: ReactiveWidgetPropertyValue<EventExpression, FormType>;
|
|
18
18
|
change?: ReactiveWidgetPropertyValue<EventExpression, FormType>;
|
|
19
19
|
filter?: ReactiveWidgetPropertyValue<EventExpression, FormType>;
|
|
20
|
+
blur?: ReactiveWidgetPropertyValue<EventExpression, FormType>;
|
|
20
21
|
}, StateKeys>;
|
|
21
22
|
export type BaseWidget<StateKeys extends UiState = never, FormType extends Record<string, any> = any, Props extends Record<string, any> = any> = {
|
|
22
23
|
uid: Uid;
|
package/lib/form.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import { WidgetLoaders } from './context/widget-registry';
|
|
1
2
|
import { FormWidget, LayoutWidget } from './form-widget';
|
|
2
|
-
import {
|
|
3
|
+
import { I18nTranslator } from './i18n';
|
|
4
|
+
import { ItemRenderer } from './item-renderer';
|
|
5
|
+
import { ReactiveExpression, UiState, ValidateOn } from './shared';
|
|
6
|
+
import { Action } from './store/actions';
|
|
7
|
+
import { Middleware, State } from './store/model';
|
|
3
8
|
import * as jd from 'ts.data.json';
|
|
4
9
|
export type Form<StateKeys extends UiState = never, FormType extends Record<string, any> = any> = {
|
|
5
10
|
states?: Record<StateKeys, ReactiveExpression>;
|
|
@@ -14,9 +19,21 @@ export declare function defineForm<FormType extends Record<string, any> = any, S
|
|
|
14
19
|
states?: States;
|
|
15
20
|
form: FormWidget<Extract<keyof States, string>, FormType>[];
|
|
16
21
|
}): Form<Extract<keyof States, string>, FormType>;
|
|
22
|
+
export interface FormInitConfig<ComponentType = unknown> {
|
|
23
|
+
formDef: string | Record<string, any>;
|
|
24
|
+
widgetLoaders: WidgetLoaders<ComponentType>;
|
|
25
|
+
formName?: string;
|
|
26
|
+
itemRenderers?: Record<string, ItemRenderer>;
|
|
27
|
+
localization?: I18nTranslator;
|
|
28
|
+
dependencies?: Record<string, unknown>;
|
|
29
|
+
middlewares?: Middleware<State, Action>[];
|
|
30
|
+
validateOn?: ValidateOn;
|
|
31
|
+
data?: Record<string, any>;
|
|
32
|
+
meta?: Record<string, any>;
|
|
33
|
+
}
|
|
17
34
|
export declare const formDefDecoder: jd.Decoder<{
|
|
18
35
|
states: {
|
|
19
36
|
[K: string]: string;
|
|
20
37
|
} | undefined;
|
|
21
|
-
form: LayoutWidget<string, any, any, (
|
|
38
|
+
form: LayoutWidget<string, any, any, (LayoutWidget<string, any, any, (LayoutWidget<string, any, any, (LayoutWidget<string, any, any, (LayoutWidget<string, any, any, (LayoutWidget<string, any, any, (LayoutWidget<string, any, any, (LayoutWidget<string, any, any, (LayoutWidget<string, any, any, (LayoutWidget<string, any, any, (LayoutWidget<string, any, any, (LayoutWidget<string, any, any, /*elided*/ any> | import('./form-widget').DisplayWidget<string, any, any> | import('./form-widget').InputWidget<any, string, any, any, any> | import('./form-widget').ActionWidget<string, any, any> | import('./form-widget').FunctionWidget<string, any, any>)[]> | import('./form-widget').DisplayWidget<string, any, any> | import('./form-widget').InputWidget<any, string, any, any, any> | import('./form-widget').ActionWidget<string, any, any> | import('./form-widget').FunctionWidget<string, any, any>)[]> | import('./form-widget').DisplayWidget<string, any, any> | import('./form-widget').InputWidget<any, string, any, any, any> | import('./form-widget').ActionWidget<string, any, any> | import('./form-widget').FunctionWidget<string, any, any>)[]> | import('./form-widget').DisplayWidget<string, any, any> | import('./form-widget').InputWidget<any, string, any, any, any> | import('./form-widget').ActionWidget<string, any, any> | import('./form-widget').FunctionWidget<string, any, any>)[]> | import('./form-widget').DisplayWidget<string, any, any> | import('./form-widget').InputWidget<any, string, any, any, any> | import('./form-widget').ActionWidget<string, any, any> | import('./form-widget').FunctionWidget<string, any, any>)[]> | import('./form-widget').DisplayWidget<string, any, any> | import('./form-widget').InputWidget<any, string, any, any, any> | import('./form-widget').ActionWidget<string, any, any> | import('./form-widget').FunctionWidget<string, any, any>)[]> | import('./form-widget').DisplayWidget<string, any, any> | import('./form-widget').InputWidget<any, string, any, any, any> | import('./form-widget').ActionWidget<string, any, any> | import('./form-widget').FunctionWidget<string, any, any>)[]> | import('./form-widget').DisplayWidget<string, any, any> | import('./form-widget').InputWidget<any, string, any, any, any> | import('./form-widget').ActionWidget<string, any, any> | import('./form-widget').FunctionWidget<string, any, any>)[]> | import('./form-widget').DisplayWidget<string, any, any> | import('./form-widget').InputWidget<any, string, any, any, any> | import('./form-widget').ActionWidget<string, any, any> | import('./form-widget').FunctionWidget<string, any, any>)[]> | import('./form-widget').DisplayWidget<string, any, any> | import('./form-widget').InputWidget<any, string, any, any, any> | import('./form-widget').ActionWidget<string, any, any> | import('./form-widget').FunctionWidget<string, any, any>)[]> | import('./form-widget').DisplayWidget<string, any, any> | import('./form-widget').InputWidget<any, string, any, any, any> | import('./form-widget').ActionWidget<string, any, any> | import('./form-widget').FunctionWidget<string, any, any>)[]>;
|
|
22
39
|
}>;
|
package/lib/i18n.d.ts
CHANGED
|
@@ -68,6 +68,18 @@ export type Localizable = string | {
|
|
|
68
68
|
/** Fallback text used when the key cannot be resolved */
|
|
69
69
|
default?: string;
|
|
70
70
|
};
|
|
71
|
+
/**
|
|
72
|
+
* An `I18nTranslator` that supports runtime language changes.
|
|
73
|
+
* Call `MutableI18nTranslator.setLang` to change the active language and notify all subscribed listeners.
|
|
74
|
+
*/
|
|
75
|
+
export interface MutableI18nTranslator extends I18nTranslator {
|
|
76
|
+
/**
|
|
77
|
+
* Updates the active language and notifies all listeners
|
|
78
|
+
*
|
|
79
|
+
* @param lang The new BCP 47 language tag (e.g., 'fr-CA', 'ar')
|
|
80
|
+
*/
|
|
81
|
+
setLang(lang: string): void;
|
|
82
|
+
}
|
|
71
83
|
export declare const isTranslationConfig: (value: unknown) => value is TranslationConfig;
|
|
72
84
|
/**
|
|
73
85
|
* Determines the text direction (left-to-right or right-to-left) based on the given language code.
|
|
@@ -81,7 +93,11 @@ export declare function getDirectionFromLanguage(lang: string): 'ltr' | 'rtl';
|
|
|
81
93
|
*
|
|
82
94
|
* This implementation performs no localization and simply returns the
|
|
83
95
|
* translation key unchanged. It is intended for use as a safe default
|
|
84
|
-
* when no i18n system is configured
|
|
85
|
-
*
|
|
96
|
+
* when no i18n system is configured while still supporting runtime language
|
|
97
|
+
* changes and subscriber notifications.
|
|
98
|
+
*
|
|
99
|
+
* Call `setLang` to change the active language and notify any subscribed listeners.
|
|
100
|
+
*
|
|
101
|
+
* @param lang The initial BCP 47 language tag; defaults to `navigator.language || 'en-US'`.
|
|
86
102
|
*/
|
|
87
|
-
export declare const identityTranslator: (lang?: string) =>
|
|
103
|
+
export declare const identityTranslator: (lang?: string) => MutableI18nTranslator;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Action } from '../../store/actions';
|
|
2
|
+
import { Middleware, State } from '../../store/model';
|
|
3
|
+
interface DevToolsConnection {
|
|
4
|
+
init(state: unknown): void;
|
|
5
|
+
send(action: unknown, state: unknown): void;
|
|
6
|
+
}
|
|
7
|
+
declare global {
|
|
8
|
+
interface Window {
|
|
9
|
+
__REDUX_DEVTOOLS_EXTENSION__?: {
|
|
10
|
+
connect(options?: {
|
|
11
|
+
name?: string;
|
|
12
|
+
}): DevToolsConnection;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export declare function devToolsMiddleware(name?: string): Middleware<State, Action>;
|
|
17
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './json-schema/json-schema.middleware';
|
|
1
|
+
export * from './devtools/devtools.middleware';
|
package/lib/shared.d.ts
CHANGED
|
@@ -24,6 +24,23 @@ export type Uid = string;
|
|
|
24
24
|
* Either `null` (there are no validation issues) or an array of issues.
|
|
25
25
|
*/
|
|
26
26
|
export type ValidationStatus = null | string[];
|
|
27
|
+
/**
|
|
28
|
+
* Represents the hierarchical structure of validation errors.
|
|
29
|
+
* Each `key` is a segment of a DotPath:
|
|
30
|
+
* e.g., in '$error.user.profile.name', the scope is '$errors' segments are 'user', 'profile', 'name'
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* {
|
|
34
|
+
* something: null,
|
|
35
|
+
* user: {
|
|
36
|
+
* email: ["Invalid format"],
|
|
37
|
+
* address: { street: ["Required"] }
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
*/
|
|
41
|
+
export type $Errors = {
|
|
42
|
+
[key: string]: ValidationStatus | $Errors;
|
|
43
|
+
};
|
|
27
44
|
export type WidgetPropertyFunctionParams<FormType extends Record<string, any>> = {
|
|
28
45
|
$form: ImmutableRecord<FormType>;
|
|
29
46
|
translate?: I18nTranslator['translate'];
|
|
@@ -81,6 +98,7 @@ export type FormEvent<T = any> = {
|
|
|
81
98
|
*/
|
|
82
99
|
export type ControlTemplateData<T, V = any> = {
|
|
83
100
|
lang?: string;
|
|
101
|
+
deps?: Record<string, unknown>;
|
|
84
102
|
label?: string;
|
|
85
103
|
value?: T;
|
|
86
104
|
/**
|
|
@@ -104,6 +122,7 @@ export type ControlTemplateData<T, V = any> = {
|
|
|
104
122
|
*/
|
|
105
123
|
export type LayoutTemplateData = {
|
|
106
124
|
lang?: string;
|
|
125
|
+
deps?: Record<string, unknown>;
|
|
107
126
|
/**
|
|
108
127
|
* A size relative to the container and sibling components
|
|
109
128
|
* @example
|
|
@@ -118,6 +137,7 @@ export type LayoutTemplateData = {
|
|
|
118
137
|
*/
|
|
119
138
|
export type DisplayWidgetTemplateData = {
|
|
120
139
|
lang?: string;
|
|
140
|
+
deps?: Record<string, unknown>;
|
|
121
141
|
/**
|
|
122
142
|
* A size relative to the container and sibling components
|
|
123
143
|
* @example
|
|
@@ -131,6 +151,7 @@ export type DisplayWidgetTemplateData = {
|
|
|
131
151
|
*/
|
|
132
152
|
export type ActionWidgetTemplateData = {
|
|
133
153
|
lang?: string;
|
|
154
|
+
deps?: Record<string, unknown>;
|
|
134
155
|
label?: string;
|
|
135
156
|
disabled?: boolean;
|
|
136
157
|
/**
|
package/lib/store/actions.d.ts
CHANGED
|
@@ -17,6 +17,17 @@ export type SET_DATA = {
|
|
|
17
17
|
data: Record<string, any>;
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Sets supplemental runtime context for the form.
|
|
22
|
+
*
|
|
23
|
+
* @param payload.meta An object with contextual data (e.g. session info or external references)
|
|
24
|
+
*/
|
|
25
|
+
export type SET_META = {
|
|
26
|
+
type: 'SET_META';
|
|
27
|
+
payload: {
|
|
28
|
+
meta: Record<string, any>;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
20
31
|
/**
|
|
21
32
|
* Sets the i18n language
|
|
22
33
|
*/
|
|
@@ -62,7 +73,8 @@ export type SET_WIDGET_DATA = {
|
|
|
62
73
|
};
|
|
63
74
|
};
|
|
64
75
|
/**
|
|
65
|
-
*
|
|
76
|
+
* Overwrites a property in a form widget's `props` object.
|
|
77
|
+
* Targets widgets via `path` (for 'control' kinds) or `uid` (for all kinds).
|
|
66
78
|
*/
|
|
67
79
|
export type OVERRIDE_WIDGET_PROP = {
|
|
68
80
|
type: 'OVERRIDE_WIDGET_PROP';
|
|
@@ -70,6 +82,10 @@ export type OVERRIDE_WIDGET_PROP = {
|
|
|
70
82
|
path: DotPath;
|
|
71
83
|
prop: string;
|
|
72
84
|
value: any;
|
|
85
|
+
} | {
|
|
86
|
+
uid: string;
|
|
87
|
+
prop: string;
|
|
88
|
+
value: any;
|
|
73
89
|
};
|
|
74
90
|
};
|
|
75
91
|
export type SET_FORM_HEALTH = {
|
|
@@ -118,4 +134,4 @@ export type INJECT_VALIDATION_ISSUES = {
|
|
|
118
134
|
path: DotPath;
|
|
119
135
|
};
|
|
120
136
|
};
|
|
121
|
-
export type Action = INITIALIZE | SET_LANGUAGE | SET_DATA | ADD_WIDGET | REMOVE_WIDGET | SET_WIDGET_INITIAL_DATA | SET_WIDGET_DATA | OVERRIDE_WIDGET_PROP | SET_FORM_HEALTH | INJECT_VALIDATION_ISSUES | ATTEMPT_VALIDATION | VALIDATE_ALL;
|
|
137
|
+
export type Action = INITIALIZE | SET_LANGUAGE | SET_DATA | SET_META | ADD_WIDGET | REMOVE_WIDGET | SET_WIDGET_INITIAL_DATA | SET_WIDGET_DATA | OVERRIDE_WIDGET_PROP | SET_FORM_HEALTH | INJECT_VALIDATION_ISSUES | ATTEMPT_VALIDATION | VALIDATE_ALL;
|
package/lib/store/model.d.ts
CHANGED
|
@@ -54,7 +54,17 @@ export type State = {
|
|
|
54
54
|
* For example, this can be used to load options for a select widget asynchronously.
|
|
55
55
|
*/
|
|
56
56
|
widgetPropOverrides: Record<Uid, Record<string, any>>;
|
|
57
|
+
/**
|
|
58
|
+
* Key-value pairs representing the current state of the form's input fields.
|
|
59
|
+
* The keys correspond to the control names.
|
|
60
|
+
*/
|
|
57
61
|
data: Record<string, any>;
|
|
62
|
+
/**
|
|
63
|
+
* Supplemental runtime context used for form logic, calculations, and UI state.
|
|
64
|
+
* Includes external dependencies like display flags or error messages.
|
|
65
|
+
* @example { errorMessage: "Invalid credentials", isAuth: true }
|
|
66
|
+
*/
|
|
67
|
+
meta: Record<string, any>;
|
|
58
68
|
/**
|
|
59
69
|
* This reflects whether the form is currently functioning normally
|
|
60
70
|
* or is in an errored state.
|
|
@@ -86,22 +96,21 @@ export type FormHealth = {
|
|
|
86
96
|
} | {
|
|
87
97
|
status: 'errored';
|
|
88
98
|
message: string;
|
|
99
|
+
/**
|
|
100
|
+
* error codes below 1000 are reserved for the core
|
|
101
|
+
*/
|
|
102
|
+
code: number;
|
|
89
103
|
};
|
|
90
104
|
/**
|
|
91
|
-
* Represents a form widget whose value is derived from a computation
|
|
92
|
-
* and evaluated against its previous derived state.
|
|
105
|
+
* Represents a form widget whose value is derived from a computation.
|
|
93
106
|
*
|
|
94
|
-
* A `DerivedWidget<T>` captures the source widget
|
|
95
|
-
*
|
|
96
|
-
*
|
|
107
|
+
* A `DerivedWidget<T>` captures the source widget definition and the most
|
|
108
|
+
* recently computed, fully resolved widget. Reference identity is used for
|
|
109
|
+
* change detection: a new object is created only when a property has changed.
|
|
97
110
|
*/
|
|
98
111
|
export type DerivedWidget<F extends Widget.FormWidget<string>> = {
|
|
99
112
|
/** The source widget from which the derived value is computed */
|
|
100
113
|
source: F;
|
|
101
|
-
/** The
|
|
102
|
-
previous: Exclude<F, Widget.FunctionWidget<string>>;
|
|
103
|
-
/** The newly derived value */
|
|
114
|
+
/** The most recently computed, fully resolved widget */
|
|
104
115
|
current: Exclude<F, Widget.FunctionWidget<string>>;
|
|
105
|
-
/** Indicates whether the newly derived value changed structurally */
|
|
106
|
-
changed?: boolean;
|
|
107
116
|
};
|
|
@@ -7,7 +7,8 @@ export * from './inject-validation-issues';
|
|
|
7
7
|
export * from './override-widget-prop';
|
|
8
8
|
export * from './remove-widget';
|
|
9
9
|
export * from './set-data';
|
|
10
|
-
export * from './set-widget-data';
|
|
11
10
|
export * from './set-form-health';
|
|
12
11
|
export * from './set-language';
|
|
12
|
+
export * from './set-meta';
|
|
13
|
+
export * from './set-widget-data';
|
|
13
14
|
export * from './validate-all';
|