@sankhyalabs/ezui 5.22.0-dev.2 → 5.22.0-dev.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{RecordValidationProcessor-4c893e04.js → RecordValidationProcessor-10846595.js} +7 -1
- package/dist/cjs/ez-custom-form-input_2.cjs.entry.js +31 -4
- package/dist/cjs/ez-form-view.cjs.entry.js +3 -2
- package/dist/cjs/ez-form.cjs.entry.js +7 -3
- package/dist/cjs/ez-grid.cjs.entry.js +264 -20
- package/dist/cjs/ez-modal-container.cjs.entry.js +2 -1
- package/dist/cjs/ez-modal.cjs.entry.js +7 -1
- package/dist/cjs/ez-multi-selection-list.cjs.entry.js +1 -1
- package/dist/cjs/ez-popup.cjs.entry.js +9 -2
- package/dist/cjs/ez-search.cjs.entry.js +6 -3
- package/dist/cjs/ez-tabselector.cjs.entry.js +8 -2
- package/dist/cjs/ezui.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/ez-form-view/custom-input/ez-custom-form-input.js +45 -5
- package/dist/collection/components/ez-form-view/fieldbuilder/templates/SearchInput.tpl.js +3 -2
- package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +106 -8
- package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +83 -5
- package/dist/collection/components/ez-grid/controller/ag-grid/GridEditionManager.js +58 -7
- package/dist/collection/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.js +8 -0
- package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/Search.tpl.js +1 -0
- package/dist/collection/components/ez-grid/controller/ag-grid/test/constants/GridEditionMock.js +1 -0
- package/dist/collection/components/ez-grid/ez-grid.js +45 -0
- package/dist/collection/components/ez-modal/ez-modal.js +25 -1
- package/dist/collection/components/ez-modal-container/ez-modal-container.js +20 -1
- package/dist/collection/components/ez-multi-selection-list/ez-multi-selection-list.js +1 -1
- package/dist/collection/components/ez-popup/ez-popup.css +5 -1
- package/dist/collection/components/ez-popup/ez-popup.js +26 -1
- package/dist/collection/components/ez-search/ez-search.js +24 -3
- package/dist/collection/components/ez-tabselector/ez-tabselector.js +34 -2
- package/dist/collection/utils/form/DataBinder.js +7 -3
- package/dist/collection/utils/validators/recordvalidator/IInvalidCells.js +1 -0
- package/dist/collection/utils/validators/recordvalidator/RecordValidationProcessor.js +7 -1
- package/dist/custom-elements/index.js +349 -44
- package/dist/esm/{RecordValidationProcessor-b00b8b77.js → RecordValidationProcessor-9c6cc267.js} +7 -1
- package/dist/esm/ez-custom-form-input_2.entry.js +32 -5
- package/dist/esm/ez-form-view.entry.js +3 -2
- package/dist/esm/ez-form.entry.js +8 -4
- package/dist/esm/ez-grid.entry.js +264 -20
- package/dist/esm/ez-modal-container.entry.js +2 -1
- package/dist/esm/ez-modal.entry.js +7 -1
- package/dist/esm/ez-multi-selection-list.entry.js +1 -1
- package/dist/esm/ez-popup.entry.js +9 -2
- package/dist/esm/ez-search.entry.js +6 -3
- package/dist/esm/ez-tabselector.entry.js +8 -2
- package/dist/esm/ezui.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/ezui/ezui.esm.js +1 -1
- package/dist/ezui/p-08061683.entry.js +1 -0
- package/dist/ezui/p-34b6916c.entry.js +1 -0
- package/dist/ezui/p-42533ea4.entry.js +1 -0
- package/dist/ezui/p-4d64a3e4.entry.js +1 -0
- package/dist/ezui/{p-816cece6.entry.js → p-a9156fef.entry.js} +2 -2
- package/dist/ezui/p-c0d9c4f8.entry.js +1 -0
- package/dist/ezui/p-c36b7c56.entry.js +1 -0
- package/dist/ezui/p-cdc472cc.entry.js +1 -0
- package/dist/ezui/p-e26f12dd.entry.js +1 -0
- package/dist/ezui/p-f42855b9.js +1 -0
- package/dist/ezui/p-f9e551de.entry.js +1 -0
- package/dist/types/components/ez-form-view/custom-input/ez-custom-form-input.d.ts +7 -1
- package/dist/types/components/ez-form-view/fieldbuilder/templates/SearchInput.tpl.d.ts +1 -1
- package/dist/types/components/ez-grid/controller/EzGridController.d.ts +32 -4
- package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +19 -3
- package/dist/types/components/ez-grid/controller/ag-grid/DataSource.d.ts +18 -0
- package/dist/types/components/ez-grid/controller/ag-grid/GridEditionManager.d.ts +13 -2
- package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.d.ts +1 -0
- package/dist/types/components/ez-grid/ez-grid.d.ts +9 -0
- package/dist/types/components/ez-modal/ez-modal.d.ts +5 -0
- package/dist/types/components/ez-modal-container/ez-modal-container.d.ts +4 -0
- package/dist/types/components/ez-popup/ez-popup.d.ts +6 -0
- package/dist/types/components/ez-search/ez-search.d.ts +4 -0
- package/dist/types/components/ez-tabselector/ez-tabselector.d.ts +2 -1
- package/dist/types/components.d.ts +49 -0
- package/dist/types/utils/customEditor/interfaces/ICustomEditor.d.ts +2 -0
- package/dist/types/utils/form/DataBinder.d.ts +2 -0
- package/dist/types/utils/validators/recordvalidator/IInvalidCells.d.ts +5 -0
- package/dist/types/utils/validators/recordvalidator/RecordValidationProcessor.d.ts +1 -1
- package/package.json +1 -1
- package/dist/ezui/p-04f24913.js +0 -1
- package/dist/ezui/p-12ae1104.entry.js +0 -1
- package/dist/ezui/p-2dcb50d4.entry.js +0 -1
- package/dist/ezui/p-30775e7f.entry.js +0 -1
- package/dist/ezui/p-4d5235f1.entry.js +0 -1
- package/dist/ezui/p-5056284a.entry.js +0 -1
- package/dist/ezui/p-784fe207.entry.js +0 -1
- package/dist/ezui/p-9ab22a07.entry.js +0 -1
- package/dist/ezui/p-d9401ea0.entry.js +0 -1
- package/dist/ezui/p-f3c526cc.entry.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,c as i,h as e,f as s,H as n,g as r}from"./p-23a36bb6.js";import{DateUtils as o,Action as h,StringUtils as a,ApplicationContext as c,WaitingChangeException as l,DataUnitAction as u,DataUnit as d,ElementIDUtils as f}from"@sankhyalabs/core";import{b as v,R as _}from"./p-f42855b9.js";import"./p-2187f86c.js";import"./p-ab574d59.js";const p=/child\[([^\]]+)\]/,b=/\$\{.+\}/;class m{constructor(){this._sheets=new Map,this._requiredFields=[],this._cleanOnCopyFields=[],this._defaultValues={}}static getDetailName(t){const i=p.exec(t);return i?i[1]:void 0}getSheet(t){return this._sheets.get(t)}getAllSheets(){return this._sheets}addSheet(t){this._sheets.set(t.name,t)}addRequiredFields(t){this._requiredFields=this._requiredFields.concat(t)}getRequiredFields(){return this._requiredFields}addCleanOnCopyFields(t){this._cleanOnCopyFields=this._cleanOnCopyFields.concat(t)}getCleanOnCopyFields(){return this._cleanOnCopyFields}addDefaultValues(t){return this._defaultValues=Object.assign(Object.assign({},this._defaultValues),t)}getDefaultValues(){const t={};return Object.entries(this._defaultValues).forEach((([i,e])=>{if("string"==typeof e){const t=b.exec(e);t&&(e=this.getDefaultVar(t[0]))}t[i]=e})),t}getDefaultVar(t){return"${data}"===t?o.getToday():"${datahora}"===t?o.getToday(!0):this._defaultVars?this._defaultVars.get(t):void 0}setDefaultVars(t){this._defaultVars=t}}const y=(t,i)=>"__main"==t[0].label?-1:(t[0].order||1e4)-(i[0].order||1e4);class w{constructor(t){this.onDataUnitEvent=t=>{var i,e;switch(t.type){case h.DATA_LOADED:case h.DATA_SAVED:case h.RECORDS_REMOVED:case h.RECORDS_ADDED:case h.RECORDS_COPIED:case h.EDITION_CANCELED:case h.SELECTION_CHANGED:case h.NEXT_SELECTED:case h.PREVIOUS_SELECTED:this.clearInvalid();case h.DATA_CHANGED:case h.CHANGE_UNDONE:case h.CHANGE_REDONE:case h.RECORD_LOADED:null===(i=this._fields)||void 0===i||i.forEach((t=>{this.updateValue(t.fieldName,t.field)}));break;case h.FIELD_INVALIDATED:null===(e=this._fields)||void 0===e||e.forEach((t=>{this.updateErrorMessage(t.fieldName,t.field)}))}},this._uuid=a.generateUUID(),this._fields=new Map,this._dataUnit=t,this.applyDefaultValues(),this._dataUnit.subscribe(this.onDataUnitEvent),this._dataUnit.addInterceptor(this),this.setContextDataBinder(t)}get dataBinderId(){return this._uuid}setContextDataBinder(t){const i=c.getContextValue("__DATABINDER_BY_DATAUNIT__")||new Map,e=[...i.get(t.dataUnitId)||[],this];i.set(t.dataUnitId,e),c.setContextValue("__DATABINDER_BY_DATAUNIT__",i)}applyDefaultValues(){const t=(this._dataUnit.getAddedRecords()||[]).map((t=>t.__record__id__));if(t.length>0){const i=this.getDefaultValues();i&&Object.keys(i).forEach((e=>{this._dataUnit.setFieldValue(e,i[e],t)}))}}bind(t,i,e,s){t.forEach((t=>{const{fieldName:e,contextName:s}=t.dataset;null!=s&&s!==i||this.updateBind(e,t)})),this._formMetadata=e,this._recordValidatorProcessor=new _(this._dataUnit,{getRequiredFields:()=>this._formMetadata.getRequiredFields(),markAsInvalid:t=>this.markInvalid(t),getMessageForField:t=>this.getErrorMessage(t)},s)}disconnectDataUnit(){const t=c.getContextValue("__DATABINDER_BY_DATAUNIT__")||new Map,i=t.get(this._dataUnit.dataUnitId).filter((t=>t.dataBinderId!==this.dataBinderId));t.set(this._dataUnit.dataUnitId,i),c.setContextValue("__DATABINDER_BY_DATAUNIT__",t)}onDisconnectedCallback(){this._dataUnit.unsubscribe(this.onDataUnitEvent),this._dataUnit.removeInterceptor(this),this.disconnectDataUnit()}getCurrentRecordId(){const t=this._dataUnit.getSelectedRecord();return null==t?void 0:t.__record__id__}markInvalid(t){if(this._fields.has(t.name)){const i=this._fields.get(t.name).field;this.updateErrorMessage(t.name,i,t.message)}}setFocus(t){if(!this._fields.has(t))return;const i=this._fields.get(t).field;"function"==typeof i.setFocus&&i.setFocus()}clearInvalid(t){this._dataUnit.clearInvalid(t),this._fields.forEach((t=>{t.field.errorMessage=""}))}updateValue(t,i){const e=this._fields.get(t);try{e&&(e.listen=!1),i.value=this._dataUnit.getFieldValue(t),this.updateErrorMessage(t,i)}finally{e&&(e.listen=!0)}}validate(){return this._recordValidatorProcessor.validate()}static async validateByDataunit(t){try{const i=c.getContextValue("__DATABINDER_BY_DATAUNIT__").get(t.dataUnitId)||[];return await Promise.all(i.map((t=>t.validate()))),!0}catch(t){return!1}}updateErrorMessage(t,i,e){null==e&&(e=this._dataUnit.getInvalidMessage(this.getCurrentRecordId(),t)),i.errorMessage||(i.errorMessage=e)}getErrorMessage(t){if(this._fields.has(t))return this._fields.get(t).field.errorMessage}updateBind(t,i){const e=this._fields.get(t);e&&e.destroy(),i.value=this._dataUnit.getFieldValue(t),this.updateErrorMessage(t,i),this._fields.set(t,A.create(t,i,((t,i)=>this.changeStarted(t,i)),(t=>this.cancelWaitingChange(t)),((t,i)=>this.setFieldValue(t,i)))),this.bindSearchOptionsLoader(t,i),this.applyEzUploadContext(t,i)}changeStarted(t,i){if(0===this._dataUnit.records.length&&this._dataUnit.addRecord(),!i.blocking&&null==i.promise){const e=this._fields.get(t);e&&(i.promise=new Promise(((t,i)=>{e.waitingChangePromiseResolve=t,e.waitingChangePromiseReject=i})))}this._dataUnit.startChange(t,i)}cancelWaitingChange(t){if(this._dataUnit.waitingForChange(t)){this._dataUnit.cancelWaitingChange(t);const i=this._fields.get(t);i&&i.rejectWaitingChange(new l("Change canceled",t))}}setFieldValue(t,i){0===this._dataUnit.records.length&&this._dataUnit.addRecord(),this._dataUnit.clearInvalid(this.getCurrentRecordId(),t);const e=this._dataUnit.getSelectedRecord();if(this._dataUnit.setFieldValue(t,i,e?[e.__record__id__]:void 0),this._dataUnit.waitingForChange(t)){const i=this._fields.get(t);i&&i.acceptWaitingChange()}}bindSearchOptionsLoader(t,i){if("EZ-SEARCH"===i.nodeName&&null==i.optionLoader){const e=c.getContextValue("__EZUI__SEARCH__OPTION__LOADER__");e&&(i.optionLoader=i=>e(i,t,this._dataUnit))}}applyEzUploadContext(t,i){var e,s;if("EZ-UPLOAD"===i.nodeName){i.urlUpload=c.getContextValue("__EZUI__UPLOAD__ADD__URL__"),i.urlDelete=c.getContextValue("__EZUI__UPLOAD__DEL__URL__");const n=this._dataUnit.getField(t),r=null===(e=n.properties)||void 0===e?void 0:e.DESTINATION;r&&(i.requestHeaders={XTRAINF:`{"destination": "${r}"}`}),i.maxFiles=(null===(s=n.properties)||void 0===s?void 0:s.MAX_FILES)||0}}interceptAction(t){if(t.type===h.RECORDS_COPIED){const i=this._formMetadata.getCleanOnCopyFields();if(i)return new u(h.RECORDS_COPIED,t.payload.map((t=>{const e=Object.assign({},t);return i.forEach((t=>delete e[t])),e})))}if(t.type===h.SAVING_DATA)return new Promise((i=>{this.validate().then((()=>i(t))).catch((()=>{}))}));if(t.type===h.RECORDS_ADDED){const i=this.getDefaultValues();if(i)return new u(h.RECORDS_ADDED,t.payload.map((t=>Object.assign(Object.assign({},t),i))))}return t}getDefaultValues(){var t;const i=null===(t=this._formMetadata)||void 0===t?void 0:t.getDefaultValues();if(i){const t={};for(const e in i)t[e]=this._dataUnit.valueFromString(e,i[e]);return t}}}class A{constructor(){this.listen=!0,this.startChangeEventName="ezStartChange",this.cancelWaitingChangeEventName="ezCancelWaitingChange",this.changeEventName="ezChange"}destroy(){this.field.removeEventListener(this.startChangeEventName,this.startChangeListener),this.field.removeEventListener(this.cancelWaitingChangeEventName,this.cancelWaitingChangeListener),this.field.removeEventListener(this.changeEventName,this.changeListener)}acceptWaitingChange(){this.waitingChangePromiseResolve&&(this.waitingChangePromiseResolve(),this.waitingChangePromiseReject=void 0,this.waitingChangePromiseResolve=void 0)}rejectWaitingChange(t){this.waitingChangePromiseReject&&(this.waitingChangePromiseReject(t),this.waitingChangePromiseReject=void 0,this.waitingChangePromiseResolve=void 0)}static create(t,i,e,s,n){const r=new A;return r.field=i,r.fieldName=t,r.startChangeListener=i=>{r.listen&&e(t,i.detail)},r.field.addEventListener(r.startChangeEventName,r.startChangeListener),r.cancelWaitingChangeListener=()=>{r.listen&&s(t)},r.field.addEventListener(r.cancelWaitingChangeEventName,r.cancelWaitingChangeListener),r.changeListener=i=>{r.listen&&n(t,i.detail)},r.field.addEventListener(r.changeEventName,r.changeListener),r}}function g(t){return"Minified Redux error #"+t+"; visit https://redux.js.org/Errors?code="+t+" for the full message or use the non-minified dev environment for full errors. "}var E="function"==typeof Symbol&&Symbol.observable||"@@observable",D=function(){return Math.random().toString(36).substring(7).split("").join(".")},C={INIT:"@@redux/INIT"+D(),REPLACE:"@@redux/REPLACE"+D(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+D()}};function O(t){if("object"!=typeof t||null===t)return!1;for(var i=t;null!==Object.getPrototypeOf(i);)i=Object.getPrototypeOf(i);return Object.getPrototypeOf(t)===i}function R(t,i,e){var s;if("function"==typeof i&&"function"==typeof e||"function"==typeof e&&"function"==typeof arguments[3])throw new Error(g(0));if("function"==typeof i&&void 0===e&&(e=i,i=void 0),void 0!==e){if("function"!=typeof e)throw new Error(g(1));return e(R)(t,i)}if("function"!=typeof t)throw new Error(g(2));var n=t,r=i,o=[],h=o,a=!1;function c(){h===o&&(h=o.slice())}function l(){if(a)throw new Error(g(3));return r}function u(t){if("function"!=typeof t)throw new Error(g(4));if(a)throw new Error(g(5));var i=!0;return c(),h.push(t),function(){if(i){if(a)throw new Error(g(6));i=!1,c();var e=h.indexOf(t);h.splice(e,1),o=null}}}function d(t){if(!O(t))throw new Error(g(7));if(void 0===t.type)throw new Error(g(8));if(a)throw new Error(g(9));try{a=!0,r=n(r,t)}finally{a=!1}for(var i=o=h,e=0;e<i.length;e++)(0,i[e])();return t}function f(t){if("function"!=typeof t)throw new Error(g(10));n=t,d({type:C.REPLACE})}function v(){var t,i=u;return(t={subscribe:function(t){if("object"!=typeof t||null===t)throw new Error(g(11));function e(){t.next&&t.next(l())}return e(),{unsubscribe:i(e)}}})[E]=function(){return this},t}return d({type:C.INIT}),(s={dispatch:d,subscribe:u,getState:l,replaceReducer:f})[E]=v,s}const I={};function T(t=I,i){switch(i.type){case F.METADATA_LOADED:return Object.assign(Object.assign({},t),{formMetadata:i.payload,currentSheet:void 0});case F.CHANGE_TAB:return Object.assign(Object.assign({},t),{currentSheet:i.payload});default:return t}}function N(t){return t.formMetadata}function j(t){const i=function(t){return t.currentSheet}(t);return i?t.formMetadata.getSheet(i):Array.from(t.formMetadata.getAllSheets().values())[0]}var F;!function(t){t.METADATA_LOADED="FORM/METADATA_LOADED",t.CHANGE_TAB="FORM/CHANGE_TAB"}(F||(F={}));const z=class{constructor(e){t(this,e),this.ezFormRequestClearFieldToFocus=i(this,"ezFormRequestClearFieldToFocus",7),this.ezFormSetFields=i(this,"ezFormSetFields",7),this.ezReady=i(this,"ezReady",7),this.formItemsReady=i(this,"formItemsReady",7),this._customEditors=new Map,this.onDataUnitAction=t=>{t.type===h.METADATA_LOADED&&this.processMetadata()},this._fieldsProps=new Map,this.dataUnit=void 0,this.config=void 0,this.recordsValidator=void 0,this.fieldToFocus=void 0,this.onlyStaticFields=!1}validate(){return this._dataBinder.validate()}async addCustomEditor(t,i,e){if(this._formView)return void this._formView.addCustomEditor(t,i,e);const s=new Map(this._customEditors);s.set(t,{customEditor:i,detailContext:e}),this._customEditors=s}observeConfig(){this.processMetadata()}async setFieldProp(t,i,e){const s=new Map(this._fieldsProps),n=this._fieldsProps.get(t);s.set(t,Object.assign(Object.assign({},n),{[i]:e})),this._fieldsProps=s}getDynamicContent(){var t;const i=N(this._store.getState());if(!i)return null;const s=Array.from(i.getAllSheets().values()),n=j(null===(t=this._store)||void 0===t?void 0:t.getState());let r=[];if(s.length>1){const t=s.map(((t,i)=>({tabKey:t.name,label:t.label,index:i}))),i="selector";r.push(e("ez-tabselector",{tabs:this.buildIdTabSelector(t),onEzChange:t=>this._store.dispatch(function(t){return{type:F.CHANGE_TAB,payload:"string"==typeof t?t:t.tabKey}}(t.detail)),selectedTab:n.name,"data-element-id":i}))}return r=r.concat(this.buildFormContent(n)),r}buildFormContent(t){const i=null==t?void 0:t.fields;if(null==t)return;this.ezFormSetFields.emit(i);const s=`${a.replaceAccentuatedChars(a.toCamelCase(null==t?void 0:t.label),!1)}_selectorContainer`;return e("div",{class:"dynamic-content","data-element-id":s},e("ez-form-view",{ref:t=>this._formView=t,class:"ez-row ez-padding-vertical--small",fields:i,selectedRecord:this.dataUnit.getSelectedRecord()}))}processMetadata(){if(this.bindFields()&&this.dataUnit&&this._store){const t=((t,i,e=!1)=>{var s,n;null!=t&&!0!==(null==t?void 0:t.emptyConfig)||(t=(t=>{const i=t.metadata;let e;return i&&(e=i.fields.filter((t=>!1!==t.visible)).map((t=>({name:t.name,defaultValue:t.defaultValue})))),{emptyConfig:!1,fields:e}})(i));const r=new Map,o=new Map,h=[],a=[],c={};null===(s=null==t?void 0:t.tabs)||void 0===s||s.forEach((t=>{o.has(t.label)||!1!==t.visible||o.set(t.label,t)})),null===(n=null==t?void 0:t.fields)||void 0===n||n.forEach((t=>{var e,s,n;if(!1!==t.visible){const l=((t,i)=>("string"==typeof t?Array.from(i.keys()).find((i=>i.label===t)):t)||{label:t,visible:!0})(t.tab||"__main",r);if(o.has(l.label))return;const u=i.getField(t.name);if(u&&l.visible){r.has(l)||r.set(l,[]);const i=v(u,t);r.get(l).push(i),i.required&&h.push(t.name),((null==t.cleanOnCopy?null===(e=u.properties)||void 0===e?void 0:e.cleanOnCopy:t.cleanOnCopy)||(null===(s=u.properties)||void 0===s?void 0:s.cleanOnCopy))&&a.push(t.name);let o=null==t.defaultValue?null===(n=u.properties)||void 0===n?void 0:n.defaultValue:t.defaultValue;if(o&&null!=o.value){const{type:i,value:e}=o;if(i)if("V"===i)o=e;else try{const t=JSON.parse(e);o=t&&"value"in t?t:e}catch(t){}c[t.name]=o}}}}));const l=new m;if(l.setDefaultVars(t.defaultVars),e){const t=i.metadata;null!=t&&null!=t.children&&t.children.forEach((t=>{const{label:i,name:e,fields:s}=(t=>({name:`child[${t.name}]`,label:t.label,fields:[]}))(t);r.set({name:e,label:i},s)}))}return Array.from(r.entries()).sort(y).forEach((([t,i])=>{l.addSheet({label:"__main"===t.label?"Principal":t.label,name:t.name||t.label,fields:i})})),l.addRequiredFields(h),l.addCleanOnCopyFields(a),l.addDefaultValues(c),l})(this.config,this.dataUnit);this._store.dispatch({type:F.METADATA_LOADED,payload:t})}}isStatic(){var t;return(null===(t=this._staticFields)||void 0===t?void 0:t.length)>0}bindFields(){return!this.isStatic()||!1===this.onlyStaticFields}componentWillLoad(){void 0===this.dataUnit&&(this.dataUnit=new d("ez-form")),this.dataUnit.subscribe(this.onDataUnitAction),this._dataBinder=new w(this.dataUnit),this._store=R(T),this._store.subscribe((()=>s(this))),this._staticFields=Array.from(this._element.querySelectorAll("[data-field-name]")),this.processMetadata(),f.addIDInfo(this._element,null,{dataUnit:this.dataUnit})}componentDidRender(){const t=N(this._store.getState());t.addRequiredFields(this._staticFields.filter((t=>t.dataset.required)).map((t=>t.dataset.fieldName))),this._dataBinder.bind(Array.from(this._element.querySelectorAll("[data-field-name]")),this.dataUnit.dataUnitId,t,this.recordsValidator),this.ezReady.emit(),this.handleFieldToFocus(),this.setCustomEditors(),this.setFieldsProps()}setCustomEditors(){if(this._formView)for(const[t,i]of this._customEditors)this._formView.addCustomEditor(t,i.customEditor,i.detailContext),this._customEditors.delete(t)}handleFieldToFocus(){var t;if(null==this.fieldToFocus)return;const i=j(null===(t=this._store)||void 0===t?void 0:t.getState());(null==i?void 0:i.fields).some((t=>t.name===this.fieldToFocus))&&requestAnimationFrame((()=>{this._dataBinder.setFocus(this.fieldToFocus),this.ezFormRequestClearFieldToFocus.emit()}))}setFieldsProps(){if(this._formView)for(const[t,i]of this._fieldsProps){for(const e in i)this._formView.setFieldProp(t,e,i[e]);this._fieldsProps.delete(t)}}disconnectedCallback(){this.dataUnit.unsubscribe(this.onDataUnitAction),this._dataBinder.onDisconnectedCallback()}buildIdTabSelector(t){return t&&t.forEach((t=>t[f.DATA_ELEMENT_ID_ATTRIBUTE_NAME]=a.toCamelCase(t.label))),t}render(){return e(n,null,this.isStatic()?null:this.getDynamicContent())}get _element(){return r(this)}static get watchers(){return{config:["observeConfig"]}}};z.style=".sc-ez-form-h{display:flex;flex-direction:column;width:100%}.dynamic-content.sc-ez-form ez-collapsible-box.sc-ez-form{--ez-collapsible-box__header--padding-right:var(--space-small, 6px);--ez-collapsible-box__header--padding-left:var(--space-small, 6px)}";export{z as ez_form}
|