@sankhyalabs/ezui 2.1.0 → 2.2.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.
Files changed (34) hide show
  1. package/dist/cjs/ez-collapsible-box.cjs.entry.js +4 -0
  2. package/dist/cjs/ez-form.cjs.entry.js +14 -4
  3. package/dist/cjs/ez-grid.cjs.entry.js +9 -1
  4. package/dist/cjs/ez-tabselector.cjs.entry.js +24 -4
  5. package/dist/cjs/ez-view-stack.cjs.entry.js +4 -0
  6. package/dist/collection/components/ez-collapsible-box/ez-collapsible-box.js +4 -0
  7. package/dist/collection/components/ez-form/ez-form.js +13 -3
  8. package/dist/collection/components/ez-form/structure/FormSheet.js +2 -2
  9. package/dist/collection/components/ez-grid/ez-grid.js +11 -2
  10. package/dist/collection/components/ez-tabselector/ez-tabselector.js +24 -4
  11. package/dist/collection/components/ez-view-stack/ez-view-stack.js +4 -0
  12. package/dist/custom-elements/index.js +52 -9
  13. package/dist/esm/ez-collapsible-box.entry.js +4 -0
  14. package/dist/esm/ez-form.entry.js +15 -5
  15. package/dist/esm/ez-grid.entry.js +11 -3
  16. package/dist/esm/ez-tabselector.entry.js +24 -4
  17. package/dist/esm/ez-view-stack.entry.js +4 -0
  18. package/dist/ezui/ezui.esm.js +1 -1
  19. package/dist/ezui/p-04fab1e9.entry.js +1 -0
  20. package/dist/ezui/{p-d0b8330e.entry.js → p-77b7b623.entry.js} +2 -2
  21. package/dist/ezui/p-8c874b58.entry.js +1 -0
  22. package/dist/ezui/p-a595dd4e.entry.js +1 -0
  23. package/dist/ezui/p-dff2b725.entry.js +1 -0
  24. package/dist/types/components/ez-collapsible-box/ez-collapsible-box.d.ts +1 -0
  25. package/dist/types/components/ez-form/ez-form.d.ts +3 -0
  26. package/dist/types/components/ez-form/structure/FormSheet.d.ts +1 -0
  27. package/dist/types/components/ez-grid/ez-grid.d.ts +3 -0
  28. package/dist/types/components/ez-tabselector/ez-tabselector.d.ts +3 -1
  29. package/dist/types/components/ez-view-stack/ez-view-stack.d.ts +1 -0
  30. package/package.json +1 -1
  31. package/dist/ezui/p-0c7203d5.entry.js +0 -1
  32. package/dist/ezui/p-659616e4.entry.js +0 -1
  33. package/dist/ezui/p-ac296141.entry.js +0 -1
  34. package/dist/ezui/p-f27c364b.entry.js +0 -1
