@sankhyalabs/ezui 1.1.7 → 1.1.11
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/{DataUnit-6a98d9de.js → DataUnit-74f074a7.js} +66 -13
- package/dist/cjs/ez-button_14.cjs.entry.js +54 -28
- package/dist/cjs/ez-modal.cjs.entry.js +0 -2
- package/dist/cjs/form-metadata.cjs.entry.js +1 -1
- package/dist/collection/components/ez-form/ez-form.js +50 -24
- package/dist/collection/components/ez-form/subcomponents/DataUnit.js +66 -13
- package/dist/collection/components/ez-form/subcomponents/structure/FormSheet.js +1 -1
- package/dist/collection/components/ez-form/subcomponents/structure/NavigationBar.js +2 -2
- package/dist/collection/components/ez-modal/ez-modal.js +0 -2
- package/dist/custom-elements/index.js +119 -42
- package/dist/esm/{DataUnit-ac4cc054.js → DataUnit-ab1a3a4d.js} +66 -13
- package/dist/esm/ez-button_14.entry.js +54 -28
- package/dist/esm/ez-modal.entry.js +0 -2
- package/dist/esm/form-metadata.entry.js +1 -1
- package/dist/ezui/ezui.esm.js +1 -1
- package/dist/ezui/{p-f95e3c71.entry.js → p-83f1d308.entry.js} +1 -1
- package/dist/ezui/p-9f97450c.js +1 -0
- package/dist/ezui/{p-346050cf.entry.js → p-b02e731e.entry.js} +1 -1
- package/dist/types/components/ez-form/ez-form.d.ts +2 -6
- package/dist/types/components/ez-form/subcomponents/DataUnit.d.ts +14 -8
- package/package.json +1 -1
- package/dist/ezui/p-593c03ba.js +0 -1
package/package.json
CHANGED
package/dist/ezui/p-593c03ba.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function t(t,s){return{type:"FORM/CHANGETAB",payload:{formId:t,index:s}}}function s(t,s){return{type:"FORM/CLEAREDITION",payload:{dataUnit:t,recordsLimit:s}}}function i(t,s){return{type:"FORM/COLLAPSEGROUP",payload:{collapseId:t,collapsed:s}}}function e(){return{type:"FORM/LOAD"}}function h(t,s,i,e,h,r,a){return{type:"FORM/INVALIDFIELD",payload:{tabController:t,tabIndex:s,dataUnit:i,recordId:h,recordIndex:e,fieldName:r,errorMessage:a}}}function r(t,s){return{type:"FORM/SHOWHIDENAVBTN",payload:{buttonName:t,status:s}}}const a=(t,s)=>t.hist.present.currentTabIndex[s]||0,n=(t,s)=>t.hist.present.collapsedGroups[s],o=(t,s)=>t.hist.present.changes[s],d=(t,s)=>t.hist.present.currentRecordIndex[s]||0,c=(t,s)=>t.hist.present.newRecordIndex[s]||0,l=t=>t.nonhist.visibleButtons;class u{constructor(t,s,i="1"){this.name=t,this.unitLabel=s,this.cardinality=i}set store(t){this._store=t}isLoading(){return this._store.getState().nonhist.dataLoading[this.name]}hasChanges(){const t=this._store.getState();return void 0!==o(t,this.name)||c(t,this.name)>0}hasNext(){return d(this._store.getState(),this.name)<this.records.length-1}hasPrevious(){return d(this._store.getState(),this.name)>0}hasCurrentRecord(){return null!=this.getCurrentRecord()}previous(){this._store.dispatch({type:"FORM/NAVIGATE",payload:{dataUnit:this.name,limit:0,backward:!0}})}next(){this._store.dispatch({type:"FORM/NAVIGATE",payload:{dataUnit:this.name,limit:this.records.length,backward:!1}})}getValue(t){const s=this.getCurrentRecord();if(!s)return;const i=this.getRecordChanges(s);return i&&void 0!==i[t]?i[t]:s[t]||null}getErrorMessage(t){const s=this.getCurrentRecord();return((t,s,i,e)=>((t.nonhist.invalidFields[this.name]||{})[i]||{})[e]||"")(this._store.getState(),0,null==s?void 0:s.record__id,t)}changeValue(t,s){0==this.records.length&&this.insert(),this._changeDeboucing&&window.clearTimeout(this._changeDeboucing),this._changeDeboucing=window.setTimeout((()=>{const i=this.getCurrentRecord();this._store.dispatch(function(t,s,i,e){return{type:"FORM/CHANGEFIELD",payload:{dataUnit:t,recordId:s,fieldName:i,value:e}}}(this.name,i.record__id,t,s))}),100)}cancel(){this.records=this.records.filter((t=>!t.record__id.startsWith("NEW_"))),this._store.dispatch(s(this.name,this.records.length-1))}insert(){const t=this.records.length,s=c(this._store.getState(),this.name);this.records.push({record__id:"NEW_"+(s+1)}),this._store.dispatch(function(t,s){return{type:"FORM/INSERT",payload:{dataUnit:t,insertionIndex:s}}}(this.name,t))}getChangesToSave(){const t=o(this._store.getState(),this.name),s=Object.keys(t).map((s=>{const i={record__id:s},e=t[s];return Object.keys(e).forEach((t=>{i[t]=e[t]})),i}));return[{dataUnit:this.name,records:s}]}save(){if(!this.validateRecords())return;let t;this._store.dispatch({type:"FORM/SAVINGCHANGES",payload:{dataUnit:this.name}}),this.saveExecutor&&(t=this.saveExecutor(this.getChangesToSave())),t instanceof Promise?t.then((t=>this.processSaveResult(t))):this.processSaveResult(t)}load(){let t;this._store.dispatch({type:"FORM/DATALOADING",payload:{dataUnit:this.name}}),this.loadExecutor&&(t=this.loadExecutor({dataUnit:this.name})),t instanceof Promise?t.then((t=>this.processLoadResult(t))):this.processLoadResult(t)}remove(){const t=d(this._store.getState(),this.name);let s;if(this._store.dispatch({type:"FORM/REMOVINGRECORD",payload:{dataUnit:this.name}}),this.removeExecutor){const t=this.getCurrentRecord();s=this.removeExecutor({dataUnit:this.name,recordId:t.record__id,record:t})}else s=!0;s&&(s instanceof Promise?s.then((s=>this.processRemoveResult(s,t))):this.processRemoveResult(s,t))}processSaveResult(t){t&&(t instanceof Array?t.forEach((t=>this.processSaveResult(t))):t.dataUnit===this.name&&t.records.forEach((t=>{let s=t.oldRecord__id;delete t.oldRecord__id,void 0===s&&(s=t.record__id),this.records.forEach(((i,e)=>{i.record__id===s&&(this.records[e]=Object.assign(i,t))}))}))),this._store.dispatch(s(this.name,this.records.length-1)),this._store.dispatch({type:"FORM/CHANGESSAVED",payload:{dataUnit:this.name}})}processLoadResult(t){this.records=t,this._store.dispatch(s(this.name,this.records.length-1)),this._store.dispatch({type:"FORM/DATALOADED",payload:{dataUnit:this.name}})}processRemoveResult(t,i){t&&(this.records.splice(i,1),this._store.dispatch(s(this.name,this.records.length-1))),this._store.dispatch({type:"FORM/RECORDREMOVED",payload:{dataUnit:this.name}})}set records(t){this._records=t}get records(){return this._records||(this._records=[]),this._records}getCurrentRecord(){const t=d(this._store.getState(),this.name);return this.records[t]}getRecordChanges(t){return void 0===t&&(t=this.getCurrentRecord()),t?((t,s,i)=>{const e=o(t,this.name);return e?e[i]:void 0})(this._store.getState(),0,t.record__id):void 0}validateRecords(){if(!this.recordsValidator)return!0;const t=o(this._store.getState(),this.name),s=[];this.records.forEach(((i,e)=>{const h=t[i.record__id];h&&s.push(Object.assign(Object.assign(Object.assign({},i),h),{record__index:e,record__changedfields:Object.keys(h)}))}));const i=this.recordsValidator.validateRecords(this,s);return i.message&&alert(i.message),i.isValid}}export{u as D,a,l as b,i as c,t as d,r as e,e as f,h as i,n as s}
|