@sankhyalabs/sankhyablocks 10.1.0-dev.14 → 10.1.0-dev.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{SnkMultiSelectionListDataSource-3f561345.js → SnkMultiSelectionListDataSource-72925620.js} +1 -1
- package/dist/cjs/config-header.cjs.entry.js +1 -1
- package/dist/cjs/configs-button.cjs.entry.js +1 -1
- package/dist/cjs/field-config_2.cjs.entry.js +1 -1
- package/dist/cjs/fields-layout.cjs.entry.js +1 -1
- package/dist/cjs/fields-selector.cjs.entry.js +1 -1
- package/dist/cjs/guides-configurator.cjs.entry.js +1 -1
- package/dist/cjs/{index-13d05f03.js → index-516250fa.js} +1 -1
- package/dist/cjs/{index-1cf293c1.js → index-dc83c596.js} +0 -17
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/pesquisa-grid_2.cjs.entry.js +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button_9.cjs.entry.js +1 -1
- package/dist/cjs/snk-actions-form.cjs.entry.js +1 -1
- package/dist/cjs/snk-application.cjs.entry.js +1 -1
- package/dist/cjs/snk-attach.cjs.entry.js +3 -3
- package/dist/cjs/snk-client-confirm.cjs.entry.js +1 -1
- package/dist/cjs/snk-configurator.cjs.entry.js +1 -1
- package/dist/cjs/snk-crud.cjs.entry.js +3 -3
- package/dist/cjs/snk-custom-slot-elements.cjs.entry.js +1 -1
- package/dist/cjs/snk-custom-slot-guide.cjs.entry.js +1 -1
- package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
- package/dist/cjs/{snk-data-unit-b8ea81e1.js → snk-data-unit-47f02b9e.js} +1 -1
- package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
- package/dist/cjs/snk-default-filter.cjs.entry.js +1 -1
- package/dist/cjs/snk-detail-view.cjs.entry.js +4 -4
- package/dist/cjs/snk-entity-list.cjs.entry.js +1 -1
- package/dist/cjs/snk-exporter-email-sender.cjs.entry.js +1 -1
- package/dist/cjs/snk-expression-group_2.cjs.entry.js +2 -2
- package/dist/cjs/snk-filter-advanced-mode_2.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-bar_4.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-binary-select.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-checkbox-list.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-detail.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-field-search_2.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-modal-item.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-multi-select.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-number.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-period.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-search.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-text.cjs.entry.js +1 -1
- package/dist/cjs/snk-form-summary.cjs.entry.js +1 -1
- package/dist/cjs/snk-form-view.cjs.entry.js +1 -1
- package/dist/cjs/snk-form_2.cjs.entry.js +1 -1
- package/dist/cjs/snk-grid.cjs.entry.js +15 -9
- package/dist/cjs/{snk-guides-viewer-61701970.js → snk-guides-viewer-41c22d96.js} +2 -2
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +4 -4
- package/dist/cjs/snk-personalized-filter-editor.cjs.entry.js +1 -1
- package/dist/cjs/snk-personalized-filter.cjs.entry.js +2 -2
- package/dist/cjs/snk-pesquisa.cjs.entry.js +1 -1
- package/dist/cjs/snk-print-selector.cjs.entry.js +1 -1
- package/dist/cjs/snk-simple-bar.cjs.entry.js +1 -1
- package/dist/cjs/snk-simple-crud.cjs.entry.js +4 -4
- package/dist/cjs/snk-taskbar.cjs.entry.js +3 -3
- package/dist/cjs/{taskbar-elements-fb5d1e08.js → taskbar-elements-756fcbe7.js} +2 -2
- package/dist/cjs/teste-pesquisa.cjs.entry.js +1 -1
- package/dist/collection/components/snk-grid/snk-grid.js +12 -7
- package/dist/components/snk-grid2.js +12 -6
- package/dist/esm/{SnkMultiSelectionListDataSource-2d1ea0c5.js → SnkMultiSelectionListDataSource-493ae8c8.js} +1 -1
- package/dist/esm/config-header.entry.js +1 -1
- package/dist/esm/configs-button.entry.js +1 -1
- package/dist/esm/field-config_2.entry.js +1 -1
- package/dist/esm/fields-layout.entry.js +1 -1
- package/dist/esm/fields-selector.entry.js +1 -1
- package/dist/esm/guides-configurator.entry.js +1 -1
- package/dist/esm/{index-446f9341.js → index-3355bd17.js} +1 -1
- package/dist/esm/{index-479e1293.js → index-7fd74680.js} +0 -17
- package/dist/esm/loader.js +2 -2
- package/dist/esm/pesquisa-grid_2.entry.js +1 -1
- package/dist/esm/sankhyablocks.js +2 -2
- package/dist/esm/snk-actions-button_9.entry.js +1 -1
- package/dist/esm/snk-actions-form.entry.js +1 -1
- package/dist/esm/snk-application.entry.js +1 -1
- package/dist/esm/snk-attach.entry.js +3 -3
- package/dist/esm/snk-client-confirm.entry.js +1 -1
- package/dist/esm/snk-configurator.entry.js +1 -1
- package/dist/esm/snk-crud.entry.js +3 -3
- package/dist/esm/snk-custom-slot-elements.entry.js +1 -1
- package/dist/esm/snk-custom-slot-guide.entry.js +1 -1
- package/dist/esm/snk-data-exporter.entry.js +2 -2
- package/dist/esm/{snk-data-unit-6f31ec56.js → snk-data-unit-9e9d9d46.js} +1 -1
- package/dist/esm/snk-data-unit.entry.js +2 -2
- package/dist/esm/snk-default-filter.entry.js +1 -1
- package/dist/esm/snk-detail-view.entry.js +4 -4
- package/dist/esm/snk-entity-list.entry.js +1 -1
- package/dist/esm/snk-exporter-email-sender.entry.js +1 -1
- package/dist/esm/snk-expression-group_2.entry.js +2 -2
- package/dist/esm/snk-filter-advanced-mode_2.entry.js +1 -1
- package/dist/esm/snk-filter-bar_4.entry.js +1 -1
- package/dist/esm/snk-filter-binary-select.entry.js +1 -1
- package/dist/esm/snk-filter-checkbox-list.entry.js +1 -1
- package/dist/esm/snk-filter-detail.entry.js +1 -1
- package/dist/esm/snk-filter-field-search_2.entry.js +1 -1
- package/dist/esm/snk-filter-modal-item.entry.js +1 -1
- package/dist/esm/snk-filter-multi-select.entry.js +1 -1
- package/dist/esm/snk-filter-number.entry.js +1 -1
- package/dist/esm/snk-filter-period.entry.js +1 -1
- package/dist/esm/snk-filter-search.entry.js +1 -1
- package/dist/esm/snk-filter-text.entry.js +1 -1
- package/dist/esm/snk-form-summary.entry.js +1 -1
- package/dist/esm/snk-form-view.entry.js +1 -1
- package/dist/esm/snk-form_2.entry.js +1 -1
- package/dist/esm/snk-grid.entry.js +15 -9
- package/dist/esm/{snk-guides-viewer-c31259f0.js → snk-guides-viewer-31ef5fc6.js} +2 -2
- package/dist/esm/snk-guides-viewer.entry.js +4 -4
- package/dist/esm/snk-personalized-filter-editor.entry.js +1 -1
- package/dist/esm/snk-personalized-filter.entry.js +2 -2
- package/dist/esm/snk-pesquisa.entry.js +1 -1
- package/dist/esm/snk-print-selector.entry.js +1 -1
- package/dist/esm/snk-simple-bar.entry.js +1 -1
- package/dist/esm/snk-simple-crud.entry.js +4 -4
- package/dist/esm/snk-taskbar.entry.js +3 -3
- package/dist/esm/{taskbar-elements-faaf5d8f.js → taskbar-elements-bf5b73f1.js} +2 -2
- package/dist/esm/teste-pesquisa.entry.js +1 -1
- package/dist/sankhyablocks/{p-6b9833c7.entry.js → p-02cb4829.entry.js} +1 -1
- package/dist/sankhyablocks/{p-af3aface.entry.js → p-0893a694.entry.js} +1 -1
- package/dist/sankhyablocks/{p-fa8c2485.entry.js → p-0da30fd9.entry.js} +1 -1
- package/dist/sankhyablocks/{p-4b1c26ae.js → p-156c9f38.js} +1 -1
- package/dist/sankhyablocks/{p-f35f2eb3.entry.js → p-17856827.entry.js} +1 -1
- package/dist/sankhyablocks/{p-b987e15d.js → p-1be69fd4.js} +1 -1
- package/dist/sankhyablocks/{p-e679c75a.entry.js → p-1dba30c9.entry.js} +1 -1
- package/dist/sankhyablocks/{p-21107f0d.entry.js → p-1e469905.entry.js} +1 -1
- package/dist/sankhyablocks/{p-96d45943.entry.js → p-227e82b2.entry.js} +1 -1
- package/dist/sankhyablocks/{p-7af6e6b8.entry.js → p-2624dfd2.entry.js} +1 -1
- package/dist/sankhyablocks/{p-99a11017.entry.js → p-301baf9c.entry.js} +1 -1
- package/dist/sankhyablocks/{p-52c0cade.entry.js → p-357e10e0.entry.js} +1 -1
- package/dist/sankhyablocks/{p-987cd79d.entry.js → p-35a26068.entry.js} +1 -1
- package/dist/sankhyablocks/{p-180716b2.entry.js → p-3671cdd4.entry.js} +1 -1
- package/dist/sankhyablocks/{p-27482793.entry.js → p-4575c4aa.entry.js} +1 -1
- package/dist/sankhyablocks/{p-3d41f5a8.entry.js → p-497ece60.entry.js} +1 -1
- package/dist/sankhyablocks/{p-5fd4f0f6.entry.js → p-4deb7f46.entry.js} +1 -1
- package/dist/sankhyablocks/{p-bdd4f02c.entry.js → p-4e9e570c.entry.js} +1 -1
- package/dist/sankhyablocks/{p-3b167a03.entry.js → p-516411de.entry.js} +1 -1
- package/dist/sankhyablocks/{p-162bddae.entry.js → p-522d36aa.entry.js} +1 -1
- package/dist/sankhyablocks/{p-825098c1.entry.js → p-56b1b397.entry.js} +1 -1
- package/dist/sankhyablocks/{p-3f68a254.js → p-59158ba4.js} +1 -1
- package/dist/sankhyablocks/{p-c98c79c3.entry.js → p-5c9bea92.entry.js} +1 -1
- package/dist/sankhyablocks/{p-91a9abb6.entry.js → p-613eb22e.entry.js} +1 -1
- package/dist/sankhyablocks/{p-49ddc27a.entry.js → p-670b8802.entry.js} +1 -1
- package/dist/sankhyablocks/{p-60dd1d27.entry.js → p-67137d7c.entry.js} +1 -1
- package/dist/sankhyablocks/{p-a5e0a780.entry.js → p-7375bf6a.entry.js} +1 -1
- package/dist/sankhyablocks/{p-b7e891cc.entry.js → p-7961c550.entry.js} +1 -1
- package/dist/sankhyablocks/{p-75af335e.entry.js → p-82b59a45.entry.js} +1 -1
- package/dist/sankhyablocks/p-82bb3eda.js +2 -0
- package/dist/sankhyablocks/{p-55798617.js → p-8336900b.js} +1 -1
- package/dist/sankhyablocks/{p-74389ec4.entry.js → p-8488fa7e.entry.js} +1 -1
- package/dist/sankhyablocks/{p-cb4343c4.entry.js → p-8783d550.entry.js} +1 -1
- package/dist/sankhyablocks/{p-471b34f4.entry.js → p-8d76a0ca.entry.js} +1 -1
- package/dist/sankhyablocks/{p-9a63f3f7.entry.js → p-8d84d6ab.entry.js} +1 -1
- package/dist/sankhyablocks/{p-8027f732.js → p-907e96eb.js} +1 -1
- package/dist/sankhyablocks/{p-e258de96.entry.js → p-939523b3.entry.js} +1 -1
- package/dist/sankhyablocks/{p-a9b16874.entry.js → p-959fe522.entry.js} +1 -1
- package/dist/sankhyablocks/{p-7e250432.entry.js → p-98c70173.entry.js} +1 -1
- package/dist/sankhyablocks/{p-2d133b6e.entry.js → p-98e3d0a1.entry.js} +1 -1
- package/dist/sankhyablocks/{p-2fdac5e6.entry.js → p-abfc9880.entry.js} +1 -1
- package/dist/sankhyablocks/{p-728959a6.entry.js → p-b5832fa0.entry.js} +1 -1
- package/dist/sankhyablocks/{p-04bbdf6f.entry.js → p-c2bb0659.entry.js} +1 -1
- package/dist/sankhyablocks/{p-7f7fe6c4.entry.js → p-c60d864f.entry.js} +1 -1
- package/dist/sankhyablocks/{p-8ce94b62.entry.js → p-cb7c592f.entry.js} +1 -1
- package/dist/sankhyablocks/{p-f3027bc9.entry.js → p-cc68a0c1.entry.js} +1 -1
- package/dist/sankhyablocks/{p-c3dbf441.entry.js → p-ce207f2a.entry.js} +1 -1
- package/dist/sankhyablocks/{p-c4fcf1fb.entry.js → p-cfa4c183.entry.js} +1 -1
- package/dist/sankhyablocks/{p-20349480.entry.js → p-d5d7fe52.entry.js} +1 -1
- package/dist/sankhyablocks/{p-b47acee0.entry.js → p-dd89bc02.entry.js} +1 -1
- package/dist/sankhyablocks/{p-667cab42.entry.js → p-def17f0e.entry.js} +1 -1
- package/dist/sankhyablocks/p-e41c86b2.entry.js +1 -0
- package/dist/sankhyablocks/{p-4c2e2767.entry.js → p-e47d6f17.entry.js} +1 -1
- package/dist/sankhyablocks/{p-7345782c.entry.js → p-fd1a5a61.entry.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-grid/snk-grid.d.ts +1 -0
- package/package.json +1 -1
- package/dist/sankhyablocks/p-0814b16c.entry.js +0 -1
- package/dist/sankhyablocks/p-d8d8169b.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,c as s,h as i,H as e,F as a}from"./p-
|
|
1
|
+
import{r as t,c as s,h as i,H as e,F as a}from"./p-82bb3eda.js";import{I as o}from"./p-9e4555ab.js";import"./p-6768f176.js";import{P as r}from"./p-48a5c311.js";import"@sankhyalabs/core";import"./p-0f3698af.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-ff1990ad.js";import"./p-7ee6b1bf.js";import"./p-9019a32f.js";import{ApplicationUtils as n}from"@sankhyalabs/ezui/dist/collection/utils";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";import"./p-8d884fab.js";const h=class{constructor(i){t(this,i),this.pesquisaGridSelectItem=s(this,"pesquisaGridSelectItem",7),this._pesquisaFetcher=new r,this.metadata=void 0,this.dataSource=[],this.pkField=void 0,this.descriptionField=void 0,this.entityName=void 0,this.shouldLoadConfig=!1,this._gridConfig=void 0,this._inMemoryLoader=void 0,this._dataunit=void 0}observeDataSource(t){this._inMemoryLoader&&this._dataunit&&t&&(this._inMemoryLoader.records=[...t])}observeMetadata(){this.initializeDataUnit()}async observeShouldLoadConfig(t){t&&!this._gridConfig&&await this.loadGridConfig()}async loadGridConfig(){this._gridConfig=await this._pesquisaFetcher.loadPesquisaGridConfig(this.entityName)}initializeDataUnit(){var t;this.metadata&&!this._dataunit&&(this._inMemoryLoader=new o(this.metadata,null!==(t=this.dataSource)&&void 0!==t?t:[]),this._dataunit=this._inMemoryLoader.dataUnit,this._dataunit.pageSize=0)}handleDbClick(t){this.pesquisaGridSelectItem.emit({value:t[this.pkField],label:t[this.descriptionField]})}async handleConfigChanged({detail:t}){var s;const i=null!==(s=null==t?void 0:t.columns)&&void 0!==s?s:[];await this._pesquisaFetcher.savePesquisaGridConfig(this.entityName,i)}render(){if(this.metadata&&this._dataunit)return i(e,null,i("ez-grid",{dataUnit:this._dataunit,config:this._gridConfig,mode:"simple",autoFocus:!1,onEzDoubleClick:({detail:t})=>this.handleDbClick(t),onConfigChange:async t=>this.handleConfigChanged(t)}))}static get watchers(){return{dataSource:["observeDataSource"],metadata:["observeMetadata"],shouldLoadConfig:["observeShouldLoadConfig"]}}};h.style=".sc-pesquisa-grid-h{background:var(--background--xlight, #FFF);overflow-x:auto}ez-grid.sc-pesquisa-grid{--ez-grid__container--shadow:none;--ez-grid__header--shadow:none}";const l=class{constructor(i){t(this,i),this.pesquisaTreeSelectItem=s(this,"pesquisaTreeSelectItem",7),this.treeLoader=void 0,this.argument=void 0,this.allowsNonAnalytic=!1,this.shouldLoadTree=!1,this.messagesBuilder=void 0,this.items=[]}async applyFilter(){await this._tree.applyFilter(this.argument)}async observeShouldLoadTree(t){!t||this.items.length>0||await this.loadTree()}async loadTree(){if(!this.shouldLoadTree)return;if(!this.treeLoader||"function"!=typeof this.treeLoader)return;const t=await this.treeLoader((this.argument||"").trim());this.items=[...t]}expandOrCloseAllItems(t,s){return t.map((t=>Object.assign(Object.assign({},t),{expanded:s,children:t.children?this.expandOrCloseAllItems(t.children,s):void 0})))}handleExpandAll(){this.items=[...this.expandOrCloseAllItems(this.items,!0)]}handleCloseAll(){this.items=[...this.expandOrCloseAllItems(this.items,!1)]}handleDbClick(t){var s;if(this.allowsNonAnalytic||(null===(s=t.props)||void 0===s?void 0:s.analitico))this.pesquisaTreeSelectItem.emit({value:t.id,label:t.label});else{const t=this.getMessage("snkPesquisa.tree.errorTitle"),s=this.getMessage("snkPesquisa.tree.nonAnalyticError");n.error(t,s)}}renderEmptyMessage(){return i("div",{class:"ez-flex ez-flex--justify-center ez-flex--align-items-center ez-margin--large ez-text ez-text--xlarge ez-text--secondary"},i("span",null,this.getMessage("snkPesquisa.tree.emptyMessage")))}getMessage(t,s){return this.messagesBuilder.getMessage(t,s)}render(){var t;return i(e,null,(null===(t=this.items)||void 0===t?void 0:t.length)?i(a,null,i("div",{class:"actions-container"},i("ez-button",{size:"small",mode:"icon",class:"ez-margin-right--small",iconName:"show-list",title:this.getMessage("snkPesquisa.tree.expandButton"),onClick:()=>this.handleExpandAll()}),i("ez-button",{size:"small",mode:"icon",iconName:"hide-list",title:this.getMessage("snkPesquisa.tree.collapseButton"),onClick:()=>this.handleCloseAll()})),i("ez-tree",{ref:t=>this._tree=t,onEzDbClickItem:({detail:t})=>this.handleDbClick(t),items:this.items})):this.renderEmptyMessage())}static get watchers(){return{shouldLoadTree:["observeShouldLoadTree"]}}};l.style=".sc-pesquisa-tree-h{--snk-pesquisa--tree__action-container--top:var(--space--sm);--snk-pesquisa--tree__action-container--right:var(--space--small);--snk-pesquisa--tree__min-height:var(--space--extra-large);background:var(--background--xlight, #FFF);position:relative;min-height:var(--snk-pesquisa--tree__min-height);height:100%;display:block;overflow-y:auto}.sc-pesquisa-tree-h:hover .actions-container.sc-pesquisa-tree{display:flex}.actions-container.sc-pesquisa-tree{flex-direction:row;position:absolute;top:var(--snk-pesquisa--tree__action-container--top);right:var(--snk-pesquisa--tree__action-container--right);display:none}";export{h as pesquisa_grid,l as pesquisa_tree}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,c as i,h as s,g as e}from"./p-
|
|
1
|
+
import{r as t,c as i,h as s,g as e}from"./p-82bb3eda.js";import{ElementIDUtils as l}from"@sankhyalabs/core";import{F as o}from"./p-ff1990ad.js";const h=class{constructor(s){t(this,s),this.valueChanged=i(this,"valueChanged",7),this.config=void 0,this.errorMessage=void 0,this.optionsList=[]}async setFocus(){var t,i;null===(i=null===(t=this._element)||void 0===t?void 0:t.querySelector("ez-check"))||void 0===i||i.setFocus()}async clearValue(){var t;this.config=Object.assign(Object.assign({},this.config),{value:this.config.value}),this.valueChanged.emit(null===(t=this.config)||void 0===t?void 0:t.value)}componentDidLoad(){this._element&&l.addIDInfo(this._element,"filterContentEditor")}handleToggleCheck(t,i){var s,e;this.errorMessage=void 0;let l=null!==(s=this.config.value)&&void 0!==s?s:{};l[t.name]=i,this.config=Object.assign(Object.assign({},this.config),{value:l}),this.valueChanged.emit(null===(e=this.config)||void 0===e?void 0:e.value)}renderOptions(){return this.optionsList.map((t=>s("ez-check",{label:t.label,onEzChange:i=>this.handleToggleCheck(t,i.detail),value:!!this.isChecked(t.name),enabled:this.config.enabled})))}isChecked(t){var i;return null===(i=this.config.value)||void 0===i?void 0:i[t]}buidOptions(){var t,i,s;const e=null!==(s=null===(i=null===(t=this.config)||void 0===t?void 0:t.props)||void 0===i?void 0:i.options)&&void 0!==s?s:[];this.optionsList=[...e]}componentWillRender(){this.buidOptions()}render(){if(this.config&&this.config.type===o.CHECK_BOX_LIST)return s("ez-tooltip",{active:!1===this.config.enabled,message:this.config.disabledMessage,type:"warning"},s("div",{class:"ez-flex ez-flex--column"},this.renderOptions(),this.errorMessage&&s("span",{class:"ez-text ez-text--small ez-text--error ez-margin--small"},this.errorMessage)))}get _element(){return e(this)}};export{h as snk_filter_checkbox_list}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as t,c as e,h as i,H as s,g as n}from"./p-
|
|
1
|
+
import{r as t,c as e,h as i,H as s,g as n}from"./p-82bb3eda.js";import{DateUtils as r,StringUtils as a,ObjectUtils as o,WaitingChangeException as h,SilentException as l,WarningException as c,ErrorException as d,ElementIDUtils as u,SearchUtils as p,ArrayUtils as m,KeyboardManager as g,OnboardingUtils as w,DependencyType as y,DataType as v,ApplicationContext as f,ErrorTracking as P,UserAgentUtils as k,LockManager as z,LockManagerOperation as _}from"@sankhyalabs/core";import{ApplicationUtils as x}from"@sankhyalabs/ezui/dist/collection/utils";import{C as A}from"./p-1f310bc6.js";import{d as S,D as b,U as I,S as T}from"./p-6768f176.js";import{A as O,a as L}from"./p-52691b42.js";import{P as N,D as C}from"./p-9e4555ab.js";import{P as E}from"./p-48a5c311.js";import{T as D}from"./p-9019a32f.js";import"./p-0f3698af.js";import"./p-ff1990ad.js";import{F as R}from"./p-7ee6b1bf.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";class F{static webConnectionCaller(t,e,i){var s;null===(s=window.AppletCaller)||void 0===s||s.webConnectionCaller(t,e,i)}}const M=U;function U(t,e){const i=j();return(U=function(t){return i[t-=378]})(t,e)}function j(){const t=["true","863GKWjmo","parse","56355fjjjAm","isSup","putAccess","4324480sjuCdS","hasOwnProperty","239748okvJLB","name","6055770tXeRaU","actions","forEach","7RPRvzn","1042CHxkUw","2988126NIwRMm","20MTNzmH","authorizationSf","item","string","hasAccess","isArray","Objeto não pode ser indefinido.","3071943fWslZp","parseFromJSON"];return(j=function(){return t})()}!function(){const t=U,e=j();for(;;)try{if(281287==parseInt(t(399))/1*(-parseInt(t(387))/2)+-parseInt(t(401))/3+parseInt(t(381))/4*(-parseInt(t(389))/5)+parseInt(t(388))/6*(-parseInt(t(386))/7)+parseInt(t(379))/8+parseInt(t(396))/9+parseInt(t(383))/10)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class ${[M(397)](t){const e=M;if(typeof(t=utxt(t[e(390)]))==e(392)&&(t=JSON[e(400)](t)),null==t)throw Error(e(395));const i=new H("S"===t[e(402)]||!0===t[e(402)]);return Array[e(394)](t[e(391)])&&t[e(391)][e(385)]((t=>i.putAccess(t[e(382)],String(t.status)==e(398)))),i}}class H{constructor(t){const e=M;this.isSup=t,this[e(384)]={}}[M(378)](t,e){this[M(384)][t]=e}[M(393)](t){const e=M;if(this[e(402)])return!0;let i=!0;return this[e(384)][e(380)](t)&&(i=this.actions[t]),i}isUserSup(){return this.isSup}}class B{constructor(){this._embeddedParams=new Map,this._cachedParams=new Map,this.templateByQuery=new Map;try{if(null!=window.MGE_PARAMS){atob(window.MGE_PARAMS).split("__;__").forEach((t=>{const[e,i]=t.split("__=__");this._embeddedParams.set(e,i)}))}}catch(t){console.error("Problemas ao obter parâmetros embarcados"),console.error(t)}this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchParam",S.gql`query($name: String!) {
|
|
2
2
|
$queryAlias$: fetchResource(name: $name){
|
|
3
3
|
name
|
|
4
4
|
resource
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,c as i,f as t,h as s,H as o,g as n}from"./p-d8d8169b.js";import{StringUtils as a,ObjectUtils as r}from"@sankhyalabs/core";import{ApplicationUtils as l}from"@sankhyalabs/ezui/dist/collection/utils";import{S as d}from"./p-51833248.js";import{a as h,G as u}from"./p-9019a32f.js";import{S as c,f as g,I as p}from"./p-8b4d6719.js";const m=class{constructor(t){e(this,t),this.isEditingGuideName=i(this,"isEditingGuideName",7),this.isEditingGroupName=i(this,"isEditingGroupName",7),this.layoutChanged=i(this,"layoutChanged",7),this.setFieldListAsAvailable=i(this,"setFieldListAsAvailable",7),this.guideRenamed=i(this,"guideRenamed",7),this.ID_GROUPS="container-groups",this.ID_FIELDS="container-fields",this.reservedGuideNames=[h.main.toLowerCase(),h.general.toLocaleLowerCase()],this.groupsListMemory=[],this.groupsRefList=[],this.isEditGuideNameActive=!1,this.selectedGuide=void 0,this.groupsList=[],this.guideNames=[],this.dataUnit=void 0,this.messagesBuilder=void 0}onMessagesBuilderChange(){this.setCustomCSSProperties()}handleFieldConfigChanged({detail:e}){const i=this.groupsListMemory.find((i=>i.name===e.group));if(!i)return;const t=i.fields.map((i=>i.name===e.name?e:i)),s=this.groupsListMemory.map((e=>e.name===i.name?{name:e.name,fields:t}:e));this.applyGroupUpdate(s)}observeSelectedGuide(){this.isEditGuideNameActive=!1,t(this),this.isEditingGroupName.emit(!1)}observeGroupList(e){this.groupsListMemory=[...e]}observeIsEditGuideNameActive(e){this.isEditingGuideName.emit(e)}async addFieldToLayout(e){e.group=u.noGroup,e.tab=this.selectedGuide.name;const i=this.getFixedFieldsGroup(),t={name:u.noGroup,fields:i?[...i.fields,e]:[e]},s=i?[t,...this.groupsListMemory.slice(1)]:[t,...this.groupsListMemory];this.applyGroupUpdate(s)}getFixedFieldsGroup(){return this.groupsListMemory.find((e=>e.name===u.noGroup))}getMessage(e,i){return this.messagesBuilder.getMessage(e,i)}handleAddGroup(){const e={name:this.buildNewGroupName(),fields:[]},i=[...this.groupsListMemory,e];this.applyGroupUpdate(i)}buildNewGroupName(){var e,i;const t=this.getMessage("snkFormConfig.form.newGroup"),s=null!==(i=null===(e=this.groupsListMemory.filter((e=>e.name.includes(t))))||void 0===e?void 0:e.length)&&void 0!==i?i:0;return 0===s?t:`${t} (${s})`}makeDynamicFieldsContainersDraggable(){this.groupsList.filter((e=>e.name!==u.noGroup)).forEach((e=>{this.makeFieldContainerDraggable(this.getFieldsContainerId(e.name))}))}getFieldsContainerId(e){return`${this.ID_FIELDS}-${a.replaceBlankCharacters(e)}`}handleSortGroups(e){var i;const t=null===(i=e.to)||void 0===i?void 0:i.children;if(!t)return;const s=Array.from(t).map((e=>e.getAttribute("data-group-name"))),o=[],n=this.getFixedFieldsGroup();n&&o.push(n),s.forEach((e=>{const i=this.groupsListMemory.find((i=>i.name===e));i&&o.push(i)})),this.applyGroupUpdate(o)}handleFieldsChanged(e){let i=[...this.groupsListMemory];i=[...this.handleFieldsOnGroupUpdate(i,e,c.FROM)],i=[...this.handleFieldsOnGroupUpdate(i,e,c.TO)],this.applyGroupUpdate(i)}applyGroupUpdate(e){var i;return null===(i=this.groupsRefList)||void 0===i||i.forEach((e=>null==e?void 0:e.cancelEdition())),!r.equals(e,this.groupsListMemory)&&(this.groupsListMemory=[...e],this.layoutChanged.emit(this.groupsListMemory),!0)}handleFieldsOnGroupUpdate(e,i,t){const s=i[t];return s.id===p?e:this.updateGroupList(e,s,t,i)}updateGroupList(e,i,t,s){const o=i.getAttribute("data-group-name"),n={name:o,fields:g(s,t,o,this.selectedGuide.name)};return this.replaceGroup(e,n)}replaceGroup(e,i){return e.map((e=>e.name===i.name?i:e))}makeGroupsDraggable(){try{const e=this.getContainerElement(this.ID_GROUPS);if(!e)return;new d(e,{group:"groups",ghostClass:"ghost",direction:"horizontal",animation:15,onSort:e=>this.handleSortGroups(e)})}catch(e){console.error(this.getMessage("snkFormConfig.errors.failMakeGroupsDraggable"),this.ID_GROUPS)}}makeFieldContainerDraggable(e){try{const i=this.getContainerElement(e);if(!i)return;new d(i,{group:"fields",ghostClass:"ghost",direction:"vertical",animation:15,onAdd:e=>this.handleFieldsChanged(e),onRemove:e=>this.handleFieldsChanged(e),onSort:e=>this.handleFieldsChanged(e)})}catch(i){console.error(this.getMessage("snkFormConfig.errors.failMakeFieldContainerDraggable"),e)}}getContainerElement(e){return this.el.querySelector(`[id="${e}"]`)}handleSetFieldAsAvailable(e){var i;const t=null!==(i=e.group)&&void 0!==i?i:u.noGroup,s=this.groupsListMemory.find((e=>e.name===t)).fields.filter((i=>i.name!==e.name)),o=[...this.replaceGroup(this.groupsListMemory,{name:t,fields:s})];this.applyGroupUpdate(o)}removeGroup(e){var i,t;const s=null!==(t=null===(i=this.groupsListMemory.find((i=>i.name===e.name)))||void 0===i?void 0:i.fields)&&void 0!==t?t:[],o=[...this.groupsListMemory.filter((i=>i.name!==e.name))];this.applyGroupUpdate(o)&&this.setFieldListAsAvailable.emit(s)}handleRenameGroup(e){const{value:i,newValue:t}=e.detail,s=this.groupsListMemory.map((e=>{if(e.name!==i)return Object.assign({},e);const s=e.fields.map((e=>Object.assign(Object.assign({},e),{group:t})));return{name:t,fields:s}}));this.applyGroupUpdate(s)}canSaveGroup(e,i){if(!this.groupsList.some((i=>{var t;return(null!==(t=i.name)&&void 0!==t?t:"").toLocaleLowerCase()===(null!=e?e:"").toLocaleLowerCase()})))return!0;const t=this.getMessage("snkFormConfig.confirm.title"),s=this.buildDuplicatedGroupNameContent(e);return l.alert(t,s).then((()=>{var e;return null===(e=this.groupsRefList[i])||void 0===e?void 0:e.applyFocusTextEdit()})),!1}buildDuplicatedGroupNameContent(e){const i=this.selectedGuide.name;return`\n ${this.getMessage("snkFormConfig.alert.titleGroupExists")}\n <b>${e}</b>\n ${this.getMessage("snkFormConfig.alert.inTab")}\n <b>${i===h.main?this.getMessage("snkFormConfig.form.mainArea"):i}</b>.\n <br/><br/>\n ${this.getMessage("snkFormConfig.alert.infoValidTitle")}\n `}buildDuplicatedTabNameContent(e){return`\n ${this.getMessage("snkFormConfig.alert.titleGuideExists")}\n <b>${e}</b>.\n <br/><br/>\n ${this.getMessage("snkFormConfig.alert.infoValidTitle")}\n `}buildReservedTabNameContent(e){return`\n ${this.getMessage("snkFormConfig.alert.titleGuideReservedName")}\n <br/><br/>\n <b>${e}</b>.\n <br/><br/>\n ${this.getMessage("snkFormConfig.alert.infoValidTitle")}\n `}renderFields(e){if(0!==e.length)return e.map((e=>s("field-item",{key:e.name,fieldConfig:e,onLayoutConfig:!0,dataUnit:this.dataUnit,messagesBuilder:this.messagesBuilder,onSetFieldAsAvailable:e=>this.handleSetFieldAsAvailable(e.detail)})))}renderDraggableGroups(){return this.groupsList.filter((e=>e.name!==u.noGroup)).map(((e,i)=>{var t;return s("div",{key:e.name,class:"group-config","data-group-name":e.name},s("ez-collapsible-box",{ref:e=>this.groupsRefList[i]=e,label:e.name,headerSize:"large",editable:!0,removable:!0,"icon-placement":"left",onEzRemove:()=>this.removeGroup(e),onEzSaveEditLabel:e=>this.handleRenameGroup(e),onEzEditLabelMode:({detail:e})=>this.isEditingGroupName.emit(e),conditionalSave:e=>this.canSaveGroup(e,i)},s("div",{id:this.getFieldsContainerId(e.name),class:"group-content "+((null===(t=e.fields)||void 0===t?void 0:t.length)?"":"empty-content"),"data-group-name":e.name},this.renderFields(e.fields))))}))}renderFixedFields(){var e,i;const t=null!==(i=null===(e=this.groupsList.find((e=>e.name===u.noGroup)))||void 0===e?void 0:e.fields)&&void 0!==i?i:[];return this.renderFields(t)}handleRenameGuide(e){const{value:i,newValue:t}=e.detail;if(this.isEditGuideNameActive=!1,t===i)return;const s=this.guideNames.includes(t.toLowerCase()),o=this.reservedGuideNames.includes(t.toLowerCase());if(o||s){const e=this.getMessage("snkFormConfig.confirm.title"),i=o?this.buildReservedTabNameContent(t):this.buildDuplicatedTabNameContent(t);l.alert(e,i).then((()=>this._refTextEdit.applyFocusSelect()))}else this.guideRenamed.emit(t)}cancelEditGuideName(){this.isEditGuideNameActive=!1}async startGuideNameEdition(){this.isEditGuideNameActive=!0,setTimeout((async()=>{await this._refTextEdit.applyFocusSelect()}),200)}getTextEditStyle(){return{fontSize:"20px",fontWeight:"500",fontFamily:"Roboto"}}renderGuideName(){var e,i;return this.isEditGuideNameActive?s("div",{class:"guide-header"},s("ez-text-edit",{class:"collapsible-box__text-edit",ref:e=>this._refTextEdit=e,value:null===(e=this.selectedGuide)||void 0===e?void 0:e.label,styled:this.getTextEditStyle(),onSaveEdition:e=>this.handleRenameGuide(e),onCancelEdition:()=>this.cancelEditGuideName()})):s("div",{class:"guide-header"},s("span",{class:"guide-header-label"},null===(i=this.selectedGuide)||void 0===i?void 0:i.label),this.renderEditGuideNameButton())}renderEditGuideNameButton(){var e;if((null===(e=this.selectedGuide)||void 0===e?void 0:e.name)!==h.main)return s("ez-button",{mode:"icon",class:"ez-button--tertiary",onClick:()=>this.startGuideNameEdition(),size:"medium",iconName:"edit",title:this.getMessage("snkFormConfig.buttons.rename")})}setCustomCSSProperties(){document.documentElement.style.setProperty("--empty-content-message",`"${this.getMessage("snkFormConfig.form.labelDropField")}"`),document.documentElement.style.setProperty("--no-group-message",`"${this.getMessage("snkFormConfig.form.subTitleInfo")}"`)}componentDidRender(){this.makeGroupsDraggable(),this.makeDynamicFieldsContainersDraggable(),this.makeFieldContainerDraggable(u.noGroup),this.setCustomCSSProperties()}render(){return this.selectedGuide?this.selectedGuide.isCustom||this.selectedGuide.isDetail?s(o,{class:"ez-flex-item--auto ez-size-height--full ez-box ez-padding--medium content-container"},s("div",{class:"message-container"},s("h1",{class:"no-guide-selected"},this.getMessage("snkFormConfig.form.canNotEditCustomGuide")),s("span",{class:"message-config-detail"},this.getMessage("snkFormConfig.form.canNotEditDetailGuide")))):s(o,{class:"ez-flex-item--auto ez-size-height--full ez-box ez-padding--medium content-container"},this.renderGuideName(),s("div",{class:"layout-container"},s("ez-scroller",{direction:"vertical",activeShadow:!0},s("div",{class:"no-group-container"},s("div",{id:u.noGroup,class:"group-content","data-group-name":u.noGroup},this.renderFixedFields())),s("hr",null),s("div",{id:this.ID_GROUPS,class:"groups-container"},this.renderDraggableGroups()))),s("div",{class:"add-group-container",onClick:this.handleAddGroup.bind(this)},s("ez-icon",{slot:"leftIcon",iconName:"plus"}),s("span",null,this.getMessage("snkFormConfig.form.createNewGroup")))):s(o,{class:"ez-flex-item--auto ez-size-height--full ez-box ez-padding--medium content-container"},s("span",{class:"no-guide-selected"},this.getMessage("snkFormConfig.form.noGuideSelected")))}get el(){return n(this)}static get watchers(){return{messagesBuilder:["onMessagesBuilderChange"],selectedGuide:["observeSelectedGuide"],groupsList:["observeGroupList"],isEditGuideNameActive:["observeIsEditGuideNameActive"]}}};m.style='.sc-fields-layout-h{display:flex;padding:12px;box-shadow:var(--shadow--small, 0 0 16px rgba(0, 38, 111, 0.07));border-radius:var(--border--radius-medium, 6px);height:var(--snk-form-config-container-height);flex-direction:column}.layout-container.sc-fields-layout{container-type:inline-size;display:flex;flex-direction:column;overflow:auto;height:calc(100vh - 225px)}.guide-header.sc-fields-layout{display:flex;width:100%;font-size:20px;border-bottom:1px solid #dce0e8;margin-bottom:6px;align-items:center;height:45px}.guide-header.sc-fields-layout ez-button.sc-fields-layout{transition:all 0.2s ease-in-out;visibility:hidden;opacity:0}.guide-header.sc-fields-layout:hover ez-button.sc-fields-layout{visibility:visible;opacity:1}.guide-header-label.sc-fields-layout{display:block;padding:10px 0}.group-config.sc-fields-layout{padding:12px 0;display:flex;flex-direction:column;width:100%}.group-content.sc-fields-layout{display:grid;gap:12px;min-height:65px;width:100%;padding:6px 0;grid-template-columns:repeat(auto-fill, minmax(250px, 1fr))}.group-content.empty-content.sc-fields-layout{position:relative}.group-content.empty-content.sc-fields-layout::before{content:var(--empty-content-message, "Arraste e solte um campo aqui");color:#cbcfd7;font-size:16px;font-weight:500;text-align:center;position:absolute;inset:0;display:flex;align-items:center;justify-content:center;pointer-events:none;transition:opacity 0.3s;height:100%;box-sizing:border-box;padding:10px;background:#f9f9f9;border:1px dashed #dce0e8;border-radius:6px}.no-group-container.sc-fields-layout{padding:12px 0;width:100%;border-bottom:1px solid #dce0e8}.no-group-container.sc-fields-layout::before{content:var(--no-group-message, "Inclua estes campos nos grupos ou deixe-os separados no topo do formulário");width:100%;display:block;font-size:16px;font-weight:400;color:#AFB6C0;padding-bottom:12px}.add-group-container.sc-fields-layout{display:flex;align-items:center;border-top:1px solid #dce0e8;padding-top:22px;padding-bottom:12px;gap:6px;cursor:pointer;justify-content:center;width:100%;height:55px}.no-guide-selected.sc-fields-layout{display:block;margin:auto;font-size:24px;color:#AFB6C0;font-weight:500}.message-container.sc-fields-layout{margin:auto;display:flex;flex-direction:column;justify-content:center;align-items:center}.message-config-detail.sc-fields-layout{display:block;margin:auto;font-size:var(--font-size--medium, 16px);color:#AFB6C0;font-weight:var(--font-weight--medium, 500)}.ghost.sc-fields-layout{opacity:.5;background:#c8fbe2}';export{m as fields_layout}
|
|
1
|
+
import{r as e,c as i,f as t,h as s,H as o,g as n}from"./p-82bb3eda.js";import{StringUtils as a,ObjectUtils as r}from"@sankhyalabs/core";import{ApplicationUtils as l}from"@sankhyalabs/ezui/dist/collection/utils";import{S as d}from"./p-51833248.js";import{a as h,G as u}from"./p-9019a32f.js";import{S as c,f as g,I as p}from"./p-8b4d6719.js";const m=class{constructor(t){e(this,t),this.isEditingGuideName=i(this,"isEditingGuideName",7),this.isEditingGroupName=i(this,"isEditingGroupName",7),this.layoutChanged=i(this,"layoutChanged",7),this.setFieldListAsAvailable=i(this,"setFieldListAsAvailable",7),this.guideRenamed=i(this,"guideRenamed",7),this.ID_GROUPS="container-groups",this.ID_FIELDS="container-fields",this.reservedGuideNames=[h.main.toLowerCase(),h.general.toLocaleLowerCase()],this.groupsListMemory=[],this.groupsRefList=[],this.isEditGuideNameActive=!1,this.selectedGuide=void 0,this.groupsList=[],this.guideNames=[],this.dataUnit=void 0,this.messagesBuilder=void 0}onMessagesBuilderChange(){this.setCustomCSSProperties()}handleFieldConfigChanged({detail:e}){const i=this.groupsListMemory.find((i=>i.name===e.group));if(!i)return;const t=i.fields.map((i=>i.name===e.name?e:i)),s=this.groupsListMemory.map((e=>e.name===i.name?{name:e.name,fields:t}:e));this.applyGroupUpdate(s)}observeSelectedGuide(){this.isEditGuideNameActive=!1,t(this),this.isEditingGroupName.emit(!1)}observeGroupList(e){this.groupsListMemory=[...e]}observeIsEditGuideNameActive(e){this.isEditingGuideName.emit(e)}async addFieldToLayout(e){e.group=u.noGroup,e.tab=this.selectedGuide.name;const i=this.getFixedFieldsGroup(),t={name:u.noGroup,fields:i?[...i.fields,e]:[e]},s=i?[t,...this.groupsListMemory.slice(1)]:[t,...this.groupsListMemory];this.applyGroupUpdate(s)}getFixedFieldsGroup(){return this.groupsListMemory.find((e=>e.name===u.noGroup))}getMessage(e,i){return this.messagesBuilder.getMessage(e,i)}handleAddGroup(){const e={name:this.buildNewGroupName(),fields:[]},i=[...this.groupsListMemory,e];this.applyGroupUpdate(i)}buildNewGroupName(){var e,i;const t=this.getMessage("snkFormConfig.form.newGroup"),s=null!==(i=null===(e=this.groupsListMemory.filter((e=>e.name.includes(t))))||void 0===e?void 0:e.length)&&void 0!==i?i:0;return 0===s?t:`${t} (${s})`}makeDynamicFieldsContainersDraggable(){this.groupsList.filter((e=>e.name!==u.noGroup)).forEach((e=>{this.makeFieldContainerDraggable(this.getFieldsContainerId(e.name))}))}getFieldsContainerId(e){return`${this.ID_FIELDS}-${a.replaceBlankCharacters(e)}`}handleSortGroups(e){var i;const t=null===(i=e.to)||void 0===i?void 0:i.children;if(!t)return;const s=Array.from(t).map((e=>e.getAttribute("data-group-name"))),o=[],n=this.getFixedFieldsGroup();n&&o.push(n),s.forEach((e=>{const i=this.groupsListMemory.find((i=>i.name===e));i&&o.push(i)})),this.applyGroupUpdate(o)}handleFieldsChanged(e){let i=[...this.groupsListMemory];i=[...this.handleFieldsOnGroupUpdate(i,e,c.FROM)],i=[...this.handleFieldsOnGroupUpdate(i,e,c.TO)],this.applyGroupUpdate(i)}applyGroupUpdate(e){var i;return null===(i=this.groupsRefList)||void 0===i||i.forEach((e=>null==e?void 0:e.cancelEdition())),!r.equals(e,this.groupsListMemory)&&(this.groupsListMemory=[...e],this.layoutChanged.emit(this.groupsListMemory),!0)}handleFieldsOnGroupUpdate(e,i,t){const s=i[t];return s.id===p?e:this.updateGroupList(e,s,t,i)}updateGroupList(e,i,t,s){const o=i.getAttribute("data-group-name"),n={name:o,fields:g(s,t,o,this.selectedGuide.name)};return this.replaceGroup(e,n)}replaceGroup(e,i){return e.map((e=>e.name===i.name?i:e))}makeGroupsDraggable(){try{const e=this.getContainerElement(this.ID_GROUPS);if(!e)return;new d(e,{group:"groups",ghostClass:"ghost",direction:"horizontal",animation:15,onSort:e=>this.handleSortGroups(e)})}catch(e){console.error(this.getMessage("snkFormConfig.errors.failMakeGroupsDraggable"),this.ID_GROUPS)}}makeFieldContainerDraggable(e){try{const i=this.getContainerElement(e);if(!i)return;new d(i,{group:"fields",ghostClass:"ghost",direction:"vertical",animation:15,onAdd:e=>this.handleFieldsChanged(e),onRemove:e=>this.handleFieldsChanged(e),onSort:e=>this.handleFieldsChanged(e)})}catch(i){console.error(this.getMessage("snkFormConfig.errors.failMakeFieldContainerDraggable"),e)}}getContainerElement(e){return this.el.querySelector(`[id="${e}"]`)}handleSetFieldAsAvailable(e){var i;const t=null!==(i=e.group)&&void 0!==i?i:u.noGroup,s=this.groupsListMemory.find((e=>e.name===t)).fields.filter((i=>i.name!==e.name)),o=[...this.replaceGroup(this.groupsListMemory,{name:t,fields:s})];this.applyGroupUpdate(o)}removeGroup(e){var i,t;const s=null!==(t=null===(i=this.groupsListMemory.find((i=>i.name===e.name)))||void 0===i?void 0:i.fields)&&void 0!==t?t:[],o=[...this.groupsListMemory.filter((i=>i.name!==e.name))];this.applyGroupUpdate(o)&&this.setFieldListAsAvailable.emit(s)}handleRenameGroup(e){const{value:i,newValue:t}=e.detail,s=this.groupsListMemory.map((e=>{if(e.name!==i)return Object.assign({},e);const s=e.fields.map((e=>Object.assign(Object.assign({},e),{group:t})));return{name:t,fields:s}}));this.applyGroupUpdate(s)}canSaveGroup(e,i){if(!this.groupsList.some((i=>{var t;return(null!==(t=i.name)&&void 0!==t?t:"").toLocaleLowerCase()===(null!=e?e:"").toLocaleLowerCase()})))return!0;const t=this.getMessage("snkFormConfig.confirm.title"),s=this.buildDuplicatedGroupNameContent(e);return l.alert(t,s).then((()=>{var e;return null===(e=this.groupsRefList[i])||void 0===e?void 0:e.applyFocusTextEdit()})),!1}buildDuplicatedGroupNameContent(e){const i=this.selectedGuide.name;return`\n ${this.getMessage("snkFormConfig.alert.titleGroupExists")}\n <b>${e}</b>\n ${this.getMessage("snkFormConfig.alert.inTab")}\n <b>${i===h.main?this.getMessage("snkFormConfig.form.mainArea"):i}</b>.\n <br/><br/>\n ${this.getMessage("snkFormConfig.alert.infoValidTitle")}\n `}buildDuplicatedTabNameContent(e){return`\n ${this.getMessage("snkFormConfig.alert.titleGuideExists")}\n <b>${e}</b>.\n <br/><br/>\n ${this.getMessage("snkFormConfig.alert.infoValidTitle")}\n `}buildReservedTabNameContent(e){return`\n ${this.getMessage("snkFormConfig.alert.titleGuideReservedName")}\n <br/><br/>\n <b>${e}</b>.\n <br/><br/>\n ${this.getMessage("snkFormConfig.alert.infoValidTitle")}\n `}renderFields(e){if(0!==e.length)return e.map((e=>s("field-item",{key:e.name,fieldConfig:e,onLayoutConfig:!0,dataUnit:this.dataUnit,messagesBuilder:this.messagesBuilder,onSetFieldAsAvailable:e=>this.handleSetFieldAsAvailable(e.detail)})))}renderDraggableGroups(){return this.groupsList.filter((e=>e.name!==u.noGroup)).map(((e,i)=>{var t;return s("div",{key:e.name,class:"group-config","data-group-name":e.name},s("ez-collapsible-box",{ref:e=>this.groupsRefList[i]=e,label:e.name,headerSize:"large",editable:!0,removable:!0,"icon-placement":"left",onEzRemove:()=>this.removeGroup(e),onEzSaveEditLabel:e=>this.handleRenameGroup(e),onEzEditLabelMode:({detail:e})=>this.isEditingGroupName.emit(e),conditionalSave:e=>this.canSaveGroup(e,i)},s("div",{id:this.getFieldsContainerId(e.name),class:"group-content "+((null===(t=e.fields)||void 0===t?void 0:t.length)?"":"empty-content"),"data-group-name":e.name},this.renderFields(e.fields))))}))}renderFixedFields(){var e,i;const t=null!==(i=null===(e=this.groupsList.find((e=>e.name===u.noGroup)))||void 0===e?void 0:e.fields)&&void 0!==i?i:[];return this.renderFields(t)}handleRenameGuide(e){const{value:i,newValue:t}=e.detail;if(this.isEditGuideNameActive=!1,t===i)return;const s=this.guideNames.includes(t.toLowerCase()),o=this.reservedGuideNames.includes(t.toLowerCase());if(o||s){const e=this.getMessage("snkFormConfig.confirm.title"),i=o?this.buildReservedTabNameContent(t):this.buildDuplicatedTabNameContent(t);l.alert(e,i).then((()=>this._refTextEdit.applyFocusSelect()))}else this.guideRenamed.emit(t)}cancelEditGuideName(){this.isEditGuideNameActive=!1}async startGuideNameEdition(){this.isEditGuideNameActive=!0,setTimeout((async()=>{await this._refTextEdit.applyFocusSelect()}),200)}getTextEditStyle(){return{fontSize:"20px",fontWeight:"500",fontFamily:"Roboto"}}renderGuideName(){var e,i;return this.isEditGuideNameActive?s("div",{class:"guide-header"},s("ez-text-edit",{class:"collapsible-box__text-edit",ref:e=>this._refTextEdit=e,value:null===(e=this.selectedGuide)||void 0===e?void 0:e.label,styled:this.getTextEditStyle(),onSaveEdition:e=>this.handleRenameGuide(e),onCancelEdition:()=>this.cancelEditGuideName()})):s("div",{class:"guide-header"},s("span",{class:"guide-header-label"},null===(i=this.selectedGuide)||void 0===i?void 0:i.label),this.renderEditGuideNameButton())}renderEditGuideNameButton(){var e;if((null===(e=this.selectedGuide)||void 0===e?void 0:e.name)!==h.main)return s("ez-button",{mode:"icon",class:"ez-button--tertiary",onClick:()=>this.startGuideNameEdition(),size:"medium",iconName:"edit",title:this.getMessage("snkFormConfig.buttons.rename")})}setCustomCSSProperties(){document.documentElement.style.setProperty("--empty-content-message",`"${this.getMessage("snkFormConfig.form.labelDropField")}"`),document.documentElement.style.setProperty("--no-group-message",`"${this.getMessage("snkFormConfig.form.subTitleInfo")}"`)}componentDidRender(){this.makeGroupsDraggable(),this.makeDynamicFieldsContainersDraggable(),this.makeFieldContainerDraggable(u.noGroup),this.setCustomCSSProperties()}render(){return this.selectedGuide?this.selectedGuide.isCustom||this.selectedGuide.isDetail?s(o,{class:"ez-flex-item--auto ez-size-height--full ez-box ez-padding--medium content-container"},s("div",{class:"message-container"},s("h1",{class:"no-guide-selected"},this.getMessage("snkFormConfig.form.canNotEditCustomGuide")),s("span",{class:"message-config-detail"},this.getMessage("snkFormConfig.form.canNotEditDetailGuide")))):s(o,{class:"ez-flex-item--auto ez-size-height--full ez-box ez-padding--medium content-container"},this.renderGuideName(),s("div",{class:"layout-container"},s("ez-scroller",{direction:"vertical",activeShadow:!0},s("div",{class:"no-group-container"},s("div",{id:u.noGroup,class:"group-content","data-group-name":u.noGroup},this.renderFixedFields())),s("hr",null),s("div",{id:this.ID_GROUPS,class:"groups-container"},this.renderDraggableGroups()))),s("div",{class:"add-group-container",onClick:this.handleAddGroup.bind(this)},s("ez-icon",{slot:"leftIcon",iconName:"plus"}),s("span",null,this.getMessage("snkFormConfig.form.createNewGroup")))):s(o,{class:"ez-flex-item--auto ez-size-height--full ez-box ez-padding--medium content-container"},s("span",{class:"no-guide-selected"},this.getMessage("snkFormConfig.form.noGuideSelected")))}get el(){return n(this)}static get watchers(){return{messagesBuilder:["onMessagesBuilderChange"],selectedGuide:["observeSelectedGuide"],groupsList:["observeGroupList"],isEditGuideNameActive:["observeIsEditGuideNameActive"]}}};m.style='.sc-fields-layout-h{display:flex;padding:12px;box-shadow:var(--shadow--small, 0 0 16px rgba(0, 38, 111, 0.07));border-radius:var(--border--radius-medium, 6px);height:var(--snk-form-config-container-height);flex-direction:column}.layout-container.sc-fields-layout{container-type:inline-size;display:flex;flex-direction:column;overflow:auto;height:calc(100vh - 225px)}.guide-header.sc-fields-layout{display:flex;width:100%;font-size:20px;border-bottom:1px solid #dce0e8;margin-bottom:6px;align-items:center;height:45px}.guide-header.sc-fields-layout ez-button.sc-fields-layout{transition:all 0.2s ease-in-out;visibility:hidden;opacity:0}.guide-header.sc-fields-layout:hover ez-button.sc-fields-layout{visibility:visible;opacity:1}.guide-header-label.sc-fields-layout{display:block;padding:10px 0}.group-config.sc-fields-layout{padding:12px 0;display:flex;flex-direction:column;width:100%}.group-content.sc-fields-layout{display:grid;gap:12px;min-height:65px;width:100%;padding:6px 0;grid-template-columns:repeat(auto-fill, minmax(250px, 1fr))}.group-content.empty-content.sc-fields-layout{position:relative}.group-content.empty-content.sc-fields-layout::before{content:var(--empty-content-message, "Arraste e solte um campo aqui");color:#cbcfd7;font-size:16px;font-weight:500;text-align:center;position:absolute;inset:0;display:flex;align-items:center;justify-content:center;pointer-events:none;transition:opacity 0.3s;height:100%;box-sizing:border-box;padding:10px;background:#f9f9f9;border:1px dashed #dce0e8;border-radius:6px}.no-group-container.sc-fields-layout{padding:12px 0;width:100%;border-bottom:1px solid #dce0e8}.no-group-container.sc-fields-layout::before{content:var(--no-group-message, "Inclua estes campos nos grupos ou deixe-os separados no topo do formulário");width:100%;display:block;font-size:16px;font-weight:400;color:#AFB6C0;padding-bottom:12px}.add-group-container.sc-fields-layout{display:flex;align-items:center;border-top:1px solid #dce0e8;padding-top:22px;padding-bottom:12px;gap:6px;cursor:pointer;justify-content:center;width:100%;height:55px}.no-guide-selected.sc-fields-layout{display:block;margin:auto;font-size:24px;color:#AFB6C0;font-weight:500}.message-container.sc-fields-layout{margin:auto;display:flex;flex-direction:column;justify-content:center;align-items:center}.message-config-detail.sc-fields-layout{display:block;margin:auto;font-size:var(--font-size--medium, 16px);color:#AFB6C0;font-weight:var(--font-weight--medium, 500)}.ghost.sc-fields-layout{opacity:.5;background:#c8fbe2}';export{m as fields_layout}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,c as i,h as s,f as t,H as n,g as o}from"./p-d8d8169b.js";import{a as r,F as a}from"./p-84345e7a.js";import{ApplicationUtils as l,CheckMode as h}from"@sankhyalabs/ezui/dist/collection/utils";import{ApplicationContext as d,StringUtils as p,ElementIDUtils as u,UserInterface as c}from"@sankhyalabs/core";import{S as v}from"./p-f4184ce7.js";import{fieldBuilder as m}from"@sankhyalabs/ezui/dist/collection/components/ez-form-view/fieldbuilder/FieldBuilder";import{s as x}from"./p-55798617.js";import{convertType as b}from"@sankhyalabs/core/dist/dataunit/metadata/DataType";const g=class{constructor(s){e(this,s),this.ezFilterGroupChange=i(this,"ezFilterGroupChange",7),this.ezFilterGroupRemove=i(this,"ezFilterGroupRemove",7),this.ezExpressionGroupLayoutChanged=i(this,"ezExpressionLayoutChanged",7),this.FIRST_LEVEL="0",this.LIMIT_GROUP_LEVEL=4,this.application=d.getContextValue("__SNK__APPLICATION__"),this._conditionOperator=r.AND,this._group=void 0,this._selfTop=0,this.canAddExpression=!0,this._showDashes=!0,this.parentTop=0,this.group=void 0,this.messagesBuilder=void 0,this.filterId=void 0,this.entityURI=void 0,this.isDefaultFilter=!1}todoCompletedHandler(e){this.updateDashes()}async getExpressionGroup(){return this._group}watchGroup(e){this._group=e,this._conditionOperator=this.getOperand()}componentWillLoad(){this._group=this.group,this._conditionOperator=this.getOperand(),this.getDataGroupLevel()||this._element.setAttribute("data-group-level",this.FIRST_LEVEL),this.canAddExpression=this.group.items.every(this.isFilledItem)}componentDidRender(){this.setSelfTop()}changeHandler(){this.ezExpressionGroupLayoutChanged.emit()}setSelfTop(){this._selfTop=this._element.getBoundingClientRect().top}getDashedHeight(){return this._selfTop-this.parentTop}getOperand(){return this._group.operand?this._group.operand:r.AND}getMessage(e,i){return this.application.messagesBuilder.getMessage(e,i)}updateDashes(){this._showDashes=!1,this.setSelfTop(),this._showDashes=!0}renderExpressionItems(){var e;return null===(e=this._group.items)||void 0===e?void 0:e.map((e=>s("snk-expression-item",{key:e.id,class:"ez-padding-top--small snk-expression-group__item",expression:e,canRemove:this._group.items.length>1,onEzFilterItemChange:()=>this.handleFilterItemChange(),onEzFilterItemRemove:i=>this.handleFilterItemRemove(i,e.id),messagesBuilder:this.messagesBuilder,entityURI:this.entityURI,isDefaultFilter:this.isDefaultFilter})))}renderGroups(){var e;const i=parseInt(this.getDataGroupLevel()||"0")+1;return null===(e=this._group.childrenGroups)||void 0===e?void 0:e.map((e=>s("snk-expression-group",{key:e.id,group:e,messagesBuilder:this.messagesBuilder,parentTop:this._selfTop,"data-group-level":i,onEzFilterGroupRemove:i=>this.handleFilterGroupRemove(i,e.id),entityURI:this.entityURI})))}handleFilterGroupRemove(e,i){this.onStopPropagation(e),this._group.childrenGroups=this._group.childrenGroups.filter((e=>e.id!==i)),t(this),this.ezFilterGroupChange.emit(this._group),this.changeHandler()}handleFilterItemRemove(e,i){this.onStopPropagation(e),this._group.items=this._group.items.filter((e=>e.id!==i)),t(this),this.ezFilterGroupChange.emit(this._group),this.changeHandler(),this.canAddExpression=!0}isFilledItem(e){return!(!e.fieldName||!e.operand||"NULL"!==e.operand&&"NOT_NULL"!==e.operand&&!e.paramVariable&&"SWITCH"!==e.userInterface&&!e.value)}handleFilterItemChange(){this.ezFilterGroupChange.emit(this._group),this.canAddExpression=this.group.items.every(this.isFilledItem)}handleAddExpression(){const e={id:p.generateUUID(),entityName:"",fieldName:"",description:"",label:this.getMessage("snkPersonalizedFilter.info.labelDefaultValue"),type:void 0,expression:void 0,operand:void 0,paramVariable:!1,value:void 0,systemConfig:null,userConfig:null};this._group.items.push(e),t(this),this.ezFilterGroupChange.emit(this.group),this.changeHandler(),this.canAddExpression=!1}handleAddGroup(){var e;const i={id:p.generateUUID(),items:[{id:p.generateUUID(),entityName:"",fieldName:"",description:"",label:this.getMessage("snkPersonalizedFilter.info.labelDefaultValue"),type:void 0,expression:void 0,operand:void 0,paramVariable:!1,value:void 0,systemConfig:null,userConfig:null}],childrenGroups:[],operand:r.AND};this._group.childrenGroups=null!==(e=this._group.childrenGroups)&&void 0!==e?e:[],this._group.childrenGroups.push(i),t(this),this.group.operand||(this.group.operand=r.AND),this.ezFilterGroupChange.emit(this.group),this.changeHandler()}buildGroupStyle(){return{height:`${this.getDashedHeight()}px`,marginTop:20-this.getDashedHeight()+"px"}}handleConditionOperatorChange(e){this._conditionOperator=e,this._group.operand=r[e],this.ezFilterGroupChange.emit(this._group)}confirmRemoveGroup(e){this.onStopPropagation(e),l.confirm(this.getMessage("snkPersonalizedFilter.confirmGroup.title"),this.getMessage("snkPersonalizedFilter.confirmGroup.description")).then((e=>{e&&this.ezFilterGroupRemove.emit(this._group)}))}getTooltipMessageForOperator(){return this.getDataGroupLevel()===this.FIRST_LEVEL&&1===this._group.items.length?this.getMessage("snkPersonalizedFilter.operador.firstLevel"):this._conditionOperator===r.AND?this.getMessage("snkPersonalizedFilter.operador.and"):this._conditionOperator===r.OR?this.getMessage("snkPersonalizedFilter.operador.or"):void 0}getDataGroupLevel(){return this._element.getAttribute("data-group-level")}canAddGroup(){return Number(this.getDataGroupLevel()||this.FIRST_LEVEL)<this.LIMIT_GROUP_LEVEL}isFirstLevel(){return Boolean(this.getDataGroupLevel()===this.FIRST_LEVEL)}onStopPropagation(e){e.preventDefault(),e.stopPropagation()}getMessageAddTooltip(){if(this.isFirstLevel()){const e=this.group.items.every((e=>!(!e.fieldName||!e.operand)&&(e.paramVariable||!!e.value)));return this.getMessage(e?"snkPersonalizedFilter.info.labelAddNewExpression":"snkPersonalizedFilter.info.labelDisabledAddExpressionButton")}return this.getMessage(this.canAddExpression?"snkPersonalizedFilter.info.labelAddNewExpression":"snkPersonalizedFilter.info.labelDisabledAddExpressionButton")}canChangeGroupCondition(){return this._group.items.length+this._group.childrenGroups.length>1}render(){const e=this.canAddGroup();return s(n,null,s("div",{class:!this.isFirstLevel()&&this._showDashes?"dashes":"hidden",style:this.buildGroupStyle()}),s("div",{class:!this.isFirstLevel()&&this._showDashes?"horizontal-dashes":"hidden"}),s("div",{class:"ez-flex ez-flex--align-items-center"},s("div",{class:"snk-expression-group__container-condition ez-flex ez-flex-item--align-center ez-flex--align-items-center","data-condition":this._conditionOperator,title:this.getTooltipMessageForOperator()},s("label",{class:"ez-label ez-padding-right--medium ez-padding-left--medium ez-title--primary"},this.getMessage("snkPersonalizedFilter.info.condition")),s("div",null,s("ez-combo-box",Object.assign({class:"snk-expression-group__container-option",canShowError:!1,mode:"slim",suppressEmptyOption:!0,enabled:this.canChangeGroupCondition(),value:this._conditionOperator,onEzChange:e=>this.handleConditionOperatorChange(e.detail.value)},{[u.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`comboBoxConditions_level_${this.getDataGroupLevel()}`}),s("option",{value:r.AND},this.getMessage("snkPersonalizedFilter.info.conditionAnd")),s("option",{value:r.OR},this.getMessage("snkPersonalizedFilter.info.conditionOr"))))),s("ez-button",{class:"ez-padding-right--medium ez-padding-left--medium",mode:"icon",iconName:"plus",size:"small",enabled:this.canAddExpression,title:this.getMessageAddTooltip(),onClick:()=>this.handleAddExpression()}),s("ez-button",{label:this.getMessage("snkPersonalizedFilter.info.addGroup"),size:"small",enabled:e,title:e?"":this.getMessage("snkPersonalizedFilter.info.labelDisabledAddGroupButton",{LIMIT_GROUP_LEVEL:this.LIMIT_GROUP_LEVEL+1}),onClick:()=>this.handleAddGroup()},s("ez-icon",{class:"ez-padding-right--small",slot:"leftIcon",iconName:"plus"})),!this.isFirstLevel()&&s("ez-button",{title:this.getMessage("snkPersonalizedFilter.info.labelDeleteExpression"),class:"ez-padding-left--medium",mode:"icon",iconName:"delete",size:"small",onClick:e=>this.confirmRemoveGroup(e)})),s("div",{class:"ez-padding-top--small snk-expression-group__container-expression"},s("div",{class:"ez-padding-top--small"},this.renderExpressionItems())),s("div",{class:"ez-padding-top--small snk-expression-group__container-expression"},s("div",{class:"ez-padding-top--small"},this.renderGroups())))}get _element(){return o(this)}static get watchers(){return{group:["watchGroup"]}}};g.style='.sc-snk-expression-group-h{display:block;--snk-expression-group--container-condition--width:184px;--snk-expression-group--container-condition--height:38px;--snk-expression-group--container-condition--border-radius:var(--border--radius-medium, 12px);--snk-expression-group--container-option--width:85px;--snk-expression-group__container-condition--background-and:#66B6A0;--snk-expression-group__container-condition--background-or:#EBC65E;--snk-expression-group__container-expression--padding-left:26px;--snk-expression-group__background-color-dashed:var(--background--body, #fafcff);--ez-text-input__margin-bottom:0px}.snk-expression-group__container-condition.sc-snk-expression-group{width:var(--snk-expression-group--container-condition--width);height:var(--snk-expression-group--container-condition--height);border-radius:var(--snk-expression-group--container-condition--border-radius);z-index:var(--more-visible--2x, 3);padding:var(--space--nano, 2px)}.snk-expression-group__container-option.sc-snk-expression-group{width:var(--snk-expression-group--container-option--width)}.snk-expression-group__container-condition[data-condition="AND"].sc-snk-expression-group{background-color:var(--snk-expression-group__container-condition--background-and)}.snk-expression-group__container-condition[data-condition="OR"].sc-snk-expression-group{background-color:var(--snk-expression-group__container-condition--background-or)}.snk-expression-group__container-expression.sc-snk-expression-group{padding-left:var(--snk-expression-group__container-expression--padding-left)}.dashes.sc-snk-expression-group{z-index:var(--visible, 1);background:var(--snk-expression-group__background-color-dashed);border-left:2px dashed var(--text-secondary, #A2ABB9);position:absolute;width:15px;height:58px;margin-left:-15px;margin-top:-36.5px}.horizontal-dashes.sc-snk-expression-group{z-index:var(--more-visible, 2);border-bottom:2px dashed var(--text-secondary, #A2ABB9);position:absolute;width:15px;height:54px;margin-left:-15px;margin-top:-33.5px}.hidden.sc-snk-expression-group{display:none}';const k=[{label:"snkPersonalizedFilter.operands.equal",value:"EQUAL"},{label:"snkPersonalizedFilter.operands.different",value:"DIFFERENT"},{label:"snkPersonalizedFilter.operands.like",value:"LIKE"},{label:"snkPersonalizedFilter.operands.in",value:"IN"},{label:"snkPersonalizedFilter.operands.startWith",value:"START_WITH"},{label:"snkPersonalizedFilter.operands.finishedWith",value:"FINISHED_WITH"},{label:"snkPersonalizedFilter.operands.null",value:"NULL"},{label:"snkPersonalizedFilter.operands.notNull",value:"NOT_NULL"}],_=k.concat([{label:"snkPersonalizedFilter.operands.larger",value:"LARGER"},{label:"snkPersonalizedFilter.operands.largerEqual",value:"LARGER_EQUAL"},{label:"snkPersonalizedFilter.operands.smaller",value:"SMALLER"},{label:"snkPersonalizedFilter.operands.smallerEqual",value:"SMALLER_EQUAL"}]),f=k,z=[c.SEARCH,c.SHORTTEXT,c.PASSWORD,c.MASKEDTEXT,c.LONGTEXT,c.HTML],F=class{constructor(s){e(this,s),this.ezFilterItemChange=i(this,"ezFilterItemChange",7),this.ezFilterItemRemove=i(this,"ezFilterItemRemove",7),this.application=d.getContextValue("__SNK__APPLICATION__"),this.filterOperandDefault=_,this.filterOperandTypeTextSearch=f,this.DEFAULT_FIELD_NAME="NOT_DEFINED",this._showValueVariable=!1,this._fieldSelected=void 0,this._optionNotNull=!1,this.expression=void 0,this.canRemove=!0,this.messagesBuilder=void 0,this.isDefaultFilter=!1,this.entityURI=void 0}expressionChanged(e,i){e!==i&&(this.ezFilterItemChange.emit(e),this.updateFieldSelected())}componentWillLoad(){this._dataSourceFetcher=x.get(`filterFieldsDataSource.${this.entityURI}`),x.onChange(`filterFieldsDataSource.${this.entityURI}`,(()=>{this._dataSourceFetcher=x.get(`filterFieldsDataSource.${this.entityURI}`)})),this.expression&&(this.updateFieldSelected(),this._optionNotNull="NULL"===this.expression.operand||"NOT_NULL"===this.expression.operand)}componentDidRender(){var e;this._showValueVariable=null===(e=this._elValueVariable)||void 0===e?void 0:e.value}updateFieldSelected(){const e={dataType:this.expression.type,description:this.expression.description,name:this.expression.fieldName,label:this.expression.fieldLabel,entityName:this.expression.entityName,onlyDate:!1,path:this.expression.description,properties:this.expressionPropsToFieldProps(this.expression.props),type:v.FIELD,uri:"",userInterface:this.expression.userInterface};this._fieldSelected=e}buildExpression(e,i,s){return s.length>0&&s.shift(),s.length>0?`${s.join("->")}->${i}`:`${e}.${i}`}setValueExpression(e,i){"fieldName"===e?(this.expression.description=i.path,this.expression.expression=this.buildExpression(i.entityName,i.name,i.entityPath),this.expression.fieldName=i.name,this.expression.fieldLabel=i.label,this.expression.type=i.dataType,this.expression.userInterface=i.userInterface,this.expression.entityName=i.entityName,this.expression.value=void 0,this.expression.props=this.fieldPropsToExpressionProps(i.properties)):this.expression[e]=i,this.expressionChanged(this.expression)}fieldPropsToExpressionProps(e){const i=[];if(!e)return i;for(const s in e){let t=e[s];"object"==typeof t&&(t=JSON.stringify(t)),i.push({name:s,value:t})}return i}expressionPropsToFieldProps(e){const i={};return e?(e.forEach((e=>{try{i[e.name]=JSON.parse(e.value)}catch(s){i[e.name]=e.value}})),i):i}getMessage(e,i){return this.application.messagesBuilder.getMessage(e,i)}handleSelectItem(e){if(this.hasNoChanges(e))this._elFilterInput.value=e.path;else if(e.type===v.FIELD){const i=e;this._fieldSelected=i,this.setValueExpression("fieldName",i)}}hasNoChanges(e){return e.name===this.expression.fieldName&&e.path===this.expression.description}handleFocus(){this._elFilterFieldSearch&&this._elFilterFieldSearch.show()}handleChangeFilterInput(e){this._elFilterFieldSearch.applyFilter(e.detail)}handleChangeValueVariable(e){this._showValueVariable=e,this._elFieldDynamic&&(this._elFieldDynamic.value=void 0,this._elFieldDynamic.enabled=!e),this.expression.paramVariable=e,this.expressionChanged(this.expression)}openSnkFilterParamConfig(){var e;null===(e=this._elFilterParamConfigRef)||void 0===e||e.open(this.expression).then(this.onOpenPromiseReady.bind(this)).catch((e=>{console.error(e)}))}onOpenPromiseReady(e){this.expression=e}buildOptionsOperator(){var e;return z.includes(null===(e=this._fieldSelected)||void 0===e?void 0:e.userInterface)?this.translateOperandOptions(this.filterOperandTypeTextSearch):this.translateOperandOptions(this.filterOperandDefault)}translateOperandOptions(e){return e.map((e=>({label:this.getMessage(e.label),value:e.value})))}handleChangeOperator(e){this.checkOptionIsNull(e),this.setValueExpression("operand",e)}checkOptionIsNull(e){[a.NULL,a.NOT_NULL].includes(a[e])?(this._optionNotNull=!0,this._elFieldDynamic&&(this._elFieldDynamic.enabled=!1,this._elFieldDynamic.value=void 0)):(this._optionNotNull=!1,this._elFieldDynamic&&(this._elFieldDynamic.enabled=!this._showValueVariable))}confirmRemove(e){e.preventDefault(),e.stopPropagation(),l.confirm(this.getMessage("snkPersonalizedFilter.confirmExpression.title"),this.getMessage("snkPersonalizedFilter.confirmExpression.description")).then((e=>{e&&this.ezFilterItemRemove.emit(this.expression)}))}buildFieldByType(){var e,i,t;if(!this._fieldSelected)return;const n=null===(e=m(this.configureFieldByType()))||void 0===e?void 0:e.i.shift();return(this._optionNotNull&&n||(null===(i=this._elValueVariable)||void 0===i?void 0:i.value)&&n||this.expression.paramVariable||this._showValueVariable||!(null===(t=this._fieldSelected)||void 0===t?void 0:t.dataType))&&(n.t.enabled=!1),null!=this.expression.value&&(n.t.value=this.getExpressiontValue(this.expression)),n.t.onEzChange=e=>{this.setValueExpression("value",e.target.value)},"SWITCH"===this.expression.userInterface&&null==this.expression.value&&this.setValueExpression("value",!1),s(n.o,Object.assign(Object.assign({},n.t),{ref:e=>{this._elFieldDynamic=e},label:this.expression.fieldLabel||this._fieldSelected.label}))}getExpressiontValue(e){return b(e.type,e.value)}configureFieldByType(){var e,i;const s={userInterface:this._fieldSelected.userInterface,name:this._fieldSelected.name,label:this._fieldSelected.label,canShowError:!1};switch(s.userInterface){case c.OPTIONSELECTOR:s.props={options:null===(i=null===(e=this._fieldSelected)||void 0===e?void 0:e.properties)||void 0===i?void 0:i.options};break;case c.LONGTEXT:s.rows=1;break;case c.SEARCH:s.optionLoader=e=>this.setCriteriaSearch(e,this.application)}return s}setCriteriaSearch({mode:e,argument:i},s){var t,n,o;if(null==s)return;const r={entity:null!==(o=null===(n=null===(t=this._fieldSelected)||void 0===t?void 0:t.properties)||void 0===n?void 0:n.ENTITYNAME)&&void 0!==o?o:this._fieldSelected.entityName,searchOptions:{showInactives:!1},entityDescription:this._fieldSelected.description};return s.executePreparedSearch(e,i,r)}render(){var e;return s(n,null,s("div",{class:"dashes"}),s("div",{class:"box"},s("div",{class:"box__container"},s("div",{class:"box__container--input-filter"},s("ez-filter-input",Object.assign({ref:e=>this._elFilterInput=e,value:null===(e=this._fieldSelected)||void 0===e?void 0:e.path,label:this.getMessage("snkPersonalizedFilter.info.labelSearchField"),canShowError:!1,onEzChange:e=>this.handleChangeFilterInput(e),onFocus:()=>this.handleFocus()},{[u.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`expressionFilterInput_${this.expression.fieldName||this.DEFAULT_FIELD_NAME}`})),s("snk-filter-field-search",{ref:e=>this._elFilterFieldSearch=e,searchable:!1,onEzSelectFilterItem:e=>this.handleSelectItem(e.detail),fieldsDataSource:this._dataSourceFetcher})),s("div",{class:"box__container--input-operator"},s("ez-combo-box",Object.assign({label:this.getMessage("snkPersonalizedFilter.info.labelOperator"),value:this.expression.operand,canShowError:!1,options:this.buildOptionsOperator(),onEzChange:e=>{var i;return this.handleChangeOperator(null===(i=e.detail)||void 0===i?void 0:i.value)},suppressEmptyOption:!0},{[u.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`comboBoxOperand_${this.expression.fieldName||this.DEFAULT_FIELD_NAME}`}))),s("div",{class:"box__container--input-value"},this._fieldSelected?this.buildFieldByType():s("ez-number-input",{label:this.getMessage("snkPersonalizedFilter.info.labelDefaultValue"),canShowError:!1,enabled:!this._showValueVariable&&!this._optionNotNull})),s("div",{class:"box__container--input-value-variable"},!this._optionNotNull&&s("ez-tooltip",{message:this.getMessage("snkPersonalizedFilter.info.checkVariableDisabled"),active:this.isDefaultFilter},s("ez-check",{ref:e=>this._elValueVariable=e,value:this.expression.paramVariable,label:this.getMessage("snkPersonalizedFilter.info.labelValueVarible"),mode:h.SWITCH,onEzChange:e=>this.handleChangeValueVariable(e.detail),enabled:!this.isDefaultFilter})),this._showValueVariable&&!this._optionNotNull&&s("ez-icon",Object.assign({class:"box__container--input-value-variable--icon",size:"large",iconName:"settings-inverted"},{[u.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:"iconConfig"},{title:this.getMessage("snkPersonalizedFilter.info.titleTooltip"),onClick:()=>this.openSnkFilterParamConfig()})),s("snk-filter-param-config",{ref:e=>this._elFilterParamConfigRef=e,messagesBuilder:this.messagesBuilder})),s("div",{class:"box__container--button-delete"},s("div",{class:"box__container--button-delete--icon"},s("ez-button",{mode:"icon",iconName:"delete",enabled:this.canRemove,label:this.getMessage("snkPersonalizedFilter.info.labelDeleteItem"),onClick:e=>this.confirmRemove(e)}))))))}static get watchers(){return{expression:["expressionChanged"]}}};F.style=".sc-snk-expression-item-h{display:flex;width:100%;--snk-expression-item--background-color:var(--background--xlight, #fff);--snk-expression-item__itens--padding:var(--space--small, 6px);--snk-expression-item__width--input-operator:220px;--snk-expression-item__width--input-value:240px;--snk-expression-item__width--input-value-variable:176px;--snk-expression-item--border-radius:var(--border--radius-medium, 12px);--snk-expression-item--border-color:var(--color--strokes, #DCE0E8);--snk-expression-item--border-style:var(--border--small, 1px solid);--snk-expression-item__background-color-dashed:var(--background--body, #fafcff)}.box.sc-snk-expression-item{width:100%;height:56px;background:var(--snk-expression-item--background-color);border:var(--snk-expression-item--border-color) var(--snk-expression-item--border-style);border-radius:var(--snk-expression-item--border-radius)}.box__container.sc-snk-expression-item{display:flex;align-items:center;justify-content:space-between;white-space:nowrap;margin:var(--space--small, 6px)}.box__container--input-filter.sc-snk-expression-item{width:100%}.box__container--input-operator.sc-snk-expression-item{display:flex;width:var(--snk-expression-item__width--input-operator);min-width:var(--snk-expression-item__width--input-operator)}.box__container--input-value.sc-snk-expression-item{display:flex;width:var(--snk-expression-item__width--input-value);min-width:var(--snk-expression-item__width--input-value)}.box__container--input-value-variable.sc-snk-expression-item{display:flex;width:var(--snk-expression-item__width--input-value-variable);min-width:var(--snk-expression-item__width--input-value-variable)}.box__container--button-delete.sc-snk-expression-item{display:flex}.box__container.sc-snk-expression-item>div.sc-snk-expression-item{padding-left:var(--snk-expression-item__itens--padding);padding-right:var(--snk-expression-item__itens--padding)}.box__container--button-delete--icon.sc-snk-expression-item{width:42px;min-width:42px}.box__container--input-value-variable--icon.sc-snk-expression-item{cursor:pointer}.dashes.sc-snk-expression-item{z-index:var(--more-visible, 2);background:var(--snk-expression-item__background-color-dashed);border-bottom:2px dashed var(--text-secondary, #A2ABB9);border-left:2px dashed var(--text-secondary, #A2ABB9);position:absolute;width:15px;height:62px;margin-left:-15px;margin-top:-33.5px}";export{g as snk_expression_group,F as snk_expression_item}
|
|
1
|
+
import{r as e,c as i,h as s,f as t,H as n,g as o}from"./p-82bb3eda.js";import{a as r,F as a}from"./p-84345e7a.js";import{ApplicationUtils as l,CheckMode as h}from"@sankhyalabs/ezui/dist/collection/utils";import{ApplicationContext as d,StringUtils as p,ElementIDUtils as u,UserInterface as c}from"@sankhyalabs/core";import{S as v}from"./p-f4184ce7.js";import{fieldBuilder as m}from"@sankhyalabs/ezui/dist/collection/components/ez-form-view/fieldbuilder/FieldBuilder";import{s as x}from"./p-8336900b.js";import{convertType as b}from"@sankhyalabs/core/dist/dataunit/metadata/DataType";const g=class{constructor(s){e(this,s),this.ezFilterGroupChange=i(this,"ezFilterGroupChange",7),this.ezFilterGroupRemove=i(this,"ezFilterGroupRemove",7),this.ezExpressionGroupLayoutChanged=i(this,"ezExpressionLayoutChanged",7),this.FIRST_LEVEL="0",this.LIMIT_GROUP_LEVEL=4,this.application=d.getContextValue("__SNK__APPLICATION__"),this._conditionOperator=r.AND,this._group=void 0,this._selfTop=0,this.canAddExpression=!0,this._showDashes=!0,this.parentTop=0,this.group=void 0,this.messagesBuilder=void 0,this.filterId=void 0,this.entityURI=void 0,this.isDefaultFilter=!1}todoCompletedHandler(e){this.updateDashes()}async getExpressionGroup(){return this._group}watchGroup(e){this._group=e,this._conditionOperator=this.getOperand()}componentWillLoad(){this._group=this.group,this._conditionOperator=this.getOperand(),this.getDataGroupLevel()||this._element.setAttribute("data-group-level",this.FIRST_LEVEL),this.canAddExpression=this.group.items.every(this.isFilledItem)}componentDidRender(){this.setSelfTop()}changeHandler(){this.ezExpressionGroupLayoutChanged.emit()}setSelfTop(){this._selfTop=this._element.getBoundingClientRect().top}getDashedHeight(){return this._selfTop-this.parentTop}getOperand(){return this._group.operand?this._group.operand:r.AND}getMessage(e,i){return this.application.messagesBuilder.getMessage(e,i)}updateDashes(){this._showDashes=!1,this.setSelfTop(),this._showDashes=!0}renderExpressionItems(){var e;return null===(e=this._group.items)||void 0===e?void 0:e.map((e=>s("snk-expression-item",{key:e.id,class:"ez-padding-top--small snk-expression-group__item",expression:e,canRemove:this._group.items.length>1,onEzFilterItemChange:()=>this.handleFilterItemChange(),onEzFilterItemRemove:i=>this.handleFilterItemRemove(i,e.id),messagesBuilder:this.messagesBuilder,entityURI:this.entityURI,isDefaultFilter:this.isDefaultFilter})))}renderGroups(){var e;const i=parseInt(this.getDataGroupLevel()||"0")+1;return null===(e=this._group.childrenGroups)||void 0===e?void 0:e.map((e=>s("snk-expression-group",{key:e.id,group:e,messagesBuilder:this.messagesBuilder,parentTop:this._selfTop,"data-group-level":i,onEzFilterGroupRemove:i=>this.handleFilterGroupRemove(i,e.id),entityURI:this.entityURI})))}handleFilterGroupRemove(e,i){this.onStopPropagation(e),this._group.childrenGroups=this._group.childrenGroups.filter((e=>e.id!==i)),t(this),this.ezFilterGroupChange.emit(this._group),this.changeHandler()}handleFilterItemRemove(e,i){this.onStopPropagation(e),this._group.items=this._group.items.filter((e=>e.id!==i)),t(this),this.ezFilterGroupChange.emit(this._group),this.changeHandler(),this.canAddExpression=!0}isFilledItem(e){return!(!e.fieldName||!e.operand||"NULL"!==e.operand&&"NOT_NULL"!==e.operand&&!e.paramVariable&&"SWITCH"!==e.userInterface&&!e.value)}handleFilterItemChange(){this.ezFilterGroupChange.emit(this._group),this.canAddExpression=this.group.items.every(this.isFilledItem)}handleAddExpression(){const e={id:p.generateUUID(),entityName:"",fieldName:"",description:"",label:this.getMessage("snkPersonalizedFilter.info.labelDefaultValue"),type:void 0,expression:void 0,operand:void 0,paramVariable:!1,value:void 0,systemConfig:null,userConfig:null};this._group.items.push(e),t(this),this.ezFilterGroupChange.emit(this.group),this.changeHandler(),this.canAddExpression=!1}handleAddGroup(){var e;const i={id:p.generateUUID(),items:[{id:p.generateUUID(),entityName:"",fieldName:"",description:"",label:this.getMessage("snkPersonalizedFilter.info.labelDefaultValue"),type:void 0,expression:void 0,operand:void 0,paramVariable:!1,value:void 0,systemConfig:null,userConfig:null}],childrenGroups:[],operand:r.AND};this._group.childrenGroups=null!==(e=this._group.childrenGroups)&&void 0!==e?e:[],this._group.childrenGroups.push(i),t(this),this.group.operand||(this.group.operand=r.AND),this.ezFilterGroupChange.emit(this.group),this.changeHandler()}buildGroupStyle(){return{height:`${this.getDashedHeight()}px`,marginTop:20-this.getDashedHeight()+"px"}}handleConditionOperatorChange(e){this._conditionOperator=e,this._group.operand=r[e],this.ezFilterGroupChange.emit(this._group)}confirmRemoveGroup(e){this.onStopPropagation(e),l.confirm(this.getMessage("snkPersonalizedFilter.confirmGroup.title"),this.getMessage("snkPersonalizedFilter.confirmGroup.description")).then((e=>{e&&this.ezFilterGroupRemove.emit(this._group)}))}getTooltipMessageForOperator(){return this.getDataGroupLevel()===this.FIRST_LEVEL&&1===this._group.items.length?this.getMessage("snkPersonalizedFilter.operador.firstLevel"):this._conditionOperator===r.AND?this.getMessage("snkPersonalizedFilter.operador.and"):this._conditionOperator===r.OR?this.getMessage("snkPersonalizedFilter.operador.or"):void 0}getDataGroupLevel(){return this._element.getAttribute("data-group-level")}canAddGroup(){return Number(this.getDataGroupLevel()||this.FIRST_LEVEL)<this.LIMIT_GROUP_LEVEL}isFirstLevel(){return Boolean(this.getDataGroupLevel()===this.FIRST_LEVEL)}onStopPropagation(e){e.preventDefault(),e.stopPropagation()}getMessageAddTooltip(){if(this.isFirstLevel()){const e=this.group.items.every((e=>!(!e.fieldName||!e.operand)&&(e.paramVariable||!!e.value)));return this.getMessage(e?"snkPersonalizedFilter.info.labelAddNewExpression":"snkPersonalizedFilter.info.labelDisabledAddExpressionButton")}return this.getMessage(this.canAddExpression?"snkPersonalizedFilter.info.labelAddNewExpression":"snkPersonalizedFilter.info.labelDisabledAddExpressionButton")}canChangeGroupCondition(){return this._group.items.length+this._group.childrenGroups.length>1}render(){const e=this.canAddGroup();return s(n,null,s("div",{class:!this.isFirstLevel()&&this._showDashes?"dashes":"hidden",style:this.buildGroupStyle()}),s("div",{class:!this.isFirstLevel()&&this._showDashes?"horizontal-dashes":"hidden"}),s("div",{class:"ez-flex ez-flex--align-items-center"},s("div",{class:"snk-expression-group__container-condition ez-flex ez-flex-item--align-center ez-flex--align-items-center","data-condition":this._conditionOperator,title:this.getTooltipMessageForOperator()},s("label",{class:"ez-label ez-padding-right--medium ez-padding-left--medium ez-title--primary"},this.getMessage("snkPersonalizedFilter.info.condition")),s("div",null,s("ez-combo-box",Object.assign({class:"snk-expression-group__container-option",canShowError:!1,mode:"slim",suppressEmptyOption:!0,enabled:this.canChangeGroupCondition(),value:this._conditionOperator,onEzChange:e=>this.handleConditionOperatorChange(e.detail.value)},{[u.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`comboBoxConditions_level_${this.getDataGroupLevel()}`}),s("option",{value:r.AND},this.getMessage("snkPersonalizedFilter.info.conditionAnd")),s("option",{value:r.OR},this.getMessage("snkPersonalizedFilter.info.conditionOr"))))),s("ez-button",{class:"ez-padding-right--medium ez-padding-left--medium",mode:"icon",iconName:"plus",size:"small",enabled:this.canAddExpression,title:this.getMessageAddTooltip(),onClick:()=>this.handleAddExpression()}),s("ez-button",{label:this.getMessage("snkPersonalizedFilter.info.addGroup"),size:"small",enabled:e,title:e?"":this.getMessage("snkPersonalizedFilter.info.labelDisabledAddGroupButton",{LIMIT_GROUP_LEVEL:this.LIMIT_GROUP_LEVEL+1}),onClick:()=>this.handleAddGroup()},s("ez-icon",{class:"ez-padding-right--small",slot:"leftIcon",iconName:"plus"})),!this.isFirstLevel()&&s("ez-button",{title:this.getMessage("snkPersonalizedFilter.info.labelDeleteExpression"),class:"ez-padding-left--medium",mode:"icon",iconName:"delete",size:"small",onClick:e=>this.confirmRemoveGroup(e)})),s("div",{class:"ez-padding-top--small snk-expression-group__container-expression"},s("div",{class:"ez-padding-top--small"},this.renderExpressionItems())),s("div",{class:"ez-padding-top--small snk-expression-group__container-expression"},s("div",{class:"ez-padding-top--small"},this.renderGroups())))}get _element(){return o(this)}static get watchers(){return{group:["watchGroup"]}}};g.style='.sc-snk-expression-group-h{display:block;--snk-expression-group--container-condition--width:184px;--snk-expression-group--container-condition--height:38px;--snk-expression-group--container-condition--border-radius:var(--border--radius-medium, 12px);--snk-expression-group--container-option--width:85px;--snk-expression-group__container-condition--background-and:#66B6A0;--snk-expression-group__container-condition--background-or:#EBC65E;--snk-expression-group__container-expression--padding-left:26px;--snk-expression-group__background-color-dashed:var(--background--body, #fafcff);--ez-text-input__margin-bottom:0px}.snk-expression-group__container-condition.sc-snk-expression-group{width:var(--snk-expression-group--container-condition--width);height:var(--snk-expression-group--container-condition--height);border-radius:var(--snk-expression-group--container-condition--border-radius);z-index:var(--more-visible--2x, 3);padding:var(--space--nano, 2px)}.snk-expression-group__container-option.sc-snk-expression-group{width:var(--snk-expression-group--container-option--width)}.snk-expression-group__container-condition[data-condition="AND"].sc-snk-expression-group{background-color:var(--snk-expression-group__container-condition--background-and)}.snk-expression-group__container-condition[data-condition="OR"].sc-snk-expression-group{background-color:var(--snk-expression-group__container-condition--background-or)}.snk-expression-group__container-expression.sc-snk-expression-group{padding-left:var(--snk-expression-group__container-expression--padding-left)}.dashes.sc-snk-expression-group{z-index:var(--visible, 1);background:var(--snk-expression-group__background-color-dashed);border-left:2px dashed var(--text-secondary, #A2ABB9);position:absolute;width:15px;height:58px;margin-left:-15px;margin-top:-36.5px}.horizontal-dashes.sc-snk-expression-group{z-index:var(--more-visible, 2);border-bottom:2px dashed var(--text-secondary, #A2ABB9);position:absolute;width:15px;height:54px;margin-left:-15px;margin-top:-33.5px}.hidden.sc-snk-expression-group{display:none}';const k=[{label:"snkPersonalizedFilter.operands.equal",value:"EQUAL"},{label:"snkPersonalizedFilter.operands.different",value:"DIFFERENT"},{label:"snkPersonalizedFilter.operands.like",value:"LIKE"},{label:"snkPersonalizedFilter.operands.in",value:"IN"},{label:"snkPersonalizedFilter.operands.startWith",value:"START_WITH"},{label:"snkPersonalizedFilter.operands.finishedWith",value:"FINISHED_WITH"},{label:"snkPersonalizedFilter.operands.null",value:"NULL"},{label:"snkPersonalizedFilter.operands.notNull",value:"NOT_NULL"}],_=k.concat([{label:"snkPersonalizedFilter.operands.larger",value:"LARGER"},{label:"snkPersonalizedFilter.operands.largerEqual",value:"LARGER_EQUAL"},{label:"snkPersonalizedFilter.operands.smaller",value:"SMALLER"},{label:"snkPersonalizedFilter.operands.smallerEqual",value:"SMALLER_EQUAL"}]),f=k,z=[c.SEARCH,c.SHORTTEXT,c.PASSWORD,c.MASKEDTEXT,c.LONGTEXT,c.HTML],F=class{constructor(s){e(this,s),this.ezFilterItemChange=i(this,"ezFilterItemChange",7),this.ezFilterItemRemove=i(this,"ezFilterItemRemove",7),this.application=d.getContextValue("__SNK__APPLICATION__"),this.filterOperandDefault=_,this.filterOperandTypeTextSearch=f,this.DEFAULT_FIELD_NAME="NOT_DEFINED",this._showValueVariable=!1,this._fieldSelected=void 0,this._optionNotNull=!1,this.expression=void 0,this.canRemove=!0,this.messagesBuilder=void 0,this.isDefaultFilter=!1,this.entityURI=void 0}expressionChanged(e,i){e!==i&&(this.ezFilterItemChange.emit(e),this.updateFieldSelected())}componentWillLoad(){this._dataSourceFetcher=x.get(`filterFieldsDataSource.${this.entityURI}`),x.onChange(`filterFieldsDataSource.${this.entityURI}`,(()=>{this._dataSourceFetcher=x.get(`filterFieldsDataSource.${this.entityURI}`)})),this.expression&&(this.updateFieldSelected(),this._optionNotNull="NULL"===this.expression.operand||"NOT_NULL"===this.expression.operand)}componentDidRender(){var e;this._showValueVariable=null===(e=this._elValueVariable)||void 0===e?void 0:e.value}updateFieldSelected(){const e={dataType:this.expression.type,description:this.expression.description,name:this.expression.fieldName,label:this.expression.fieldLabel,entityName:this.expression.entityName,onlyDate:!1,path:this.expression.description,properties:this.expressionPropsToFieldProps(this.expression.props),type:v.FIELD,uri:"",userInterface:this.expression.userInterface};this._fieldSelected=e}buildExpression(e,i,s){return s.length>0&&s.shift(),s.length>0?`${s.join("->")}->${i}`:`${e}.${i}`}setValueExpression(e,i){"fieldName"===e?(this.expression.description=i.path,this.expression.expression=this.buildExpression(i.entityName,i.name,i.entityPath),this.expression.fieldName=i.name,this.expression.fieldLabel=i.label,this.expression.type=i.dataType,this.expression.userInterface=i.userInterface,this.expression.entityName=i.entityName,this.expression.value=void 0,this.expression.props=this.fieldPropsToExpressionProps(i.properties)):this.expression[e]=i,this.expressionChanged(this.expression)}fieldPropsToExpressionProps(e){const i=[];if(!e)return i;for(const s in e){let t=e[s];"object"==typeof t&&(t=JSON.stringify(t)),i.push({name:s,value:t})}return i}expressionPropsToFieldProps(e){const i={};return e?(e.forEach((e=>{try{i[e.name]=JSON.parse(e.value)}catch(s){i[e.name]=e.value}})),i):i}getMessage(e,i){return this.application.messagesBuilder.getMessage(e,i)}handleSelectItem(e){if(this.hasNoChanges(e))this._elFilterInput.value=e.path;else if(e.type===v.FIELD){const i=e;this._fieldSelected=i,this.setValueExpression("fieldName",i)}}hasNoChanges(e){return e.name===this.expression.fieldName&&e.path===this.expression.description}handleFocus(){this._elFilterFieldSearch&&this._elFilterFieldSearch.show()}handleChangeFilterInput(e){this._elFilterFieldSearch.applyFilter(e.detail)}handleChangeValueVariable(e){this._showValueVariable=e,this._elFieldDynamic&&(this._elFieldDynamic.value=void 0,this._elFieldDynamic.enabled=!e),this.expression.paramVariable=e,this.expressionChanged(this.expression)}openSnkFilterParamConfig(){var e;null===(e=this._elFilterParamConfigRef)||void 0===e||e.open(this.expression).then(this.onOpenPromiseReady.bind(this)).catch((e=>{console.error(e)}))}onOpenPromiseReady(e){this.expression=e}buildOptionsOperator(){var e;return z.includes(null===(e=this._fieldSelected)||void 0===e?void 0:e.userInterface)?this.translateOperandOptions(this.filterOperandTypeTextSearch):this.translateOperandOptions(this.filterOperandDefault)}translateOperandOptions(e){return e.map((e=>({label:this.getMessage(e.label),value:e.value})))}handleChangeOperator(e){this.checkOptionIsNull(e),this.setValueExpression("operand",e)}checkOptionIsNull(e){[a.NULL,a.NOT_NULL].includes(a[e])?(this._optionNotNull=!0,this._elFieldDynamic&&(this._elFieldDynamic.enabled=!1,this._elFieldDynamic.value=void 0)):(this._optionNotNull=!1,this._elFieldDynamic&&(this._elFieldDynamic.enabled=!this._showValueVariable))}confirmRemove(e){e.preventDefault(),e.stopPropagation(),l.confirm(this.getMessage("snkPersonalizedFilter.confirmExpression.title"),this.getMessage("snkPersonalizedFilter.confirmExpression.description")).then((e=>{e&&this.ezFilterItemRemove.emit(this.expression)}))}buildFieldByType(){var e,i,t;if(!this._fieldSelected)return;const n=null===(e=m(this.configureFieldByType()))||void 0===e?void 0:e.i.shift();return(this._optionNotNull&&n||(null===(i=this._elValueVariable)||void 0===i?void 0:i.value)&&n||this.expression.paramVariable||this._showValueVariable||!(null===(t=this._fieldSelected)||void 0===t?void 0:t.dataType))&&(n.t.enabled=!1),null!=this.expression.value&&(n.t.value=this.getExpressiontValue(this.expression)),n.t.onEzChange=e=>{this.setValueExpression("value",e.target.value)},"SWITCH"===this.expression.userInterface&&null==this.expression.value&&this.setValueExpression("value",!1),s(n.o,Object.assign(Object.assign({},n.t),{ref:e=>{this._elFieldDynamic=e},label:this.expression.fieldLabel||this._fieldSelected.label}))}getExpressiontValue(e){return b(e.type,e.value)}configureFieldByType(){var e,i;const s={userInterface:this._fieldSelected.userInterface,name:this._fieldSelected.name,label:this._fieldSelected.label,canShowError:!1};switch(s.userInterface){case c.OPTIONSELECTOR:s.props={options:null===(i=null===(e=this._fieldSelected)||void 0===e?void 0:e.properties)||void 0===i?void 0:i.options};break;case c.LONGTEXT:s.rows=1;break;case c.SEARCH:s.optionLoader=e=>this.setCriteriaSearch(e,this.application)}return s}setCriteriaSearch({mode:e,argument:i},s){var t,n,o;if(null==s)return;const r={entity:null!==(o=null===(n=null===(t=this._fieldSelected)||void 0===t?void 0:t.properties)||void 0===n?void 0:n.ENTITYNAME)&&void 0!==o?o:this._fieldSelected.entityName,searchOptions:{showInactives:!1},entityDescription:this._fieldSelected.description};return s.executePreparedSearch(e,i,r)}render(){var e;return s(n,null,s("div",{class:"dashes"}),s("div",{class:"box"},s("div",{class:"box__container"},s("div",{class:"box__container--input-filter"},s("ez-filter-input",Object.assign({ref:e=>this._elFilterInput=e,value:null===(e=this._fieldSelected)||void 0===e?void 0:e.path,label:this.getMessage("snkPersonalizedFilter.info.labelSearchField"),canShowError:!1,onEzChange:e=>this.handleChangeFilterInput(e),onFocus:()=>this.handleFocus()},{[u.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`expressionFilterInput_${this.expression.fieldName||this.DEFAULT_FIELD_NAME}`})),s("snk-filter-field-search",{ref:e=>this._elFilterFieldSearch=e,searchable:!1,onEzSelectFilterItem:e=>this.handleSelectItem(e.detail),fieldsDataSource:this._dataSourceFetcher})),s("div",{class:"box__container--input-operator"},s("ez-combo-box",Object.assign({label:this.getMessage("snkPersonalizedFilter.info.labelOperator"),value:this.expression.operand,canShowError:!1,options:this.buildOptionsOperator(),onEzChange:e=>{var i;return this.handleChangeOperator(null===(i=e.detail)||void 0===i?void 0:i.value)},suppressEmptyOption:!0},{[u.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`comboBoxOperand_${this.expression.fieldName||this.DEFAULT_FIELD_NAME}`}))),s("div",{class:"box__container--input-value"},this._fieldSelected?this.buildFieldByType():s("ez-number-input",{label:this.getMessage("snkPersonalizedFilter.info.labelDefaultValue"),canShowError:!1,enabled:!this._showValueVariable&&!this._optionNotNull})),s("div",{class:"box__container--input-value-variable"},!this._optionNotNull&&s("ez-tooltip",{message:this.getMessage("snkPersonalizedFilter.info.checkVariableDisabled"),active:this.isDefaultFilter},s("ez-check",{ref:e=>this._elValueVariable=e,value:this.expression.paramVariable,label:this.getMessage("snkPersonalizedFilter.info.labelValueVarible"),mode:h.SWITCH,onEzChange:e=>this.handleChangeValueVariable(e.detail),enabled:!this.isDefaultFilter})),this._showValueVariable&&!this._optionNotNull&&s("ez-icon",Object.assign({class:"box__container--input-value-variable--icon",size:"large",iconName:"settings-inverted"},{[u.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:"iconConfig"},{title:this.getMessage("snkPersonalizedFilter.info.titleTooltip"),onClick:()=>this.openSnkFilterParamConfig()})),s("snk-filter-param-config",{ref:e=>this._elFilterParamConfigRef=e,messagesBuilder:this.messagesBuilder})),s("div",{class:"box__container--button-delete"},s("div",{class:"box__container--button-delete--icon"},s("ez-button",{mode:"icon",iconName:"delete",enabled:this.canRemove,label:this.getMessage("snkPersonalizedFilter.info.labelDeleteItem"),onClick:e=>this.confirmRemove(e)}))))))}static get watchers(){return{expression:["expressionChanged"]}}};F.style=".sc-snk-expression-item-h{display:flex;width:100%;--snk-expression-item--background-color:var(--background--xlight, #fff);--snk-expression-item__itens--padding:var(--space--small, 6px);--snk-expression-item__width--input-operator:220px;--snk-expression-item__width--input-value:240px;--snk-expression-item__width--input-value-variable:176px;--snk-expression-item--border-radius:var(--border--radius-medium, 12px);--snk-expression-item--border-color:var(--color--strokes, #DCE0E8);--snk-expression-item--border-style:var(--border--small, 1px solid);--snk-expression-item__background-color-dashed:var(--background--body, #fafcff)}.box.sc-snk-expression-item{width:100%;height:56px;background:var(--snk-expression-item--background-color);border:var(--snk-expression-item--border-color) var(--snk-expression-item--border-style);border-radius:var(--snk-expression-item--border-radius)}.box__container.sc-snk-expression-item{display:flex;align-items:center;justify-content:space-between;white-space:nowrap;margin:var(--space--small, 6px)}.box__container--input-filter.sc-snk-expression-item{width:100%}.box__container--input-operator.sc-snk-expression-item{display:flex;width:var(--snk-expression-item__width--input-operator);min-width:var(--snk-expression-item__width--input-operator)}.box__container--input-value.sc-snk-expression-item{display:flex;width:var(--snk-expression-item__width--input-value);min-width:var(--snk-expression-item__width--input-value)}.box__container--input-value-variable.sc-snk-expression-item{display:flex;width:var(--snk-expression-item__width--input-value-variable);min-width:var(--snk-expression-item__width--input-value-variable)}.box__container--button-delete.sc-snk-expression-item{display:flex}.box__container.sc-snk-expression-item>div.sc-snk-expression-item{padding-left:var(--snk-expression-item__itens--padding);padding-right:var(--snk-expression-item__itens--padding)}.box__container--button-delete--icon.sc-snk-expression-item{width:42px;min-width:42px}.box__container--input-value-variable--icon.sc-snk-expression-item{cursor:pointer}.dashes.sc-snk-expression-item{z-index:var(--more-visible, 2);background:var(--snk-expression-item__background-color-dashed);border-bottom:2px dashed var(--text-secondary, #A2ABB9);border-left:2px dashed var(--text-secondary, #A2ABB9);position:absolute;width:15px;height:62px;margin-left:-15px;margin-top:-33.5px}";export{g as snk_expression_group,F as snk_expression_item}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as o,c as r,h as t,g as i}from"./p-
|
|
1
|
+
import{r as o,c as r,h as t,g as i}from"./p-82bb3eda.js";import{ApplicationContext as n}from"@sankhyalabs/core";import{V as s}from"./p-9019a32f.js";import{A as a}from"./p-dc36cfbf.js";const l=class{constructor(t){o(this,t),this.configSelected=r(this,"configSelected",7),this.openConfig=r(this,"openConfig",7),this.save=r(this,"save",7),this.cancel=r(this,"cancel",7),this._opened=!1,this._permissions=void 0,this.showActionButtons=!1,this.configName=void 0,this.resourceID=void 0,this.viewMode=s.GRID,this.customContainerId=void 0,this.layoutFormConfig=!0,this.entityName=void 0,this.disableNumberingConfig=!1,this.messagesBuilder=void 0}async open(){this._opened=!0,this.configSelected.emit(this.getViewModeValue()),this.modal.heightMode="full"}async close(){this.closeConfig()}closeConfig(){this._opened=!1}onViewModeChanged(o){this.viewMode=null==o?void 0:o.detail,this.configSelected.emit(this.viewMode)}onClickOpenConfig(){this.openConfig.emit(this.viewMode)}isAllowed(o){return!a[o]||!!this._permissions&&(this._permissions.isSup||this._permissions[o])}enableModeConfig(){return!(!this.isAllowed(a.CONFIG_GRID)||!this.isAllowed(a.CONFIG))}getViewModeValue(){return null!=this._permissions&&(this.isAllowed(a.CONFIG_GRID)?this.isAllowed(a.CONFIG)||(this.viewMode=s.GRID):this.viewMode=s.FORM),this.viewMode}getMessage(o){var r;return null===(r=this.messagesBuilder)||void 0===r?void 0:r.getMessage(o,{})}async handleSave(){var o;(this.disableNumberingConfig||await(null===(o=this._snkNumberingConfig)||void 0===o?void 0:o.save()))&&(this.layoutFormConfig&&this._snkLayoutFormConfig.save(),this.save.emit())}componentWillLoad(){this._application=n.getContextValue("__SNK__APPLICATION__"),this._application?this._application.getAllAccess(this.resourceID).then((o=>this._permissions=o)):this._permissions={}}componentDidRender(){if(!this.customContainerId)return;const o=document.querySelector(`#${this.customContainerId}`),r=null==o?void 0:o.querySelector("#SnkConfigContainerSlot");if(!r)return;const t=r.firstElementChild;if(!t)return;const i=this._element.querySelector("#slotContainer");null==i||i.appendChild(t)}render(){return t("ez-modal",{ref:o=>this.modal=o,opened:this._opened,"close-esc":!1,"close-outside-click":!1,"modal-size":"small",scrim:"light",onEzCloseModal:()=>this.closeConfig()},t("div",{class:"snk-configurator"},t("div",{class:"snk-configurator__header"},t("label",{class:"snk-configurator__title"},this.getMessage("snkConfigurator.titleConfigurations")),t("div",{class:"snk-configurator__button-close"},t("ez-button",{mode:"icon",iconName:"close",size:"medium",onClick:()=>this.closeConfig()}))),t("div",{class:"snk-configurator__main"},t("ez-collapsible-box",{boxBordered:!0,label:this.getMessage("snkConfigurator.subTitleModeConfig"),headerSize:"medium",class:"snk-configurator__collapsable-box"},t("ez-radio-button",{value:this.getViewModeValue().toString(),onEzChange:o=>this.onViewModeChanged(o),enabled:this.enableModeConfig()},t("ez-radio-button-option",{label:this.getMessage("snkConfigurator.labelGrid"),value:s.GRID}),t("ez-radio-button-option",{label:this.getMessage("snkConfigurator.labelForm"),value:s.FORM})),t("div",{class:"snk-configurator__collsable-box-action"},t("ez-button",{label:this.getMessage(this.viewMode===s.GRID?"snkConfigurator.labelConfigGrid":"snkConfigurator.labelConfigForm"),class:"snk-configurator__button-config ez-button--secondary",onClick:()=>this.onClickOpenConfig(),id:"openConfigurator"}))),this.layoutFormConfig&&t("ez-collapsible-box",{boxBordered:!0,value:!0,label:this.getMessage("snkConfigurator.labelLayoutForm"),headerSize:"medium",class:"snk-configurator__collapsable-box ez-margin-top--medium"},t("div",{class:"ez-flex ez-flex--column ez-size-width--full"},t("snk-layout-form-config",{ref:o=>this._snkLayoutFormConfig=o,messagesBuilder:this.messagesBuilder}))),!this.disableNumberingConfig&&t("ez-collapsible-box",{boxBordered:!0,value:!0,label:this.getMessage("snkConfigurator.labelNumberingConfig"),headerSize:"medium",class:"snk-configurator__collapsable-box ez-margin-top--medium"},t("div",{class:"ez-flex ez-flex--column ez-size-width--full"},t("snk-numbering-config",{ref:o=>this._snkNumberingConfig=o,messagesBuilder:this.messagesBuilder,entityName:this.entityName,resourceID:this.resourceID}))),t("div",{id:"slotContainer",class:"snk-configurator__outline"})),this.showActionButtons&&t("div",{class:"snk-configurator__action-buttons"},t("ez-button",{label:this.getMessage("snkConfigurator.buttons.cancel"),onClick:()=>this.cancel.emit()}),t("ez-button",{label:this.getMessage("snkConfigurator.buttons.save"),onClick:()=>this.handleSave(),class:"ez-button--primary"}))))}get _element(){return i(this)}};l.style='.sc-snk-configurator-h{--snk-configurator__button-close--padding-left:var(--space--medium, 12px);--snk-configurator__title--color:var(--title--primary, #2B3A54);--snk-configurator__title--font-family:var(--font-pattern, "Roboto");--snk-configurator__title--font-size:var(--title--large, 20px);--snk-configurator__title--font-weight:var(--text-weight--extra-large, 700);--snk-configurator__subtitle--color:var(--title--primary, #2B3A54);--snk-configurator__subtitle--font-family:var(--font-pattern, "Roboto");--snk-configurator__subtitle--font-size:var(--text--medium, 14px);--snk-configurator__subtitle--font-weight:var(--text-weight--large, 600);--snk-configurator__scrollbar--color-default:var(--scrollbar--default, #626e82);--snk-configurator__scrollbar--color-background:var(--scrollbar--background, #E5EAF0);--snk-configurator__scrollbar--color-hover:var(--scrollbar--hover, #2B3A54);--snk-configurator__scrollbar--color-clicked:var(--scrollbar--clicked, #a2abb9);--snk-configurator__scrollbar--border-radius:var(--border--radius-small, 6px);--snk-configurator__scrollbar--width:var(--space--small, 6px)}.snk-configurator.sc-snk-configurator{display:grid;grid-template-rows:auto 1fr auto;max-height:100%;width:100%}.snk-configurator__collsable-box-action.sc-snk-configurator{width:100%}.snk-configurator__action-buttons.sc-snk-configurator{display:flex;flex-direction:row;justify-content:flex-end;gap:var(--space--medium)}.snk-configurator__outline.sc-snk-configurator{display:flex;flex-direction:column;gap:var(--space--small);margin-top:var(--space--small);margin-bottom:var(--space--large)}@media screen and (min-width: 480px){.snk-configurator.sc-snk-configurator{width:359px;max-width:359px}}.snk-configurator__button-config.sc-snk-configurator{--ez-button--min-width:100%}.snk-configurator__header.sc-snk-configurator{display:flex;justify-content:space-between;align-items:center;width:100%}.snk-configurator__title.sc-snk-configurator{display:flex;margin:0;line-height:normal;letter-spacing:0em;text-align:left;color:var(--snk-configurator__title--color);font-size:var(--snk-configurator__title--font-size);font-family:var(--snk-configurator__title--font-family);font-weight:var(--snk-configurator__title--font-weight)}.snk-configurator__subtitle.sc-snk-configurator{display:flex;margin:0;padding-top:var(--space--medium);padding-bottom:var(--space--small);color:var(--snk-configurator__subtitle--color);font-size:var(--snk-configurator__subtitle--font-size);font-family:var(--snk-configurator__subtitle--font-family);font-weight:var(--snk-configurator__subtitle--font-weight)}.snk-configurator__button-close.sc-snk-configurator{padding-left:var(--snk-configurator__button-close--padding-left)}.snk-configurator__main.sc-snk-configurator{overflow-y:auto;scrollbar-width:thin;margin:var(--space--medium) 0;scrollbar-color:var(--snk-configurator__scrollbar--color-clicked) var(--snk-configurator__scrollbar--color-background)}.snk-configurator__main.sc-snk-configurator::-webkit-scrollbar{background-color:var(--snk-configurator__scrollbar--color-background);width:var(--snk-configurator__scrollbar--width);max-width:var(--snk-configurator__scrollbar--width);min-width:var(--snk-configurator__scrollbar--width)}.snk-configurator__main.sc-snk-configurator::-webkit-scrollbar-track{background-color:var(--snk-configurator__scrollbar--color-background);border-radius:var(--snk-configurator__scrollbar--border-radius)}.snk-configurator__main.sc-snk-configurator::-webkit-scrollbar-thumb{background-color:var(--snk-configurator__scrollbar--color-default);border-radius:var(--snk-configurator__scrollbar--border-radius)}.snk-configurator__main.sc-snk-configurator::-webkit-scrollbar-thumb:vertical:hover,.snk-configurator__main.sc-snk-configurator::-webkit-scrollbar-thumb:horizontal:hover{background-color:var(--snk-configurator__scrollbar--color-hover)}.snk-configurator__main.sc-snk-configurator::-webkit-scrollbar-thumb:vertical:active,.snk-configurator__main.sc-snk-configurator::-webkit-scrollbar-thumb:horizontal:active{background-color:var(--snk-configurator__scrollbar--color-clicked)}';export{l as snk_configurator}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,c as i,h as e,H as s,g as r}from"./p-
|
|
1
|
+
import{r as t,c as i,h as e,H as s,g as r}from"./p-82bb3eda.js";import{ElementIDUtils as o,ObjectUtils as a}from"@sankhyalabs/core";import{C as l}from"./p-1f310bc6.js";import{E as n}from"./p-1a68fb59.js";import{F as h}from"./p-ff1990ad.js";import{F as d}from"./p-b568c1d4.js";import"./p-7ee6b1bf.js";import"./p-6768f176.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";const p=class{constructor(e){t(this,e),this.filterChange=i(this,"filterChange",7),this.editPersonalizedFilter=i(this,"editPersonalizedFilter",7),this.addPersonalizedFilter=i(this,"addPersonalizedFilter",7),this.filterItem=void 0,this.configName=void 0,this.resourceID=void 0}getContentEditorConfig(){const t={presentationMode:n.MODAL};switch(this.filterItem.type){case h.BINARY_SELECT:return{tag:"snk-filter-binary-select",props:t};case h.MULTI_SELECT:return{tag:"snk-filter-multi-select"};case h.PERIOD:return{tag:"snk-filter-period",props:t};case h.SEARCH:return{tag:"snk-filter-search"};case h.NUMBER:return{tag:"snk-filter-number",props:t};case h.PERSONALIZED:return this.buildSnkFilterPersonalizedProps();case h.CHECK_BOX_LIST:return{tag:"snk-filter-checkbox-list",props:t};case h.MULTI_LIST:return{tag:"snk-entity-list",props:{maxHeightList:"640px",rightListSlotBuilder:t=>this.buildRightSlot(t)}}}return{tag:"snk-filter-text"}}buildSnkFilterPersonalizedProps(){return{tag:"snk-personalized-filter-editor",props:{onEditFilter:t=>this.editPersonalizedFilter.emit(t.detail),onAddFilter:()=>this.addPersonalizedFilter.emit()}}}isVisible(t){return!!this.filterItem.visible||void 0!==t}updateFilterValue(t){var i,e;const s=void 0!==(null==t?void 0:t.value)?t.value:t;this.filterItem=Object.assign(Object.assign({},this.filterItem),null!=this.filterItem.groupedItems?{visible:s>0,value:s,groupedItems:t.items}:{value:this.filterItem.type===(h.SEARCH||h.CHECK_BOX_LIST)?t:s,visible:this.isVisible(s)}),this._editor&&(this._editor.config=this.filterItem),null===(e=null===(i=this._editor)||void 0===i?void 0:i.reloadList)||void 0===e||e.call(i),this.filterChange.emit(this.filterItem)}handleDeleteFilter(t,i){i===h.PERSONALIZED&&l.removePersonalizedFilter(t,this.resourceID,this.configName)}componentDidLoad(){if(this._element){o.addIDInfo(this._element);const t=this._element.getAttribute(o.DATA_ELEMENT_ID_ATTRIBUTE_NAME);this._idContentEditor=`${t}_${this.filterItem.id}`}}buildRightSlot(t){return e("ez-icon",{iconName:"delete",onClick:()=>this.removeValueFromConfig(t)})}removeValueFromConfig(t){var i,e,s;const r=null===(e=null===(i=this.filterItem)||void 0===i?void 0:i.value)||void 0===e?void 0:e.findIndex((({id:i})=>i===t.id)),o=a.copy(this.filterItem);null===(s=null==o?void 0:o.value)||void 0===s||s.splice(r,1),this.updateFilterValue(o.value)}canShowDetailModal(){const{CUSTOM_FILTER:t,OTHER_FILTERS:i}=d;return![t,i].includes(this.filterItem.filterType)&&this.filterItem.type!==h.BINARY_SELECT}render(){const{tag:t,props:i}=this.getContentEditorConfig();return e(s,null,e("div",{class:"ez-flex ez-flex--column grow"},this.canShowDetailModal()&&e("label",{class:"ez-text ez-text--medium ez-text--primary ez-margin-bottom--extra-small",htmlFor:`filter-item-${this.filterItem.id}`},this.filterItem.detailModal),e(t,Object.assign({ref:t=>this._editor=t,id:`filter-item-${this.filterItem.id}`,config:this.filterItem,value:this.filterItem.value,onValueChanged:t=>this.updateFilterValue(t.detail),"data-element-id":this._idContentEditor},i))))}get _element(){return r(this)}};p.style=".grow{flex-grow:1}.gap{gap:4px}";export{p as snk_filter_modal_item}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,c as i,h as e,H as s,g as r,f as l}from"./p-d8d8169b.js";import{DataType as a,StringUtils as n,ObjectUtils as o,ElementIDUtils as h,ErrorException as d,ApplicationContext as c,LockManager as u,LockManagerOperation as f,DateUtils as m,MaskFormatter as p,KeyboardManager as v,FloatingManager as b,ArrayUtils as g}from"@sankhyalabs/core";import{EzScrollDirection as k}from"@sankhyalabs/ezui/dist/collection/components/ez-scroller/EzScrollDirection";import{C as _}from"./p-1f310bc6.js";import{P as F}from"./p-988afe78.js";import{toString as y}from"@sankhyalabs/core/dist/dataunit/metadata/DataType";import{F as z}from"./p-ff1990ad.js";import{F as x,D as w}from"./p-84345e7a.js";import{F as C}from"./p-fa80e546.js";import{ModalAction as I}from"@sankhyalabs/ezui/dist/collection/components/ez-modal-container";import{ApplicationUtils as $}from"@sankhyalabs/ezui/dist/collection/utils";import{A as N}from"./p-6a4b21dd.js";import{F as T}from"./p-b568c1d4.js";import{g as L}from"./p-76e66fd9.js";import"./p-7ee6b1bf.js";import"./p-6768f176.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";function A(t){let i="";return t.forEach(((t,e)=>{var s;i+=` ${e>0?null!==(s=t.operand)&&void 0!==s?s:"OR":""} ${t.expression}`})),i.trim()}const P=class{constructor(e){t(this,e),this.configUpdated=i(this,"configUpdated",7),this._updateSequence=[],this._loadingPending=!1,this._configUpdated=!1,this._firstLoad=!0,this._pendingVariables=!1,this._isDefaultFilter=!1,this._customfiltersToBeUpdated=[],this._resolveLoading=void 0,this._calculateSortIndex=t=>{if(!t.visible)return 0;if(t.hardFixed)return 1e6;let i=t.fixed?1e5:0;return i+=this.hasValidValue(t)?1e4:0,i+=this._updateSequence.lastIndexOf(t.id)+1,i},this._filtersComparator=(t,i)=>this._calculateSortIndex(i)-this._calculateSortIndex(t),this.enableLockManagerLoadingComp=!1,this.customFilterBarConfig=void 0,this.dataUnit=void 0,this.title=void 0,this.configName=void 0,this.resourceID=void 0,this.mode="regular",this.filterConfig=void 0,this.messagesBuilder=void 0,this.disablePersonalizedFilter=void 0,this.filterBarLegacyConfigName=void 0,this.autoLoad=void 0,this.afterApplyConfig=void 0,this.filterCustomConfig=void 0,this.filterCustomConfigInterceptor=void 0,this.allowDefault=void 0,this.scrollerLocked=!1,this.showPersonalizedFilter=!1,this.personalizedFilterId=void 0,this.isFilterModalOpen=!1}hasValidValue(t){var i,e;return null!=t.value&&(t.type===z.PERIOD?!!(null===(i=t.value)||void 0===i?void 0:i.start)||!!(null===(e=t.value)||void 0===e?void 0:e.end):!!t.groupedItems||!Array.isArray(t.value)||t.value.some((t=>!0===t.check)))}observeFilterConfig(t,i){o.equals(t,i)||this.handleFilterConfigsChanged(i,t)}handleFilterConfigsChanged(t,i){if(null!=t&&null==i)this._loadingPending=!0,this._configUpdated=!0;else{const e=new Map(t?t.map((t=>[t.id,t])):void 0);0===e.size&&i.length>0?(this._loadingPending=!0,this._configUpdated=!1):i.forEach((t=>{const i=e.get(t.id);if(null!=i){if(this._configUpdated=this._configUpdated||o.objectToString(i)!=o.objectToString(t),this._loadingPending=this._loadingPending||o.objectToString(i.value)!==o.objectToString(t.value),!this._loadingPending){const e=o.objectToString(i.groupedItems)!=o.objectToString(t.groupedItems);this._configUpdated=this._configUpdated||e,this._loadingPending=this._loadingPending||e}}else this._configUpdated=!0,this._loadingPending=this._loadingPending||null!=t.value}))}(this._loadingPending||this._configUpdated)&&this.configUpdated.emit(i),this.processAfterUpdateConfig()}async reload(){this.loadConfigFromStorage(!0)}async getFilterItem(t){const i=this.filterConfig.find((i=>i.id===t));return Promise.resolve(o.copy(i))}async updateFilterItem(t){return-1==this.filterConfig.findIndex((i=>i.id===t.id))?(console.warn("[SnkFilterBar.updateFilterItem] "+this.getMessage("snkFilterBar.filterItem.updateFilterItemNotFound")),Promise.resolve()):(this._loadingPending=!0,this.updateFilter(t),Promise.resolve())}async addFilterItem(t){return this.filterConfig.findIndex((i=>i.id===t.id))>-1?(console.warn("[SnkFilterBar.addFilterItem] "+this.getMessage("snkFilterBar.filterItem.addFilterItemExists")),Promise.resolve()):(this.filterConfig.push(t),this._loadingPending=!0,this.updateFilter(t),Promise.resolve())}async removeFilterItem(t){const i=this.filterConfig.findIndex((i=>i.id===t));if(-1==i)return console.warn("[SnkFilterBar.removeFilterItem] "+this.getMessage("snkFilterBar.filterItem.removeFilterItemNotFound")),Promise.resolve(void 0);const e=this.filterConfig[i];return this.filterConfig=this.filterConfig.filter((i=>i.id!==t)),Promise.resolve(e)}componentDidLoad(){this._element&&h.addIDInfo(this._element,null,{dataUnit:this.dataUnit})}processPendingFilter(){if(this._pendingVariables){const t=this._element.querySelector("#filter-PERSONALIZED_FILTER_GROUP");t&&t.showUp(!0).then((()=>{this.processAfterUpdateConfig()}))}else this.processAfterUpdateConfig()}getPersonalizedFilterItem(){return this.filterConfig.find((t=>t.type===z.PERSONALIZED))}async processAfterUpdateConfig(){var t;if(this._loadingPending){if(await this._application.isLoadedByPk()&&!this._configUpdated)return;const t=this.getPersonalizedFilterItem();if(this._pendingVariables=!F.validateVariableValues(t),this._pendingVariables)return;this._loadingPending=!1,this.doLoadData()}this._configUpdated&&(this._configUpdated=!1,_.saveFilterBarConfig(this.filterConfig,this.configName,this.resourceID),null===(t=this.afterApplyConfig)||void 0===t||t.call(this))}async doLoadData(t=!1){try{if(this._firstLoad&&!1===this.autoLoad)return;if(this._firstLoad&&!t&&void 0===this.autoLoad&&!await this._application.getBooleanParam("global.carregar.registros.iniciar.tela"))return;this.dataUnit.loadData(void 0,void 0,!0)}finally{this._firstLoad=!1}}getMessage(t,i,e){var s;return null==this.messagesBuilder&&this._application&&(this.messagesBuilder=this._application.messagesBuilder),(null===(s=this.messagesBuilder)||void 0===s?void 0:s.getMessage(t,i))||e}async getFilters(){return this.getFilter(null)}getFilter(t){var i;const e=[];return null===(i=this.filterConfig)||void 0===i||i.filter((t=>this.isActiveFilter(t))).forEach((t=>{const i=(t=>{switch(t.type){case z.DEFAULT_FILTER:return function(t){return{name:t.id,expression:t.props.expression,params:[]}}(t);case z.BINARY_SELECT:return function(t){const{id:i,value:e,props:s}=t;return{name:i,expression:s.options.find((t=>t.name===e)).expression,params:[]}}(t);case z.MULTI_SELECT:return function(t){const{id:i,value:e,props:s}=t;return{name:i,expression:s.expression,params:[{name:i,dataType:a.TEXT,value:e}]}}(t);case z.MULTI_LIST:return function(t){const{id:i,value:e,props:s}=t,r=(null!==(o=null!==(n=null==(l=e)?void 0:l.elements)&&void 0!==n?n:null==l?void 0:l.members)&&void 0!==o?o:l).filter((t=>null==t?void 0:t.check)).map((({id:t})=>Number.isNaN(+t)?String(t):Number(t)));var l,n,o;if(r.length>0)return{name:i,expression:s.expression,params:[{name:i,dataType:a.TEXT,value:JSON.stringify(r)}]}}(t);case z.PERIOD:return function(t){const{id:i,value:e,props:s}=t;let{end:r,start:l}=e;"string"==typeof r&&(r=new Date(r)),"string"==typeof l&&(l=new Date(l));const n=[];let o;return r&&l?(o=s.expression.fullfill,n.push({name:`${i}.START`,dataType:a.DATE,value:y(a.DATE,l)},{name:`${i}.END`,dataType:a.DATE,value:y(a.DATE,r)})):l?(o=s.expression.onlystart,n.push({name:i,dataType:a.DATE,value:y(a.DATE,l)})):(o=s.expression.onlyend,n.push({name:i,dataType:a.DATE,value:y(a.DATE,r)})),{name:i,expression:o,params:n}}(t);case z.SEARCH:return function(t){const{id:i,value:e,props:s}=t;return{name:i,expression:s.expression,params:[{name:i,dataType:a.TEXT,value:y(a.TEXT,null==e?void 0:e.value)}]}}(t);case z.TEXT:return function(t){let{id:i,value:e,props:s}=t;const r=s.expression;var l,o;return n.isEmpty(s.likeAs)||(l=e,e="CONTANIS"===(o=s.likeAs)?`%${l}%`:"STARTS_WITH"===o?`${l}%`:"ENDS_WITH"===o?`%${l}`:l),{name:i,expression:r,params:[{name:i,dataType:a.TEXT,value:y(a.TEXT,e)}]}}(t);case z.NUMBER:return function(t){const{id:i,value:e,props:s}=t;if(s.variation===C.INTERVAL){const{start:t,end:r}=null!=e?e:{start:0,end:0};if(!isNaN(t)&&!isNaN(r))return{name:i,expression:s.intervalExpression.fullfill,params:[{name:`${i}.START`,dataType:a.NUMBER,value:y(a.NUMBER,t)},{name:`${i}.END`,dataType:a.NUMBER,value:y(a.NUMBER,r)}]};if(!isNaN(t))return{name:i,expression:s.intervalExpression.onlystart,params:[{name:i,dataType:a.NUMBER,value:y(a.NUMBER,t)}]};if(!isNaN(r))return{name:i,expression:s.intervalExpression.onlyend,params:[{name:i,dataType:a.NUMBER,value:y(a.NUMBER,r)}]}}return{name:i,expression:s.expression,params:[{name:i,dataType:a.NUMBER,value:y(a.NUMBER,e)}]}}(t);case z.PERSONALIZED:return function(t){const{id:i,groupedItems:e=[]}=t,s=e.filter((t=>!!t.visible)).map((t=>{var i;const e=t.props.expression,s=((null===(i=t.props.personalizedFilter)||void 0===i?void 0:i.parameters)||[]).map(((i,e)=>{const s=Array.from(t.value||0),r=i.dataType;let l=e>=0&&e<s.length?s[e]:null;return null!=l&&"object"==typeof l&&"value"in l&&(l=l.value),null==l&&r===a.BOOLEAN&&(l=!1),{name:i.name,dataType:r,value:"string"==typeof l?l:y(r,l)}}));return{expression:e,name:t.id,params:s}}));return{name:i,expression:s.map((t=>`(${t.expression})`)).join(` ${x.AND} `),params:s.flatMap((t=>t.params))}}(t);case z.CHECK_BOX_LIST:return function(t){var i;const{id:e,value:s,props:r}=t,l=Object.entries(null!=s?s:{}).filter((([t,i])=>!0===i)).map((([t,i])=>t));return{name:e,expression:A(null===(i=r.options)||void 0===i?void 0:i.filter((t=>l.includes(t.name)))),params:[]}}(t);default:return}})(t);i&&e.push(i)})),e}isActiveFilter(t){return t.type===z.DEFAULT_FILTER||this.filterActiveFilter(t)&&this.hasValidValue(t)}async registryFilterProvider(){this.dataUnit.addFilterProvider(this),this.filterConfig&&await this.doLoadData()}itemFocused(t){this._element.querySelectorAll("snk-filter-item,snk-filter-list").forEach((i=>{i.id===t?"snk-filter-item"===i.tagName.toLowerCase()&&i.getClientRects()[0].x<0&&i.scrollIntoView({behavior:"auto",inline:"nearest"}):i.hideDetail()}))}filterActiveFilter(t){return t.visible||t.removalBlocked}filterPersonalizedItems(t){return t.type===z.PERSONALIZED}getPersonalizedFilterVariableItems(){return this.filterConfig.filter(this.filterPersonalizedItems).map((t=>{const i=`filter-${t.id}`;return e("snk-filter-item",{key:t.id,id:i,config:Object.assign({},t),onFocusin:()=>this.itemFocused(i),onVisibleChanged:t=>this.scrollerLocked=t.detail,onFilterChange:t=>this.updateFilter(t.detail),getMessage:(t,i)=>this.getMessage(t,i),showChips:!1})}))}getFilterItems(){const t=[],i=[];this.filterConfig.sort(((t,i)=>this._filtersComparator(t,i))).filter(this.filterActiveFilter).forEach((s=>{const r=`filter-${(s=o.copy(s)).id}`,l=e("snk-filter-item",{onVisibleChanged:t=>this.scrollerLocked=t.detail,onFilterChange:t=>this.updateFilter(t.detail),onFocusin:()=>this.itemFocused(r),id:r,config:s,class:"ez-margin-horizontal--extra-small",getMessage:(t,i)=>this.getMessage(t,i),key:s.id});return s.fixed||s.hardFixed||s.required?t.push(l):i.push(l),l}));const s=[];return s.push(...t.reverse()),t.length>0&&i.length>0&&s.push(e("hr",{class:"ez-margin-horizontal--small ez-margin-vertical--auto ez-divider-vertical ez-divider--dark snk-filter-bar__divider"})),s.push(...i),s}calculateUpdateSequence(t){t&&(this._updateSequence=this._updateSequence.filter((i=>t.id!==i)),this._updateSequence.push(t.id))}normalizeItem(t){const i=Object.assign({},t);return["props","value","hardFixed","fixed"].forEach((t=>{null==i[t]&&delete i[t]})),""===t.value&&delete t.value,i}updateFilter(t){let i=this.filterConfig.map((i=>(t=this.normalizeItem(t),i.id===t.id?(o.objectToString(i)!=o.objectToString(t)&&this.calculateUpdateSequence(t),t):i))).sort(((t,i)=>this._filtersComparator(t,i)));this.filterCustomConfigInterceptor&&(i=this.filterCustomConfigInterceptor(i)),this.filterConfig=i}loadPermitions(){this._application.isUserSup().then((t=>this.allowDefault=t))}addFilterBarLegacyConfigName(){this.filterBarLegacyConfigName&&_.addFilterBarLegacyConfig(this.configName,this.filterBarLegacyConfigName)}async loadConfigFromStorage(t){try{let i;t&&await _.deleteFilterBarConfigCache(this.configName,this.resourceID),i=this.customFilterBarConfig?await this.customFilterBarConfig(this.configName,this.resourceID,{contextURI:this.dataUnit.name}):await _.loadFilterBarConfig(this.configName,this.resourceID,{contextURI:this.dataUnit.name}),this.filterCustomConfig&&(i=[...this.filterCustomConfig,...i]),this.filterCustomConfigInterceptor&&(i=this.filterCustomConfigInterceptor(i)),this.filterConfig=i.map((t=>this.normalizeItem(t))),this.filterConfig.sort(((t,i)=>this._filtersComparator(t,i)))}catch(t){throw new d(this.getMessage("snkFilterBar.failToLoadConfig"),t)}}async attachDataUnit(){if(null==this.dataUnit){let t=this._element.parentElement;for(;t;)if("SNK-DATA-UNIT"===t.tagName.toUpperCase()){const i=t;this.dataUnit=i.dataUnit,this.dataUnit?await this.registryFilterProvider():i.addEventListener("dataUnitReady",(async t=>{this.dataUnit=t.detail,await this.registryFilterProvider()}));break}t=t.parentElement}else await this.registryFilterProvider()}filterChangeListener(t){this.updateFilter(t.detail)}async showFilterModal(){this.isFilterModalOpen||(this.isFilterModalOpen=!0)}addPersonalizedFilter(t=!1){this.isFilterModalOpen=!1,this._isDefaultFilter=t,this.personalizedFilterId=void 0,this.showPersonalizedFilter=!0,window.requestAnimationFrame((()=>{this._elPersonalizedFilter.createPersonalizedFilter()}))}editPersonalizedFilter(t,i=!1){this.isFilterModalOpen=!1,this._isDefaultFilter=i,this.showPersonalizedFilter=!0,this.personalizedFilterId=t}deletePersonalizedFilter(t,i,e,s=!1){if(s)return _.removeDefaultFilter(t,this.resourceID,e),void(this._isDefaultFilter=!1);i===z.PERSONALIZED&&_.removePersonalizedFilter(t,this.resourceID,e)}closeFilterModal(){this.isFilterModalOpen=!1}applyFiltersFromModal(t){var i;this.filterConfig=t.map(this.normalizeItem).sort(((t,i)=>this._filtersComparator(t,i))),null===(i=this.afterApplyConfig)||void 0===i||i.call(this),this.isFilterModalOpen=!1}handleHidePersonalizedFilter(t){t?this.loadConfigFromStorage().then((()=>{this.hidePersonalizedFilter()})):this.hidePersonalizedFilter()}hidePersonalizedFilter(){this.personalizedFilterId=void 0,this.showPersonalizedFilter=!1,this._isDefaultFilter=!1}async componentWillLoad(){var t;try{if(this._application=c.getContextValue("__SNK__APPLICATION__"),await this.attachDataUnit(),this._application){if(this._application.enableLockManagerLoadingApp&&this.enableLockManagerLoadingComp){const t=u.addLockManagerCtxId(this._element);this._resolveLoading=u.lock(t,f.APP_LOADING)}await Promise.all([this.loadPermitions(),this.addFilterBarLegacyConfigName(),this.loadConfigFromStorage()])}}finally{null===(t=this._resolveLoading)||void 0===t||t.call(this)}}componentDidRender(){this.processPendingFilter()}render(){if(!this.dataUnit||!this.filterConfig||0===this.filterConfig.length)return;if(this.showPersonalizedFilter)return e("snk-personalized-filter",{class:"filter-bar__personalized-filter",filterId:this.personalizedFilterId,ref:t=>this._elPersonalizedFilter=t,isDefaultFilter:this._isDefaultFilter,onEzCancel:()=>this.handleHidePersonalizedFilter(!1),onEzAfterSave:()=>this.handleHidePersonalizedFilter(!0),entityUri:this.dataUnit.name,configName:this.configName,resourceID:this.resourceID});let t=o.copy(this.filterConfig);return t=t.sort(((t,i)=>t.originOrder-i.originOrder)),"regular"!==this.mode?e(s,{"data-mode":this.mode},this.getPersonalizedFilterVariableItems(),"button"===this.mode&&e("ez-button",{class:"ez-margin-left--medium",size:"small",label:this.getMessage("snkFilterBar.filters",void 0,this.getMessage("snkFilterBar.filters")),onClick:this.showFilterModal.bind(this)}),e("snk-filter-modal",{opened:this.isFilterModalOpen,filterConfig:this.filterConfig,configName:this.configName,disablePersonalizedFilter:this.disablePersonalizedFilter,getMessage:(t,i)=>this.getMessage(t,i),applyFilters:t=>this.applyFiltersFromModal(t),closeModal:()=>this.closeFilterModal(),addPersonalizedFilter:t=>this.addPersonalizedFilter(t),editPersonalizedFilter:(t,i)=>this.editPersonalizedFilter(t,i),deletePersonalizedFilter:(t,i,e)=>this.deletePersonalizedFilter(t,z.PERSONALIZED,i,e),filterCustomConfigInterceptor:this.filterCustomConfigInterceptor})):e(s,null,e("div",null,e("span",{class:"snk-filter-bar__title",title:this.title,"data-tooltip":this.title,"data-flow":"bottom"},this.title)),e("ez-scroller",{class:"snk-filter-bar__scroller",direction:k.HORIZONTAL,activeShadow:!0,locked:this.scrollerLocked},e("section",{class:"snk-filter-bar__filter-item-container"},this.getFilterItems())),e("ez-button",{class:"ez-padding-left--medium ez-margin-top--extra-small",size:"small",label:this.getMessage("snkFilterBar.filters",void 0,this.getMessage("snkFilterBar.filters")),onClick:this.showFilterModal.bind(this)},e("ez-icon",{slot:"leftIcon",iconName:"plus",class:"ez-padding-right--small"})),e("snk-filter-modal",{opened:this.isFilterModalOpen,filterConfig:this.filterConfig,configName:this.configName,disablePersonalizedFilter:this.disablePersonalizedFilter,getMessage:(t,i)=>this.getMessage(t,i),applyFilters:t=>this.applyFiltersFromModal(t),closeModal:()=>this.closeFilterModal(),addPersonalizedFilter:t=>this.addPersonalizedFilter(t),editPersonalizedFilter:(t,i)=>this.editPersonalizedFilter(t,i),deletePersonalizedFilter:(t,i,e)=>this.deletePersonalizedFilter(t,z.PERSONALIZED,i,e),filterCustomConfigInterceptor:this.filterCustomConfigInterceptor}))}get _element(){return r(this)}static get watchers(){return{filterConfig:["observeFilterConfig"]}}};P.style='.sc-snk-filter-bar-h{display:grid;grid-template-columns:1fr minmax(100px, 100%) 1fr 1fr;--snk-personalized-filter--z-index:var(--elevation--20, 20);--snk-personalized-filter--background-color:var(--background--xlight, #fff)}.snk-filter-bar__title.sc-snk-filter-bar{max-width:260px;display:inline-block;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;font-size:16px;font-family:var(--font-pattern, Arial);font-weight:var(--text-weight--large, 600);color:var(--color--title-primary, #2B3A54);margin-top:12px}[data-mode="hidden"].sc-snk-filter-bar-h{width:0px;height:0px}[data-mode="button"].sc-snk-filter-bar-h{grid-template-columns:1fr;width:fit-content}.snk-filter__popover-container.sc-snk-filter-bar{display:flex;cursor:auto}.filter-bar__personalized-filter.sc-snk-filter-bar{display:flex;flex-direction:column;position:fixed;top:0;left:0;width:100%;height:100%;overflow:auto;z-index:var(--snk-personalized-filter--z-index);background-color:var(--snk-personalized-filter--background-color)}.snk-filter__popover.sc-snk-filter-bar{display:flex;flex-direction:column;position:absolute;width:fit-content;height:fit-content;min-width:265px;background-color:var(--background--xlight, #fff);border-radius:var(--border--radius-medium, 12px);box-shadow:var(--shadow, 0px 0px 16px 0px #000)}.snk-filter-item__editor-header.sc-snk-filter-bar{flex-grow:1;font-weight:var(--text-weight--medium, 400);color:var(--color--title-primary, #2B3A54)}.snk-filter__popover-rule.sc-snk-filter-bar{border-style:solid;border-color:var(--color--disable-secondary, #F2F5F8);border-radius:1px;border-width:1px;width:100%}.editor__ez-check.sc-snk-filter-bar{--ez-check__label--padding-left:0}.snk-filter-item__editor-header-button.sc-snk-filter-bar{cursor:pointer;background-color:transparent;border:none;padding:3px;outline-color:var(--color--primary)}.snk-filter-bar__divider.sc-snk-filter-bar{margin-bottom:var(--space--small);height:80%}.snk-filter-bar__filter-item-container.sc-snk-filter-bar{display:flex;align-items:start;margin:var(--space--2, 2px) 0}.snk-filter-bar__scroller.sc-snk-filter-bar .sc-snk-filter-bar:first-child{margin-left:var(--space-extra-small, 3px)}.snk-filter-bar__filter-list-items-container.sc-snk-filter-bar{overflow-y:auto;max-height:360px;margin-top:var(--space--small, 6px)}.snk-filter-bar__filter-list-item.sc-snk-filter-bar{cursor:pointer;border-radius:var(--border--radius-small, 6px);border:none;background-color:transparent}.snk-filter-bar__filter-list-item__label.sc-snk-filter-bar{color:var(--title--primary)}.snk-filter-bar__filter-list-item__label--secondary.sc-snk-filter-bar{color:var(--text--primary)}.snk-filter-bar__filter-list-item__icon.sc-snk-filter-bar{--ez-icon--color:var(--title--primary)}.snk-filter-bar__filter-list-item__icon--secondary.sc-snk-filter-bar{--ez-icon--color:var(--text--secondary)}.snk-filter-bar__filter-list-item.sc-snk-filter-bar:focus-visible{outline:none;background-color:var(--background--medium)}.snk-filter-bar__filter-list-item.sc-snk-filter-bar:hover{background-color:var(--background--medium)}.snk-filter-bar__filter-list-items-container--empty.sc-snk-filter-bar{width:100%;height:100px;display:flex;justify-content:center;align-self:center;align-items:center}.snk-filter-bar__filter-list-items-button--active.sc-snk-filter-bar{position:relative}.snk-filter-bar__filter-list-items-button--active.sc-snk-filter-bar::after{display:flex;position:absolute;content:"";width:8px;height:8px;top:7px;left:17px;background-color:var(--icon--alert--color, #008561);border-radius:50%}.snk-filter-bar__filter-modal-item.sc-snk-filter-bar{--modal-item-border-width:2px;display:flex;flex-direction:row;margin-left:var(--modal-item-border-width);border-radius:var(--border--radius-medium, 12px);background-color:var(--background--medium, #f0f3f7);border:none;width:100%}.snk-filter-bar__filter-modal-item.sc-snk-filter-bar:focus-visible{outline:var(--color--primary) solid var(--modal-item-border-width)}.snk-filter-bar__filter-modal-item__check.sc-snk-filter-bar{width:auto}.snk-filter-bar__filter-modal-item__label.sc-snk-filter-bar{font-weight:var(--text-weight--medium)}.snk-filter-bar__filter-modal-content.sc-snk-filter-bar{display:grid;grid-template-rows:auto auto 1fr auto;width:99%;height:100%}';const D=class{constructor(e){t(this,e),this.visibleChanged=i(this,"visibleChanged",7),this.filterChange=i(this,"filterChange",3),this._keyboardManager=void 0,this.detailIsVisible=void 0,this.config=void 0,this.getMessage=void 0,this.showChips=!0}observeDetailIsVisible(t){this.visibleChanged.emit(t)}filterChangeListener(){this.hideDetail()}async showUp(t=!1){var i;this._filterItemElement.scrollIntoView({behavior:"auto",block:"nearest",inline:"nearest"}),t&&(await(null===(i=this._chipElement)||void 0===i?void 0:i.setBlur()),await this._popover.showUnder(this._chipElement),await this._filterDetail.setFocusField())}async hideDetail(){var t;await(null===(t=this._popover)||void 0===t?void 0:t.hide())}getConfigChanges(){var t;const i=this.config;(null===(t=i.groupedItems)||void 0===t?void 0:t.length)&&(i.visible=!1,i.groupedItems=i.groupedItems.map((t=>Object.assign(Object.assign({},t),{visible:!1}))));const e=i.type===z.MULTI_LIST&&Array.isArray(i.value)?i.value.map((t=>Object.assign(Object.assign({},t),{check:!1}))):void 0;return Object.assign(Object.assign({},i),{value:e})}clearFilter(t){if(null==t||t.stopPropagation(),this.canClearFilter()){const t=this.getConfigChanges();this.filterChange.emit(t)}else this.togglePopover(t)}async togglePopover(t){null==t||t.preventDefault(),null==t||t.stopPropagation(),!1!==this.config.enabled&&(this.detailIsVisible?await this.hideDetail():await this.showUp(!0))}getLabel(t=!1){var i,e;const{type:s,value:r,label:l,props:a,groupedItems:n=[]}=this.config;if(r||n.length){if(s===z.BINARY_SELECT){const[i,e]=a.options,s=this.getMessage("snkFilterBar.binarySelectTooltip");if(i.name===r)return t?`${s} ${String(i.label).toLowerCase()}`:i.label;if(e.name===r)return t?`${s} ${String(e.label).toLowerCase()}`:e.label}if(s===z.MULTI_SELECT)return`${l}: ${a.options.find((t=>t.value===r)).label}`;if(s===z.PERIOD){let{end:i,start:e}=r;"string"==typeof i&&(i=new Date(i),i.setMinutes(i.getMinutes()+i.getTimezoneOffset())),"string"==typeof e&&(e=new Date(e),e.setMinutes(e.getMinutes()+e.getTimezoneOffset()));const s=new Intl.DateTimeFormat("pt-BR");if(i&&e){const s=e.getFullYear()===i.getFullYear(),r=Object.assign({day:"2-digit",month:"2-digit"},(!s||t)&&{year:"2-digit"}),a=m.formatDate(e,r),n=m.formatDate(i,r);return t?this.getMessage("snkFilterBar.fullPeriodTooltip",{LABEL:l,START_LABEL:a,END_LABEL:n}):`${l}: ${a} → ${n}`}return e?`${l}: ${this.getMessage("snkFilterBar.onlyStartToltip")} ${s.format(e)}`:i?`${l}: ${this.getMessage("snkFilterBar.onlyEndToltip")} ${s.format(i)}`:l}if(s===z.SEARCH)return`${l}: ${r.value} - ${r.label}`;if(s===z.PERSONALIZED){const t=this.calculateActiveCount(n);return t<=0?l:`${l}: ${this.getMessage("snkFilterBar.personalizedCount",{activeCount:t})}`}if(s===z.MULTI_LIST){const e=(null!==(i=r.elements)&&void 0!==i?i:r).filter((t=>null==t?void 0:t.check));return this.getLabelFromCheckedOptions(e,l,t)}if(s===z.CHECK_BOX_LIST){const i=Object.entries(null!=r?r:{}).filter((([t,i])=>!0===i)).map((([t,i])=>t)),s=(null!==(e=a.options)&&void 0!==e?e:[]).filter((t=>i.includes(t.name)));return this.getLabelFromCheckedOptions(s,l,t)}if(s===z.NUMBER&&a.variation===C.INTERVAL){const{start:t,end:i}=r;if(!isNaN(t)&&!isNaN(i))return this.getMessage("snkFilterBar.fullIntervalTooltip",{LABEL:l,START_LABEL:t,END_LABEL:i});if(!isNaN(t))return`${l}: ${this.getMessage("snkFilterBar.onlyStartToltip")} ${Number(t)}`;if(!isNaN(i))return`${l}: ${this.getMessage("snkFilterBar.onlyEndToltip")} ${Number(i)}`}return this.config.mask?`${l}: ${new p(this.config.mask).format(r)}`:`${l}: ${r}`}return l}getLabelFromCheckedOptions(t,i,e){const s=t.length;return 0===s?`${i}`:s>1?e?`${i}: ${t.map((t=>t.label)).join(",")}`:`${i}: ${s} ${this.getMessage("snkFilterBar.multiListToltip")}`:`${i}: ${t[0].label}`}calculateActiveCount(t){return t.reduce(((t,i)=>i.visible?t+1:t),0)}componentDidLoad(){this._filterItemElement&&(h.addIDInfo(this._filterItemElement),this._idSnkFilterDetail=`filterDetail_${this.config.id}`)}canClearFilter(){const{value:t,groupedItems:i=[]}=this.config;return null!=t&&this.config.type===z.MULTI_LIST?t.some((t=>t.check)):void 0!==t||i.some((t=>t.visible))}getRightIconName(){return this.canClearFilter()?"close":this.detailIsVisible?"chevron-up":"chevron-down"}getLeftIconName(){switch(this.config.type){case z.PERIOD:return"calendar";case z.PERSONALIZED:return"tune"}}hasActiveElements(t){var i;const e=Array.isArray(t)?t:null==t?void 0:t.elements;return(null===(i=null==e?void 0:e.filter((t=>null==t?void 0:t.check)))||void 0===i?void 0:i.length)>0}hasActiveValue(t){var i,e;return t.type===z.PERIOD?!!(null===(i=t.value)||void 0===i?void 0:i.start)||!!(null===(e=t.value)||void 0===e?void 0:e.end):t.type!==z.MULTI_LIST&&void 0!==t.value||this.hasActiveElements(t.value)}getEnabledChip(){if(this.detailIsVisible)return!0;if(this.config.type===z.PERSONALIZED){const{groupedItems:t=[]}=this.config;return t.some((t=>t.visible))}return this.hasActiveValue(this.config)}async handleVisibilityPopover(t){this.detailIsVisible=t.detail,this.detailIsVisible||await this._filterDetail.clearValue()}getCustomMessage(t,i){var e;return null===(e=this.getMessage)||void 0===e?void 0:e.call(this,`snkFilterBar.filterModal.${t}`,i)}hasValue(){return this.config.type===z.MULTI_LIST?this.hasActiveElements(this.config.value):null!=this.config.value}getTooltipMessage(){var t,i;return this.config.required&&!this.hasValue()?{message:null!==(t=this.config.requiredMessage)&&void 0!==t?t:this.getCustomMessage("validations.requiredFilter"),type:"error"}:!1===this.config.enabled&&this.config.disabledMessage?{message:this.config.disabledMessage,type:"warning"}:{message:null!==(i=this.config.defaultMessage)&&void 0!==i?i:this.getLabel(!0),type:"default"}}getTypeChip(t){switch(t){case"default":return"secondary";case"warning":return"warning-light";case"error":return"error-light";case"success":return"success-light";default:return t}}initKeyboardManager(){this._keyboardManager=new v({element:this._filterItemElement,propagate:!0}),this._keyboardManager.bind("Escape",(()=>this.hideDetail()))}connectedCallback(){this.initKeyboardManager()}disconnectedCallback(){this._keyboardManager.unbindAllShortcutKeys()}render(){const t=this.getLeftIconName(),{type:i,message:r}=this.getTooltipMessage();return e(s,null,this.showChips&&e("ez-tooltip",{id:this.config.id,message:r,type:i,active:!this.detailIsVisible,strategy:"fixed"},e("ez-chip",{id:this.config.id,ref:t=>this._chipElement=t,label:this.getLabel(),value:this.getEnabledChip(),onClick:t=>this.togglePopover(t),disableAutoUpdateValue:!0,type:this.getTypeChip(i),enabled:this.config.enabled},t&&e("ez-icon",{ref:t=>this._leftIconElement=t,iconName:t,slot:"leftIcon"}),e("ez-icon",{ref:t=>this._rightIconElement=t,iconName:this.getRightIconName(),slot:"rightIcon",id:"removeFilter",onClick:t=>this.clearFilter(t)}))),e("ez-popover-core",{ref:t=>this._popover=t,onEzVisibilityChange:t=>this.handleVisibilityPopover(t)},e("snk-filter-detail",{ref:t=>this._filterDetail=t,key:this.config.id,config:this.config,getMessage:this.getMessage,class:"sc-snk-filter-bar snk-filter__popover ez-padding--small ez-elevation--16","data-element-id":this._idSnkFilterDetail,showHardFixed:this.showChips&&!this.config.required,removalBlocked:this.config.required})))}get _filterItemElement(){return r(this)}static get watchers(){return{detailIsVisible:["observeDetailIsVisible"]}}};D.style="ez-popover-core.sc-snk-filter-item{--ez-popover__box--z-index:var(--elevation--20, 20);--ez-popover__box--overlay-z-index:var(--elevation--16, 16)}";const S="__SHOWMORE__",B=class{constructor(e){t(this,e),this.snkItemSelected=i(this,"snkItemSelected",7),this._preselection=-1,this.innerClickCheck=(t,i)=>i.id!=b.MODAL_ELEMENT_ID||(this._detailIsVisible=!1,!1),this._filterArgument=void 0,this._showAll=void 0,this.label=void 0,this.iconName=void 0,this.items=void 0,this.getMessage=void 0,this.emptyText=void 0,this.findFilterText=void 0,this.buttonClass=void 0}showDetail(){this._preselection=-1,this._floatingID=b.float(this._popover,this._popoverContainer,{autoClose:!0,innerClickTest:this.innerClickCheck,backClickListener:()=>this.onListCloseCallback(),useOverlay:!0}),this._detailIsVisible=!0,this._showAll=!1,this._filterArgument="",this._filterInput.setFocus()}async hideDetail(){null!=this._floatingID&&b.close(this._floatingID)}onListCloseCallback(){this._floatingID=void 0,this._detailIsVisible=!1}buttonClick(){this._detailIsVisible?this.hideDetail():this.showDetail()}componentDidLoad(){this._element&&h.addIDInfo(this._element)}componentDidRender(){null==this._floatingID&&this._popover&&this._popover.remove()}buildIdElement(t,i){if(!t)return;const e={id:i};t.removeAttribute(h.DATA_ELEMENT_ID_ATTRIBUTE_NAME),h.addIDInfoIfNotExists(t,"filterItemList",e)}buildItemElement(t){const i=++this._selectableItemsCount;return e("button",{ref:i=>i&&this.buildIdElement(i,t.label),id:`filter-item${i}`,onFocusin:()=>this._preselection=i,class:"ez-col ez-col--sd-12 ez-align--middle ez-padding--small sc-snk-filter-bar snk-filter-bar__filter-list-item",onClick:()=>this.itemSelected(t.name),name:t.label,key:i},t.iconName?e("ez-icon",{iconName:t.iconName,size:"small",class:`ez-padding-right--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-item__icon ${t.iconClass||""}`}):void 0,e("div",{class:`ez-text ez-text--medium ez-text--primary ez-padding--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-item__label ${t.labelClass||""}`},t.label))}itemSelected(t){t===S?this._showAll=!0:(this.hideDetail(),this.snkItemSelected.emit(t))}getFilterItems(){const t=this.items?g.applyStringFilter(this._filterArgument,this.items.filter((t=>"FILTER"===t.kind))):[];return 0===t.length?e("div",{class:"ez-text ez-text--medium ez-text--primary ez-padding--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-items-container--empty"},this.emptyText):(!this._filterArgument&&!this._showAll&&t.length>6&&(t.splice(5),t.push({kind:"INTERNAL",label:this.getMessage("snkFilterList.showMore"),iconName:"dots-horizontal",name:S,iconClass:"snk-filter-bar__filter-list-item__icon--secondary",labelClass:"snk-filter-bar__filter-list-item__label--secondary"})),this._selectableItemsCount=0,e("div",{class:"sc-snk-filter-bar snk-filter-bar__filter-list-items-container"},t.map((t=>this.buildItemElement(t)))))}getFooterItems(){return this.items.filter((t=>"FOOTER"===t.kind))}keyDownHandler(t){switch(t.key){case"ArrowDown":this.changePreselection(this._preselection+1),t.stopImmediatePropagation(),t.stopPropagation(),t.preventDefault();break;case"ArrowUp":this.changePreselection(this._preselection-1),t.stopImmediatePropagation(),t.stopPropagation(),t.preventDefault()}}changePreselection(t){if(t<0&&(t=this._selectableItemsCount),this._preselection=t>this._selectableItemsCount?0:t,0===this._preselection)this._filterInput.setFocus();else{const t=this._element.querySelector(`#filter-item${this._preselection}`);t&&t.focus()}}render(){return e(s,{class:"ez-flex ez-flex--column"},e("ez-button",{class:this.buttonClass,label:this.label,onClick:()=>this.buttonClick(),mode:this.iconName?"icon":void 0,iconName:this.iconName,size:"small"},e("slot",{name:"leftIcon"})),e("section",{class:"ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container",ref:t=>this._popoverContainer=t},e("div",{class:"sc-snk-filter-bar snk-filter__popover ez-padding--small ez-elevation--4",ref:t=>this._popover=t},e("ez-filter-input",{ref:t=>this._filterInput=t,"data-element-id":"serachFilters",mode:"slim",label:this.findFilterText,value:this._filterArgument,onEzChange:t=>this._filterArgument=t.detail,onFocus:()=>this._preselection=0}),this.getFilterItems(),e("hr",{class:"sc-snk-filter-bar snk-filter__popover-rule"}),this.items?this.getFooterItems().map((t=>this.buildItemElement(t))):void 0)))}get _element(){return r(this)}},E=class{constructor(i){t(this,i),this._isUserSup=!1,this.filters=[],this.filtersWithError=[],this.getMessage=void 0,this.configName=void 0,this.filterConfig=void 0,this.opened=!1,this.applyFilters=void 0,this.closeModal=void 0,this.addPersonalizedFilter=void 0,this.editPersonalizedFilter=void 0,this.deletePersonalizedFilter=void 0,this.filtersToDelete=[],this.filterDefaultToDelete=void 0,this.disablePersonalizedFilter=void 0,this.filterCustomConfigInterceptor=void 0}filterConfigChangeHandler(t){this.filters=o.copy(t),this.validateFilters()}deletePersonalizedFilterListener(t){this.filtersToDelete.push(t.detail)}getCustomMessage(t,i){var e;return null===(e=this.getMessage)||void 0===e?void 0:e.call(this,`snkFilterBar.filterModal.${t}`,i)}handleClearAll(){const{customFilters:t,quickFilters:i,otherFilters:e,multiListFilters:s}=this.filters.reduce(((t,i)=>i.type===z.MULTI_LIST?(t.multiListFilters.push(i),t):i.filterType===T.QUICK_FILTER?(t.quickFilters.push(i),t):i.filterType===T.CUSTOM_FILTER?(t.customFilters.push(i),t):i.filterType===T.OTHER_FILTERS?(t.otherFilters.push(i),t):t),{quickFilters:[],customFilters:[],otherFilters:[],multiListFilters:[]});this.handleClearFilterList(i),this.handleClearCustomFilters(t),this.handleClearOthersFilters(e),s.forEach((t=>this.handleClearSigleFilter(t))),l(this)}handleClearOthersFilters(t){this.filters=this.filters.map((i=>t.includes(i)?Object.assign(Object.assign({},i),{value:void 0}):i))}handleClearCustomFilters(t){this.filters.forEach(((i,e)=>{i.filterType===T.CUSTOM_FILTER&&(this.filters[e]=this.clearAllCustomFilter(t).shift())}))}clearAllCustomFilter(t){return t.map((t=>{const i=Object.assign({},t);return delete i.value,i.visible=!1,i.groupedItems&&(i.groupedItems=this.clearAllCustomFilter(i.groupedItems)),i}))}hasChangeToSave(){return o.objectToString(this.filters)!=o.objectToString(this.filters)}handleClose(){if(this.hasChangeToSave())return $.confirm(this.getCustomMessage("validations.notSaved.title"),this.getCustomMessage("validations.notSaved.message")).then((t=>{t&&this.closeModal()}));this.closeModal()}handleApplyFilters(){if(!this.validateFilters())return;const t=this.filters.find((t=>t.filterType===T.CUSTOM_FILTER||t.filterType===T.DEFAULT_FILTER));this.isValidCustomFilter(t)&&this.applyFilters(this.filters),this.filtersToDelete.length>0&&(this.filtersToDelete.forEach((t=>{this.deletePersonalizedFilter(t,this.configName)})),this.filtersToDelete=[]),this.filterDefaultToDelete&&(this.deletePersonalizedFilter(this.filterDefaultToDelete,this.configName,!0),this._defaultFilter=void 0,this.filterDefaultToDelete=void 0)}isValidCustomFilter(t){return!!F.validateVariableValues(t)||($.alert(this.getCustomMessage("validations.notFullFilled.title"),this.getCustomMessage("validations.notFullFilled.message")),!1)}modalActionListener(t){switch(t.detail){case I.CANCEL:this.handleClearAll();break;case I.OK:this.handleApplyFilters();break;case I.CLOSE:this.handleClose()}}handleFilterChange(t){t.stopPropagation();const i=t.detail;let e=this.filters.map((t=>t.id===i.id?i:t));this.filterCustomConfigInterceptor&&(e=this.filterCustomConfigInterceptor(e)),this.filters=o.copy(e)}handleClearFilterList(t){this.filters=this.filters.map((i=>t.includes(i)?Object.assign(Object.assign({},i),{value:void 0}):i))}handleClearSigleFilter(t){if(z.MULTI_LIST===t.type){let i=o.copy(t);this.uncheckFilterValues(i.value);const e=o.copy(this.filters),s=e.findIndex((i=>i.id===t.id));return e.splice(s,1,i),void(this.filters=o.copy(e))}if(z.CHECK_BOX_LIST===t.type){const i=o.copy(this.filters);return i.find((i=>i.id===t.id)).value=void 0,void(this.filters=o.copy(i))}this.filters.find((i=>i.id===t.id)).value=void 0,this.filters=o.copy(this.filters)}uncheckFilterValues(t){return t.forEach((t=>{t&&(t.check=!1)})),t}validateFilters(){const t=L(this.filters);return this.filtersWithError=t.map((t=>t.id)),0===t.length||(t.forEach((t=>{const i=this._element.querySelector(`#filter-item-${t.id}`);i&&(i.errorMessage=t.requiredMessage||this.getCustomMessage("validations.requiredFilter"))})),!1)}renderFilterItem(t,i){return e("snk-filter-modal-item",{key:`modal-item-${t.id}`,class:i?"ez-col ez-col--sd-12":"ez-col ez-col--sd-6 ez-padding--small",filterItem:t,configName:this.configName,onFilterChange:t=>this.handleFilterChange(t),onEditPersonalizedFilter:t=>this.editPersonalizedFilter(t.detail),onAddPersonalizedFilter:()=>this.addPersonalizedFilter()})}isDefaultFilterNumberVariation(t){var i;return t.type===z.NUMBER&&(!t.props.variation||(null===(i=t.props)||void 0===i?void 0:i.variation)===C.DEFAULT)}mountFiltersLines(t){let i=0,e=!1;const s={};for(let r=0;r<t.length;r++){s[i]=s[i]||[];const l=t[r],a=r===t.length-1,n=l.type===z.TEXT||this.isDefaultFilterNumberVariation(l),o=!a&&(t[r+1].type===z.TEXT||this.isDefaultFilterNumberVariation(t[r+1]));n&&o||e?(s[i].push(l),e=s[i].length<2,2===s[i].length&&++i):(s[i]=s[i]||[],s[i].push(l),++i)}return Object.values(s)}renderFilterLine(t){const i=1===t.length;return t.map((t=>this.renderFilterItem(t,i)))}getIformedFiltersCount(t){let i=0;return t.forEach((t=>{var e,s,r,l,a,n,o,h;const d=this.filterConfig.find((i=>i.id===t.id));z.MULTI_LIST!==d.type?z.CHECK_BOX_LIST!==d.type?z.PERIOD!==d.type?null==d.groupedItems?d.value&&i++:i=d.groupedItems.filter((t=>t.visible)).length:((null===(o=d.value)||void 0===o?void 0:o.start)||(null===(h=d.value)||void 0===h?void 0:h.end))&&i++:i+=Object.entries(null!==(n=d.value)&&void 0!==n?n:{}).filter((([t,i])=>!0===i)).map((([t,i])=>t)).length:i+=null!==(a=null===(l=null===(r=null!==(s=null===(e=d.value)||void 0===e?void 0:e.elements)&&void 0!==s?s:d.value)||void 0===r?void 0:r.filter((t=>null==t?void 0:t.check)))||void 0===l?void 0:l.length)&&void 0!==a?a:0})),i}renderCollapsibleFilterBox(t,i,s,r=!0){if(!i.length)return null;const l=this.getIformedFiltersCount(i),a=this.mountFiltersLines(i),n=this.filtersWithError.filter((t=>i.some((i=>i.id===t)))).length;return e("ez-collapsible-box",{class:"snk-filter-modal__collapsible-box",headerSize:"medium",value:!0,label:t},e("div",{class:"ez-flex ez-flex--justify-end grow",slot:"rightSlot"},!!l&&e("ez-badge",{class:"ez-badge--primary-subtle",label:null==l?void 0:l.toString()}),!!n&&e("ez-badge",{class:"ez-badge--error-subtle",label:null==n?void 0:n.toString()})),e("div",{class:"ez-row snk-filter-modal__rendered-items"},a.map(this.renderFilterLine.bind(this))),r&&e("div",{class:"ez-flex ez-flex--justify-end grow"},e("ez-button",{class:"ez-button--tertiary",size:"medium",label:this.getCustomMessage("clearModal"),onClick:()=>s?this.handleClearSigleFilter(i[0]):this.handleClearFilterList(i)})))}handleDeleteFilter(){this._application.confirm(this.getMessage("snkPersonalizedFilter.deleteConfirm.title"),this.getMessage("snkPersonalizedFilter.info.deleteDefaultFilterConfirm"),"alert-circle-inverted","critical").then((t=>{t&&(this.filterDefaultToDelete=this._defaultFilter,this.filters=this.filters.filter((t=>t.id!==T.DEFAULT_FILTER)))}))}handleActionSelectedDefaultFilter({detail:t}){switch(t){case N.CREATE:this.addPersonalizedFilter(!0);break;case N.EDIT:this.editPersonalizedFilter(this._defaultFilter.id,!0);break;case N.REMOVE:this.handleDeleteFilter()}}getCustomFilter(t){return t.filter((t=>t.filterType===T.CUSTOM_FILTER))}getDefaultFilter(t){return t.find((t=>t.id===w.id))}async componentWillLoad(){this._application=c.getContextValue("__SNK__APPLICATION__"),this._isUserSup=await this._application.isUserSup(),this.filters=o.copy(this.filterConfig)}componentWillRender(){this._modalTitle=this.getCustomMessage("title"),this._okButtonLabel=this.getCustomMessage("okButtonLabel"),this._cancelButtonLabel=this.getCustomMessage("cancelButtonLabel")}componentDidLoad(){this.validateFilters()}render(){this._defaultFilter=this._isUserSup?this.getDefaultFilter(this.filters):void 0;const t=this.getCustomFilter(this.filters),i=this.filters.filter((t=>t.filterType===T.QUICK_FILTER)),s=this.filters.filter((t=>t.filterType===T.OTHER_FILTERS));return e("ez-modal",{opened:this.opened,modalSize:"col--sd-3",align:"right",heightMode:"full",closeEsc:!0},e("ez-modal-container",{class:"snk-filter-modal__container",modalTitle:this._modalTitle,cancelButtonLabel:this._cancelButtonLabel,okButtonLabel:this._okButtonLabel,onEzModalAction:this.modalActionListener.bind(this)},e("div",{class:"snk-filter-modal__content ez-col--sd-12"},this._isUserSup&&e("snk-default-filter",{getMessage:this.getCustomMessage.bind(this),hasDefaultFilter:!!this._defaultFilter,onActionSelected:this.handleActionSelectedDefaultFilter.bind(this)}),!this.disablePersonalizedFilter&&this.renderCollapsibleFilterBox(this.getCustomMessage("customFilters"),t,!1,!1),this.renderCollapsibleFilterBox(this.getCustomMessage("quickFilters"),i,!1),s.map((t=>this.renderCollapsibleFilterBox(t.label,[t],!0))))))}get _element(){return r(this)}static get watchers(){return{filterConfig:["filterConfigChangeHandler"]}}};E.style="ez-modal{--ez-modal-content-padding:24px 12px}.snk-filter-modal__container{min-width:344px;overflow:hidden}.snk-filter-modal__content{display:flex;flex-direction:column;gap:var(--space--medium, 12px);padding-right:var(--space--3xs, 4px)}.snk-filter-modal__collapsible-box{border:var(--border--small, 1px solid) var(--color--strokes, #DCE0E8);border-radius:var(--border--radius-medium);padding:var(--space--medium, 12px) var(--space--small, 6px)}.snk-filter-modal__rendered-items{max-height:760px}.snk-filter-modal__rendered-items::-webkit-scrollbar{width:var(--space--small);min-width:var(--space--small);max-width:var(--space--small)}";export{P as snk_filter_bar,D as snk_filter_item,B as snk_filter_list,E as snk_filter_modal}
|
|
1
|
+
import{r as t,c as i,h as e,H as s,g as r,f as l}from"./p-82bb3eda.js";import{DataType as a,StringUtils as n,ObjectUtils as o,ElementIDUtils as h,ErrorException as d,ApplicationContext as c,LockManager as u,LockManagerOperation as f,DateUtils as m,MaskFormatter as p,KeyboardManager as v,FloatingManager as b,ArrayUtils as g}from"@sankhyalabs/core";import{EzScrollDirection as k}from"@sankhyalabs/ezui/dist/collection/components/ez-scroller/EzScrollDirection";import{C as _}from"./p-1f310bc6.js";import{P as F}from"./p-988afe78.js";import{toString as y}from"@sankhyalabs/core/dist/dataunit/metadata/DataType";import{F as z}from"./p-ff1990ad.js";import{F as x,D as w}from"./p-84345e7a.js";import{F as C}from"./p-fa80e546.js";import{ModalAction as I}from"@sankhyalabs/ezui/dist/collection/components/ez-modal-container";import{ApplicationUtils as $}from"@sankhyalabs/ezui/dist/collection/utils";import{A as N}from"./p-6a4b21dd.js";import{F as T}from"./p-b568c1d4.js";import{g as L}from"./p-76e66fd9.js";import"./p-7ee6b1bf.js";import"./p-6768f176.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";function A(t){let i="";return t.forEach(((t,e)=>{var s;i+=` ${e>0?null!==(s=t.operand)&&void 0!==s?s:"OR":""} ${t.expression}`})),i.trim()}const P=class{constructor(e){t(this,e),this.configUpdated=i(this,"configUpdated",7),this._updateSequence=[],this._loadingPending=!1,this._configUpdated=!1,this._firstLoad=!0,this._pendingVariables=!1,this._isDefaultFilter=!1,this._customfiltersToBeUpdated=[],this._resolveLoading=void 0,this._calculateSortIndex=t=>{if(!t.visible)return 0;if(t.hardFixed)return 1e6;let i=t.fixed?1e5:0;return i+=this.hasValidValue(t)?1e4:0,i+=this._updateSequence.lastIndexOf(t.id)+1,i},this._filtersComparator=(t,i)=>this._calculateSortIndex(i)-this._calculateSortIndex(t),this.enableLockManagerLoadingComp=!1,this.customFilterBarConfig=void 0,this.dataUnit=void 0,this.title=void 0,this.configName=void 0,this.resourceID=void 0,this.mode="regular",this.filterConfig=void 0,this.messagesBuilder=void 0,this.disablePersonalizedFilter=void 0,this.filterBarLegacyConfigName=void 0,this.autoLoad=void 0,this.afterApplyConfig=void 0,this.filterCustomConfig=void 0,this.filterCustomConfigInterceptor=void 0,this.allowDefault=void 0,this.scrollerLocked=!1,this.showPersonalizedFilter=!1,this.personalizedFilterId=void 0,this.isFilterModalOpen=!1}hasValidValue(t){var i,e;return null!=t.value&&(t.type===z.PERIOD?!!(null===(i=t.value)||void 0===i?void 0:i.start)||!!(null===(e=t.value)||void 0===e?void 0:e.end):!!t.groupedItems||!Array.isArray(t.value)||t.value.some((t=>!0===t.check)))}observeFilterConfig(t,i){o.equals(t,i)||this.handleFilterConfigsChanged(i,t)}handleFilterConfigsChanged(t,i){if(null!=t&&null==i)this._loadingPending=!0,this._configUpdated=!0;else{const e=new Map(t?t.map((t=>[t.id,t])):void 0);0===e.size&&i.length>0?(this._loadingPending=!0,this._configUpdated=!1):i.forEach((t=>{const i=e.get(t.id);if(null!=i){if(this._configUpdated=this._configUpdated||o.objectToString(i)!=o.objectToString(t),this._loadingPending=this._loadingPending||o.objectToString(i.value)!==o.objectToString(t.value),!this._loadingPending){const e=o.objectToString(i.groupedItems)!=o.objectToString(t.groupedItems);this._configUpdated=this._configUpdated||e,this._loadingPending=this._loadingPending||e}}else this._configUpdated=!0,this._loadingPending=this._loadingPending||null!=t.value}))}(this._loadingPending||this._configUpdated)&&this.configUpdated.emit(i),this.processAfterUpdateConfig()}async reload(){this.loadConfigFromStorage(!0)}async getFilterItem(t){const i=this.filterConfig.find((i=>i.id===t));return Promise.resolve(o.copy(i))}async updateFilterItem(t){return-1==this.filterConfig.findIndex((i=>i.id===t.id))?(console.warn("[SnkFilterBar.updateFilterItem] "+this.getMessage("snkFilterBar.filterItem.updateFilterItemNotFound")),Promise.resolve()):(this._loadingPending=!0,this.updateFilter(t),Promise.resolve())}async addFilterItem(t){return this.filterConfig.findIndex((i=>i.id===t.id))>-1?(console.warn("[SnkFilterBar.addFilterItem] "+this.getMessage("snkFilterBar.filterItem.addFilterItemExists")),Promise.resolve()):(this.filterConfig.push(t),this._loadingPending=!0,this.updateFilter(t),Promise.resolve())}async removeFilterItem(t){const i=this.filterConfig.findIndex((i=>i.id===t));if(-1==i)return console.warn("[SnkFilterBar.removeFilterItem] "+this.getMessage("snkFilterBar.filterItem.removeFilterItemNotFound")),Promise.resolve(void 0);const e=this.filterConfig[i];return this.filterConfig=this.filterConfig.filter((i=>i.id!==t)),Promise.resolve(e)}componentDidLoad(){this._element&&h.addIDInfo(this._element,null,{dataUnit:this.dataUnit})}processPendingFilter(){if(this._pendingVariables){const t=this._element.querySelector("#filter-PERSONALIZED_FILTER_GROUP");t&&t.showUp(!0).then((()=>{this.processAfterUpdateConfig()}))}else this.processAfterUpdateConfig()}getPersonalizedFilterItem(){return this.filterConfig.find((t=>t.type===z.PERSONALIZED))}async processAfterUpdateConfig(){var t;if(this._loadingPending){if(await this._application.isLoadedByPk()&&!this._configUpdated)return;const t=this.getPersonalizedFilterItem();if(this._pendingVariables=!F.validateVariableValues(t),this._pendingVariables)return;this._loadingPending=!1,this.doLoadData()}this._configUpdated&&(this._configUpdated=!1,_.saveFilterBarConfig(this.filterConfig,this.configName,this.resourceID),null===(t=this.afterApplyConfig)||void 0===t||t.call(this))}async doLoadData(t=!1){try{if(this._firstLoad&&!1===this.autoLoad)return;if(this._firstLoad&&!t&&void 0===this.autoLoad&&!await this._application.getBooleanParam("global.carregar.registros.iniciar.tela"))return;this.dataUnit.loadData(void 0,void 0,!0)}finally{this._firstLoad=!1}}getMessage(t,i,e){var s;return null==this.messagesBuilder&&this._application&&(this.messagesBuilder=this._application.messagesBuilder),(null===(s=this.messagesBuilder)||void 0===s?void 0:s.getMessage(t,i))||e}async getFilters(){return this.getFilter(null)}getFilter(t){var i;const e=[];return null===(i=this.filterConfig)||void 0===i||i.filter((t=>this.isActiveFilter(t))).forEach((t=>{const i=(t=>{switch(t.type){case z.DEFAULT_FILTER:return function(t){return{name:t.id,expression:t.props.expression,params:[]}}(t);case z.BINARY_SELECT:return function(t){const{id:i,value:e,props:s}=t;return{name:i,expression:s.options.find((t=>t.name===e)).expression,params:[]}}(t);case z.MULTI_SELECT:return function(t){const{id:i,value:e,props:s}=t;return{name:i,expression:s.expression,params:[{name:i,dataType:a.TEXT,value:e}]}}(t);case z.MULTI_LIST:return function(t){const{id:i,value:e,props:s}=t,r=(null!==(o=null!==(n=null==(l=e)?void 0:l.elements)&&void 0!==n?n:null==l?void 0:l.members)&&void 0!==o?o:l).filter((t=>null==t?void 0:t.check)).map((({id:t})=>Number.isNaN(+t)?String(t):Number(t)));var l,n,o;if(r.length>0)return{name:i,expression:s.expression,params:[{name:i,dataType:a.TEXT,value:JSON.stringify(r)}]}}(t);case z.PERIOD:return function(t){const{id:i,value:e,props:s}=t;let{end:r,start:l}=e;"string"==typeof r&&(r=new Date(r)),"string"==typeof l&&(l=new Date(l));const n=[];let o;return r&&l?(o=s.expression.fullfill,n.push({name:`${i}.START`,dataType:a.DATE,value:y(a.DATE,l)},{name:`${i}.END`,dataType:a.DATE,value:y(a.DATE,r)})):l?(o=s.expression.onlystart,n.push({name:i,dataType:a.DATE,value:y(a.DATE,l)})):(o=s.expression.onlyend,n.push({name:i,dataType:a.DATE,value:y(a.DATE,r)})),{name:i,expression:o,params:n}}(t);case z.SEARCH:return function(t){const{id:i,value:e,props:s}=t;return{name:i,expression:s.expression,params:[{name:i,dataType:a.TEXT,value:y(a.TEXT,null==e?void 0:e.value)}]}}(t);case z.TEXT:return function(t){let{id:i,value:e,props:s}=t;const r=s.expression;var l,o;return n.isEmpty(s.likeAs)||(l=e,e="CONTANIS"===(o=s.likeAs)?`%${l}%`:"STARTS_WITH"===o?`${l}%`:"ENDS_WITH"===o?`%${l}`:l),{name:i,expression:r,params:[{name:i,dataType:a.TEXT,value:y(a.TEXT,e)}]}}(t);case z.NUMBER:return function(t){const{id:i,value:e,props:s}=t;if(s.variation===C.INTERVAL){const{start:t,end:r}=null!=e?e:{start:0,end:0};if(!isNaN(t)&&!isNaN(r))return{name:i,expression:s.intervalExpression.fullfill,params:[{name:`${i}.START`,dataType:a.NUMBER,value:y(a.NUMBER,t)},{name:`${i}.END`,dataType:a.NUMBER,value:y(a.NUMBER,r)}]};if(!isNaN(t))return{name:i,expression:s.intervalExpression.onlystart,params:[{name:i,dataType:a.NUMBER,value:y(a.NUMBER,t)}]};if(!isNaN(r))return{name:i,expression:s.intervalExpression.onlyend,params:[{name:i,dataType:a.NUMBER,value:y(a.NUMBER,r)}]}}return{name:i,expression:s.expression,params:[{name:i,dataType:a.NUMBER,value:y(a.NUMBER,e)}]}}(t);case z.PERSONALIZED:return function(t){const{id:i,groupedItems:e=[]}=t,s=e.filter((t=>!!t.visible)).map((t=>{var i;const e=t.props.expression,s=((null===(i=t.props.personalizedFilter)||void 0===i?void 0:i.parameters)||[]).map(((i,e)=>{const s=Array.from(t.value||0),r=i.dataType;let l=e>=0&&e<s.length?s[e]:null;return null!=l&&"object"==typeof l&&"value"in l&&(l=l.value),null==l&&r===a.BOOLEAN&&(l=!1),{name:i.name,dataType:r,value:"string"==typeof l?l:y(r,l)}}));return{expression:e,name:t.id,params:s}}));return{name:i,expression:s.map((t=>`(${t.expression})`)).join(` ${x.AND} `),params:s.flatMap((t=>t.params))}}(t);case z.CHECK_BOX_LIST:return function(t){var i;const{id:e,value:s,props:r}=t,l=Object.entries(null!=s?s:{}).filter((([t,i])=>!0===i)).map((([t,i])=>t));return{name:e,expression:A(null===(i=r.options)||void 0===i?void 0:i.filter((t=>l.includes(t.name)))),params:[]}}(t);default:return}})(t);i&&e.push(i)})),e}isActiveFilter(t){return t.type===z.DEFAULT_FILTER||this.filterActiveFilter(t)&&this.hasValidValue(t)}async registryFilterProvider(){this.dataUnit.addFilterProvider(this),this.filterConfig&&await this.doLoadData()}itemFocused(t){this._element.querySelectorAll("snk-filter-item,snk-filter-list").forEach((i=>{i.id===t?"snk-filter-item"===i.tagName.toLowerCase()&&i.getClientRects()[0].x<0&&i.scrollIntoView({behavior:"auto",inline:"nearest"}):i.hideDetail()}))}filterActiveFilter(t){return t.visible||t.removalBlocked}filterPersonalizedItems(t){return t.type===z.PERSONALIZED}getPersonalizedFilterVariableItems(){return this.filterConfig.filter(this.filterPersonalizedItems).map((t=>{const i=`filter-${t.id}`;return e("snk-filter-item",{key:t.id,id:i,config:Object.assign({},t),onFocusin:()=>this.itemFocused(i),onVisibleChanged:t=>this.scrollerLocked=t.detail,onFilterChange:t=>this.updateFilter(t.detail),getMessage:(t,i)=>this.getMessage(t,i),showChips:!1})}))}getFilterItems(){const t=[],i=[];this.filterConfig.sort(((t,i)=>this._filtersComparator(t,i))).filter(this.filterActiveFilter).forEach((s=>{const r=`filter-${(s=o.copy(s)).id}`,l=e("snk-filter-item",{onVisibleChanged:t=>this.scrollerLocked=t.detail,onFilterChange:t=>this.updateFilter(t.detail),onFocusin:()=>this.itemFocused(r),id:r,config:s,class:"ez-margin-horizontal--extra-small",getMessage:(t,i)=>this.getMessage(t,i),key:s.id});return s.fixed||s.hardFixed||s.required?t.push(l):i.push(l),l}));const s=[];return s.push(...t.reverse()),t.length>0&&i.length>0&&s.push(e("hr",{class:"ez-margin-horizontal--small ez-margin-vertical--auto ez-divider-vertical ez-divider--dark snk-filter-bar__divider"})),s.push(...i),s}calculateUpdateSequence(t){t&&(this._updateSequence=this._updateSequence.filter((i=>t.id!==i)),this._updateSequence.push(t.id))}normalizeItem(t){const i=Object.assign({},t);return["props","value","hardFixed","fixed"].forEach((t=>{null==i[t]&&delete i[t]})),""===t.value&&delete t.value,i}updateFilter(t){let i=this.filterConfig.map((i=>(t=this.normalizeItem(t),i.id===t.id?(o.objectToString(i)!=o.objectToString(t)&&this.calculateUpdateSequence(t),t):i))).sort(((t,i)=>this._filtersComparator(t,i)));this.filterCustomConfigInterceptor&&(i=this.filterCustomConfigInterceptor(i)),this.filterConfig=i}loadPermitions(){this._application.isUserSup().then((t=>this.allowDefault=t))}addFilterBarLegacyConfigName(){this.filterBarLegacyConfigName&&_.addFilterBarLegacyConfig(this.configName,this.filterBarLegacyConfigName)}async loadConfigFromStorage(t){try{let i;t&&await _.deleteFilterBarConfigCache(this.configName,this.resourceID),i=this.customFilterBarConfig?await this.customFilterBarConfig(this.configName,this.resourceID,{contextURI:this.dataUnit.name}):await _.loadFilterBarConfig(this.configName,this.resourceID,{contextURI:this.dataUnit.name}),this.filterCustomConfig&&(i=[...this.filterCustomConfig,...i]),this.filterCustomConfigInterceptor&&(i=this.filterCustomConfigInterceptor(i)),this.filterConfig=i.map((t=>this.normalizeItem(t))),this.filterConfig.sort(((t,i)=>this._filtersComparator(t,i)))}catch(t){throw new d(this.getMessage("snkFilterBar.failToLoadConfig"),t)}}async attachDataUnit(){if(null==this.dataUnit){let t=this._element.parentElement;for(;t;)if("SNK-DATA-UNIT"===t.tagName.toUpperCase()){const i=t;this.dataUnit=i.dataUnit,this.dataUnit?await this.registryFilterProvider():i.addEventListener("dataUnitReady",(async t=>{this.dataUnit=t.detail,await this.registryFilterProvider()}));break}t=t.parentElement}else await this.registryFilterProvider()}filterChangeListener(t){this.updateFilter(t.detail)}async showFilterModal(){this.isFilterModalOpen||(this.isFilterModalOpen=!0)}addPersonalizedFilter(t=!1){this.isFilterModalOpen=!1,this._isDefaultFilter=t,this.personalizedFilterId=void 0,this.showPersonalizedFilter=!0,window.requestAnimationFrame((()=>{this._elPersonalizedFilter.createPersonalizedFilter()}))}editPersonalizedFilter(t,i=!1){this.isFilterModalOpen=!1,this._isDefaultFilter=i,this.showPersonalizedFilter=!0,this.personalizedFilterId=t}deletePersonalizedFilter(t,i,e,s=!1){if(s)return _.removeDefaultFilter(t,this.resourceID,e),void(this._isDefaultFilter=!1);i===z.PERSONALIZED&&_.removePersonalizedFilter(t,this.resourceID,e)}closeFilterModal(){this.isFilterModalOpen=!1}applyFiltersFromModal(t){var i;this.filterConfig=t.map(this.normalizeItem).sort(((t,i)=>this._filtersComparator(t,i))),null===(i=this.afterApplyConfig)||void 0===i||i.call(this),this.isFilterModalOpen=!1}handleHidePersonalizedFilter(t){t?this.loadConfigFromStorage().then((()=>{this.hidePersonalizedFilter()})):this.hidePersonalizedFilter()}hidePersonalizedFilter(){this.personalizedFilterId=void 0,this.showPersonalizedFilter=!1,this._isDefaultFilter=!1}async componentWillLoad(){var t;try{if(this._application=c.getContextValue("__SNK__APPLICATION__"),await this.attachDataUnit(),this._application){if(this._application.enableLockManagerLoadingApp&&this.enableLockManagerLoadingComp){const t=u.addLockManagerCtxId(this._element);this._resolveLoading=u.lock(t,f.APP_LOADING)}await Promise.all([this.loadPermitions(),this.addFilterBarLegacyConfigName(),this.loadConfigFromStorage()])}}finally{null===(t=this._resolveLoading)||void 0===t||t.call(this)}}componentDidRender(){this.processPendingFilter()}render(){if(!this.dataUnit||!this.filterConfig||0===this.filterConfig.length)return;if(this.showPersonalizedFilter)return e("snk-personalized-filter",{class:"filter-bar__personalized-filter",filterId:this.personalizedFilterId,ref:t=>this._elPersonalizedFilter=t,isDefaultFilter:this._isDefaultFilter,onEzCancel:()=>this.handleHidePersonalizedFilter(!1),onEzAfterSave:()=>this.handleHidePersonalizedFilter(!0),entityUri:this.dataUnit.name,configName:this.configName,resourceID:this.resourceID});let t=o.copy(this.filterConfig);return t=t.sort(((t,i)=>t.originOrder-i.originOrder)),"regular"!==this.mode?e(s,{"data-mode":this.mode},this.getPersonalizedFilterVariableItems(),"button"===this.mode&&e("ez-button",{class:"ez-margin-left--medium",size:"small",label:this.getMessage("snkFilterBar.filters",void 0,this.getMessage("snkFilterBar.filters")),onClick:this.showFilterModal.bind(this)}),e("snk-filter-modal",{opened:this.isFilterModalOpen,filterConfig:this.filterConfig,configName:this.configName,disablePersonalizedFilter:this.disablePersonalizedFilter,getMessage:(t,i)=>this.getMessage(t,i),applyFilters:t=>this.applyFiltersFromModal(t),closeModal:()=>this.closeFilterModal(),addPersonalizedFilter:t=>this.addPersonalizedFilter(t),editPersonalizedFilter:(t,i)=>this.editPersonalizedFilter(t,i),deletePersonalizedFilter:(t,i,e)=>this.deletePersonalizedFilter(t,z.PERSONALIZED,i,e),filterCustomConfigInterceptor:this.filterCustomConfigInterceptor})):e(s,null,e("div",null,e("span",{class:"snk-filter-bar__title",title:this.title,"data-tooltip":this.title,"data-flow":"bottom"},this.title)),e("ez-scroller",{class:"snk-filter-bar__scroller",direction:k.HORIZONTAL,activeShadow:!0,locked:this.scrollerLocked},e("section",{class:"snk-filter-bar__filter-item-container"},this.getFilterItems())),e("ez-button",{class:"ez-padding-left--medium ez-margin-top--extra-small",size:"small",label:this.getMessage("snkFilterBar.filters",void 0,this.getMessage("snkFilterBar.filters")),onClick:this.showFilterModal.bind(this)},e("ez-icon",{slot:"leftIcon",iconName:"plus",class:"ez-padding-right--small"})),e("snk-filter-modal",{opened:this.isFilterModalOpen,filterConfig:this.filterConfig,configName:this.configName,disablePersonalizedFilter:this.disablePersonalizedFilter,getMessage:(t,i)=>this.getMessage(t,i),applyFilters:t=>this.applyFiltersFromModal(t),closeModal:()=>this.closeFilterModal(),addPersonalizedFilter:t=>this.addPersonalizedFilter(t),editPersonalizedFilter:(t,i)=>this.editPersonalizedFilter(t,i),deletePersonalizedFilter:(t,i,e)=>this.deletePersonalizedFilter(t,z.PERSONALIZED,i,e),filterCustomConfigInterceptor:this.filterCustomConfigInterceptor}))}get _element(){return r(this)}static get watchers(){return{filterConfig:["observeFilterConfig"]}}};P.style='.sc-snk-filter-bar-h{display:grid;grid-template-columns:1fr minmax(100px, 100%) 1fr 1fr;--snk-personalized-filter--z-index:var(--elevation--20, 20);--snk-personalized-filter--background-color:var(--background--xlight, #fff)}.snk-filter-bar__title.sc-snk-filter-bar{max-width:260px;display:inline-block;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;font-size:16px;font-family:var(--font-pattern, Arial);font-weight:var(--text-weight--large, 600);color:var(--color--title-primary, #2B3A54);margin-top:12px}[data-mode="hidden"].sc-snk-filter-bar-h{width:0px;height:0px}[data-mode="button"].sc-snk-filter-bar-h{grid-template-columns:1fr;width:fit-content}.snk-filter__popover-container.sc-snk-filter-bar{display:flex;cursor:auto}.filter-bar__personalized-filter.sc-snk-filter-bar{display:flex;flex-direction:column;position:fixed;top:0;left:0;width:100%;height:100%;overflow:auto;z-index:var(--snk-personalized-filter--z-index);background-color:var(--snk-personalized-filter--background-color)}.snk-filter__popover.sc-snk-filter-bar{display:flex;flex-direction:column;position:absolute;width:fit-content;height:fit-content;min-width:265px;background-color:var(--background--xlight, #fff);border-radius:var(--border--radius-medium, 12px);box-shadow:var(--shadow, 0px 0px 16px 0px #000)}.snk-filter-item__editor-header.sc-snk-filter-bar{flex-grow:1;font-weight:var(--text-weight--medium, 400);color:var(--color--title-primary, #2B3A54)}.snk-filter__popover-rule.sc-snk-filter-bar{border-style:solid;border-color:var(--color--disable-secondary, #F2F5F8);border-radius:1px;border-width:1px;width:100%}.editor__ez-check.sc-snk-filter-bar{--ez-check__label--padding-left:0}.snk-filter-item__editor-header-button.sc-snk-filter-bar{cursor:pointer;background-color:transparent;border:none;padding:3px;outline-color:var(--color--primary)}.snk-filter-bar__divider.sc-snk-filter-bar{margin-bottom:var(--space--small);height:80%}.snk-filter-bar__filter-item-container.sc-snk-filter-bar{display:flex;align-items:start;margin:var(--space--2, 2px) 0}.snk-filter-bar__scroller.sc-snk-filter-bar .sc-snk-filter-bar:first-child{margin-left:var(--space-extra-small, 3px)}.snk-filter-bar__filter-list-items-container.sc-snk-filter-bar{overflow-y:auto;max-height:360px;margin-top:var(--space--small, 6px)}.snk-filter-bar__filter-list-item.sc-snk-filter-bar{cursor:pointer;border-radius:var(--border--radius-small, 6px);border:none;background-color:transparent}.snk-filter-bar__filter-list-item__label.sc-snk-filter-bar{color:var(--title--primary)}.snk-filter-bar__filter-list-item__label--secondary.sc-snk-filter-bar{color:var(--text--primary)}.snk-filter-bar__filter-list-item__icon.sc-snk-filter-bar{--ez-icon--color:var(--title--primary)}.snk-filter-bar__filter-list-item__icon--secondary.sc-snk-filter-bar{--ez-icon--color:var(--text--secondary)}.snk-filter-bar__filter-list-item.sc-snk-filter-bar:focus-visible{outline:none;background-color:var(--background--medium)}.snk-filter-bar__filter-list-item.sc-snk-filter-bar:hover{background-color:var(--background--medium)}.snk-filter-bar__filter-list-items-container--empty.sc-snk-filter-bar{width:100%;height:100px;display:flex;justify-content:center;align-self:center;align-items:center}.snk-filter-bar__filter-list-items-button--active.sc-snk-filter-bar{position:relative}.snk-filter-bar__filter-list-items-button--active.sc-snk-filter-bar::after{display:flex;position:absolute;content:"";width:8px;height:8px;top:7px;left:17px;background-color:var(--icon--alert--color, #008561);border-radius:50%}.snk-filter-bar__filter-modal-item.sc-snk-filter-bar{--modal-item-border-width:2px;display:flex;flex-direction:row;margin-left:var(--modal-item-border-width);border-radius:var(--border--radius-medium, 12px);background-color:var(--background--medium, #f0f3f7);border:none;width:100%}.snk-filter-bar__filter-modal-item.sc-snk-filter-bar:focus-visible{outline:var(--color--primary) solid var(--modal-item-border-width)}.snk-filter-bar__filter-modal-item__check.sc-snk-filter-bar{width:auto}.snk-filter-bar__filter-modal-item__label.sc-snk-filter-bar{font-weight:var(--text-weight--medium)}.snk-filter-bar__filter-modal-content.sc-snk-filter-bar{display:grid;grid-template-rows:auto auto 1fr auto;width:99%;height:100%}';const D=class{constructor(e){t(this,e),this.visibleChanged=i(this,"visibleChanged",7),this.filterChange=i(this,"filterChange",3),this._keyboardManager=void 0,this.detailIsVisible=void 0,this.config=void 0,this.getMessage=void 0,this.showChips=!0}observeDetailIsVisible(t){this.visibleChanged.emit(t)}filterChangeListener(){this.hideDetail()}async showUp(t=!1){var i;this._filterItemElement.scrollIntoView({behavior:"auto",block:"nearest",inline:"nearest"}),t&&(await(null===(i=this._chipElement)||void 0===i?void 0:i.setBlur()),await this._popover.showUnder(this._chipElement),await this._filterDetail.setFocusField())}async hideDetail(){var t;await(null===(t=this._popover)||void 0===t?void 0:t.hide())}getConfigChanges(){var t;const i=this.config;(null===(t=i.groupedItems)||void 0===t?void 0:t.length)&&(i.visible=!1,i.groupedItems=i.groupedItems.map((t=>Object.assign(Object.assign({},t),{visible:!1}))));const e=i.type===z.MULTI_LIST&&Array.isArray(i.value)?i.value.map((t=>Object.assign(Object.assign({},t),{check:!1}))):void 0;return Object.assign(Object.assign({},i),{value:e})}clearFilter(t){if(null==t||t.stopPropagation(),this.canClearFilter()){const t=this.getConfigChanges();this.filterChange.emit(t)}else this.togglePopover(t)}async togglePopover(t){null==t||t.preventDefault(),null==t||t.stopPropagation(),!1!==this.config.enabled&&(this.detailIsVisible?await this.hideDetail():await this.showUp(!0))}getLabel(t=!1){var i,e;const{type:s,value:r,label:l,props:a,groupedItems:n=[]}=this.config;if(r||n.length){if(s===z.BINARY_SELECT){const[i,e]=a.options,s=this.getMessage("snkFilterBar.binarySelectTooltip");if(i.name===r)return t?`${s} ${String(i.label).toLowerCase()}`:i.label;if(e.name===r)return t?`${s} ${String(e.label).toLowerCase()}`:e.label}if(s===z.MULTI_SELECT)return`${l}: ${a.options.find((t=>t.value===r)).label}`;if(s===z.PERIOD){let{end:i,start:e}=r;"string"==typeof i&&(i=new Date(i),i.setMinutes(i.getMinutes()+i.getTimezoneOffset())),"string"==typeof e&&(e=new Date(e),e.setMinutes(e.getMinutes()+e.getTimezoneOffset()));const s=new Intl.DateTimeFormat("pt-BR");if(i&&e){const s=e.getFullYear()===i.getFullYear(),r=Object.assign({day:"2-digit",month:"2-digit"},(!s||t)&&{year:"2-digit"}),a=m.formatDate(e,r),n=m.formatDate(i,r);return t?this.getMessage("snkFilterBar.fullPeriodTooltip",{LABEL:l,START_LABEL:a,END_LABEL:n}):`${l}: ${a} → ${n}`}return e?`${l}: ${this.getMessage("snkFilterBar.onlyStartToltip")} ${s.format(e)}`:i?`${l}: ${this.getMessage("snkFilterBar.onlyEndToltip")} ${s.format(i)}`:l}if(s===z.SEARCH)return`${l}: ${r.value} - ${r.label}`;if(s===z.PERSONALIZED){const t=this.calculateActiveCount(n);return t<=0?l:`${l}: ${this.getMessage("snkFilterBar.personalizedCount",{activeCount:t})}`}if(s===z.MULTI_LIST){const e=(null!==(i=r.elements)&&void 0!==i?i:r).filter((t=>null==t?void 0:t.check));return this.getLabelFromCheckedOptions(e,l,t)}if(s===z.CHECK_BOX_LIST){const i=Object.entries(null!=r?r:{}).filter((([t,i])=>!0===i)).map((([t,i])=>t)),s=(null!==(e=a.options)&&void 0!==e?e:[]).filter((t=>i.includes(t.name)));return this.getLabelFromCheckedOptions(s,l,t)}if(s===z.NUMBER&&a.variation===C.INTERVAL){const{start:t,end:i}=r;if(!isNaN(t)&&!isNaN(i))return this.getMessage("snkFilterBar.fullIntervalTooltip",{LABEL:l,START_LABEL:t,END_LABEL:i});if(!isNaN(t))return`${l}: ${this.getMessage("snkFilterBar.onlyStartToltip")} ${Number(t)}`;if(!isNaN(i))return`${l}: ${this.getMessage("snkFilterBar.onlyEndToltip")} ${Number(i)}`}return this.config.mask?`${l}: ${new p(this.config.mask).format(r)}`:`${l}: ${r}`}return l}getLabelFromCheckedOptions(t,i,e){const s=t.length;return 0===s?`${i}`:s>1?e?`${i}: ${t.map((t=>t.label)).join(",")}`:`${i}: ${s} ${this.getMessage("snkFilterBar.multiListToltip")}`:`${i}: ${t[0].label}`}calculateActiveCount(t){return t.reduce(((t,i)=>i.visible?t+1:t),0)}componentDidLoad(){this._filterItemElement&&(h.addIDInfo(this._filterItemElement),this._idSnkFilterDetail=`filterDetail_${this.config.id}`)}canClearFilter(){const{value:t,groupedItems:i=[]}=this.config;return null!=t&&this.config.type===z.MULTI_LIST?t.some((t=>t.check)):void 0!==t||i.some((t=>t.visible))}getRightIconName(){return this.canClearFilter()?"close":this.detailIsVisible?"chevron-up":"chevron-down"}getLeftIconName(){switch(this.config.type){case z.PERIOD:return"calendar";case z.PERSONALIZED:return"tune"}}hasActiveElements(t){var i;const e=Array.isArray(t)?t:null==t?void 0:t.elements;return(null===(i=null==e?void 0:e.filter((t=>null==t?void 0:t.check)))||void 0===i?void 0:i.length)>0}hasActiveValue(t){var i,e;return t.type===z.PERIOD?!!(null===(i=t.value)||void 0===i?void 0:i.start)||!!(null===(e=t.value)||void 0===e?void 0:e.end):t.type!==z.MULTI_LIST&&void 0!==t.value||this.hasActiveElements(t.value)}getEnabledChip(){if(this.detailIsVisible)return!0;if(this.config.type===z.PERSONALIZED){const{groupedItems:t=[]}=this.config;return t.some((t=>t.visible))}return this.hasActiveValue(this.config)}async handleVisibilityPopover(t){this.detailIsVisible=t.detail,this.detailIsVisible||await this._filterDetail.clearValue()}getCustomMessage(t,i){var e;return null===(e=this.getMessage)||void 0===e?void 0:e.call(this,`snkFilterBar.filterModal.${t}`,i)}hasValue(){return this.config.type===z.MULTI_LIST?this.hasActiveElements(this.config.value):null!=this.config.value}getTooltipMessage(){var t,i;return this.config.required&&!this.hasValue()?{message:null!==(t=this.config.requiredMessage)&&void 0!==t?t:this.getCustomMessage("validations.requiredFilter"),type:"error"}:!1===this.config.enabled&&this.config.disabledMessage?{message:this.config.disabledMessage,type:"warning"}:{message:null!==(i=this.config.defaultMessage)&&void 0!==i?i:this.getLabel(!0),type:"default"}}getTypeChip(t){switch(t){case"default":return"secondary";case"warning":return"warning-light";case"error":return"error-light";case"success":return"success-light";default:return t}}initKeyboardManager(){this._keyboardManager=new v({element:this._filterItemElement,propagate:!0}),this._keyboardManager.bind("Escape",(()=>this.hideDetail()))}connectedCallback(){this.initKeyboardManager()}disconnectedCallback(){this._keyboardManager.unbindAllShortcutKeys()}render(){const t=this.getLeftIconName(),{type:i,message:r}=this.getTooltipMessage();return e(s,null,this.showChips&&e("ez-tooltip",{id:this.config.id,message:r,type:i,active:!this.detailIsVisible,strategy:"fixed"},e("ez-chip",{id:this.config.id,ref:t=>this._chipElement=t,label:this.getLabel(),value:this.getEnabledChip(),onClick:t=>this.togglePopover(t),disableAutoUpdateValue:!0,type:this.getTypeChip(i),enabled:this.config.enabled},t&&e("ez-icon",{ref:t=>this._leftIconElement=t,iconName:t,slot:"leftIcon"}),e("ez-icon",{ref:t=>this._rightIconElement=t,iconName:this.getRightIconName(),slot:"rightIcon",id:"removeFilter",onClick:t=>this.clearFilter(t)}))),e("ez-popover-core",{ref:t=>this._popover=t,onEzVisibilityChange:t=>this.handleVisibilityPopover(t)},e("snk-filter-detail",{ref:t=>this._filterDetail=t,key:this.config.id,config:this.config,getMessage:this.getMessage,class:"sc-snk-filter-bar snk-filter__popover ez-padding--small ez-elevation--16","data-element-id":this._idSnkFilterDetail,showHardFixed:this.showChips&&!this.config.required,removalBlocked:this.config.required})))}get _filterItemElement(){return r(this)}static get watchers(){return{detailIsVisible:["observeDetailIsVisible"]}}};D.style="ez-popover-core.sc-snk-filter-item{--ez-popover__box--z-index:var(--elevation--20, 20);--ez-popover__box--overlay-z-index:var(--elevation--16, 16)}";const S="__SHOWMORE__",B=class{constructor(e){t(this,e),this.snkItemSelected=i(this,"snkItemSelected",7),this._preselection=-1,this.innerClickCheck=(t,i)=>i.id!=b.MODAL_ELEMENT_ID||(this._detailIsVisible=!1,!1),this._filterArgument=void 0,this._showAll=void 0,this.label=void 0,this.iconName=void 0,this.items=void 0,this.getMessage=void 0,this.emptyText=void 0,this.findFilterText=void 0,this.buttonClass=void 0}showDetail(){this._preselection=-1,this._floatingID=b.float(this._popover,this._popoverContainer,{autoClose:!0,innerClickTest:this.innerClickCheck,backClickListener:()=>this.onListCloseCallback(),useOverlay:!0}),this._detailIsVisible=!0,this._showAll=!1,this._filterArgument="",this._filterInput.setFocus()}async hideDetail(){null!=this._floatingID&&b.close(this._floatingID)}onListCloseCallback(){this._floatingID=void 0,this._detailIsVisible=!1}buttonClick(){this._detailIsVisible?this.hideDetail():this.showDetail()}componentDidLoad(){this._element&&h.addIDInfo(this._element)}componentDidRender(){null==this._floatingID&&this._popover&&this._popover.remove()}buildIdElement(t,i){if(!t)return;const e={id:i};t.removeAttribute(h.DATA_ELEMENT_ID_ATTRIBUTE_NAME),h.addIDInfoIfNotExists(t,"filterItemList",e)}buildItemElement(t){const i=++this._selectableItemsCount;return e("button",{ref:i=>i&&this.buildIdElement(i,t.label),id:`filter-item${i}`,onFocusin:()=>this._preselection=i,class:"ez-col ez-col--sd-12 ez-align--middle ez-padding--small sc-snk-filter-bar snk-filter-bar__filter-list-item",onClick:()=>this.itemSelected(t.name),name:t.label,key:i},t.iconName?e("ez-icon",{iconName:t.iconName,size:"small",class:`ez-padding-right--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-item__icon ${t.iconClass||""}`}):void 0,e("div",{class:`ez-text ez-text--medium ez-text--primary ez-padding--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-item__label ${t.labelClass||""}`},t.label))}itemSelected(t){t===S?this._showAll=!0:(this.hideDetail(),this.snkItemSelected.emit(t))}getFilterItems(){const t=this.items?g.applyStringFilter(this._filterArgument,this.items.filter((t=>"FILTER"===t.kind))):[];return 0===t.length?e("div",{class:"ez-text ez-text--medium ez-text--primary ez-padding--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-items-container--empty"},this.emptyText):(!this._filterArgument&&!this._showAll&&t.length>6&&(t.splice(5),t.push({kind:"INTERNAL",label:this.getMessage("snkFilterList.showMore"),iconName:"dots-horizontal",name:S,iconClass:"snk-filter-bar__filter-list-item__icon--secondary",labelClass:"snk-filter-bar__filter-list-item__label--secondary"})),this._selectableItemsCount=0,e("div",{class:"sc-snk-filter-bar snk-filter-bar__filter-list-items-container"},t.map((t=>this.buildItemElement(t)))))}getFooterItems(){return this.items.filter((t=>"FOOTER"===t.kind))}keyDownHandler(t){switch(t.key){case"ArrowDown":this.changePreselection(this._preselection+1),t.stopImmediatePropagation(),t.stopPropagation(),t.preventDefault();break;case"ArrowUp":this.changePreselection(this._preselection-1),t.stopImmediatePropagation(),t.stopPropagation(),t.preventDefault()}}changePreselection(t){if(t<0&&(t=this._selectableItemsCount),this._preselection=t>this._selectableItemsCount?0:t,0===this._preselection)this._filterInput.setFocus();else{const t=this._element.querySelector(`#filter-item${this._preselection}`);t&&t.focus()}}render(){return e(s,{class:"ez-flex ez-flex--column"},e("ez-button",{class:this.buttonClass,label:this.label,onClick:()=>this.buttonClick(),mode:this.iconName?"icon":void 0,iconName:this.iconName,size:"small"},e("slot",{name:"leftIcon"})),e("section",{class:"ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container",ref:t=>this._popoverContainer=t},e("div",{class:"sc-snk-filter-bar snk-filter__popover ez-padding--small ez-elevation--4",ref:t=>this._popover=t},e("ez-filter-input",{ref:t=>this._filterInput=t,"data-element-id":"serachFilters",mode:"slim",label:this.findFilterText,value:this._filterArgument,onEzChange:t=>this._filterArgument=t.detail,onFocus:()=>this._preselection=0}),this.getFilterItems(),e("hr",{class:"sc-snk-filter-bar snk-filter__popover-rule"}),this.items?this.getFooterItems().map((t=>this.buildItemElement(t))):void 0)))}get _element(){return r(this)}},E=class{constructor(i){t(this,i),this._isUserSup=!1,this.filters=[],this.filtersWithError=[],this.getMessage=void 0,this.configName=void 0,this.filterConfig=void 0,this.opened=!1,this.applyFilters=void 0,this.closeModal=void 0,this.addPersonalizedFilter=void 0,this.editPersonalizedFilter=void 0,this.deletePersonalizedFilter=void 0,this.filtersToDelete=[],this.filterDefaultToDelete=void 0,this.disablePersonalizedFilter=void 0,this.filterCustomConfigInterceptor=void 0}filterConfigChangeHandler(t){this.filters=o.copy(t),this.validateFilters()}deletePersonalizedFilterListener(t){this.filtersToDelete.push(t.detail)}getCustomMessage(t,i){var e;return null===(e=this.getMessage)||void 0===e?void 0:e.call(this,`snkFilterBar.filterModal.${t}`,i)}handleClearAll(){const{customFilters:t,quickFilters:i,otherFilters:e,multiListFilters:s}=this.filters.reduce(((t,i)=>i.type===z.MULTI_LIST?(t.multiListFilters.push(i),t):i.filterType===T.QUICK_FILTER?(t.quickFilters.push(i),t):i.filterType===T.CUSTOM_FILTER?(t.customFilters.push(i),t):i.filterType===T.OTHER_FILTERS?(t.otherFilters.push(i),t):t),{quickFilters:[],customFilters:[],otherFilters:[],multiListFilters:[]});this.handleClearFilterList(i),this.handleClearCustomFilters(t),this.handleClearOthersFilters(e),s.forEach((t=>this.handleClearSigleFilter(t))),l(this)}handleClearOthersFilters(t){this.filters=this.filters.map((i=>t.includes(i)?Object.assign(Object.assign({},i),{value:void 0}):i))}handleClearCustomFilters(t){this.filters.forEach(((i,e)=>{i.filterType===T.CUSTOM_FILTER&&(this.filters[e]=this.clearAllCustomFilter(t).shift())}))}clearAllCustomFilter(t){return t.map((t=>{const i=Object.assign({},t);return delete i.value,i.visible=!1,i.groupedItems&&(i.groupedItems=this.clearAllCustomFilter(i.groupedItems)),i}))}hasChangeToSave(){return o.objectToString(this.filters)!=o.objectToString(this.filters)}handleClose(){if(this.hasChangeToSave())return $.confirm(this.getCustomMessage("validations.notSaved.title"),this.getCustomMessage("validations.notSaved.message")).then((t=>{t&&this.closeModal()}));this.closeModal()}handleApplyFilters(){if(!this.validateFilters())return;const t=this.filters.find((t=>t.filterType===T.CUSTOM_FILTER||t.filterType===T.DEFAULT_FILTER));this.isValidCustomFilter(t)&&this.applyFilters(this.filters),this.filtersToDelete.length>0&&(this.filtersToDelete.forEach((t=>{this.deletePersonalizedFilter(t,this.configName)})),this.filtersToDelete=[]),this.filterDefaultToDelete&&(this.deletePersonalizedFilter(this.filterDefaultToDelete,this.configName,!0),this._defaultFilter=void 0,this.filterDefaultToDelete=void 0)}isValidCustomFilter(t){return!!F.validateVariableValues(t)||($.alert(this.getCustomMessage("validations.notFullFilled.title"),this.getCustomMessage("validations.notFullFilled.message")),!1)}modalActionListener(t){switch(t.detail){case I.CANCEL:this.handleClearAll();break;case I.OK:this.handleApplyFilters();break;case I.CLOSE:this.handleClose()}}handleFilterChange(t){t.stopPropagation();const i=t.detail;let e=this.filters.map((t=>t.id===i.id?i:t));this.filterCustomConfigInterceptor&&(e=this.filterCustomConfigInterceptor(e)),this.filters=o.copy(e)}handleClearFilterList(t){this.filters=this.filters.map((i=>t.includes(i)?Object.assign(Object.assign({},i),{value:void 0}):i))}handleClearSigleFilter(t){if(z.MULTI_LIST===t.type){let i=o.copy(t);this.uncheckFilterValues(i.value);const e=o.copy(this.filters),s=e.findIndex((i=>i.id===t.id));return e.splice(s,1,i),void(this.filters=o.copy(e))}if(z.CHECK_BOX_LIST===t.type){const i=o.copy(this.filters);return i.find((i=>i.id===t.id)).value=void 0,void(this.filters=o.copy(i))}this.filters.find((i=>i.id===t.id)).value=void 0,this.filters=o.copy(this.filters)}uncheckFilterValues(t){return t.forEach((t=>{t&&(t.check=!1)})),t}validateFilters(){const t=L(this.filters);return this.filtersWithError=t.map((t=>t.id)),0===t.length||(t.forEach((t=>{const i=this._element.querySelector(`#filter-item-${t.id}`);i&&(i.errorMessage=t.requiredMessage||this.getCustomMessage("validations.requiredFilter"))})),!1)}renderFilterItem(t,i){return e("snk-filter-modal-item",{key:`modal-item-${t.id}`,class:i?"ez-col ez-col--sd-12":"ez-col ez-col--sd-6 ez-padding--small",filterItem:t,configName:this.configName,onFilterChange:t=>this.handleFilterChange(t),onEditPersonalizedFilter:t=>this.editPersonalizedFilter(t.detail),onAddPersonalizedFilter:()=>this.addPersonalizedFilter()})}isDefaultFilterNumberVariation(t){var i;return t.type===z.NUMBER&&(!t.props.variation||(null===(i=t.props)||void 0===i?void 0:i.variation)===C.DEFAULT)}mountFiltersLines(t){let i=0,e=!1;const s={};for(let r=0;r<t.length;r++){s[i]=s[i]||[];const l=t[r],a=r===t.length-1,n=l.type===z.TEXT||this.isDefaultFilterNumberVariation(l),o=!a&&(t[r+1].type===z.TEXT||this.isDefaultFilterNumberVariation(t[r+1]));n&&o||e?(s[i].push(l),e=s[i].length<2,2===s[i].length&&++i):(s[i]=s[i]||[],s[i].push(l),++i)}return Object.values(s)}renderFilterLine(t){const i=1===t.length;return t.map((t=>this.renderFilterItem(t,i)))}getIformedFiltersCount(t){let i=0;return t.forEach((t=>{var e,s,r,l,a,n,o,h;const d=this.filterConfig.find((i=>i.id===t.id));z.MULTI_LIST!==d.type?z.CHECK_BOX_LIST!==d.type?z.PERIOD!==d.type?null==d.groupedItems?d.value&&i++:i=d.groupedItems.filter((t=>t.visible)).length:((null===(o=d.value)||void 0===o?void 0:o.start)||(null===(h=d.value)||void 0===h?void 0:h.end))&&i++:i+=Object.entries(null!==(n=d.value)&&void 0!==n?n:{}).filter((([t,i])=>!0===i)).map((([t,i])=>t)).length:i+=null!==(a=null===(l=null===(r=null!==(s=null===(e=d.value)||void 0===e?void 0:e.elements)&&void 0!==s?s:d.value)||void 0===r?void 0:r.filter((t=>null==t?void 0:t.check)))||void 0===l?void 0:l.length)&&void 0!==a?a:0})),i}renderCollapsibleFilterBox(t,i,s,r=!0){if(!i.length)return null;const l=this.getIformedFiltersCount(i),a=this.mountFiltersLines(i),n=this.filtersWithError.filter((t=>i.some((i=>i.id===t)))).length;return e("ez-collapsible-box",{class:"snk-filter-modal__collapsible-box",headerSize:"medium",value:!0,label:t},e("div",{class:"ez-flex ez-flex--justify-end grow",slot:"rightSlot"},!!l&&e("ez-badge",{class:"ez-badge--primary-subtle",label:null==l?void 0:l.toString()}),!!n&&e("ez-badge",{class:"ez-badge--error-subtle",label:null==n?void 0:n.toString()})),e("div",{class:"ez-row snk-filter-modal__rendered-items"},a.map(this.renderFilterLine.bind(this))),r&&e("div",{class:"ez-flex ez-flex--justify-end grow"},e("ez-button",{class:"ez-button--tertiary",size:"medium",label:this.getCustomMessage("clearModal"),onClick:()=>s?this.handleClearSigleFilter(i[0]):this.handleClearFilterList(i)})))}handleDeleteFilter(){this._application.confirm(this.getMessage("snkPersonalizedFilter.deleteConfirm.title"),this.getMessage("snkPersonalizedFilter.info.deleteDefaultFilterConfirm"),"alert-circle-inverted","critical").then((t=>{t&&(this.filterDefaultToDelete=this._defaultFilter,this.filters=this.filters.filter((t=>t.id!==T.DEFAULT_FILTER)))}))}handleActionSelectedDefaultFilter({detail:t}){switch(t){case N.CREATE:this.addPersonalizedFilter(!0);break;case N.EDIT:this.editPersonalizedFilter(this._defaultFilter.id,!0);break;case N.REMOVE:this.handleDeleteFilter()}}getCustomFilter(t){return t.filter((t=>t.filterType===T.CUSTOM_FILTER))}getDefaultFilter(t){return t.find((t=>t.id===w.id))}async componentWillLoad(){this._application=c.getContextValue("__SNK__APPLICATION__"),this._isUserSup=await this._application.isUserSup(),this.filters=o.copy(this.filterConfig)}componentWillRender(){this._modalTitle=this.getCustomMessage("title"),this._okButtonLabel=this.getCustomMessage("okButtonLabel"),this._cancelButtonLabel=this.getCustomMessage("cancelButtonLabel")}componentDidLoad(){this.validateFilters()}render(){this._defaultFilter=this._isUserSup?this.getDefaultFilter(this.filters):void 0;const t=this.getCustomFilter(this.filters),i=this.filters.filter((t=>t.filterType===T.QUICK_FILTER)),s=this.filters.filter((t=>t.filterType===T.OTHER_FILTERS));return e("ez-modal",{opened:this.opened,modalSize:"col--sd-3",align:"right",heightMode:"full",closeEsc:!0},e("ez-modal-container",{class:"snk-filter-modal__container",modalTitle:this._modalTitle,cancelButtonLabel:this._cancelButtonLabel,okButtonLabel:this._okButtonLabel,onEzModalAction:this.modalActionListener.bind(this)},e("div",{class:"snk-filter-modal__content ez-col--sd-12"},this._isUserSup&&e("snk-default-filter",{getMessage:this.getCustomMessage.bind(this),hasDefaultFilter:!!this._defaultFilter,onActionSelected:this.handleActionSelectedDefaultFilter.bind(this)}),!this.disablePersonalizedFilter&&this.renderCollapsibleFilterBox(this.getCustomMessage("customFilters"),t,!1,!1),this.renderCollapsibleFilterBox(this.getCustomMessage("quickFilters"),i,!1),s.map((t=>this.renderCollapsibleFilterBox(t.label,[t],!0))))))}get _element(){return r(this)}static get watchers(){return{filterConfig:["filterConfigChangeHandler"]}}};E.style="ez-modal{--ez-modal-content-padding:24px 12px}.snk-filter-modal__container{min-width:344px;overflow:hidden}.snk-filter-modal__content{display:flex;flex-direction:column;gap:var(--space--medium, 12px);padding-right:var(--space--3xs, 4px)}.snk-filter-modal__collapsible-box{border:var(--border--small, 1px solid) var(--color--strokes, #DCE0E8);border-radius:var(--border--radius-medium);padding:var(--space--medium, 12px) var(--space--small, 6px)}.snk-filter-modal__rendered-items{max-height:760px}.snk-filter-modal__rendered-items::-webkit-scrollbar{width:var(--space--small);min-width:var(--space--small);max-width:var(--space--small)}";export{P as snk_filter_bar,D as snk_filter_item,B as snk_filter_list,E as snk_filter_modal}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as s,c as t,h as o,H as e}from"./p-
|
|
1
|
+
import{r as s,c as t,h as o,H as e}from"./p-82bb3eda.js";const n=class{constructor(o){s(this,o),this.snkCustomSlotElementsLoaded=t(this,"snkCustomSlotElementsLoaded",7),this.slotName="CUSTOM_SLOT_ELEMENTS"}componentDidLoad(){this.snkCustomSlotElementsLoaded.emit(this.slotName)}render(){return o(e,{slot:this.slotName,id:this.slotName,class:"custom-slot-elements-container"},o("slot",null))}};n.style=".sc-snk-custom-slot-elements-h{display:none}";export{n as snk_custom_slot_elements}
|