@sankhyalabs/ezui 1.2.0-beta.4 → 1.2.0-beta.7

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 (150) hide show
  1. package/dist/cjs/{ApplicationUtils-483c0a9e.js → ApplicationUtils-2ac1b73e.js} +2 -1
  2. package/dist/cjs/ApplicationUtils-475b50d9.js +63 -0
  3. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  4. package/dist/cjs/css-shim-3bfdba4f.js +6 -0
  5. package/dist/cjs/dom-8ac1ad03.js +75 -0
  6. package/dist/cjs/ez-actions-button.cjs.entry.js +7 -6
  7. package/dist/cjs/ez-application.cjs.entry.js +1 -1
  8. package/dist/cjs/ez-button.cjs.entry.js +1 -1
  9. package/dist/cjs/ez-calendar.cjs.entry.js +4 -4
  10. package/dist/cjs/ez-card-item.cjs.entry.js +1 -1
  11. package/dist/cjs/ez-check.cjs.entry.js +1 -1
  12. package/dist/cjs/ez-chip.cjs.entry.js +1 -1
  13. package/dist/cjs/ez-collapsible-box.cjs.entry.js +1 -1
  14. package/dist/cjs/ez-combo-box.cjs.entry.js +7 -6
  15. package/dist/cjs/ez-date-input.cjs.entry.js +6 -6
  16. package/dist/cjs/ez-date-time-input.cjs.entry.js +4 -4
  17. package/dist/cjs/ez-dialog.cjs.entry.js +1 -1
  18. package/dist/cjs/ez-filter-input.cjs.entry.js +1 -1
  19. package/dist/cjs/ez-form.cjs.entry.js +460 -49
  20. package/dist/cjs/ez-grid-config.cjs.entry.js +5 -5
  21. package/dist/cjs/ez-grid.cjs.entry.js +1167 -985
  22. package/dist/cjs/ez-icon.cjs.entry.js +3 -3
  23. package/dist/cjs/ez-list.cjs.entry.js +3 -1
  24. package/dist/cjs/ez-loading-bar.cjs.entry.js +1 -1
  25. package/dist/cjs/ez-modal.cjs.entry.js +1 -1
  26. package/dist/cjs/ez-number-input.cjs.entry.js +4 -4
  27. package/dist/cjs/ez-popover.cjs.entry.js +5 -5
  28. package/dist/cjs/ez-popup.cjs.entry.js +1 -1
  29. package/dist/cjs/ez-radio-button.cjs.entry.js +1 -1
  30. package/dist/cjs/ez-scroller.cjs.entry.js +1 -1
  31. package/dist/cjs/ez-search.cjs.entry.js +1 -1
  32. package/dist/cjs/ez-select-box.cjs.entry.js +1 -1
  33. package/dist/cjs/ez-tabselector.cjs.entry.js +2 -1
  34. package/dist/cjs/ez-text-area.cjs.entry.js +1 -1
  35. package/dist/cjs/ez-text-input.cjs.entry.js +3 -3
  36. package/dist/cjs/ez-time-input.cjs.entry.js +7 -7
  37. package/dist/cjs/ez-toast.cjs.entry.js +1 -1
  38. package/dist/cjs/ez-upload.cjs.entry.js +2 -2
  39. package/dist/cjs/ez-view-stack.cjs.entry.js +2 -1
  40. package/dist/cjs/ezui.cjs.js +112 -4
  41. package/dist/cjs/index-0ad7c3e4.js +6 -0
  42. package/dist/cjs/index-2ec1da82.js +2307 -0
  43. package/dist/cjs/index-d9c5cb88.js +3068 -0
  44. package/dist/cjs/loader.cjs.js +18 -2
  45. package/dist/cjs/shadow-css-41d9783d.js +390 -0
  46. package/dist/collection/collection-manifest.json +2 -2
  47. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +19 -1
  48. package/dist/collection/utils/ApplicationUtils.js +2 -1
  49. package/dist/custom-elements/index.js +3863 -968
  50. package/dist/esm/ApplicationUtils-30a69eb0.js +61 -0
  51. package/dist/esm/{ApplicationUtils-5f87ae60.js → ApplicationUtils-a4a76132.js} +2 -1
  52. package/dist/esm/app-globals-0f993ce5.js +3 -0
  53. package/dist/esm/css-shim-20dbffa5.js +4 -0
  54. package/dist/esm/dom-c5ed0ba5.js +73 -0
  55. package/dist/esm/ez-actions-button.entry.js +4 -3
  56. package/dist/esm/ez-application.entry.js +1 -1
  57. package/dist/esm/ez-button.entry.js +1 -1
  58. package/dist/esm/ez-calendar.entry.js +2 -2
  59. package/dist/esm/ez-card-item.entry.js +1 -1
  60. package/dist/esm/ez-check.entry.js +1 -1
  61. package/dist/esm/ez-chip.entry.js +1 -1
  62. package/dist/esm/ez-collapsible-box.entry.js +1 -1
  63. package/dist/esm/ez-combo-box.entry.js +4 -3
  64. package/dist/esm/ez-date-input.entry.js +2 -2
  65. package/dist/esm/ez-date-time-input.entry.js +2 -2
  66. package/dist/esm/ez-dialog.entry.js +1 -1
  67. package/dist/esm/ez-filter-input.entry.js +1 -1
  68. package/dist/esm/ez-form.entry.js +426 -15
  69. package/dist/esm/ez-grid-config.entry.js +3 -3
  70. package/dist/esm/ez-grid.entry.js +1138 -956
  71. package/dist/esm/ez-icon.entry.js +2 -2
  72. package/dist/esm/ez-list.entry.js +3 -1
  73. package/dist/esm/ez-loading-bar.entry.js +1 -1
  74. package/dist/esm/ez-modal.entry.js +1 -1
  75. package/dist/esm/ez-number-input.entry.js +2 -2
  76. package/dist/esm/ez-popover.entry.js +2 -2
  77. package/dist/esm/ez-popup.entry.js +1 -1
  78. package/dist/esm/ez-radio-button.entry.js +1 -1
  79. package/dist/esm/ez-scroller.entry.js +1 -1
  80. package/dist/esm/ez-search.entry.js +1 -1
  81. package/dist/esm/ez-select-box.entry.js +1 -1
  82. package/dist/esm/ez-tabselector.entry.js +2 -1
  83. package/dist/esm/ez-text-area.entry.js +1 -1
  84. package/dist/esm/ez-text-input.entry.js +2 -2
  85. package/dist/esm/ez-time-input.entry.js +2 -2
  86. package/dist/esm/ez-toast.entry.js +1 -1
  87. package/dist/esm/ez-upload.entry.js +2 -2
  88. package/dist/esm/ez-view-stack.entry.js +2 -1
  89. package/dist/esm/ezui.js +112 -4
  90. package/dist/esm/index-12b43518.js +3 -0
  91. package/dist/esm/index-1e9d524f.js +3031 -0
  92. package/dist/esm/index-b96183c8.js +2295 -0
  93. package/dist/esm/loader.js +18 -2
  94. package/dist/esm/shadow-css-8c625855.js +388 -0
  95. package/dist/ezui/ApplicationUtils-30a69eb0.js +61 -0
  96. package/dist/ezui/CSSVarsUtils-499b75c2.js +53 -0
  97. package/dist/ezui/DialogType-72afa679.js +8 -0
  98. package/dist/ezui/app-globals-0f993ce5.js +3 -0
  99. package/dist/ezui/css-shim-20dbffa5.js +4 -0
  100. package/dist/ezui/dom-c5ed0ba5.js +73 -0
  101. package/dist/ezui/ez-actions-button.entry.js +98 -0
  102. package/dist/ezui/ez-application.entry.js +22 -0
  103. package/dist/ezui/ez-button.entry.js +73 -0
  104. package/dist/ezui/ez-calendar.entry.js +219 -0
  105. package/dist/ezui/ez-card-item.entry.js +40 -0
  106. package/dist/ezui/ez-check.entry.js +72 -0
  107. package/dist/ezui/ez-chip.entry.js +97 -0
  108. package/dist/ezui/ez-collapsible-box.entry.js +57 -0
  109. package/dist/ezui/ez-combo-box.entry.js +439 -0
  110. package/dist/ezui/ez-date-input.entry.js +159 -0
  111. package/dist/ezui/ez-date-time-input.entry.js +214 -0
  112. package/dist/ezui/ez-dialog.entry.js +108 -0
  113. package/dist/ezui/ez-filter-input.entry.js +75 -0
  114. package/dist/ezui/ez-form.entry.js +1395 -0
  115. package/dist/ezui/ez-grid-config.entry.js +433 -0
  116. package/dist/ezui/ez-grid.entry.js +115419 -0
  117. package/dist/ezui/ez-icon.entry.js +37 -0
  118. package/dist/ezui/ez-list.entry.js +516 -0
  119. package/dist/ezui/ez-loading-bar.entry.js +24 -0
  120. package/dist/ezui/ez-modal.entry.js +67 -0
  121. package/dist/ezui/ez-number-input.entry.js +148 -0
  122. package/dist/ezui/ez-popover.entry.js +141 -0
  123. package/dist/ezui/ez-popup.entry.js +49 -0
  124. package/dist/ezui/ez-radio-button.entry.js +45 -0
  125. package/dist/ezui/ez-scroller.entry.js +101 -0
  126. package/dist/ezui/ez-search.entry.js +83 -0
  127. package/dist/ezui/ez-select-box.entry.js +18 -0
  128. package/dist/ezui/ez-tabselector.entry.js +195 -0
  129. package/dist/ezui/ez-text-area.entry.js +158 -0
  130. package/dist/ezui/ez-text-input.entry.js +235 -0
  131. package/dist/ezui/ez-time-input.entry.js +164 -0
  132. package/dist/ezui/ez-toast.entry.js +84 -0
  133. package/dist/ezui/ez-upload.entry.js +379 -0
  134. package/dist/ezui/ez-view-stack.entry.js +74 -0
  135. package/dist/ezui/ezui.esm.js +125 -1
  136. package/dist/ezui/index-12b43518.js +3 -0
  137. package/dist/ezui/index-1e9d524f.js +3031 -0
  138. package/dist/ezui/index-b96183c8.js +2295 -0
  139. package/dist/ezui/index.esm.js +1 -0
  140. package/dist/ezui/{p-72ab066f.entry.js → p-4eb273f8.entry.js} +1 -1
  141. package/dist/ezui/{p-d9c72ff7.entry.js → p-88bfdea4.entry.js} +1 -1
  142. package/dist/ezui/p-adbe4188.js +1 -0
  143. package/dist/ezui/{p-6cfe20a0.entry.js → p-af43be42.entry.js} +1 -1
  144. package/dist/ezui/{p-47e06040.entry.js → p-c9d2060e.entry.js} +1 -1
  145. package/dist/ezui/{p-3ae441ec.entry.js → p-d836f546.entry.js} +1 -1
  146. package/dist/ezui/{p-7fe1ac9a.entry.js → p-e55fc20f.entry.js} +1 -1
  147. package/dist/ezui/shadow-css-8c625855.js +388 -0
  148. package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +1 -0
  149. package/package.json +2 -2
  150. package/dist/ezui/p-898b9906.js +0 -1
