@sankhyalabs/ezui 1.1.142 → 1.1.143
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/ez-form.cjs.entry.js +4 -4
- package/dist/cjs/ez-grid.cjs.entry.js +2 -0
- package/dist/collection/components/ez-form/structure/FormSheetMetadata.js +4 -4
- package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +2 -0
- package/dist/custom-elements/index.js +6 -4
- package/dist/esm/ez-form.entry.js +4 -4
- package/dist/esm/ez-grid.entry.js +2 -0
- package/dist/ezui/ezui.esm.js +1 -1
- package/dist/ezui/{p-1b2bf15d.entry.js → p-6816c9ee.entry.js} +1 -1
- package/dist/ezui/{p-87808290.entry.js → p-8639fc8c.entry.js} +1 -1
- package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as e,r as t,c as i,f as n,H as s,g as r}from"./p-139ed2f6.js";import{UserInterface as a,Action as o,WaitingChangeException as l,ApplicationContext as c,DataUnitAction as d,DataUnit as h}from"@sankhyalabs/core";import{A as u}from"./p-0cd386db.js";const f=({name:t,label:i})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-text-input",{label:i,"data-field-name":t,key:t}));function b(t,i,n,s=!1){return e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-align--middle ez-padding-horizontal--small ez-padding-bottom--large"},e("ez-check",{enabled:!n,label:i,mode:s?"switch":"regular","data-field-name":t,key:t}))}function p(t,i,n,s,r){return e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-number-input",{enabled:!n,label:i,precision:s,prettyPrecision:r,"data-field-name":t,key:t}))}const m=new Map;m.set(a.LONGTEXT,(({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-padding-horizontal--small",key:t},e("ez-text-area",{enabled:!n,label:i,"data-field-name":t})))),m.set(a.CHECKBOX,(e=>b(e.name,e.label,e.readOnly,!1))),m.set(a.SWITCH,(e=>b(e.name,e.label,e.readOnly,!0))),m.set(a.OPTIONSELECTOR,(({name:t,label:i,readOnly:n,required:s},r)=>{const a=null==r?void 0:r.options;let o;if("string"==typeof a){const e=JSON.parse(a);o=Object.keys(e).map((t=>({value:t,label:e[t]})))}else o=a;return e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-combo-box",{enabled:!n,suppressEmptyOption:s,label:i,"data-field-name":t,key:t,options:o}))})),m.set(a.SEARCH,(({name:t,label:i,readOnly:n,required:s})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-search",{enabled:!n,suppressEmptyOption:s,label:i,"data-field-name":t,key:t})))),m.set(a.FILE,(({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-padding-horizontal--small"},e("ez-upload",{enabled:!n,label:i,"data-field-name":t,key:t})))),m.set(a.DATE,(({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-date-input",{enabled:!n,label:i,"data-field-name":t,key:t})))),m.set(a.TIME,(({name:t,label:i})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-time-input",{label:i,"data-field-name":t,key:t})))),m.set(a.DATETIME,(({name:t,label:i})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-date-time-input",{label:i,"data-field-name":t,key:t})))),m.set(a.DECIMALNUMBER,(({name:e,label:t,readOnly:i},n)=>{const s=Number((null==n?void 0:n.precision)||2);return p(e,t,i,s,Number((null==n?void 0:n.prettyPrecision)||s))})),m.set(a.INTEGERNUMBER,(({name:e,label:t,readOnly:i})=>p(e,t,i,0,0)));const z=e=>{const t=e.descriptor,i=Object.assign({},e.config);let n,s;return t&&(i.label||(i.label=t.label),i.name||(i.name=t.name),void 0===i.required&&(i.required=t.required),void 0===i.readOnly&&(i.readOnly=t.readOnly),s=t.properties,n=m.get(t.userInterface)),i.required&&(i.label=`* ${i.label} (obrigatório)`),n||(n=f),n(i,s)},v=({source:t})=>"items"in t?e("ez-collapsible-box",{label:t.label,"header-size":"large"},t.items.map((e=>z(e)))):z(t),y=({store:t,source:i})=>e("div",{class:"dynamic-content ez-box__container"},e("div",{class:"ez-row ez-padding-vertical--small"},i.items.map((i=>e(v,{store:t,source:i})))));class g{constructor(){this._sheets=new Map,this._requiredFields=[],this._cleanOnCopyFields=[],this._defaultValues={}}getSheet(e){return this._sheets.get(e)}getAllSheets(){return this._sheets}addSheet(e){this._sheets.set(e.name,e),this._requiredFields=this._requiredFields.concat(e.requiredFields),this._cleanOnCopyFields=this._cleanOnCopyFields.concat(e.cleanOnCopyFields),this._defaultValues=e.defaultValues}getRequiredFields(){return this._requiredFields}getCleanOnCopyFields(){return this._cleanOnCopyFields}getDefaultValues(){return this._defaultValues}}function w(e,t){return"Geral"==e[0].label?-1:(e[0].order||1e4)-(t[0].order||1e4)}function _(e){return"Minified Redux error #"+e+"; visit https://redux.js.org/Errors?code="+e+" for the full message or use the non-minified dev environment for full errors. "}var O="function"==typeof Symbol&&Symbol.observable||"@@observable",E=function(){return Math.random().toString(36).substring(7).split("").join(".")},A={INIT:"@@redux/INIT"+E(),REPLACE:"@@redux/REPLACE"+E(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+E()}};function C(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function x(e,t,i){var n;if("function"==typeof t&&"function"==typeof i||"function"==typeof i&&"function"==typeof arguments[3])throw new Error(_(0));if("function"==typeof t&&void 0===i&&(i=t,t=void 0),void 0!==i){if("function"!=typeof i)throw new Error(_(1));return i(x)(e,t)}if("function"!=typeof e)throw new Error(_(2));var s=e,r=t,a=[],o=a,l=!1;function c(){o===a&&(o=a.slice())}function d(){if(l)throw new Error(_(3));return r}function h(e){if("function"!=typeof e)throw new Error(_(4));if(l)throw new Error(_(5));var t=!0;return c(),o.push(e),function(){if(t){if(l)throw new Error(_(6));t=!1,c();var i=o.indexOf(e);o.splice(i,1),a=null}}}function u(e){if(!C(e))throw new Error(_(7));if(void 0===e.type)throw new Error(_(8));if(l)throw new Error(_(9));try{l=!0,r=s(r,e)}finally{l=!1}for(var t=a=o,i=0;i<t.length;i++)(0,t[i])();return e}function f(e){if("function"!=typeof e)throw new Error(_(10));s=e,u({type:A.REPLACE})}function b(){var e,t=h;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new Error(_(11));function i(){e.next&&e.next(d())}return i(),{unsubscribe:t(i)}}})[O]=function(){return this},e}return u({type:A.INIT}),(n={dispatch:u,subscribe:h,getState:d,replaceReducer:f})[O]=b,n}const R={};function j(e=R,t){switch(t.type){case k.METADATA_LOADED:return Object.assign(Object.assign({},e),{formMetadata:t.payload});case k.CHANGE_TAB:return Object.assign(Object.assign({},e),{currentSheet:t.payload});default:return e}}function N(e){return e.formMetadata}var k;!function(e){e.METADATA_LOADED="FORM/METADATA_LOADED",e.CHANGE_TAB="FORM/CHANGE_TAB"}(k||(k={}));class D{constructor(e){this.onDataUnitEvent=e=>{var t;switch(e.type){case o.DATA_LOADED:case o.DATA_SAVED:case o.RECORDS_REMOVED:case o.RECORDS_ADDED:case o.RECORDS_COPIED:case o.DATA_CHANGED:case o.EDITION_CANCELED:case o.CHANGE_UNDONE:case o.CHANGE_REDONE:case o.SELECTION_CHANGED:case o.NEXT_SELECTED:case o.PREVIOUS_SELECTED:null===(t=this._fields)||void 0===t||t.forEach((e=>{this.updateValue(e.fieldName,e.field)}))}},this._fields=new Map,this._dataUnit=e,this._dataUnit.subscribe(this.onDataUnitEvent)}bind(e){e.forEach((e=>{this.updateBind(e.dataset.fieldName,e)}))}onDisconnectedCallback(){this._dataUnit.unsubscribe(this.onDataUnitEvent)}updateValue(e,t){t.value=this._dataUnit.getFieldValue(e)}updateBind(e,t){const i=this._fields.get(e);i&&i.destroy(),t.value=this._dataUnit.getFieldValue(e),this._fields.set(e,S.create(e,t,((e,t)=>this.changeStarted(e,t)),(e=>this.cancelWaitingChange(e)),((e,t)=>this.setFieldValue(e,t)))),this.bindSearchOptionsLoader(e,t),this.applyEzUploadContext(e,t)}changeStarted(e,t){if(0===this._dataUnit.records.length&&this._dataUnit.addRecord(),!t.blocking&&null==t.promise){const i=this._fields.get(e);i&&(t.promise=new Promise(((e,t)=>{i.waitingChangePromiseResolve=e,i.waitingChangePromiseReject=t})))}this._dataUnit.startChange(e,t)}cancelWaitingChange(e){if(this._dataUnit.waitingForChange(e)){this._dataUnit.cancelWaitingChange(e);const t=this._fields.get(e);t&&t.rejectWaitingChange(new l("Change canceled",e))}}setFieldValue(e,t){if(0===this._dataUnit.records.length&&this._dataUnit.addRecord(),this._dataUnit.setFieldValue(e,t),this._dataUnit.waitingForChange(e)){const t=this._fields.get(e);t&&t.acceptWaitingChange()}}bindSearchOptionsLoader(e,t){if("EZ-SEARCH"===t.nodeName&&null==t.optionLoader){const i=c.getContextValue("__EZUI__SEARCH__OPTION__LOADER__");i&&(t.optionLoader=t=>i(t,e,this._dataUnit))}}applyEzUploadContext(e,t){var i,n;if("EZ-UPLOAD"===t.nodeName){t.urlUpload=c.getContextValue("__EZUI__UPLOAD__ADD__URL__"),t.urlDelete=c.getContextValue("__EZUI__UPLOAD__DEL__URL__");const s=this._dataUnit.getField(e),r=null===(i=s.properties)||void 0===i?void 0:i.DESTINATION;r&&(t.requestHeaders={XTRAINF:`{"destination": "${r}"}`}),t.maxFiles=(null===(n=s.properties)||void 0===n?void 0:n.MAX_FILES)||0}}}class S{constructor(){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(e){this.waitingChangePromiseReject&&(this.waitingChangePromiseReject(e),this.waitingChangePromiseReject=void 0,this.waitingChangePromiseResolve=void 0)}static create(e,t,i,n,s){const r=new S;return r.field=t,r.fieldName=e,r.startChangeListener=t=>{i(e,t.detail)},r.field.addEventListener(r.startChangeEventName,r.startChangeListener),r.cancelWaitingChangeListener=()=>{n(e)},r.field.addEventListener(r.cancelWaitingChangeEventName,r.cancelWaitingChangeListener),r.changeListener=t=>{s(e,t.detail)},r.field.addEventListener(r.changeEventName,r.changeListener),r}}let P=class{constructor(e){t(this,e),this.ezReady=i(this,"ezReady",7),this.onDataUnitAction=e=>{e.type===o.METADATA_LOADED&&this.processMetadata()}}submit(){return Promise.resolve()}cancel(){return Promise.resolve()}validate(){return new Promise(((e,t)=>{const i=N(this._store.getState()),n=this._staticFields.filter((e=>e.dataset.required)).map((e=>e.dataset.fieldName)).concat(i.getRequiredFields()),s=this.dataUnit.getModifiedRecords();for(let e=0;e<s.length;e++)if(!this.validateRequired(n,s[e])){t();break}e()}))}observeConfig(){this.processMetadata()}validateRequired(e,t){const i=[];e.forEach((e=>{const n=t[e],s=this._element.querySelector(`[data-field-name=${e}]`);null==n||""===n?(i.push(e),s.errorMessage="Essa informação é obrigatória"):s.errorMessage=""}));const n=0===i.length;return n||u.info("Há pelo menos um campo obrigatório não preenchido."),n}getDynamicContent(){var t;const i=N(this._store.getState());if(!i)return null;const n=(s=null===(t=this._store)||void 0===t?void 0:t.getState()).currentSheet?s.formMetadata.getSheet(s.currentSheet):Array.from(s.formMetadata.getAllSheets().values())[0];var s;if(!n)return null;const r=Array.from(i.getAllSheets().values()),a=[];return r.length>1&&a.push(e("ez-tabselector",{onEzChange:e=>this._store.dispatch(function(e){return{type:k.CHANGE_TAB,payload:e.tabKey}}(e.detail)),selectedTab:n.name},r.map((t=>e("ez-tab",{tabKey:t.name,label:t.label}))))),a.push(e(y,{store:this._store,source:n})),a}processMetadata(){if(!this.isStatic()){const e=this.config&&this.config.length>0?((e,t)=>{const i=new Map,n=[],s=[],r={};e.forEach((e=>{var a,o;if(!1!==e.visible){const l=function(e,t){return("string"==typeof e?Array.from(t.keys()).find((t=>t.label===e)):e)||{label:e,visible:!0}}(e.tab||"Geral",i),c=t.getField(e.name);if(c&&l.visible){i.has(l)||i.set(l,new Map);const t=i.get(l);(void 0===e.required?c.required:e.required)&&n.push(e.name),(void 0===e.cleanOnCopy?null===(a=c.properties)||void 0===a?void 0:a.cleanOnCopy:e.cleanOnCopy)&&s.push(e.name),(void 0===e.defaultValue?null===(o=c.properties)||void 0===o?void 0:o.defaultValue:e.defaultValue)&&(r[e.name]=e.defaultValue);const d={config:e,descriptor:c},h=e.group;if(h){const e=`group::${h}`;t.has(e)?t.get(e).items.push(d):t.set(e,{label:h,items:[d]})}else t.set(e.name,d)}}}));const a=new g;return Array.from(i.entries()).sort(w).forEach((([e,t])=>{a.addSheet({label:e.label,name:e.label,items:Array.from(t.values()),requiredFields:n,cleanOnCopyFields:s,defaultValues:r})})),a})(this.config,this.dataUnit):(()=>{var e;const t=this.dataUnit.metadata,i=new g;if(t){const n=null===(e=t.fields)||void 0===e?void 0:e.filter((e=>!1!==e.visible));let s={};n.filter((e=>e.defaultValue)).map((e=>s[e.name]=e.defaultValue)),i.addSheet({label:t.label,name:t.name,items:n.map((e=>({descriptor:e}))),requiredFields:n.filter((e=>e.required)).map((e=>e.name)),cleanOnCopyFields:n.filter((e=>{var t;return null===(t=e.properties)||void 0===t?void 0:t.cleanOnCopy})).map((e=>e.name)),defaultValues:s})}return i})();this._store.dispatch({type:k.METADATA_LOADED,payload:e})}}isStatic(){var e;return(null===(e=this._staticFields)||void 0===e?void 0:e.length)>0}interceptAction(e){if(e.type===o.RECORDS_COPIED){const t=N(this._store.getState()).getCleanOnCopyFields();if(t)return new d(o.RECORDS_COPIED,e.payload.map((e=>{const i=Object.assign({},e);return t.forEach((e=>delete i[e])),i})))}if(e.type===o.RECORDS_ADDED){const t=N(this._store.getState()).getDefaultValues();if(t)return new d(o.RECORDS_ADDED,e.payload.map((e=>{const i=Object.assign({},e);for(const e in t)i[e]=this.dataUnit.valueFromString(e,t[e]);return i})))}return e}componentWillLoad(){void 0===this.dataUnit&&(this.dataUnit=new h("ez-form")),this.dataUnit.addInterceptor(this),this.dataUnit.subscribe(this.onDataUnitAction),this._dataBinder=new D(this.dataUnit),this._store=x(j),this._store.subscribe((()=>n(this))),this._staticFields=Array.from(this._element.querySelectorAll("[data-field-name]")),this.processMetadata()}componentDidRender(){this._dataBinder.bind(Array.from(this._element.querySelectorAll("[data-field-name]"))),this.ezReady.emit()}disconnectedCallback(){this.dataUnit.unsubscribe(this.onDataUnitAction),this.dataUnit.removeInterceptor(this),this._dataBinder.onDisconnectedCallback()}render(){return e(s,null,this.isStatic()?null:this.getDynamicContent())}get _element(){return r(this)}static get watchers(){return{config:["observeConfig"]}}};P.style="ez-form{display:flex;flex-direction:column;width:100%}.dynamic-content ez-collapsible-box{--ez-collapsible-box__header--padding-right:var(--space-small, 6px);--ez-collapsible-box__header--padding-left:var(--space-small, 6px)}";export{P as ez_form}
|
|
1
|
+
import{h as e,r as t,c as i,f as n,H as s,g as r}from"./p-139ed2f6.js";import{UserInterface as o,Action as a,WaitingChangeException as l,ApplicationContext as c,DataUnitAction as d,DataUnit as h}from"@sankhyalabs/core";import{A as u}from"./p-0cd386db.js";const f=({name:t,label:i})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-text-input",{label:i,"data-field-name":t,key:t}));function b(t,i,n,s=!1){return e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-align--middle ez-padding-horizontal--small ez-padding-bottom--large"},e("ez-check",{enabled:!n,label:i,mode:s?"switch":"regular","data-field-name":t,key:t}))}function p(t,i,n,s,r){return e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-number-input",{enabled:!n,label:i,precision:s,prettyPrecision:r,"data-field-name":t,key:t}))}const m=new Map;m.set(o.LONGTEXT,(({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-padding-horizontal--small",key:t},e("ez-text-area",{enabled:!n,label:i,"data-field-name":t})))),m.set(o.CHECKBOX,(e=>b(e.name,e.label,e.readOnly,!1))),m.set(o.SWITCH,(e=>b(e.name,e.label,e.readOnly,!0))),m.set(o.OPTIONSELECTOR,(({name:t,label:i,readOnly:n,required:s},r)=>{const o=null==r?void 0:r.options;let a;if("string"==typeof o){const e=JSON.parse(o);a=Object.keys(e).map((t=>({value:t,label:e[t]})))}else a=o;return e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-combo-box",{enabled:!n,suppressEmptyOption:s,label:i,"data-field-name":t,key:t,options:a}))})),m.set(o.SEARCH,(({name:t,label:i,readOnly:n,required:s})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-search",{enabled:!n,suppressEmptyOption:s,label:i,"data-field-name":t,key:t})))),m.set(o.FILE,(({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-padding-horizontal--small"},e("ez-upload",{enabled:!n,label:i,"data-field-name":t,key:t})))),m.set(o.DATE,(({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-date-input",{enabled:!n,label:i,"data-field-name":t,key:t})))),m.set(o.TIME,(({name:t,label:i})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-time-input",{label:i,"data-field-name":t,key:t})))),m.set(o.DATETIME,(({name:t,label:i})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-date-time-input",{label:i,"data-field-name":t,key:t})))),m.set(o.DECIMALNUMBER,(({name:e,label:t,readOnly:i},n)=>{const s=Number((null==n?void 0:n.precision)||2);return p(e,t,i,s,Number((null==n?void 0:n.prettyPrecision)||s))})),m.set(o.INTEGERNUMBER,(({name:e,label:t,readOnly:i})=>p(e,t,i,0,0)));const v=e=>{const t=e.descriptor,i=Object.assign({},e.config);let n,s;return t&&(i.label||(i.label=t.label),i.name||(i.name=t.name),void 0===i.required&&(i.required=t.required),void 0===i.readOnly&&(i.readOnly=t.readOnly),s=t.properties,n=m.get(t.userInterface)),i.required&&(i.label=`* ${i.label} (obrigatório)`),n||(n=f),n(i,s)},z=({source:t})=>"items"in t?e("ez-collapsible-box",{label:t.label,"header-size":"large"},t.items.map((e=>v(e)))):v(t),y=({store:t,source:i})=>e("div",{class:"dynamic-content ez-box__container"},e("div",{class:"ez-row ez-padding-vertical--small"},i.items.map((i=>e(z,{store:t,source:i})))));class g{constructor(){this._sheets=new Map,this._requiredFields=[],this._cleanOnCopyFields=[],this._defaultValues={}}getSheet(e){return this._sheets.get(e)}getAllSheets(){return this._sheets}addSheet(e){this._sheets.set(e.name,e),this._requiredFields=this._requiredFields.concat(e.requiredFields),this._cleanOnCopyFields=this._cleanOnCopyFields.concat(e.cleanOnCopyFields),this._defaultValues=e.defaultValues}getRequiredFields(){return this._requiredFields}getCleanOnCopyFields(){return this._cleanOnCopyFields}getDefaultValues(){return this._defaultValues}}function w(e,t){return"Geral"==e[0].label?-1:(e[0].order||1e4)-(t[0].order||1e4)}function _(e){return"Minified Redux error #"+e+"; visit https://redux.js.org/Errors?code="+e+" for the full message or use the non-minified dev environment for full errors. "}var O="function"==typeof Symbol&&Symbol.observable||"@@observable",E=function(){return Math.random().toString(36).substring(7).split("").join(".")},A={INIT:"@@redux/INIT"+E(),REPLACE:"@@redux/REPLACE"+E(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+E()}};function C(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function x(e,t,i){var n;if("function"==typeof t&&"function"==typeof i||"function"==typeof i&&"function"==typeof arguments[3])throw new Error(_(0));if("function"==typeof t&&void 0===i&&(i=t,t=void 0),void 0!==i){if("function"!=typeof i)throw new Error(_(1));return i(x)(e,t)}if("function"!=typeof e)throw new Error(_(2));var s=e,r=t,o=[],a=o,l=!1;function c(){a===o&&(a=o.slice())}function d(){if(l)throw new Error(_(3));return r}function h(e){if("function"!=typeof e)throw new Error(_(4));if(l)throw new Error(_(5));var t=!0;return c(),a.push(e),function(){if(t){if(l)throw new Error(_(6));t=!1,c();var i=a.indexOf(e);a.splice(i,1),o=null}}}function u(e){if(!C(e))throw new Error(_(7));if(void 0===e.type)throw new Error(_(8));if(l)throw new Error(_(9));try{l=!0,r=s(r,e)}finally{l=!1}for(var t=o=a,i=0;i<t.length;i++)(0,t[i])();return e}function f(e){if("function"!=typeof e)throw new Error(_(10));s=e,u({type:A.REPLACE})}function b(){var e,t=h;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new Error(_(11));function i(){e.next&&e.next(d())}return i(),{unsubscribe:t(i)}}})[O]=function(){return this},e}return u({type:A.INIT}),(n={dispatch:u,subscribe:h,getState:d,replaceReducer:f})[O]=b,n}const R={};function j(e=R,t){switch(t.type){case k.METADATA_LOADED:return Object.assign(Object.assign({},e),{formMetadata:t.payload});case k.CHANGE_TAB:return Object.assign(Object.assign({},e),{currentSheet:t.payload});default:return e}}function N(e){return e.formMetadata}var k;!function(e){e.METADATA_LOADED="FORM/METADATA_LOADED",e.CHANGE_TAB="FORM/CHANGE_TAB"}(k||(k={}));class D{constructor(e){this.onDataUnitEvent=e=>{var t;switch(e.type){case a.DATA_LOADED:case a.DATA_SAVED:case a.RECORDS_REMOVED:case a.RECORDS_ADDED:case a.RECORDS_COPIED:case a.DATA_CHANGED:case a.EDITION_CANCELED:case a.CHANGE_UNDONE:case a.CHANGE_REDONE:case a.SELECTION_CHANGED:case a.NEXT_SELECTED:case a.PREVIOUS_SELECTED:null===(t=this._fields)||void 0===t||t.forEach((e=>{this.updateValue(e.fieldName,e.field)}))}},this._fields=new Map,this._dataUnit=e,this._dataUnit.subscribe(this.onDataUnitEvent)}bind(e){e.forEach((e=>{this.updateBind(e.dataset.fieldName,e)}))}onDisconnectedCallback(){this._dataUnit.unsubscribe(this.onDataUnitEvent)}updateValue(e,t){t.value=this._dataUnit.getFieldValue(e)}updateBind(e,t){const i=this._fields.get(e);i&&i.destroy(),t.value=this._dataUnit.getFieldValue(e),this._fields.set(e,S.create(e,t,((e,t)=>this.changeStarted(e,t)),(e=>this.cancelWaitingChange(e)),((e,t)=>this.setFieldValue(e,t)))),this.bindSearchOptionsLoader(e,t),this.applyEzUploadContext(e,t)}changeStarted(e,t){if(0===this._dataUnit.records.length&&this._dataUnit.addRecord(),!t.blocking&&null==t.promise){const i=this._fields.get(e);i&&(t.promise=new Promise(((e,t)=>{i.waitingChangePromiseResolve=e,i.waitingChangePromiseReject=t})))}this._dataUnit.startChange(e,t)}cancelWaitingChange(e){if(this._dataUnit.waitingForChange(e)){this._dataUnit.cancelWaitingChange(e);const t=this._fields.get(e);t&&t.rejectWaitingChange(new l("Change canceled",e))}}setFieldValue(e,t){if(0===this._dataUnit.records.length&&this._dataUnit.addRecord(),this._dataUnit.setFieldValue(e,t),this._dataUnit.waitingForChange(e)){const t=this._fields.get(e);t&&t.acceptWaitingChange()}}bindSearchOptionsLoader(e,t){if("EZ-SEARCH"===t.nodeName&&null==t.optionLoader){const i=c.getContextValue("__EZUI__SEARCH__OPTION__LOADER__");i&&(t.optionLoader=t=>i(t,e,this._dataUnit))}}applyEzUploadContext(e,t){var i,n;if("EZ-UPLOAD"===t.nodeName){t.urlUpload=c.getContextValue("__EZUI__UPLOAD__ADD__URL__"),t.urlDelete=c.getContextValue("__EZUI__UPLOAD__DEL__URL__");const s=this._dataUnit.getField(e),r=null===(i=s.properties)||void 0===i?void 0:i.DESTINATION;r&&(t.requestHeaders={XTRAINF:`{"destination": "${r}"}`}),t.maxFiles=(null===(n=s.properties)||void 0===n?void 0:n.MAX_FILES)||0}}}class S{constructor(){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(e){this.waitingChangePromiseReject&&(this.waitingChangePromiseReject(e),this.waitingChangePromiseReject=void 0,this.waitingChangePromiseResolve=void 0)}static create(e,t,i,n,s){const r=new S;return r.field=t,r.fieldName=e,r.startChangeListener=t=>{i(e,t.detail)},r.field.addEventListener(r.startChangeEventName,r.startChangeListener),r.cancelWaitingChangeListener=()=>{n(e)},r.field.addEventListener(r.cancelWaitingChangeEventName,r.cancelWaitingChangeListener),r.changeListener=t=>{s(e,t.detail)},r.field.addEventListener(r.changeEventName,r.changeListener),r}}let P=class{constructor(e){t(this,e),this.ezReady=i(this,"ezReady",7),this.onDataUnitAction=e=>{e.type===a.METADATA_LOADED&&this.processMetadata()}}submit(){return Promise.resolve()}cancel(){return Promise.resolve()}validate(){return new Promise(((e,t)=>{const i=N(this._store.getState()),n=this._staticFields.filter((e=>e.dataset.required)).map((e=>e.dataset.fieldName)).concat(i.getRequiredFields()),s=this.dataUnit.getModifiedRecords();for(let e=0;e<s.length;e++)if(!this.validateRequired(n,s[e])){t();break}e()}))}observeConfig(){this.processMetadata()}validateRequired(e,t){const i=[];e.forEach((e=>{const n=t[e],s=this._element.querySelector(`[data-field-name=${e}]`);null==n||""===n?(i.push(e),s.errorMessage="Essa informação é obrigatória"):s.errorMessage=""}));const n=0===i.length;return n||u.info("Há pelo menos um campo obrigatório não preenchido."),n}getDynamicContent(){var t;const i=N(this._store.getState());if(!i)return null;const n=(s=null===(t=this._store)||void 0===t?void 0:t.getState()).currentSheet?s.formMetadata.getSheet(s.currentSheet):Array.from(s.formMetadata.getAllSheets().values())[0];var s;if(!n)return null;const r=Array.from(i.getAllSheets().values()),o=[];return r.length>1&&o.push(e("ez-tabselector",{onEzChange:e=>this._store.dispatch(function(e){return{type:k.CHANGE_TAB,payload:e.tabKey}}(e.detail)),selectedTab:n.name},r.map((t=>e("ez-tab",{tabKey:t.name,label:t.label}))))),o.push(e(y,{store:this._store,source:n})),o}processMetadata(){if(!this.isStatic()){const e=this.config&&this.config.length>0?((e,t)=>{const i=new Map,n=[],s=[],r={};e.forEach((e=>{var o,a,l;if(!1!==e.visible){const c=function(e,t){return("string"==typeof e?Array.from(t.keys()).find((t=>t.label===e)):e)||{label:e,visible:!0}}(e.tab||"Geral",i),d=t.getField(e.name);if(d&&c.visible){i.has(c)||i.set(c,new Map);const t=i.get(c);(void 0===e.required?d.required:e.required)&&n.push(e.name),(void 0===e.cleanOnCopy?(null===(o=d.properties)||void 0===o?void 0:o.cleanOnCopy)||(null===(a=d.properties)||void 0===a?void 0:a.autoNum):e.cleanOnCopy)&&s.push(e.name),(void 0===e.defaultValue?null===(l=d.properties)||void 0===l?void 0:l.defaultValue:e.defaultValue)&&(r[e.name]=e.defaultValue);const h={config:e,descriptor:d},u=e.group;if(u){const e=`group::${u}`;t.has(e)?t.get(e).items.push(h):t.set(e,{label:u,items:[h]})}else t.set(e.name,h)}}}));const o=new g;return Array.from(i.entries()).sort(w).forEach((([e,t])=>{o.addSheet({label:e.label,name:e.label,items:Array.from(t.values()),requiredFields:n,cleanOnCopyFields:s,defaultValues:r})})),o})(this.config,this.dataUnit):(()=>{var e;const t=this.dataUnit.metadata,i=new g;if(t){const n=null===(e=t.fields)||void 0===e?void 0:e.filter((e=>!1!==e.visible));let s={};n.filter((e=>e.defaultValue)).map((e=>s[e.name]=e.defaultValue)),i.addSheet({label:t.label,name:t.name,items:n.map((e=>({descriptor:e}))),requiredFields:n.filter((e=>e.required)).map((e=>e.name)),cleanOnCopyFields:n.filter((e=>{var t,i;return(null===(t=e.properties)||void 0===t?void 0:t.cleanOnCopy)||(null===(i=e.properties)||void 0===i?void 0:i.autoNum)})).map((e=>e.name)),defaultValues:s})}return i})();this._store.dispatch({type:k.METADATA_LOADED,payload:e})}}isStatic(){var e;return(null===(e=this._staticFields)||void 0===e?void 0:e.length)>0}interceptAction(e){if(e.type===a.RECORDS_COPIED){const t=N(this._store.getState()).getCleanOnCopyFields();if(t)return new d(a.RECORDS_COPIED,e.payload.map((e=>{const i=Object.assign({},e);return t.forEach((e=>delete i[e])),i})))}if(e.type===a.RECORDS_ADDED){const t=N(this._store.getState()).getDefaultValues();if(t)return new d(a.RECORDS_ADDED,e.payload.map((e=>{const i=Object.assign({},e);for(const e in t)i[e]=this.dataUnit.valueFromString(e,t[e]);return i})))}return e}componentWillLoad(){void 0===this.dataUnit&&(this.dataUnit=new h("ez-form")),this.dataUnit.addInterceptor(this),this.dataUnit.subscribe(this.onDataUnitAction),this._dataBinder=new D(this.dataUnit),this._store=x(j),this._store.subscribe((()=>n(this))),this._staticFields=Array.from(this._element.querySelectorAll("[data-field-name]")),this.processMetadata()}componentDidRender(){this._dataBinder.bind(Array.from(this._element.querySelectorAll("[data-field-name]"))),this.ezReady.emit()}disconnectedCallback(){this.dataUnit.unsubscribe(this.onDataUnitAction),this.dataUnit.removeInterceptor(this),this._dataBinder.onDisconnectedCallback()}render(){return e(s,null,this.isStatic()?null:this.getDynamicContent())}get _element(){return r(this)}static get watchers(){return{config:["observeConfig"]}}};P.style="ez-form{display:flex;flex-direction:column;width:100%}.dynamic-content ez-collapsible-box{--ez-collapsible-box__header--padding-right:var(--space-small, 6px);--ez-collapsible-box__header--padding-left:var(--space-small, 6px)}";export{P as ez_form}
|
|
@@ -5,6 +5,7 @@ export default class AgGridController implements EzGridController, SortingProvid
|
|
|
5
5
|
private readonly DEFAULT_ROW_HEIGHT;
|
|
6
6
|
private readonly CHECK_BOX_COL_ID;
|
|
7
7
|
private readonly RECORD_ARCHIVE_COL_ID;
|
|
8
|
+
private readonly BLOCK_LOAD_DEBOUNCE;
|
|
8
9
|
private _grid;
|
|
9
10
|
private _gridOptions;
|
|
10
11
|
private _columnStateChangeCallback;
|