@golemui/gui-shared 0.0.2 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -10
- package/README.md +15 -6
- package/index.d.ts +4 -3
- package/index.js +2363 -104
- package/index.umd.cjs +1 -1
- package/lib/dx/__tests__/helpers.d.ts +30 -0
- package/lib/dx/core/defineShortcutType.d.ts +38 -0
- package/lib/dx/core/dx.domain.d.ts +76 -0
- package/lib/dx/core/dxBase.types.d.ts +107 -0
- package/lib/dx/core/dxPropsHelper.d.ts +9 -0
- package/lib/dx/core/dxUtilityTypes.d.ts +40 -0
- package/lib/dx/core/dxValidatorHelper.d.ts +18 -0
- package/lib/dx/core/eventWiring.service.d.ts +22 -0
- package/lib/dx/core/itemTypeRegistry.d.ts +82 -0
- package/lib/dx/core/itemWalker.service.d.ts +31 -0
- package/lib/dx/core/selectorNormalizer.service.d.ts +15 -0
- package/lib/dx/core/selectorResolver.service.d.ts +11 -0
- package/lib/dx/core/sharedSensibleDefaults.service.d.ts +35 -0
- package/lib/dx/core/stateExpansion.service.d.ts +31 -0
- package/lib/dx/core/widgetMapper.service.d.ts +13 -0
- package/lib/dx/core/widgetMerger.service.d.ts +14 -0
- package/lib/dx/dx.service.d.ts +40 -0
- package/lib/dx/formDef.domain.d.ts +52 -0
- package/lib/dx/gui.d.ts +74 -0
- package/lib/dx/index.d.ts +100 -0
- package/lib/dx/registerAll.d.ts +0 -0
- package/lib/dx/resolveFormInput.d.ts +37 -0
- package/lib/dx/shortcuts/accordion/accordion.domain.d.ts +20 -0
- package/lib/dx/shortcuts/accordion/guiAccordion.impl.d.ts +12 -0
- package/lib/dx/shortcuts/accordion/register.d.ts +2 -0
- package/lib/dx/shortcuts/actions/actions.domain.d.ts +21 -0
- package/lib/dx/shortcuts/actions/guiActions.impl.d.ts +7 -0
- package/lib/dx/shortcuts/actions/register.d.ts +2 -0
- package/lib/dx/shortcuts/alert/alert.domain.d.ts +9 -0
- package/lib/dx/shortcuts/alert/guiAlert.impl.d.ts +6 -0
- package/lib/dx/shortcuts/alert/register.d.ts +2 -0
- package/lib/dx/shortcuts/calendar/calendar.domain.d.ts +21 -0
- package/lib/dx/shortcuts/calendar/calendarSensibleDefaults.service.d.ts +6 -0
- package/lib/dx/shortcuts/calendar/guiCalendar.impl.d.ts +6 -0
- package/lib/dx/shortcuts/calendar/register.d.ts +2 -0
- package/lib/dx/shortcuts/checkbox/checkbox.domain.d.ts +16 -0
- package/lib/dx/shortcuts/checkbox/guiCheckbox.impl.d.ts +6 -0
- package/lib/dx/shortcuts/checkbox/register.d.ts +2 -0
- package/lib/dx/shortcuts/currency/currency.domain.d.ts +17 -0
- package/lib/dx/shortcuts/currency/guiCurrency.impl.d.ts +6 -0
- package/lib/dx/shortcuts/currency/register.d.ts +2 -0
- package/lib/dx/shortcuts/custom-action/customAction.domain.d.ts +14 -0
- package/lib/dx/shortcuts/custom-action/guiCustomAction.impl.d.ts +6 -0
- package/lib/dx/shortcuts/custom-action/register.d.ts +2 -0
- package/lib/dx/shortcuts/custom-display/customDisplay.domain.d.ts +9 -0
- package/lib/dx/shortcuts/custom-display/guiCustomDisplay.impl.d.ts +8 -0
- package/lib/dx/shortcuts/custom-display/register.d.ts +2 -0
- package/lib/dx/shortcuts/custom-input/customInput.domain.d.ts +16 -0
- package/lib/dx/shortcuts/custom-input/guiCustomInput.impl.d.ts +6 -0
- package/lib/dx/shortcuts/custom-input/register.d.ts +2 -0
- package/lib/dx/shortcuts/custom-layout/customLayout.domain.d.ts +13 -0
- package/lib/dx/shortcuts/custom-layout/guiCustomLayout.impl.d.ts +7 -0
- package/lib/dx/shortcuts/custom-layout/register.d.ts +2 -0
- package/lib/dx/shortcuts/date-input/dateInput.domain.d.ts +16 -0
- package/lib/dx/shortcuts/date-input/guiDateInput.impl.d.ts +6 -0
- package/lib/dx/shortcuts/date-input/register.d.ts +2 -0
- package/lib/dx/shortcuts/date-picker/datePicker.domain.d.ts +17 -0
- package/lib/dx/shortcuts/date-picker/guiDatePicker.impl.d.ts +7 -0
- package/lib/dx/shortcuts/date-picker/register.d.ts +2 -0
- package/lib/dx/shortcuts/display/display.domain.d.ts +13 -0
- package/lib/dx/shortcuts/display/guiDisplay.impl.d.ts +3 -0
- package/lib/dx/shortcuts/display/register.d.ts +2 -0
- package/lib/dx/shortcuts/dropdown/dropdown.domain.d.ts +18 -0
- package/lib/dx/shortcuts/dropdown/guiDropdown.impl.d.ts +7 -0
- package/lib/dx/shortcuts/dropdown/register.d.ts +2 -0
- package/lib/dx/shortcuts/inputs/gslInputSubtypes.d.ts +4 -0
- package/lib/dx/shortcuts/inputs/guiBooleanInput.impl.d.ts +6 -0
- package/lib/dx/shortcuts/inputs/guiInputs.impl.d.ts +2 -0
- package/lib/dx/shortcuts/inputs/guiNumberInput.impl.d.ts +6 -0
- package/lib/dx/shortcuts/inputs/guiTextInput.impl.d.ts +6 -0
- package/lib/dx/shortcuts/inputs/inputDefsByKey.service.d.ts +11 -0
- package/lib/dx/shortcuts/inputs/inputSensibleDefaults.service.d.ts +9 -0
- package/lib/dx/shortcuts/inputs/inputTypeDefaults.service.d.ts +9 -0
- package/lib/dx/shortcuts/inputs/inputs.domain.d.ts +51 -0
- package/lib/dx/shortcuts/inputs/register.d.ts +2 -0
- package/lib/dx/shortcuts/layouts/guiFlex.impl.d.ts +8 -0
- package/lib/dx/shortcuts/layouts/layouts.domain.d.ts +31 -0
- package/lib/dx/shortcuts/layouts/register.d.ts +2 -0
- package/lib/dx/shortcuts/list/guiList.impl.d.ts +7 -0
- package/lib/dx/shortcuts/list/list.domain.d.ts +17 -0
- package/lib/dx/shortcuts/list/register.d.ts +2 -0
- package/lib/dx/shortcuts/markdown/guiMarkdown.impl.d.ts +6 -0
- package/lib/dx/shortcuts/markdown/markdown.domain.d.ts +17 -0
- package/lib/dx/shortcuts/markdown/register.d.ts +2 -0
- package/lib/dx/shortcuts/password/guiPassword.impl.d.ts +6 -0
- package/lib/dx/shortcuts/password/password.domain.d.ts +17 -0
- package/lib/dx/shortcuts/password/register.d.ts +2 -0
- package/lib/dx/shortcuts/radiogroup/guiRadiogroup.impl.d.ts +7 -0
- package/lib/dx/shortcuts/radiogroup/radiogroup.domain.d.ts +17 -0
- package/lib/dx/shortcuts/radiogroup/register.d.ts +2 -0
- package/lib/dx/shortcuts/range-calendar/guiRangeCalendar.impl.d.ts +6 -0
- package/lib/dx/shortcuts/range-calendar/rangeCalendar.domain.d.ts +16 -0
- package/lib/dx/shortcuts/range-calendar/register.d.ts +2 -0
- package/lib/dx/shortcuts/range-date-input/guiRangeDateInput.impl.d.ts +6 -0
- package/lib/dx/shortcuts/range-date-input/rangeDateInput.domain.d.ts +16 -0
- package/lib/dx/shortcuts/range-date-input/register.d.ts +2 -0
- package/lib/dx/shortcuts/range-date-picker/guiRangeDatePicker.impl.d.ts +6 -0
- package/lib/dx/shortcuts/range-date-picker/rangeDatePicker.domain.d.ts +17 -0
- package/lib/dx/shortcuts/range-date-picker/register.d.ts +2 -0
- package/lib/dx/shortcuts/repeater/guiRepeater.impl.d.ts +6 -0
- package/lib/dx/shortcuts/repeater/register.d.ts +3 -0
- package/lib/dx/shortcuts/repeater/repeater.domain.d.ts +21 -0
- package/lib/dx/shortcuts/scopes/gslStates.impl.d.ts +11 -0
- package/lib/dx/shortcuts/scopes/gslTag.impl.d.ts +2 -0
- package/lib/dx/shortcuts/scopes/scopeChain.d.ts +99 -0
- package/lib/dx/shortcuts/select/guiSelect.impl.d.ts +7 -0
- package/lib/dx/shortcuts/select/register.d.ts +2 -0
- package/lib/dx/shortcuts/select/select.domain.d.ts +18 -0
- package/lib/dx/shortcuts/tabs/guiTabs.impl.d.ts +12 -0
- package/lib/dx/shortcuts/tabs/register.d.ts +2 -0
- package/lib/dx/shortcuts/tabs/tabs.domain.d.ts +17 -0
- package/lib/dx/shortcuts/textarea/guiTextarea.impl.d.ts +6 -0
- package/lib/dx/shortcuts/textarea/register.d.ts +2 -0
- package/lib/dx/shortcuts/textarea/textarea.domain.d.ts +17 -0
- package/lib/golem-form.d.ts +18 -3
- package/lib/shared.d.ts +13 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/objectUtils.service.d.ts +11 -0
- package/lib/utils/repeater.d.ts +9 -0
- package/lib/utils/schema.d.ts +14 -0
- package/lib/widget.factory.d.ts +4 -2
- package/lib/widget.props.d.ts +99 -7
- package/lib/widgets.d.ts +9 -9
- package/package.json +8 -3
- package/lib/middleware/json-schema-vanilla.d.ts +0 -2
package/index.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(i,l){typeof exports=="object"&&typeof module<"u"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(i=typeof globalThis<"u"?globalThis:i||self,l(i["gui-shared"]={}))})(this,(function(i){"use strict";class l{create(e){return{states:e.states,form:{uid:"gui-root-uid",type:"flex",kind:"layout",children:e.form}}}}function s(){return new l}const u=["calendar","checkbox","currency","dateInput","datePicker","dropdown","list","number","password","radiogroup","rangeCalendar","repeater","select","textarea","textinput","toggle"],o=["accordion","flex","tabs"],d=["alert","renderer"],c=["button"],f=[...u,...o,...d,...c],a={textinput:({config:t,props:e,validator:n})=>({uid:"",kind:"input",type:"textinput",...e&&{props:e},...n&&{validator:n},...t}),password:({config:t,props:e,validator:n})=>({uid:"",kind:"input",type:"password",...e&&{props:e},...n&&{validator:n},...t}),numberinput:({config:t,props:e,validator:n})=>({uid:"",kind:"input",type:"numberinput",...e&&{props:e},...n&&{validator:n},...t}),checkbox:({config:t,props:e,validator:n})=>({uid:"",kind:"input",type:"checkbox",...e&&{props:e},...n&&{validator:n},...t}),select:({config:t,props:e,validator:n})=>({uid:"",kind:"input",type:"select",...e&&{props:e},...n&&{validator:n},...t}),flex:(t,e)=>({uid:"",kind:"layout",type:"flex",...e&&{props:e},...t}),tabs:(t,e)=>({uid:"",kind:"layout",type:"tabs",...e&&{props:e},...t}),alert:(t,e)=>({uid:"",kind:"display",type:"alert",...e&&{props:e},...t})},r=t=>t!==null&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"label")&&Object.prototype.hasOwnProperty.call(t,"value");function m(t){return r(t)?t:{label:t,value:t}}const b=t=>({string:(e,n)=>a.textinput({config:{path:n}}),enum:(e,n)=>a.select({config:{path:n},props:{options:e.enum?.map(m)??[]},validator:t.stringValidator()}),boolean:(e,n)=>a.checkbox({config:{path:n},validator:t.booleanValidator()}),number:(e,n)=>a.numberinput({config:{path:n},validator:t.numberValidator()}),integer:(e,n)=>a.numberinput({config:{path:n},validator:t.integerValidator()}),object:(e,n)=>a.flex({children:n}),oneOf:(e,n)=>a.tabs({children:n}),anyOf:(e,n)=>a.tabs({children:n}),fallback:e=>a.alert({},{text:`❌ Unsupported Json Schema field ${JSON.stringify(e)}`,level:"error"})});i.Vanilla=a,i.actionWidgets=c,i.displayWidgets=d,i.golemForm=s,i.inputWidgets=u,i.isOption=r,i.layoutWidgets=o,i.vanillaSchemaToFieldMap=b,i.vanillaWidgets=f,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(r,b){typeof exports=="object"&&typeof module<"u"?b(exports):typeof define=="function"&&define.amd?define(["exports"],b):(r=typeof globalThis<"u"?globalThis:r||self,b(r["gui-shared"]={}))})(this,(function(r){"use strict";const b={INPUTS:"INPUTS",ACTIONS:"ACTIONS",LAYOUTS:"LAYOUTS",DISPLAYS:"DISPLAYS"};function Y(e,t,n){if(typeof t=="function"){const i=t;return{items:[{key:e,def:a=>({type:"text",...i(a)})}],type:"ITEMS",itemType:b.INPUTS,tags:n??[]}}const s={type:"text",...t};return{items:[{key:e,def:s}],type:"ITEMS",itemType:b.INPUTS,tags:n??[]}}function z(e,t,n){if(typeof t=="function"){const i=t;return{items:[{key:e,def:a=>({type:"number",...i(a)})}],type:"ITEMS",itemType:b.INPUTS,tags:n??[]}}const s={type:"number",...t};return{items:[{key:e,def:s}],type:"ITEMS",itemType:b.INPUTS,tags:n??[]}}function G(e,t,n){if(typeof t=="function"){const i=t;return{items:[{key:e,def:a=>({type:"boolean",...i(a)})}],type:"ITEMS",itemType:b.INPUTS,tags:n??[]}}const s={type:"boolean",...t};return{items:[{key:e,def:s}],type:"ITEMS",itemType:b.INPUTS,tags:n??[]}}function K(e,t,n){if(typeof t=="function"){const l=t;return{type:"ITEMS",itemType:"SELECT",items:[{key:e,def:o=>({type:"select",...l(o)})}],tags:n??[]}}const s={type:"select",...t};return{type:"ITEMS",itemType:"SELECT",items:[{key:e,def:s}],tags:n??[]}}function V(e,t,n){if(typeof t=="function"){const l=t;return{type:"ITEMS",itemType:"DROPDOWN",items:[{key:e,def:o=>({type:"dropdown",...l(o)})}],tags:n??[]}}const s={type:"dropdown",...t};return{type:"ITEMS",itemType:"DROPDOWN",items:[{key:e,def:s}],tags:n??[]}}function H(e,t,n){if(typeof t=="function"){const l=t;return{type:"ITEMS",itemType:"RADIOGROUP",items:[{key:e,def:o=>({type:"radiogroup",...l(o)})}],tags:n??[]}}const s={type:"radiogroup",...t};return{type:"ITEMS",itemType:"RADIOGROUP",items:[{key:e,def:s}],tags:n??[]}}function X(e,t,n){if(typeof t=="function"){const l=t;return{type:"ITEMS",itemType:"CHECKBOX",items:[{key:e,def:o=>({type:"checkbox",...l(o)})}],tags:n??[]}}const s={type:"checkbox",...t};return{type:"ITEMS",itemType:"CHECKBOX",items:[{key:e,def:s}],tags:n??[]}}function Z(e,t,n){if(typeof t=="function"){const l=t;return{type:"ITEMS",itemType:"TEXTAREA",items:[{key:e,def:o=>({type:"textarea",...l(o)})}],tags:n??[]}}const s={type:"textarea",...t};return{type:"ITEMS",itemType:"TEXTAREA",items:[{key:e,def:s}],tags:n??[]}}function q(e,t,n){if(typeof t=="function"){const l=t;return{type:"ITEMS",itemType:"PASSWORD",items:[{key:e,def:o=>({type:"password",...l(o)})}],tags:n??[]}}const s={type:"password",...t};return{type:"ITEMS",itemType:"PASSWORD",items:[{key:e,def:s}],tags:n??[]}}function Q(e,t,n){if(typeof t=="function"){const l=t;return{type:"ITEMS",itemType:"CURRENCY",items:[{key:e,def:o=>({type:"currency",...l(o)})}],tags:n??[]}}const s={type:"currency",...t};return{type:"ITEMS",itemType:"CURRENCY",items:[{key:e,def:s}],tags:n??[]}}function J(e,t,n){if(typeof t=="function"){const l=t;return{type:"ITEMS",itemType:"MARKDOWN",items:[{key:e,def:o=>({type:"markdown",...l(o)})}],tags:n??[]}}const s={type:"markdown",...t};return{type:"ITEMS",itemType:"MARKDOWN",items:[{key:e,def:s}],tags:n??[]}}function x(e,t,n){if(typeof t=="function"){const l=t;return{type:"ITEMS",itemType:"LIST",items:[{key:e,def:o=>({type:"list",...l(o)})}],tags:n??[]}}const s={type:"list",...t};return{type:"ITEMS",itemType:"LIST",items:[{key:e,def:s}],tags:n??[]}}function ee(e,t,n){if(typeof t=="function"){const i=t;return{items:[a=>({type:"calendar",path:e,...i(a)})],type:"ITEMS",itemType:"CALENDAR",tags:n??[]}}return{items:[{type:"calendar",path:e,...t}],type:"ITEMS",itemType:"CALENDAR",tags:n??[]}}function te(e,t,n){if(typeof t=="function"){const l=t;return{type:"ITEMS",itemType:"DATE_INPUT",items:[{key:e,def:o=>({type:"dateInput",...l(o)})}],tags:n??[]}}const s={type:"dateInput",...t};return{type:"ITEMS",itemType:"DATE_INPUT",items:[{key:e,def:s}],tags:n??[]}}function ne(e,t,n){if(typeof t=="function"){const l=t;return{type:"ITEMS",itemType:"DATE_PICKER",items:[{key:e,def:o=>({type:"datePicker",...l(o)})}],tags:n??[]}}const s={type:"datePicker",...t};return{type:"ITEMS",itemType:"DATE_PICKER",items:[{key:e,def:s}],tags:n??[]}}function se(e,t,n){if(typeof t=="function"){const l=t;return{type:"ITEMS",itemType:"RANGE_CALENDAR",items:[{key:e,def:o=>({type:"rangeCalendar",...l(o)})}],tags:n??[]}}const s={type:"rangeCalendar",...t};return{type:"ITEMS",itemType:"RANGE_CALENDAR",items:[{key:e,def:s}],tags:n??[]}}function ie(e,t,n){if(typeof t=="function"){const l=t;return{type:"ITEMS",itemType:"RANGE_DATE_INPUT",items:[{key:e,def:o=>({type:"rangeDateInput",...l(o)})}],tags:n??[]}}const s={type:"rangeDateInput",...t};return{type:"ITEMS",itemType:"RANGE_DATE_INPUT",items:[{key:e,def:s}],tags:n??[]}}function le(e,t,n){if(typeof t=="function"){const l=t;return{type:"ITEMS",itemType:"RANGE_DATE_PICKER",items:[{key:e,def:o=>({type:"rangeDatePicker",...l(o)})}],tags:n??[]}}const s={type:"rangeDatePicker",...t};return{type:"ITEMS",itemType:"RANGE_DATE_PICKER",items:[{key:e,def:s}],tags:n??[]}}function ae(e,t,n,s){if(typeof n=="function"){const a=n;return{type:"ITEMS",itemType:"CUSTOM_INPUT",items:[{key:t,def:c=>({customType:e,...a(c)})}],tags:s??[]}}const i={customType:e,...n};return{type:"ITEMS",itemType:"CUSTOM_INPUT",items:[{key:t,def:i}],tags:s??[]}}class Ft{deepMerge(t,n){if(n==null)return t;if(t==null||typeof t!="object"||typeof n!="object"||Array.isArray(t)||Array.isArray(n))return n;const s={...t};for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&(typeof n[i]=="object"&&!Array.isArray(n[i])&&n[i]!==null&&typeof t[i]=="object"&&!Array.isArray(t[i])&&t[i]!==null?s[i]=this.deepMerge(t[i],n[i]):s[i]=n[i]);return s}}const re=new Ft;function v(e,t){return{items:[e],type:"ITEMS",itemType:b.ACTIONS,tags:t??[]}}const M=e=>{const t={uid:"#submit",label:"Submit"},n=e!=null?re.deepMerge(t,e):t;return v(n)};function oe(e,t,n){if(typeof t=="function"){const l=t;return{type:"ITEMS",itemType:"CUSTOM_ACTION",items:[u=>({customType:e,...l(u)})],tags:n??[]}}return{type:"ITEMS",itemType:"CUSTOM_ACTION",items:[{customType:e,...t}],tags:n??[]}}const R=(e,t)=>({type:"ITEMS",itemType:b.DISPLAYS,items:[{render:e}],tags:t??[]});function ue(e,t){return{type:"ITEMS",itemType:"ALERTS",items:[e],tags:t??[]}}function ce(e,t,n){if(typeof t=="function"){const u=t;return{type:"ITEMS",itemType:"CUSTOM_DISPLAY",items:[c=>({customType:e,...u(c)})],tags:n??[]}}const{uid:s,...i}=t??{};return{type:"ITEMS",itemType:"CUSTOM_DISPLAY",items:[{customType:e,...s!=null?{uid:s}:{},props:Object.keys(i).length>0?i:void 0}],tags:n??[]}}const D=(e,t,n)=>({type:"ITEMS",itemType:b.LAYOUTS,items:[{def:{widgetName:"flex",...t??{}},children:e}],tags:n??[]}),de=(e,t,n)=>D(e,{direction:"row",...t??{}},n),pe=(e,t,n)=>D(e,{direction:"column",...t??{}},n),C=(e,t,n)=>({type:"ITEMS",itemType:b.LAYOUTS,items:[{def:{widgetName:"grid",direction:"row",autoFit:!0,...t??{}},children:e}],tags:n??[]}),ye=(e,t,n)=>C(e,{direction:"row",...t??{}},n),me=(e,t,n)=>C(e,{direction:"column",...t??{}},n);function ge(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,"")}function be(e,t,n){const s=e.map(a=>({label:a.label,uid:a.uid??ge(a.label)})),i=e.map(a=>({type:"ITEMS",itemType:b.LAYOUTS,items:[{def:{uid:a.uid??ge(a.label),direction:"column",widgetName:"flex"},children:a.children}],tags:[]}));return{type:"ITEMS",itemType:"TABS",items:[{def:{tabs:s,...t},children:i}],tags:n??[]}}function fe(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,"")}function he(e,t,n){const s=e.map(a=>({label:a.label,uid:a.uid??fe(a.label)})),i=e.map(a=>({type:"ITEMS",itemType:b.LAYOUTS,items:[{def:{uid:a.uid??fe(a.label),direction:"column",widgetName:"flex"},children:a.children}],tags:[]}));return{type:"ITEMS",itemType:"ACCORDION",items:[{def:{sections:s,...t},children:i}],tags:n??[]}}function Te(e,t,n,s){if(typeof n=="function"){const a=n;return{type:"ITEMS",itemType:"CUSTOM_LAYOUT",items:[{def:c=>({customType:e,...a(c)}),children:t}],tags:s??[]}}return{type:"ITEMS",itemType:"CUSTOM_LAYOUT",items:[{def:{customType:e,...n},children:t}],tags:s??[]}}function _e(e,t,n){const{template:s,...i}=t;return{type:"ITEMS",itemType:"REPEATER",items:[{key:e,def:i,children:s}],tags:n??[]}}function O(e){return function(t,n=()=>!0){return{kind:"leaf",selectorType:e,matcher:n,config:t}}}const P=new Map;function Se(e,t){if(P.has(e))throw new Error(`Item type "${e}" is already registered.`);P.set(e,t)}function U(e){const t=P.get(e);if(!t)throw new Error(`No handler registered for item type "${e}". Did you forget to import the registration module?`);return t}function Ae(e){return P.has(e)}function p(e){const t=u=>{if(!e.sensibleDefaults)return{};let o={...e.sensibleDefaults.base};for(const c of u){const d=c.config;for(const m of e.sensibleDefaults.fields){const y=m;d[y]!=null&&(o={...o,[y]:d[y]})}}return o},n=(u,o)=>e.sensibleDefaults?e.sensibleDefaults.apply(u,o):u,s=u=>{switch(e.entryShape){case"bare":return{baseDef:u};case"keyed":{const o=u;return{baseDef:o.def,path:o.key}}case"compound":{const o=u;return{baseDef:o.def,children:o.children}}}},i={rollUpSensibleDefaults:t,applySensibleDefaults:n,mapToWidget:e.mapToWidget,parseEntry:s,...e.afterMerge?{afterMerge:e.afterMerge}:{},...e.buildCustomWidget?{buildCustomWidget:e.buildCustomWidget}:{},...e.getChildren?{getChildren:e.getChildren}:{}};Se(e.itemType,i);const l=O(e.itemType);return{gsl:l,gslByUid:(u,o)=>l(o,(c=>c.uid===u))}}function g(e){const{uid:t,path:n,label:s,disabled:i,readonly:l,defaultValue:a,tags:u,type:o,size:c,onLoad:d,onChange:m,onFilter:y,on:_,states:w,include:L,exclude:Ot,validator:Wt,...I}=e;return I}function h(e,t){return typeof e=="function"?e:{type:t,...e??{}}}function jt(e){return e?e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,t=>t.toUpperCase()):""}function f(e,t){return e.label!=null||t.suppressAutomaticLabels||!e.path?e:{...e,label:jt(e.path)}}function S(e,t){return e.placeholder!=null||t.suppressAutomaticPlaceholders||!e.path?e:{...e,placeholder:e.path}}function $t(e){switch(e.type){case"text":return zt(e);case"number":return Gt(e);case"boolean":return Yt(e);default:throw new Error(`Unsupported field type "${e.type}"`)}}function Yt(e){const t=g(e);return{uid:e.uid??"",kind:"input",type:"toggle",path:e.path??"",...e.label!=null?{label:e.label}:{},...e.disabled!=null?{disabled:e.disabled}:{},...e.readonly!=null?{readonly:e.readonly}:{},...e.validator!=null?{validator:h(e.validator,"boolean")}:{},props:t}}function zt(e){const t=g(e);return{uid:e.uid??"",kind:"input",type:"textinput",path:e.path??"",...e.label!=null?{label:e.label}:{},...e.disabled!=null?{disabled:e.disabled}:{},...e.readonly!=null?{readonly:e.readonly}:{},props:{placeholder:t.placeholder??"",...t},validator:h(e.validator,"string")}}function Gt(e){const t=g(e);return{uid:e.uid??"",kind:"input",type:"number",path:e.path??"",...e.label!=null?{label:e.label}:{},...e.disabled!=null?{disabled:e.disabled}:{},...e.readonly!=null?{readonly:e.readonly}:{},props:{placeholder:t.placeholder??"",...t},validator:h(e.validator,"number")}}const{gsl:E,gslByUid:ke}=p({itemType:"INPUTS",entryShape:"keyed",sensibleDefaults:{base:{suppressAutomaticLabels:!1,suppressAutomaticPlaceholders:!1},fields:["suppressAutomaticLabels","suppressAutomaticPlaceholders"],apply:(e,t)=>{let n=f(e,t);return n=S(n,t),n}},mapToWidget:$t}),Ie=e=>E(e,t=>t.type==="text"),Ue=e=>E(e,t=>t.type==="number"),Ee=e=>E(e,t=>t.type==="boolean"),{gsl:De,gslByUid:Ce}=p({itemType:"SELECT",entryShape:"keyed",sensibleDefaults:{base:{suppressAutomaticLabels:!1,suppressAutomaticPlaceholders:!1},fields:["suppressAutomaticLabels","suppressAutomaticPlaceholders"],apply:(e,t)=>S(f(e,t),t)},mapToWidget:e=>({uid:e.uid??"",kind:"input",type:"select",path:e.path??"",...e.label!=null?{label:e.label}:{},...e.disabled!=null?{disabled:e.disabled}:{},...e.readonly!=null?{readonly:e.readonly}:{},...e.validator!=null?{validator:e.validator}:{},props:g(e)})}),{gsl:Pe,gslByUid:Be}=p({itemType:"DROPDOWN",entryShape:"keyed",sensibleDefaults:{base:{suppressAutomaticLabels:!1,suppressAutomaticPlaceholders:!1},fields:["suppressAutomaticLabels","suppressAutomaticPlaceholders"],apply:(e,t)=>S(f(e,t),t)},mapToWidget:e=>({uid:e.uid??"",kind:"input",type:"dropdown",path:e.path??"",...e.label!=null?{label:e.label}:{},...e.disabled!=null?{disabled:e.disabled}:{},...e.readonly!=null?{readonly:e.readonly}:{},...e.validator!=null?{validator:e.validator}:{},props:g(e)})}),{gsl:we,gslByUid:Le}=p({itemType:"RADIOGROUP",entryShape:"keyed",sensibleDefaults:{base:{suppressAutomaticLabels:!1},fields:["suppressAutomaticLabels"],apply:(e,t)=>f(e,t)},mapToWidget:e=>({uid:e.uid??"",kind:"input",type:"radiogroup",path:e.path??"",...e.label!=null?{label:e.label}:{},...e.disabled!=null?{disabled:e.disabled}:{},...e.readonly!=null?{readonly:e.readonly}:{},...e.validator!=null?{validator:e.validator}:{},props:g(e)})}),{gsl:ve,gslByUid:Me}=p({itemType:"CHECKBOX",entryShape:"keyed",sensibleDefaults:{base:{suppressAutomaticLabels:!1},fields:["suppressAutomaticLabels"],apply:(e,t)=>f(e,t)},mapToWidget:e=>({uid:e.uid??"",kind:"input",type:"checkbox",path:e.path??"",...e.label!=null?{label:e.label}:{},...e.disabled!=null?{disabled:e.disabled}:{},...e.readonly!=null?{readonly:e.readonly}:{},...e.validator!=null?{validator:h(e.validator,"boolean")}:{},props:g(e)})}),{gsl:Re,gslByUid:Oe}=p({itemType:"TEXTAREA",entryShape:"keyed",sensibleDefaults:{base:{suppressAutomaticLabels:!1,suppressAutomaticPlaceholders:!1},fields:["suppressAutomaticLabels","suppressAutomaticPlaceholders"],apply:(e,t)=>S(f(e,t),t)},mapToWidget:e=>({uid:e.uid??"",kind:"input",type:"textarea",path:e.path??"",...e.label!=null?{label:e.label}:{},...e.disabled!=null?{disabled:e.disabled}:{},...e.readonly!=null?{readonly:e.readonly}:{},...e.validator!=null?{validator:h(e.validator,"string")}:{},props:g(e)})}),{gsl:We,gslByUid:Ne}=p({itemType:"PASSWORD",entryShape:"keyed",sensibleDefaults:{base:{suppressAutomaticLabels:!1,suppressAutomaticPlaceholders:!1},fields:["suppressAutomaticLabels","suppressAutomaticPlaceholders"],apply:(e,t)=>S(f(e,t),t)},mapToWidget:e=>({uid:e.uid??"",kind:"input",type:"password",path:e.path??"",...e.label!=null?{label:e.label}:{},...e.disabled!=null?{disabled:e.disabled}:{},...e.readonly!=null?{readonly:e.readonly}:{},...e.validator!=null?{validator:h(e.validator,"string")}:{},props:g(e)})}),{gsl:Fe,gslByUid:je}=p({itemType:"CURRENCY",entryShape:"keyed",sensibleDefaults:{base:{suppressAutomaticLabels:!1,suppressAutomaticPlaceholders:!1},fields:["suppressAutomaticLabels","suppressAutomaticPlaceholders"],apply:(e,t)=>S(f(e,t),t)},mapToWidget:e=>({uid:e.uid??"",kind:"input",type:"currency",path:e.path??"",...e.label!=null?{label:e.label}:{},...e.disabled!=null?{disabled:e.disabled}:{},...e.readonly!=null?{readonly:e.readonly}:{},...e.validator!=null?{validator:h(e.validator,"number")}:{},props:g(e)})}),{gsl:$e,gslByUid:Ye}=p({itemType:"MARKDOWN",entryShape:"keyed",sensibleDefaults:{base:{suppressAutomaticLabels:!1,suppressAutomaticPlaceholders:!1},fields:["suppressAutomaticLabels","suppressAutomaticPlaceholders"],apply:(e,t)=>S(f(e,t),t)},mapToWidget:e=>({uid:e.uid??"",kind:"input",type:"markdown",path:e.path??"",...e.label!=null?{label:e.label}:{},...e.disabled!=null?{disabled:e.disabled}:{},...e.readonly!=null?{readonly:e.readonly}:{},...e.validator!=null?{validator:h(e.validator,"string")}:{},props:g(e)})}),{gsl:ze,gslByUid:Ge}=p({itemType:"LIST",entryShape:"keyed",sensibleDefaults:{base:{suppressAutomaticLabels:!1},fields:["suppressAutomaticLabels"],apply:(e,t)=>f(e,t)},mapToWidget:e=>({uid:e.uid??"",kind:"input",type:"list",path:e.path??"",...e.label!=null?{label:e.label}:{},...e.disabled!=null?{disabled:e.disabled}:{},...e.readonly!=null?{readonly:e.readonly}:{},...e.validator!=null?{validator:e.validator}:{},props:g(e)})}),{gsl:Ke,gslByUid:Ve}=p({itemType:"CALENDAR",entryShape:"bare",sensibleDefaults:{base:{suppressAutomaticLabels:!1},fields:["suppressAutomaticLabels"],apply:(e,t)=>f(e,t)},mapToWidget:e=>({uid:e.uid??"",kind:"input",type:"calendar",path:e.path??"",...e.label!=null?{label:e.label}:{},...e.disabled!=null?{disabled:e.disabled}:{},...e.readonly!=null?{readonly:e.readonly}:{},...e.validator!=null?{validator:h(e.validator,"string")}:{},props:g(e)})}),{gsl:He,gslByUid:Xe}=p({itemType:"DATE_INPUT",entryShape:"keyed",sensibleDefaults:{base:{suppressAutomaticLabels:!1},fields:["suppressAutomaticLabels"],apply:(e,t)=>f(e,t)},mapToWidget:e=>({uid:e.uid??"",kind:"input",type:"dateInput",path:e.path??"",...e.label!=null?{label:e.label}:{},...e.disabled!=null?{disabled:e.disabled}:{},...e.readonly!=null?{readonly:e.readonly}:{},...e.validator!=null?{validator:h(e.validator,"string")}:{},props:g(e)})}),{gsl:Ze,gslByUid:qe}=p({itemType:"DATE_PICKER",entryShape:"keyed",sensibleDefaults:{base:{suppressAutomaticLabels:!1,suppressAutomaticPlaceholders:!1},fields:["suppressAutomaticLabels","suppressAutomaticPlaceholders"],apply:(e,t)=>S(f(e,t),t)},mapToWidget:e=>({uid:e.uid??"",kind:"input",type:"datePicker",path:e.path??"",...e.label!=null?{label:e.label}:{},...e.disabled!=null?{disabled:e.disabled}:{},...e.readonly!=null?{readonly:e.readonly}:{},...e.validator!=null?{validator:h(e.validator,"string")}:{},props:g(e)})}),{gsl:Qe,gslByUid:Je}=p({itemType:"RANGE_CALENDAR",entryShape:"keyed",sensibleDefaults:{base:{suppressAutomaticLabels:!1},fields:["suppressAutomaticLabels"],apply:(e,t)=>f(e,t)},mapToWidget:e=>({uid:e.uid??"",kind:"input",type:"rangeCalendar",path:e.path??"",...e.label!=null?{label:e.label}:{},...e.disabled!=null?{disabled:e.disabled}:{},...e.readonly!=null?{readonly:e.readonly}:{},...e.validator!=null?{validator:h(e.validator,"array")}:{},props:g(e)})}),{gsl:xe,gslByUid:et}=p({itemType:"RANGE_DATE_INPUT",entryShape:"keyed",sensibleDefaults:{base:{suppressAutomaticLabels:!1},fields:["suppressAutomaticLabels"],apply:(e,t)=>f(e,t)},mapToWidget:e=>({uid:e.uid??"",kind:"input",type:"rangeDateInput",path:e.path??"",...e.label!=null?{label:e.label}:{},...e.disabled!=null?{disabled:e.disabled}:{},...e.readonly!=null?{readonly:e.readonly}:{},...e.validator!=null?{validator:h(e.validator,"array")}:{},props:g(e)})}),{gsl:tt,gslByUid:nt}=p({itemType:"RANGE_DATE_PICKER",entryShape:"keyed",sensibleDefaults:{base:{suppressAutomaticLabels:!1,suppressAutomaticPlaceholders:!1},fields:["suppressAutomaticLabels","suppressAutomaticPlaceholders"],apply:(e,t)=>S(f(e,t),t)},mapToWidget:e=>({uid:e.uid??"",kind:"input",type:"rangeDatePicker",path:e.path??"",...e.label!=null?{label:e.label}:{},...e.disabled!=null?{disabled:e.disabled}:{},...e.readonly!=null?{readonly:e.readonly}:{},...e.validator!=null?{validator:h(e.validator,"array")}:{},props:g(e)})});function Kt(e){const t={};return e.addLabel!=null&&(t.addLabel=e.addLabel),e.removeLabel!=null&&(t.removeLabel=e.removeLabel),e.limit!=null&&(t.limit=e.limit),e.title!=null&&(t.title=e.title),e.addButtonIcon!=null&&(t.addButtonIcon=e.addButtonIcon),e.removeButtonIcon!=null&&(t.removeButtonIcon=e.removeButtonIcon),t}function Vt(e){return{uid:e.uid??"",kind:"input",type:"repeater",path:e.path??"",...e.label!=null?{label:e.label}:{},...e.disabled!=null?{disabled:e.disabled}:{},...e.readonly!=null?{readonly:e.readonly}:{},...e.validator!=null?{validator:h(e.validator,"array")}:{},props:{...Kt(e),template:{kind:"layout",type:"flex",children:[],props:{direction:"column"}}}}}function W(e,t){for(const n of e){if(typeof n=="function")continue;const s=n;typeof s.path=="string"&&s.path&&(s.path=t+s.path),"children"in s&&Array.isArray(s.children)&&W(s.children,t);const i=s.props;i?.template?.children&&Array.isArray(i.template.children)&&W(i.template.children,t)}}function Ht(e,t){const n=t.walkChildren(t.children??[]),s=e.kind==="static"?e.def.path??"":e.fn({})?.path??"";s&&W(n,s+".items.");const i={kind:"layout",type:"flex",uid:"",children:n,props:{direction:"column"}};if(e.kind==="static"){const a=t.mapStaticDef(e.def,"REPEATER");return{...a,props:{...a.props,template:i}}}const l=e.fn;return(a=>{const u=l(a),o=t.mapStaticDef(u,"REPEATER");return{...o,props:{...o.props,template:i}}})}function Xt(e){return{baseDef:e.def,path:e.key,children:e.children}}function Zt(e){return e.children}Se("REPEATER",{parseEntry:Xt,rollUpSensibleDefaults:()=>({}),applySensibleDefaults:e=>e,mapToWidget:Vt,buildCustomWidget:Ht,getChildren:Zt});const N=O("REPEATER"),st=(e,t)=>N(t,(n=>n.uid===e)),it={onLoad:"load",onChange:"change",onFilter:"filter",onBlur:"blur"},qt=Object.keys(it);class Qt{extractOnClickFromMergeResult(t,n,s,i){if(t.kind==="dynamic"){const u=t.fn;return{kind:"dynamic",fn:c=>{const d=u(c);return this.wireOnClick(d,n,s,i)}}}const l=t.def;return{kind:"static",def:this.wireOnClick(l,n,s,i)}}countSubmitButtons(t){let n=0;for(const s of t){if(s.type!=="ITEMS")continue;const i=U(s.itemType);for(const l of s.items){const a=i.getChildren?.(l);if(a&&(n+=this.countSubmitButtons(a)),s.itemType===b.ACTIONS){if(typeof l=="function")continue;const u=l;(u.uid==="#submit"||u.onClick==="submit")&&n++}}}return n}wireOnClick(t,n,s,i){const l=t.uid==="#submit"||t.onClick==="submit",a=l?"#submit":i.next(),u=l?"submit":a,o=t.onClick,d=(typeof o=="function"?o:void 0)??(l?s.onSubmit:void 0);if(d){n.set(u,_=>d(_.data));const{onClick:m,...y}=t;return{...y,uid:a,on:{click:u}}}if(l){const{onClick:m,...y}=t;return{...y,uid:a,on:{click:"submit"}}}if(typeof o=="string"){const{onClick:m,...y}=t;return{...y,uid:a,on:{click:o}}}return{...t,uid:a}}wireInputLayoutEvents(t,n,s){if(t.kind==="dynamic"){const l=t.fn;return{kind:"dynamic",fn:u=>{const o=l(u);return this.wireEventProperties(o,n,s)}}}return{kind:"static",def:this.wireEventProperties(t.def,n,s)}}wireEventProperties(t,n,s){const i={...t.on||{}};let l=!1;const a={...t};for(const u of qt){const o=t[u];if(o==null)continue;const c=it[u];if(typeof o=="function"){const d=s.next();n.set(d,o),i[c]=d,l=!0}else typeof o=="string"&&(i[c]=o,l=!0);delete a[u]}return l&&(a.on=i),a}}const B=new Qt;function Jt(e){const{uid:t,label:n,disabled:s,on:i,onClick:l,data:a,type:u,tags:o,size:c,include:d,exclude:m,states:y,..._}=e;return{uid:t??"",kind:"action",type:"button",disabled:s,label:n,...i!=null?{on:i}:{},props:_}}const{gsl:lt,gslByUid:at}=p({itemType:"ACTIONS",entryShape:"bare",mapToWidget:Jt,afterMerge:(e,t)=>B.extractOnClickFromMergeResult(e,t.eventRegistry,t.formConfig,t.eventIdGenerator)});function xt(e){const{uid:t,widgetName:n,tags:s,size:i,onChange:l,include:a,exclude:u,...o}=e,{on:c,...d}=o;return{uid:t??"",kind:"layout",type:n??"flex",props:{direction:d.direction??"column",...d},children:[]}}function en(e,t){const n=t.walkChildren(t.children??[]);if(e.kind==="static")return{...t.mapStaticDef(e.def,"LAYOUTS"),children:n};const s=e.fn;return(i=>{const l=s(i);return{...t.mapStaticDef(l,"LAYOUTS"),children:n}})}function tn(e){return e.children}const{gsl:rt,gslByUid:ot}=p({itemType:"LAYOUTS",entryShape:"compound",mapToWidget:xt,buildCustomWidget:en,getChildren:tn});function nn(e){return{uid:"",kind:"display",type:"renderer",props:{render:e.render}}}function sn(e,t){if(e.kind==="static"){const s=e.def;return(i=>({uid:"",kind:"display",type:"renderer",...s.include!=null?{include:s.include}:{},...s.exclude!=null?{exclude:s.exclude}:{},props:{render:s.render(i??{})}}))}const n=e.fn;return(s=>{const i=n(s);return{uid:"",kind:"display",type:"renderer",...i.include!=null?{include:i.include}:{},...i.exclude!=null?{exclude:i.exclude}:{},props:{render:i.render(s??{})}}})}const{gsl:ut,gslByUid:ct}=p({itemType:"DISPLAYS",entryShape:"bare",mapToWidget:nn,buildCustomWidget:sn}),{gsl:dt,gslByUid:pt}=p({itemType:"ALERTS",entryShape:"bare",mapToWidget:e=>({uid:e.uid??"",kind:"display",type:"alert",props:{text:e.text,...e.level!=null?{level:e.level}:{}}})});function ln(e){return{uid:e.uid??"",kind:"layout",type:"tabs",props:{tabs:e.tabs,renderMode:e.renderMode??"all",...e.defaultOpen!=null?{defaultOpen:e.defaultOpen}:{}},children:[]}}function an(e,t){const n=t.walkChildren(t.children??[]);if(e.kind==="static")return{...t.mapStaticDef(e.def,"TABS"),children:n};const s=e.fn;return(i=>{const l=s(i);return{...t.mapStaticDef(l,"TABS"),children:n}})}function rn(e){return e.children}const{gsl:yt,gslByUid:mt}=p({itemType:"TABS",entryShape:"compound",mapToWidget:ln,buildCustomWidget:an,getChildren:rn});function on(e){return{uid:e.uid??"",kind:"layout",type:"accordion",props:{sections:e.sections,renderMode:e.renderMode??"all",...e.singleOpen!=null?{singleOpen:e.singleOpen}:{},...e.defaultOpen!=null?{defaultOpen:e.defaultOpen}:{}},children:[]}}function un(e,t){const n=t.walkChildren(t.children??[]);if(e.kind==="static")return{...t.mapStaticDef(e.def,"ACCORDION"),children:n};const s=e.fn;return(i=>{const l=s(i);return{...t.mapStaticDef(l,"ACCORDION"),children:n}})}function cn(e){return e.children}const{gsl:gt,gslByUid:bt}=p({itemType:"ACCORDION",entryShape:"compound",mapToWidget:on,buildCustomWidget:un,getChildren:cn}),{gsl:ft,gslByUid:ht}=p({itemType:"CUSTOM_INPUT",entryShape:"keyed",sensibleDefaults:{base:{suppressAutomaticLabels:!1},fields:["suppressAutomaticLabels"],apply:(e,t)=>f(e,t)},mapToWidget:e=>({uid:e.uid??"",kind:"input",type:e.customType,path:e.path??"",...e.label!=null?{label:e.label}:{},...e.disabled!=null?{disabled:e.disabled}:{},...e.readonly!=null?{readonly:e.readonly}:{},...e.defaultValue!=null?{defaultValue:e.defaultValue}:{},...e.validator!=null?{validator:e.validator}:{},props:e.props??{}})}),{gsl:Tt,gslByUid:_t}=p({itemType:"CUSTOM_ACTION",entryShape:"bare",mapToWidget:e=>{const{uid:t,label:n,disabled:s,on:i,onClick:l,data:a,customType:u,tags:o,size:c,include:d,exclude:m,states:y,props:_,...w}=e;return{uid:t??"",kind:"action",type:e.customType,label:n,disabled:s,...i!=null?{on:i}:{},props:{..._,...w}}},afterMerge:(e,t)=>B.extractOnClickFromMergeResult(e,t.eventRegistry,t.formConfig,t.eventIdGenerator)}),{gsl:St,gslByUid:At}=p({itemType:"CUSTOM_DISPLAY",entryShape:"bare",mapToWidget:e=>({uid:e.uid??"",kind:"display",type:e.customType,props:e.props??{}})});function dn(e){return{uid:e.uid??"",kind:"layout",type:e.customType,props:e.props??{},children:[]}}function pn(e,t){const n=t.walkChildren(t.children??[]);if(e.kind==="static")return{...t.mapStaticDef(e.def,"CUSTOM_LAYOUT"),children:n};const s=e.fn;return(i=>{const l=s(i);return{...t.mapStaticDef(l,"CUSTOM_LAYOUT"),children:n}})}function yn(e){return e.children}const{gsl:kt,gslByUid:It}=p({itemType:"CUSTOM_LAYOUT",entryShape:"compound",mapToWidget:dn,buildCustomWidget:pn,getChildren:yn});class k{constructor(t){this.conditions=t}static root(){return new k([])}tag(t){return new k([...this.conditions,{kind:"tagsAnd",tags:[t]}])}state(t){return new k([...this.conditions,{kind:"state",name:t}])}tagsAnd(t){return new k([...this.conditions,{kind:"tagsAnd",tags:t}])}tagsOr(t){return new k([...this.conditions,{kind:"tagsOr",tags:t}])}apply(t){if(this.conditions.length===0)return t;const n=this.conditions.find(l=>l.kind==="state"),s=this.conditions.filter(l=>l.kind!=="state"),i=t.matcher;return{...t,matcher:l=>{if(!i(l))return!1;for(const a of s){const u=l.tags??[];if(a.kind==="tagsAnd"){for(const o of a.tags)if(!u.includes(o))return!1}else{if(a.tags.length===0)continue;if(!a.tags.some(o=>u.includes(o)))return!1}}return!0},...n?{targetState:n.name}:{}}}inputs(t){return this.apply(E(t))}inputByUid(t,n){return this.apply(ke(t,n))}textInputs(t){return this.apply(Ie(t))}numberInputs(t){return this.apply(Ue(t))}booleanInputs(t){return this.apply(Ee(t))}selects(t){return this.apply(De(t))}selectByUid(t,n){return this.apply(Ce(t,n))}dropdowns(t){return this.apply(Pe(t))}dropdownByUid(t,n){return this.apply(Be(t,n))}radiogroups(t){return this.apply(we(t))}radiogroupByUid(t,n){return this.apply(Le(t,n))}checkboxes(t){return this.apply(ve(t))}checkboxByUid(t,n){return this.apply(Me(t,n))}textareas(t){return this.apply(Re(t))}textareaByUid(t,n){return this.apply(Oe(t,n))}passwords(t){return this.apply(We(t))}passwordByUid(t,n){return this.apply(Ne(t,n))}currencies(t){return this.apply(Fe(t))}currencyByUid(t,n){return this.apply(je(t,n))}markdowns(t){return this.apply($e(t))}markdownByUid(t,n){return this.apply(Ye(t,n))}lists(t){return this.apply(ze(t))}listByUid(t,n){return this.apply(Ge(t,n))}calendars(t){return this.apply(Ke(t))}calendarByUid(t,n){return this.apply(Ve(t,n))}dateInputs(t){return this.apply(He(t))}dateInputByUid(t,n){return this.apply(Xe(t,n))}datePickers(t){return this.apply(Ze(t))}datePickerByUid(t,n){return this.apply(qe(t,n))}rangeCalendars(t){return this.apply(Qe(t))}rangeCalendarByUid(t,n){return this.apply(Je(t,n))}rangeDateInputs(t){return this.apply(xe(t))}rangeDateInputByUid(t,n){return this.apply(et(t,n))}rangeDatePickers(t){return this.apply(tt(t))}rangeDatePickerByUid(t,n){return this.apply(nt(t,n))}repeaters(t){return this.apply(N(t))}repeaterByUid(t,n){return this.apply(st(t,n))}actions(t){return this.apply(lt(t))}actionByUid(t,n){return this.apply(at(t,n))}layouts(t){return this.apply(rt(t))}layoutByUid(t,n){return this.apply(ot(t,n))}displays(t){return this.apply(ut(t))}displayByUid(t,n){return this.apply(ct(t,n))}alerts(t){return this.apply(dt(t))}alertByUid(t,n){return this.apply(pt(t,n))}tabs(t){return this.apply(yt(t))}tabsByUid(t,n){return this.apply(mt(t,n))}accordions(t){return this.apply(gt(t))}accordionByUid(t,n){return this.apply(bt(t,n))}customInputs(t){return this.apply(ft(t))}customInputByUid(t,n){return this.apply(ht(t,n))}customActions(t){return this.apply(Tt(t))}customActionByUid(t,n){return this.apply(_t(t,n))}customDisplays(t){return this.apply(St(t))}customDisplayByUid(t,n){return this.apply(At(t,n))}customLayouts(t){return this.apply(kt(t))}customLayoutByUid(t,n){return this.apply(It(t,n))}}const mn={inputs:{textInput:Y,numberInput:z,booleanInput:G,select:K,dropdown:V,radiogroup:H,checkbox:X,textarea:Z,password:q,currency:Q,markdown:J,list:x,calendar:ee,dateInput:te,datePicker:ne,rangeCalendar:se,rangeDateInput:ie,rangeDatePicker:le,repeater:_e,custom:ae},actions:{button:v,submitButton:M,custom:oe},displays:{display:R,alert:ue,custom:ce},layouts:{flex:D,horizontalFlex:de,verticalFlex:pe,grid:C,horizontalGrid:ye,verticalGrid:me,tabs:be,accordion:he,custom:Te},selectors:k.root()};function gn(e,...t){return t.map(n=>({...n,targetState:e}))}function bn(e,...t){return{kind:"aggregated",matcher:n=>n.tags?.includes(e)??!1,children:t}}const Ut={INPUTS:new Set(["INPUTS","TEXTAREA","PASSWORD","SELECT","DROPDOWN","RADIOGROUP","CHECKBOX","CALENDAR","DATE_INPUT","DATE_PICKER","RANGE_CALENDAR","RANGE_DATE_INPUT","RANGE_DATE_PICKER","CURRENCY","MARKDOWN","LIST","CUSTOM_INPUT","REPEATER"]),ACTIONS:new Set(["ACTIONS","CUSTOM_ACTION"]),DISPLAYS:new Set(["DISPLAYS","ALERTS","CUSTOM_DISPLAY"]),LAYOUTS:new Set(["LAYOUTS","TABS","ACCORDION","CUSTOM_LAYOUT"])};function fn(e,t){const n=Ut[e];return n?n.has(t):e===t}class hn{resolve(t,n){const s=[];for(const l of n)l.kind==="aggregated"?this.collectFromAggregated(l,t,s):this.collectFromLeaf(l,t,s);const i=this.rollUpSensibleDefaults(s);return{leafSelectors:s,sensibleDefaults:i}}collectFromAggregated(t,n,s){if(t.matcher(n))for(const i of t.children)this.collectFromLeaf(i,n,s)}collectFromLeaf(t,n,s){fn(t.selectorType,n.itemType??"")&&t.matcher(n)&&s.push(t)}rollUpSensibleDefaults(t){const n=new Map,s=(l,a)=>{const u=n.get(l)??[];u.push(a),n.set(l,u)};for(const l of t){const a=Ut[l.selectorType];if(a)for(const u of a)s(u,l);else s(l.selectorType,l)}const i={};for(const[l,a]of n)Ae(l)&&(i[l]=U(l).rollUpSensibleDefaults(a));return i}}const Tn=new hn;class _n{constructor(t){this.objectUtils=t}merge(t,n,s){let i={},l=null;typeof t=="function"&&(l=t);const a=this.collectDecorators(s);for(const c of a){if(l!=null){l=this.composeRuntimeFunctions(l,c);continue}if(typeof c=="function"){const d=c({...i,...typeof t=="function"?{}:t});if(typeof d=="function"){l=this.createPromotedFunction(i,t,d,n,s);continue}i=this.objectUtils.deepMerge(i,d)}else i=this.objectUtils.deepMerge(i,c)}if(l!=null)return{kind:"dynamic",fn:this.wrapWithSensibleDefaults(l,i,n,s)};const u=this.objectUtils.deepMerge(t,i);return{kind:"static",def:this.applySensibleDefaults({...u},n,s)}}collectDecorators(t){const n=[];for(const s of t.leafSelectors){const i=s.config;i.override!=null&&n.push(i.override)}return n}applySensibleDefaults(t,n,s){if(!Ae(n))return t;const i=s.sensibleDefaults[n]??{};return U(n).applySensibleDefaults(t,i)}createPromotedFunction(t,n,s,i,l){return a=>{const u=s(a);let o=this.objectUtils.deepMerge(t,u);return o=this.objectUtils.deepMerge(o,n),this.applySensibleDefaults(o,i,l)}}wrapWithSensibleDefaults(t,n,s,i){return l=>{let a=t(l);return Object.keys(n).length>0&&(a=this.objectUtils.deepMerge(n,a)),this.applySensibleDefaults(a,s,i)}}composeRuntimeFunctions(t,n){return typeof n=="function"?s=>{const i=t(s),l=n(i);return typeof l=="function"?l(s):this.objectUtils.deepMerge(l,i)}:s=>{const i=t(s);return this.objectUtils.deepMerge(i,n)}}}const Sn=new _n(re);class An{mapToWidget(t,n){if(t.kind==="dynamic"){const s=t.fn;return(i=>{const l=s(i);return this.mapStaticDef(l,n)})}return this.mapStaticDef(t.def,n)}mapStaticDef(t,n){const s=U(n).mapToWidget(t);return this.applyBaseWidgetFields(s,t)}applyBaseWidgetFields(t,n){return n.size!=null&&(t.size=n.size),n.defaultValue!=null&&t.kind==="input"&&(t.defaultValue=n.defaultValue),n.on!=null&&(t.on=n.on),n.include!=null&&(t.include=n.include),n.exclude!=null&&(t.exclude=n.exclude),t}}const kn=new An;class In{normalizeSelectors(t){const n=Array.isArray(t)?t:[t],s=[],i=[];for(const l of n)l.kind==="leaf"?i.push(l):s.push(l);return i.length>0&&s.unshift({kind:"aggregated",matcher:()=>!0,children:i}),s}extractFormConfig(){return{suppressAutomaticStack:!1,suppressAutomaticSubmit:!1,onSubmit:t=>console.log("Form submitted:",t)}}}const Un=new In;function En(){let e=0;return{next:()=>`event_${e++}`}}class Dn{constructor(t,n,s,i,l){this.resolver=t,this.merger=n,this.mapper=s,this.eventWiring=i,this.stateExpansion=l}walkAndMap(t,n,s){const i=new Map,l=En(),a={value:0},u=new Set;return{widgets:this.walkItems(t,n,i,s,l,a,u),eventRegistry:i}}walkItems(t,n,s,i,l,a,u){return t.flatMap(o=>{if(o.type!=="ITEMS")throw new Error("Unexpected gui shortcut type");return o.items.map(c=>this.processItem(c,o.itemType,o.tags,n,s,i,l,a,u))})}processItem(t,n,s,i,l,a,u,o,c){const d=n,m=U(n),y=m.parseEntry(t),_=this.buildBaseDef(y),w=this.buildDecoratorForMatching(_,d,s),L=this.resolver.resolve(w,i),Ot=L.leafSelectors.filter(T=>T.targetState!=null),Wt={leafSelectors:L.leafSelectors.filter(T=>T.targetState==null),sensibleDefaults:L.sensibleDefaults};let I=this.merger.merge(_,d,Wt);m.afterMerge&&(I=m.afterMerge(I,{eventRegistry:l,formConfig:a,eventIdGenerator:u})),I=this.eventWiring.wireInputLayoutEvents(I,l,u);const{cleanedResult:Nt,stateData:$}=this.stateExpansion.extractFromMergeResult(I,Ot);let A;if(m.buildCustomWidget){const T=this.buildCustomWidgetContext(y.children,i,l,a,u,o,c);A=this.buildCustomWidget(m,Nt,T)}else A=this.mapper.mapToWidget(Nt,d);if(typeof A!="function"){const T=A;T.uid||(T.path&&!c.has(T.path)?(T.uid=T.path,c.add(T.path)):T.uid=`dx_${o.value++}`)}if(this.stateExpansion.hasStateData($))if(typeof A=="function"){const T=A;A=(Gn=>{const Kn=T(Gn);return this.stateExpansion.applyToWidget(Kn,$,l,u)})}else A=this.stateExpansion.applyToWidget(A,$,l,u);return A}buildCustomWidgetContext(t,n,s,i,l,a,u){return{children:t,mapStaticDef:(o,c)=>this.mapper.mapStaticDef(o,c),walkChildren:o=>this.walkItems(o,n,s,i,l,a,u)}}buildCustomWidget(t,n,s){return t.buildCustomWidget(n,s)}buildBaseDef(t){const n=t.baseDef;return typeof n=="function"?s=>{const l=n(s??{});return t.path!=null?{...l,path:t.path}:l}:t.path!=null?{...n,path:t.path}:n}buildDecoratorForMatching(t,n,s){if(typeof t=="function")return{itemType:n,tags:[...s]};const i=[...s,..."tags"in t&&t.tags?t.tags:[]],l="uid"in t?t.uid:void 0,a="type"in t?t.type:void 0;return{itemType:n,tags:i,uid:l,type:a}}}const Cn={input:new Set(["disabled","readonly","label","validator","size"]),action:new Set(["disabled","label","size"]),layout:new Set(["size"]),display:new Set([])},Et={onChange:"change",onLoad:"load",onFilter:"filter",onClick:"click"};class Pn{extractFromMergeResult(t,n){const s={};for(const u of n){const o=u.targetState,c=u.config,d=c.override&&typeof c.override!="function"?c.override:c;s[o]={...s[o]||{},...d}}if(t.kind==="dynamic"){const u=t.fn;return{cleanedResult:{kind:"dynamic",fn:c=>{const d=u(c),{states:m,...y}=d;return y}},stateData:{stateOverrides:s}}}const{states:i,...l}=t.def,a={};for(const[u,o]of Object.entries(s))a[u]={...o};if(i)for(const[u,o]of Object.entries(i))a[u]={...a[u]||{},...o};return{cleanedResult:{kind:"static",def:l},stateData:{stateOverrides:a}}}applyToWidget(t,n,s,i){const{stateOverrides:l}=n;if(Object.keys(l).length===0)return t;const a={...t},u=t.kind,o=Cn[u]||new Set;t.props&&(a.props={...t.props}),t.on&&(a.on={...t.on});for(const[c,d]of Object.entries(l))for(const[m,y]of Object.entries(d))m==="visible"?this.applyVisibility(a,c,y):Et[m]?this.applyStateEvent(a,c,m,y,s,i):o.has(m)?a[`${m}.${c}`]=y:(a.props||(a.props={}),a.props[`${m}.${c}`]=y);return a}hasStateData(t){return Object.keys(t.stateOverrides).length>0}applyVisibility(t,n,s){if(s){const i=t.include?.in||[];t.include={...t.include||{},in:[...i,n]}}else{const i=t.exclude?.from||[];t.exclude={...t.exclude||{},from:[...i,n]}}}applyStateEvent(t,n,s,i,l,a){const u=Et[s];if(t.on||(t.on={}),typeof i=="function"){const o=a.next();l.set(o,i),t.on[`${u}.${n}`]=o}else typeof i=="string"&&(t.on[`${u}.${n}`]=i)}}const Bn=new Pn;class wn{constructor(t,n,s){this.selectorNormalizer=t,this.eventWiring=n,this.walker=s}processDxFacade(t,n=[],s){const{defs:i,gslSelectors:l,formConfig:a}=this.prepareForm(t,n,s),{widgets:u,eventRegistry:o}=this.walker.walkAndMap(i,l,a),c=u[0];return this.buildResult({form:c},o,a)}prepareForm(t,n,s){const l=(Array.isArray(t)?[...t]:[t]).map(c=>typeof c=="function"?R(c):c),a=this.selectorNormalizer.normalizeSelectors(n),u={...this.selectorNormalizer.extractFormConfig(),...s},o=this.eventWiring.countSubmitButtons(l);if(o>1)throw new Error(`Only one submit button is allowed per form, but ${o} were found. A button is a submit button if it has uid: '#submit' or onClick: 'submit'.`);if(!u.suppressAutomaticSubmit&&o===0&&l.push(M()),!u.suppressAutomaticStack){const c={def:{uid:"#root",direction:"column",widgetName:"flex"},children:l};return{defs:[{type:"ITEMS",itemType:b.LAYOUTS,items:[c],tags:[]}],gslSelectors:a,formConfig:u}}return{defs:l,gslSelectors:a,formConfig:u}}convertStateNames(t){const n={};for(const[s,i]of Object.entries(t))n[s.replace(/\$/g,":")]=i;return n}buildResult(t,n,s){s.states&&Object.keys(s.states).length>0&&(t={...t,states:this.convertStateNames(s.states)});const i={form:t};return n.size>0&&(i.events=l=>{const a=n.get(l.name);if(a){const u=c=>{if(c&&typeof c=="object"&&"path"in c&&!("type"in c)){const{path:d,...m}=c;for(const[y,_]of Object.entries(m))l.callback({type:"OVERRIDE_WIDGET_PROP",payload:{path:d,prop:y,value:_}})}else l.callback(c)},o={...l,callback:u,update:u};a(o)}}),s.dependencies&&(i.dependencies=s.dependencies),s.widgetLoaders&&(i.widgetLoaders=s.widgetLoaders),s.validateOn&&(i.validateOn=s.validateOn),s.itemRenderers&&(i.itemRenderers=s.itemRenderers),i}}const Ln=new Dn(Tn,Sn,kn,B,Bn),Dt=new wn(Un,B,Ln);function Ct(e){return typeof e=="function"?!0:Array.isArray(e)?e.length===0||e.every(Pt):Pt(e)}function Pt(e){if(typeof e=="function")return!0;if(e===null||typeof e!="object")return!1;const t=e;return t.type==="ITEMS"&&typeof t.itemType=="string"}const Bt=Object.freeze({}),vn=Object.freeze({}),wt=new WeakMap;function F(e,t){return e==null?t:typeof e=="object"?e:{}}function Mn(e,t,n){if(!Ct(e))return{formDef:e};const s=F(e,Bt),i=F(t,Bt),l=F(n,vn);let a=wt.get(s);a||(a=new WeakMap,wt.set(s,a));let u=a.get(i);u||(u=new WeakMap,a.set(i,u));const o=u.get(l);if(o)return o;const c=Dt.processDxFacade(e,t,n),d={formDef:c.form,formEvent:c.events,dependencies:c.dependencies,widgetLoaders:c.widgetLoaders,validateOn:c.validateOn,itemRenderers:c.itemRenderers};return u.set(l,d),d}class Rn{create(t){return{states:t.states,form:{uid:"gui-root-uid",type:"flex",kind:"layout",children:t.form}}}}function On(){return new Rn}const Wn=e=>e!==null&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"label")&&Object.prototype.hasOwnProperty.call(e,"value");function Nn(e,t){if(e!=null&&typeof e=="object"&&"__rid"in e)return e.__rid;const n=t();return Object.defineProperty(e,"__rid",{value:n,enumerable:!1,configurable:!1}),n}function Fn(e){return typeof e=="object"&&e!==null&&"$ref"in e&&typeof e.$ref=="string"&&Object.keys(e).length===1}async function jn(e,t){const n=new URL(e,t).href,s=await fetch(n);if(!s.ok)throw new Error(`Failed to load form chunk ${n}: ${s.status}`);const{$schema:i,...l}=await s.json();return j(l,n)}async function j(e,t){if(Fn(e))return jn(e.$ref,t);const n=e;if(Array.isArray(n.children)){const s=await Promise.all(n.children.map(i=>j(i,t)));return{...n,children:s}}return e}async function $n(e,t){const n=await Promise.all(e.form.map(s=>j(s,t)));return{...e,form:n}}const Yn={textinput:({config:e,props:t,validator:n})=>({uid:"",kind:"input",type:"textinput",...t&&{props:t},...n&&{validator:n},...e}),password:({config:e,props:t,validator:n})=>({uid:"",kind:"input",type:"password",...t&&{props:t},...n&&{validator:n},...e}),numberinput:({config:e,props:t,validator:n})=>({uid:"",kind:"input",type:"numberinput",...t&&{props:t},...n&&{validator:n},...e}),checkbox:({config:e,props:t,validator:n})=>({uid:"",kind:"input",type:"checkbox",...t&&{props:t},...n&&{validator:n},...e}),select:({config:e,props:t,validator:n})=>({uid:"",kind:"input",type:"select",...t&&{props:t},...n&&{validator:n},...e}),flex:(e,t)=>({uid:"",kind:"layout",type:"flex",...t&&{props:t},...e}),grid:(e,t)=>({uid:"",kind:"layout",type:"grid",...t&&{props:t},...e}),tabs:(e,t)=>({uid:"",kind:"layout",type:"tabs",...t&&{props:t},...e}),alert:(e,t)=>({uid:"",kind:"display",type:"alert",...t&&{props:t},...e}),markdownText:(e,t)=>({uid:"",kind:"display",type:"markdownText",...t&&{props:t},...e})},Lt=["calendar","checkbox","currency","dateInput","datePicker","dropdown","list","markdown","number","password","radiogroup","rangeCalendar","rangeDateInput","rangeDatePicker","repeater","select","textarea","textinput","toggle"],vt=["accordion","flex","grid","tabs"],Mt=["alert","markdownText","renderer"],Rt=["button"],zn=[...Lt,...vt,...Mt,...Rt];r.GolemWidgets=Yn,r._gslAccordionByUid=bt,r._gslAccordions=gt,r._gslActionByUid=at,r._gslActions=lt,r._gslAlertByUid=pt,r._gslAlerts=dt,r._gslBooleanInputs=Ee,r._gslCalendarByUid=Ve,r._gslCalendars=Ke,r._gslCheckboxByUid=Me,r._gslCheckboxes=ve,r._gslCurrencies=Fe,r._gslCurrencyByUid=je,r._gslCustomActionByUid=_t,r._gslCustomActions=Tt,r._gslCustomDisplayByUid=At,r._gslCustomDisplays=St,r._gslCustomInputByUid=ht,r._gslCustomInputs=ft,r._gslCustomLayoutByUid=It,r._gslCustomLayouts=kt,r._gslDateInputByUid=Xe,r._gslDateInputs=He,r._gslDatePickerByUid=qe,r._gslDatePickers=Ze,r._gslDisplayByUid=ct,r._gslDisplays=ut,r._gslDropdownByUid=Be,r._gslDropdowns=Pe,r._gslInputByUid=ke,r._gslInputs=E,r._gslLayoutByUid=ot,r._gslLayouts=rt,r._gslListByUid=Ge,r._gslLists=ze,r._gslMarkdownByUid=Ye,r._gslMarkdowns=$e,r._gslNumberInputs=Ue,r._gslPasswordByUid=Ne,r._gslPasswords=We,r._gslRadiogroupByUid=Le,r._gslRadiogroups=we,r._gslRangeCalendarByUid=Je,r._gslRangeCalendars=Qe,r._gslRangeDateInputByUid=et,r._gslRangeDateInputs=xe,r._gslRangeDatePickerByUid=nt,r._gslRangeDatePickers=tt,r._gslRepeaterByUid=st,r._gslRepeaters=N,r._gslSelectByUid=Ce,r._gslSelects=De,r._gslStates=gn,r._gslTabs=yt,r._gslTabsByUid=mt,r._gslTag=bn,r._gslTextInputs=Ie,r._gslTextareaByUid=Oe,r._gslTextareas=Re,r._guiAccordion=he,r._guiAlert=ue,r._guiBooleanInput=G,r._guiButton=v,r._guiCalendar=ee,r._guiCheckbox=X,r._guiCurrency=Q,r._guiCustomAction=oe,r._guiCustomDisplay=ce,r._guiCustomInput=ae,r._guiCustomLayout=Te,r._guiDateInput=te,r._guiDatePicker=ne,r._guiDisplay=R,r._guiDropdown=V,r._guiFlex=D,r._guiGrid=C,r._guiHorizontalFlex=de,r._guiHorizontalGrid=ye,r._guiList=x,r._guiMarkdown=J,r._guiNumberInput=z,r._guiPassword=q,r._guiRadiogroup=H,r._guiRangeCalendar=se,r._guiRangeDateInput=ie,r._guiRangeDatePicker=le,r._guiRepeater=_e,r._guiSelect=K,r._guiSubmitButton=M,r._guiTabs=be,r._guiTextInput=Y,r._guiTextarea=Z,r._guiVerticalFlex=pe,r._guiVerticalGrid=me,r.actionWidgets=Rt,r.createGslSelector=O,r.defineShortcutType=p,r.displayWidgets=Mt,r.extractWidgetProps=g,r.formDefs=Dt,r.getItemKey=Nn,r.golemForm=On,r.golemWidgets=zn,r.gui=mn,r.inputWidgets=Lt,r.isDxDefinitions=Ct,r.isOption=Wn,r.layoutWidgets=vt,r.processAutoLabel=f,r.processAutoPlaceholder=S,r.resolveChunkRefs=$n,r.resolveFormInput=Mn,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { FormWidget, FunctionWidgetParams, LayoutWidget, NonFunctionWidget } from '@golemui/core';
|
|
2
|
+
import { DxDefinitions } from '../formDef.domain';
|
|
3
|
+
import { FormConfig, GslSelectorsInput } from '../core/dx.domain';
|
|
4
|
+
/**
|
|
5
|
+
* Process a form definition through the full DX pipeline.
|
|
6
|
+
*
|
|
7
|
+
* Returns the root layout widget with its children.
|
|
8
|
+
* Strips the auto-injected submit button for cleaner assertions
|
|
9
|
+
* (it's always the last child if present).
|
|
10
|
+
*
|
|
11
|
+
* IMPORTANT: Asserts that the root widget IS a layout with uid '#root'
|
|
12
|
+
* before unwrapping. This makes the helper a canary for auto-stack
|
|
13
|
+
* changes — if Phase 2 subtly alters auto-stack wiring, this assertion
|
|
14
|
+
* fails loudly instead of silently masking a regression.
|
|
15
|
+
*/
|
|
16
|
+
export declare function processDx(defs: DxDefinitions, selectors?: GslSelectorsInput, formConfig?: FormConfig): LayoutWidget;
|
|
17
|
+
/**
|
|
18
|
+
* Get a static (non-function) child widget from a layout by index.
|
|
19
|
+
* Throws if the child is a function widget — use resolveDynamic for those.
|
|
20
|
+
*/
|
|
21
|
+
export declare function getStaticChild(layout: LayoutWidget, index: number): NonFunctionWidget;
|
|
22
|
+
/**
|
|
23
|
+
* Get a raw child from a layout by index (could be static or function).
|
|
24
|
+
*/
|
|
25
|
+
export declare function getRawChild(layout: LayoutWidget, index: number): FormWidget;
|
|
26
|
+
/**
|
|
27
|
+
* Resolve a function widget (dynamic) by calling it with given params.
|
|
28
|
+
* Returns the resolved static widget.
|
|
29
|
+
*/
|
|
30
|
+
export declare function resolveDynamic(widget: FormWidget, params?: Partial<FunctionWidgetParams<any>>): NonFunctionWidget;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { NonFunctionWidget, FormWidget } from '@golemui/core';
|
|
2
|
+
import { GslLeafSelector, MergeResult } from './dx.domain';
|
|
3
|
+
import { GslConfigBase } from './dxUtilityTypes';
|
|
4
|
+
import { AfterMergeContext, BuildWidgetContext } from './itemTypeRegistry';
|
|
5
|
+
import { DxCommonFields } from './dxBase.types';
|
|
6
|
+
type EntryShape = 'bare' | 'keyed' | 'compound';
|
|
7
|
+
interface SensibleDefaultsSpec<TDecorator, TConfig> {
|
|
8
|
+
base: TConfig;
|
|
9
|
+
fields: (keyof TConfig)[];
|
|
10
|
+
apply: (def: TDecorator, config: TConfig) => TDecorator;
|
|
11
|
+
}
|
|
12
|
+
interface ShortcutTypeConfig<TEntry, TDecorator, TConfig> {
|
|
13
|
+
itemType: string;
|
|
14
|
+
entryShape: EntryShape;
|
|
15
|
+
mapToWidget: (def: TDecorator) => NonFunctionWidget;
|
|
16
|
+
sensibleDefaults?: SensibleDefaultsSpec<TDecorator, TConfig>;
|
|
17
|
+
afterMerge?: (mergeResult: MergeResult, context: AfterMergeContext) => MergeResult;
|
|
18
|
+
buildCustomWidget?: (mergeResult: MergeResult, context: BuildWidgetContext) => FormWidget;
|
|
19
|
+
getChildren?: (entry: TEntry) => any[] | undefined;
|
|
20
|
+
}
|
|
21
|
+
export interface ShortcutTypeSelectors<TDecorator, TConfig extends GslConfigBase<TDecorator>> {
|
|
22
|
+
gsl: (config: TConfig, matcher?: (decorator: TDecorator) => boolean) => GslLeafSelector;
|
|
23
|
+
gslByUid: (uid: string, config: TConfig) => GslLeafSelector;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Convenience factory for registering a new widget type into the DX pipeline.
|
|
27
|
+
*
|
|
28
|
+
* Accepts a simple config object (entry shape, mapToWidget, optional hooks) and
|
|
29
|
+
* assembles a full {@link ItemTypeHandler} from it — generating `parseEntry`,
|
|
30
|
+
* `rollUpSensibleDefaults`, and `applySensibleDefaults` automatically.
|
|
31
|
+
* The handler is registered in the global registry so the pipeline can look it up
|
|
32
|
+
* by `itemType` at runtime.
|
|
33
|
+
*
|
|
34
|
+
* Returns GSL selector factories (`gsl`, `gslByUid`) for styling/configuring
|
|
35
|
+
* widgets of this type.
|
|
36
|
+
*/
|
|
37
|
+
export declare function defineShortcutType<TEntry, TDecorator extends DxCommonFields, TConfig extends GslConfigBase<TDecorator> = GslConfigBase<TDecorator>>(config: ShortcutTypeConfig<TEntry, TDecorator, TConfig>): ShortcutTypeSelectors<TDecorator, TConfig>;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { FunctionWidgetParams, ValidateOn } from '@golemui/core';
|
|
2
|
+
import { WidgetItemDecorator, GslItemType } from '../formDef.domain';
|
|
3
|
+
import { Dependencies } from '../../shared';
|
|
4
|
+
export type { GslItemType } from '../formDef.domain';
|
|
5
|
+
export type RuntimeFunction = (params: FunctionWidgetParams<any>) => any;
|
|
6
|
+
export type GuiItemType = string;
|
|
7
|
+
export declare const GuiItemTypes: {
|
|
8
|
+
readonly INPUTS: "INPUTS";
|
|
9
|
+
readonly ACTIONS: "ACTIONS";
|
|
10
|
+
readonly LAYOUTS: "LAYOUTS";
|
|
11
|
+
readonly DISPLAYS: "DISPLAYS";
|
|
12
|
+
readonly CUSTOM_DISPLAY: "CUSTOM_DISPLAY";
|
|
13
|
+
readonly CUSTOM_INPUT: "CUSTOM_INPUT";
|
|
14
|
+
readonly CUSTOM_ACTION: "CUSTOM_ACTION";
|
|
15
|
+
readonly CUSTOM_LAYOUT: "CUSTOM_LAYOUT";
|
|
16
|
+
};
|
|
17
|
+
export interface GuiItemsShortcut {
|
|
18
|
+
type: 'ITEMS';
|
|
19
|
+
itemType: GuiItemType;
|
|
20
|
+
items: unknown[];
|
|
21
|
+
tags: string[];
|
|
22
|
+
}
|
|
23
|
+
export type ValidGuiShortcut = GuiItemsShortcut;
|
|
24
|
+
export type GslMatcher = (decorator: WidgetItemDecorator) => boolean;
|
|
25
|
+
export type GslLeafConfig = Record<string, any>;
|
|
26
|
+
export interface GslLeafSelector {
|
|
27
|
+
kind: 'leaf';
|
|
28
|
+
selectorType: GslItemType;
|
|
29
|
+
matcher: (decorator: any) => boolean;
|
|
30
|
+
config: GslLeafConfig;
|
|
31
|
+
/** When set by `_gslStates`, config is applied as state-suffixed overrides. */
|
|
32
|
+
targetState?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface FormConfig {
|
|
35
|
+
suppressAutomaticStack?: boolean;
|
|
36
|
+
suppressAutomaticSubmit?: boolean;
|
|
37
|
+
onSubmit?: (data: any) => void;
|
|
38
|
+
dependencies?: Dependencies;
|
|
39
|
+
widgetLoaders?: Record<string, () => Promise<unknown>>;
|
|
40
|
+
validateOn?: ValidateOn;
|
|
41
|
+
states?: Record<string, string>;
|
|
42
|
+
/**
|
|
43
|
+
* Framework-specific item renderers (e.g. ReactItemRenderer / AngularItemRenderer / LitItemRenderer).
|
|
44
|
+
* Forwarded to the unified <gui-form>; the type is intentionally framework-agnostic
|
|
45
|
+
* here and gets narrowed at the framework wrapper boundary.
|
|
46
|
+
*/
|
|
47
|
+
itemRenderers?: Record<string, unknown>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Public-facing form config type for `processDxFacade`'s third argument.
|
|
51
|
+
* Generic over state keys — TypeScript enforces that every declared state name
|
|
52
|
+
* has a corresponding expression.
|
|
53
|
+
*
|
|
54
|
+
* Usage: `processDxFacade<typeof states[number], FormData>(defs, selectors, formConfig)`
|
|
55
|
+
*/
|
|
56
|
+
export type DxFormConfig<S extends string = string> = Omit<FormConfig, 'states'> & {
|
|
57
|
+
states?: Record<S, string>;
|
|
58
|
+
};
|
|
59
|
+
export interface GslAggregatedSelector {
|
|
60
|
+
kind: 'aggregated';
|
|
61
|
+
matcher: GslMatcher;
|
|
62
|
+
children: GslLeafSelector[];
|
|
63
|
+
}
|
|
64
|
+
export type GslSelector = GslAggregatedSelector | GslLeafSelector;
|
|
65
|
+
export type GslSelectorsInput = GslSelector | GslSelector[];
|
|
66
|
+
export interface ResolvedSelectors {
|
|
67
|
+
leafSelectors: GslLeafSelector[];
|
|
68
|
+
sensibleDefaults: Record<string, Record<string, any>>;
|
|
69
|
+
}
|
|
70
|
+
export type MergeResult = {
|
|
71
|
+
kind: 'static';
|
|
72
|
+
def: Record<string, any>;
|
|
73
|
+
} | {
|
|
74
|
+
kind: 'dynamic';
|
|
75
|
+
fn: RuntimeFunction;
|
|
76
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { FormEvent, Localizable, ReactiveExpression } from '@golemui/core';
|
|
2
|
+
/**
|
|
3
|
+
* DX-enriched FormEvent. Extends the core FormEvent with `update()` — the
|
|
4
|
+
* recommended way for DX event handlers to push widget property changes.
|
|
5
|
+
*
|
|
6
|
+
* `update({ path: 'widget', options: [...] })` translates to OVERRIDE_WIDGET_PROP
|
|
7
|
+
* dispatches under the hood. `callback` is also available for raw/backward-compat use.
|
|
8
|
+
*/
|
|
9
|
+
export type DxFormEvent = FormEvent & {
|
|
10
|
+
update: (arg: {
|
|
11
|
+
path: string;
|
|
12
|
+
[prop: string]: any;
|
|
13
|
+
}) => void;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Event handler type for DX event properties.
|
|
17
|
+
* - Function: handler invoked with a DxFormEvent (use event.update to push widget changes).
|
|
18
|
+
* - String: pass-through event name for host-managed dispatch.
|
|
19
|
+
*/
|
|
20
|
+
export type DxEventHandler = string | ((event: DxFormEvent) => void);
|
|
21
|
+
/**
|
|
22
|
+
* INTERNAL decorator fields — used by the pipeline, NOT by form authors.
|
|
23
|
+
* Contains fields that the pipeline needs but users should never set.
|
|
24
|
+
*/
|
|
25
|
+
export interface DxInternalFields {
|
|
26
|
+
itemType?: string;
|
|
27
|
+
removeField?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Sub-type discriminator on the decorator (e.g. `'text' | 'number' | 'boolean'`
|
|
30
|
+
* for inputs that share the `INPUTS` itemType, `'password'`, `'dropdown'`, etc.
|
|
31
|
+
* for top-level itemTypes). Carried into the matching phase so sub-type
|
|
32
|
+
* matchers like `_gslTextInputs((d) => d.type === 'text')` work.
|
|
33
|
+
*/
|
|
34
|
+
type?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Conditional inclusion: state-list or reactive expression form.
|
|
38
|
+
* Mirrors core's `include` shape on `BaseWidget`.
|
|
39
|
+
*/
|
|
40
|
+
export type DxIncludeCondition = {
|
|
41
|
+
in: string[];
|
|
42
|
+
} | {
|
|
43
|
+
when: ReactiveExpression;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Conditional exclusion: state-list or reactive expression form.
|
|
47
|
+
* Mirrors core's `exclude` shape on `BaseWidget`.
|
|
48
|
+
*/
|
|
49
|
+
export type DxExcludeCondition = {
|
|
50
|
+
from: string[];
|
|
51
|
+
} | {
|
|
52
|
+
when: ReactiveExpression;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* User-settable common fields available on ALL decorator types.
|
|
56
|
+
*/
|
|
57
|
+
export interface DxCommonFields {
|
|
58
|
+
uid?: string;
|
|
59
|
+
tags?: string[];
|
|
60
|
+
size?: number;
|
|
61
|
+
/** Per-state property overrides. Keys are state names (use `:` for hierarchy). */
|
|
62
|
+
states?: Record<string, Record<string, any>>;
|
|
63
|
+
/** Conditionally include the widget — by active state list or reactive expression. */
|
|
64
|
+
include?: DxIncludeCondition;
|
|
65
|
+
/** Conditionally exclude the widget — by active state list or reactive expression. */
|
|
66
|
+
exclude?: DxExcludeCondition;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* PUBLIC base for input-like decorators.
|
|
70
|
+
* Clean projection of InputWidget properties — no generics, no SomeSuffixable.
|
|
71
|
+
*/
|
|
72
|
+
export interface DxInputBase {
|
|
73
|
+
path?: string;
|
|
74
|
+
label?: Localizable | null;
|
|
75
|
+
disabled?: boolean | {
|
|
76
|
+
when: ReactiveExpression;
|
|
77
|
+
};
|
|
78
|
+
readonly?: boolean | {
|
|
79
|
+
when: ReactiveExpression;
|
|
80
|
+
};
|
|
81
|
+
defaultValue?: unknown;
|
|
82
|
+
onLoad?: DxEventHandler;
|
|
83
|
+
onChange?: DxEventHandler;
|
|
84
|
+
onFilter?: DxEventHandler;
|
|
85
|
+
onBlur?: DxEventHandler;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* PUBLIC base for action decorators.
|
|
89
|
+
*/
|
|
90
|
+
export interface DxActionBase {
|
|
91
|
+
label?: Localizable;
|
|
92
|
+
disabled?: boolean | {
|
|
93
|
+
when: ReactiveExpression;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* PUBLIC base for layout decorators.
|
|
98
|
+
*/
|
|
99
|
+
export interface DxLayoutBase {
|
|
100
|
+
onChange?: DxEventHandler;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* PUBLIC base for display decorators.
|
|
104
|
+
* Displays are render-function-only — no shared properties beyond uid.
|
|
105
|
+
*/
|
|
106
|
+
export interface DxDisplayBase {
|
|
107
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DxCommonFields, DxInputBase } from './dxBase.types';
|
|
2
|
+
type DxBaseKeys = keyof DxInputBase | keyof DxCommonFields | 'type';
|
|
3
|
+
/**
|
|
4
|
+
* Extract widget-specific props from a flattened decorator.
|
|
5
|
+
* Strips DxInputBase + DxCommonFields fields, event properties,
|
|
6
|
+
* and pipeline-internal `on` from the output.
|
|
7
|
+
*/
|
|
8
|
+
export declare function extractWidgetProps<D extends DxInputBase & DxCommonFields>(def: D): Omit<D, DxBaseKeys>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { FunctionWidgetParams } from '@golemui/core';
|
|
2
|
+
import { RuntimeFunction, GuiItemsShortcut, GslLeafSelector } from './dx.domain';
|
|
3
|
+
export type DxRuntimeParams<FormData = any> = FunctionWidgetParams<FormData>;
|
|
4
|
+
/**
|
|
5
|
+
* Generic GSL decorator callback — same structure for every type.
|
|
6
|
+
* Usage: replace per-type `GslCalendarDecoratorCallback`, `GslInputDecoratorCallback`, etc.
|
|
7
|
+
*/
|
|
8
|
+
export type GslDecoratorCallback<D> = (current: D) => Partial<D> | RuntimeFunction;
|
|
9
|
+
/**
|
|
10
|
+
* A field definition can be a static decorator or a runtime callback.
|
|
11
|
+
* Usage: replace per-type `CalendarDefOrCallback`, `ActionDefOrCallback`, etc.
|
|
12
|
+
*/
|
|
13
|
+
export type DefOrCallback<D, TForm = any> = D | ((params: DxRuntimeParams<TForm>) => Partial<D>);
|
|
14
|
+
/**
|
|
15
|
+
* Standard GSL config shape — override + optional suppress flags.
|
|
16
|
+
* Extend this for types that have additional GSL config fields.
|
|
17
|
+
* Usage: replace per-type `GslCalendarConfig`, `GslInputConfig`, etc. base shape.
|
|
18
|
+
*/
|
|
19
|
+
export interface GslConfigBase<D> {
|
|
20
|
+
override?: Partial<D> | GslDecoratorCallback<D>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Typed GUI shortcut sub-interface.
|
|
24
|
+
* Usage: replace per-type `GuiCalendarShortcut`, `GuiInputsShortcut`, etc.
|
|
25
|
+
*/
|
|
26
|
+
export interface GuiShortcutOf<TItemType extends string, TEntry> extends GuiItemsShortcut {
|
|
27
|
+
itemType: TItemType;
|
|
28
|
+
items: TEntry[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Creates a GSL selector factory for a given shortcut type.
|
|
32
|
+
* Eliminates the need for per-type gsl*.impl.ts files.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* export const _gslCalendars = createGslSelector<CalendarDecorator, GslCalendarConfig>('CALENDAR');
|
|
37
|
+
* // Equivalent to the hand-written gslCalendar.impl.ts factory
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function createGslSelector<D, TConfig extends GslConfigBase<D> = GslConfigBase<D>>(selectorType: string): (config: TConfig, matcher?: (decorator: D) => boolean) => GslLeafSelector;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Validator } from '@golemui/gui-validators';
|
|
2
|
+
type ValidatorFn = (api: any) => Partial<Validator>;
|
|
3
|
+
/**
|
|
4
|
+
* Build a fixed-type validator from a user-supplied partial validator and a
|
|
5
|
+
* known JSON-schema type. The DX layer uses this for widgets whose value
|
|
6
|
+
* shape is fixed (e.g. password is always string, currency always number,
|
|
7
|
+
* calendar always string-with-format, repeater always array).
|
|
8
|
+
*
|
|
9
|
+
* Runtime-function validators are passed through unchanged — the function's
|
|
10
|
+
* return value is responsible for setting `type` itself. The function is
|
|
11
|
+
* evaluated by the engine on every form-data change.
|
|
12
|
+
*
|
|
13
|
+
* When `validator` is `undefined`, returns a no-op typed validator
|
|
14
|
+
* (`{ type }` with no rules). Callers can still gate the call with a null
|
|
15
|
+
* check when they only want to emit `validator` if the user supplied one.
|
|
16
|
+
*/
|
|
17
|
+
export declare function buildTypedValidator(validator: Record<string, unknown> | ValidatorFn | undefined, type: Validator['type']): Validator | ValidatorFn;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FormEvent } from '@golemui/core';
|
|
2
|
+
import { FormConfig, MergeResult, ValidGuiShortcut } from './dx.domain';
|
|
3
|
+
import { EventIdGenerator } from './itemTypeRegistry';
|
|
4
|
+
export type EventRegistry = Map<string, (event: FormEvent) => void>;
|
|
5
|
+
/**
|
|
6
|
+
* Generalisation of ActionOnClickService.
|
|
7
|
+
*
|
|
8
|
+
* Two entry points:
|
|
9
|
+
* - `extractOnClickFromMergeResult` — action-specific: handles onClick + submit promotion.
|
|
10
|
+
* Called from the actions afterMerge hook.
|
|
11
|
+
* - `wireInputLayoutEvents` — universal: handles onLoad, onChange, onFilter on any widget.
|
|
12
|
+
* Called from ItemWalker.processItem for every item.
|
|
13
|
+
*/
|
|
14
|
+
export declare class EventWiringService {
|
|
15
|
+
extractOnClickFromMergeResult(mergeResult: MergeResult, eventRegistry: EventRegistry, formConfig: FormConfig, eventIdGenerator: EventIdGenerator): MergeResult;
|
|
16
|
+
countSubmitButtons(defs: ValidGuiShortcut[]): number;
|
|
17
|
+
private wireOnClick;
|
|
18
|
+
wireInputLayoutEvents(mergeResult: MergeResult, eventRegistry: EventRegistry, eventIdGenerator: EventIdGenerator): MergeResult;
|
|
19
|
+
private wireEventProperties;
|
|
20
|
+
}
|
|
21
|
+
declare const eventWiringService: EventWiringService;
|
|
22
|
+
export default eventWiringService;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { FormWidget, NonFunctionWidget, UiState, FormEvent } from '@golemui/core';
|
|
2
|
+
import { DxRuntimeParams } from './dxUtilityTypes';
|
|
3
|
+
import { GslLeafSelector, FormConfig, MergeResult, ValidGuiShortcut, GslItemType } from './dx.domain';
|
|
4
|
+
import { DxCommonFields } from './dxBase.types';
|
|
5
|
+
export interface ParsedEntry<TDecorator extends DxCommonFields = DxCommonFields> {
|
|
6
|
+
baseDef: TDecorator | ((params: DxRuntimeParams) => Partial<TDecorator>);
|
|
7
|
+
path?: string;
|
|
8
|
+
children?: ValidGuiShortcut[];
|
|
9
|
+
}
|
|
10
|
+
export type EventRegistry = Map<string, (event: FormEvent) => void>;
|
|
11
|
+
export interface EventIdGenerator {
|
|
12
|
+
next(): string;
|
|
13
|
+
}
|
|
14
|
+
export interface AfterMergeContext {
|
|
15
|
+
eventRegistry: EventRegistry;
|
|
16
|
+
formConfig: FormConfig;
|
|
17
|
+
eventIdGenerator: EventIdGenerator;
|
|
18
|
+
}
|
|
19
|
+
export interface BuildWidgetContext {
|
|
20
|
+
children?: ValidGuiShortcut[];
|
|
21
|
+
mapStaticDef: (def: Record<string, any>, itemType: GslItemType) => NonFunctionWidget;
|
|
22
|
+
walkChildren: (children: ValidGuiShortcut[]) => FormWidget[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Strategy interface for a widget type (inputs, actions, layouts, calendars, etc.).
|
|
26
|
+
*
|
|
27
|
+
* The DX pipeline (`ItemWalker.processItem`) is generic — it walks the widget tree,
|
|
28
|
+
* resolves selectors, merges definitions, and maps to framework widgets. But each
|
|
29
|
+
* widget type has its own entry shape, its own sensible defaults, and sometimes
|
|
30
|
+
* custom post-merge or widget-building logic. The handler provides these type-specific
|
|
31
|
+
* behaviors at well-defined extension points in the pipeline:
|
|
32
|
+
*
|
|
33
|
+
* 1. `parseEntry` — parse raw entry into a normalized `ParsedEntry`
|
|
34
|
+
* 2. `rollUpSensibleDefaults` — aggregate config from matching leaf selectors
|
|
35
|
+
* 3. `applySensibleDefaults` — apply aggregated config to a merged decorator
|
|
36
|
+
* 4. `mapToWidget` — map a decorator to a core `FormWidget`
|
|
37
|
+
* 5. `afterMerge` (optional) — post-merge hook (e.g. actions use this to wire onClick)
|
|
38
|
+
* 6. `buildCustomWidget` (optional) — custom widget building for compound types (e.g. layouts
|
|
39
|
+
* that need to recursively walk children)
|
|
40
|
+
*
|
|
41
|
+
* Shortcut authors do NOT implement this interface directly. Instead, they call
|
|
42
|
+
* {@link defineShortcutType} with a simple config object, and it assembles the full
|
|
43
|
+
* handler and registers it in the global registry.
|
|
44
|
+
*
|
|
45
|
+
* Entry shape taxonomy:
|
|
46
|
+
*
|
|
47
|
+
* 1. Keyed entries — { key, def } — path derived from key
|
|
48
|
+
* Used by: inputs, future select/radiogroup
|
|
49
|
+
*
|
|
50
|
+
* 2. Bare entries — decorator | callback directly
|
|
51
|
+
* Used by: actions, calendar, displays
|
|
52
|
+
*
|
|
53
|
+
* 3. Compound entries — { def, children } — container with nested shortcuts
|
|
54
|
+
* Used by: layouts, future tabs/accordion
|
|
55
|
+
*
|
|
56
|
+
* Each handler declares TEntry to match its shape.
|
|
57
|
+
* There is no shared base type — the shapes are intentionally different.
|
|
58
|
+
* parseEntry(entry: TEntry) is the type-safe boundary.
|
|
59
|
+
*/
|
|
60
|
+
export interface ItemTypeHandler<TEntry = any, TDecorator extends DxCommonFields = DxCommonFields, TConfig = Record<string, any>> {
|
|
61
|
+
rollUpSensibleDefaults(leafSelectors: GslLeafSelector[]): TConfig;
|
|
62
|
+
applySensibleDefaults(def: TDecorator, config: TConfig): TDecorator;
|
|
63
|
+
mapToWidget<StateKeys extends UiState = never, FormData extends Record<string, any> = any>(def: TDecorator): NonFunctionWidget<StateKeys, FormData>;
|
|
64
|
+
parseEntry(entry: TEntry): ParsedEntry<TDecorator>;
|
|
65
|
+
afterMerge?(mergeResult: MergeResult, context: AfterMergeContext): MergeResult;
|
|
66
|
+
/**
|
|
67
|
+
* Optional override for widget types that need custom construction beyond the
|
|
68
|
+
* generic mapToWidget path. Two flavors:
|
|
69
|
+
*
|
|
70
|
+
* - Compound types (layouts, accordion, tabs, repeater): use `context.walkChildren`
|
|
71
|
+
* to recursively process child widgets and attach them to the result.
|
|
72
|
+
* - Custom rendering (displays): wrap a render function into a specialized widget
|
|
73
|
+
* shape that the generic mapper can't produce.
|
|
74
|
+
*
|
|
75
|
+
* If not provided, the pipeline falls back to `mapToWidget` for simple leaf types.
|
|
76
|
+
*/
|
|
77
|
+
buildCustomWidget?(mergeResult: MergeResult, context: BuildWidgetContext): FormWidget;
|
|
78
|
+
getChildren?(entry: TEntry): ValidGuiShortcut[] | undefined;
|
|
79
|
+
}
|
|
80
|
+
export declare function registerItemType(itemType: string, handler: ItemTypeHandler<any, any, any>): void;
|
|
81
|
+
export declare function getItemTypeHandler(itemType: string): ItemTypeHandler<any, any, any>;
|
|
82
|
+
export declare function hasItemTypeHandler(itemType: string): boolean;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { FormWidget, UiState } from '@golemui/core';
|
|
2
|
+
import { FormConfig, GslSelector, ValidGuiShortcut } from './dx.domain';
|
|
3
|
+
import { SelectorResolver } from './selectorResolver.service';
|
|
4
|
+
import { WidgetMerger } from './widgetMerger.service';
|
|
5
|
+
import { WidgetMapper } from './widgetMapper.service';
|
|
6
|
+
import { EventRegistry } from './itemTypeRegistry';
|
|
7
|
+
import { EventWiringService } from './eventWiring.service';
|
|
8
|
+
import { StateExpansionService } from './stateExpansion.service';
|
|
9
|
+
export interface WalkResult<StateKeys extends UiState = never, FormData extends Record<string, any> = any> {
|
|
10
|
+
widgets: FormWidget<StateKeys, FormData>[];
|
|
11
|
+
eventRegistry: EventRegistry;
|
|
12
|
+
}
|
|
13
|
+
export declare class ItemWalker {
|
|
14
|
+
private readonly resolver;
|
|
15
|
+
private readonly merger;
|
|
16
|
+
private readonly mapper;
|
|
17
|
+
private readonly eventWiring;
|
|
18
|
+
private readonly stateExpansion;
|
|
19
|
+
constructor(resolver: SelectorResolver, merger: WidgetMerger, mapper: WidgetMapper, eventWiring: EventWiringService, stateExpansion: StateExpansionService);
|
|
20
|
+
walkAndMap<StateKeys extends UiState = never, FormData extends Record<string, any> = any>(guiShortcuts: ValidGuiShortcut[], gslSelectors: GslSelector[], formConfig: FormConfig): WalkResult<StateKeys, FormData>;
|
|
21
|
+
private walkItems;
|
|
22
|
+
private processItem;
|
|
23
|
+
private buildCustomWidgetContext;
|
|
24
|
+
private buildCustomWidget;
|
|
25
|
+
/**
|
|
26
|
+
* Resolves the base definition from a parsed entry, injecting the path for keyed entries.
|
|
27
|
+
* For runtime (function) providers, wraps them to inject the path at evaluation time.
|
|
28
|
+
*/
|
|
29
|
+
private buildBaseDef;
|
|
30
|
+
private buildDecoratorForMatching;
|
|
31
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FormConfig, GslSelector, GslSelectorsInput } from './dx.domain';
|
|
2
|
+
export declare class SelectorNormalizer {
|
|
3
|
+
/**
|
|
4
|
+
* Ensures the output is always a uniform GslSelector[] of aggregated selectors.
|
|
5
|
+
*
|
|
6
|
+
* Callers can pass flat leaf selectors (single styling rules) or pre-grouped
|
|
7
|
+
* aggregated selectors. This method separates them into two buckets, then wraps
|
|
8
|
+
* any bare leaves into a catch-all aggregated selector so downstream code only
|
|
9
|
+
* deals with one shape.
|
|
10
|
+
*/
|
|
11
|
+
normalizeSelectors(input: GslSelectorsInput): GslSelector[];
|
|
12
|
+
extractFormConfig(): FormConfig;
|
|
13
|
+
}
|
|
14
|
+
declare const selectorNormalizer: SelectorNormalizer;
|
|
15
|
+
export default selectorNormalizer;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GslSelector, ResolvedSelectors } from './dx.domain';
|
|
2
|
+
import { DxCommonFields, DxInternalFields } from './dxBase.types';
|
|
3
|
+
type DecoratorForMatching = DxInternalFields & DxCommonFields;
|
|
4
|
+
export declare class SelectorResolver {
|
|
5
|
+
resolve(decorator: DecoratorForMatching, allSelectors: GslSelector[]): ResolvedSelectors;
|
|
6
|
+
private collectFromAggregated;
|
|
7
|
+
private collectFromLeaf;
|
|
8
|
+
private rollUpSensibleDefaults;
|
|
9
|
+
}
|
|
10
|
+
declare const selectorResolver: SelectorResolver;
|
|
11
|
+
export default selectorResolver;
|