@@ -0,0 +1 @@
1
+ import{D as e}from"./p-787fbdfe.js";class n{static async showDialog(t,o,c=null,s,a=e.DEFAULT,l){return l&&(l=Object.assign(Object.assign({},n.defaultMessageOptions),l)),new Promise((e=>{let n=document.querySelector("ez-dialog");n||(n=document.createElement("ez-dialog"),window.document.body.appendChild(n)),n.show(t,o,a,s,c,l.labelCancel,l.labelConfirm,l.btnConfirmDanger).then((n=>e(n)))}))}static async alert(t,o,c=null,s=n.defaultMessageOptions){return n.showDialog(t,o,c,!1,e.WARN,s)}static async error(t,o,c=null,s=n.defaultMessageOptions){return n.showDialog(t,o,c,!1,e.CRITICAL,s)}static async confirm(t,o,c=null,s=e.WARN,a=n.defaultMessageOptions){return n.showDialog(t,o,c,!0,s,a)}static async message(t,o,c=null,s=n.defaultMessageOptions){return n.showDialog(t,o,c,!1,e.DEFAULT,s)}static async info(e,t=n.defaultMessageOptions){let o=document.querySelector("ez-toast");if(!o){o=document.createElement("ez-toast");const e=document.createElement("ez-icon");e.className="ez-margin-right--small",e.slot="icon",e.style.setProperty("--ez-icon--color","var(--color--success)"),o.appendChild(e),window.document.body.appendChild(o)}if(t.iconName){const e=o.querySelector("ez-icon");e&&(e.iconName=t.iconName,o.useIcon=!0)}else o.useIcon=!1;o.show(e,5e3,!1,t.canClose)}}n.defaultMessageOptions={canClose:!0,labelCancel:"Não",labelConfirm:"Sim",btnConfirmDanger:!1};export{n as A}
@@ -1 +1 @@
1
- import{r as i,c as e,h as t,H as s}from"./p-3c7ea91b.js";import{StringUtils as a}from"@sankhyalabs/core";import{A as r}from"./p-898b9906.js";import{D as o}from"./p-787fbdfe.js";let n=class{constructor(t){i(this,t),this.configFinish=e(this,"configFinish",7),this.configCancel=e(this,"configCancel",7),this._orderListItems=[],this._orderPriorityList=[],this._columListItems=[],this._selectedIndex=-1,this._dataChanged=!1,this._componenteInternalKey=Date.now(),this.selectedTab="Colunas"}createOrderList(){let i=[];this.columns.filter((i=>{var e;return a.getBooleanValue(null===(e=null==i?void 0:i.props)||void 0===e?void 0:e.get("sortable"),!0)})).forEach((e=>{var t;let s=null===(t=this.config)||void 0===t?void 0:t.columns.find((i=>i.name===e.name)),a={name:e.name,label:e.label};s&&(a.orderIndex=s.orderIndex,a.ascending=s.ascending),e.hidden||i.push(a)})),i.sort(((i,e)=>0!=i.orderIndex||0!=e.orderIndex||null==i.ascending&&null==e.ascending?null!=i.ascending&&null!=e.ascending?i.orderIndex-e.orderIndex:null!=i.ascending||null!=e.ascending?null!=i.ascending?-1:null!=e.ascending?1:0:i.orderIndex-e.orderIndex:null!=i.ascending?-1:null!=e.ascending?1:0)),this._orderListItems=i}createColumnList(){let i={group:"Visíveis",items:[]},e={group:"Ocultas",items:[],sort:"ASC"};this.columns.forEach((t=>{let s={label:t.label};t.hidden?e.items.push(s):i.items.push(s)})),this._columListItems=[i,e]}buildColumnListSlot(i,e){return t("div",null,t("ez-check",{mode:"switch",id:"switch"+i+e,value:"Visíveis"===e.group,onEzChange:e=>{this.switchColumnGroup(e,i)}}))}buildOrderListSlot(i){let e="na";return null!=(null==i?void 0:i.ascending)&&(e=1==i.ascending?"asc":"desc"),t("div",null,t("ez-select-box",{selectedOption:e,key:"ez-select-box-"+this._componenteInternalKey+"-"+i,onEzChange:e=>{e.stopPropagation(),this.updateOrder(e.detail,i.label)}}))}updateOrder(i,e){var t;this._dataChanged=!0;let s,a=[...this.columns],r=a.find((i=>i.label===e));r&&(r.sort="na"===i.value?void 0:i.value),(null===(t=this._orderPriorityList)||void 0===t?void 0:t.length)>0?(this._orderPriorityList.find((i=>i.label===r.label)).sort=i,this._orderPriorityList.filter((i=>i.sort)).map(((i,e)=>{i.label===r.label&&(r.sortIndex=e)}))):(s=a.filter((i=>i.sort&&!0!==i.hidden)).map(((i,e)=>({label:i.label,orderIndex:e}))),s.forEach((i=>{a.find((e=>e.label===i.label)).sortIndex=i.orderIndex}))),this.columns=a}switchColumnGroup(i,e){i.stopPropagation();let t=[...this._columListItems];if(this._dataChanged=!0,!0===i.detail){let i=t.find((i=>"Ocultas"===i.group)),s=i.items.findIndex((i=>i.label===e.label));s>=0&&i.items.splice(s,1),t.find((i=>"Visíveis"===i.group)).items.push(e),this._columListItems=t,this.createOrderList()}else if(!1===i.detail){let i=t.find((i=>"Visíveis"===i.group)),s=i.items.findIndex((i=>i.label===e.label));s>=0&&i.items.splice(s,1),t.find((i=>"Ocultas"===i.group)).items.push(e),this._columListItems=t,this.createOrderList()}}finish(){let i=[];this._columListItems.forEach((e=>{e.items.forEach((t=>{const s=this.columns.find((i=>i.label===t.label));let a=Object.assign({},s);a.hidden="Ocultas"===e.group,i.push(a)}))})),this.columns=i,this._dataChanged=!1,this.closeConfig(),r.info("As configurações foram salvas com sucesso!"),this.save()}save(){var i;let e;e=this.config?this.config:this.createConfigFromState(this.columns);let t,s=[];if((null===(i=this._orderPriorityList)||void 0===i?void 0:i.length)>0){t=this.columns.filter((i=>i.sort&&!0!==i.hidden)).map((i=>({label:i.label,orderIndex:0})));let i=0,e=[];this._orderPriorityList.forEach((s=>{let a=t.find((i=>i.label===s.label));a&&(a.orderIndex=i,e.push(a),i++)})),e.length>0&&(t=e)}for(let i=0;i<this.columns.length;i++){const r=this.columns[i];let o=e.columns.find((i=>r.name===i.name));!0===r.hidden&&o||(o?o.width=r.width:!1===r.hidden&&(o={name:r.name,width:r.width,orderIndex:0}),o&&(r.sort?(o.ascending="ASC"===r.sort.toUpperCase(),t?a(r,o):o.orderIndex=r.sortIndex):(delete o.ascending,o.orderIndex=0),s.push(o)))}function a(i,e){if(t){let s=t.find((e=>e.label===i.label));s&&(e.orderIndex=s.orderIndex)}}e.columns=s,this.configFinish.emit(e),this._orderList.clearHistory()}createConfigFromState(i){let e={columns:[]};return i.forEach((i=>{if(!i.hidden){let t={name:i.name};i.width&&(t.width=i.width),i.sort?(t.ascending="ASC"===i.sort.toUpperCase(),t.orderIndex=i.sortIndex):t.orderIndex=0,t&&e.columns.push(t)}})),e}async locateColumn(i,e){var t;const s="Enter"===i.key;e||(e=null===(t=i.currentTarget)||void 0===t?void 0:t.value);let a=-1;if("Ordenação das linhas"===this.selectedTab)if(e){const i=[];let t,r;if(await this._orderList.getList().then((s=>{t=s,t.forEach(((t,s)=>{this.compareWords(t,e)&&i.push(s)}))})),i.length>0){if(s)for(let e=0;e<i.length;e++)if(i[e]>this._selectedIndex){a=i[e];break}-1===a&&(a=i[0])}this._selectedIndex=a,r=t[a],r?this._orderList.setSelection({label:r.label},!0):this._orderList.setSelection(void 0)}else this._orderList.setSelection(void 0);else if(e){const i=[];if(this.columns.forEach(((t,s)=>{this.compareWords(t,e)&&i.push(s)})),i.length>0){if(s)for(let e=0;e<i.length;e++)if(i[e]>this._selectedIndex){a=i[e];break}-1===a&&(a=i[0])}this._selectedIndex=a;let t=this.columns[a];t?this._columnList.setSelection({label:t.label},!0):this._columnList.setSelection(void 0)}else this._columnList.setSelection(void 0)}compareWords(i,e){return a.replaceAccentuatedChars(i.label).indexOf(a.replaceAccentuatedChars(e))>-1}closeConfig(){this._orderList.scrollToTop(),this._columnList.scrollToTop(),this._searchElement.value="",this._dataChanged?r.confirm("Aviso","As alterações realizadas serão descartadas. Gostaria de salvar antes de sair?",null,o.WARN,{canClose:!1,labelCancel:"Descartar",labelConfirm:"Salvar",btnConfirmDanger:!1}).then((i=>{i?this.finish():(this._dataChanged=!1,this.configCancel.emit(),this._orderList.clearHistory(),this._componenteInternalKey=Date.now())})):(this.configCancel.emit(),this._orderList.clearHistory())}handleTabChange(i){var e;(null===(e=null==i?void 0:i.target)||void 0===e?void 0:e.selectedTab)&&(this.selectedTab!==i.target.selectedTab&&("Colunas"===i.target.selectedTab?this._orderList.scrollToTop():"Ordenação das linhas"===i.target.selectedTab&&this._columnList.scrollToTop(),this._searchElement.value=""),"Ordenação das linhas"===i.target.selectedTab&&this.createOrderList(),this.selectedTab=i.target.selectedTab)}handleColumnListChange(i){var e;if(i.detail){let t=null===(e=i.detail.find((i=>"Visíveis"===i.group)))||void 0===e?void 0:e.items;t&&(this._dataChanged=!0,this._orderListItems=t)}}handleOrderListChange(i){if(i.detail){let e=i.detail;e&&(this._dataChanged=!0,this._orderPriorityList=e)}}componentWillRender(){var i;(null===(i=this.columns)||void 0===i?void 0:i.length)>0&&this.createColumnList()}componentDidRender(){var i;(null===(i=this.columns)||void 0===i?void 0:i.length)>0&&this.locateColumn(new KeyboardEvent("arrow-right",{key:"ArrowRight"}),this._searchElement.value)}render(){return t(s,null,t("div",{class:"grid-config__header"},t("div",{class:"title-container"},t("div",{class:""},t("label",{class:"title"},"Configuração da Grade"),t("label",{class:"subtitle"},"Defina visibilidade e ordem das colunas.")),t("div",{class:"button-close"},t("ez-button",{mode:"icon",iconName:"close",size:"medium",onClick:()=>this.closeConfig()}))),t("div",{class:"tabselector-container"},t("ez-tabselector",{selectedTab:this.selectedTab,selectedIndex:0,onEzChange:i=>{this.handleTabChange(i)},tabs:"Colunas, Ordenação das linhas"})),t("div",null,t("ez-text-input",{ref:i=>this._searchElement=i,label:"Localizar coluna",onKeyUp:i=>this.locateColumn(i)},t("ez-icon",{slot:"leftIcon",size:"medium",iconName:"search"})))),t("div",{class:"grid-config__main"},t("ez-list",{ref:i=>this._columnList=i,class:"Colunas"===this.selectedTab?"":"hidden",dataSource:this._columListItems,onEzChange:i=>this.handleColumnListChange(i),ezDraggable:!0,ezSelectable:!0,itemSlotBuilder:(i,e)=>this.buildColumnListSlot(i,e),useGroups:!0}),t("div",{class:"Ordenação das linhas"===this.selectedTab?"group-name":"hidden"},"Sequência da ordenação"),t("ez-list",{ref:i=>this._orderList=i,class:"Ordenação das linhas"===this.selectedTab?"height-calc":"hidden",dataSource:this._orderListItems,ezSelectable:!0,onEzChange:i=>this.handleOrderListChange(i),ezDraggable:!0,itemSlotBuilder:i=>this.buildOrderListSlot(i)})),t("div",{class:"grid-config__footer"},t("ez-button",{class:"padding-right--medium",label:"Cancelar",onClick:()=>this.closeConfig()}),t("ez-button",{label:"Concluir",class:"ez-button--primary",onClick:()=>this.finish()})))}static get assetsDirs(){return["../assets"]}};n.style='.sc-ez-grid-config-h{--ez-grid-config__footer--padding-top:var(--space--medium, 12px);--ez-grid-config__main--padding-right:var(--space--medium, 12px);--ez-grid-config__tabselector-container--padding:var(--space--medium, 12px);--ez-grid-config__button-close--padding-left:var(--space--medium, 12px);--ez-grid-config__subtitle--font-family:var(--font-pattern, "Sora");--ez-grid-config__title--font-family:var(--font-pattern, "Sora");--ez-grid-config__title--font-weight:var(--text-weight--large, 700);--ez-grid-config__subtitle--font-size:var(--text--medium, 14px);--ez-grid-config__scrollbar--width:var(--space--medium, 12px);--ez-grid-config__scrollbar--background-color:var(--text--primary, #626e82);--ez-grid-config__scrollbar--border-radius:var(--border--radius-medium, 12px);--ez-grid-config__group--font-family:var(--font-pattern, "Sora");--ez-grid-config__group--font-size:var(--text--medium, 14px);--ez-grid-config__group--font-weight:var(--text-weight--large, 600);--ez-grid-config__group--padding-bottom:var(--space-small, 6px);display:grid;grid-template-rows:auto 1fr auto;max-height:100%;width:100%}@media screen and (min-width: 480px){.sc-ez-grid-config-h{width:359px;max-width:359px}}.padding-right--medium.sc-ez-grid-config{padding-right:var(--space--medium)}ez-list.sc-ez-grid-config{height:100%}.height-calc.sc-ez-grid-config{max-height:calc(100% - 24px)}.grid-config__footer.sc-ez-grid-config{display:flex;justify-content:flex-end;width:100%;padding-top:var(--ez-grid-config__footer--padding-top)}.hidden.sc-ez-grid-config{display:none}.grid-config__main.sc-ez-grid-config{overflow-y:auto;padding-right:var(--ez-grid-config__main--padding-right)}.tabselector-container.sc-ez-grid-config{padding:var(--ez-grid-config__tabselector-container--padding) 0}.button-close.sc-ez-grid-config{padding-left:var(--ez-grid-config__button-close--padding-left)}.title-container.sc-ez-grid-config{display:flex;justify-content:space-between;align-items:center;width:100%}.subtitle.sc-ez-grid-config{font-family:var(--ez-grid-config__subtitle--font-family);font-size:var(--ez-grid-config__subtitle--font-size);color:var(--text--primary)}.title.sc-ez-grid-config{display:flex;margin:0;line-height:normal;letter-spacing:0em;text-align:left;color:var(--title--primary);font-family:var(--ez-grid-config__title--font-family);font-size:var(--title--large);font-weight:var(--ez-grid-config__title--font-weight)}.grid-config__main.sc-ez-grid-config::-webkit-scrollbar-track{background-color:#f0f2f5}.grid-config__main.sc-ez-grid-config::-webkit-scrollbar-thumb{background-color:var(--ez-grid-config__scrollbar--background-color);border-radius:var(--ez-grid-config__scrollbar--border-radius)}.grid-config__main.sc-ez-grid-config::-webkit-scrollbar{background-color:#f0f2f5;width:var(--ez-grid-config__scrollbar--width);max-width:var(--ez-grid-config__scrollbar--width);min-width:var(--ez-grid-config__scrollbar--width)}.group-name.sc-ez-grid-config{font-family:var(--ez-grid-config__group--font-family);font-size:var(--ez-grid-config__group--font-size);font-weight:var(--ez-grid-config__group--font-weight);padding-bottom:var(--ez-grid-config__group--padding-bottom)}';export{n as ez_grid_config}
1
+ import{r as i,c as e,h as t,H as s}from"./p-3c7ea91b.js";import{StringUtils as a}from"@sankhyalabs/core";import{A as r}from"./p-adbe4188.js";import{D as o}from"./p-787fbdfe.js";let n=class{constructor(t){i(this,t),this.configFinish=e(this,"configFinish",7),this.configCancel=e(this,"configCancel",7),this._orderListItems=[],this._orderPriorityList=[],this._columListItems=[],this._selectedIndex=-1,this._dataChanged=!1,this._componenteInternalKey=Date.now(),this.selectedTab="Colunas"}createOrderList(){let i=[];this.columns.filter((i=>{var e;return a.getBooleanValue(null===(e=null==i?void 0:i.props)||void 0===e?void 0:e.get("sortable"),!0)})).forEach((e=>{var t;let s=null===(t=this.config)||void 0===t?void 0:t.columns.find((i=>i.name===e.name)),a={name:e.name,label:e.label};s&&(a.orderIndex=s.orderIndex,a.ascending=s.ascending),e.hidden||i.push(a)})),i.sort(((i,e)=>0!=i.orderIndex||0!=e.orderIndex||null==i.ascending&&null==e.ascending?null!=i.ascending&&null!=e.ascending?i.orderIndex-e.orderIndex:null!=i.ascending||null!=e.ascending?null!=i.ascending?-1:null!=e.ascending?1:0:i.orderIndex-e.orderIndex:null!=i.ascending?-1:null!=e.ascending?1:0)),this._orderListItems=i}createColumnList(){let i={group:"Visíveis",items:[]},e={group:"Ocultas",items:[],sort:"ASC"};this.columns.forEach((t=>{let s={label:t.label};t.hidden?e.items.push(s):i.items.push(s)})),this._columListItems=[i,e]}buildColumnListSlot(i,e){return t("div",null,t("ez-check",{mode:"switch",id:"switch"+i+e,value:"Visíveis"===e.group,onEzChange:e=>{this.switchColumnGroup(e,i)}}))}buildOrderListSlot(i){let e="na";return null!=(null==i?void 0:i.ascending)&&(e=1==i.ascending?"asc":"desc"),t("div",null,t("ez-select-box",{selectedOption:e,key:"ez-select-box-"+this._componenteInternalKey+"-"+i,onEzChange:e=>{e.stopPropagation(),this.updateOrder(e.detail,i.label)}}))}updateOrder(i,e){var t;this._dataChanged=!0;let s,a=[...this.columns],r=a.find((i=>i.label===e));r&&(r.sort="na"===i.value?void 0:i.value),(null===(t=this._orderPriorityList)||void 0===t?void 0:t.length)>0?(this._orderPriorityList.find((i=>i.label===r.label)).sort=i,this._orderPriorityList.filter((i=>i.sort)).map(((i,e)=>{i.label===r.label&&(r.sortIndex=e)}))):(s=a.filter((i=>i.sort&&!0!==i.hidden)).map(((i,e)=>({label:i.label,orderIndex:e}))),s.forEach((i=>{a.find((e=>e.label===i.label)).sortIndex=i.orderIndex}))),this.columns=a}switchColumnGroup(i,e){i.stopPropagation();let t=[...this._columListItems];if(this._dataChanged=!0,!0===i.detail){let i=t.find((i=>"Ocultas"===i.group)),s=i.items.findIndex((i=>i.label===e.label));s>=0&&i.items.splice(s,1),t.find((i=>"Visíveis"===i.group)).items.push(e),this._columListItems=t,this.createOrderList()}else if(!1===i.detail){let i=t.find((i=>"Visíveis"===i.group)),s=i.items.findIndex((i=>i.label===e.label));s>=0&&i.items.splice(s,1),t.find((i=>"Ocultas"===i.group)).items.push(e),this._columListItems=t,this.createOrderList()}}finish(){let i=[];this._columListItems.forEach((e=>{e.items.forEach((t=>{const s=this.columns.find((i=>i.label===t.label));let a=Object.assign({},s);a.hidden="Ocultas"===e.group,i.push(a)}))})),this.columns=i,this._dataChanged=!1,this.closeConfig(),r.info("As configurações foram salvas com sucesso!"),this.save()}save(){var i;let e;e=this.config?this.config:this.createConfigFromState(this.columns);let t,s=[];if((null===(i=this._orderPriorityList)||void 0===i?void 0:i.length)>0){t=this.columns.filter((i=>i.sort&&!0!==i.hidden)).map((i=>({label:i.label,orderIndex:0})));let i=0,e=[];this._orderPriorityList.forEach((s=>{let a=t.find((i=>i.label===s.label));a&&(a.orderIndex=i,e.push(a),i++)})),e.length>0&&(t=e)}for(let i=0;i<this.columns.length;i++){const r=this.columns[i];let o=e.columns.find((i=>r.name===i.name));!0===r.hidden&&o||(o?o.width=r.width:!1===r.hidden&&(o={name:r.name,width:r.width,orderIndex:0}),o&&(r.sort?(o.ascending="ASC"===r.sort.toUpperCase(),t?a(r,o):o.orderIndex=r.sortIndex):(delete o.ascending,o.orderIndex=0),s.push(o)))}function a(i,e){if(t){let s=t.find((e=>e.label===i.label));s&&(e.orderIndex=s.orderIndex)}}e.columns=s,this.configFinish.emit(e),this._orderList.clearHistory()}createConfigFromState(i){let e={columns:[]};return i.forEach((i=>{if(!i.hidden){let t={name:i.name};i.width&&(t.width=i.width),i.sort?(t.ascending="ASC"===i.sort.toUpperCase(),t.orderIndex=i.sortIndex):t.orderIndex=0,t&&e.columns.push(t)}})),e}async locateColumn(i,e){var t;const s="Enter"===i.key;e||(e=null===(t=i.currentTarget)||void 0===t?void 0:t.value);let a=-1;if("Ordenação das linhas"===this.selectedTab)if(e){const i=[];let t,r;if(await this._orderList.getList().then((s=>{t=s,t.forEach(((t,s)=>{this.compareWords(t,e)&&i.push(s)}))})),i.length>0){if(s)for(let e=0;e<i.length;e++)if(i[e]>this._selectedIndex){a=i[e];break}-1===a&&(a=i[0])}this._selectedIndex=a,r=t[a],r?this._orderList.setSelection({label:r.label},!0):this._orderList.setSelection(void 0)}else this._orderList.setSelection(void 0);else if(e){const i=[];if(this.columns.forEach(((t,s)=>{this.compareWords(t,e)&&i.push(s)})),i.length>0){if(s)for(let e=0;e<i.length;e++)if(i[e]>this._selectedIndex){a=i[e];break}-1===a&&(a=i[0])}this._selectedIndex=a;let t=this.columns[a];t?this._columnList.setSelection({label:t.label},!0):this._columnList.setSelection(void 0)}else this._columnList.setSelection(void 0)}compareWords(i,e){return a.replaceAccentuatedChars(i.label).indexOf(a.replaceAccentuatedChars(e))>-1}closeConfig(){this._orderList.scrollToTop(),this._columnList.scrollToTop(),this._searchElement.value="",this._dataChanged?r.confirm("Aviso","As alterações realizadas serão descartadas. Gostaria de salvar antes de sair?",null,o.WARN,{canClose:!1,labelCancel:"Descartar",labelConfirm:"Salvar",btnConfirmDanger:!1}).then((i=>{i?this.finish():(this._dataChanged=!1,this.configCancel.emit(),this._orderList.clearHistory(),this._componenteInternalKey=Date.now())})):(this.configCancel.emit(),this._orderList.clearHistory())}handleTabChange(i){var e;(null===(e=null==i?void 0:i.target)||void 0===e?void 0:e.selectedTab)&&(this.selectedTab!==i.target.selectedTab&&("Colunas"===i.target.selectedTab?this._orderList.scrollToTop():"Ordenação das linhas"===i.target.selectedTab&&this._columnList.scrollToTop(),this._searchElement.value=""),"Ordenação das linhas"===i.target.selectedTab&&this.createOrderList(),this.selectedTab=i.target.selectedTab)}handleColumnListChange(i){var e;if(i.detail){let t=null===(e=i.detail.find((i=>"Visíveis"===i.group)))||void 0===e?void 0:e.items;t&&(this._dataChanged=!0,this._orderListItems=t)}}handleOrderListChange(i){if(i.detail){let e=i.detail;e&&(this._dataChanged=!0,this._orderPriorityList=e)}}componentWillRender(){var i;(null===(i=this.columns)||void 0===i?void 0:i.length)>0&&this.createColumnList()}componentDidRender(){var i;(null===(i=this.columns)||void 0===i?void 0:i.length)>0&&this.locateColumn(new KeyboardEvent("arrow-right",{key:"ArrowRight"}),this._searchElement.value)}render(){return t(s,null,t("div",{class:"grid-config__header"},t("div",{class:"title-container"},t("div",{class:""},t("label",{class:"title"},"Configuração da Grade"),t("label",{class:"subtitle"},"Defina visibilidade e ordem das colunas.")),t("div",{class:"button-close"},t("ez-button",{mode:"icon",iconName:"close",size:"medium",onClick:()=>this.closeConfig()}))),t("div",{class:"tabselector-container"},t("ez-tabselector",{selectedTab:this.selectedTab,selectedIndex:0,onEzChange:i=>{this.handleTabChange(i)},tabs:"Colunas, Ordenação das linhas"})),t("div",null,t("ez-text-input",{ref:i=>this._searchElement=i,label:"Localizar coluna",onKeyUp:i=>this.locateColumn(i)},t("ez-icon",{slot:"leftIcon",size:"medium",iconName:"search"})))),t("div",{class:"grid-config__main"},t("ez-list",{ref:i=>this._columnList=i,class:"Colunas"===this.selectedTab?"":"hidden",dataSource:this._columListItems,onEzChange:i=>this.handleColumnListChange(i),ezDraggable:!0,ezSelectable:!0,itemSlotBuilder:(i,e)=>this.buildColumnListSlot(i,e),useGroups:!0}),t("div",{class:"Ordenação das linhas"===this.selectedTab?"group-name":"hidden"},"Sequência da ordenação"),t("ez-list",{ref:i=>this._orderList=i,class:"Ordenação das linhas"===this.selectedTab?"height-calc":"hidden",dataSource:this._orderListItems,ezSelectable:!0,onEzChange:i=>this.handleOrderListChange(i),ezDraggable:!0,itemSlotBuilder:i=>this.buildOrderListSlot(i)})),t("div",{class:"grid-config__footer"},t("ez-button",{class:"padding-right--medium",label:"Cancelar",onClick:()=>this.closeConfig()}),t("ez-button",{label:"Concluir",class:"ez-button--primary",onClick:()=>this.finish()})))}static get assetsDirs(){return["../assets"]}};n.style='.sc-ez-grid-config-h{--ez-grid-config__footer--padding-top:var(--space--medium, 12px);--ez-grid-config__main--padding-right:var(--space--medium, 12px);--ez-grid-config__tabselector-container--padding:var(--space--medium, 12px);--ez-grid-config__button-close--padding-left:var(--space--medium, 12px);--ez-grid-config__subtitle--font-family:var(--font-pattern, "Sora");--ez-grid-config__title--font-family:var(--font-pattern, "Sora");--ez-grid-config__title--font-weight:var(--text-weight--large, 700);--ez-grid-config__subtitle--font-size:var(--text--medium, 14px);--ez-grid-config__scrollbar--width:var(--space--medium, 12px);--ez-grid-config__scrollbar--background-color:var(--text--primary, #626e82);--ez-grid-config__scrollbar--border-radius:var(--border--radius-medium, 12px);--ez-grid-config__group--font-family:var(--font-pattern, "Sora");--ez-grid-config__group--font-size:var(--text--medium, 14px);--ez-grid-config__group--font-weight:var(--text-weight--large, 600);--ez-grid-config__group--padding-bottom:var(--space-small, 6px);display:grid;grid-template-rows:auto 1fr auto;max-height:100%;width:100%}@media screen and (min-width: 480px){.sc-ez-grid-config-h{width:359px;max-width:359px}}.padding-right--medium.sc-ez-grid-config{padding-right:var(--space--medium)}ez-list.sc-ez-grid-config{height:100%}.height-calc.sc-ez-grid-config{max-height:calc(100% - 24px)}.grid-config__footer.sc-ez-grid-config{display:flex;justify-content:flex-end;width:100%;padding-top:var(--ez-grid-config__footer--padding-top)}.hidden.sc-ez-grid-config{display:none}.grid-config__main.sc-ez-grid-config{overflow-y:auto;padding-right:var(--ez-grid-config__main--padding-right)}.tabselector-container.sc-ez-grid-config{padding:var(--ez-grid-config__tabselector-container--padding) 0}.button-close.sc-ez-grid-config{padding-left:var(--ez-grid-config__button-close--padding-left)}.title-container.sc-ez-grid-config{display:flex;justify-content:space-between;align-items:center;width:100%}.subtitle.sc-ez-grid-config{font-family:var(--ez-grid-config__subtitle--font-family);font-size:var(--ez-grid-config__subtitle--font-size);color:var(--text--primary)}.title.sc-ez-grid-config{display:flex;margin:0;line-height:normal;letter-spacing:0em;text-align:left;color:var(--title--primary);font-family:var(--ez-grid-config__title--font-family);font-size:var(--title--large);font-weight:var(--ez-grid-config__title--font-weight)}.grid-config__main.sc-ez-grid-config::-webkit-scrollbar-track{background-color:#f0f2f5}.grid-config__main.sc-ez-grid-config::-webkit-scrollbar-thumb{background-color:var(--ez-grid-config__scrollbar--background-color);border-radius:var(--ez-grid-config__scrollbar--border-radius)}.grid-config__main.sc-ez-grid-config::-webkit-scrollbar{background-color:#f0f2f5;width:var(--ez-grid-config__scrollbar--width);max-width:var(--ez-grid-config__scrollbar--width);min-width:var(--ez-grid-config__scrollbar--width)}.group-name.sc-ez-grid-config{font-family:var(--ez-grid-config__group--font-family);font-size:var(--ez-grid-config__group--font-size);font-weight:var(--ez-grid-config__group--font-weight);padding-bottom:var(--ez-grid-config__group--padding-bottom)}';export{n as ez_grid_config}
@@ -1 +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 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-898b9906.js";import"./p-787fbdfe.js";const f=({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 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 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 _(e,t){return"__main"==e[0].label?-1:(e[0].order||1e4)-(t[0].order||1e4)}function w(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(w(0));if("function"==typeof t&&void 0===i&&(i=t,t=void 0),void 0!==i){if("function"!=typeof i)throw new Error(w(1));return i(x)(e,t)}if("function"!=typeof e)throw new Error(w(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(w(3));return r}function h(e){if("function"!=typeof e)throw new Error(w(4));if(l)throw new Error(w(5));var t=!0;return c(),o.push(e),function(){if(t){if(l)throw new Error(w(6));t=!1,c();var i=o.indexOf(e);o.splice(i,1),a=null}}}function u(e){if(!C(e))throw new Error(w(7));if(void 0===e.type)throw new Error(w(8));if(l)throw new Error(w(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(w(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(w(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 M.METADATA_LOADED:return Object.assign(Object.assign({},e),{formMetadata:t.payload});case M.CHANGE_TAB:return Object.assign(Object.assign({},e),{currentSheet:t.payload});default:return e}}function k(e){return e.formMetadata}var M;!function(e){e.METADATA_LOADED="FORM/METADATA_LOADED",e.CHANGE_TAB="FORM/CHANGE_TAB"}(M||(M={}));class N{constructor(e){this._invalidFields=new Map,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.EDITION_CANCELED:case o.SELECTION_CHANGED:case o.NEXT_SELECTED:case o.PREVIOUS_SELECTED:this.clearInvalid();case o.DATA_CHANGED:case o.CHANGE_UNDONE:case o.CHANGE_REDONE: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){this._invalidFields.set(e.name,e),this._fields.has(e.name)&&this.updateErrorMessage(e.name,this._fields.get(e.name).field)}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);t.errorMessage=i?i.message:""}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,P.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._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 P{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 P;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 D=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)=>{var i;const n=this.dataUnit.getModifiedRecords();for(let e=0;e<n.length;e++){const s=n[e],r=[];let a=this.validateRequired(s);if(a&&!a.isValid&&r.push(a),a=null===(i=this.recordsValidator)||void 0===i?void 0:i.validateRecord(this,s),a&&!a.isValid&&r.push(a),r.length>0){this.processValidationResult(r),t();break}}e()}))}observeConfig(){this.processMetadata()}validateRequired(e){const t=k(this._store.getState()),i=this._staticFields.filter((e=>e.dataset.required)).map((e=>e.dataset.fieldName)).concat(t.getRequiredFields()),n=[];if(i.forEach((t=>{const i=e[t];null!=i&&""!==i||n.push({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&&u.info(e.infoMessage),e.errorMessage){const{errorTitle:t,errorMessage:i}=e;u.error(t,i)}}))}getDynamicContent(){var t;const i=k(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:M.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()&&this.dataUnit){const e=this.config&&this.config.length>0?((e,t)=>{const i=new Map,n=[],s=[],r={};e.forEach((e=>{var a,o,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||"__main",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===(a=d.properties)||void 0===a?void 0:a.cleanOnCopy)||(null===(o=d.properties)||void 0===o?void 0:o.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 a=new g;return Array.from(i.entries()).sort(_).forEach((([e,t])=>{a.addSheet({label:"__main"===e.label?"Principal":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,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:M.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=k(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.SAVING_DATA)return new Promise((t=>{this.validate().then((()=>t(e))).catch((()=>{}))}));if(e.type===o.RECORDS_ADDED){const t=k(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 N(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"]}}};D.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{D 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-3c7ea91b.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-adbe4188.js";import"./p-787fbdfe.js";const f=({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 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 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 _(e,t){return"__main"==e[0].label?-1:(e[0].order||1e4)-(t[0].order||1e4)}function w(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(w(0));if("function"==typeof t&&void 0===i&&(i=t,t=void 0),void 0!==i){if("function"!=typeof i)throw new Error(w(1));return i(x)(e,t)}if("function"!=typeof e)throw new Error(w(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(w(3));return r}function h(e){if("function"!=typeof e)throw new Error(w(4));if(l)throw new Error(w(5));var t=!0;return c(),o.push(e),function(){if(t){if(l)throw new Error(w(6));t=!1,c();var i=o.indexOf(e);o.splice(i,1),a=null}}}function u(e){if(!C(e))throw new Error(w(7));if(void 0===e.type)throw new Error(w(8));if(l)throw new Error(w(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(w(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(w(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 M.METADATA_LOADED:return Object.assign(Object.assign({},e),{formMetadata:t.payload});case M.CHANGE_TAB:return Object.assign(Object.assign({},e),{currentSheet:t.payload});default:return e}}function k(e){return e.formMetadata}var M;!function(e){e.METADATA_LOADED="FORM/METADATA_LOADED",e.CHANGE_TAB="FORM/CHANGE_TAB"}(M||(M={}));class N{constructor(e){this._invalidFields=new Map,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.EDITION_CANCELED:case o.SELECTION_CHANGED:case o.NEXT_SELECTED:case o.PREVIOUS_SELECTED:this.clearInvalid();case o.DATA_CHANGED:case o.CHANGE_UNDONE:case o.CHANGE_REDONE: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){this._invalidFields.set(e.name,e),this._fields.has(e.name)&&this.updateErrorMessage(e.name,this._fields.get(e.name).field)}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);t.errorMessage=i?i.message:""}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,P.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._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 P{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 P;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 D=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)=>{var i;const n=this.dataUnit.getModifiedRecords();for(let e=0;e<n.length;e++){const s=n[e],r=[];let a=this.validateRequired(s);if(a&&!a.isValid&&r.push(a),a=null===(i=this.recordsValidator)||void 0===i?void 0:i.validateRecord(this,s),a&&!a.isValid&&r.push(a),r.length>0){this.processValidationResult(r),t();break}}e()}))}observeConfig(){this.processMetadata()}validateRequired(e){const t=k(this._store.getState()),i=this._staticFields.filter((e=>e.dataset.required)).map((e=>e.dataset.fieldName)).concat(t.getRequiredFields()),n=[];if(i.forEach((t=>{const i=e[t];null!=i&&""!==i||n.push({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&&u.info(e.infoMessage),e.errorMessage){const{errorTitle:t,errorMessage:i}=e;u.error(t,i)}}))}getDynamicContent(){var t;const i=k(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:M.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()&&this.dataUnit){const e=this.config&&this.config.length>0?((e,t)=>{const i=new Map,n=[],s=[],r={};e.forEach((e=>{var a,o,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||"__main",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===(a=d.properties)||void 0===a?void 0:a.cleanOnCopy)||(null===(o=d.properties)||void 0===o?void 0:o.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 a=new g;return Array.from(i.entries()).sort(_).forEach((([e,t])=>{a.addSheet({label:"__main"===e.label?"Principal":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,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:M.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=k(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.SAVING_DATA)return new Promise((t=>{this.validate().then((()=>t(e))).catch((()=>{}))}));if(e.type===o.RECORDS_ADDED){const t=k(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 N(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"]}}};D.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{D as ez_form}
@@ -1 +1 @@
1
- import{r as t,c as o,h as i,H as n,g as s}from"./p-3c7ea91b.js";import{FloatingManager as e}from"@sankhyalabs/core";import"./p-898b9906.js";import{C as a}from"./p-3263a002.js";import"./p-787fbdfe.js";let r=class{constructor(i){t(this,i),this.ezAction=o(this,"ezAction",7),this.enabled=!0,this.innerClickCheck=(t,o)=>{if(o&&t){if(o===t)return!0;const i=t.children;for(let t=0;t<i.length;t++)if(i[t].shadowRoot.contains(o))return!0}return!1}}showActions(){if(!this.enabled)return;this._floatingID=e.float(this._actionsList,this._listContainer,{autoClose:!0,innerClickTest:this.innerClickCheck});const t=document.body.clientWidth,o=this._actionsList.getBoundingClientRect();o.right>t&&e.updateFloatPosition(this._actionsList,this._listContainer,{autoClose:!0,innerClickTest:this.innerClickCheck,left:t-o.width+"px"}),window.requestAnimationFrame((()=>{this._actionsList.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}))}hideActions(){null!=this._floatingID&&e.close(this._floatingID),this._floatingID=void 0}handlerButtonClick(){this.showActions()}actionClick(t){this.hideActions(),this.ezAction.emit(t)}componentWillLoad(){if(null==this.actions){this.actions=[];const t=this._element.querySelectorAll("action");t&&t.forEach((t=>{let o=t.innerText,i=t.getAttribute("value");i||(i=o),this.actions.push({label:o,value:i}),t.hidden=!0}))}}componentDidLoad(){a.applyVarsButton(this._element,this._button)}componentDidRender(){null==this._floatingID&&this._actionsList.remove()}render(){return i(n,null,i("ez-button",{ref:t=>this._button=t,enabled:this.enabled,mode:"icon",iconName:"dots-vertical",size:this.size,onClick:()=>this.handlerButtonClick()}),i("section",{class:"list-container",ref:t=>this._listContainer=t},i("div",{class:"actions-list",ref:t=>this._actionsList=t},this.actions.map((t=>i("ez-button",{class:"btn-action",size:"small",label:t.label,onClick:()=>this.actionClick(t)}))))))}get _element(){return s(this)}};r.style=":host{--ez-actions-button__box--border-radius:var(--border--radius-medium, 12px);--ez-actions-button__box--box-shadow:var(--shadow, 0px 0px 16px 0px #000);--ez-actions-button__box--background-color:var(--background--xlight, #fff);--ez-actions-button__box--padding:var(--space-small, 6px);--ez-actions-button__box--top-margin:var(--space-extra-small, 3px);--ez-actions-button__action--min-width:400px;--ez-actions-button__action--background-color:var(--background--xlight, #fff);display:flex;flex-direction:column;height:fit-content;user-select:none}.actions-list{display:flex;flex-direction:column;position:absolute;width:fit-content;height:fit-content;z-index:var(--more-visible, 1);padding:var(--ez-actions-button__box--padding);margin-top:var(--ez-actions-button__box--top-margin);background-color:var(--ez-actions-button__box--background-color);border-radius:var(--ez-actions-button__box--border-radius);box-shadow:var(--ez-actions-button__box--box-shadow)}.btn-action{--ez-button--min-width:var(--ez-actions-button__action--min-width);--ez-button--background-color:var(--ez-actions-button__action--background-color)}";export{r as ez_actions_button}
1
+ import{r as t,c as o,h as i,H as n,g as s}from"./p-3c7ea91b.js";import{FloatingManager as e}from"@sankhyalabs/core";import"./p-adbe4188.js";import{C as a}from"./p-3263a002.js";import"./p-787fbdfe.js";let r=class{constructor(i){t(this,i),this.ezAction=o(this,"ezAction",7),this.enabled=!0,this.innerClickCheck=(t,o)=>{if(o&&t){if(o===t)return!0;const i=t.children;for(let t=0;t<i.length;t++)if(i[t].shadowRoot.contains(o))return!0}return!1}}showActions(){if(!this.enabled)return;this._floatingID=e.float(this._actionsList,this._listContainer,{autoClose:!0,innerClickTest:this.innerClickCheck});const t=document.body.clientWidth,o=this._actionsList.getBoundingClientRect();o.right>t&&e.updateFloatPosition(this._actionsList,this._listContainer,{autoClose:!0,innerClickTest:this.innerClickCheck,left:t-o.width+"px"}),window.requestAnimationFrame((()=>{this._actionsList.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}))}hideActions(){null!=this._floatingID&&e.close(this._floatingID),this._floatingID=void 0}handlerButtonClick(){this.showActions()}actionClick(t){this.hideActions(),this.ezAction.emit(t)}componentWillLoad(){if(null==this.actions){this.actions=[];const t=this._element.querySelectorAll("action");t&&t.forEach((t=>{let o=t.innerText,i=t.getAttribute("value");i||(i=o),this.actions.push({label:o,value:i}),t.hidden=!0}))}}componentDidLoad(){a.applyVarsButton(this._element,this._button)}componentDidRender(){null==this._floatingID&&this._actionsList.remove()}render(){return i(n,null,i("ez-button",{ref:t=>this._button=t,enabled:this.enabled,mode:"icon",iconName:"dots-vertical",size:this.size,onClick:()=>this.handlerButtonClick()}),i("section",{class:"list-container",ref:t=>this._listContainer=t},i("div",{class:"actions-list",ref:t=>this._actionsList=t},this.actions.map((t=>i("ez-button",{class:"btn-action",size:"small",label:t.label,onClick:()=>this.actionClick(t)}))))))}get _element(){return s(this)}};r.style=":host{--ez-actions-button__box--border-radius:var(--border--radius-medium, 12px);--ez-actions-button__box--box-shadow:var(--shadow, 0px 0px 16px 0px #000);--ez-actions-button__box--background-color:var(--background--xlight, #fff);--ez-actions-button__box--padding:var(--space-small, 6px);--ez-actions-button__box--top-margin:var(--space-extra-small, 3px);--ez-actions-button__action--min-width:400px;--ez-actions-button__action--background-color:var(--background--xlight, #fff);display:flex;flex-direction:column;height:fit-content;user-select:none}.actions-list{display:flex;flex-direction:column;position:absolute;width:fit-content;height:fit-content;z-index:var(--more-visible, 1);padding:var(--ez-actions-button__box--padding);margin-top:var(--ez-actions-button__box--top-margin);background-color:var(--ez-actions-button__box--background-color);border-radius:var(--ez-actions-button__box--border-radius);box-shadow:var(--ez-actions-button__box--box-shadow)}.btn-action{--ez-button--min-width:var(--ez-actions-button__action--min-width);--ez-button--background-color:var(--ez-actions-button__action--background-color)}";export{r as ez_actions_button}
@@ -1 +1 @@
1
- import{r as o,c as i,h as t,H as s,g as e}from"./p-3c7ea91b.js";import{FloatingManager as r}from"@sankhyalabs/core";import{A as a}from"./p-898b9906.js";import{C as l}from"./p-3263a002.js";import"./p-787fbdfe.js";let n=class{constructor(t){o(this,t),this.ezChange=i(this,"ezChange",7),this._changeDeboucingTimeout=null,this._limitCharsToSearch=3,this._deboucingTime=300,this._maxWidthValue=0,this._tabPressed=!1,this._textEmptyList="Nenhum resultado encontrado",this._startLoading=!1,this._showLoading=!0,this.enabled=!0,this.showSelectedValue=!1,this.showOptionValue=!1,this.suppressSearch=!1,this.suppressEmptyOption=!1,this.canShowError=!0,this.mode="regular"}observeErrorMessage(){var o;this._textInput&&(this._textInput.errorMessage=this.errorMessage,(null===(o=this.errorMessage)||void 0===o?void 0:o.trim())||this.setInputValue())}observeValue(o,i){var t,s,e,r;if(this._textInput&&o!=i){const a=this.getSelectedOption(o),l=this.getSelectedOption(i),n=this.getSelectedOption(this.value);(null===(t=null==n?void 0:n.value)||void 0===t?void 0:t.toString())!=(null===(s=null==a?void 0:a.value)||void 0===s?void 0:s.toString())&&(this.value=a),(null===(e=null==a?void 0:a.value)||void 0===e?void 0:e.toString())!==(null===(r=null==l?void 0:l.value)||void 0===r?void 0:r.toString())&&(this.setInputValue(),this.ezChange.emit(null===a?void 0:a)),this.hideOptions(),this._criteria=void 0,this._preSelection=void 0,this.updateVisibleOptions()}}async setFocus(){this._textInput.setFocus()}async setBlur(){this._textInput.setBlur()}async isInvalid(){return"string"==typeof this.errorMessage&&""!==this.errorMessage.trim()}getText(){let o="";const i=this.getSelectedOption(this.value);return i&&(o=this.showSelectedValue?`${i.value} - ${i.label}`:i.label),o}getSelectedOption(o){return"string"==typeof o||o instanceof String?this._visibleOptions.find((i=>i.value===o)):o}updateVisibleOptions(){let o=this._source||[];if(!this.searchMode&&this._criteria){const i=this._criteria.toUpperCase();o=o.filter((o=>o.label.toLocaleUpperCase().indexOf(i)>-1))}this._visibleOptions=this.suppressEmptyOption?o:[{value:void 0,label:""}].concat(o),this._maxWidthValue=this.getMaxWidthValue()}getMaxWidthValue(){var o;if(this.showOptionValue){const i=[];return null===(o=this._visibleOptions)||void 0===o||o.forEach((o=>{const t=this.getWidthValue(o.value);i.includes(t)||i.push(t)})),i.length>1?Math.max(...i):0}return 0}getWidthValue(o){if(this._itemValueBasis){const i=this._itemValueBasis;if(o)return i.innerHTML=o,i.clientWidth>0?i.clientWidth+1:0;i.innerHTML=""}return 0}buildItem(o,i){return t("li",{class:i===this._preSelection?"item preselected":"item",id:`item_${o.value}`,onMouseDown:()=>this.selectOption(o),onMouseOver:()=>this._preSelection=void 0},this.showOptionValue?t("span",{class:"item__value",title:o.value,style:{width:this.showOptionValue&&this._maxWidthValue>0?`${this._maxWidthValue}px`:""}},o.value):void 0,t("span",{class:"item__label",title:o.label},o.label))}showOptions(){this.enabled&&(this._floatingID=r.float(this._listWrapper,this._listContainer,{autoClose:!0,top:this.errorMessage||!this.canShowError||"slim"===this.mode?"0px":"-19px"}),window.requestAnimationFrame((()=>{this._listWrapper.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})})))}hideOptions(){void 0!==this._floatingID&&r.close(this._floatingID),this._floatingID=void 0}isOptionsVisible(){return void 0!==this._floatingID&&r.isFloating(this._floatingID)}nextOption(){this.searchMode&&!this.isOptionsVisible()||(this.showOptions(),this._preSelection=void 0===this._preSelection?0:Math.min(this._preSelection+1,this._visibleOptions.length-1),this.scrollToOption(this._visibleOptions[this._preSelection],!0))}previousOption(){this._preSelection=void 0===this._preSelection?0:Math.max(this._preSelection-1,0),this.scrollToOption(this._visibleOptions[this._preSelection],!1)}scrollToOption(o,i){window.requestAnimationFrame((()=>{const t=this._optionsList.querySelector(`li#item_${o.value}`);if(t){const o=t.parentElement,s=o.getBoundingClientRect(),e=t.getBoundingClientRect();i&&e.bottom>s.bottom?o.scrollTop=e.top:!i&&e.top<s.top&&(o.scrollTop=0)}}))}selectCurrentOption(){void 0!==this._preSelection?(this.selectOption(this._visibleOptions[this._preSelection]),this._preSelection=void 0):this.controlListWithOnlyOne()}updateSource(o){this._startLoading=!1,o instanceof Promise?(this._showLoading=!0,o.then((o=>{this._showLoading=!1,this.updateSource(o)})).catch((()=>this._showLoading=!1)),this.updateVisibleOptions()):(this._showLoading=!1,Array.isArray(o)?(this._source=o,this.updateVisibleOptions(),this._tabPressed&&(this._tabPressed=!1,this.controlEmptySearch())):this.selectOption(o))}clearSource(){this._source=[],this.updateVisibleOptions()}selectOption(o){var i,t;const s=this.getSelectedOption(this.value);(null===(i=null==s?void 0:s.value)||void 0===i?void 0:i.toString())!==(null===(t=null==o?void 0:o.value)||void 0===t?void 0:t.toString())?this.value=(null==o?void 0:o.value)?o:void 0:this.setInputValue(),this.searchMode&&(this._visibleOptions=[]),this.searchMode&&(this._visibleOptions=[])}loadOptions(o,i=""){this._criteria=i,this._startLoading=!0,this.updateSource(this.optionLoader?this.optionLoader({mode:o,argument:i}):this.options)}cancelPreselection(){!this._textInput.value&&this.value?this.selectOption(void 0):this.setInputValue()}setInputValue(o=!0){const i=this.getText();(this._textInput.value||"")!==i&&(this._textInput.value=i,o&&(this.errorMessage=""))}clearSearch(){this.value=null}controlListWithOnlyOne(){if(this.searchMode){const o=this._visibleOptions;1===(null==o?void 0:o.length)&&this.selectOption(o[0])}}controlEmptySearch(){var o;this.searchMode&&((null===(o=this._visibleOptions)||void 0===o?void 0:o.length)?this.controlListWithOnlyOne():(this.clearSearch(),a.info(this._textEmptyList)))}componentWillLoad(){if(void 0===this.options){this.options=[];const o=this.el.querySelectorAll("option");o&&o.forEach((o=>{let i=o.innerText,t=o.getAttribute("value");t||(t=i),this.options.push({label:i,value:t}),o.hidden=!0}))}this.searchMode?this.updateSource([]):this.loadOptions("PRELOAD")}componentDidRender(){void 0===this._floatingID&&this._listWrapper.remove()}componentDidLoad(){l.applyVarsTextInput(this.el,this._textInput),this.setInputValue(!1)}handlerIconClick(){this.searchMode?this.loadOptions("ADVANCED"):this.showOptions()}onTextInputChangeHandler(o){var i;if(this.clearDeboucingTimeout(),this._startLoading)return void(this._changeDeboucingTimeout=window.setTimeout((()=>{this.onTextInputChangeHandler(o)}),this._deboucingTime));const t=null===(i=o.target.value)||void 0===i?void 0:i.trim(),s=Number(t||void 0);this._criteria||(this._textInput.value=o.data||t),this._criteria=t,t&&(!isNaN(s)||t.length>=this._limitCharsToSearch)?(this.searchMode?(this._showLoading=!0,this.clearSource(),this._changeDeboucingTimeout=window.setTimeout((()=>{this.loadOptions("PREDICTIVE",isNaN(s)?t:s.toString())}),this._deboucingTime)):this.updateVisibleOptions(),this.showOptions()):this.hideOptions()}clearDeboucingTimeout(){this._changeDeboucingTimeout&&(window.clearTimeout(this._changeDeboucingTimeout),this._changeDeboucingTimeout=void 0)}onTextInputClickHandler(){this.searchMode||this.showOptions()}keyDownHandler(o){switch(this._tabPressed=!1,o.key){case"ArrowDown":this.nextOption();break;case"ArrowUp":this.previousOption();break;case"Enter":this.selectCurrentOption();break;case"Escape":this.cancelPreselection();break;case"Tab":this._tabPressed=!0,this.controlListWithOnlyOne()}o.stopPropagation()}onTextInputFocusOutHandler(){this.cancelPreselection()}render(){var o;return t(s,null,t("ez-text-input",{class:this.suppressSearch?"suppressed-search-input":"",ref:o=>this._textInput=o,"data-slave-mode":"true",enabled:this.enabled&&!this.suppressSearch,onInput:o=>this.onTextInputChangeHandler(o),onClick:()=>this.onTextInputClickHandler(),onFocusout:()=>this.onTextInputFocusOutHandler(),onKeyDown:o=>this.keyDownHandler(o),label:this.label,canShowError:this.canShowError,errorMessage:this.errorMessage,mode:this.mode},t("button",{class:"btn",slot:this.searchMode?"leftIcon":"rightIcon",disabled:!this.enabled,tabindex:-1,onClick:()=>this.handlerIconClick()},t("ez-icon",{iconName:this.searchMode?"search":"chevron-down"})),this.searchMode&&(null===(o=this._textInput)||void 0===o?void 0:o.value)&&(this._criteria||this.value)?t("button",{class:"btn btn__close",slot:"rightIcon",disabled:!this.enabled,tabindex:-1,onClick:()=>this.clearSearch()},t("ez-icon",{iconName:"close"})):void 0),t("section",{class:"list-container",ref:o=>this._listContainer=o},t("div",{class:"list-wrapper",ref:o=>this._listWrapper=o},t("div",{class:"list-options",ref:o=>this._optionsList=o},0===this._visibleOptions.length&&t("div",{class:"message"},!this._showLoading&&t("span",{class:"message__no-result"},this._textEmptyList),this._showLoading&&t("div",{class:"message__loading"})),this.showOptionValue?t("span",{class:"item__value item__value--hidden",ref:o=>this._itemValueBasis=o}):void 0,this._visibleOptions.length>0&&this._visibleOptions.map(((o,i)=>this.buildItem(o,i)))))))}get el(){return e(this)}static get watchers(){return{errorMessage:["observeErrorMessage"],value:["observeValue"]}}};n.style=":host{--ez-combo-box--height:42px;--ez-combo-box--width:100%;--ez-combo-box__icon--width:48px;--ez-combo-box--border-radius:var(--border--radius-medium, 12px);--ez-combo-box--border-radius-small:var(--border--radius-small, 6px);--ez-combo-box--font-size:var(--text--medium, 14px);--ez-combo-box--font-family:var(--font-pattern, Arial);--ez-combo-box--font-weight--large:var(--text-weight--large, 500);--ez-combo-box--font-weight--medium:var(--text-weight--medium, 400);--ez-combo-box--background-color--xlight:var(--background--xlight, #fff);--ez-combo-box--background-medium:var(--background--medium, #f0f3f7);--ez-combo-box__input--background-color:var(--background--medium, #e0e0e0);--ez-combo-box__input--border:var(--border--medium, 2px solid);--ez-combo-box__input--border-color:var(--ez-combo-box__input--background-color);--ez-combo-box__input--focus--border-color:var(--color--primary, #008561);--ez-combo-box__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--ez-combo-box__input--disabled--color:var(--text--disable, #AFB6C0);--ez-combo-box__input--error--border-color:#CC2936;--ez-combo-box__btn--color:var(--title--primary, #2B3A54);--ez-combo-box__btn-disabled--color:var(--text--disable, #AFB6C0);--ez-combo-box__btn-hover--color:var(--color--primary, #4e4e4e);--ez-combo-box__label--color:var(--title--primary, #2B3A54);--ez-combo-box__list-title--primary:var(--title--primary, #2B3A54);--ez-combo-box__list-text--primary:var(--text--primary, #626e82);--ez-combo-box__list-height:calc(var(--ez-combo-box--font-size) + var(--ez-combo-box--space--medium));--ez-combo-box--space--medium:var(--space--medium, 12px);--ez-combo-box--space--small:var(--space--small, 6px);--ez-combo-box__list-scrollbar--background-color-primary:var(--scrollbar--primary, #2B3A54);--ez-combo-box__list-scrollbar--background-color-secondary:var(--scrollbar--secondary, #E5EAF0);--ez-combo-box__list-scrollbar--border-radius:var(--border--radius-small, 6px);--ez-combo-box__list-scrollbar--width:var(--space--medium, 12px);display:flex;flex-wrap:wrap;position:relative;width:var(--ez-combo-box--width)}ez-icon{--ez-icon--color:inherit;font-weight:var(--text-weight--large, 600)}.suppressed-search-input{--ez-text-input__input--border-color:var(--color--strokes, #dce0e8);--ez-text-input__input--disabled--background-color:var(--background--xlight, #fff);--ez-text-input__input--disabled--color:var(--title--primary, #2B3A54)}.list-container{position:relative;width:100%}.list-wrapper{display:flex;flex-direction:column;box-sizing:border-box;width:100%;z-index:var(--more-visible, 2);max-height:calc(4*var(--ez-combo-box__list-height) + 2*var(--ez-combo-box--space--small));background-color:var(--ez-combo-box--background-color--xlight);border-radius:var(--ez-combo-box--border-radius);box-shadow:var(--shadow, 0px 0px 16px 0px #000);padding:var(--ez-combo-box--space--small)}.list-options{box-sizing:border-box;width:100%;height:100%;display:flex;flex-direction:column;scroll-behavior:smooth;overflow:auto;scrollbar-width:thin;scrollbar-color:var(--ez-combo-box__list-scrollbar--background-color-primary) var(--ez-combo-box__list-scrollbar--background-color-secondary)}.list-options::-webkit-scrollbar-track{background-color:var(--ez-combo-box__list-scrollbar--background-color-secondary);border-radius:var(--ez-combo-box__list-scrollbar--border-radius)}.list-options::-webkit-scrollbar-thumb{background-color:var(--ez-combo-box__list-scrollbar--background-color-primary);border-radius:var(--ez-combo-box__list-scrollbar--border-radius)}.list-options::-webkit-scrollbar{background-color:var(--ez-combo-box__list-scrollbar--background-color-secondary);width:var(--ez-combo-box__list-scrollbar--width);max-width:var(--ez-combo-box__list-scrollbar--width);min-width:var(--ez-combo-box__list-scrollbar--width)}.list-options::-webkit-scrollbar-track{background-color:#f0f2f5;border-radius:var(--ez-combo-box__list-scrollbar--border-radius)}.list-options::-webkit-scrollbar-thumb{background-color:var(--ez-combo-box__list-scrollbar--background-color);border-radius:var(--ez-combo-box__list-scrollbar--border-radius)}.list-options::-webkit-scrollbar{background-color:#f0f2f5;width:var(--ez-combo-box__list-scrollbar--width);max-width:var(--ez-combo-box__list-scrollbar--width);min-width:var(--ez-combo-box__list-scrollbar--width)}.item{display:flex;align-items:center;width:100%;box-sizing:border-box;list-style-type:none;cursor:pointer;border-radius:var(--ez-combo-box--border-radius-small);padding:0 var(--ez-combo-box--space--small);min-height:var(--ez-combo-box__list-height);gap:var(--space--small, 6px)}.item__value,.item__label{flex-basis:auto;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--ez-combo-box__list-title--primary);font-weight:var(--ez-combo-box--font-weight--large);font-family:var(--ez-combo-box--font-family);font-size:var(--ez-combo-box--font-size)}.item__value{text-align:center;color:var(--ez-combo-box__list-text--primary)}.item__value--hidden{visibility:hidden;position:absolute;z-index:-1;top:0;left:0}.item__label{text-align:left}.message{text-align:center;display:flex;justify-content:center;align-items:center;list-style-type:none;min-height:calc(var(--ez-combo-box__list-height) * 1.5)}.message__no-result{color:var(--ez-combo-box__list-title--primary);font-family:var(--ez-combo-box--font-family);font-size:var(--ez-combo-box--font-size)}.message__loading{border-radius:50%;width:16px;height:16px;-webkit-animation:spin 1s linear infinite;animation:spin 1s linear infinite;border:3px solid var(--ez-combo-box__list-title--primary);border-top:3px solid transparent}li:hover{background-color:var(--ez-combo-box--background-medium)}.preselected{background-color:var(--background--medium)}.btn{outline:none;border:none;background:none;cursor:pointer;color:var(--ez-combo-box__btn--color)}.btn:disabled{cursor:unset;color:var(--ez-combo-box__btn-disabled--color)}.btn:disabled:hover{cursor:unset;color:var(--ez-combo-box__btn-disabled--color)}.btn:hover{color:var(--ez-combo-box__btn-hover--color)}.btn__close{visibility:hidden}ez-text-input:hover .btn__close,ez-text-input:focus .btn__close{visibility:visible}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg)}}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}";export{n as ez_combo_box}
1
+ import{r as o,c as i,h as t,H as s,g as e}from"./p-3c7ea91b.js";import{FloatingManager as r}from"@sankhyalabs/core";import{A as a}from"./p-adbe4188.js";import{C as l}from"./p-3263a002.js";import"./p-787fbdfe.js";let n=class{constructor(t){o(this,t),this.ezChange=i(this,"ezChange",7),this._changeDeboucingTimeout=null,this._limitCharsToSearch=3,this._deboucingTime=300,this._maxWidthValue=0,this._tabPressed=!1,this._textEmptyList="Nenhum resultado encontrado",this._startLoading=!1,this._showLoading=!0,this.enabled=!0,this.showSelectedValue=!1,this.showOptionValue=!1,this.suppressSearch=!1,this.suppressEmptyOption=!1,this.canShowError=!0,this.mode="regular"}observeErrorMessage(){var o;this._textInput&&(this._textInput.errorMessage=this.errorMessage,(null===(o=this.errorMessage)||void 0===o?void 0:o.trim())||this.setInputValue())}observeValue(o,i){var t,s,e,r;if(this._textInput&&o!=i){const a=this.getSelectedOption(o),l=this.getSelectedOption(i),n=this.getSelectedOption(this.value);(null===(t=null==n?void 0:n.value)||void 0===t?void 0:t.toString())!=(null===(s=null==a?void 0:a.value)||void 0===s?void 0:s.toString())&&(this.value=a),(null===(e=null==a?void 0:a.value)||void 0===e?void 0:e.toString())!==(null===(r=null==l?void 0:l.value)||void 0===r?void 0:r.toString())&&(this.setInputValue(),this.ezChange.emit(null===a?void 0:a)),this.hideOptions(),this._criteria=void 0,this._preSelection=void 0,this.updateVisibleOptions()}}async setFocus(){this._textInput.setFocus()}async setBlur(){this._textInput.setBlur()}async isInvalid(){return"string"==typeof this.errorMessage&&""!==this.errorMessage.trim()}getText(){let o="";const i=this.getSelectedOption(this.value);return i&&(o=this.showSelectedValue?`${i.value} - ${i.label}`:i.label),o}getSelectedOption(o){return"string"==typeof o||o instanceof String?this._visibleOptions.find((i=>i.value===o)):o}updateVisibleOptions(){let o=this._source||[];if(!this.searchMode&&this._criteria){const i=this._criteria.toUpperCase();o=o.filter((o=>o.label.toLocaleUpperCase().indexOf(i)>-1))}this._visibleOptions=this.suppressEmptyOption?o:[{value:void 0,label:""}].concat(o),this._maxWidthValue=this.getMaxWidthValue()}getMaxWidthValue(){var o;if(this.showOptionValue){const i=[];return null===(o=this._visibleOptions)||void 0===o||o.forEach((o=>{const t=this.getWidthValue(o.value);i.includes(t)||i.push(t)})),i.length>1?Math.max(...i):0}return 0}getWidthValue(o){if(this._itemValueBasis){const i=this._itemValueBasis;if(o)return i.innerHTML=o,i.clientWidth>0?i.clientWidth+1:0;i.innerHTML=""}return 0}buildItem(o,i){return t("li",{class:i===this._preSelection?"item preselected":"item",id:`item_${o.value}`,onMouseDown:()=>this.selectOption(o),onMouseOver:()=>this._preSelection=void 0},this.showOptionValue?t("span",{class:"item__value",title:o.value,style:{width:this.showOptionValue&&this._maxWidthValue>0?`${this._maxWidthValue}px`:""}},o.value):void 0,t("span",{class:"item__label",title:o.label},o.label))}showOptions(){this.enabled&&(this._floatingID=r.float(this._listWrapper,this._listContainer,{autoClose:!0,top:this.errorMessage||!this.canShowError||"slim"===this.mode?"0px":"-19px"}),window.requestAnimationFrame((()=>{this._listWrapper.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})})))}hideOptions(){void 0!==this._floatingID&&r.close(this._floatingID),this._floatingID=void 0}isOptionsVisible(){return void 0!==this._floatingID&&r.isFloating(this._floatingID)}nextOption(){this.searchMode&&!this.isOptionsVisible()||(this.showOptions(),this._preSelection=void 0===this._preSelection?0:Math.min(this._preSelection+1,this._visibleOptions.length-1),this.scrollToOption(this._visibleOptions[this._preSelection],!0))}previousOption(){this._preSelection=void 0===this._preSelection?0:Math.max(this._preSelection-1,0),this.scrollToOption(this._visibleOptions[this._preSelection],!1)}scrollToOption(o,i){window.requestAnimationFrame((()=>{const t=this._optionsList.querySelector(`li#item_${o.value}`);if(t){const o=t.parentElement,s=o.getBoundingClientRect(),e=t.getBoundingClientRect();i&&e.bottom>s.bottom?o.scrollTop=e.top:!i&&e.top<s.top&&(o.scrollTop=0)}}))}selectCurrentOption(){void 0!==this._preSelection?(this.selectOption(this._visibleOptions[this._preSelection]),this._preSelection=void 0):this.controlListWithOnlyOne()}updateSource(o){this._startLoading=!1,o instanceof Promise?(this._showLoading=!0,o.then((o=>{this._showLoading=!1,this.updateSource(o)})).catch((()=>this._showLoading=!1)),this.updateVisibleOptions()):(this._showLoading=!1,Array.isArray(o)?(this._source=o,this.updateVisibleOptions(),this._tabPressed&&(this._tabPressed=!1,this.controlEmptySearch())):this.selectOption(o))}clearSource(){this._source=[],this.updateVisibleOptions()}selectOption(o){var i,t;const s=this.getSelectedOption(this.value);(null===(i=null==s?void 0:s.value)||void 0===i?void 0:i.toString())!==(null===(t=null==o?void 0:o.value)||void 0===t?void 0:t.toString())?this.value=(null==o?void 0:o.value)?o:void 0:this.setInputValue(),this.searchMode&&(this._visibleOptions=[]),this.searchMode&&(this._visibleOptions=[])}loadOptions(o,i=""){this._criteria=i,this._startLoading=!0,this.updateSource(this.optionLoader?this.optionLoader({mode:o,argument:i}):this.options)}cancelPreselection(){!this._textInput.value&&this.value?this.selectOption(void 0):this.setInputValue()}setInputValue(o=!0){const i=this.getText();(this._textInput.value||"")!==i&&(this._textInput.value=i,o&&(this.errorMessage=""))}clearSearch(){this.value=null}controlListWithOnlyOne(){if(this.searchMode){const o=this._visibleOptions;1===(null==o?void 0:o.length)&&this.selectOption(o[0])}}controlEmptySearch(){var o;this.searchMode&&((null===(o=this._visibleOptions)||void 0===o?void 0:o.length)?this.controlListWithOnlyOne():(this.clearSearch(),a.info(this._textEmptyList)))}componentWillLoad(){if(void 0===this.options){this.options=[];const o=this.el.querySelectorAll("option");o&&o.forEach((o=>{let i=o.innerText,t=o.getAttribute("value");t||(t=i),this.options.push({label:i,value:t}),o.hidden=!0}))}this.searchMode?this.updateSource([]):this.loadOptions("PRELOAD")}componentDidRender(){void 0===this._floatingID&&this._listWrapper.remove()}componentDidLoad(){l.applyVarsTextInput(this.el,this._textInput),this.setInputValue(!1)}handlerIconClick(){this.searchMode?this.loadOptions("ADVANCED"):this.showOptions()}onTextInputChangeHandler(o){var i;if(this.clearDeboucingTimeout(),this._startLoading)return void(this._changeDeboucingTimeout=window.setTimeout((()=>{this.onTextInputChangeHandler(o)}),this._deboucingTime));const t=null===(i=o.target.value)||void 0===i?void 0:i.trim(),s=Number(t||void 0);this._criteria||(this._textInput.value=o.data||t),this._criteria=t,t&&(!isNaN(s)||t.length>=this._limitCharsToSearch)?(this.searchMode?(this._showLoading=!0,this.clearSource(),this._changeDeboucingTimeout=window.setTimeout((()=>{this.loadOptions("PREDICTIVE",isNaN(s)?t:s.toString())}),this._deboucingTime)):this.updateVisibleOptions(),this.showOptions()):this.hideOptions()}clearDeboucingTimeout(){this._changeDeboucingTimeout&&(window.clearTimeout(this._changeDeboucingTimeout),this._changeDeboucingTimeout=void 0)}onTextInputClickHandler(){this.searchMode||this.showOptions()}keyDownHandler(o){switch(this._tabPressed=!1,o.key){case"ArrowDown":this.nextOption();break;case"ArrowUp":this.previousOption();break;case"Enter":this.selectCurrentOption();break;case"Escape":this.cancelPreselection();break;case"Tab":this._tabPressed=!0,this.controlListWithOnlyOne()}o.stopPropagation()}onTextInputFocusOutHandler(){this.cancelPreselection()}render(){var o;return t(s,null,t("ez-text-input",{class:this.suppressSearch?"suppressed-search-input":"",ref:o=>this._textInput=o,"data-slave-mode":"true",enabled:this.enabled&&!this.suppressSearch,onInput:o=>this.onTextInputChangeHandler(o),onClick:()=>this.onTextInputClickHandler(),onFocusout:()=>this.onTextInputFocusOutHandler(),onKeyDown:o=>this.keyDownHandler(o),label:this.label,canShowError:this.canShowError,errorMessage:this.errorMessage,mode:this.mode},t("button",{class:"btn",slot:this.searchMode?"leftIcon":"rightIcon",disabled:!this.enabled,tabindex:-1,onClick:()=>this.handlerIconClick()},t("ez-icon",{iconName:this.searchMode?"search":"chevron-down"})),this.searchMode&&(null===(o=this._textInput)||void 0===o?void 0:o.value)&&(this._criteria||this.value)?t("button",{class:"btn btn__close",slot:"rightIcon",disabled:!this.enabled,tabindex:-1,onClick:()=>this.clearSearch()},t("ez-icon",{iconName:"close"})):void 0),t("section",{class:"list-container",ref:o=>this._listContainer=o},t("div",{class:"list-wrapper",ref:o=>this._listWrapper=o},t("div",{class:"list-options",ref:o=>this._optionsList=o},0===this._visibleOptions.length&&t("div",{class:"message"},!this._showLoading&&t("span",{class:"message__no-result"},this._textEmptyList),this._showLoading&&t("div",{class:"message__loading"})),this.showOptionValue?t("span",{class:"item__value item__value--hidden",ref:o=>this._itemValueBasis=o}):void 0,this._visibleOptions.length>0&&this._visibleOptions.map(((o,i)=>this.buildItem(o,i)))))))}get el(){return e(this)}static get watchers(){return{errorMessage:["observeErrorMessage"],value:["observeValue"]}}};n.style=":host{--ez-combo-box--height:42px;--ez-combo-box--width:100%;--ez-combo-box__icon--width:48px;--ez-combo-box--border-radius:var(--border--radius-medium, 12px);--ez-combo-box--border-radius-small:var(--border--radius-small, 6px);--ez-combo-box--font-size:var(--text--medium, 14px);--ez-combo-box--font-family:var(--font-pattern, Arial);--ez-combo-box--font-weight--large:var(--text-weight--large, 500);--ez-combo-box--font-weight--medium:var(--text-weight--medium, 400);--ez-combo-box--background-color--xlight:var(--background--xlight, #fff);--ez-combo-box--background-medium:var(--background--medium, #f0f3f7);--ez-combo-box__input--background-color:var(--background--medium, #e0e0e0);--ez-combo-box__input--border:var(--border--medium, 2px solid);--ez-combo-box__input--border-color:var(--ez-combo-box__input--background-color);--ez-combo-box__input--focus--border-color:var(--color--primary, #008561);--ez-combo-box__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--ez-combo-box__input--disabled--color:var(--text--disable, #AFB6C0);--ez-combo-box__input--error--border-color:#CC2936;--ez-combo-box__btn--color:var(--title--primary, #2B3A54);--ez-combo-box__btn-disabled--color:var(--text--disable, #AFB6C0);--ez-combo-box__btn-hover--color:var(--color--primary, #4e4e4e);--ez-combo-box__label--color:var(--title--primary, #2B3A54);--ez-combo-box__list-title--primary:var(--title--primary, #2B3A54);--ez-combo-box__list-text--primary:var(--text--primary, #626e82);--ez-combo-box__list-height:calc(var(--ez-combo-box--font-size) + var(--ez-combo-box--space--medium));--ez-combo-box--space--medium:var(--space--medium, 12px);--ez-combo-box--space--small:var(--space--small, 6px);--ez-combo-box__list-scrollbar--background-color-primary:var(--scrollbar--primary, #2B3A54);--ez-combo-box__list-scrollbar--background-color-secondary:var(--scrollbar--secondary, #E5EAF0);--ez-combo-box__list-scrollbar--border-radius:var(--border--radius-small, 6px);--ez-combo-box__list-scrollbar--width:var(--space--medium, 12px);display:flex;flex-wrap:wrap;position:relative;width:var(--ez-combo-box--width)}ez-icon{--ez-icon--color:inherit;font-weight:var(--text-weight--large, 600)}.suppressed-search-input{--ez-text-input__input--border-color:var(--color--strokes, #dce0e8);--ez-text-input__input--disabled--background-color:var(--background--xlight, #fff);--ez-text-input__input--disabled--color:var(--title--primary, #2B3A54)}.list-container{position:relative;width:100%}.list-wrapper{display:flex;flex-direction:column;box-sizing:border-box;width:100%;z-index:var(--more-visible, 2);max-height:calc(4*var(--ez-combo-box__list-height) + 2*var(--ez-combo-box--space--small));background-color:var(--ez-combo-box--background-color--xlight);border-radius:var(--ez-combo-box--border-radius);box-shadow:var(--shadow, 0px 0px 16px 0px #000);padding:var(--ez-combo-box--space--small)}.list-options{box-sizing:border-box;width:100%;height:100%;display:flex;flex-direction:column;scroll-behavior:smooth;overflow:auto;scrollbar-width:thin;scrollbar-color:var(--ez-combo-box__list-scrollbar--background-color-primary) var(--ez-combo-box__list-scrollbar--background-color-secondary)}.list-options::-webkit-scrollbar-track{background-color:var(--ez-combo-box__list-scrollbar--background-color-secondary);border-radius:var(--ez-combo-box__list-scrollbar--border-radius)}.list-options::-webkit-scrollbar-thumb{background-color:var(--ez-combo-box__list-scrollbar--background-color-primary);border-radius:var(--ez-combo-box__list-scrollbar--border-radius)}.list-options::-webkit-scrollbar{background-color:var(--ez-combo-box__list-scrollbar--background-color-secondary);width:var(--ez-combo-box__list-scrollbar--width);max-width:var(--ez-combo-box__list-scrollbar--width);min-width:var(--ez-combo-box__list-scrollbar--width)}.list-options::-webkit-scrollbar-track{background-color:#f0f2f5;border-radius:var(--ez-combo-box__list-scrollbar--border-radius)}.list-options::-webkit-scrollbar-thumb{background-color:var(--ez-combo-box__list-scrollbar--background-color);border-radius:var(--ez-combo-box__list-scrollbar--border-radius)}.list-options::-webkit-scrollbar{background-color:#f0f2f5;width:var(--ez-combo-box__list-scrollbar--width);max-width:var(--ez-combo-box__list-scrollbar--width);min-width:var(--ez-combo-box__list-scrollbar--width)}.item{display:flex;align-items:center;width:100%;box-sizing:border-box;list-style-type:none;cursor:pointer;border-radius:var(--ez-combo-box--border-radius-small);padding:0 var(--ez-combo-box--space--small);min-height:var(--ez-combo-box__list-height);gap:var(--space--small, 6px)}.item__value,.item__label{flex-basis:auto;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--ez-combo-box__list-title--primary);font-weight:var(--ez-combo-box--font-weight--large);font-family:var(--ez-combo-box--font-family);font-size:var(--ez-combo-box--font-size)}.item__value{text-align:center;color:var(--ez-combo-box__list-text--primary)}.item__value--hidden{visibility:hidden;position:absolute;z-index:-1;top:0;left:0}.item__label{text-align:left}.message{text-align:center;display:flex;justify-content:center;align-items:center;list-style-type:none;min-height:calc(var(--ez-combo-box__list-height) * 1.5)}.message__no-result{color:var(--ez-combo-box__list-title--primary);font-family:var(--ez-combo-box--font-family);font-size:var(--ez-combo-box--font-size)}.message__loading{border-radius:50%;width:16px;height:16px;-webkit-animation:spin 1s linear infinite;animation:spin 1s linear infinite;border:3px solid var(--ez-combo-box__list-title--primary);border-top:3px solid transparent}li:hover{background-color:var(--ez-combo-box--background-medium)}.preselected{background-color:var(--background--medium)}.btn{outline:none;border:none;background:none;cursor:pointer;color:var(--ez-combo-box__btn--color)}.btn:disabled{cursor:unset;color:var(--ez-combo-box__btn-disabled--color)}.btn:disabled:hover{cursor:unset;color:var(--ez-combo-box__btn-disabled--color)}.btn:hover{color:var(--ez-combo-box__btn-hover--color)}.btn__close{visibility:hidden}ez-text-input:hover .btn__close,ez-text-input:focus .btn__close{visibility:visible}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg)}}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}";export{n as ez_combo_box}
@@ -0,0 +1,388 @@
1
+ /*
2
+ Stencil Client Platform v2.13.0 | MIT Licensed | https://stenciljs.com
3
+ */
4
+ /**
5
+ * @license
6
+ * Copyright Google Inc. All Rights Reserved.
7
+ *
8
+ * Use of this source code is governed by an MIT-style license that can be
9
+ * found in the LICENSE file at https://angular.io/license
10
+ *
11
+ * This file is a port of shadowCSS from webcomponents.js to TypeScript.
12
+ * https://github.com/webcomponents/webcomponentsjs/blob/4efecd7e0e/src/ShadowCSS/ShadowCSS.js
13
+ * https://github.com/angular/angular/blob/master/packages/compiler/src/shadow_css.ts
14
+ */
15
+ const safeSelector = (selector) => {
16
+ const placeholders = [];
17
+ let index = 0;
18
+ let content;
19
+ // Replaces attribute selectors with placeholders.
20
+ // The WS in [attr="va lue"] would otherwise be interpreted as a selector separator.
21
+ selector = selector.replace(/(\[[^\]]*\])/g, (_, keep) => {
22
+ const replaceBy = `__ph-${index}__`;
23
+ placeholders.push(keep);
24
+ index++;
25
+ return replaceBy;
26
+ });
27
+ // Replaces the expression in `:nth-child(2n + 1)` with a placeholder.
28
+ // WS and "+" would otherwise be interpreted as selector separators.
29
+ content = selector.replace(/(:nth-[-\w]+)(\([^)]+\))/g, (_, pseudo, exp) => {
30
+ const replaceBy = `__ph-${index}__`;
31
+ placeholders.push(exp);
32
+ index++;
33
+ return pseudo + replaceBy;
34
+ });
35
+ const ss = {
36
+ content,
37
+ placeholders,
38
+ };
39
+ return ss;
40
+ };
41
+ const restoreSafeSelector = (placeholders, content) => {
42
+ return content.replace(/__ph-(\d+)__/g, (_, index) => placeholders[+index]);
43
+ };
44
+ const _polyfillHost = '-shadowcsshost';
45
+ const _polyfillSlotted = '-shadowcssslotted';
46
+ // note: :host-context pre-processed to -shadowcsshostcontext.
47
+ const _polyfillHostContext = '-shadowcsscontext';
48
+ const _parenSuffix = ')(?:\\((' + '(?:\\([^)(]*\\)|[^)(]*)+?' + ')\\))?([^,{]*)';
49
+ const _cssColonHostRe = new RegExp('(' + _polyfillHost + _parenSuffix, 'gim');
50
+ const _cssColonHostContextRe = new RegExp('(' + _polyfillHostContext + _parenSuffix, 'gim');
51
+ const _cssColonSlottedRe = new RegExp('(' + _polyfillSlotted + _parenSuffix, 'gim');
52
+ const _polyfillHostNoCombinator = _polyfillHost + '-no-combinator';
53
+ const _polyfillHostNoCombinatorRe = /-shadowcsshost-no-combinator([^\s]*)/;
54
+ const _shadowDOMSelectorsRe = [/::shadow/g, /::content/g];
55
+ const _selectorReSuffix = '([>\\s~+[.,{:][\\s\\S]*)?$';
56
+ const _polyfillHostRe = /-shadowcsshost/gim;
57
+ const _colonHostRe = /:host/gim;
58
+ const _colonSlottedRe = /::slotted/gim;
59
+ const _colonHostContextRe = /:host-context/gim;
60
+ const _commentRe = /\/\*\s*[\s\S]*?\*\//g;
61
+ const stripComments = (input) => {
62
+ return input.replace(_commentRe, '');
63
+ };
64
+ const _commentWithHashRe = /\/\*\s*#\s*source(Mapping)?URL=[\s\S]+?\*\//g;
65
+ const extractCommentsWithHash = (input) => {
66
+ return input.match(_commentWithHashRe) || [];
67
+ };
68
+ const _ruleRe = /(\s*)([^;\{\}]+?)(\s*)((?:{%BLOCK%}?\s*;?)|(?:\s*;))/g;
69
+ const _curlyRe = /([{}])/g;
70
+ const _selectorPartsRe = /(^.*?[^\\])??((:+)(.*)|$)/;
71
+ const OPEN_CURLY = '{';
72
+ const CLOSE_CURLY = '}';
73
+ const BLOCK_PLACEHOLDER = '%BLOCK%';
74
+ const processRules = (input, ruleCallback) => {
75
+ const inputWithEscapedBlocks = escapeBlocks(input);
76
+ let nextBlockIndex = 0;
77
+ return inputWithEscapedBlocks.escapedString.replace(_ruleRe, (...m) => {
78
+ const selector = m[2];
79
+ let content = '';
80
+ let suffix = m[4];
81
+ let contentPrefix = '';
82
+ if (suffix && suffix.startsWith('{' + BLOCK_PLACEHOLDER)) {
83
+ content = inputWithEscapedBlocks.blocks[nextBlockIndex++];
84
+ suffix = suffix.substring(BLOCK_PLACEHOLDER.length + 1);
85
+ contentPrefix = '{';
86
+ }
87
+ const cssRule = {
88
+ selector,
89
+ content,
90
+ };
91
+ const rule = ruleCallback(cssRule);
92
+ return `${m[1]}${rule.selector}${m[3]}${contentPrefix}${rule.content}${suffix}`;
93
+ });
94
+ };
95
+ const escapeBlocks = (input) => {
96
+ const inputParts = input.split(_curlyRe);
97
+ const resultParts = [];
98
+ const escapedBlocks = [];
99
+ let bracketCount = 0;
100
+ let currentBlockParts = [];
101
+ for (let partIndex = 0; partIndex < inputParts.length; partIndex++) {
102
+ const part = inputParts[partIndex];
103
+ if (part === CLOSE_CURLY) {
104
+ bracketCount--;
105
+ }
106
+ if (bracketCount > 0) {
107
+ currentBlockParts.push(part);
108
+ }
109
+ else {
110
+ if (currentBlockParts.length > 0) {
111
+ escapedBlocks.push(currentBlockParts.join(''));
112
+ resultParts.push(BLOCK_PLACEHOLDER);
113
+ currentBlockParts = [];
114
+ }
115
+ resultParts.push(part);
116
+ }
117
+ if (part === OPEN_CURLY) {
118
+ bracketCount++;
119
+ }
120
+ }
121
+ if (currentBlockParts.length > 0) {
122
+ escapedBlocks.push(currentBlockParts.join(''));
123
+ resultParts.push(BLOCK_PLACEHOLDER);
124
+ }
125
+ const strEscapedBlocks = {
126
+ escapedString: resultParts.join(''),
127
+ blocks: escapedBlocks,
128
+ };
129
+ return strEscapedBlocks;
130
+ };
131
+ const insertPolyfillHostInCssText = (selector) => {
132
+ selector = selector
133
+ .replace(_colonHostContextRe, _polyfillHostContext)
134
+ .replace(_colonHostRe, _polyfillHost)
135
+ .replace(_colonSlottedRe, _polyfillSlotted);
136
+ return selector;
137
+ };
138
+ const convertColonRule = (cssText, regExp, partReplacer) => {
139
+ // m[1] = :host(-context), m[2] = contents of (), m[3] rest of rule
140
+ return cssText.replace(regExp, (...m) => {
141
+ if (m[2]) {
142
+ const parts = m[2].split(',');
143
+ const r = [];
144
+ for (let i = 0; i < parts.length; i++) {
145
+ const p = parts[i].trim();
146
+ if (!p)
147
+ break;
148
+ r.push(partReplacer(_polyfillHostNoCombinator, p, m[3]));
149
+ }
150
+ return r.join(',');
151
+ }
152
+ else {
153
+ return _polyfillHostNoCombinator + m[3];
154
+ }
155
+ });
156
+ };
157
+ const colonHostPartReplacer = (host, part, suffix) => {
158
+ return host + part.replace(_polyfillHost, '') + suffix;
159
+ };
160
+ const convertColonHost = (cssText) => {
161
+ return convertColonRule(cssText, _cssColonHostRe, colonHostPartReplacer);
162
+ };
163
+ const colonHostContextPartReplacer = (host, part, suffix) => {
164
+ if (part.indexOf(_polyfillHost) > -1) {
165
+ return colonHostPartReplacer(host, part, suffix);
166
+ }
167
+ else {
168
+ return host + part + suffix + ', ' + part + ' ' + host + suffix;
169
+ }
170
+ };
171
+ const convertColonSlotted = (cssText, slotScopeId) => {
172
+ const slotClass = '.' + slotScopeId + ' > ';
173
+ const selectors = [];
174
+ cssText = cssText.replace(_cssColonSlottedRe, (...m) => {
175
+ if (m[2]) {
176
+ const compound = m[2].trim();
177
+ const suffix = m[3];
178
+ const slottedSelector = slotClass + compound + suffix;
179
+ let prefixSelector = '';
180
+ for (let i = m[4] - 1; i >= 0; i--) {
181
+ const char = m[5][i];
182
+ if (char === '}' || char === ',') {
183
+ break;
184
+ }
185
+ prefixSelector = char + prefixSelector;
186
+ }
187
+ const orgSelector = prefixSelector + slottedSelector;
188
+ const addedSelector = `${prefixSelector.trimRight()}${slottedSelector.trim()}`;
189
+ if (orgSelector.trim() !== addedSelector.trim()) {
190
+ const updatedSelector = `${addedSelector}, ${orgSelector}`;
191
+ selectors.push({
192
+ orgSelector,
193
+ updatedSelector,
194
+ });
195
+ }
196
+ return slottedSelector;
197
+ }
198
+ else {
199
+ return _polyfillHostNoCombinator + m[3];
200
+ }
201
+ });
202
+ return {
203
+ selectors,
204
+ cssText,
205
+ };
206
+ };
207
+ const convertColonHostContext = (cssText) => {
208
+ return convertColonRule(cssText, _cssColonHostContextRe, colonHostContextPartReplacer);
209
+ };
210
+ const convertShadowDOMSelectors = (cssText) => {
211
+ return _shadowDOMSelectorsRe.reduce((result, pattern) => result.replace(pattern, ' '), cssText);
212
+ };
213
+ const makeScopeMatcher = (scopeSelector) => {
214
+ const lre = /\[/g;
215
+ const rre = /\]/g;
216
+ scopeSelector = scopeSelector.replace(lre, '\\[').replace(rre, '\\]');
217
+ return new RegExp('^(' + scopeSelector + ')' + _selectorReSuffix, 'm');
218
+ };
219
+ const selectorNeedsScoping = (selector, scopeSelector) => {
220
+ const re = makeScopeMatcher(scopeSelector);
221
+ return !re.test(selector);
222
+ };
223
+ const injectScopingSelector = (selector, scopingSelector) => {
224
+ return selector.replace(_selectorPartsRe, (_, before = '', _colonGroup, colon = '', after = '') => {
225
+ return before + scopingSelector + colon + after;
226
+ });
227
+ };
228
+ const applySimpleSelectorScope = (selector, scopeSelector, hostSelector) => {
229
+ // In Android browser, the lastIndex is not reset when the regex is used in String.replace()
230
+ _polyfillHostRe.lastIndex = 0;
231
+ if (_polyfillHostRe.test(selector)) {
232
+ const replaceBy = `.${hostSelector}`;
233
+ return selector
234
+ .replace(_polyfillHostNoCombinatorRe, (_, selector) => injectScopingSelector(selector, replaceBy))
235
+ .replace(_polyfillHostRe, replaceBy + ' ');
236
+ }
237
+ return scopeSelector + ' ' + selector;
238
+ };
239
+ const applyStrictSelectorScope = (selector, scopeSelector, hostSelector) => {
240
+ const isRe = /\[is=([^\]]*)\]/g;
241
+ scopeSelector = scopeSelector.replace(isRe, (_, ...parts) => parts[0]);
242
+ const className = '.' + scopeSelector;
243
+ const _scopeSelectorPart = (p) => {
244
+ let scopedP = p.trim();
245
+ if (!scopedP) {
246
+ return '';
247
+ }
248
+ if (p.indexOf(_polyfillHostNoCombinator) > -1) {
249
+ scopedP = applySimpleSelectorScope(p, scopeSelector, hostSelector);
250
+ }
251
+ else {
252
+ // remove :host since it should be unnecessary
253
+ const t = p.replace(_polyfillHostRe, '');
254
+ if (t.length > 0) {
255
+ scopedP = injectScopingSelector(t, className);
256
+ }
257
+ }
258
+ return scopedP;
259
+ };
260
+ const safeContent = safeSelector(selector);
261
+ selector = safeContent.content;
262
+ let scopedSelector = '';
263
+ let startIndex = 0;
264
+ let res;
265
+ const sep = /( |>|\+|~(?!=))\s*/g;
266
+ // If a selector appears before :host it should not be shimmed as it
267
+ // matches on ancestor elements and not on elements in the host's shadow
268
+ // `:host-context(div)` is transformed to
269
+ // `-shadowcsshost-no-combinatordiv, div -shadowcsshost-no-combinator`
270
+ // the `div` is not part of the component in the 2nd selectors and should not be scoped.
271
+ // Historically `component-tag:host` was matching the component so we also want to preserve
272
+ // this behavior to avoid breaking legacy apps (it should not match).
273
+ // The behavior should be:
274
+ // - `tag:host` -> `tag[h]` (this is to avoid breaking legacy apps, should not match anything)
275
+ // - `tag :host` -> `tag [h]` (`tag` is not scoped because it's considered part of a
276
+ // `:host-context(tag)`)
277
+ const hasHost = selector.indexOf(_polyfillHostNoCombinator) > -1;
278
+ // Only scope parts after the first `-shadowcsshost-no-combinator` when it is present
279
+ let shouldScope = !hasHost;
280
+ while ((res = sep.exec(selector)) !== null) {
281
+ const separator = res[1];
282
+ const part = selector.slice(startIndex, res.index).trim();
283
+ shouldScope = shouldScope || part.indexOf(_polyfillHostNoCombinator) > -1;
284
+ const scopedPart = shouldScope ? _scopeSelectorPart(part) : part;
285
+ scopedSelector += `${scopedPart} ${separator} `;
286
+ startIndex = sep.lastIndex;
287
+ }
288
+ const part = selector.substring(startIndex);
289
+ shouldScope = shouldScope || part.indexOf(_polyfillHostNoCombinator) > -1;
290
+ scopedSelector += shouldScope ? _scopeSelectorPart(part) : part;
291
+ // replace the placeholders with their original values
292
+ return restoreSafeSelector(safeContent.placeholders, scopedSelector);
293
+ };
294
+ const scopeSelector = (selector, scopeSelectorText, hostSelector, slotSelector) => {
295
+ return selector
296
+ .split(',')
297
+ .map((shallowPart) => {
298
+ if (slotSelector && shallowPart.indexOf('.' + slotSelector) > -1) {
299
+ return shallowPart.trim();
300
+ }
301
+ if (selectorNeedsScoping(shallowPart, scopeSelectorText)) {
302
+ return applyStrictSelectorScope(shallowPart, scopeSelectorText, hostSelector).trim();
303
+ }
304
+ else {
305
+ return shallowPart.trim();
306
+ }
307
+ })
308
+ .join(', ');
309
+ };
310
+ const scopeSelectors = (cssText, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector) => {
311
+ return processRules(cssText, (rule) => {
312
+ let selector = rule.selector;
313
+ let content = rule.content;
314
+ if (rule.selector[0] !== '@') {
315
+ selector = scopeSelector(rule.selector, scopeSelectorText, hostSelector, slotSelector);
316
+ }
317
+ else if (rule.selector.startsWith('@media') ||
318
+ rule.selector.startsWith('@supports') ||
319
+ rule.selector.startsWith('@page') ||
320
+ rule.selector.startsWith('@document')) {
321
+ content = scopeSelectors(rule.content, scopeSelectorText, hostSelector, slotSelector);
322
+ }
323
+ const cssRule = {
324
+ selector: selector.replace(/\s{2,}/g, ' ').trim(),
325
+ content,
326
+ };
327
+ return cssRule;
328
+ });
329
+ };
330
+ const scopeCssText = (cssText, scopeId, hostScopeId, slotScopeId, commentOriginalSelector) => {
331
+ cssText = insertPolyfillHostInCssText(cssText);
332
+ cssText = convertColonHost(cssText);
333
+ cssText = convertColonHostContext(cssText);
334
+ const slotted = convertColonSlotted(cssText, slotScopeId);
335
+ cssText = slotted.cssText;
336
+ cssText = convertShadowDOMSelectors(cssText);
337
+ if (scopeId) {
338
+ cssText = scopeSelectors(cssText, scopeId, hostScopeId, slotScopeId);
339
+ }
340
+ cssText = cssText.replace(/-shadowcsshost-no-combinator/g, `.${hostScopeId}`);
341
+ cssText = cssText.replace(/>\s*\*\s+([^{, ]+)/gm, ' $1 ');
342
+ return {
343
+ cssText: cssText.trim(),
344
+ slottedSelectors: slotted.selectors,
345
+ };
346
+ };
347
+ const scopeCss = (cssText, scopeId, commentOriginalSelector) => {
348
+ const hostScopeId = scopeId + '-h';
349
+ const slotScopeId = scopeId + '-s';
350
+ const commentsWithHash = extractCommentsWithHash(cssText);
351
+ cssText = stripComments(cssText);
352
+ const orgSelectors = [];
353
+ if (commentOriginalSelector) {
354
+ const processCommentedSelector = (rule) => {
355
+ const placeholder = `/*!@___${orgSelectors.length}___*/`;
356
+ const comment = `/*!@${rule.selector}*/`;
357
+ orgSelectors.push({ placeholder, comment });
358
+ rule.selector = placeholder + rule.selector;
359
+ return rule;
360
+ };
361
+ cssText = processRules(cssText, (rule) => {
362
+ if (rule.selector[0] !== '@') {
363
+ return processCommentedSelector(rule);
364
+ }
365
+ else if (rule.selector.startsWith('@media') ||
366
+ rule.selector.startsWith('@supports') ||
367
+ rule.selector.startsWith('@page') ||
368
+ rule.selector.startsWith('@document')) {
369
+ rule.content = processRules(rule.content, processCommentedSelector);
370
+ return rule;
371
+ }
372
+ return rule;
373
+ });
374
+ }
375
+ const scoped = scopeCssText(cssText, scopeId, hostScopeId, slotScopeId);
376
+ cssText = [scoped.cssText, ...commentsWithHash].join('\n');
377
+ if (commentOriginalSelector) {
378
+ orgSelectors.forEach(({ placeholder, comment }) => {
379
+ cssText = cssText.replace(placeholder, comment);
380
+ });
381
+ }
382
+ scoped.slottedSelectors.forEach((slottedSelector) => {
383
+ cssText = cssText.replace(slottedSelector.orgSelector, slottedSelector.updatedSelector);
384
+ });
385
+ return cssText;
386
+ };
387
+
388
+ export { scopeCss };
@@ -39,6 +39,7 @@ export default class AgGridController implements EzGridController, SortingProvid
39
39
  quickFilter(term: string): void;
40
40
  setSelectedIndex(index: number): void;
41
41
  private buildColDef;
42
+ private getStyleByColumn;
42
43
  private getFormatterByColumn;
43
44
  private onCallStateChange;
44
45
  private isUIEvent;