@golemui/core 1.0.3 → 1.1.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/CHANGELOG.md +10 -0
- package/index.d.ts +1 -1
- package/index.js +1082 -1053
- package/index.umd.cjs +7 -7
- package/lib/context/form.context.d.ts +2 -2
- package/lib/form-store.d.ts +2 -2
- package/lib/form.d.ts +9 -1
- package/lib/shared.d.ts +32 -0
- package/lib/store/model.d.ts +31 -1
- package/lib/store/reducer.d.ts +3 -2
- package/lib/store/reducers/calculate-current-state.d.ts +2 -1
- package/lib/store/reducers/calculate-widget-flags.d.ts +2 -1
- package/lib/store/reducers/calculate-widget-props.d.ts +2 -1
- package/lib/store/reducers/index.d.ts +1 -0
- package/lib/store/reducers/materialize-repeater-items.d.ts +10 -0
- package/lib/utils/justin.d.ts +15 -2
- package/lib/utils/repeater.d.ts +31 -7
- package/package.json +1 -1
package/index.umd.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("rxjs");require("@standard-schema/spec");function mt(e,t){const r=e["~standard"].validate(t);if(r instanceof Promise)throw new TypeError("Schema validation must be synchronous");return r}function gt(e){return e.issues===void 0}var rr=class{value;constructor(e){this.value=e}map(e){return k(e(this.value))}isOk(){return!0}},nr=class yt{issues;constructor(t){this.issues=t}map(t){return new yt(this.issues)}isOk(){return!1}};function k(e){return new rr(e)}function C(e){return new nr(e)}function At(e){return e.reduce((t,r)=>typeof r=="number"?`${t}[${r}]`:t.length===0?String(r):`${t}.${r}`,"")}function dt(e){return e.map(t=>t.path.length===0?t.message:`${At(t.path)}: ${t.message}`).join("; ")}var D=class Fe{decodeFn;constructor(t){this.decodeFn=t}parse(t){let r=this.decode(t);if(r.isOk())return r.value;{let n=r;throw Error(dt(n.issues),{cause:n.issues})}}decode(t){return this.decodeFn(t)}"~standard"={version:1,vendor:"ts.data.json",validate:t=>{let r=this.decode(t);return r.isOk()?{value:r.value}:{issues:r.issues.map(n=>({message:n.message,path:n.path.length>0?n.path.map(o=>({key:o})):void 0}))}}};decodePromise(t){return new Promise((r,n)=>{let o=this.decode(t);if(o.isOk())return r(o.value);{let i=o;return n(Error(dt(i.issues),{cause:i.issues}))}})}map(t){return new Fe(r=>{let n=this.decodeFn(r);return n.isOk()?k(t(n.value)):C(n.issues)})}flatMap(t){return new Fe(r=>{let n=this.decodeFn(r);return n.isOk()?t(n.value).decode(r):C(n.issues)})}},K=(e,t)=>[{message:`${JSON.stringify(e)} is not a valid ${t}`,path:[]}],_e=(e,t)=>e.map(r=>({...r,path:[t,...r.path]}));function Ve(e){return new D(t=>{if(t instanceof Array){let r=[],n=[];for(let o=0;o<t.length;o++){let i=e.decode(t[o]);i.isOk()?r.push(i.value):n.push(..._e(i.issues,o))}return n.length>0?C(n):k(r)}else return C(K(t,"array"))})}function or(){return new D(e=>typeof e=="boolean"?k(e):C(K(e,"boolean")))}function ir(e,t){return new D(r=>{if(typeof r!="object"||!r)return C(K(r,"object"));let n=r[e];return Object.prototype.hasOwnProperty.call(t,n)?t[n].decode(r):C([{message:`"${e}" must be one of ${Object.keys(t).map(o=>JSON.stringify(o)).join(", ")}, but got ${JSON.stringify(n)}`,path:[e]}])})}function $t(e){return new D(t=>e().decode(t))}function J(e){return new D(t=>t===e?k(e):C([{message:`${JSON.stringify(t)} is not exactly ${JSON.stringify(e)}`,path:[]}]))}function $e(){return new D(e=>typeof e=="number"?k(e):C(K(e,"number")))}function re(e){return new D(t=>{if(typeof t=="object"&&t){let r={},n=[];for(let o in e)if(Object.prototype.hasOwnProperty.call(e,o)){let i,s=e[o];i=s instanceof D?s.decode(t[o]):s.decoder.decode(t[s.fromKey]),i.isOk()?r[o]=i.value:n.push(..._e(i.issues,o))}return n.length>0?C(n):k(r)}else return C(K(t,"object"))})}function Q(e){return new D(t=>{let r=[];for(let n=0;n<e.length;n++){let o=e[n].decode(t);if(o.isOk())return o;r.push(o.issues)}return C([{message:`no alternative matched (tried ${e.length})`,path:[]},...sr(r)])})}function sr(e){let t=new Map;for(let r of e)for(let n of r){let o=JSON.stringify(n.path),i=t.get(o);i?i.messages.includes(n.message)||i.messages.push(n.message):t.set(o,{path:n.path,messages:[n.message]})}return Array.from(t.values()).map(({path:r,messages:n})=>({message:n.join(" or "),path:r}))}function A(e){return new D(t=>t===void 0?k(void 0):e.decode(t))}function dr(e){return new D(t=>{if(typeof t=="object"&&t){let r={},n=[];for(let o in t)if(Object.prototype.hasOwnProperty.call(t,o)){let i=e.decode(t[o]);i.isOk()?r[o]=i.value:n.push(..._e(i.issues,o))}return n.length>0?C(n):k(r)}else return C(K(t,"object"))})}function w(){return new D(e=>typeof e=="string"?k(e):C(K(e,"string")))}function G(){return new D(e=>k(e))}function ne(e){return new D(t=>{if(typeof t!="object"||t===null)return C([{message:`Expected object literal, got "${typeof t}"`,path:[]}]);const r={};for(const[n,o]of Object.entries(e)){const i=o.decoder.decode(t[n]);if(!i.isOk())return C(i.issues.map(s=>({message:s.message,path:[n,...s.path]})));if(r[n]=i.value,o.suffixed){for(const[s,u]of Object.entries(t))if(s.startsWith(n+".")){const c=o.decoder.decode(u);if(!c.isOk())return C(c.issues.map(l=>({message:l.message,path:[s,...l.path]})));r[s]=c.value}}}return k(r)})}const Le=()=>crypto.randomUUID().slice(0,8),ur=e=>typeof e!="function"&&e.kind==="display",Y=e=>typeof e!="function"&&e.kind==="action",I=e=>typeof e!="function"&&e.kind==="input",ae=e=>typeof e!="function"&&e.kind==="layout",oe=e=>typeof e=="function",cr=re({in:Ve(w())}),Re=re({when:w()}),Se=Q([cr,Re]),lr=re({from:Ve(w())}),ve=Q([lr,Re]),je=Q([or(),Re]),ar=new D(e=>{const t=typeof e;return t==="function"?k(e):C([{message:`Expected a function, got '${t}'`,path:[]}])}),V=e=>Q([e,ar]),Me=ne({load:{suffixed:!0,decoder:V(A(w()))},click:{suffixed:!0,decoder:V(A(w()))},change:{suffixed:!0,decoder:V(A(w()))},filter:{suffixed:!0,decoder:V(A(w()))},blur:{suffixed:!0,decoder:V(A(w()))}}),fr=re({key:w(),default:A(w()),params:A(G())}),St=Q([w(),fr]),Be=A(w()).map(e=>e||Le()),pr=ne({kind:{decoder:J("display")},uid:{decoder:Be},type:{decoder:w()},size:{suffixed:!0,decoder:A($e())},include:{decoder:A(Se)},exclude:{decoder:A(ve)},props:{decoder:A(G())}}),hr=ne({kind:{decoder:J("action")},uid:{decoder:Be},type:{decoder:w()},actionType:{decoder:A(Q([J("button"),J("submit")]))},size:{suffixed:!0,decoder:A($e())},include:{decoder:A(Se)},exclude:{decoder:A(ve)},label:{suffixed:!0,decoder:V(A(St))},disabled:{suffixed:!0,decoder:A(je)},on:{decoder:A(Me)},props:{decoder:A(G())}}),mr=new D(e=>{const t=typeof e;if(t==="function"){const r=e,n=r({$form:{},errors:void 0,touched:void 0,translate:void 0});return r.uid=n.uid||Le(),r.type=n.type,r.path=n.path,k(r)}else return C([{message:`Expected a function, got '${t}'`,path:[]}])}),gr=ne({kind:{decoder:J("input")},uid:{decoder:A(w())},type:{decoder:w()},size:{suffixed:!0,decoder:A($e())},include:{decoder:A(Se)},exclude:{decoder:A(ve)},disabled:{suffixed:!0,decoder:A(je)},readonly:{suffixed:!0,decoder:A(je)},on:{decoder:A(Me)},props:{decoder:A(G())},label:{suffixed:!0,decoder:V(A(St))},path:{decoder:w()},defaultValue:{decoder:A(G())},validator:{suffixed:!0,decoder:V(A(G()))}}).map(e=>{const t={...e};if(e.uid||(t.uid=`${e.path}-${e.type}`),e.type==="repeater"){const r=e.props;r.template=He.parse(r.template)}return t}),yr=$t(()=>{const e=ir("kind",{input:gr,layout:He,display:pr,action:hr});return new D(t=>typeof t=="function"?mr.decode(t):e.decode(t))}),He=ne({kind:{decoder:J("layout")},uid:{decoder:Be},type:{decoder:w()},size:{suffixed:!0,decoder:A($e())},include:{decoder:A(Se)},exclude:{decoder:A(ve)},props:{decoder:A(G())},on:{decoder:A(Me)},children:{decoder:Ve(yr)}}),B=class B{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(!B.sharedCache.has(r)){const n=r().catch(o=>(B.sharedCache.delete(r),Promise.reject(o)));B.sharedCache.set(r,n)}return B.sharedCache.get(r)}};B.sharedCache=new Map;let We=B;function Ar(e){return{...e,form:{uid:"",type:"flex",kind:"layout",children:e.form}}}const vt=re({states:A(dr(w())),form:$t(()=>He)}),Et=e=>({formName:"",formDef:vt.parse({form:{kind:"layout",type:"flex",children:[]}}),flatForm:{},currentStates:[],calculatedWidgets:{},validations:{},touchedControls:{},injectedValidations:{},isFormValid:!0,widgetFlags:{},widgetPropOverrides:{},data:{},meta:{},formHealth:{status:"ok"},touched:!1,lang:e}),$r=e=>!(typeof e!="object"||e===null||typeof e.key!="string");function Sr(e){const t=new Intl.Locale(e).maximize().script;return["Arab","Hebr","Thaa","Syrc","Tfng","Adlm","Rohg"].includes(t||"")?"rtl":"ltr"}const Ct=(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(o=>o(e))}}},vr=e=>{throw new Error(`Unhandled case: ${JSON.stringify(e)}`)};function W(e,...t){return t.reduce((r,n)=>n(r),e)}function Er(e,t){const r=t.payload.widget.uid;if(!r)throw new Error("addWidget: widget must have a uid");const n=t.payload.widget,o=e.touched&&I(n)?{...e.touchedControls,[n.path]:!0}:e.touchedControls;return{...e,touchedControls:o,calculatedWidgets:{...e.calculatedWidgets,[r]:{source:n,current:{}}}}}const b={calculateCurrentStateError:10,initializeParseError:20,initializeUidCollisionError:21,initializeUnknownError:22,initializeMalformedFormShapeError:23,widgetCouldNotBeLoaded:30,resolveStringInterpolationError:40},ie=(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)},Ge=(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]=wr(c)?[]:{}),o=o[u]}const i=n[n.length-1];return o[i]=r,e},Cr=(e,t)=>{if(t==="")return e;const r=t.split("."),n=[e];for(let s=0;s<r.length-1;s++){const u=n[s];if(u==null||typeof u!="object")return e;const c=r[s],l=Array.isArray(u)?u[parseInt(c,10)]:u[c];if(l==null||typeof l!="object")return e;n.push(l)}const o=n[n.length-1],i=r[r.length-1];Array.isArray(o)?o.splice(parseInt(i,10),1):delete o[i];for(let s=n.length-1;s>=1;s--){const u=n[s];if(Array.isArray(u)||!Or(u))break;const c=n[s-1],l=r[s-1];if(Array.isArray(c))break;delete c[l]}return e};function wr(e){const t=Number(e);return Number.isInteger(t)&&t>=0&&t.toString()===e}function Or(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0}const Ee=(e,t)=>(delete e[t],e);function fe(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(r=>fe(r));const t={};for(const r of Object.keys(e))t[r]=fe(e[r]);return t}function be(e){return e.flatMap(t=>[t,...ae(t)?be(t.children):[]])}function Ke(e){return Object.entries(e.validations).reduce((r,[n,o])=>(o!==null&&(r.$formIsInvalid=!0,Ge(r.$errors,n,[...o])),r),{$formIsInvalid:!1,$errors:{}})}function Oe(e){const t=fe(e.data);for(const[r,n]of Object.entries(e.widgetFlags))if(n.hidden===!0){const o=e.flatForm[r];o&&I(o)&&Cr(t,o.path)}return t}const ze=32;let Pe,h,y,$=e=>(h=0,y=e,$.newline=!1,e=v(),y[h]?z():e||""),z=(e="Unexpected token",t=h,r=y.slice(0,t).split(`
|
|
2
|
-
`),n=r.pop(),o=y.slice(Math.max(0,t-40),t),i="̭",s=(y[t]||" ")+i,
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("rxjs");require("@standard-schema/spec");function mt(e,t){const r=e["~standard"].validate(t);if(r instanceof Promise)throw new TypeError("Schema validation must be synchronous");return r}function gt(e){return e.issues===void 0}var nr=class{value;constructor(e){this.value=e}map(e){return T(e(this.value))}isOk(){return!0}},or=class yt{issues;constructor(t){this.issues=t}map(t){return new yt(this.issues)}isOk(){return!1}};function T(e){return new nr(e)}function C(e){return new or(e)}function $t(e){return e.reduce((t,r)=>typeof r=="number"?`${t}[${r}]`:t.length===0?String(r):`${t}.${r}`,"")}function st(e){return e.map(t=>t.path.length===0?t.message:`${$t(t.path)}: ${t.message}`).join("; ")}var D=class We{decodeFn;constructor(t){this.decodeFn=t}parse(t){let r=this.decode(t);if(r.isOk())return r.value;{let n=r;throw Error(st(n.issues),{cause:n.issues})}}decode(t){return this.decodeFn(t)}"~standard"={version:1,vendor:"ts.data.json",validate:t=>{let r=this.decode(t);return r.isOk()?{value:r.value}:{issues:r.issues.map(n=>({message:n.message,path:n.path.length>0?n.path.map(o=>({key:o})):void 0}))}}};decodePromise(t){return new Promise((r,n)=>{let o=this.decode(t);if(o.isOk())return r(o.value);{let i=o;return n(Error(st(i.issues),{cause:i.issues}))}})}map(t){return new We(r=>{let n=this.decodeFn(r);return n.isOk()?T(t(n.value)):C(n.issues)})}flatMap(t){return new We(r=>{let n=this.decodeFn(r);return n.isOk()?t(n.value).decode(r):C(n.issues)})}},H=(e,t)=>[{message:`${JSON.stringify(e)} is not a valid ${t}`,path:[]}],Ue=(e,t)=>e.map(r=>({...r,path:[t,...r.path]}));function _e(e){return new D(t=>{if(t instanceof Array){let r=[],n=[];for(let o=0;o<t.length;o++){let i=e.decode(t[o]);i.isOk()?r.push(i.value):n.push(...Ue(i.issues,o))}return n.length>0?C(n):T(r)}else return C(H(t,"array"))})}function ir(){return new D(e=>typeof e=="boolean"?T(e):C(H(e,"boolean")))}function sr(e,t){return new D(r=>{if(typeof r!="object"||!r)return C(H(r,"object"));let n=r[e];return Object.prototype.hasOwnProperty.call(t,n)?t[n].decode(r):C([{message:`"${e}" must be one of ${Object.keys(t).map(o=>JSON.stringify(o)).join(", ")}, but got ${JSON.stringify(n)}`,path:[e]}])})}function At(e){return new D(t=>e().decode(t))}function K(e){return new D(t=>t===e?T(e):C([{message:`${JSON.stringify(t)} is not exactly ${JSON.stringify(e)}`,path:[]}]))}function ye(){return new D(e=>typeof e=="number"?T(e):C(H(e,"number")))}function re(e){return new D(t=>{if(typeof t=="object"&&t){let r={},n=[];for(let o in e)if(Object.prototype.hasOwnProperty.call(e,o)){let i,s=e[o];i=s instanceof D?s.decode(t[o]):s.decoder.decode(t[s.fromKey]),i.isOk()?r[o]=i.value:n.push(...Ue(i.issues,o))}return n.length>0?C(n):T(r)}else return C(H(t,"object"))})}function X(e){return new D(t=>{let r=[];for(let n=0;n<e.length;n++){let o=e[n].decode(t);if(o.isOk())return o;r.push(o.issues)}return C([{message:`no alternative matched (tried ${e.length})`,path:[]},...dr(r)])})}function dr(e){let t=new Map;for(let r of e)for(let n of r){let o=JSON.stringify(n.path),i=t.get(o);i?i.messages.includes(n.message)||i.messages.push(n.message):t.set(o,{path:n.path,messages:[n.message]})}return Array.from(t.values()).map(({path:r,messages:n})=>({message:n.join(" or "),path:r}))}function $(e){return new D(t=>t===void 0?T(void 0):e.decode(t))}function ur(e){return new D(t=>{if(typeof t=="object"&&t){let r={},n=[];for(let o in t)if(Object.prototype.hasOwnProperty.call(t,o)){let i=e.decode(t[o]);i.isOk()?r[o]=i.value:n.push(...Ue(i.issues,o))}return n.length>0?C(n):T(r)}else return C(H(t,"object"))})}function I(){return new D(e=>typeof e=="string"?T(e):C(H(e,"string")))}function M(){return new D(e=>T(e))}function ne(e){return new D(t=>{if(typeof t!="object"||t===null)return C([{message:`Expected object literal, got "${typeof t}"`,path:[]}]);const r={};for(const[n,o]of Object.entries(e)){const i=o.decoder.decode(t[n]);if(!i.isOk())return C(i.issues.map(s=>({message:s.message,path:[n,...s.path]})));if(r[n]=i.value,o.suffixed){for(const[s,d]of Object.entries(t))if(s.startsWith(n+".")){const c=o.decoder.decode(d);if(!c.isOk())return C(c.issues.map(l=>({message:l.message,path:[s,...l.path]})));r[s]=c.value}}}return T(r)})}const Le=()=>crypto.randomUUID().slice(0,8),cr=e=>typeof e!="function"&&e.kind==="display",ue=e=>typeof e!="function"&&e.kind==="action",W=e=>typeof e!="function"&&e.kind==="input",ce=e=>typeof e!="function"&&e.kind==="layout",J=e=>typeof e=="function",lr=re({in:_e(I())}),Re=re({when:I()}),$e=X([lr,Re]),ar=re({from:_e(I())}),Ae=X([ar,Re]),Te=X([ir(),Re]),fr=new D(e=>{const t=typeof e;return t==="function"?T(e):C([{message:`Expected a function, got '${t}'`,path:[]}])}),U=e=>X([e,fr]),Ve=ne({load:{suffixed:!0,decoder:U($(I()))},click:{suffixed:!0,decoder:U($(I()))},change:{suffixed:!0,decoder:U($(I()))},filter:{suffixed:!0,decoder:U($(I()))},blur:{suffixed:!0,decoder:U($(I()))}}),pr=re({key:I(),default:$(I()),params:$(M())}),St=X([I(),pr]),Me=$(I()).map(e=>e||Le()),hr=ne({kind:{decoder:K("display")},uid:{decoder:Me},type:{decoder:I()},size:{suffixed:!0,decoder:$(ye())},include:{decoder:$($e)},exclude:{decoder:$(Ae)},props:{decoder:$(M())}}),mr=ne({kind:{decoder:K("action")},uid:{decoder:Me},type:{decoder:I()},actionType:{decoder:$(X([K("button"),K("submit")]))},size:{suffixed:!0,decoder:$(ye())},include:{decoder:$($e)},exclude:{decoder:$(Ae)},label:{suffixed:!0,decoder:U($(St))},disabled:{suffixed:!0,decoder:$(Te)},on:{decoder:$(Ve)},props:{decoder:$(M())}}),gr=new D(e=>{const t=typeof e;if(t==="function"){const r=e,n=r({$form:{},errors:void 0,touched:void 0,translate:void 0});return r.uid=n.uid||Le(),r.type=n.type,r.path=n.path,T(r)}else return C([{message:`Expected a function, got '${t}'`,path:[]}])}),yr=ne({kind:{decoder:K("input")},uid:{decoder:$(I())},type:{decoder:I()},size:{suffixed:!0,decoder:$(ye())},include:{decoder:$($e)},exclude:{decoder:$(Ae)},disabled:{suffixed:!0,decoder:$(Te)},readonly:{suffixed:!0,decoder:$(Te)},on:{decoder:$(Ve)},props:{decoder:$(M())},label:{suffixed:!0,decoder:U($(St))},path:{decoder:I()},defaultValue:{decoder:$(M())},validator:{suffixed:!0,decoder:U($(M()))}}).map(e=>{const t={...e};if(e.uid||(t.uid=`${e.path}-${e.type}`),e.type==="repeater"){const r=e.props;r.template=Be.parse(r.template)}return t}),$r=At(()=>{const e=sr("kind",{input:yr,layout:Be,display:hr,action:mr});return new D(t=>typeof t=="function"?gr.decode(t):e.decode(t))}),Be=ne({kind:{decoder:K("layout")},uid:{decoder:Me},type:{decoder:I()},size:{suffixed:!0,decoder:$(ye())},include:{decoder:$($e)},exclude:{decoder:$(Ae)},props:{decoder:$(M())},on:{decoder:$(Ve)},children:{decoder:_e($r)}}),V=class V{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(!V.sharedCache.has(r)){const n=r().catch(o=>(V.sharedCache.delete(r),Promise.reject(o)));V.sharedCache.set(r,n)}return V.sharedCache.get(r)}};V.sharedCache=new Map;let ke=V;function Ar(e){return{...e,form:{uid:"",type:"flex",kind:"layout",children:e.form}}}const vt=re({states:$(ur(I())),form:At(()=>Be)}),Et=e=>({formName:"",formDef:vt.parse({form:{kind:"layout",type:"flex",children:[]}}),flatForm:{},currentStates:[],calculatedWidgets:{},validations:{},touchedControls:{},injectedValidations:{},isFormValid:!0,widgetFlags:{},repeaterItemScopes:{},materializedRepeaterWidgets:{},widgetPropOverrides:{},data:{},meta:{},formHealth:{status:"ok"},touched:!1,lang:e}),Sr=e=>!(typeof e!="object"||e===null||typeof e.key!="string");function vr(e){const t=new Intl.Locale(e).maximize().script;return["Arab","Hebr","Thaa","Syrc","Tfng","Adlm","Rohg"].includes(t||"")?"rtl":"ltr"}const Ct=(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(o=>o(e))}}},Er=e=>{throw new Error(`Unhandled case: ${JSON.stringify(e)}`)};function j(e,...t){return t.reduce((r,n)=>n(r),e)}const P=(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)},He=(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 d=n[s],c=n[s+1];(o[d]==null||typeof o[d]!="object")&&(o[d]=Ir(c)?[]:{}),o=o[d]}const i=n[n.length-1];return o[i]=r,e},Cr=(e,t)=>{if(t==="")return e;const r=t.split("."),n=[e];for(let s=0;s<r.length-1;s++){const d=n[s];if(d==null||typeof d!="object")return e;const c=r[s],l=Array.isArray(d)?d[parseInt(c,10)]:d[c];if(l==null||typeof l!="object")return e;n.push(l)}const o=n[n.length-1],i=r[r.length-1];Array.isArray(o)?o.splice(parseInt(i,10),1):delete o[i];for(let s=n.length-1;s>=1;s--){const d=n[s];if(Array.isArray(d)||!wr(d))break;const c=n[s-1],l=r[s-1];if(Array.isArray(c))break;delete c[l]}return e};function Ir(e){const t=Number(e);return Number.isInteger(t)&&t>=0&&t.toString()===e}function wr(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0}const Se=(e,t)=>(delete e[t],e);function le(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(r=>le(r));const t={};for(const r of Object.keys(e))t[r]=le(e[r]);return t}function Or(e,t){const r=t.payload.widget.uid;if(!r)throw new Error("addWidget: widget must have a uid");const n=t.payload.widget,o=e.touched&&W(n)?{...e.touchedControls,[n.path]:!0}:e.touchedControls;return{...e,touchedControls:o,calculatedWidgets:{...e.calculatedWidgets,[r]:{source:n,current:{}}}}}const B={calculateCurrentStateError:10,initializeParseError:20,initializeUidCollisionError:21,initializeUnknownError:22,initializeMalformedFormShapeError:23,widgetCouldNotBeLoaded:30,resolveStringInterpolationError:40};function ze(e){return e.flatMap(t=>[t,...ce(t)?ze(t.children):[]])}function Ge(e){return Object.entries(e.validations).reduce((r,[n,o])=>(o!==null&&(r.$formIsInvalid=!0,He(r.$errors,n,[...o])),r),{$formIsInvalid:!1,$errors:{}})}function Ie(e){const t=le(e.data);for(const[r,n]of Object.entries(e.widgetFlags))if(n.hidden===!0){const o=e.flatForm[r];o&&W(o)&&Cr(t,o.path)}return t}const be=32;let Fe,h,y,A=e=>(h=0,y=e,A.newline=!1,e=v(),y[h]?z():e||""),z=(e="Unexpected token",t=h,r=y.slice(0,t).split(`
|
|
2
|
+
`),n=r.pop(),o=y.slice(Math.max(0,t-40),t),i="̭",s=(y[t]||" ")+i,d=y.slice(t+1,t+20))=>{throw SyntaxError(`${e} at ${r.length+1}:${n.length+1}
|
|
3
3
|
${y[t-41]!==`
|
|
4
|
-
`,""+o}${s}${
|
|
5
|
-
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},
|
|
6
|
-
`,"/*":"*/"};let
|
|
7
|
-
`)for(;y.charCodeAt(n)>=qr;)n++;else{for(;y[n]&&y.substr(n,r[1].length)!==r[1];)n++;y[n]&&(n+=r[1].length)}
|
|
8
|
-
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},pt=()=>{const e=[];for(let t="",r;(r=y.charCodeAt(h))!==Ae;)r?r===An?(O(),t+=$n[y[h]]||y[h],O()):r===gn&&y.charCodeAt(h+1)===yn?(t&&e.push([,t]),t="",O(2),e.push(v(0,125))):(t+=y[h],O(),r=y.charCodeAt(h),r===Ae&&t&&e.push([,t])):z("Unterminated template");return O(),e},Sn=j[Ae];j[Ae]=(e,t)=>e&&t<mn?$.asi&&$.newline?void 0:(O(),["``",e,...pt()]):e?Sn?.(e,t):(O(),(r=>r.length<2&&r[0]?.[0]===void 0?r[0]||[,""]:["`",...r])(pt()));a("`",(...e)=>(e=e.map(d),t=>e.map(r=>r(t)).join("")));a("``",(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 vn={log:(e,t)=>(t?console.log(t,e):console.log(e),e)};function N(e,t,r,n,o){const i=$(nt(e));return d(i)({$form:t,$meta:r,$errors:n,$formIsInvalid:o,$log:vn.log})===!0}function nt(e){return e.replace(/\?\.(\d+)/g,"?.[$1]").replace(/\.(\d+)/g,"[$1]")}const U=e=>{let t=e.formDef.states;if(!t||Object.keys(t).length===0||e.formHealth.status==="errored")return e;const{$formIsInvalid:r,$errors:n}=Ke(e);t=En(t);let o=[],i={status:"ok"};try{o=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=b.calculateCurrentStateError;i={status:"errored",message:`[${c}] ${u.message}`,code:c}}return{...e,currentStates:o,formHealth:i}};function En(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 ot=Symbol("filterMap.skip");function Kt(e,t){const r=[];for(let n=0;n<e.length;n++){const o=t(e[n],n,e);o!==ot&&r.push(o)}return r}function Cn(e,t,r){for(let n=0;n<e.length;n++)t(e[n],n,e)&&r(e[n],n,e)}function wn(e,t,r,n){let o=n;for(let i=0;i<e.length;i++)t(e[i],i,e)&&(o=r(o,e[i],i,e));return o}function On(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 zt(e,t){const r=Xt(e.uid,t);return I(e)?{...e,uid:r,path:In(e.path,t)}:{...e,uid:r}}function Xt(e,t){if(t.length===0)throw new Error("Repeater indexes cannot be an empty array");const r=t.reduce((n,o)=>`${n}[${o}]`,"");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}`),o=n.length-1;if(o!==t.length)throw new Error(`Path contains ${o} '${r}' occurrences, but ${t.length} indexes were provided.`);return n.reduce((i,s,u)=>u===0?s:`${i}.${t[u-1]}${s}`)}function ue(e,t){let r=0;return e.replace(/\.items(\??)\./g,(n,o)=>{const i=t[r++];return i===void 0?n:`.${i}${o}.`})}const ce=(e,t)=>r=>e(r)?t(r):r,H=e=>e!==void 0&&typeof e=="object"&&e!==null&&"when"in e,_=e=>{const{$formIsInvalid:t,$errors:r}=Ke(e);return{...e,widgetFlags:{...Dn(e,r,t),...Tn(e,r,t)}}};function Dn(e,t,r){return Kt(Object.values(e.flatForm),n=>{if(n.uid?.includes("["))return ot;if(oe(n)){const o=n({$form:e.data,errors:void 0,touched:void 0,translate:void 0});return o.uid=n.uid,o}return n}).filter(n=>!!(n.include&&("in"in n.include||"when"in n.include)||n.exclude&&("from"in n.exclude||"when"in n.exclude)||(I(n)||Y(n))&&H(n.disabled)||I(n)&&H(n.readonly))).reduce((n,o)=>(n[o.uid]=n[o.uid]||{},o.include&&"in"in o.include?n[o.uid].hidden=!o.include.in.some(i=>e.currentStates.includes(i)):o.include&&"when"in o.include&&(n[o.uid].hidden=!N(o.include.when,e.data,e.meta,t,r)),o.exclude&&"from"in o.exclude?n[o.uid].hidden=o.exclude.from.some(i=>e.currentStates.includes(i)):o.exclude&&"when"in o.exclude&&(n[o.uid].hidden=N(o.exclude.when,e.data,e.meta,t,r)),(I(o)||Y(o))&&H(o.disabled)&&(n[o.uid].disabled=N(o.disabled.when,e.data,e.meta,t,r)),I(o)&&H(o.readonly)&&(n[o.uid].readonly=N(o.readonly.when,e.data,e.meta,t,r)),n),{})}function Tn(e,t,r){return wn(Object.values(e.flatForm),n=>!oe(n)&&n.type==="repeater",(n,o)=>({...n,...Jt(e,o,[],t,r)}),{})}function Jt(e,t,r,n,o){const i=t.props.template,s=ie(e.data,t.path);if(!Array.isArray(s))return{};const u={};return s.forEach((c,l)=>{const g=[...r,l];be([i]).forEach(m=>{let f;if(oe(m)?(f=m({$form:e.data,errors:void 0,touched:void 0,translate:void 0}),f.uid=m.uid):f=m,f.type==="repeater"){const Z=zt(f,g);Object.assign(u,Jt(e,Z,g,n,o));return}const T=Xt(f.uid,g);u[T]=u[T]||{},f.include&&"in"in f.include?u[T].hidden=!f.include.in.some(Z=>e.currentStates.includes(Z)):f.include&&"when"in f.include&&(u[T].hidden=!N(ue(f.include.when,g),e.data,e.meta,n,o)),f.exclude&&"from"in f.exclude?u[T].hidden=f.exclude.from.some(Z=>e.currentStates.includes(Z)):f.exclude&&"when"in f.exclude&&(u[T].hidden=N(ue(f.exclude.when,g),e.data,e.meta,n,o)),(I(f)||Y(f))&&H(f.disabled)&&(u[T].disabled=N(ue(f.disabled.when,g),e.data,e.meta,n,o)),I(f)&&H(f.readonly)&&(u[T].readonly=N(ue(f.readonly.when,g),e.data,e.meta,n,o))})}),u}const P=e=>t=>{try{return{...t,calculatedWidgets:kn(t,e)}}catch(r){const n=r;return{...t,formHealth:{status:"errored",message:`[${n.code}] ${n.message}`,code:n.code}}}};function kn(e,t){const{$formIsInvalid:r,$errors:n}=Ke(e),o=Jn(e,t,r,n),i={};for(const s of Object.keys(e.calculatedWidgets)){if(e.widgetFlags[s]?.hidden)continue;const u=e.calculatedWidgets[s],c=u.source;if(oe(c)){i[s]=Fn(s,c,e,t);continue}i[s]=jn(u,c,e,o)}return i}function Fn(e,t,r,n){const o=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 o.uid=e,{source:t,current:o}}function jn(e,t,r,n){const o=new Xn(t,e.current);return o.write("uid",t.uid),o.write("type",t.type),o.write("kind",t.kind),ur(t)?Wn(o,n):Y(t)?Pn(o,n):I(t)?Nn(o,n):ae(t)&&Un(o,n),_n(t,o,n,r),(Y(t)||I(t))&&Vn(t,o,n),ae(t)&&Ln(t,o,r),o.changed?{source:e.source,current:o.current}:e}function Wn(e,t){E(e,t,"size"),E(e,t,"include"),E(e,t,"exclude")}function Pn(e,t){E(e,t,"size"),E(e,t,"include"),E(e,t,"exclude"),E(e,t,"label"),E(e,t,"disabled"),E(e,t,"actionType")}function Nn(e,t){E(e,t,"size"),E(e,t,"include"),E(e,t,"exclude"),E(e,t,"label"),E(e,t,"disabled"),E(e,t,"readonly"),E(e,t,"validator"),E(e,t,"path"),E(e,t,"defaultValue")}function Un(e,t){E(e,t,"size"),E(e,t,"include"),E(e,t,"exclude")}function _n(e,t,r,n){const o=n.widgetPropOverrides[e.uid]??{},i={...e.props??{},...o};for(const s of xt(Object.keys(i)))Rn(t,r,s)}function Vn(e,t,r){const n=e.on??{};for(const o of xt(Object.keys(n)))Mn(t,r,o)}function Ln(e,t,r){const n=xn(e.uid),o=qn(e.children,n,r.widgetFlags);t.current.children=o;const i=t.previous.children??[];i.length===o.length&&o.every((u,c)=>i[c]&&i[c].uid===o[c].uid)||t.markChanged()}function E(e,t,r){const n=e.source;if(!Qn(n,r))return;const o=st(n,r,t.sortedStates);let i;switch(r){case"disabled":case"readonly":i=Gn(o,t,e.source.uid,r);break;case"defaultValue":i=o;break;default:i=qt(o,t)}e.write(r,i)}function Rn(e,t,r){const n=e.source.props,o=st(n,r,t.sortedStates);let i=qt(o,t);const s=t.widgetPropOverrides[e.source.uid]?.[r];s!==void 0&&(i=s),e.write(`props.${r}`,i)}function Mn(e,t,r){const n=e.source.on,o=st(n,r,t.sortedStates);e.write(`on.${r}`,bn(o,t))}function it(e,t){return e({$form:t.$form,translate:t.localization.translate})}function Bn(e,t){return t.localization.translate(e.key,zn(e.params,t),e.default)}const Hn=/\{\{([^}]+)\}\}/g;function Qt(e,t){return e.includes("{{")?e.replace(Hn,(r,n)=>{const o=nt(n.trim());try{const i=d($(o))({$form:t.$form,$meta:t.$meta,$errors:t.$errors,$formIsInvalid:t.$formIsInvalid});return i==null?"":String(i)}catch(i){const s=i instanceof Error?i.message:String(i);throw new Zt(`Failed to evaluate '{{${n.trim()}}}': ${s}`)}}):e}function qt(e,t){return typeof e=="function"?it(e,t):$r(e)?Bn(e,t):typeof e=="string"?Qt(e,t):e}function Gn(e,t,r,n){return typeof e=="function"?it(e,t):H(e)?t.widgetFlags[r]?.[n]:typeof e=="string"?Qt(e,t):e}function bn(e,t){return typeof e=="function"?it(e,t):e}function st(e,t,r){if(e){for(const n of r){const o=e[`${t}.${n}`];if(o!==void 0)return o}return e[t]}}function Kn(e){return e.startsWith("$form")||e.startsWith("$meta")||e.startsWith("$errors")||e==="$formIsInvalid"}function zn(e,t){return e&&Object.keys(e).reduce((r,n)=>{const o=String(e[n]);if(Kn(o))try{const i=d($(nt(o)))({$form:t.$form,$meta:t.$meta,$errors:t.$errors,$formIsInvalid:t.$formIsInvalid});r[n]=i??o}catch(i){const s=i instanceof Error?i.message:String(i);throw new Zt(`Failed to evaluate i18n param '${o}': ${s}`)}else r[n]=o;return r},{})}class Xn{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){Ge(this.current,t,r),ie(this.previous,t)!==r&&(this._changed=!0)}}function Jn(e,t,r,n){return{sortedStates:[...e.currentStates].sort((o,i)=>i.length-o.length),widgetPropOverrides:e.widgetPropOverrides,widgetFlags:e.widgetFlags,$form:e.data,$meta:e.meta,$formIsInvalid:r,$errors:n,localization:t}}function Qn(e,t){if(t in e)return!0;const r=`${t}.`;return Object.keys(e).some(n=>n.startsWith(r))}function xt(e){return Array.from(new Set(e.map(t=>t.split(".")[0])))}function qn(e,t,r){const n=t.map(o=>`[${o}]`).join("");return e.filter(o=>{const i=o.uid+n,s=r[i];return!s||s.hidden!==!0})}const xn=e=>[...e.matchAll(/\[(\d+)\]/g)].map(t=>parseInt(t[1],10));class Zt extends Error{constructor(){super(...arguments),this.code=b.resolveStringInterpolationError,this.name="StringInterpolationError"}}const Zn=({lang:e},t)=>{const r={...Et(e),formName:t.payload.formName};let n=t.payload.formDef,o={status:"ok"};if(typeof n=="string"){try{n=JSON.parse(n)}catch(l){const g=l,m=b.initializeParseError;o={status:"errored",message:`[${m}] ${g.message}`,code:m}}if(o.status==="errored")return{...r,formHealth:o}}if(Array.isArray(n.form)){const l=n,g=l.form;l.form={uid:"",type:"flex",kind:"layout",children:g}}const i=vt.decode(n);if(i.isOk()){o={status:"ok"};let l={};try{l=be([i.value.form]).reduce((g,m)=>{const f=m.uid;if(g[f])throw{existingWidget:g[f],newWidget:m};return g[f]=m,g},{})}catch(g){o=to(g.existingWidget,g.newWidget),l={}}return ro(l,i.value.states),{...r,formDef:i.value,flatForm:l,formHealth:o}}const s=eo(n);if(s)return{...r,formHealth:s};const u=b.initializeUnknownError,c=i.issues.map(l=>`${l.path.length>0?At(l.path):"root"}: ${l.message}`).join("; ");return{...r,formHealth:{status:"errored",message:`[${u}] ${c}`,code:u}}};function Yt(e,t){return{status:"errored",code:e,message:`[${e}] ${t}`}}function Yn(){return"Malformed form definition. Pass it directly as formDef - `config={{ formDef: { states, form: [...] } }}`. Do NOT wrap it in an extra `{ form: ... }`."}function eo(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e.form;return t&&typeof t=="object"&&!Array.isArray(t)&&!ae(t)?Yt(b.initializeMalformedFormShapeError,Yn()):null}function to(e,t){const r=o=>I(o)?` at "${o.path}"`:"",n=`Duplicate UID "${t.uid}": Assigned to widget "${e.type}"${r(e)} and "${t.type}"${r(t)}.`;return Yt(b.initializeUidCollisionError,n)}function ro(e,t){const r=new Set(Object.keys(t??{})),n=new Map;for(const i of Object.values(e)){const s=[],u=i.include;u&&Array.isArray(u.in)&&s.push(...u.in);const c=i.exclude;c&&Array.isArray(c.from)&&s.push(...c.from);for(const l of s){if(r.has(l))continue;const g=n.get(l)??[];g.push(i.uid||"(unknown)"),n.set(l,g)}}if(n.size===0)return;const o=r.size?[...r].join(", "):"(none declared)";for(const[i,s]of n)console.error(`[GolemUI] include/exclude references undefined state "${i}" (on ${s.join(", ")}); these widgets will stay hidden. Declared states: ${o}. Fix: declare "${i}" in formConfig.states, or correct the name.`)}function no(e,t){return{...e,injectedValidations:{...e.injectedValidations,[t.payload.path]:t.payload.issues}}}const oo=(e,{payload:t})=>{let r;if("path"in t){if(r=Object.values(e.calculatedWidgets).find(({source:i})=>I(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=r.source.uid,o=e.widgetPropOverrides[n]||{};return{...e,widgetPropOverrides:{...e.widgetPropOverrides,[n]:{...o,[t.prop]:t.value}}}};function io(e,t){return W(e,so(t),uo(t),co(t),lo(t))}const so=e=>t=>({...t,widgetFlags:{...Ee(t.widgetFlags,e.payload.uid)}}),uo=e=>t=>({...t,calculatedWidgets:{...Ee(t.calculatedWidgets,e.payload.uid)}}),co=e=>t=>({...t,widgetPropOverrides:{...Ee(t.widgetPropOverrides,e.payload.uid)}}),lo=e=>t=>({...t,touchedControls:W(t.touchedControls,r=>{const n=t.flatForm[e.payload.uid];return n&&I(n)?Ee(r,n.path):r})}),ao=(e,t)=>({...e,data:{...t.payload.data}}),fo=(e,t)=>({...e,formHealth:t.payload.formHealth}),po=(e,t)=>({...e,lang:t.payload.lang}),ho=(e,t)=>({...e,meta:{...t.payload.meta}}),mo=(e,t)=>{const r=ie(e.data,t.payload.path);return t.type==="SET_WIDGET_DATA"||t.type==="SET_WIDGET_INITIAL_DATA"&&r===void 0?{...e,data:{...Ge(e.data,t.payload.path,t.payload.data)}}:e},Te=(e,t)=>r=>{const n=Kt(Object.values(r.calculatedWidgets),({current:i})=>I(i)?i:ot),o=r.validations;return{...r,validations:n.reduce((i,s)=>{if(i[s.path]=null,s.validator){const u=e(s.validator,t),c=ie(r.data,s.path),l=mt(u,c);i[s.path]=gt(l)?null:l.issues.map(g=>g.message)}return Array.isArray(i[s.path])&&Array.isArray(o[s.path])&&On(i[s.path],o[s.path],(u,c)=>u===c)&&(i[s.path]=o[s.path]),i},{})}},go=({validators:e,validateOn:t,localization:r})=>(n,o)=>{switch(o.type){case"INITIALIZE":return Zn(n,o);case"SET_DATA":return W(ao(n,o),U,_,P(r));case"SET_META":return W(ho(n,o),U,_,P(r));case"SET_LANGUAGE":return W(po(n,o),P(r));case"ADD_WIDGET":return W(Er(n,o),ce(ke,U),ce(ke,_),ce(ke,P(r)));case"REMOVE_WIDGET":return W(io(n,o),U,_,P(r));case"SET_WIDGET_INITIAL_DATA":case"SET_WIDGET_DATA":return W(mo(n,o),U,_,P(r));case"OVERRIDE_WIDGET_PROP":return W(oo(n,o),U,_,P(r),ce(i=>{let s=!1,u="";"path"in o.payload?(s=!0,u=o.payload.path):I(i.calculatedWidgets[o.payload.uid].current)&&(s=!0,u=i.calculatedWidgets[o.payload.uid].current.path);const c=s&&i.touchedControls[u];return i.touched&&c},Te(e,r)));case"SET_FORM_HEALTH":return fo(n,o);case"VALIDATE_ALL":return W({...n,touched:!0,touchedControls:Object.keys(n.calculatedWidgets).reduce((i,s)=>{const u=n.calculatedWidgets[s].source;return I(u)&&(i[u.path]=!0),i},{})},Te(e,r),U,_,P(r),ht);case"ATTEMPT_VALIDATION":{const i=o.payload.reason,s=o.payload.path;return t==="eager"||i===t||t.includes(i)?W({...n,touched:!0,touchedControls:{...n.touchedControls,[s]:!0}},Te(e,r),U,_,P(r),c=>{const l=o.payload.uid,g=c.calculatedWidgets[l],m=g.source;if(oe(m)){const f=m({$form:c.data,errors:c.validations[s],touched:!0,translate:r.translate});return{...c,calculatedWidgets:{...c.calculatedWidgets,[l]:{source:g.source,current:f}}}}return c},ht):n}case"INJECT_VALIDATION_ISSUES":return no(n,o);default:return vr(o)}},ke=e=>e.formHealth.status==="ok";function ht(e){const t=Object.keys(e.injectedValidations),r=Object.keys(e.validations);if(t.length===0&&r.length===0)return{...e,isFormValid:!0};let n=t.find(o=>e.injectedValidations[o]!==null&&Array.isArray(e.injectedValidations[o]));return n!==void 0?{...e,isFormValid:!1}:(n=r.find(o=>e.validations[o]!==null&&Array.isArray(e.validations[o])),n!==void 0?{...e,isFormValid:!1}:{...e,isFormValid:!0})}function yo(e=[],t,r,n){const o=new p.BehaviorSubject(Et(n.lang)),i=o.asObservable().pipe(p.distinctUntilChanged()),s=go({validators:t,validateOn:r,localization:n});function u(m){const f=o.getValue(),T=s(f,m);o.next(T)}let c=u;const l={getState:()=>o.getValue(),dispatch:m=>c(m)};return c=e.map(m=>m(l)).reduceRight((m,f)=>f(m),u),{state$:i,dispatch:c,getState:()=>o.getValue()}}class Ao{constructor(){this.widgetRegistry=new We,this.store={},this.events$=new p.Subject,this.submit$=new p.Subject,this.uuid=crypto.randomUUID(),this.itemRenderers={},this.dependencies={}}initialize(t,r=[],n,o,i,s=Ct(),u){this.localization=s,this.dependencies=u,this.widgetRegistry.setWidgetLoaders(t),this.itemRenderers=i,this.store=yo(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,r),u&&this.events$.next({name:u,data:Oe(this.store.getState()),detail:n??void 0,callback:c=>{this.store.dispatch(c)}})});else{const s=r.on?.[t];this.attemptValidation(t,r),s&&this.events$.next({name:s,data:Oe(this.store.getState()),detail:n,callback:u=>{this.store.dispatch(u)}})}}emitSubmitEvent(){this.store.dispatch({type:"VALIDATE_ALL"}),this.store.getState().isFormValid&&this.submit$.next({data:Oe(this.store.getState()),callback:t=>{this.store.dispatch(t)}})}attemptValidation(t,r){r.kind!=="layout"&&(t==="change"?this.store.dispatch({type:"ATTEMPT_VALIDATION",payload:{reason:"change",path:r.path,uid:r.uid}}):t==="click"&&r.kind==="action"&&r.actionType==="submit"&&this.store.dispatch({type:"VALIDATE_ALL"}))}}function $o(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()),o=>i=>{o(i),n&&n.send(i,t.getState())}}}const So=p.pipe(p.map(e=>e.data),p.distinctUntilChanged()),vo=e=>p.pipe(So,p.map(t=>ie(t,e)),p.distinctUntilChanged()),Eo=p.pipe(p.filter(e=>e.touched===!0),p.map(e=>e.validations),p.distinctUntilChanged()),Co=e=>p.pipe(Eo,p.map(t=>t[e]),p.distinctUntilChanged()),wo=p.pipe(p.filter(e=>e.touched===!0),p.map(e=>e.injectedValidations),p.distinctUntilChanged()),Oo=e=>p.pipe(wo,p.map(t=>t[e]),p.distinctUntilChanged(),p.startWith(null)),Io=p.pipe(p.map(e=>e.lang),p.distinctUntilChanged()),er=p.pipe(p.map(e=>e.calculatedWidgets),p.distinctUntilChanged()),Do=e=>t=>p.combineLatest([t.pipe(Io),t.pipe(er)]).pipe(p.map(([r,n])=>({lang:r,widget:n[e]})),p.filter(r=>r.widget!==void 0),p.distinctUntilChanged((r,n)=>r.lang===n.lang&&r.widget===n.widget),p.map(r=>r.widget.current)),To=e=>p.pipe(er,p.map(t=>t[e]),p.filter(t=>t!==void 0),p.map(t=>t.current.children),p.distinctUntilChanged());p.pipe(p.map(e=>e.widgetFlags),p.distinctUntilChanged());const ko=p.pipe(p.map(e=>e.touchedControls),p.distinctUntilChanged()),Fo=e=>p.pipe(ko,p.map(t=>t[e]),p.distinctUntilChanged()),jo=p.pipe(p.map(e=>e.formHealth),p.distinctUntilChanged((e,t)=>e.status!==t.status?!1:e.status==="errored"&&t.status==="errored"?e.message===t.message&&e.code===t.code:!0)),Wo=e=>e.pipe(jo);let tr=!1;function Po(){tr=!0}function No(){return tr}function Uo(e,t,r){if(!No())return;const n=Object.keys(t??{}).filter(o=>o in r);if(n.length>0)throw new Error(`[GolemUI] Widget "${e}": prop keys [${n.join(", ")}] collide with widget fields`)}exports.FormContext=Ao;exports.assertNoPropCollisions=Uo;exports.calculatedLayoutChildrenByUid$=To;exports.calculatedWidgetsByUid$=Do;exports.cloneObject=fe;exports.dataByPath$=vo;exports.defineForm=Ar;exports.devToolsMiddleware=$o;exports.enableDevMode=Po;exports.errorCodes=b;exports.filterTap=Cn;exports.formHealth=Wo;exports.getDirectionFromLanguage=Sr;exports.identityTranslator=Ct;exports.injectedValidationByPath$=Oo;exports.isStandardValidateSuccess=gt;exports.makeRepeaterItemConfig=zt;exports.shortUUID=Le;exports.standardValidate=mt;exports.touchedControlsByPath$=Fo;exports.validationByPath$=Co;
|
|
4
|
+
`,""+o}${s}${d}`)},It=(e,t=h)=>(Array.isArray(e)&&(e.loc=t),e),x=(e,t=h,r)=>{for(;r=e(y.charCodeAt(h));)h+=r;return y.slice(t,h)},w=(e=1)=>y[h+=e],je=e=>h=e,v=(e=0,t)=>{let r,n,o,i,s;for(t&&A.asi&&(A.newline=!1);(r=A.space())&&(s=A.newline,1)&&r!==t&&(o=(n&&r===91&&Fe&&A.asi?.(n,e,v)||null)??((i=F[r])&&i(n,e))??(n&&s&&A.asi?.(n,e,v))??(!n&&x(A.id)));)n=o;return t&&(r==t?(h++,t===125&&A.asi&&(A.newline=!0)):z("Unclosed "+String.fromCharCode(t-(t>42?2:1)))),n},L=(e,t=h)=>{for(Fe=!1;(e=y.charCodeAt(h))<=be;)A.asi&&e===10&&(A.newline=Fe=!0),h++;return e},Dr=(e=h)=>{for(;y.charCodeAt(e)<=be;)e++;return y.charCodeAt(e)};A.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 Wr=(e,t=e.length)=>y.substr(h,t)===e&&!A.id(y.charCodeAt(h+t)),F=[],dt={},k=(e,t=be,r,n=e.charCodeAt(0),o=e.length,i=F[n],s=e.toUpperCase()!==e,d,c)=>(t=dt[e]=!i&&dt[e]||t,F[n]=(l,f,g,m=h)=>(d=g,(g?e==g:(o<2||e.charCodeAt(1)===y.charCodeAt(h+1)&&(o<3||y.substr(h,o)==e))&&(!s||!A.id(y.charCodeAt(h+o)))&&(d=g=e))&&f<t&&(h+=o,(c=r(l))?It(c,m):(h=m,d=0,!s&&!i&&!l&&z()),c)||i?.(l,f,d))),S=(e,t,r=!1)=>k(e,t,n=>n&&(o=>o&&[e,n,o])(v(t-(r?.5:0)))),R=(e,t,r)=>k(e,t,n=>!n&&(n=v(t-.5))&&[e,n]),oe=(e,t)=>k(e,200,r=>!r&&[,t]),wt=(e,t,r)=>k(e,t,(n,o)=>(o=v(t-(r?.5:0)),n?.[0]!==e&&(n=[e,n||null]),o?.[0]===e?n.push(...o.slice(1)):n.push(o||null),n)),Ke=(e,t)=>k(e[0],t,r=>!r&&[e,v(0,e.charCodeAt(1))||null]),Ot=(e,t)=>k(e[0],t,r=>r&&[e,r,v(0,e.charCodeAt(1))||null]),ie=(e,t,r,n=e.charCodeAt(0),o=e.length,i=F[n],s)=>F[n]=(d,c,l,f=h)=>!d&&(l?e==l:(o<2||y.substr(h,o)==e)&&(l=e))&&c<t&&!A.id(y.charCodeAt(h+o))&&(!A.prop||A.prop(h+o))&&(je(h+o),(s=r())?It(s,f):je(f),s)||i?.(d,c,l);Object.defineProperty(A,"space",{configurable:!0,enumerable:!0,get:()=>L,set:e=>L=e});const Pe={},a=(e,t,r=Pe[e])=>Pe[e]=(...n)=>t(...n)||r?.(...n),u=e=>Array.isArray(e)?e[0]==null?(t=>()=>t)(e[1]):Pe[e[0]]?.(...e.slice(1))??z(`Unknown operator: ${e[0]}`,e?.loc):e===void 0?()=>{}:t=>t?.[e],ae=46,ee=48,fe=57,Tr=69,kr=101,Fr=43,jr=45,de=95,Dt=110,Pr=97,Nr=102,Ur=65,_r=70,Wt=e=>e.indexOf("_")<0?e:e.replaceAll("_",""),Xe=e=>{let t=Wt(x(r=>r===ae&&y.charCodeAt(h+1)!==ae||r>=ee&&r<=fe||r===de||((r===Tr||r===kr)&&((r=y.charCodeAt(h+1))>=ee&&r<=fe||r===Fr||r===jr)?2:0)));return y.charCodeAt(h)===Dt?(w(),[,BigInt(t)]):(e=+t)!=e?z():[,e]},Lr={2:e=>e===48||e===49||e===de,8:e=>e>=48&&e<=55||e===de,16:e=>e>=ee&&e<=fe||e>=Pr&&e<=Nr||e>=Ur&&e<=_r||e===de};A.number=null;F[ae]=e=>!e&&y.charCodeAt(h+1)!==ae&&Xe();for(let e=ee;e<=fe;e++)F[e]=t=>t?void 0:Xe();F[ee]=e=>{if(e)return;const t=A.number;if(t){for(const[r,n]of Object.entries(t))if(r[0]==="0"&&y[h+1]?.toLowerCase()===r[1]){w(2);const o=Wt(x(Lr[n]));return y.charCodeAt(h)===Dt?(w(),[,BigInt("0"+r[1]+o)]):[,parseInt(o,n)]}}return Xe()};const Rr=92,ut=34,ct=39,Vr={n:`
|
|
5
|
+
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},Tt=e=>(t,r,n="")=>{if(!(t||!A.string?.[String.fromCharCode(e)]))return w(),x(o=>o-e&&(o===Rr?(n+=Vr[y[h+1]]||y[h+1],2):(n+=y[h],1))),y[h]===String.fromCharCode(e)?w():z("Bad string"),[,n]};F[ut]=Tt(ut);F[ct]=Tt(ct);A.string={'"':!0};const Mr=20;"= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map(e=>S(e,Mr,!0));const kt=(e,t,r,n)=>typeof e=="string"?o=>t(o,e,o):e[0]==="."?(r=u(e[1]),n=e[2],o=>t(r(o),n,o)):e[0]==="[]"&&e.length===3?(r=u(e[1]),n=u(e[2]),o=>t(r(o),n(o),o)):e[0]==="()"&&e.length===2?kt(e[1],t):(()=>{throw Error("Invalid assignment target")})(),lt={"=":(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 lt)a(e,(t,r)=>(r=u(r),kt(t,(n,o,i)=>lt[e](n,o,r(i)))));const Br=30,Hr=40,zr=140;R("!",zr);S("||",Br);S("&&",Hr);a("!",e=>(e=u(e),t=>!e(t)));a("||",(e,t)=>(e=u(e),t=u(t),r=>e(r)||t(r)));a("&&",(e,t)=>(e=u(e),t=u(t),r=>e(r)&&t(r)));const Gr=50,br=60,Kr=70,Ft=100,Xr=140;S("|",Gr);S("&",Kr);S("^",br);S(">>",Ft);S("<<",Ft);R("~",Xr);a("~",e=>(e=u(e),t=>~e(t)));a("|",(e,t)=>(e=u(e),t=u(t),r=>e(r)|t(r)));a("&",(e,t)=>(e=u(e),t=u(t),r=>e(r)&t(r)));a("^",(e,t)=>(e=u(e),t=u(t),r=>e(r)^t(r)));a(">>",(e,t)=>(e=u(e),t=u(t),r=>e(r)>>t(r)));a("<<",(e,t)=>(e=u(e),t=u(t),r=>e(r)<<t(r)));const ve=90;S("<",ve);S(">",ve);S("<=",ve);S(">=",ve);a(">",(e,t)=>(e=u(e),t=u(t),r=>e(r)>t(r)));a("<",(e,t)=>(e=u(e),t=u(t),r=>e(r)<t(r)));a(">=",(e,t)=>(e=u(e),t=u(t),r=>e(r)>=t(r)));a("<=",(e,t)=>(e=u(e),t=u(t),r=>e(r)<=t(r)));const jt=80;S("==",jt);S("!=",jt);a("==",(e,t)=>(e=u(e),t=u(t),r=>e(r)==t(r)));a("!=",(e,t)=>(e=u(e),t=u(t),r=>e(r)!=t(r)));const Pt=110,Je=120,Nt=140;S("+",Pt);S("-",Pt);S("*",Je);S("/",Je);S("%",Je);R("+",Nt);R("-",Nt);a("+",(e,t)=>t!==void 0?(e=u(e),t=u(t),r=>e(r)+t(r)):(e=u(e),r=>+e(r)));a("-",(e,t)=>t!==void 0?(e=u(e),t=u(t),r=>e(r)-t(r)):(e=u(e),r=>-e(r)));a("*",(e,t)=>(e=u(e),t=u(t),r=>e(r)*t(r)));a("/",(e,t)=>(e=u(e),t=u(t),r=>e(r)/t(r)));a("%",(e,t)=>(e=u(e),t=u(t),r=>e(r)%t(r)));const pe=150;k("++",pe,e=>e?["++",e,null]:["++",v(pe-1)]);k("--",pe,e=>e?["--",e,null]:["--",v(pe-1)]);const xe=(e,t,r,n)=>typeof e=="string"?o=>t(o,e):e[0]==="."?(r=u(e[1]),n=e[2],o=>t(r(o),n)):e[0]==="[]"&&e.length===3?(r=u(e[1]),n=u(e[2]),o=>t(r(o),n(o))):e[0]==="()"&&e.length===2?xe(e[1],t):(()=>{throw Error("Invalid increment target")})();a("++",(e,t)=>xe(e,t===null?(r,n)=>r[n]++:(r,n)=>++r[n]));a("--",(e,t)=>xe(e,t===null?(r,n)=>r[n]--:(r,n)=>--r[n]));const Jr=5,xr=10;wt(",",xr);wt(";",Jr,!0);const Ut=(...e)=>(e=e.map(u),t=>{let r;for(const n of e)r=n(t);return r});a(",",Ut);a(";",Ut);const Qr=170;Ke("()",Qr);const _=e=>e?.[0]==="_"&&e[1]==="_"||e==="constructor"||e==="prototype",Qe=170;Ot("[]",Qe);S(".",Qe);Ot("()",Qe);const he=e=>{throw Error(e)};a("[]",(e,t)=>t===void 0?(e=e?e[0]===","?e.slice(1):[e]:[],e=e.map(r=>r==null?(()=>{}):r[0]==="..."?(r=u(r[1]),n=>r(n)):(r=u(r),n=>[r(n)])),r=>e.flatMap(n=>n(r))):(t==null&&he("Missing index"),e=u(e),t=u(t),r=>{const n=t(r);return _(n)?void 0:e(r)[n]}));a(".",(e,t)=>(e=u(e),t=t[0]?t:t[1],_(t)?()=>{}:r=>e(r)[t]));a("()",(e,t)=>{if(t===void 0)return e==null?he("Empty ()"):u(e);const r=o=>o?.[0]===","&&o.slice(1).some(i=>i==null||r(i));r(t)&&he("Empty argument");const n=t?t[0]===","?(t=t.slice(1).map(u),o=>t.map(i=>i(o))):(t=u(t),o=>[t(o)]):()=>[];return qe(e,(o,i,s)=>o[i](...n(s)))});const G=e=>typeof e=="string"||Array.isArray(e)&&(e[0]==="."||e[0]==="?."||e[0]==="[]"&&e.length===3||e[0]==="?.[]"||e[0]==="()"&&e.length===2&&G(e[1])||e[0]==="{}"),qe=(e,t,r,n)=>e==null?he("Empty ()"):e[0]==="()"&&e.length==2?qe(e[1],t):typeof e=="string"?o=>t(o,e,o):e[0]==="."?(r=u(e[1]),n=e[2],o=>t(r(o),n,o)):e[0]==="?."?(r=u(e[1]),n=e[2],o=>{const i=r(o);return i==null?void 0:t(i,n,o)}):e[0]==="[]"&&e.length===3?(r=u(e[1]),n=u(e[2]),o=>t(r(o),n(o),o)):e[0]==="?.[]"?(r=u(e[1]),n=u(e[2]),o=>{const i=r(o);return i==null?void 0:t(i,n(o),o)}):(e=u(e),o=>t([e(o)],0,o)),Q=qe,qr=32,Zr=A.space;A.comment??={"//":`
|
|
6
|
+
`,"/*":"*/"};let we;A.space=()=>{we||(we=Object.entries(A.comment).map(([o,i])=>[o,i,o.charCodeAt(0)]));for(var e;e=Zr();){for(var t=0,r;r=we[t++];)if(e===r[2]&&y.substr(h,r[0].length)===r[0]){var n=h+r[0].length;if(r[1]===`
|
|
7
|
+
`)for(;y.charCodeAt(n)>=qr;)n++;else{for(;y[n]&&y.substr(n,r[1].length)!==r[1];)n++;y[n]&&(n+=r[1].length)}je(n),e=0;break}if(e)return e}return e};const _t=80;S("===",_t);S("!==",_t);a("===",(e,t)=>(e=u(e),t=u(t),r=>e(r)===t(r)));a("!==",(e,t)=>(e=u(e),t=u(t),r=>e(r)!==t(r)));const Yr=30;S("??",Yr);a("??",(e,t)=>(e=u(e),t=u(t),r=>e(r)??t(r)));const en=130,tn=20;S("**",en,!0);S("**=",tn,!0);a("**",(e,t)=>(e=u(e),t=u(t),r=>e(r)**t(r)));const rn=e=>{throw Error(e)};a("**=",(e,t)=>(G(e)||rn("Invalid assignment target"),t=u(t),Q(e,(r,n,o)=>r[n]**=t(o))));const Lt=90;S("in",Lt);S("of",Lt);a("in",(e,t)=>(e=u(e),t=u(t),r=>e(r)in t(r)));const nn=20,on=100,sn=e=>{throw Error(e)};S(">>>",on);S(">>>=",nn,!0);a(">>>",(e,t)=>(e=u(e),t=u(t),r=>e(r)>>>t(r)));a(">>>=",(e,t)=>(G(e)||sn("Invalid assignment target"),t=u(t),Q(e,(r,n,o)=>r[n]>>>=t(o))));const Ze=5,dn=10,un=20,cn=e=>e[0]?.[0]===","?e[0].slice(1):e,me=(e,t,r)=>{if(typeof e=="string"){r[e]=t;return}const[n,...o]=e,i=cn(o);if(n==="{}"){const s=[];for(const d of i){if(Array.isArray(d)&&d[0]==="..."){const m={};for(const O in t)s.includes(O)||(m[O]=t[O]);r[d[1]]=m;break}let c,l,f;typeof d=="string"?c=l=d:d[0]==="="?(typeof d[1]=="string"?c=l=d[1]:[,c,l]=d[1],f=d[2]):[,c,l]=d,s.push(c);let g=t[c];g===void 0&&f&&(g=u(f)(r)),me(l,g,r)}}else if(n==="[]"){let s=0;for(const d of i){if(d===null){s++;continue}if(Array.isArray(d)&&d[0]==="..."){r[d[1]]=t.slice(s);break}let c=d,l;Array.isArray(d)&&d[0]==="="&&([,c,l]=d);let f=t[s++];f===void 0&&l&&(f=u(l)(r)),me(c,f,r)}}},Rt=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]};ie("let",Ze+1,()=>Rt("let"));ie("const",Ze+1,()=>Rt("const"));ie("var",Ze,()=>(L(),["var",v(un)]));const Vt=(...e)=>(e=e.map(t=>{if(typeof t=="string")return r=>{r[t]=void 0};if(t[0]==="="){const[,r,n]=t,o=u(n);return typeof r=="string"?i=>{i[r]=o(i)}:i=>me(r,o(i),i)}return u(t)}),t=>{for(const r of e)r(t)});a("let",Vt);a("const",Vt);a("var",e=>typeof e=="string"?t=>{t[e]=void 0}:()=>{});const Ye=20,Ee=e=>{throw Error(e)};S("||=",Ye,!0);S("&&=",Ye,!0);S("??=",Ye,!0);a("=",(e,t)=>{if(Array.isArray(e)&&(e[0]==="let"||e[0]==="const"||e[0]==="var")){const r=e[1];return t=u(t),typeof r=="string"?n=>{n[r]=t(n)}:n=>me(r,t(n),n)}return G(e)||Ee("Invalid assignment target"),t=u(t),Q(e,(r,n,o)=>r[n]=t(o))});a("||=",(e,t)=>(G(e)||Ee("Invalid assignment target"),t=u(t),Q(e,(r,n,o)=>r[n]||=t(o))));a("&&=",(e,t)=>(G(e)||Ee("Invalid assignment target"),t=u(t),Q(e,(r,n,o)=>r[n]&&=t(o))));a("??=",(e,t)=>(G(e)||Ee("Invalid assignment target"),t=u(t),Q(e,(r,n,o)=>r[n]??=t(o))));oe("true",!0);oe("false",!1);oe("null",null);ie("undefined",200,()=>[]);oe("NaN",NaN);oe("Infinity",1/0);const Oe=20;k("?",Oe,(e,t,r)=>e&&(t=v(Oe-1))&&x(n=>n===58)&&(r=v(Oe-1),["?",e,t,r]));a("?",(e,t,r)=>(e=u(e),t=u(t),r=u(r),n=>e(n)?t(n):r(n)));const ln=[],an=20;S("=>",an,!0);a("=>",(e,t)=>{e=e?.[0]==="()"?e[1]:e;const r=e?e[0]===","?e.slice(1):[e]:[];let n=-1,o=null;const i=r[r.length-1];Array.isArray(i)&&i[0]==="..."&&(n=r.length-1,o=i[1],r.length--);const s=t?.[0]==="{}";return t=u(s?["{",t[1]]:t),d=>(...c)=>{const l={};r.forEach((g,m)=>l[g]=c[m]),o&&(l[o]=c.slice(n));const f=new Proxy(l,{get:(g,m)=>m in g?g[m]:d?.[m],set:(g,m,O)=>((m in g?g:d)[m]=O,!0),has:(g,m)=>m in g||(d?m in d:!1)});try{const g=t(f);return s?void 0:g}catch(g){if(g===ln)return g[0];throw g}}});const fn=140;R("...",fn);a("...",e=>(e=u(e),t=>Object.entries(e(t))));const at=170;k("?.",at,(e,t)=>{if(!e)return;const r=L();return r===40?(w(),["?.()",e,v(0,41)||null]):r===91?(w(),["?.[]",e,v(0,93)]):(t=v(at),t?["?.",e,t]:void 0)});a("?.",(e,t)=>(e=u(e),_(t)?()=>{}:r=>e(r)?.[t]));a("?.[]",(e,t)=>(e=u(e),t=u(t),r=>{const n=t(r);return _(n)?void 0:e(r)?.[n]}));a("?.()",(e,t)=>{const r=t?t[0]===","?(t=t.slice(1).map(u),o=>t.map(i=>i(o))):(t=u(t),o=>[t(o)]):()=>[];if(e[0]==="?."){const o=u(e[1]),i=e[2];return _(i)?()=>{}:s=>o(s)?.[i]?.(...r(s))}if(e[0]==="?.[]"){const o=u(e[1]),i=u(e[2]);return s=>{const d=o(s),c=i(s);return _(c)?void 0:d?.[c]?.(...r(s))}}if(e[0]==="."){const o=u(e[1]),i=e[2];return _(i)?()=>{}:s=>o(s)?.[i]?.(...r(s))}if(e[0]==="[]"&&e.length===3){const o=u(e[1]),i=u(e[2]);return s=>{const d=o(s),c=i(s);return _(c)?void 0:d?.[c]?.(...r(s))}}const n=u(e);return o=>n(o)?.(...r(o))});const te=140;R("typeof",te);R("void",te);R("delete",te);ie("new",te,()=>Wr(".target")?(w(7),["new.target"]):["new",v(te)]);a("typeof",e=>(e=u(e),t=>typeof e(t)));a("void",e=>(e=u(e),t=>(e(t),void 0)));a("delete",e=>{if(e[0]==="."){const t=u(e[1]),r=e[2];return n=>delete t(n)[r]}if(e[0]==="[]"){const t=u(e[1]),r=u(e[2]);return n=>delete t(n)[r(n)]}return()=>!0});a("new",e=>{const t=u(e?.[0]==="()"?e[1]:e),r=e?.[0]==="()"?e[2]:null,n=r?r[0]===","?(o=>i=>o.map(s=>s(i)))(r.slice(1).map(u)):(o=>i=>[o(i)])(u(r)):()=>[];return o=>new(t(o))(...n(o))});const et=Symbol("accessor"),tt=20,pn=40,Mt=41,Bt=123,Ht=125,zt=e=>t=>{if(t)return;L();const r=x(A.id);if(!r||(L(),y.charCodeAt(h)!==pn))return!1;w();const n=v(0,Mt);return L(),y.charCodeAt(h)!==Bt?!1:(w(),[e,r,n,v(0,Ht)])};k("get",tt-1,zt("get"));k("set",tt-1,zt("set"));k("(",tt-1,e=>{if(!e||typeof e!="string")return;const t=v(0,Mt)||null;if(L(),y.charCodeAt(h)===Bt)return w(),[":",e,["=>",["()",t],v(0,Ht)||null]]});a("get",(e,t)=>(t=t?u(t):()=>{},r=>[[et,e,{get:function(){const n=Object.create(r||{});return n.this=this,t(n)}}]]));a("set",(e,t,r)=>(r=r?u(r):()=>{},n=>[[et,e,{set:function(o){const i=Object.create(n||{});i.this=this,i[t]=o,r(i)}}]]));const hn=20,Gt=200;A.prop=e=>Dr(e)!==58;const mn=e=>e==null||typeof e=="string"||[":",",","...","get","set"].includes(e[0]);Ke("[]",Gt);Ke("{}",Gt);S(":",hn-1,!0);a("{}",(e,t)=>{if(t!==void 0)return;if(!mn(e))return u(["{",e]);e=e?e[0]!==","?[e]:e.slice(1):[];const r=e.map(n=>u(typeof n=="string"?[":",n,n]:n));return n=>{const o={},i={};for(const s of r.flatMap(d=>d(n)))if(s[0]===et){const[,d,c]=s;i[d]={...i[d],...c,configurable:!0,enumerable:!0}}else o[s[0]]=s[1];for(const s in i)Object.defineProperty(o,s,i[s]);return o}});a("{",e=>(e=e?u(e):()=>{},t=>e(Object.create(t))));a(":",(e,t)=>(t=u(t),Array.isArray(e)?(e=u(e),r=>[[e(r),t(r)]]):r=>[[e,t(r)]]));const gn=170,ge=96,yn=36,$n=123,An=92,Sn={n:`
|
|
8
|
+
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},ft=()=>{const e=[];for(let t="",r;(r=y.charCodeAt(h))!==ge;)r?r===An?(w(),t+=Sn[y[h]]||y[h],w()):r===yn&&y.charCodeAt(h+1)===$n?(t&&e.push([,t]),t="",w(2),e.push(v(0,125))):(t+=y[h],w(),r=y.charCodeAt(h),r===ge&&t&&e.push([,t])):z("Unterminated template");return w(),e},vn=F[ge];F[ge]=(e,t)=>e&&t<gn?A.asi&&A.newline?void 0:(w(),["``",e,...ft()]):e?vn?.(e,t):(w(),(r=>r.length<2&&r[0]?.[0]===void 0?r[0]||[,""]:["`",...r])(ft()));a("`",(...e)=>(e=e.map(u),t=>e.map(r=>r(t)).join("")));a("``",(e,...t)=>{e=u(e);const r=[],n=[];for(const i of t)Array.isArray(i)&&i[0]===void 0?r.push(i[1]):n.push(u(i));const o=Object.assign([...r],{raw:r});return i=>e(i)(o,...n.map(s=>s(i)))});A.string["'"]=!0;A.number={"0x":16,"0b":2,"0o":8};const En={log:(e,t)=>(t?console.log(t,e):console.log(e),e)};function Z(e,t,r,n,o,i){const s=A(rt(e));return u(s)({$form:t,$meta:r,$errors:n,$formIsInvalid:o,$log:En.log,$fn:{},...i})===!0}function rt(e){return e.replace(/(\?\.|\.)(\d+)/g,(t,r,n,o)=>r==="."&&Cn(e,o)?t:r==="?."?`?.[${n}]`:`[${n}]`)}function Cn(e,t){let r=t-1,n=!1;for(;r>=0&&e[r]>="0"&&e[r]<="9";)n=!0,r--;if(r<0)return!0;const o=e[r];return n?!/[\w$.\]]/.test(o):!/[\w$)\]]/.test(o)}const In=e=>t=>{let r=t.formDef.states;if(!r||Object.keys(r).length===0||t.formHealth.status==="errored")return t;const{$formIsInvalid:n,$errors:o}=Ge(t);r=wn(r);let i=[],s={status:"ok"};try{i=Object.keys(r).map(d=>{const c=r[d];let l;try{l=Z(c,t.data,t.meta,o,n,{$fn:e})}catch{l=!1}return l===!0?d:void 0}).filter(d=>d!==void 0)}catch(d){const c=d,l=B.calculateCurrentStateError;s={status:"errored",message:`[${l}] ${c.message}`,code:l}}return{...t,currentStates:i,formHealth:s}};function wn(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 d of i)e[d]&&s.push(`(${e[d]})`);t[n]=s.join(" && ")}return t}const q=(e,t)=>r=>e(r)?t(r):r,Y=e=>e!==void 0&&typeof e=="object"&&e!==null&&"when"in e,On=e=>t=>{const{$formIsInvalid:r,$errors:n}=Ge(t);return{...t,widgetFlags:Dn(t,n,r,e)}};function Dn(e,t,r,n){const o=Object.values(e.flatForm).map(s=>{if(J(s)){const d=s({$form:e.data,errors:void 0,touched:void 0,translate:void 0});return d.uid=s.uid,d}return s}),i=Object.values(e.materializedRepeaterWidgets);return[...o,...i].filter(s=>!!(s.include&&("in"in s.include||"when"in s.include)||s.exclude&&("from"in s.exclude||"when"in s.exclude)||(W(s)||ue(s))&&Y(s.disabled)||W(s)&&Y(s.readonly))).reduce((s,d)=>{s[d.uid]=s[d.uid]||{};const c=e.repeaterItemScopes[d.uid],l=c?{$item:P(e.data,c.itemPath),$index:c.index,$fn:n}:{$fn:n};return d.include&&"in"in d.include?s[d.uid].hidden=!d.include.in.some(f=>e.currentStates.includes(f)):d.include&&"when"in d.include&&(s[d.uid].hidden=!Z(d.include.when,e.data,e.meta,t,r,l)),d.exclude&&"from"in d.exclude?s[d.uid].hidden=d.exclude.from.some(f=>e.currentStates.includes(f)):d.exclude&&"when"in d.exclude&&(s[d.uid].hidden=Z(d.exclude.when,e.data,e.meta,t,r,l)),(W(d)||ue(d))&&Y(d.disabled)&&(s[d.uid].disabled=Z(d.disabled.when,e.data,e.meta,t,r,l)),W(d)&&Y(d.readonly)&&(s[d.uid].readonly=Z(d.readonly.when,e.data,e.meta,t,r,l)),s},{})}const Wn=(e,t)=>r=>{try{return{...r,calculatedWidgets:Tn(r,e,t)}}catch(n){const o=n;return{...r,formHealth:{status:"errored",message:`[${o.code}] ${o.message}`,code:o.code}}}};function Tn(e,t,r){const{$formIsInvalid:n,$errors:o}=Ge(e),i=Jn(e,t,n,o,r),s={};for(const d of Object.keys(e.calculatedWidgets)){if(e.widgetFlags[d]?.hidden)continue;const c=e.calculatedWidgets[d],l=c.source,f=e.repeaterItemScopes[d];if(!f&&Jt(d).length>0){s[d]=c;continue}if(J(l)){s[d]=kn(d,l,e,t,f);continue}const g=f?{...i,$item:P(i.$form,f.itemPath),$index:f.index}:i;s[d]=Fn(c,l,e,g)}return s}function kn(e,t,r,n,o){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,$item:o?P(r.data,o.itemPath):void 0,$index:o?.index});return i.uid=e,{source:t,current:i}}function Fn(e,t,r,n){const o=new Xn(t,e.current);return o.write("uid",t.uid),o.write("type",t.type),o.write("kind",t.kind),cr(t)?jn(o,n):ue(t)?Pn(o,n):W(t)?Nn(o,n):ce(t)&&Un(o,n),_n(t,o,n,r),(ue(t)||W(t))&&Ln(t,o,n),ce(t)&&Rn(t,o,r),o.changed?{source:e.source,current:o.current}:e}function jn(e,t){E(e,t,"size"),E(e,t,"include"),E(e,t,"exclude")}function Pn(e,t){E(e,t,"size"),E(e,t,"include"),E(e,t,"exclude"),E(e,t,"label"),E(e,t,"disabled"),E(e,t,"actionType")}function Nn(e,t){E(e,t,"size"),E(e,t,"include"),E(e,t,"exclude"),E(e,t,"label"),E(e,t,"disabled"),E(e,t,"readonly"),E(e,t,"validator"),E(e,t,"path"),E(e,t,"defaultValue")}function Un(e,t){E(e,t,"size"),E(e,t,"include"),E(e,t,"exclude")}function _n(e,t,r,n){const o=n.widgetPropOverrides[e.uid]??{},i={...e.props??{},...o};for(const s of Xt(Object.keys(i)))Vn(t,r,s)}function Ln(e,t,r){const n=e.on??{};for(const o of Xt(Object.keys(n)))Mn(t,r,o)}function Rn(e,t,r){const n=Jt(e.uid),o=Qn(e.children,n,r.widgetFlags);t.current.children=o;const i=t.previous.children??[];i.length===o.length&&o.every((d,c)=>i[c]&&i[c].uid===o[c].uid)||t.markChanged()}function E(e,t,r){const n=e.source;if(!xn(n,r))return;const o=ot(n,r,t.sortedStates);let i;switch(r){case"disabled":case"readonly":i=zn(o,t,e.source.uid,r);break;case"defaultValue":i=o;break;default:i=Kt(o,t)}e.write(r,i)}function Vn(e,t,r){const n=e.source.props,o=ot(n,r,t.sortedStates);let i=Kt(o,t);const s=t.widgetPropOverrides[e.source.uid]?.[r];s!==void 0&&(i=s),e.write(`props.${r}`,i)}function Mn(e,t,r){const n=e.source.on,o=ot(n,r,t.sortedStates);e.write(`on.${r}`,Gn(o,t))}function nt(e,t){return e({$form:t.$form,translate:t.localization.translate,$item:t.$item,$index:t.$index})}function Bn(e,t){return t.localization.translate(e.key,Kn(e.params,t),e.default)}const Hn=/\{\{([^}]+)\}\}/g;function bt(e,t){return e.includes("{{")?e.replace(Hn,(r,n)=>{const o=rt(n.trim());try{const i=u(A(o))({$form:t.$form,$meta:t.$meta,$errors:t.$errors,$formIsInvalid:t.$formIsInvalid,$item:t.$item,$index:t.$index,$fn:t.$fn});return i==null?"":String(i)}catch(i){const s=i instanceof Error?i.message:String(i);throw new xt(`Failed to evaluate '{{${n.trim()}}}': ${s}`)}}):e}function Kt(e,t){return typeof e=="function"?nt(e,t):Sr(e)?Bn(e,t):typeof e=="string"?bt(e,t):e}function zn(e,t,r,n){return typeof e=="function"?nt(e,t):Y(e)?t.widgetFlags[r]?.[n]:typeof e=="string"?bt(e,t):e}function Gn(e,t){return typeof e=="function"?nt(e,t):e}function ot(e,t,r){if(e){for(const n of r){const o=e[`${t}.${n}`];if(o!==void 0)return o}return e[t]}}function bn(e){return e.startsWith("$form")||e.startsWith("$meta")||e.startsWith("$errors")||e.startsWith("$item")||e.startsWith("$index")||e.startsWith("$fn")||e==="$formIsInvalid"}function Kn(e,t){return e&&Object.keys(e).reduce((r,n)=>{const o=String(e[n]);if(bn(o))try{const i=u(A(rt(o)))({$form:t.$form,$meta:t.$meta,$errors:t.$errors,$formIsInvalid:t.$formIsInvalid,$item:t.$item,$index:t.$index,$fn:t.$fn});r[n]=i??o}catch(i){const s=i instanceof Error?i.message:String(i);throw new xt(`Failed to evaluate i18n param '${o}': ${s}`)}else r[n]=o;return r},{})}class Xn{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){He(this.current,t,r),P(this.previous,t)!==r&&(this._changed=!0)}}function Jn(e,t,r,n,o){return{sortedStates:[...e.currentStates].sort((i,s)=>s.length-i.length),widgetPropOverrides:e.widgetPropOverrides,widgetFlags:e.widgetFlags,$form:e.data,$meta:e.meta,$formIsInvalid:r,$errors:n,localization:t,$fn:o}}function xn(e,t){if(t in e)return!0;const r=`${t}.`;return Object.keys(e).some(n=>n.startsWith(r))}function Xt(e){return Array.from(new Set(e.map(t=>t.split(".")[0])))}function Qn(e,t,r){const n=t.map(o=>`[${o}]`).join("");return e.filter(o=>{const i=o.uid+n,s=r[i];return!s||s.hidden!==!0})}const Jt=e=>[...e.matchAll(/\[(\d+)\]/g)].map(t=>parseInt(t[1],10));class xt extends Error{constructor(){super(...arguments),this.code=B.resolveStringInterpolationError,this.name="StringInterpolationError"}}const qn=({lang:e},t)=>{const r={...Et(e),formName:t.payload.formName};let n=t.payload.formDef,o={status:"ok"};if(typeof n=="string"){try{n=JSON.parse(n)}catch(l){const f=l,g=B.initializeParseError;o={status:"errored",message:`[${g}] ${f.message}`,code:g}}if(o.status==="errored")return{...r,formHealth:o}}if(Array.isArray(n.form)){const l=n,f=l.form;l.form={uid:"",type:"flex",kind:"layout",children:f}}const i=vt.decode(n);if(i.isOk()){o={status:"ok"};let l={};try{l=ze([i.value.form]).reduce((f,g)=>{const m=g.uid;if(f[m])throw{existingWidget:f[m],newWidget:g};return f[m]=g,f},{})}catch(f){o=eo(f.existingWidget,f.newWidget),l={}}return to(l,i.value.states),{...r,formDef:i.value,flatForm:l,formHealth:o}}const s=Yn(n);if(s)return{...r,formHealth:s};const d=B.initializeUnknownError,c=i.issues.map(l=>`${l.path.length>0?$t(l.path):"root"}: ${l.message}`).join("; ");return{...r,formHealth:{status:"errored",message:`[${d}] ${c}`,code:d}}};function Qt(e,t){return{status:"errored",code:e,message:`[${e}] ${t}`}}function Zn(){return"Malformed form definition. Pass it directly as formDef - `config={{ formDef: { states, form: [...] } }}`. Do NOT wrap it in an extra `{ form: ... }`."}function Yn(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e.form;return t&&typeof t=="object"&&!Array.isArray(t)&&!ce(t)?Qt(B.initializeMalformedFormShapeError,Zn()):null}function eo(e,t){const r=o=>W(o)?` at "${o.path}"`:"",n=`Duplicate UID "${t.uid}": Assigned to widget "${e.type}"${r(e)} and "${t.type}"${r(t)}.`;return Qt(B.initializeUidCollisionError,n)}function to(e,t){const r=new Set(Object.keys(t??{})),n=new Map;for(const i of Object.values(e)){const s=[],d=i.include;d&&Array.isArray(d.in)&&s.push(...d.in);const c=i.exclude;c&&Array.isArray(c.from)&&s.push(...c.from);for(const l of s){if(r.has(l))continue;const f=n.get(l)??[];f.push(i.uid||"(unknown)"),n.set(l,f)}}if(n.size===0)return;const o=r.size?[...r].join(", "):"(none declared)";for(const[i,s]of n)console.error(`[GolemUI] include/exclude references undefined state "${i}" (on ${s.join(", ")}); these widgets will stay hidden. Declared states: ${o}. Fix: declare "${i}" in formConfig.states, or correct the name.`)}function ro(e,t){return{...e,injectedValidations:{...e.injectedValidations,[t.payload.path]:t.payload.issues}}}function Ne(e,t){const r=qt(e.uid,t);if(J(e)){const n=o=>e(o);return n.uid=r,n.type=e.type,e.path!==void 0&&(n.path=pt(e.path,t)),n}return W(e)?{...e,uid:r,path:pt(e.path,t)}:{...e,uid:r}}function qt(e,t){if(t.length===0)throw new Error("Repeater indexes cannot be an empty array");const r=t.reduce((n,o)=>`${n}[${o}]`,"");return`${e}${r}`}function pt(e,t){if(t.length===0)throw new Error("Repeater indexes cannot be an empty array");const r="items",n=e.split(`.${r}`),o=n.length-1;if(o!==t.length)throw new Error(`Path contains ${o} '${r}' occurrences, but ${t.length} indexes were provided.`);return n.reduce((i,s,d)=>d===0?s:`${i}.${t[d-1]}${s}`)}function no(e,t){let r=0;return e.replace(/\.items(\??)\./g,(n,o)=>{const i=t[r++];return i===void 0?n:`.${i}${o}.`})}const oo=["include","exclude","disabled","readonly"];function io(e,t){const r={...e};for(const n of oo){const o=r[n];so(o)&&(r[n]={...o,when:no(o.when,t)})}return r}function so(e){return e!==null&&typeof e=="object"&&"when"in e&&typeof e.when=="string"}const N=e=>{const t={},r={},n=Object.values(e.flatForm).filter(o=>!J(o)&&o.type==="repeater");for(const o of n)Zt(e,o,[],t,r);return{...e,repeaterItemScopes:t,materializedRepeaterWidgets:r}};function Zt(e,t,r,n,o){const i=t.props.template,s=P(e.data,t.path);Array.isArray(s)&&s.forEach((d,c)=>{const l=[...r,c],f={itemPath:`${t.path}.${c}`,index:c};ze([i]).forEach(g=>{let m;if(J(g)?(m=g({$form:e.data,$item:d,$index:c,errors:void 0,touched:void 0,translate:void 0}),m.uid=g.uid):m=g,m.type==="repeater"){const b=Ne(m,l);n[qt(m.uid,l)]=f,Zt(e,b,l,n,o);return}const O=io(Ne(m,l),l);n[O.uid]=f,o[O.uid]=O})})}const uo=(e,{payload:t})=>{let r;if("path"in t){if(r=Object.values(e.calculatedWidgets).find(({source:i})=>W(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=r.source.uid,o=e.widgetPropOverrides[n]||{};return{...e,widgetPropOverrides:{...e.widgetPropOverrides,[n]:{...o,[t.prop]:t.value}}}};function co(e,t){return j(e,lo(t),ao(t),fo(t),po(t))}const lo=e=>t=>({...t,widgetFlags:{...Se(t.widgetFlags,e.payload.uid)}}),ao=e=>t=>({...t,calculatedWidgets:{...Se(t.calculatedWidgets,e.payload.uid)}}),fo=e=>t=>({...t,widgetPropOverrides:{...Se(t.widgetPropOverrides,e.payload.uid)}}),po=e=>t=>({...t,touchedControls:j(t.touchedControls,r=>{const n=t.flatForm[e.payload.uid];return n&&W(n)?Se(r,n.path):r})}),ho=(e,t)=>({...e,data:{...t.payload.data}}),mo=(e,t)=>({...e,formHealth:t.payload.formHealth}),go=(e,t)=>({...e,lang:t.payload.lang}),yo=(e,t)=>({...e,meta:{...t.payload.meta}}),$o=(e,t)=>{const r=P(e.data,t.payload.path);return t.type==="SET_WIDGET_DATA"||t.type==="SET_WIDGET_INITIAL_DATA"&&r===void 0?{...e,data:{...He(e.data,t.payload.path,t.payload.data)}}:e},Yt=Symbol("filterMap.skip");function Ao(e,t){const r=[];for(let n=0;n<e.length;n++){const o=t(e[n],n,e);o!==Yt&&r.push(o)}return r}function So(e,t,r){for(let n=0;n<e.length;n++)t(e[n],n,e)&&r(e[n],n,e)}function vo(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 De=(e,t)=>r=>{const n=Ao(Object.values(r.calculatedWidgets),({current:i})=>W(i)?i:Yt),o=r.validations;return{...r,validations:n.reduce((i,s)=>{if(i[s.path]=null,s.validator){const d=e(s.validator,t),c=P(r.data,s.path),l=mt(d,c);i[s.path]=gt(l)?null:l.issues.map(f=>f.message)}return Array.isArray(i[s.path])&&Array.isArray(o[s.path])&&vo(i[s.path],o[s.path],(d,c)=>d===c)&&(i[s.path]=o[s.path]),i},{})}},Eo=({validators:e,validateOn:t,localization:r,functions:n})=>{const o=In(n),i=On(n),s=Wn(r,n);return(d,c)=>{switch(c.type){case"INITIALIZE":return qn(d,c);case"SET_DATA":return j(ho(d,c),o,N,i,s);case"SET_META":return j(yo(d,c),o,N,i,s);case"SET_LANGUAGE":return j(go(d,c),s);case"ADD_WIDGET":return j(Or(d,c),q(se,o),q(se,N),q(se,i),q(se,s));case"REMOVE_WIDGET":return j(co(d,c),o,N,i,s);case"SET_WIDGET_INITIAL_DATA":case"SET_WIDGET_DATA":return j($o(d,c),o,N,i,s);case"OVERRIDE_WIDGET_PROP":return j(uo(d,c),o,N,i,s,q(l=>{let f=!1,g="";"path"in c.payload?(f=!0,g=c.payload.path):W(l.calculatedWidgets[c.payload.uid].current)&&(f=!0,g=l.calculatedWidgets[c.payload.uid].current.path);const m=f&&l.touchedControls[g];return l.touched&&m},De(e,r)));case"SET_FORM_HEALTH":return mo(d,c);case"VALIDATE_ALL":return j({...d,touched:!0,touchedControls:Object.keys(d.calculatedWidgets).reduce((l,f)=>{const g=d.calculatedWidgets[f].source;return W(g)&&(l[g.path]=!0),l},{})},De(e,r),o,N,i,s,ht);case"ATTEMPT_VALIDATION":{const l=c.payload.reason,f=c.payload.path;return t==="eager"||l===t||t.includes(l)?j({...d,touched:!0,touchedControls:{...d.touchedControls,[f]:!0}},De(e,r),o,N,i,s,m=>{const O=c.payload.uid,b=m.calculatedWidgets[O],it=b.source;if(J(it)){const Ce=m.repeaterItemScopes[O],rr=it({$form:m.data,errors:m.validations[f],touched:!0,translate:r.translate,$item:Ce?P(m.data,Ce.itemPath):void 0,$index:Ce?.index});return{...m,calculatedWidgets:{...m.calculatedWidgets,[O]:{source:b.source,current:rr}}}}return m},ht):d}case"INJECT_VALIDATION_ISSUES":return ro(d,c);default:return Er(c)}}},se=e=>e.formHealth.status==="ok";function ht(e){const t=Object.keys(e.injectedValidations),r=Object.keys(e.validations);if(t.length===0&&r.length===0)return{...e,isFormValid:!0};let n=t.find(o=>e.injectedValidations[o]!==null&&Array.isArray(e.injectedValidations[o]));return n!==void 0?{...e,isFormValid:!1}:(n=r.find(o=>e.validations[o]!==null&&Array.isArray(e.validations[o])),n!==void 0?{...e,isFormValid:!1}:{...e,isFormValid:!0})}function Co(e=[],t,r,n,o={}){const i=new p.BehaviorSubject(Et(n.lang)),s=i.asObservable().pipe(p.distinctUntilChanged()),d=Eo({validators:t,validateOn:r,localization:n,functions:o});function c(m){const O=i.getValue(),b=d(O,m);i.next(b)}let l=c;const f={getState:()=>i.getValue(),dispatch:m=>l(m)};return l=e.map(m=>m(f)).reduceRight((m,O)=>O(m),c),{state$:s,dispatch:l,getState:()=>i.getValue()}}class Io{constructor(){this.widgetRegistry=new ke,this.store={},this.events$=new p.Subject,this.submit$=new p.Subject,this.uuid=crypto.randomUUID(),this.itemRenderers={},this.dependencies={}}initialize(t,r=[],n,o,i,s=Ct(),d,c={}){this.localization=s,this.dependencies=d,this.widgetRegistry.setWidgetLoaders(t),this.itemRenderers=i,this.store=Co(r,n,o,s,c)}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 d=r.on?.[`${t}.${s}`];this.attemptValidation(t,r),d&&this.events$.next({name:d,data:Ie(this.store.getState()),detail:n??void 0,callback:c=>{this.store.dispatch(c)}})});else{const s=r.on?.[t];this.attemptValidation(t,r),s&&this.events$.next({name:s,data:Ie(this.store.getState()),detail:n,callback:d=>{this.store.dispatch(d)}})}}emitSubmitEvent(){this.store.dispatch({type:"VALIDATE_ALL"}),this.store.getState().isFormValid&&this.submit$.next({data:Ie(this.store.getState()),callback:t=>{this.store.dispatch(t)}})}attemptValidation(t,r){r.kind!=="layout"&&(t==="change"?this.store.dispatch({type:"ATTEMPT_VALIDATION",payload:{reason:"change",path:r.path,uid:r.uid}}):t==="click"&&r.kind==="action"&&r.actionType==="submit"&&this.store.dispatch({type:"VALIDATE_ALL"}))}}function wo(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()),o=>i=>{o(i),n&&n.send(i,t.getState())}}}const Oo=p.pipe(p.map(e=>e.data),p.distinctUntilChanged()),Do=e=>p.pipe(Oo,p.map(t=>P(t,e)),p.distinctUntilChanged()),Wo=p.pipe(p.filter(e=>e.touched===!0),p.map(e=>e.validations),p.distinctUntilChanged()),To=e=>p.pipe(Wo,p.map(t=>t[e]),p.distinctUntilChanged()),ko=p.pipe(p.filter(e=>e.touched===!0),p.map(e=>e.injectedValidations),p.distinctUntilChanged()),Fo=e=>p.pipe(ko,p.map(t=>t[e]),p.distinctUntilChanged(),p.startWith(null)),jo=p.pipe(p.map(e=>e.lang),p.distinctUntilChanged()),er=p.pipe(p.map(e=>e.calculatedWidgets),p.distinctUntilChanged()),Po=e=>t=>p.combineLatest([t.pipe(jo),t.pipe(er)]).pipe(p.map(([r,n])=>({lang:r,widget:n[e]})),p.filter(r=>r.widget!==void 0),p.distinctUntilChanged((r,n)=>r.lang===n.lang&&r.widget===n.widget),p.map(r=>r.widget.current)),No=e=>p.pipe(er,p.map(t=>t[e]),p.filter(t=>t!==void 0),p.map(t=>t.current.children),p.distinctUntilChanged());p.pipe(p.map(e=>e.widgetFlags),p.distinctUntilChanged());const Uo=p.pipe(p.map(e=>e.touchedControls),p.distinctUntilChanged()),_o=e=>p.pipe(Uo,p.map(t=>t[e]),p.distinctUntilChanged()),Lo=p.pipe(p.map(e=>e.formHealth),p.distinctUntilChanged((e,t)=>e.status!==t.status?!1:e.status==="errored"&&t.status==="errored"?e.message===t.message&&e.code===t.code:!0)),Ro=e=>e.pipe(Lo);let tr=!1;function Vo(){tr=!0}function Mo(){return tr}function Bo(e,t,r){if(!Mo())return;const n=Object.keys(t??{}).filter(o=>o in r);if(n.length>0)throw new Error(`[GolemUI] Widget "${e}": prop keys [${n.join(", ")}] collide with widget fields`)}exports.FormContext=Io;exports.assertNoPropCollisions=Bo;exports.calculatedLayoutChildrenByUid$=No;exports.calculatedWidgetsByUid$=Po;exports.cloneObject=le;exports.dataByPath$=Do;exports.defineForm=Ar;exports.devToolsMiddleware=wo;exports.enableDevMode=Vo;exports.errorCodes=B;exports.filterTap=So;exports.formHealth=Ro;exports.getDirectionFromLanguage=vr;exports.identityTranslator=Ct;exports.injectedValidationByPath$=Fo;exports.isStandardValidateSuccess=gt;exports.makeRepeaterItemConfig=Ne;exports.shortUUID=Le;exports.standardValidate=mt;exports.touchedControlsByPath$=_o;exports.validationByPath$=To;
|
|
@@ -4,7 +4,7 @@ import { ValidatorFn } from '../form-validator';
|
|
|
4
4
|
import { ActionWidget, InputWidget, LayoutWidget, On } from '../form-widget';
|
|
5
5
|
import { I18nTranslator } from '../i18n';
|
|
6
6
|
import { ItemRenderer } from '../item-renderer';
|
|
7
|
-
import { FormEvent, FormSubmitEvent, ValidateOn } from '../shared';
|
|
7
|
+
import { ExpressionFunctions, FormEvent, FormSubmitEvent, 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';
|
|
@@ -21,7 +21,7 @@ export declare class FormContext<ComponentType> {
|
|
|
21
21
|
* e.g. a markdown parser for the Markdown component
|
|
22
22
|
*/
|
|
23
23
|
dependencies: Record<string, unknown>;
|
|
24
|
-
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
|
|
24
|
+
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>, functions?: ExpressionFunctions): void;
|
|
25
25
|
emitEvent(eventType: keyof On<string>, widget: InputWidget<any, string> | ActionWidget<string> | LayoutWidget<string>, detail?: any): void;
|
|
26
26
|
emitSubmitEvent(): void;
|
|
27
27
|
private attemptValidation;
|
package/lib/form-store.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
2
|
import { ValidatorFn } from './form-validator';
|
|
3
3
|
import { I18nTranslator } from './i18n';
|
|
4
|
-
import { ValidateOn } from './shared';
|
|
4
|
+
import { ExpressionFunctions, ValidateOn } from './shared';
|
|
5
5
|
import { Action } from './store/actions';
|
|
6
6
|
import { Middleware, State } from './store/model';
|
|
7
|
-
export declare function createFormStore(middlewares: Middleware<State, Action>[] | undefined, validators: ValidatorFn<any>, validateOn: ValidateOn, localization: I18nTranslator): FormStore;
|
|
7
|
+
export declare function createFormStore(middlewares: Middleware<State, Action>[] | undefined, validators: ValidatorFn<any>, validateOn: ValidateOn, localization: I18nTranslator, functions?: ExpressionFunctions): FormStore;
|
|
8
8
|
export type FormStore = {
|
|
9
9
|
state$: Observable<State>;
|
|
10
10
|
dispatch: (action: Action) => void;
|
package/lib/form.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { WidgetLoaders } from './context/widget-registry';
|
|
|
2
2
|
import { FormWidget, LayoutWidget } from './form-widget';
|
|
3
3
|
import { I18nTranslator } from './i18n';
|
|
4
4
|
import { ItemRenderer } from './item-renderer';
|
|
5
|
-
import { ReactiveExpression, UiState, ValidateOn } from './shared';
|
|
5
|
+
import { ExpressionFunctions, ReactiveExpression, UiState, ValidateOn } from './shared';
|
|
6
6
|
import { Action } from './store/actions';
|
|
7
7
|
import { Middleware, State } from './store/model';
|
|
8
8
|
export type Form<StateKeys extends UiState = never, FormType extends Record<string, any> = any> = {
|
|
@@ -25,6 +25,14 @@ export interface FormInitConfig<ComponentType = unknown> {
|
|
|
25
25
|
itemRenderers?: Record<string, ItemRenderer>;
|
|
26
26
|
localization?: I18nTranslator;
|
|
27
27
|
dependencies?: Record<string, unknown>;
|
|
28
|
+
/**
|
|
29
|
+
* Pure functions callable from reactive expressions under the `$fn` namespace,
|
|
30
|
+
* e.g. `"text": "Total: {{ $fn.grandTotal($form.lineItems) }}"`.
|
|
31
|
+
*
|
|
32
|
+
* Available in every expression context: `{{...}}` string interpolation, i18n params,
|
|
33
|
+
* `when` expressions (include/exclude/disabled/readonly) and state expressions.
|
|
34
|
+
*/
|
|
35
|
+
functions?: ExpressionFunctions;
|
|
28
36
|
middlewares?: Middleware<State, Action>[];
|
|
29
37
|
validateOn?: ValidateOn;
|
|
30
38
|
data?: Record<string, any>;
|
package/lib/shared.d.ts
CHANGED
|
@@ -11,6 +11,22 @@ export type UiState = string;
|
|
|
11
11
|
* A ReactiveExpression is an expression that is evaluated and then substituted by the produced value.
|
|
12
12
|
*/
|
|
13
13
|
export type ReactiveExpression = string;
|
|
14
|
+
/**
|
|
15
|
+
* A pure function exposed to expressions via `$fn`.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* const functions = {
|
|
19
|
+
* grandTotal: (items: Array<{ price?: number }> = []) =>
|
|
20
|
+
* items.reduce((total, item) => total + (item.price ?? 0), 0),
|
|
21
|
+
* };
|
|
22
|
+
* // Form usage: "Grand Total: {{ $fn.grandTotal($form.lineItems) }}"
|
|
23
|
+
*/
|
|
24
|
+
export type ExpressionFunction = (...args: any[]) => unknown;
|
|
25
|
+
/**
|
|
26
|
+
* Map of {@link ExpressionFunction} entries. The key is the name used after `$fn.`
|
|
27
|
+
* in reactive expressions: `functions: { grandTotal }` is called as `$fn.grandTotal(...)`.
|
|
28
|
+
*/
|
|
29
|
+
export type ExpressionFunctions = Record<string, ExpressionFunction>;
|
|
14
30
|
/**
|
|
15
31
|
* The path to a json object
|
|
16
32
|
*/
|
|
@@ -44,6 +60,14 @@ export type $Errors = {
|
|
|
44
60
|
export type WidgetPropertyFunctionParams<FormType extends Record<string, any>> = {
|
|
45
61
|
$form: ImmutableRecord<FormType>;
|
|
46
62
|
translate?: I18nTranslator['translate'];
|
|
63
|
+
/**
|
|
64
|
+
* The current repeater item. Bound only when the widget is inside a repeater `props.template`, for nested repeaters it is the innermost enclosing item.
|
|
65
|
+
*/
|
|
66
|
+
$item?: any;
|
|
67
|
+
/**
|
|
68
|
+
* Zero-based position of the current repeater item. Bound only when the widget is inside a repeater `props.template`.
|
|
69
|
+
*/
|
|
70
|
+
$index?: number;
|
|
47
71
|
};
|
|
48
72
|
/**
|
|
49
73
|
* A WidgetPropertyFunction is a widget function that is evaluated and then substituted by the produced value.
|
|
@@ -54,6 +78,14 @@ export type FunctionWidgetParams<FormType> = {
|
|
|
54
78
|
errors: ValidationStatus | undefined;
|
|
55
79
|
touched: boolean | undefined;
|
|
56
80
|
translate: I18nTranslator['translate'] | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* The current repeater item. Bound only when the widget is inside a repeater `props.template`, for nested repeaters it is the innermost enclosing item.
|
|
83
|
+
*/
|
|
84
|
+
$item?: any;
|
|
85
|
+
/**
|
|
86
|
+
* Zero-based position of the current repeater item. Bound only when the widget is inside a repeater `props.template`.
|
|
87
|
+
*/
|
|
88
|
+
$index?: number;
|
|
57
89
|
};
|
|
58
90
|
/**
|
|
59
91
|
* Defines when widget validation should run.
|
package/lib/store/model.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Form } from '../form';
|
|
2
|
-
import { FormWidget, FunctionWidget } from '../form-widget';
|
|
2
|
+
import { FormWidget, FunctionWidget, NonFunctionWidget } from '../form-widget';
|
|
3
3
|
import { DotPath, Uid, ValidationStatus } from '../shared';
|
|
4
4
|
export type State = {
|
|
5
5
|
formName: string;
|
|
@@ -53,6 +53,27 @@ export type State = {
|
|
|
53
53
|
readonly?: boolean;
|
|
54
54
|
disabled?: boolean;
|
|
55
55
|
}>;
|
|
56
|
+
/**
|
|
57
|
+
* Maps every widget rendered inside a repeater item (by its materialized uid) to the repeater item that owns it.
|
|
58
|
+
* Used to bind the `$item` and `$index` expression scope variables.
|
|
59
|
+
* For nested repeaters the entry points to the innermost enclosing item.
|
|
60
|
+
* Built by `materializeRepeaterItems` on every reducer pipeline run.
|
|
61
|
+
*
|
|
62
|
+
* @example { 'quantity-number[0]': { itemPath: 'lineItems.0', index: 0 } }
|
|
63
|
+
* @example Nested repeater, keyed by the innermost item: { 'dev-name[2][0]': { itemPath: 'teams.2.devs.0', index: 0 } }
|
|
64
|
+
*/
|
|
65
|
+
repeaterItemScopes: Record<Uid, RepeaterItemScope>;
|
|
66
|
+
/**
|
|
67
|
+
* State-managed copies of the repeater template widgets, one per repeater item, keyed by materialized uid.
|
|
68
|
+
* Each entry mirrors the widget the renderer mounts for that item:
|
|
69
|
+
* - the uid and data path carry the concrete indexes,
|
|
70
|
+
* - `when` expressions are rewritten for the item's row,
|
|
71
|
+
* - and function widgets are already resolved to plain configs.
|
|
72
|
+
* Built by `materializeRepeaterItems` on every reducer pipeline run and consumed by `calculateWidgetFlags`.
|
|
73
|
+
*
|
|
74
|
+
* @example { 'quantity-number[0]': { uid: 'quantity-number[0]', path: 'lineItems.0.quantity', ... } }
|
|
75
|
+
*/
|
|
76
|
+
materializedRepeaterWidgets: Record<Uid, NonFunctionWidget<string>>;
|
|
56
77
|
/**
|
|
57
78
|
* Allows overriding a widget’s `prop` properties externally via its event handler mechanism.
|
|
58
79
|
* For example, this can be used to load options for a select widget asynchronously.
|
|
@@ -90,6 +111,15 @@ export type MiddlewareAPI<S, A> = {
|
|
|
90
111
|
dispatch: (action: A) => void;
|
|
91
112
|
};
|
|
92
113
|
export type Middleware<S, A> = (api: MiddlewareAPI<S, A>) => (next: (action: A) => void) => (action: A) => void;
|
|
114
|
+
/**
|
|
115
|
+
* Identifies the repeater item that owns a widget rendered inside a repeater `props.template`.
|
|
116
|
+
*/
|
|
117
|
+
export type RepeaterItemScope = {
|
|
118
|
+
/** Data path of the owning item, e.g. `lineItems.0` */
|
|
119
|
+
itemPath: DotPath;
|
|
120
|
+
/** Zero-based position of the owning item in the repeater array */
|
|
121
|
+
index: number;
|
|
122
|
+
};
|
|
93
123
|
/**
|
|
94
124
|
* Represents the current operational state of the form.
|
|
95
125
|
* When in an errored state, the form is considered non-operational
|
package/lib/store/reducer.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { ValidatorFn } from '../form-validator';
|
|
2
2
|
import { I18nTranslator } from '../i18n';
|
|
3
|
-
import { ValidateOn } from '../shared';
|
|
3
|
+
import { ExpressionFunctions, ValidateOn } from '../shared';
|
|
4
4
|
import { Action } from './actions';
|
|
5
5
|
import { State } from './model';
|
|
6
|
-
export declare const reducer: ({ validators, validateOn, localization, }: {
|
|
6
|
+
export declare const reducer: ({ validators, validateOn, localization, functions, }: {
|
|
7
7
|
validators: ValidatorFn<any>;
|
|
8
8
|
validateOn: ValidateOn;
|
|
9
9
|
localization: I18nTranslator;
|
|
10
|
+
functions: ExpressionFunctions;
|
|
10
11
|
}) => (state: State, action: Action) => State;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { I18nTranslator } from '../../i18n';
|
|
2
|
+
import { ExpressionFunctions } from '../../shared';
|
|
2
3
|
import { State } from '../model';
|
|
3
|
-
export declare const calculateWidgetProps: (localization: I18nTranslator) => (state: State) => State;
|
|
4
|
+
export declare const calculateWidgetProps: (localization: I18nTranslator, functions: ExpressionFunctions) => (state: State) => State;
|
|
@@ -4,6 +4,7 @@ export { calculateWidgetFlags } from './calculate-widget-flags';
|
|
|
4
4
|
export { calculateWidgetProps } from './calculate-widget-props';
|
|
5
5
|
export { initialize } from './initialize';
|
|
6
6
|
export { injectValidationIssues } from './inject-validation-issues';
|
|
7
|
+
export { materializeRepeaterItems } from './materialize-repeater-items';
|
|
7
8
|
export { overrideWidgetProp } from './override-widget-prop';
|
|
8
9
|
export { removeWidget } from './remove-widget';
|
|
9
10
|
export { setData } from './set-data';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { State } from '../model';
|
|
2
|
+
/**
|
|
3
|
+
* Walks every repeater's live array data and derives, per item, the same concrete widgets the renderer mounts for that item.
|
|
4
|
+
* Produces two maps keyed by materialized uid, both rebuilt from scratch on every run:
|
|
5
|
+
* - `repeaterItemScopes`: which item owns each widget (binds `$item` / `$index`).
|
|
6
|
+
* - `materializedRepeaterWidgets`: the item-concrete widget configs, with uid and path baked, `when` expressions rewritten for the item's row, and function widgets resolved.
|
|
7
|
+
*
|
|
8
|
+
* `calculateWidgetFlags` and `calculateWidgetProps` consume these maps, so this stage must run before them in the pipeline.
|
|
9
|
+
*/
|
|
10
|
+
export declare const materializeRepeaterItems: (state: State) => State;
|
package/lib/utils/justin.d.ts
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
|
-
import { $Errors, ReactiveExpression } from '../shared';
|
|
1
|
+
import { $Errors, ExpressionFunctions, ReactiveExpression } from '../shared';
|
|
2
2
|
import { State } from '../store/model';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Extra scope variables available to expressions evaluated inside a repeater `props.template`: the current item object and its position
|
|
5
|
+
*/
|
|
6
|
+
export type RepeaterItemExpressionScope = {
|
|
7
|
+
$item?: unknown;
|
|
8
|
+
$index?: number;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Extra scope available to expressions: repeater item variables and host-provided $fn functions.
|
|
12
|
+
*/
|
|
13
|
+
export type ExpressionExtraScope = RepeaterItemExpressionScope & {
|
|
14
|
+
$fn?: ExpressionFunctions;
|
|
15
|
+
};
|
|
16
|
+
export declare function expressionIsTrue(expression: ReactiveExpression, $form: State['data'], $meta: State['meta'], $errors: $Errors, $formIsInvalid: boolean, extraScope?: ExpressionExtraScope): boolean;
|
|
4
17
|
export declare function normalizeArrayIndexes(expression: string): string;
|
package/lib/utils/repeater.d.ts
CHANGED
|
@@ -1,19 +1,26 @@
|
|
|
1
|
-
import { NonFunctionWidget } from '../form-widget';
|
|
1
|
+
import { FormWidget, NonFunctionWidget } from '../form-widget';
|
|
2
2
|
import { Uid } from '../shared';
|
|
3
3
|
/**
|
|
4
|
-
* Derives a concrete widget config for a specific repeater item by
|
|
5
|
-
*
|
|
4
|
+
* Derives a concrete widget config for a specific repeater item by materializing the provided indexes into the
|
|
5
|
+
* widget's `uid` (and `path` for input widgets).
|
|
6
|
+
*
|
|
7
|
+
* Function widgets are wrapped in a new function that delegates to the original, so they stay callable while
|
|
8
|
+
* carrying the materialized `uid` and `path`.
|
|
6
9
|
*
|
|
7
10
|
* @param widget - The base widget config defined on the repeater template.
|
|
8
|
-
* @param repeaterIndexes - Ordered list of indexes for each nesting level
|
|
9
|
-
* e.g. `[2, 0]` for the first item of a nested repeater inside the third
|
|
10
|
-
*
|
|
11
|
-
* @returns A new widget config with the indexes baked in; the original is not mutated.
|
|
11
|
+
* @param repeaterIndexes - Ordered list of indexes for each nesting level
|
|
12
|
+
* e.g. `[2, 0]` for the first item of a nested repeater inside the third item of an outer repeater.
|
|
13
|
+
* @returns A new widget config with the indexes baked in. The original is not mutated.
|
|
12
14
|
*
|
|
13
15
|
* @example
|
|
14
16
|
* makeRepeaterItemConfig(widget, [1]) // { uid: 'user-name[1]', path: 'users.1.name' }
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Nested repeater: the first item of an inner repeater inside the third item of the outer one.
|
|
20
|
+
* makeRepeaterItemConfig(widget, [2, 0]) // { uid: 'dev-name[2][0]', path: 'teams.2.devs.0.name' }
|
|
15
21
|
*/
|
|
16
22
|
export declare function makeRepeaterItemConfig(widget: NonFunctionWidget<string>, repeaterIndexes: number[]): NonFunctionWidget<string>;
|
|
23
|
+
export declare function makeRepeaterItemConfig(widget: FormWidget<string>, repeaterIndexes: number[]): FormWidget<string>;
|
|
17
24
|
export declare function toRepeaterItemUid(uid: Uid, repeaterIndexes: number[]): Uid;
|
|
18
25
|
/**
|
|
19
26
|
* Replaces `.items.` and `.items?.` tokens in a `when` expression with the
|
|
@@ -30,3 +37,20 @@ export declare function toRepeaterItemUid(uid: Uid, repeaterIndexes: number[]):
|
|
|
30
37
|
* // "$form.reptr.teams.items?.devs?.items?.firstName?.length > 0" -> "$form.reptr.teams.1?.devs?.0?.firstName?.length > 0"
|
|
31
38
|
*/
|
|
32
39
|
export declare function transformRepeaterItemWhenExpression(expression: string, repeaterIndexes: number[]): string;
|
|
40
|
+
/**
|
|
41
|
+
* Returns a copy of a repeater item widget whose reactive flag conditions
|
|
42
|
+
* (`include.when`, `exclude.when`, `disabled.when`, `readonly.when`) are rewritten
|
|
43
|
+
* for a concrete item via {@link transformRepeaterItemWhenExpression}.
|
|
44
|
+
*
|
|
45
|
+
* State-based flags (`include.in`, `exclude.from`) carry no expression and are left untouched.
|
|
46
|
+
*
|
|
47
|
+
* @param widget - A widget already materialized for a repeater item (see {@link makeRepeaterItemConfig}).
|
|
48
|
+
* @param repeaterIndexes - Ordered list of indexes for each nesting level.
|
|
49
|
+
* @returns A new widget config with item-concrete `when` expressions. The original is not mutated.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* // repeaterIndexes = [1]
|
|
53
|
+
* // { include: { when: '$form.lineItems.items.active' } }
|
|
54
|
+
* // -> { include: { when: '$form.lineItems.1.active' } }
|
|
55
|
+
*/
|
|
56
|
+
export declare function transformWidgetWhenExpressions(widget: NonFunctionWidget<string>, repeaterIndexes: number[]): NonFunctionWidget<string>;
|