@@ -0,0 +1 @@
1
+ import{r as i,c as l,h as e,g as o}from"./p-3c7ea91b.js";import{ElementIDUtils as t}from"@sankhyalabs/core";import{A as s}from"./p-0b44cf1c.js";import"./p-e1148f5c.js";import"./p-b853763b.js";let a=class{constructor(e){i(this,e),this.ezChange=l(this,"ezChange",7),this.ezRemove=l(this,"ezRemove",7),this.ezSaveEditLabel=l(this,"ezSaveEditLabel",7),this.ezEditLabelMode=l(this,"ezEditLabelMode",7),this._activeEditText=!1,this.value=!1,this.headerSize="small",this.iconPlacement="left",this.stretchTitle=!1,this.removable=!1,this.editable=!1}async showHide(){this.value=!this.value}async applyFocusTextEdit(){var i;null===(i=this._refTextEdit)||void 0===i||i.applyFocusSelect()}async cancelEdition(){this._activeEditText=!1,this.ezEditLabelMode.emit(this._activeEditText)}observeCollapsedValue(){this.ezChange.emit(this.value)}getHeaderSize(){const i=this.headerSize&&this.headerSize.toLowerCase(),l=["xsmall","xlarge"].includes(i)?i.replace("x","x-"):i;return["x-small","small","medium","large","x-large"].includes(l)?l:"small"}removeElement(){this._hostElement&&this._hostElement.remove(),this.ezRemove.emit(this)}editLabel(i){i.preventDefault(),i.stopPropagation(),this._activeEditText=!0,this.ezEditLabelMode.emit(this._activeEditText)}confirmRemove(i){i.preventDefault(),i.stopPropagation(),s.confirm("Aviso",`Deseja realmente remover o grupo <b>${this.label}</b>?`).then((i=>{i&&this.removeElement()}))}saveEditionText(i){const{newValue:l}=i.detail;let e=!0;this.conditionalSave&&(e=this.conditionalSave(l)),this.label!==l&&e&&(this.label=l,this._activeEditText=!1,this.ezSaveEditLabel.emit(i.detail),this.ezEditLabelMode.emit(this._activeEditText))}getStyledLabel(){if(null!=this._refLabel)return{fontSize:window.getComputedStyle(this._refLabel).getPropertyValue("font-size"),fontWeight:window.getComputedStyle(this._refLabel).getPropertyValue("font-weight"),fontFamily:window.getComputedStyle(this._refLabel).getPropertyValue("font-family")}}componentDidLoad(){t.addIDInfo(this._hostElement)}render(){return e("div",{class:"collapsible-box"},e("div",{class:"collapsible-box__header"},e("button",Object.assign({},this._activeEditText?null:{onClick:()=>{this.showHide()}},{class:"collapsible-box__title"+("right"===this.iconPlacement?" collapsible-box__title--icon-right":"")+(this.stretchTitle?" collapsible-box__title--stretched":"")+(this.value?" collapsible-box__title--no-margin":"")}),e("ez-icon",{slot:"icon","icon-name":"chevron-right",size:this.getHeaderSize(),class:"collapsible-box__icon collapsible-box__icon--"+this.getHeaderSize()+(this.value?" collapsible-box__icon--collapsed":"")}),this._activeEditText?e("ez-text-edit",{class:"collapsible-box__text-edit",ref:i=>this._refTextEdit=i,value:this.label,styled:this.getStyledLabel(),onSaveEdition:i=>this.saveEditionText(i),onCancelEdition:()=>this.cancelEdition()}):e("label",{class:"collapsible-box__label font--"+this.getHeaderSize(),title:this.label,ref:i=>this._refLabel=i},e("span",null,this.label),this.editable&&e("ez-icon",{slot:"icon","icon-name":"edit",onClick:i=>this.editLabel(i),title:"Editar"}),this.removable&&e("ez-icon",{slot:"icon","icon-name":"delete",onClick:i=>this.confirmRemove(i),title:"Remover"})))),e("div",{class:"collapsible-box__content"+(this.value?"":" collapsible-box__content--show")},e("slot",null)))}get _hostElement(){return o(this)}static get watchers(){return{value:["observeCollapsedValue"]}}};a.style=":host{--ez-collapsible-box--font-size:var(--title--medium, 14px);--ez-collapsible-box--font-family:var(--font-pattern, Arial);--ez-collapsible-box--font-weight:var(--text-weight--large, 600);--ez-collapsible-box--color:var(--title--primary);--ez-collapsible-box--focus--color:var(--color--primary-600);--ez-collapsible-box__icon--color:var(--ez-collapsible-box--color);--ez-collapsible-box__header--padding-top:0px;--ez-collapsible-box__header--padding-bottom:0px;--ez-collapsible-box__header--padding-right:0px;--ez-collapsible-box__header--padding-left:0px;display:flex;flex-wrap:wrap;width:100%}ez-icon{--ez-icon--color:inherit}.collapsible-box{display:flex;flex-direction:column;width:100%}.collapsible-box__header{display:flex;box-sizing:border-box;padding-top:var(--ez-collapsible-box__header--padding-top);padding-bottom:var(--ez-collapsible-box__header--padding-bottom);padding-right:var(--ez-collapsible-box__header--padding-right);padding-left:var(--ez-collapsible-box__header--padding-left)}.collapsible-box__title{position:relative;width:auto;display:flex;box-sizing:border-box;align-items:center;outline:none;border:none;background-color:unset;cursor:pointer;padding:0px;text-align:left;color:var(--ez-collapsible-box--color);--ez-icon--color:var(--ez-collapsible-box__icon--color);margin-bottom:var(--space--medium, 12px)}.collapsible-box__title:focus{color:var(--ez-collapsible-box--focus--color);--ez-icon--color:var(--ez-collapsible-box--focus--color)}.collapsible-box__label{display:flex;white-space:nowrap;overflow:hidden;cursor:pointer;text-overflow:ellipsis;box-sizing:border-box;margin-left:6px;gap:6px;font-family:var(--ez-collapsible-box--font-family);font-size:var(--ez-collapsible-box--font-size);font-weight:var(--ez-collapsible-box--font-weight)}.collapsible-box__label ez-icon{visibility:hidden;transition:0.25s linear}.collapsible-box__label:hover ez-icon{visibility:visible}.collapsible-box__text-edit{margin-left:6px}.collapsible-box__icon{transform:rotate(90deg) translate(0px, 14%);transition:transform var(--transition)}.collapsible-box__icon--collapsed{transform:rotate(0deg) translate(-14%, 0px)}.collapsible-box__title--icon-right{flex-direction:row-reverse}.collapsible-box__title--icon-right .collapsible-box__icon{transform:rotate(90deg) translate(0px, -14%)}.collapsible-box__title--icon-right .collapsible-box__icon--collapsed{transform:rotate(0deg) translate(14%, 0px)}.collapsible-box__title--icon-right .collapsible-box__label{margin-left:0px;margin-right:6px}.collapsible-box__title--stretched{width:100%;justify-content:space-between}.collapsible-box__title--no-margin{margin-bottom:0}.collapsible-box__content{display:flex;flex-wrap:wrap;width:100%;height:0px;max-height:0px;opacity:0;overflow:hidden;transition:all var(--transition, 0.5s)}.collapsible-box__content--show{height:100%;max-height:none;opacity:1;overflow:visible;transition:all var(--transition, 0.5s)}.font--x-small{font-size:10px}.font--small{font-size:12px}.font--medium{font-size:14px}.font--large{font-size:16px}.font--x-large{font-size:20px}";export{a as ez_collapsible_box}
@@ -0,0 +1 @@
1
+ import{h as e,r as t,c as i,f as n,H as s,g as r}from"./p-3c7ea91b.js";import{UserInterface as l,Action as a,WaitingChangeException as o,ApplicationContext as c,StringUtils as d,DataUnitAction as h,DataUnit as u,ElementIDUtils as f}from"@sankhyalabs/core";import{C as b}from"./p-b853763b.js";import{A as p}from"./p-0b44cf1c.js";import"./p-e1148f5c.js";const m=({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-text-input",{label:i,"data-field-name":t,key:t,enabled:!n}));function v(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?b.SWITCH:b.REGULAR,"data-field-name":t,key:t}))}function z(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 y=new Map;y.set(l.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})))),y.set(l.CHECKBOX,(e=>v(e.name,e.label,e.readOnly,!1))),y.set(l.SWITCH,(e=>v(e.name,e.label,e.readOnly,!0))),y.set(l.OPTIONSELECTOR,(({name:t,label:i,readOnly:n,required:s},r)=>{const l=null==r?void 0:r.options;let a;if("string"==typeof l){const e=JSON.parse(l);a=Object.keys(e).map((t=>({value:t,label:e[t]})))}else a=l;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}))})),y.set(l.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})))),y.set(l.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})))),y.set(l.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})))),y.set(l.TIME,(({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-time-input",{enabled:!n,label:i,"data-field-name":t,key:t})))),y.set(l.DATETIME,(({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-time-input",{enabled:!n,label:i,"data-field-name":t,key:t})))),y.set(l.DECIMALNUMBER,(({name:e,label:t,readOnly:i},n)=>{const s=Number((null==n?void 0:n.precision)||2);return z(e,t,i,s,Number((null==n?void 0:n.prettyPrecision)||s))})),y.set(l.INTEGERNUMBER,(({name:e,label:t,readOnly:i})=>z(e,t,i,0,0)));const g=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),null!=i.required&&!0!==t.required||(i.required=t.required),null!=i.readOnly&&!0!==t.readOnly||(i.readOnly=t.readOnly),s=t.properties,n=y.get(t.userInterface)),i.required&&(i.label=`${i.label} (obrigatório) *`),n||(n=m),n(i,s)},_=({source:t})=>"items"in t?e("ez-collapsible-box",{label:t.label,"header-size":"large"},t.items.map((e=>g(e)))):g(t),w=({store:t,source:i,dataElementId:n})=>e("div",{class:"dynamic-content ez-box__container","data-element-id":n},e("div",{class:"ez-row ez-padding-vertical--small"},i.items.map((i=>e(_,{store:t,source:i})))));class O{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 E(e,t){return"__main"==e[0].label?-1:(e[0].order||1e4)-(t[0].order||1e4)}function A(e,t,i){const n={config:t,descriptor:i};let s=(null==t?void 0:t.group)||i.group;if(s){const t=`group::${s}`;e.has(t)?e.get(t).items.push(n):e.set(t,{label:s,items:[n]})}else e.set((null==t?void 0:t.name)||i.name,n)}function C(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 j="function"==typeof Symbol&&Symbol.observable||"@@observable",x=function(){return Math.random().toString(36).substring(7).split("").join(".")},M={INIT:"@@redux/INIT"+x(),REPLACE:"@@redux/REPLACE"+x(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+x()}};function R(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 S(e,t,i){var n;if("function"==typeof t&&"function"==typeof i||"function"==typeof i&&"function"==typeof arguments[3])throw new Error(C(0));if("function"==typeof t&&void 0===i&&(i=t,t=void 0),void 0!==i){if("function"!=typeof i)throw new Error(C(1));return i(S)(e,t)}if("function"!=typeof e)throw new Error(C(2));var s=e,r=t,l=[],a=l,o=!1;function c(){a===l&&(a=l.slice())}function d(){if(o)throw new Error(C(3));return r}function h(e){if("function"!=typeof e)throw new Error(C(4));if(o)throw new Error(C(5));var t=!0;return c(),a.push(e),function(){if(t){if(o)throw new Error(C(6));t=!1,c();var i=a.indexOf(e);a.splice(i,1),l=null}}}function u(e){if(!R(e))throw new Error(C(7));if(void 0===e.type)throw new Error(C(8));if(o)throw new Error(C(9));try{o=!0,r=s(r,e)}finally{o=!1}for(var t=l=a,i=0;i<t.length;i++)(0,t[i])();return e}function f(e){if("function"!=typeof e)throw new Error(C(10));s=e,u({type:M.REPLACE})}function b(){var e,t=h;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new Error(C(11));function i(){e.next&&e.next(d())}return i(),{unsubscribe:t(i)}}})[j]=function(){return this},e}return u({type:M.INIT}),(n={dispatch:u,subscribe:h,getState:d,replaceReducer:f})[j]=b,n}const k={};function I(e=k,t){switch(t.type){case P.METADATA_LOADED:return Object.assign(Object.assign({},e),{formMetadata:t.payload,currentSheet:void 0});case P.CHANGE_TAB:return Object.assign(Object.assign({},e),{currentSheet:t.payload});default:return e}}function N(e){return e.formMetadata}var P;!function(e){e.METADATA_LOADED="FORM/METADATA_LOADED",e.CHANGE_TAB="FORM/CHANGE_TAB"}(P||(P={}));class D{constructor(e){this._invalidFields=new Map,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.EDITION_CANCELED:case a.SELECTION_CHANGED:case a.NEXT_SELECTED:case a.PREVIOUS_SELECTED:this.clearInvalid();case a.DATA_CHANGED:case a.CHANGE_UNDONE:case a.CHANGE_REDONE:case a.RECORD_LOADED: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)}markInvalid(e){if(this._invalidFields.set(e.name,e),this._fields.has(e.name)){const t=this._fields.get(e.name).field;t.errorMessage||this.updateErrorMessage(e.name,t)}}clearInvalid(){this._invalidFields.clear(),this._fields.forEach((e=>{this.updateErrorMessage(e.field.dataset.fieldName,e.field)}))}updateValue(e,t){const i=this._fields.get(e);try{i&&(i.listen=!1),t.value=this._dataUnit.getFieldValue(e),this.updateErrorMessage(e,t)}finally{i&&(i.listen=!0)}}updateErrorMessage(e,t){const i=this._invalidFields.get(e);i&&(t.errorMessage=i.message)}getErrorMessage(e){if(this._fields.has(e))return this._fields.get(e).field.errorMessage||null}updateBind(e,t){const i=this._fields.get(e);i&&i.destroy(),t.value=this._dataUnit.getFieldValue(e),this.updateErrorMessage(e,t),this._fields.set(e,L.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 o("Change canceled",e))}}setFieldValue(e,t){if(0===this._dataUnit.records.length&&this._dataUnit.addRecord(),this._invalidFields.delete(e),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 L{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(e){this.waitingChangePromiseReject&&(this.waitingChangePromiseReject(e),this.waitingChangePromiseReject=void 0,this.waitingChangePromiseResolve=void 0)}static create(e,t,i,n,s){const r=new L;return r.field=t,r.fieldName=e,r.startChangeListener=t=>{r.listen&&i(e,t.detail)},r.field.addEventListener(r.startChangeEventName,r.startChangeListener),r.cancelWaitingChangeListener=()=>{r.listen&&n(e)},r.field.addEventListener(r.cancelWaitingChangeEventName,r.cancelWaitingChangeListener),r.changeListener=t=>{r.listen&&s(e,t.detail)},r.field.addEventListener(r.changeEventName,r.changeListener),r}}let T=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)=>{var i;const n=this.dataUnit.getModifiedRecords();for(let e=0;e<n.length;e++){const s=n[e],r=[];let l=this.validateRequired(s);if(l&&!l.isValid&&r.push(l),l=null===(i=this.recordsValidator)||void 0===i?void 0:i.validateRecord(this,s),l&&!l.isValid&&r.push(l),r.length>0){this.processValidationResult(r),t();break}}e()}))}observeConfig(){this.processMetadata()}validateRequired(e){const t=N(this._store.getState()),i=this._staticFields.filter((e=>e.dataset.required)).map((e=>e.dataset.fieldName)).concat(t.getRequiredFields()),n=[];if(new Set(i).forEach((t=>{const i=e[t];if(null==i||""===i){const e=this._dataBinder.getErrorMessage(t);n.push(e?{name:t,message:e}:{name:t,message:"Essa informação é obrigatória"})}})),n.length>0)return{isValid:!1,invalidFields:n,infoMessage:"Há pelo menos um campo obrigatório não preenchido."}}processValidationResult(e){e.forEach((e=>{const t=e.invalidFields;if(t&&t.forEach((e=>{this._dataBinder.markInvalid(e)})),e.infoMessage&&p.info(e.infoMessage),e.errorMessage){const{errorTitle:t,errorMessage:i}=e;p.error(t,i)}}))}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()),l=[];if(r.length>1){const t=r.map(((e,t)=>({tabKey:e.name,label:e.label,index:t}))),i=`${this._dataElementIdEzForm}_internal_tabSelector`;l.push(e("ez-tabselector",{tabs:this.buildIdTabSelector(t),onEzChange:e=>this._store.dispatch(function(e){return{type:P.CHANGE_TAB,payload:e.tabKey}}(e.detail)),selectedTab:n.name,"data-element-id":i}))}const a=`${this._dataElementIdEzForm}_${d.toCamelCase(n.label)}`;return l.push(e(w,{store:this._store,source:n,dataElementId:a})),l}processMetadata(){if(!this.isStatic()&&this.dataUnit){const e=null!=this.config&&Object.values(this.config).length>0?((e,t)=>{var i,n;const s=new Map,r=new Map,l=[],a=[],o={};null===(i=null==e?void 0:e.tabs)||void 0===i||i.forEach((e=>{r.has(e.label)||!1!==e.visible||r.set(e.label,e)})),null===(n=null==e?void 0:e.fields)||void 0===n||n.forEach((e=>{var i,n,c;if(!1!==e.visible){const d=function(e,t){return("string"==typeof e?Array.from(t.keys()).find((t=>t.label===e)):e)||{label:e,visible:!0}}(e.tab||"__main",s);if(r.has(d.label))return;const h=t.getField(e.name);if(h&&d.visible){s.has(d)||s.set(d,new Map);const t=s.get(d);(null==e.required?h.required:e.required)&&l.push(e.name),((null==e.cleanOnCopy?null===(i=h.properties)||void 0===i?void 0:i.cleanOnCopy:e.cleanOnCopy)||(null===(n=h.properties)||void 0===n?void 0:n.autoNum))&&a.push(e.name),(null==e.defaultValue?null===(c=h.properties)||void 0===c?void 0:c.defaultValue:e.defaultValue)&&(o[e.name]=e.defaultValue),A(t,e,h)}}}));const c=new O;return Array.from(s.entries()).sort(E).forEach((([e,t])=>{c.addSheet({label:"__main"===e.label?"Principal":e.label,name:e.label,items:Array.from(t.values()),requiredFields:l,cleanOnCopyFields:a,defaultValues:o})})),c})(this.config,this.dataUnit):(()=>{var e,t;const i=this.dataUnit.metadata,n=new O;if(i){const s=null===(e=i.fields)||void 0===e?void 0:e.filter((e=>!1!==e.visible)),r=new Map;null===(t=null==i?void 0:i.fields)||void 0===t||t.forEach((e=>{!1!==e.visible&&A(r,null,e)}));let l={};s.filter((e=>e.defaultValue)).map((e=>l[e.name]=e.defaultValue)),n.addSheet({label:i.label,name:i.name,items:Array.from(r.values()),requiredFields:s.filter((e=>e.required)).map((e=>e.name)),cleanOnCopyFields:s.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:l})}return n})();this._store.dispatch({type:P.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 h(a.RECORDS_COPIED,e.payload.map((e=>{const i=Object.assign({},e);return t.forEach((e=>delete i[e])),i})))}if(e.type===a.SAVING_DATA)return new Promise((t=>{this.validate().then((()=>t(e))).catch((()=>{}))}));if(e.type===a.RECORDS_ADDED){const t=N(this._store.getState()).getDefaultValues();if(t)return new h(a.RECORDS_ADDED,e.payload.map((e=>{const i=Object.assign({},e);for(const e in t){const n="formattedValue"in t[e]?t[e].formattedValue:t[e].value,s=null!=n?n:t[e],r="function"==typeof s?s():s;i[e]=this.dataUnit.valueFromString(e,r)}return i})))}return e}componentWillLoad(){void 0===this.dataUnit&&(this.dataUnit=new u("ez-form")),this.dataUnit.addInterceptor(this),this.dataUnit.subscribe(this.onDataUnitAction),this._dataBinder=new D(this.dataUnit),this._store=S(I),this._store.subscribe((()=>n(this))),this._staticFields=Array.from(this._element.querySelectorAll("[data-field-name]")),this.processMetadata(),this._dataElementIdEzForm=f.addIDInfo(this._element,null,{dataUnit:this.dataUnit})}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()}buildIdTabSelector(e){return e&&e.forEach((e=>e["data-element-id"]=`${this._dataElementIdEzForm}_${d.toCamelCase(e.label)}`)),e}render(){return e(s,null,this.isStatic()?null:this.getDynamicContent())}get _element(){return r(this)}static get watchers(){return{config:["observeConfig"]}}};T.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{T as ez_form}
@@ -0,0 +1 @@
1
+ import{r as t,c as i,h as s,H as e,g as a}from"./p-3c7ea91b.js";import{ElementIDUtils as o,StringUtils as r}from"@sankhyalabs/core";let n=class{constructor(s){t(this,s),this.ezChange=i(this,"ezChange",7),this.setFocusedParam=t=>{if("Enter"===t.key){const i=this._processedTabs[this._focusedIndex];this.handleTabClick(i),t.preventDefault(),this.setFocusedTab(i.index)}else if("ArrowLeft"===t.key||"ArrowRight"===t.key){let i;if("ArrowLeft"===t.key)i=!1;else{if("ArrowRight"!==t.key)return;i=!0}this._focusedIndex=void 0===this._focusedIndex?!1===i?void 0!==this.selectedIndex?this.selectedIndex-1:void 0:void 0!==this.selectedIndex?this.selectedIndex+1:void 0:!1===i?this._focusedIndex-1:this._focusedIndex+1,this._focusedIndex<0?this._focusedIndex=0:this._focusedIndex>this._processedTabs.length-1&&(this._focusedIndex=this._processedTabs.length-1),this.setFocusedBtn(!0,this._focusedIndex),this.setFocusedTab(this._focusedIndex)}else if("Tab"===t.key||"Escape"===t.key){const i=this._processedTabs[this.selectedIndex];this._focusedIndex=void 0,this.handleTabClick(i),t.preventDefault(),this.setFocusedTab(this.selectedIndex)}}}observeTabs(t){t&&"string"!=typeof t&&(this._processedTabs=t)}handleTabClick(t){this.selectedIndex=t.index,this._focusedIndex=void 0,this.selectedTab=t.tabKey,this.ezChange.emit(t),this.setFocusedBtn(!1,t.index)}componentWillRender(){o.addIDInfo(this._hostElem),this._processedTabs||(this._processedTabs=[],this.tabs&&"string"==typeof this.tabs&&this.tabs.split(",").forEach((t=>{t=t.trim(),this._processedTabs.push({label:t,tabKey:t,index:this._processedTabs.length}),this.buildElementIdTab(this._processedTabs)})),this._hostElem.querySelectorAll("ez-tab").forEach((t=>{const i=t.getAttribute("tabKey"),s={label:t.getAttribute("label"),tabKey:i,leftIcon:t.getAttribute("leftIcon"),rightIcon:t.getAttribute("rightIcon"),index:this._processedTabs.length},e=t.firstChild;e&&(e.setAttribute("slot","tab"+s.index),this._hostElem.appendChild(e)),this._processedTabs.push(s),this.buildElementIdTab(this._processedTabs)})))}componentDidRender(){this.updateScroll()}componentDidLoad(){this._hostElem.shadowRoot.querySelectorAll('button[name="tab-button"]').forEach((t=>{const i={id:`${this._hostElem.getAttribute("data-element-id")}_${r.toCamelCase(t.id)}`};o.addIDInfo(t,null,i)}))}handleSlotChange(t){const i=t.target.assignedElements()[0];i&&(i.style.marginLeft="6px")}scrollBackward(){const t=this._scrollContainer;t&&(t.scrollLeft-=t.clientWidth)}scrollFoward(){const t=this._scrollContainer;if(t){let i=null;t.querySelectorAll(".tab").forEach((s=>{s.getBoundingClientRect().right<t.clientWidth&&(i=s)})),t.scrollLeft=i.offsetLeft+i.offsetWidth}}updateScroll(){const t=this._scrollContainer;if(t){const{scrollWidth:i,clientWidth:s,scrollLeft:e}=t,a=i-s-Math.ceil(e);this._startHidden=t.scrollLeft>0,this._endHidden=a>0,this._startHidden?this._backwardButton.classList.remove("hidden"):this._backwardButton.classList.add("hidden"),this._endHidden?this._forwardButton.classList.remove("hidden"):this._forwardButton.classList.add("hidden");const o=["","startHidden","endHidden","middle"],r=o[Number(this._startHidden)|Number(this._endHidden)<<1];o.forEach((i=>{i!==r&&t.classList.contains(i)&&t.classList.remove(i)})),r&&!t.classList.contains(r)&&t.classList.add(r)}}domScrollHandler(){window.clearTimeout(this._scrollCallBack),this._scrollCallBack=window.setTimeout((()=>{this.updateScroll()}),200)}setFocusedTab(t){window.clearTimeout(this._scrollCallBackTest),this._scrollCallBackTest=window.setTimeout((()=>{this._scrollContainer.querySelector(`#tab${t}`).scrollIntoView()}),200)}getTextWidth(t){void 0===this._textMesurement&&(this._textMesurement=this._hostElem.shadowRoot.ownerDocument.createElement("canvas"));const i=this._textMesurement.getContext("2d");return i.font="14px Sora, Algerian",Math.min(220,24+i.measureText(t).width)+"px"}setFocusedBtn(t,i){this._scrollContainer.querySelectorAll(".tab").forEach((s=>{s.classList.remove("is-focused"),s.id==="tab"+i&&t&&s.classList.add("is-focused")}))}buildElementIdTab(t){t.forEach((t=>{if(!t.hasOwnProperty("data-element-id")){const i=`${this._hostElem.getAttribute("data-element-id")}_${r.toCamelCase(t.tabKey)}`;t["data-element-id"]=i}}))}render(){return s(e,null,s("button",{class:"backward-button",ref:t=>this._backwardButton=t,onClick:()=>this.scrollBackward()}),s("div",{class:"scroll",ref:t=>this._scrollContainer=t,onScroll:()=>this.domScrollHandler(),onKeyDown:t=>this.setFocusedParam(t)},this._processedTabs.map(((t,i)=>{const e={"min-width":this.getTextWidth(t.label)},a="tab"+i,o=i===this.selectedIndex||this.selectedTab&&t.tabKey===this.selectedTab;return o&&(this.selectedTab=t.tabKey,this.selectedIndex=i),s("button",{id:a,name:"tab-button",class:"tab"+(o?" is-active":""),onClick:()=>this.handleTabClick(t),style:e},t.leftIcon&&s("ez-icon",{iconName:t.leftIcon,class:"left-icon"}),s("span",{class:"tab-label",title:t.label},t.label),t.rightIcon&&s("ez-icon",{iconName:t.rightIcon,class:"right-icon"}),s("slot",{name:a,onSlotchange:t=>{this.handleSlotChange(t)}}))}))),s("button",{class:"forward-button",ref:t=>this._forwardButton=t,onClick:()=>this.scrollFoward()}))}get _hostElem(){return a(this)}static get watchers(){return{tabs:["observeTabs"]}}};n.style='@keyframes activate{0%{clip-path:inset(calc(100% - 3px) 50% 0px 50%)}100%{clip-path:inset(calc(100% - 3px) 0px 0px 0px)}}:host{display:flex;position:relative;width:100%;overflow:hidden;--tabselector--backward-icon:url(\'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="16px" width="10px"><path d="M 9.7808475,13.860393 3.9204526,8.0000004 9.7808475,2.0624965 7.9301965,0.28895552 0.21915255,8.0000004 7.9301965,15.711044 Z"/></svg>\');--tabselector--forward-icon:url(\'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="16px" width="10px"><path d="M 0.21915251,13.860393 6.0795475,8.0000007 0.21915251,2.0624968 2.0698036,0.28895588 9.7808475,8.0000007 2.0698036,15.711044 Z"/></svg>\')}.scroll{display:flex;width:100%;scroll-behavior:smooth;overflow-x:auto;scrollbar-width:none}.scroll.startHidden{-webkit-mask-image:linear-gradient(90deg, transparent 20px, #000 48px)}.scroll.middle{-webkit-mask-image:linear-gradient(90deg, transparent 20px, #000 48px, #000 calc(100% - 48px), transparent calc(100% - 20px))}.scroll.endHidden{-webkit-mask-image:linear-gradient(90deg, #000 calc(100% - 48px), transparent calc(100% - 20px))}.tab{display:flex;border:none;min-width:100px;background-color:unset;cursor:pointer;padding:6px 12px;align-items:center;justify-content:center;color:var(--text--primary, #626e82);font-family:var(--font-pattern, "Roboto");font-size:var(--title--small, 14px)}.tab:focus,.forward-button,.backward-button{outline:none}.is-active{position:relative;color:var(--color--primary, #008561)}.is-active::after{content:"";position:absolute;width:100%;height:100%;background-color:var(--color--primary, #008561);clip-path:inset(calc(100% - 3px) 0px 0px 0px);animation:activate 0.25s ease-in-out}.is-focused{border:1px dashed var(--color--primary, #000000c5)}.tab-label{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;text-shadow:var(--text-shadow);margin-bottom:var(--space--extra-small, 3px)}.forward-button,.backward-button{position:absolute;z-index:1;display:flex;box-sizing:border-box;padding:0px;top:0px;right:0px;width:16px;height:100%;border:none;background-color:unset;cursor:pointer;justify-content:center;align-items:center}.backward-button{left:0px}.forward-button::after,.backward-button::after{content:\'\';display:flex;background-color:var(--text--primary, #008561);width:10px;height:16px}.forward-button::after{-webkit-mask-image:var(--tabselector--forward-icon);mask-image:var(--tabselector--forward-icon)}.backward-button::after{-webkit-mask-image:var(--tabselector--backward-icon);mask-image:var(--tabselector--backward-icon)}.forward-button:hover::after,.backward-button:hover::after{background-color:var(--color--primary, #4e4e4e)}.hidden{display:none}.scroll::-webkit-scrollbar{display:none}.left-icon{padding-right:var(--space--small)}.right-icon{padding-left:var(--space--small)}';export{n as ez_tabselector}
@@ -78,5 +78,6 @@ export declare class EzCollapsibleBox {
78
78
  fontWeight: string;
79
79
  fontFamily: string;
80
80
  };
81
+ componentDidLoad(): void;
81
82
  render(): any;
82
83
  }
@@ -1,10 +1,12 @@
1
1
  import { EventEmitter } from "../../stencil-public-runtime";
2
2
  import { DataUnit, Record, DUActionInterceptor, DataUnitAction } from "@sankhyalabs/core";
3
+ import { Tab } from "../ez-tabselector/ez-tabselector";
3
4
  export declare class EzForm implements DUActionInterceptor {
4
5
  private _element;
5
6
  private _store;
6
7
  private _staticFields;
7
8
  private _dataBinder;
9
+ private _dataElementIdEzForm;
8
10
  /**
9
11
  * Repositório de dados, controla a manipulação dos dados
10
12
  */
@@ -35,6 +37,7 @@ export declare class EzForm implements DUActionInterceptor {
35
37
  onDataUnitAction: (action: any) => void;
36
38
  componentDidRender(): void;
37
39
  disconnectedCallback(): void;
40
+ buildIdTabSelector(tabs: Array<Tab>): Array<Tab>;
38
41
  render(): any;
39
42
  }
40
43
  export interface IFieldConfig {
@@ -4,6 +4,7 @@ import { FormSheetMetadata } from "./FormSheetMetadata";
4
4
  interface FormSheetProps {
5
5
  source: FormSheetMetadata;
6
6
  store: Store;
7
+ dataElementId: string;
7
8
  }
8
9
  export declare const FormSheet: FunctionalComponent<FormSheetProps>;
9
10
  export {};
@@ -3,8 +3,10 @@ import { EventEmitter } from "../../stencil-public-runtime";
3
3
  import EzGridController, { EzGridColumn, EzGridColumnConfig, EzGridColumStateEvent, IGridConfig, IStatusResolver } from "./controller/EzGridController";
4
4
  export declare class EzGrid {
5
5
  _container: HTMLElement;
6
+ _refPaginationControl: HTMLElement;
6
7
  _gridController: EzGridController;
7
8
  _lastColumnMovedName: string;
9
+ _element: HTMLElement;
8
10
  private _paginationInfo;
9
11
  /**
10
12
  * Evento disparado ao mudar o estado das colunas do grid. Ordenação, largura, etc.
@@ -81,6 +83,7 @@ export declare class EzGrid {
81
83
  onColumnStateChange(type: string, state: Array<EzGridColumn>, info: any): void;
82
84
  private createConfigFromState;
83
85
  componentDidLoad(): void;
86
+ buildDataElementId(): void;
84
87
  previousPage(): void;
85
88
  nextPage(): void;
86
89
  getPaginationControl(): Array<HTMLElement>;
@@ -32,10 +32,11 @@ export declare class EzTabselector {
32
32
  observeTabs(newValue: any): void;
33
33
  handleTabClick(tab: Tab): void;
34
34
  componentWillRender(): void;
35
+ componentDidRender(): void;
36
+ componentDidLoad(): void;
35
37
  handleSlotChange(ev: Event): void;
36
38
  scrollBackward(): void;
37
39
  scrollFoward(): void;
38
- componentDidRender(): void;
39
40
  updateScroll(): void;
40
41
  _scrollCallBack: number;
41
42
  domScrollHandler(): void;
@@ -44,6 +45,7 @@ export declare class EzTabselector {
44
45
  getTextWidth(text: string): string;
45
46
  setFocusedParam: (ev: KeyboardEvent) => void;
46
47
  setFocusedBtn(visible: boolean, parameter: number): void;
48
+ buildElementIdTab(tabs: Array<any>): void;
47
49
  render(): any;
48
50
  }
49
51
  export interface Tab {
@@ -19,6 +19,7 @@ export declare class EzViewStack {
19
19
  policyShowAppend(index: number): void;
20
20
  checkElementVisibility(element: Element): void;
21
21
  componentWillRender(): void;
22
+ componentDidLoad(): void;
22
23
  disconectCallback(): void;
23
24
  render(): any;
24
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sankhyalabs/ezui",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Biblioteca de componentes Sankhya.",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/custom-elements/index.js",
@@ -1 +0,0 @@
1
- import{r as t,h as i,g as e,H as s}from"./p-3c7ea91b.js";let h=class{constructor(i){t(this,i),this._dataKey="id_".concat(Date.now().toString())}async show(t){t!==this._focusedIndex&&0<=t&&t<this._totalStackItems&&(this.policyHideRemove(),this.policyShowAppend(t),this._focusedIndex=t)}async getSelectedIndex(){return this._focusedIndex}policyHideRemove(){let t=this._hostElem.querySelector(`#${this._dataKey}_el_${this._focusedIndex}`);this.checkElementVisibility(t)}policyShowAppend(t){let i=this._hostElem.querySelector(`#${this._dataKey}_el_${t}`);i?i.removeAttribute("style"):this._hostElem.append(this._elemList[t])}checkElementVisibility(t){"hide"!==t.getAttribute("hidePolicy")&&t.getAttribute("hidePolicy")?"remove"===t.getAttribute("hidePolicy")&&t.remove():t.setAttribute("style","display: none")}componentWillRender(){this._elemList||(this._elemList=[],this._focusedIndex=0,this._totalStackItems=0,this._hostElem.classList.add("ez-view-stack__container"),this._hostElem.querySelectorAll(":scope > stack-item").forEach(((t,i)=>{t.setAttribute("id",`${this._dataKey}_el_${i}`),0!==i&&this.checkElementVisibility(t),this._totalStackItems++,this._elemList.push(t)})))}disconectCallback(){this._hostElem=null,this._elemList=null}render(){return i(s,null)}get _hostElem(){return e(this)}};h.style=":host{width:100%;height:100%}.ez-view-stack__container{width:100%;height:100%}";export{h as ez_view_stack}
@@ -1 +0,0 @@
1
- import{r as i,c as l,h as e,g as o}from"./p-3c7ea91b.js";import{A as t}from"./p-0b44cf1c.js";import"./p-e1148f5c.js";import"./p-b853763b.js";let s=class{constructor(e){i(this,e),this.ezChange=l(this,"ezChange",7),this.ezRemove=l(this,"ezRemove",7),this.ezSaveEditLabel=l(this,"ezSaveEditLabel",7),this.ezEditLabelMode=l(this,"ezEditLabelMode",7),this._activeEditText=!1,this.value=!1,this.headerSize="small",this.iconPlacement="left",this.stretchTitle=!1,this.removable=!1,this.editable=!1}async showHide(){this.value=!this.value}async applyFocusTextEdit(){var i;null===(i=this._refTextEdit)||void 0===i||i.applyFocusSelect()}async cancelEdition(){this._activeEditText=!1,this.ezEditLabelMode.emit(this._activeEditText)}observeCollapsedValue(){this.ezChange.emit(this.value)}getHeaderSize(){const i=this.headerSize&&this.headerSize.toLowerCase(),l=["xsmall","xlarge"].includes(i)?i.replace("x","x-"):i;return["x-small","small","medium","large","x-large"].includes(l)?l:"small"}removeElement(){this._hostElement&&this._hostElement.remove(),this.ezRemove.emit(this)}editLabel(i){i.preventDefault(),i.stopPropagation(),this._activeEditText=!0,this.ezEditLabelMode.emit(this._activeEditText)}confirmRemove(i){i.preventDefault(),i.stopPropagation(),t.confirm("Aviso",`Deseja realmente remover o grupo <b>${this.label}</b>?`).then((i=>{i&&this.removeElement()}))}saveEditionText(i){const{newValue:l}=i.detail;let e=!0;this.conditionalSave&&(e=this.conditionalSave(l)),this.label!==l&&e&&(this.label=l,this._activeEditText=!1,this.ezSaveEditLabel.emit(i.detail),this.ezEditLabelMode.emit(this._activeEditText))}getStyledLabel(){if(null!=this._refLabel)return{fontSize:window.getComputedStyle(this._refLabel).getPropertyValue("font-size"),fontWeight:window.getComputedStyle(this._refLabel).getPropertyValue("font-weight"),fontFamily:window.getComputedStyle(this._refLabel).getPropertyValue("font-family")}}render(){return e("div",{class:"collapsible-box"},e("div",{class:"collapsible-box__header"},e("button",Object.assign({},this._activeEditText?null:{onClick:()=>{this.showHide()}},{class:"collapsible-box__title"+("right"===this.iconPlacement?" collapsible-box__title--icon-right":"")+(this.stretchTitle?" collapsible-box__title--stretched":"")+(this.value?" collapsible-box__title--no-margin":"")}),e("ez-icon",{slot:"icon","icon-name":"chevron-right",size:this.getHeaderSize(),class:"collapsible-box__icon collapsible-box__icon--"+this.getHeaderSize()+(this.value?" collapsible-box__icon--collapsed":"")}),this._activeEditText?e("ez-text-edit",{class:"collapsible-box__text-edit",ref:i=>this._refTextEdit=i,value:this.label,styled:this.getStyledLabel(),onSaveEdition:i=>this.saveEditionText(i),onCancelEdition:()=>this.cancelEdition()}):e("label",{class:"collapsible-box__label font--"+this.getHeaderSize(),title:this.label,ref:i=>this._refLabel=i},e("span",null,this.label),this.editable&&e("ez-icon",{slot:"icon","icon-name":"edit",onClick:i=>this.editLabel(i),title:"Editar"}),this.removable&&e("ez-icon",{slot:"icon","icon-name":"delete",onClick:i=>this.confirmRemove(i),title:"Remover"})))),e("div",{class:"collapsible-box__content"+(this.value?"":" collapsible-box__content--show")},e("slot",null)))}get _hostElement(){return o(this)}static get watchers(){return{value:["observeCollapsedValue"]}}};s.style=":host{--ez-collapsible-box--font-size:var(--title--medium, 14px);--ez-collapsible-box--font-family:var(--font-pattern, Arial);--ez-collapsible-box--font-weight:var(--text-weight--large, 600);--ez-collapsible-box--color:var(--title--primary);--ez-collapsible-box--focus--color:var(--color--primary-600);--ez-collapsible-box__icon--color:var(--ez-collapsible-box--color);--ez-collapsible-box__header--padding-top:0px;--ez-collapsible-box__header--padding-bottom:0px;--ez-collapsible-box__header--padding-right:0px;--ez-collapsible-box__header--padding-left:0px;display:flex;flex-wrap:wrap;width:100%}ez-icon{--ez-icon--color:inherit}.collapsible-box{display:flex;flex-direction:column;width:100%}.collapsible-box__header{display:flex;box-sizing:border-box;padding-top:var(--ez-collapsible-box__header--padding-top);padding-bottom:var(--ez-collapsible-box__header--padding-bottom);padding-right:var(--ez-collapsible-box__header--padding-right);padding-left:var(--ez-collapsible-box__header--padding-left)}.collapsible-box__title{position:relative;width:auto;display:flex;box-sizing:border-box;align-items:center;outline:none;border:none;background-color:unset;cursor:pointer;padding:0px;text-align:left;color:var(--ez-collapsible-box--color);--ez-icon--color:var(--ez-collapsible-box__icon--color);margin-bottom:var(--space--medium, 12px)}.collapsible-box__title:focus{color:var(--ez-collapsible-box--focus--color);--ez-icon--color:var(--ez-collapsible-box--focus--color)}.collapsible-box__label{display:flex;white-space:nowrap;overflow:hidden;cursor:pointer;text-overflow:ellipsis;box-sizing:border-box;margin-left:6px;gap:6px;font-family:var(--ez-collapsible-box--font-family);font-size:var(--ez-collapsible-box--font-size);font-weight:var(--ez-collapsible-box--font-weight)}.collapsible-box__label ez-icon{visibility:hidden;transition:0.25s linear}.collapsible-box__label:hover ez-icon{visibility:visible}.collapsible-box__text-edit{margin-left:6px}.collapsible-box__icon{transform:rotate(90deg) translate(0px, 14%);transition:transform var(--transition)}.collapsible-box__icon--collapsed{transform:rotate(0deg) translate(-14%, 0px)}.collapsible-box__title--icon-right{flex-direction:row-reverse}.collapsible-box__title--icon-right .collapsible-box__icon{transform:rotate(90deg) translate(0px, -14%)}.collapsible-box__title--icon-right .collapsible-box__icon--collapsed{transform:rotate(0deg) translate(14%, 0px)}.collapsible-box__title--icon-right .collapsible-box__label{margin-left:0px;margin-right:6px}.collapsible-box__title--stretched{width:100%;justify-content:space-between}.collapsible-box__title--no-margin{margin-bottom:0}.collapsible-box__content{display:flex;flex-wrap:wrap;width:100%;height:0px;max-height:0px;opacity:0;overflow:hidden;transition:all var(--transition, 0.5s)}.collapsible-box__content--show{height:100%;max-height:none;opacity:1;overflow:visible;transition:all var(--transition, 0.5s)}.font--x-small{font-size:10px}.font--small{font-size:12px}.font--medium{font-size:14px}.font--large{font-size:16px}.font--x-large{font-size:20px}";export{s as ez_collapsible_box}
@@ -1 +0,0 @@
1
- import{h as e,r as t,c as i,f as n,H as s,g as r}from"./p-3c7ea91b.js";import{UserInterface as l,Action as a,WaitingChangeException as o,ApplicationContext as c,DataUnitAction as d,DataUnit as h}from"@sankhyalabs/core";import{C as u}from"./p-b853763b.js";import{A as f}from"./p-0b44cf1c.js";import"./p-e1148f5c.js";const b=({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-text-input",{label:i,"data-field-name":t,key:t,enabled:!n}));function p(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?u.SWITCH:u.REGULAR,"data-field-name":t,key:t}))}function m(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 v=new Map;v.set(l.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})))),v.set(l.CHECKBOX,(e=>p(e.name,e.label,e.readOnly,!1))),v.set(l.SWITCH,(e=>p(e.name,e.label,e.readOnly,!0))),v.set(l.OPTIONSELECTOR,(({name:t,label:i,readOnly:n,required:s},r)=>{const l=null==r?void 0:r.options;let a;if("string"==typeof l){const e=JSON.parse(l);a=Object.keys(e).map((t=>({value:t,label:e[t]})))}else a=l;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}))})),v.set(l.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})))),v.set(l.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})))),v.set(l.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})))),v.set(l.TIME,(({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-time-input",{enabled:!n,label:i,"data-field-name":t,key:t})))),v.set(l.DATETIME,(({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-time-input",{enabled:!n,label:i,"data-field-name":t,key:t})))),v.set(l.DECIMALNUMBER,(({name:e,label:t,readOnly:i},n)=>{const s=Number((null==n?void 0:n.precision)||2);return m(e,t,i,s,Number((null==n?void 0:n.prettyPrecision)||s))})),v.set(l.INTEGERNUMBER,(({name:e,label:t,readOnly:i})=>m(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),null!=i.required&&!0!==t.required||(i.required=t.required),null!=i.readOnly&&!0!==t.readOnly||(i.readOnly=t.readOnly),s=t.properties,n=v.get(t.userInterface)),i.required&&(i.label=`${i.label} (obrigatório) *`),n||(n=b),n(i,s)},y=({source:t})=>"items"in t?e("ez-collapsible-box",{label:t.label,"header-size":"large"},t.items.map((e=>z(e)))):z(t),g=({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(y,{store:t,source:i})))));class _{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"__main"==e[0].label?-1:(e[0].order||1e4)-(t[0].order||1e4)}function O(e,t,i){const n={config:t,descriptor:i};let s=(null==t?void 0:t.group)||i.group;if(s){const t=`group::${s}`;e.has(t)?e.get(t).items.push(n):e.set(t,{label:s,items:[n]})}else e.set((null==t?void 0:t.name)||i.name,n)}function E(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 A="function"==typeof Symbol&&Symbol.observable||"@@observable",C=function(){return Math.random().toString(36).substring(7).split("").join(".")},j={INIT:"@@redux/INIT"+C(),REPLACE:"@@redux/REPLACE"+C(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+C()}};function x(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 M(e,t,i){var n;if("function"==typeof t&&"function"==typeof i||"function"==typeof i&&"function"==typeof arguments[3])throw new Error(E(0));if("function"==typeof t&&void 0===i&&(i=t,t=void 0),void 0!==i){if("function"!=typeof i)throw new Error(E(1));return i(M)(e,t)}if("function"!=typeof e)throw new Error(E(2));var s=e,r=t,l=[],a=l,o=!1;function c(){a===l&&(a=l.slice())}function d(){if(o)throw new Error(E(3));return r}function h(e){if("function"!=typeof e)throw new Error(E(4));if(o)throw new Error(E(5));var t=!0;return c(),a.push(e),function(){if(t){if(o)throw new Error(E(6));t=!1,c();var i=a.indexOf(e);a.splice(i,1),l=null}}}function u(e){if(!x(e))throw new Error(E(7));if(void 0===e.type)throw new Error(E(8));if(o)throw new Error(E(9));try{o=!0,r=s(r,e)}finally{o=!1}for(var t=l=a,i=0;i<t.length;i++)(0,t[i])();return e}function f(e){if("function"!=typeof e)throw new Error(E(10));s=e,u({type:j.REPLACE})}function b(){var e,t=h;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new Error(E(11));function i(){e.next&&e.next(d())}return i(),{unsubscribe:t(i)}}})[A]=function(){return this},e}return u({type:j.INIT}),(n={dispatch:u,subscribe:h,getState:d,replaceReducer:f})[A]=b,n}const R={};function k(e=R,t){switch(t.type){case S.METADATA_LOADED:return Object.assign(Object.assign({},e),{formMetadata:t.payload,currentSheet:void 0});case S.CHANGE_TAB:return Object.assign(Object.assign({},e),{currentSheet:t.payload});default:return e}}function N(e){return e.formMetadata}var S;!function(e){e.METADATA_LOADED="FORM/METADATA_LOADED",e.CHANGE_TAB="FORM/CHANGE_TAB"}(S||(S={}));class P{constructor(e){this._invalidFields=new Map,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.EDITION_CANCELED:case a.SELECTION_CHANGED:case a.NEXT_SELECTED:case a.PREVIOUS_SELECTED:this.clearInvalid();case a.DATA_CHANGED:case a.CHANGE_UNDONE:case a.CHANGE_REDONE:case a.RECORD_LOADED: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)}markInvalid(e){if(this._invalidFields.set(e.name,e),this._fields.has(e.name)){const t=this._fields.get(e.name).field;t.errorMessage||this.updateErrorMessage(e.name,t)}}clearInvalid(){this._invalidFields.clear(),this._fields.forEach((e=>{this.updateErrorMessage(e.field.dataset.fieldName,e.field)}))}updateValue(e,t){const i=this._fields.get(e);try{i&&(i.listen=!1),t.value=this._dataUnit.getFieldValue(e),this.updateErrorMessage(e,t)}finally{i&&(i.listen=!0)}}updateErrorMessage(e,t){const i=this._invalidFields.get(e);i&&(t.errorMessage=i.message)}getErrorMessage(e){if(this._fields.has(e))return this._fields.get(e).field.errorMessage||null}updateBind(e,t){const i=this._fields.get(e);i&&i.destroy(),t.value=this._dataUnit.getFieldValue(e),this.updateErrorMessage(e,t),this._fields.set(e,D.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 o("Change canceled",e))}}setFieldValue(e,t){if(0===this._dataUnit.records.length&&this._dataUnit.addRecord(),this._invalidFields.delete(e),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 D{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(e){this.waitingChangePromiseReject&&(this.waitingChangePromiseReject(e),this.waitingChangePromiseReject=void 0,this.waitingChangePromiseResolve=void 0)}static create(e,t,i,n,s){const r=new D;return r.field=t,r.fieldName=e,r.startChangeListener=t=>{r.listen&&i(e,t.detail)},r.field.addEventListener(r.startChangeEventName,r.startChangeListener),r.cancelWaitingChangeListener=()=>{r.listen&&n(e)},r.field.addEventListener(r.cancelWaitingChangeEventName,r.cancelWaitingChangeListener),r.changeListener=t=>{r.listen&&s(e,t.detail)},r.field.addEventListener(r.changeEventName,r.changeListener),r}}let I=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)=>{var i;const n=this.dataUnit.getModifiedRecords();for(let e=0;e<n.length;e++){const s=n[e],r=[];let l=this.validateRequired(s);if(l&&!l.isValid&&r.push(l),l=null===(i=this.recordsValidator)||void 0===i?void 0:i.validateRecord(this,s),l&&!l.isValid&&r.push(l),r.length>0){this.processValidationResult(r),t();break}}e()}))}observeConfig(){this.processMetadata()}validateRequired(e){const t=N(this._store.getState()),i=this._staticFields.filter((e=>e.dataset.required)).map((e=>e.dataset.fieldName)).concat(t.getRequiredFields()),n=[];if(new Set(i).forEach((t=>{const i=e[t];if(null==i||""===i){const e=this._dataBinder.getErrorMessage(t);n.push(e?{name:t,message:e}:{name:t,message:"Essa informação é obrigatória"})}})),n.length>0)return{isValid:!1,invalidFields:n,infoMessage:"Há pelo menos um campo obrigatório não preenchido."}}processValidationResult(e){e.forEach((e=>{const t=e.invalidFields;if(t&&t.forEach((e=>{this._dataBinder.markInvalid(e)})),e.infoMessage&&f.info(e.infoMessage),e.errorMessage){const{errorTitle:t,errorMessage:i}=e;f.error(t,i)}}))}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()),l=[];if(r.length>1){const t=r.map(((e,t)=>({tabKey:e.name,label:e.label,index:t})));l.push(e("ez-tabselector",{tabs:t,onEzChange:e=>this._store.dispatch(function(e){return{type:S.CHANGE_TAB,payload:e.tabKey}}(e.detail)),selectedTab:n.name}))}return l.push(e(g,{store:this._store,source:n})),l}processMetadata(){if(!this.isStatic()&&this.dataUnit){const e=null!=this.config&&Object.values(this.config).length>0?((e,t)=>{var i,n;const s=new Map,r=new Map,l=[],a=[],o={};null===(i=null==e?void 0:e.tabs)||void 0===i||i.forEach((e=>{r.has(e.label)||!1!==e.visible||r.set(e.label,e)})),null===(n=null==e?void 0:e.fields)||void 0===n||n.forEach((e=>{var i,n,c;if(!1!==e.visible){const d=function(e,t){return("string"==typeof e?Array.from(t.keys()).find((t=>t.label===e)):e)||{label:e,visible:!0}}(e.tab||"__main",s);if(r.has(d.label))return;const h=t.getField(e.name);if(h&&d.visible){s.has(d)||s.set(d,new Map);const t=s.get(d);(null==e.required?h.required:e.required)&&l.push(e.name),((null==e.cleanOnCopy?null===(i=h.properties)||void 0===i?void 0:i.cleanOnCopy:e.cleanOnCopy)||(null===(n=h.properties)||void 0===n?void 0:n.autoNum))&&a.push(e.name),(null==e.defaultValue?null===(c=h.properties)||void 0===c?void 0:c.defaultValue:e.defaultValue)&&(o[e.name]=e.defaultValue),O(t,e,h)}}}));const c=new _;return Array.from(s.entries()).sort(w).forEach((([e,t])=>{c.addSheet({label:"__main"===e.label?"Principal":e.label,name:e.label,items:Array.from(t.values()),requiredFields:l,cleanOnCopyFields:a,defaultValues:o})})),c})(this.config,this.dataUnit):(()=>{var e,t;const i=this.dataUnit.metadata,n=new _;if(i){const s=null===(e=i.fields)||void 0===e?void 0:e.filter((e=>!1!==e.visible)),r=new Map;null===(t=null==i?void 0:i.fields)||void 0===t||t.forEach((e=>{!1!==e.visible&&O(r,null,e)}));let l={};s.filter((e=>e.defaultValue)).map((e=>l[e.name]=e.defaultValue)),n.addSheet({label:i.label,name:i.name,items:Array.from(r.values()),requiredFields:s.filter((e=>e.required)).map((e=>e.name)),cleanOnCopyFields:s.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:l})}return n})();this._store.dispatch({type:S.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.SAVING_DATA)return new Promise((t=>{this.validate().then((()=>t(e))).catch((()=>{}))}));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){const n="formattedValue"in t[e]?t[e].formattedValue:t[e].value,s=null!=n?n:t[e],r="function"==typeof s?s():s;i[e]=this.dataUnit.valueFromString(e,r)}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 P(this.dataUnit),this._store=M(k),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"]}}};I.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{I as ez_form}
@@ -1 +0,0 @@
1
- import{r as t,c as i,h as s,H as e,g as a}from"./p-3c7ea91b.js";let o=class{constructor(s){t(this,s),this.ezChange=i(this,"ezChange",7),this.setFocusedParam=t=>{if("Enter"===t.key){const i=this._processedTabs[this._focusedIndex];this.handleTabClick(i),t.preventDefault(),this.setFocusedTab(i.index)}else if("ArrowLeft"===t.key||"ArrowRight"===t.key){let i;if("ArrowLeft"===t.key)i=!1;else{if("ArrowRight"!==t.key)return;i=!0}this._focusedIndex=void 0===this._focusedIndex?!1===i?void 0!==this.selectedIndex?this.selectedIndex-1:void 0:void 0!==this.selectedIndex?this.selectedIndex+1:void 0:!1===i?this._focusedIndex-1:this._focusedIndex+1,this._focusedIndex<0?this._focusedIndex=0:this._focusedIndex>this._processedTabs.length-1&&(this._focusedIndex=this._processedTabs.length-1),this.setFocusedBtn(!0,this._focusedIndex),this.setFocusedTab(this._focusedIndex)}else if("Tab"===t.key||"Escape"===t.key){const i=this._processedTabs[this.selectedIndex];this._focusedIndex=void 0,this.handleTabClick(i),t.preventDefault(),this.setFocusedTab(this.selectedIndex)}}}observeTabs(t){t&&"string"!=typeof t&&(this._processedTabs=t)}handleTabClick(t){this.selectedIndex=t.index,this._focusedIndex=void 0,this.selectedTab=t.tabKey,this.ezChange.emit(t),this.setFocusedBtn(!1,t.index)}componentWillRender(){this._processedTabs||(this._processedTabs=[],this.tabs&&"string"==typeof this.tabs&&this.tabs.split(",").forEach((t=>{t=t.trim(),this._processedTabs.push({label:t,tabKey:t,index:this._processedTabs.length})})),this._hostElem.querySelectorAll("ez-tab").forEach((t=>{const i=t.getAttribute("tabKey"),s={label:t.getAttribute("label"),tabKey:i,leftIcon:t.getAttribute("leftIcon"),rightIcon:t.getAttribute("rightIcon"),index:this._processedTabs.length},e=t.firstChild;e&&(e.setAttribute("slot","tab"+s.index),this._hostElem.appendChild(e)),this._processedTabs.push(s)})))}handleSlotChange(t){const i=t.target.assignedElements()[0];i&&(i.style.marginLeft="6px")}scrollBackward(){const t=this._scrollContainer;t&&(t.scrollLeft-=t.clientWidth)}scrollFoward(){const t=this._scrollContainer;if(t){let i=null;t.querySelectorAll(".tab").forEach((s=>{s.getBoundingClientRect().right<t.clientWidth&&(i=s)})),t.scrollLeft=i.offsetLeft+i.offsetWidth}}componentDidRender(){this.updateScroll()}updateScroll(){const t=this._scrollContainer;if(t){const{scrollWidth:i,clientWidth:s,scrollLeft:e}=t,a=i-s-Math.ceil(e);this._startHidden=t.scrollLeft>0,this._endHidden=a>0,this._startHidden?this._backwardButton.classList.remove("hidden"):this._backwardButton.classList.add("hidden"),this._endHidden?this._forwardButton.classList.remove("hidden"):this._forwardButton.classList.add("hidden");const o=["","startHidden","endHidden","middle"],r=o[Number(this._startHidden)|Number(this._endHidden)<<1];o.forEach((i=>{i!==r&&t.classList.contains(i)&&t.classList.remove(i)})),r&&!t.classList.contains(r)&&t.classList.add(r)}}domScrollHandler(){window.clearTimeout(this._scrollCallBack),this._scrollCallBack=window.setTimeout((()=>{this.updateScroll()}),200)}setFocusedTab(t){window.clearTimeout(this._scrollCallBackTest),this._scrollCallBackTest=window.setTimeout((()=>{this._scrollContainer.querySelector(`#tab${t}`).scrollIntoView()}),200)}getTextWidth(t){void 0===this._textMesurement&&(this._textMesurement=this._hostElem.shadowRoot.ownerDocument.createElement("canvas"));const i=this._textMesurement.getContext("2d");return i.font="14px Sora, Algerian",Math.min(220,24+i.measureText(t).width)+"px"}setFocusedBtn(t,i){this._scrollContainer.querySelectorAll(".tab").forEach((s=>{s.classList.remove("is-focused"),s.id==="tab"+i&&t&&s.classList.add("is-focused")}))}render(){return s(e,null,s("button",{class:"backward-button",ref:t=>this._backwardButton=t,onClick:()=>this.scrollBackward()}),s("div",{class:"scroll",ref:t=>this._scrollContainer=t,onScroll:()=>this.domScrollHandler(),onKeyDown:t=>this.setFocusedParam(t)},this._processedTabs.map(((t,i)=>{const e={"min-width":this.getTextWidth(t.label)},a="tab"+i,o=i===this.selectedIndex||this.selectedTab&&t.tabKey===this.selectedTab;return o&&(this.selectedTab=t.tabKey,this.selectedIndex=i),s("button",{id:a,class:"tab"+(o?" is-active":""),onClick:()=>this.handleTabClick(t),style:e},t.leftIcon&&s("ez-icon",{iconName:t.leftIcon,class:"left-icon"}),s("span",{class:"tab-label",title:t.label},t.label),t.rightIcon&&s("ez-icon",{iconName:t.rightIcon,class:"right-icon"}),s("slot",{name:a,onSlotchange:t=>{this.handleSlotChange(t)}}))}))),s("button",{class:"forward-button",ref:t=>this._forwardButton=t,onClick:()=>this.scrollFoward()}))}get _hostElem(){return a(this)}static get watchers(){return{tabs:["observeTabs"]}}};o.style='@keyframes activate{0%{clip-path:inset(calc(100% - 3px) 50% 0px 50%)}100%{clip-path:inset(calc(100% - 3px) 0px 0px 0px)}}:host{display:flex;position:relative;width:100%;overflow:hidden;--tabselector--backward-icon:url(\'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="16px" width="10px"><path d="M 9.7808475,13.860393 3.9204526,8.0000004 9.7808475,2.0624965 7.9301965,0.28895552 0.21915255,8.0000004 7.9301965,15.711044 Z"/></svg>\');--tabselector--forward-icon:url(\'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="16px" width="10px"><path d="M 0.21915251,13.860393 6.0795475,8.0000007 0.21915251,2.0624968 2.0698036,0.28895588 9.7808475,8.0000007 2.0698036,15.711044 Z"/></svg>\')}.scroll{display:flex;width:100%;scroll-behavior:smooth;overflow-x:auto;scrollbar-width:none}.scroll.startHidden{-webkit-mask-image:linear-gradient(90deg, transparent 20px, #000 48px)}.scroll.middle{-webkit-mask-image:linear-gradient(90deg, transparent 20px, #000 48px, #000 calc(100% - 48px), transparent calc(100% - 20px))}.scroll.endHidden{-webkit-mask-image:linear-gradient(90deg, #000 calc(100% - 48px), transparent calc(100% - 20px))}.tab{display:flex;border:none;min-width:100px;background-color:unset;cursor:pointer;padding:6px 12px;align-items:center;justify-content:center;color:var(--text--primary, #626e82);font-family:var(--font-pattern, "Roboto");font-size:var(--title--small, 14px)}.tab:focus,.forward-button,.backward-button{outline:none}.is-active{position:relative;color:var(--color--primary, #008561)}.is-active::after{content:"";position:absolute;width:100%;height:100%;background-color:var(--color--primary, #008561);clip-path:inset(calc(100% - 3px) 0px 0px 0px);animation:activate 0.25s ease-in-out}.is-focused{border:1px dashed var(--color--primary, #000000c5)}.tab-label{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;text-shadow:var(--text-shadow);margin-bottom:var(--space--extra-small, 3px)}.forward-button,.backward-button{position:absolute;z-index:1;display:flex;box-sizing:border-box;padding:0px;top:0px;right:0px;width:16px;height:100%;border:none;background-color:unset;cursor:pointer;justify-content:center;align-items:center}.backward-button{left:0px}.forward-button::after,.backward-button::after{content:\'\';display:flex;background-color:var(--text--primary, #008561);width:10px;height:16px}.forward-button::after{-webkit-mask-image:var(--tabselector--forward-icon);mask-image:var(--tabselector--forward-icon)}.backward-button::after{-webkit-mask-image:var(--tabselector--backward-icon);mask-image:var(--tabselector--backward-icon)}.forward-button:hover::after,.backward-button:hover::after{background-color:var(--color--primary, #4e4e4e)}.hidden{display:none}.scroll::-webkit-scrollbar{display:none}.left-icon{padding-right:var(--space--small)}.right-icon{padding-left:var(--space--small)}';export{o as ez_tabselector}