@golemui/gui-shared 0.17.0 → 1.0.0-rc.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 +4 -0
- package/index.d.ts +1 -8
- package/index.js +209 -729
- package/index.umd.cjs +1 -1
- package/internals.d.ts +8 -1
- package/internals.js +721 -10
- package/internals.umd.cjs +1 -1
- package/package.json +3 -3
- package/register-BCL1xvhN.js +1399 -0
- package/register-CjTULX-4.cjs +1 -0
- package/resolveFormInput-BkRkdOqj.cjs +0 -1
- package/resolveFormInput-DoBisQ5Q.js +0 -1542
package/internals.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./resolveFormInput-BkRkdOqj.cjs");function n(e,t){if(e!=null&&typeof e=="object"&&"__rid"in e)return e.__rid;const r=t();return Object.defineProperty(e,"__rid",{value:r,enumerable:!1,configurable:!1}),r}exports.resolveFormInput=o.resolveFormInput;exports.getItemKey=n;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./register-CjTULX-4.cjs");require("@golemui/core");require("@golemui/gui-validators");function E(a,...e){return e.map(t=>({...t,targetState:a}))}function v(a,...e){return{kind:"aggregated",matcher:t=>t.tags?.includes(a)??!1,children:e}}const B={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","TAGS"]),ACTIONS:new Set(["ACTIONS","CUSTOM_ACTION"]),DISPLAYS:new Set(["DISPLAYS","ALERTS","MARKDOWN_TEXTS","CUSTOM_DISPLAY"]),LAYOUTS:new Set(["LAYOUTS","TABS","ACCORDION","CUSTOM_LAYOUT"])};function P(a,e){const t=B[a];return t?t.has(e):a===e}class L{resolve(e,t){const i=[];for(const r of t)r.kind==="aggregated"?this.collectFromAggregated(r,e,i):this.collectFromLeaf(r,e,i);const n=this.rollUpSensibleDefaults(i);return{leafSelectors:i,sensibleDefaults:n}}collectFromAggregated(e,t,i){if(e.matcher(t))for(const n of e.children)this.collectFromLeaf(n,t,i)}collectFromLeaf(e,t,i){P(e.selectorType,t.itemType??"")&&e.matcher(t)&&i.push(e)}rollUpSensibleDefaults(e){const t=new Map,i=(r,o)=>{const l=t.get(r)??[];l.push(o),t.set(r,l)};for(const r of e){const o=B[r.selectorType];if(o)for(const l of o)i(l,r);else i(r.selectorType,r)}const n={};for(const[r,o]of t)s.hasItemTypeHandler(r)&&(n[r]=s.getItemTypeHandler(r).rollUpSensibleDefaults(o));return n}}const F=new L;class j{deepMerge(e,t){if(t==null)return e;if(e==null||typeof e!="object"||typeof t!="object"||Array.isArray(e)||Array.isArray(t))return t;const i={...e};for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(typeof t[n]=="object"&&!Array.isArray(t[n])&&t[n]!==null&&typeof e[n]=="object"&&!Array.isArray(e[n])&&e[n]!==null?i[n]=this.deepMerge(e[n],t[n]):i[n]=t[n]);return i}}const N=new j;class W{constructor(e){this.objectUtils=e}merge(e,t,i){let n={},r=null;typeof e=="function"&&(r=e);const o=this.collectDecorators(i);for(const c of o){if(r!=null){r=this.composeRuntimeFunctions(r,c);continue}if(typeof c=="function"){const g=c({...n,...typeof e=="function"?{}:e});if(typeof g=="function"){r=this.createPromotedFunction(n,e,g,t,i);continue}n=this.objectUtils.deepMerge(n,g)}else n=this.objectUtils.deepMerge(n,c)}if(r!=null)return{kind:"dynamic",fn:this.wrapWithSensibleDefaults(r,n,t,i)};const l=this.objectUtils.deepMerge(e,n);return{kind:"static",def:this.applySensibleDefaults({...l},t,i)}}collectDecorators(e){const t=[];for(const i of e.leafSelectors){const n=i.config;n.override!=null&&t.push(n.override)}return t}applySensibleDefaults(e,t,i){if(!s.hasItemTypeHandler(t))return e;const n=i.sensibleDefaults[t]??{};return s.getItemTypeHandler(t).applySensibleDefaults(e,n)}createPromotedFunction(e,t,i,n,r){return o=>{const l=i(o);let u=this.objectUtils.deepMerge(e,l);return u=this.objectUtils.deepMerge(u,t),this.applySensibleDefaults(u,n,r)}}wrapWithSensibleDefaults(e,t,i,n){return r=>{let o=e(r);return Object.keys(t).length>0&&(o=this.objectUtils.deepMerge(t,o)),this.applySensibleDefaults(o,i,n)}}composeRuntimeFunctions(e,t){return typeof t=="function"?i=>{const n=e(i),r=t(n);return typeof r=="function"?r(i):this.objectUtils.deepMerge(r,n)}:i=>{const n=e(i);return this.objectUtils.deepMerge(n,t)}}}const z=new W(N);class G{mapToWidget(e,t){if(e.kind==="dynamic"){const i=e.fn;return(n=>{const r=i(n);return this.mapStaticDef(r,t)})}return this.mapStaticDef(e.def,t)}mapStaticDef(e,t){const i=s.getItemTypeHandler(t).mapToWidget(e);return this.applyBaseWidgetFields(i,e)}applyBaseWidgetFields(e,t){return t.size!=null&&(e.size=t.size),t.defaultValue!=null&&e.kind==="input"&&(e.defaultValue=t.defaultValue),t.on!=null&&(e.on=t.on),t.include!=null&&(e.include=t.include),t.exclude!=null&&(e.exclude=t.exclude),e}}const K=new G;class H{normalizeSelectors(e){const t=Array.isArray(e)?e:[e],i=[],n=[];for(const r of t)r.kind==="leaf"?n.push(r):i.push(r);return n.length>0&&i.unshift({kind:"aggregated",matcher:()=>!0,children:n}),i}extractFormConfig(){return{suppressAutomaticStack:!1}}}const V=new H,$={input:new Set(["disabled","readonly","label","validator","size"]),action:new Set(["disabled","label","size"]),layout:new Set(["size"]),display:new Set([])},D={onChange:"change",onLoad:"load",onFilter:"filter",onClick:"click"};class Y{extractFromMergeResult(e,t){const i={};for(const l of t){const u=l.targetState,c=l.config,g=c.override&&typeof c.override!="function"?c.override:c;i[u]={...i[u]||{},...g}}if(e.kind==="dynamic"){const l=e.fn;return{cleanedResult:{kind:"dynamic",fn:c=>{const g=l(c),{states:d,..._}=g;return _}},stateData:{stateOverrides:i}}}const{states:n,...r}=e.def,o={};for(const[l,u]of Object.entries(i))o[l]={...u};if(n)for(const[l,u]of Object.entries(n))o[l]={...o[l]||{},...u};return{cleanedResult:{kind:"static",def:r},stateData:{stateOverrides:o}}}applyToWidget(e,t,i,n){const{stateOverrides:r}=t;if(Object.keys(r).length===0)return e;const o={...e},l=e.kind,u=$[l]||new Set;e.props&&(o.props={...e.props}),e.on&&(o.on={...e.on});for(const[c,g]of Object.entries(r))for(const[d,_]of Object.entries(g))d==="visible"?this.applyVisibility(o,c,_):D[d]?this.applyStateEvent(o,c,d,_,i,n):u.has(d)?o[`${d}.${c}`]=_:(o.props||(o.props={}),o.props[`${d}.${c}`]=_);return o}hasStateData(e){return Object.keys(e.stateOverrides).length>0}applyVisibility(e,t,i){if(i){const n=e.include?.in||[];e.include={...e.include||{},in:[...n,t]}}else{const n=e.exclude?.from||[];e.exclude={...e.exclude||{},from:[...n,t]}}}applyStateEvent(e,t,i,n,r,o){const l=D[i];if(e.on||(e.on={}),typeof n=="function"){const u=o.next();r.set(u,n),e.on[`${l}.${t}`]=u}else typeof n=="string"&&(e.on[`${l}.${t}`]=n)}}const X=new Y;function q(){let a=0;return{next:()=>`event_${a++}`}}class J{constructor(e,t,i,n,r){this.resolver=e,this.merger=t,this.mapper=i,this.eventWiring=n,this.stateExpansion=r}walkAndMap(e,t,i){const n=new Map,r=q(),o={value:0},l=new Set;return{widgets:this.walkItems(e,t,n,i,r,o,l),eventRegistry:n}}walkItems(e,t,i,n,r,o,l){return e.flatMap(u=>{if(u.type!=="ITEMS")throw new Error("Unexpected gui shortcut type");return u.items.map(c=>this.processItem(c,u.itemType,u.tags,t,i,n,r,o,l))})}processItem(e,t,i,n,r,o,l,u,c){const g=t,d=s.getItemTypeHandler(t),_=d.parseEntry(e),m=this.buildBaseDef(_),k=this.buildDecoratorForMatching(m,g,i),h=this.resolver.resolve(k,n),x=h.leafSelectors.filter(p=>p.targetState!=null),O={leafSelectors:h.leafSelectors.filter(p=>p.targetState==null),sensibleDefaults:h.sensibleDefaults};let f=this.merger.merge(m,g,O);d.afterMerge&&(f=d.afterMerge(f,{eventRegistry:r,formConfig:o,eventIdGenerator:l})),f=this.eventWiring.wireInputLayoutEvents(f,r,l);const{cleanedResult:b,stateData:S}=this.stateExpansion.extractFromMergeResult(f,x);let y;if(d.buildCustomWidget){const p=this.buildCustomWidgetContext(_.children,n,r,o,l,u,c);y=this.buildCustomWidget(d,b,p)}else y=this.mapper.mapToWidget(b,g);if(typeof y!="function"){const p=y;p.uid||(p.path&&!c.has(p.path)?(p.uid=p.path,c.add(p.path)):p.uid=`dx_${u.value++}`)}if(this.stateExpansion.hasStateData(S))if(typeof y=="function"){const p=y;y=(w=>{const M=p(w);return this.stateExpansion.applyToWidget(M,S,r,l)})}else y=this.stateExpansion.applyToWidget(y,S,r,l);return y}buildCustomWidgetContext(e,t,i,n,r,o,l){return{children:e,mapStaticDef:(u,c)=>this.mapper.mapStaticDef(u,c),walkChildren:u=>this.walkItems(u,t,i,n,r,o,l)}}buildCustomWidget(e,t,i){return e.buildCustomWidget(t,i)}buildBaseDef(e){const t=e.baseDef;return typeof t=="function"?i=>{const r=t(i??{});return e.path!=null?{...r,path:e.path}:r}:e.path!=null?{...t,path:e.path}:t}buildDecoratorForMatching(e,t,i){if(typeof e=="function")return{itemType:t,tags:[...i]};const n=[...i,..."tags"in e&&e.tags?e.tags:[]],r="uid"in e?e.uid:void 0,o="type"in e?e.type:void 0;return{itemType:t,tags:n,uid:r,type:o}}}class Q{constructor(e,t){this.selectorNormalizer=e,this.walker=t}processDxFacade(e,t=[],i){const{defs:n,gslSelectors:r,formConfig:o}=this.prepareForm(e,t,i),{widgets:l,eventRegistry:u}=this.walker.walkAndMap(n,r,o),c=l[0];return this.buildResult({form:c},u,o)}prepareForm(e,t,i){const r=(Array.isArray(e)?[...e]:[e]).map(u=>typeof u=="function"?s._guiDisplay(u):u),o=this.selectorNormalizer.normalizeSelectors(t),l={...this.selectorNormalizer.extractFormConfig(),...i};if(!l.suppressAutomaticStack){const u={def:{uid:"#root",direction:"column",widgetName:"flex"},children:r};return{defs:[{type:"ITEMS",itemType:s.GuiItemTypes.LAYOUTS,items:[u],tags:[]}],gslSelectors:o,formConfig:l}}return{defs:r,gslSelectors:o,formConfig:l}}convertStateNames(e){const t={};for(const[i,n]of Object.entries(e))t[i.replace(/\$/g,":")]=n;return t}buildResult(e,t,i){i.states&&Object.keys(i.states).length>0&&(e={...e,states:this.convertStateNames(i.states)});const n={form:e};return t.size>0&&(n.events=r=>{const o=t.get(r.name);if(o){const l=c=>{if(c&&typeof c=="object"&&"path"in c&&!("type"in c)){const{path:g,...d}=c;for(const[_,m]of Object.entries(d))r.callback({type:"OVERRIDE_WIDGET_PROP",payload:{path:g,prop:_,value:m}})}else r.callback(c)},u={...r,callback:l,update:l};o(u)}}),i.dependencies&&(n.dependencies=i.dependencies),i.widgetLoaders&&(n.widgetLoaders=i.widgetLoaders),i.validateOn&&(n.validateOn=i.validateOn),i.itemRenderers&&(n.itemRenderers=i.itemRenderers),n}}const Z=new J(F,z,K,s.eventWiringService,X),C=new Q(V,Z);function R(a){return typeof a=="function"?!0:Array.isArray(a)?a.length===0||a.every(T):T(a)}function T(a){if(typeof a=="function")return!0;if(a===null||typeof a!="object")return!1;const e=a;return e.type==="ITEMS"&&typeof e.itemType=="string"}const I=Object.freeze({}),ee=Object.freeze({}),A=new WeakMap;function U(a,e){return a==null?e:typeof a=="object"?a:{}}function te(a,e,t){if(!R(a))return{formDef:a};const i=U(a,I),n=U(e,I),r=U(t,ee);let o=A.get(i);o||(o=new WeakMap,A.set(i,o));let l=o.get(n);l||(l=new WeakMap,o.set(n,l));const u=l.get(r);if(u)return u;const c=C.processDxFacade(a,e,t),g={formDef:c.form,formEvent:c.events,dependencies:c.dependencies,widgetLoaders:c.widgetLoaders,validateOn:c.validateOn,itemRenderers:c.itemRenderers};return l.set(r,g),g}class se{create(e){return{states:e.states,form:{uid:"gui-root-uid",type:"flex",kind:"layout",children:e.form}}}}function ne(){return new se}const ie=a=>a!==null&&typeof a=="object"&&Object.prototype.hasOwnProperty.call(a,"label")&&Object.prototype.hasOwnProperty.call(a,"value");function re(a,e){if(a!=null&&typeof a=="object"&&"__rid"in a)return a.__rid;const t=e();return Object.defineProperty(a,"__rid",{value:t,enumerable:!1,configurable:!1}),t}exports._gslAccordionByUid=s._gslAccordionByUid;exports._gslAccordions=s._gslAccordions;exports._gslActionByUid=s._gslActionByUid;exports._gslActions=s._gslActions;exports._gslAlertByUid=s._gslAlertByUid;exports._gslAlerts=s._gslAlerts;exports._gslBooleanInputs=s._gslBooleanInputs;exports._gslCalendarByUid=s._gslCalendarByUid;exports._gslCalendars=s._gslCalendars;exports._gslCheckboxByUid=s._gslCheckboxByUid;exports._gslCheckboxes=s._gslCheckboxes;exports._gslCurrencies=s._gslCurrencies;exports._gslCurrencyByUid=s._gslCurrencyByUid;exports._gslCustomActionByUid=s._gslCustomActionByUid;exports._gslCustomActions=s._gslCustomActions;exports._gslCustomDisplayByUid=s._gslCustomDisplayByUid;exports._gslCustomDisplays=s._gslCustomDisplays;exports._gslCustomInputByUid=s._gslCustomInputByUid;exports._gslCustomInputs=s._gslCustomInputs;exports._gslCustomLayoutByUid=s._gslCustomLayoutByUid;exports._gslCustomLayouts=s._gslCustomLayouts;exports._gslDateInputByUid=s._gslDateInputByUid;exports._gslDateInputs=s._gslDateInputs;exports._gslDatePickerByUid=s._gslDatePickerByUid;exports._gslDatePickers=s._gslDatePickers;exports._gslDisplayByUid=s._gslDisplayByUid;exports._gslDisplays=s._gslDisplays;exports._gslDropdownByUid=s._gslDropdownByUid;exports._gslDropdowns=s._gslDropdowns;exports._gslInputByUid=s._gslInputByUid;exports._gslInputs=s._gslInputs;exports._gslLayoutByUid=s._gslLayoutByUid;exports._gslLayouts=s._gslLayouts;exports._gslListByUid=s._gslListByUid;exports._gslLists=s._gslLists;exports._gslMarkdownByUid=s._gslMarkdownByUid;exports._gslMarkdownTextByUid=s._gslMarkdownTextByUid;exports._gslMarkdownTexts=s._gslMarkdownTexts;exports._gslMarkdowns=s._gslMarkdowns;exports._gslNumberInputs=s._gslNumberInputs;exports._gslPasswordByUid=s._gslPasswordByUid;exports._gslPasswords=s._gslPasswords;exports._gslRadiogroupByUid=s._gslRadiogroupByUid;exports._gslRadiogroups=s._gslRadiogroups;exports._gslRangeCalendarByUid=s._gslRangeCalendarByUid;exports._gslRangeCalendars=s._gslRangeCalendars;exports._gslRangeDateInputByUid=s._gslRangeDateInputByUid;exports._gslRangeDateInputs=s._gslRangeDateInputs;exports._gslRangeDatePickerByUid=s._gslRangeDatePickerByUid;exports._gslRangeDatePickers=s._gslRangeDatePickers;exports._gslRepeaterByUid=s._gslRepeaterByUid;exports._gslRepeaters=s._gslRepeaters;exports._gslSelectByUid=s._gslSelectByUid;exports._gslSelects=s._gslSelects;exports._gslTabs=s._gslTabs;exports._gslTabsByUid=s._gslTabsByUid;exports._gslTags=s._gslTags;exports._gslTagsByUid=s._gslTagsByUid;exports._gslTextInputs=s._gslTextInputs;exports._gslTextareaByUid=s._gslTextareaByUid;exports._gslTextareas=s._gslTextareas;exports._guiAccordion=s._guiAccordion;exports._guiAlert=s._guiAlert;exports._guiBooleanInput=s._guiBooleanInput;exports._guiButton=s._guiButton;exports._guiCalendar=s._guiCalendar;exports._guiCheckbox=s._guiCheckbox;exports._guiCurrency=s._guiCurrency;exports._guiCustomAction=s._guiCustomAction;exports._guiCustomDisplay=s._guiCustomDisplay;exports._guiCustomInput=s._guiCustomInput;exports._guiCustomLayout=s._guiCustomLayout;exports._guiDateInput=s._guiDateInput;exports._guiDatePicker=s._guiDatePicker;exports._guiDisplay=s._guiDisplay;exports._guiDropdown=s._guiDropdown;exports._guiFlex=s._guiFlex;exports._guiGrid=s._guiGrid;exports._guiHorizontalFlex=s._guiHorizontalFlex;exports._guiHorizontalGrid=s._guiHorizontalGrid;exports._guiList=s._guiList;exports._guiMarkdown=s._guiMarkdown;exports._guiMarkdownText=s._guiMarkdownText;exports._guiNumberInput=s._guiNumberInput;exports._guiPassword=s._guiPassword;exports._guiRadiogroup=s._guiRadiogroup;exports._guiRangeCalendar=s._guiRangeCalendar;exports._guiRangeDateInput=s._guiRangeDateInput;exports._guiRangeDatePicker=s._guiRangeDatePicker;exports._guiRepeater=s._guiRepeater;exports._guiSelect=s._guiSelect;exports._guiTabs=s._guiTabs;exports._guiTags=s._guiTags;exports._guiTextInput=s._guiTextInput;exports._guiTextarea=s._guiTextarea;exports._guiVerticalFlex=s._guiVerticalFlex;exports._guiVerticalGrid=s._guiVerticalGrid;exports.createGslSelector=s.createGslSelector;exports.defineShortcutType=s.defineShortcutType;exports.extractWidgetProps=s.extractWidgetProps;exports.processAutoLabel=s.processAutoLabel;exports.processAutoPlaceholder=s.processAutoPlaceholder;exports._gslStates=E;exports._gslTag=v;exports.formDefs=C;exports.getItemKey=re;exports.golemForm=ne;exports.isDxDefinitions=R;exports.isOption=ie;exports.resolveFormInput=te;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@golemui/gui-shared",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-rc.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.umd.cjs",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"*.md"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@golemui/core": "0.
|
|
34
|
-
"@golemui/gui-validators": "0.
|
|
33
|
+
"@golemui/core": "1.0.0-rc.0",
|
|
34
|
+
"@golemui/gui-validators": "1.0.0-rc.0"
|
|
35
35
|
},
|
|
36
36
|
"repository": {
|
|
37
37
|
"type": "git",
|