@sankhyalabs/sankhyablocks 2.2.2-SKA-60656.4 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/snk-application.cjs.entry.js +2 -0
- package/dist/cjs/snk-configurator_3.cjs.entry.js +9 -1
- package/dist/cjs/snk-crud.cjs.entry.js +10 -2
- package/dist/cjs/snk-filter-bar_7.cjs.entry.js +28 -16
- package/dist/cjs/snk-filter-detail.cjs.entry.js +10 -0
- package/dist/cjs/snk-form.cjs.entry.js +11 -2
- package/dist/cjs/{taskbar-elements-997af1c9.js → taskbar-elements-b995b84d.js} +26 -26
- package/dist/collection/components/snk-application/snk-application.js +3 -1
- package/dist/collection/components/snk-crud/snk-crud.js +10 -2
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +11 -1
- package/dist/collection/components/snk-form/snk-form.js +12 -3
- package/dist/collection/components/snk-grid/snk-grid.js +10 -1
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +26 -26
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +28 -16
- package/dist/components/snk-application2.js +3 -1
- package/dist/components/snk-crud.js +10 -2
- package/dist/components/snk-filter-detail2.js +11 -1
- package/dist/components/snk-form2.js +12 -3
- package/dist/components/snk-grid2.js +10 -1
- package/dist/components/snk-taskbar2.js +54 -42
- package/dist/esm/snk-application.entry.js +4 -2
- package/dist/esm/snk-configurator_3.entry.js +9 -1
- package/dist/esm/snk-crud.entry.js +11 -3
- package/dist/esm/snk-filter-bar_7.entry.js +28 -16
- package/dist/esm/snk-filter-detail.entry.js +11 -1
- package/dist/esm/snk-form.entry.js +12 -3
- package/dist/esm/taskbar-elements-a0a8c3ac.js +95 -0
- package/dist/sankhyablocks/p-00f6d216.entry.js +1 -0
- package/dist/sankhyablocks/{p-6340d992.entry.js → p-0e18f6e6.entry.js} +8 -8
- package/dist/sankhyablocks/p-4cbc4ae3.js +1 -0
- package/dist/sankhyablocks/p-6ca95ef3.entry.js +1 -0
- package/dist/sankhyablocks/{p-9b0f99fd.entry.js → p-975182f8.entry.js} +1 -1
- package/dist/sankhyablocks/p-c4e9394c.entry.js +1 -0
- package/dist/sankhyablocks/{p-7dcce5aa.entry.js → p-de0fe8a4.entry.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +1 -0
- package/dist/types/components/snk-crud/snk-crud.d.ts +2 -0
- package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +2 -0
- package/dist/types/components/snk-form/snk-form.d.ts +2 -0
- package/dist/types/components/snk-grid/snk-grid.d.ts +2 -0
- package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +2 -2
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +6 -2
- package/package.json +2 -3
- package/dist/esm/taskbar-elements-a0a8b106.js +0 -95
- package/dist/sankhyablocks/p-09720dd1.js +0 -1
- package/dist/sankhyablocks/p-0ffee54f.entry.js +0 -1
- package/dist/sankhyablocks/p-133cf71d.entry.js +0 -1
- package/dist/sankhyablocks/p-bc41625b.entry.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, h, g as getElement } from './index-e4121713.js';
|
|
2
|
-
import { DateUtils, ObjectUtils, ApplicationContext } from '@sankhyalabs/core';
|
|
2
|
+
import { DateUtils, ObjectUtils, ElementIDUtils, ApplicationContext } from '@sankhyalabs/core';
|
|
3
3
|
import { T as TaskbarProcessor } from './taskbar-processor-aa6772c9.js';
|
|
4
4
|
import { C as ConfigStorage } from './ConfigStorage-99025655.js';
|
|
5
5
|
import './_commonjsHelpers-9943807e.js';
|
|
@@ -140,6 +140,15 @@ const SnkForm = class {
|
|
|
140
140
|
}
|
|
141
141
|
return disabled;
|
|
142
142
|
}
|
|
143
|
+
dataunitReady() {
|
|
144
|
+
this.loadInsertionConfig();
|
|
145
|
+
const dataInfo = { dataUnit: this._dataUnit };
|
|
146
|
+
ElementIDUtils.addIDInfo(this._element, null, dataInfo);
|
|
147
|
+
}
|
|
148
|
+
getDataElementId(suffix) {
|
|
149
|
+
const elemIdSnkTaskBar = this._element.getAttribute("data-element-id");
|
|
150
|
+
return `${elemIdSnkTaskBar}_${suffix}`;
|
|
151
|
+
}
|
|
143
152
|
componentWillLoad() {
|
|
144
153
|
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
145
154
|
let parent = this._element.parentElement;
|
|
@@ -149,7 +158,7 @@ const SnkForm = class {
|
|
|
149
158
|
this._dataUnit = this._snkDataUnit.dataUnit;
|
|
150
159
|
this._dataState = this._snkDataUnit.dataState;
|
|
151
160
|
if (this._dataUnit) {
|
|
152
|
-
this.
|
|
161
|
+
this.dataunitReady();
|
|
153
162
|
}
|
|
154
163
|
else {
|
|
155
164
|
this._snkDataUnit.addEventListener("dataUnitReady", (evt) => {
|
|
@@ -183,7 +192,7 @@ const SnkForm = class {
|
|
|
183
192
|
if (!this._dataUnit || !this._dataState) {
|
|
184
193
|
return undefined;
|
|
185
194
|
}
|
|
186
|
-
return (h("section", { class: "snk-form" }, h("div", { class: "snk-form__header snk-form__header--fixed ez-row" }, h("div", { class: "ez-col ez-col--sd-6 ez-col--tb-6", key: "formHeader" }, h("ez-button", { title: this.getMessage("snkForm.goBackTitle"), mode: "icon", iconName: "arrow_back", class: "ez-padding-right--medium", size: "small", onClick: () => this.exitForm() }), h("h1", { class: "ez-title ez-title--primary ez-title--xlarge ez-align--middle" }, this.getMessage("snkForm.title"))), h("div", { class: "ez-col ez-col--sd-6 ez-col--tb-6 ez-align--right" }, h("snk-taskbar", { key: "formTaskbar", configName: this.configName, buttons: this._taskbarProcessor.buttons, disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, actionsList: this.actionsList, primaryButton: ((_a = this._dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", dataUnit: this._dataUnit }))), h("section", null, h("div", { class: "ez-row" }, h("div", { class: "ez-col ez-col--sd-12" }, h("ez-form", { key: "ezForm" + this._snkDataUnit.entityName, dataUnit: this._dataUnit, config: this.getFormConfig(), recordsValidator: this.recordsValidator, class: this._showFormConfig ? 'snk-form__form--hidden' : '' }), this._showFormConfig &&
|
|
195
|
+
return (h("section", { class: "snk-form" }, h("div", { class: "snk-form__header snk-form__header--fixed ez-row" }, h("div", { class: "ez-col ez-col--sd-6 ez-col--tb-6", key: "formHeader" }, h("ez-button", { title: this.getMessage("snkForm.goBackTitle"), mode: "icon", iconName: "arrow_back", class: "ez-padding-right--medium", size: "small", onClick: () => this.exitForm() }), h("h1", { class: "ez-title ez-title--primary ez-title--xlarge ez-align--middle" }, this.getMessage("snkForm.title"))), h("div", { class: "ez-col ez-col--sd-6 ez-col--tb-6 ez-align--right" }, h("snk-taskbar", { key: "formTaskbar", "data-element-id": this.getDataElementId("form_taskbar"), configName: this.configName, buttons: this._taskbarProcessor.buttons, disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, actionsList: this.actionsList, primaryButton: ((_a = this._dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", dataUnit: this._dataUnit }))), h("section", null, h("div", { class: "ez-row" }, h("div", { class: "ez-col ez-col--sd-12" }, h("ez-form", { key: "ezForm" + this._snkDataUnit.entityName, "data-element-id": this.getDataElementId("internal_form"), dataUnit: this._dataUnit, config: this.getFormConfig(), recordsValidator: this.recordsValidator, class: this._showFormConfig ? 'snk-form__form--hidden' : '' }), this._showFormConfig &&
|
|
187
196
|
h("snk-form-config", { dataUnit: this._dataUnit, formConfig: this.getFormConfig(), "data-element-id": this._element.getAttribute("data-element-id"), configName: this.configName, onConfigChange: (evt) => this.changeConfig(evt.detail), onConfigClose: () => this.closeConfig() }))))));
|
|
188
197
|
}
|
|
189
198
|
get _element() { return getElement(this); }
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { h } from './index-e4121713.js';
|
|
2
|
+
|
|
3
|
+
var TaskbarElement;
|
|
4
|
+
(function (TaskbarElement) {
|
|
5
|
+
TaskbarElement["PREVIOUS"] = "PREVIOUS";
|
|
6
|
+
TaskbarElement["NEXT"] = "NEXT";
|
|
7
|
+
TaskbarElement["REFRESH"] = "REFRESH";
|
|
8
|
+
TaskbarElement["UPDATE"] = "UPDATE";
|
|
9
|
+
TaskbarElement["CLONE"] = "CLONE";
|
|
10
|
+
TaskbarElement["REMOVE"] = "REMOVE";
|
|
11
|
+
TaskbarElement["INSERT"] = "INSERT";
|
|
12
|
+
TaskbarElement["CANCEL"] = "CANCEL";
|
|
13
|
+
TaskbarElement["SAVE"] = "SAVE";
|
|
14
|
+
TaskbarElement["GRID_MODE"] = "GRID_MODE";
|
|
15
|
+
TaskbarElement["FORM_MODE"] = "FORM_MODE";
|
|
16
|
+
TaskbarElement["MORE_OPTIONS"] = "MORE_OPTIONS";
|
|
17
|
+
TaskbarElement["DIVIDER"] = "DIVIDER";
|
|
18
|
+
TaskbarElement["CONFIGURATOR"] = "CONFIGURATOR";
|
|
19
|
+
})(TaskbarElement || (TaskbarElement = {}));
|
|
20
|
+
var AuthorizationElements;
|
|
21
|
+
(function (AuthorizationElements) {
|
|
22
|
+
AuthorizationElements["UPDATE"] = "UPDATE";
|
|
23
|
+
AuthorizationElements["CLONE"] = "CLONE";
|
|
24
|
+
AuthorizationElements["REMOVE"] = "REMOVE";
|
|
25
|
+
AuthorizationElements["INSERT"] = "INSERT";
|
|
26
|
+
AuthorizationElements["CONFIGURATOR"] = "CONFIGURATOR";
|
|
27
|
+
})(AuthorizationElements || (AuthorizationElements = {}));
|
|
28
|
+
var VisibleWhenForbidden;
|
|
29
|
+
(function (VisibleWhenForbidden) {
|
|
30
|
+
VisibleWhenForbidden["CONFIGURATOR"] = "CONFIGURATOR";
|
|
31
|
+
})(VisibleWhenForbidden || (VisibleWhenForbidden = {}));
|
|
32
|
+
const buildCustomButton = (def, className, dataElementId, action, isEnabled) => {
|
|
33
|
+
const { hint, text, iconName } = def;
|
|
34
|
+
if (iconName) {
|
|
35
|
+
if (text) {
|
|
36
|
+
return iconTextButton(iconName, def.name, className, dataElementId, hint, text, action, isEnabled);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return iconButton(iconName, def.name, className, dataElementId, hint, action, isEnabled);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
return textButton(def.name, className, dataElementId, text, hint, action, isEnabled);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const buildElem = (element, className, dataElementId, getTitle, action, isEnabled, actions) => {
|
|
47
|
+
const title = getTitle(element);
|
|
48
|
+
switch (element) {
|
|
49
|
+
case TaskbarElement.PREVIOUS:
|
|
50
|
+
return iconButton("chevron-left", element, className, dataElementId, title, action, isEnabled);
|
|
51
|
+
case TaskbarElement.NEXT:
|
|
52
|
+
return iconButton("chevron-right", element, className, dataElementId, title, action, isEnabled);
|
|
53
|
+
case TaskbarElement.REFRESH:
|
|
54
|
+
return iconButton("sync", element, className, dataElementId, title, action, isEnabled);
|
|
55
|
+
case TaskbarElement.UPDATE:
|
|
56
|
+
return iconButton("edit", element, className, dataElementId, title, action, isEnabled);
|
|
57
|
+
case TaskbarElement.CLONE:
|
|
58
|
+
return iconButton("copy", element, className, dataElementId, title, action, isEnabled);
|
|
59
|
+
case TaskbarElement.REMOVE:
|
|
60
|
+
return iconButton("delete", element, className, dataElementId, title, action, isEnabled);
|
|
61
|
+
case TaskbarElement.INSERT:
|
|
62
|
+
return iconTextButton("plus", element, className, dataElementId, title, title, action, isEnabled);
|
|
63
|
+
case TaskbarElement.CANCEL:
|
|
64
|
+
return textButton(element, className, dataElementId, title, title, action, isEnabled);
|
|
65
|
+
case TaskbarElement.SAVE:
|
|
66
|
+
return iconTextButton("save", element, className, dataElementId, title, title, action, isEnabled);
|
|
67
|
+
case TaskbarElement.GRID_MODE:
|
|
68
|
+
return iconButton("table", element, className, dataElementId, title, action, isEnabled);
|
|
69
|
+
case TaskbarElement.FORM_MODE:
|
|
70
|
+
return iconButton("list", element, className, dataElementId, title, action, isEnabled);
|
|
71
|
+
case TaskbarElement.CONFIGURATOR:
|
|
72
|
+
return iconButton("settings-inverted", element, className, dataElementId, title, action, isEnabled);
|
|
73
|
+
case TaskbarElement.MORE_OPTIONS:
|
|
74
|
+
return actionButton(element, className, dataElementId, title, action, isEnabled, actions);
|
|
75
|
+
case TaskbarElement.DIVIDER:
|
|
76
|
+
return h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-horizontal--medium", "data-taskbar-divider": true });
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
function textButton(name, className, dataElementId, text, title, action, isEnabled) {
|
|
80
|
+
return h("ez-button", { title: title, label: text, size: "small", class: className, "data-element-id": dataElementId, enabled: isEnabled(name), onClick: () => action(name) });
|
|
81
|
+
}
|
|
82
|
+
function iconButton(iconName, name, className, dataElementId, title, action, isEnabled) {
|
|
83
|
+
return h("ez-button", { name: iconName, title: title, mode: "icon", size: "small", class: className, "data-element-id": dataElementId, iconName: iconName, enabled: isEnabled(name), onClick: () => action(name) });
|
|
84
|
+
}
|
|
85
|
+
function iconTextButton(iconName, name, className, dataElementId, text, title, action, isEnabled) {
|
|
86
|
+
return h("ez-button", { name: iconName, title: title, label: text, size: "small", class: className, "data-element-id": dataElementId, enabled: isEnabled(name), onClick: () => action(name) },
|
|
87
|
+
h("ez-icon", { class: "ez-padding-right--small", slot: "leftIcon", iconName: iconName }));
|
|
88
|
+
}
|
|
89
|
+
function actionButton(element, className, dataElementId, title, action, isEnabled, actions) {
|
|
90
|
+
return actions && actions.length > 0
|
|
91
|
+
? h("ez-actions-button", { title: title, size: "small", "data-element-id": dataElementId, arrowActive: true, class: className, enabled: isEnabled(element), onEzAction: (evt) => action(evt.detail.value), actions: actions })
|
|
92
|
+
: undefined;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export { AuthorizationElements as A, TaskbarElement as T, VisibleWhenForbidden as V, buildCustomButton as a, buildElem as b };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,c as e,h as i,H as s,g as l}from"./p-9ba3df4c.js";import{ApplicationUtils as r}from"@sankhyalabs/ezui/dist/collection/utils";import{F as n}from"./p-9dd2b8cb.js";import{ElementIDUtils as a,DataType as o}from"@sankhyalabs/core";const h=class{constructor(i){t(this,i),this.filterChange=e(this,"filterChange",7)}async show(){this._editor.show()}componentDidLoad(){if(this._element){a.addIDInfo(this._element);const t=this._element.getAttribute("data-element-id");this._idContentEditor=`${t}_${this.config.id}`}}changeConfig(t){this.filterChange.emit(t)}getContentEditor(){switch(this.config.type){case n.BINARY_SELECT:return"snk-filter-binary-select";case n.MULTI_SELECT:return"snk-filter-multi-select";case n.PERIOD:return"snk-filter-period";case n.SEARCH:return"snk-filter-search";case n.NUMBER:return"snk-filter-number";case n.PERSONALIZED:return"snk-filter-personalized"}return"snk-filter-text"}removeItem(){this.changeConfig(Object.assign(Object.assign({},this.config),{visible:!1,fixed:!1,value:void 0}))}getPopUpHeaderButtons(){if(!this.config.hardFixed)return[this.buildIcon(this.getMessage("snkFilterBar.removeFilter"),"delete",(()=>this.removeItem())),this.buildIcon(this.getMessage(this.config.fixed?"snkFilterBar.unpinFilter":"snkFilterBar.pinFilter"),this.config.fixed?"un-pin":"push-pin",(()=>this.changeConfig(Object.assign(Object.assign({},this.config),{fixed:!this.config.fixed}))))]}buildIcon(t,e,s){return i("button",{onClick:()=>s(),class:"sc-snk-filter-bar snk-filter-item__editor-header-button"},i("ez-icon",{title:t,iconName:e}))}getNormalizedValue(t,e){return t.reduce(((t,e,i)=>(e.dataType!==o.BOOLEAN||null!=t&&null!=t[i]||((t=t||[])[i]=!1),t)),e)}apply(){var t;let e=this._editor.value,i=!0;if(this.config.type===n.PERSONALIZED){const s=(null===(t=this.config.props.personalizedFilter)||void 0===t?void 0:t.parameters)||[];e=this.getNormalizedValue(s,e);const l=s.length;0===l?e=[]:i=this.validateAllFilled(l,e)}i&&this.changeConfig(Object.assign(Object.assign({},this.config),{value:e}))}validateAllFilled(t,e){let i=!0;return null!=e&&t>1&&(t>e.length?i=!1:e.forEach((t=>{null==t&&(i=!1)}))),i||r.alert("Filtro parcialmente preenchido","Favor completar todas as informações do filtro."),i}clear(){this.changeConfig(Object.assign(Object.assign({},this.config),{value:void 0}))}onKeyDonwListener(t){"Enter"===t.key&&this._applyButton.setFocus().then((()=>this.apply()))}render(){const t=this.getContentEditor();return i(s,null,i("div",{class:"col ez-col--sd-12 ez-align--right ez-padding-medium ez-flex--align-items-center"},i("div",{class:"ez-text ez-title ez-title--small ez-padding--small sc-snk-filter-bar snk-filter-item__editor-header"},this.config.detailTitle),this.getPopUpHeaderButtons()),i(t,{ref:t=>this._editor=t,value:this.config.value,config:this.config,onKeyDown:t=>this.onKeyDonwListener(t),"data-element-id":this._idContentEditor}),i("hr",{class:"sc-snk-filter-bar snk-filter__popover-rule"}),i("div",{class:"ez-col ez-col--sd-12 ez-align--right"},i("ez-button",{label:this.getMessage("snkFilterBar.cleanFilter"),onClick:()=>this.clear(),size:"small"}),i("ez-button",{ref:t=>this._applyButton=t,label:this.getMessage("snkFilterBar.applyFilter"),onClick:()=>this.apply(),size:"small",class:"ez-button--primary ez-padding-left--medium"})))}get _element(){return l(this)}};export{h as snk_filter_detail}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import{r as t,c as e,h as s}from"./p-9ba3df4c.js";import{WaitingChangeException as
|
|
1
|
+
import{r as t,c as e,h as s,g as i}from"./p-9ba3df4c.js";import{WaitingChangeException as r,WarningException as n,ErrorException as a,ObjectUtils as o,DataType as c,DataUnit as h,StringUtils as u,ChangeOperation as l,DateUtils as d,DependencyType as p,ApplicationContext as m,ErrorTracking as f,ElementIDUtils as y}from"@sankhyalabs/core";import{d as g,D as v,R as w,U as I,F as _,G as P,C as $}from"./p-6ba8f415.js";import{ApplicationUtils as D}from"@sankhyalabs/ezui/dist/collection/utils";import{S}from"./p-877bd6cf.js";import"./p-112455b1.js";class C{constructor(t){this._app=t,window.addEventListener("error",(t=>this.errorHandler(t))),window.addEventListener("unhandledrejection",(t=>this.rejectionHandler(t)))}rejectionHandler(t){const e=t.reason;e instanceof r||(e?this.processException(e):this._app.isDebugMode().then((t=>{t&&this._app.error("Promise rejeitada","Erro interno: Uma promise foi rejeitada sem razão determinada.")})))}errorHandler(t){this.processException(t.error)}buildErrorCodeHTML(t){return'<br><a href="#" onclick="try{window.workspace.openHelp(\'_tbcode:'+t.errorCode+"')} catch(e){alert('Não é possível abrir a ajuda fora do workspace Sankhya');}\">Código: "+t.errorCode+"</a>"}processException(t){t.errorCode&&(t.message+=this.buildErrorCodeHTML(t)),t instanceof r||t instanceof n?this._app.alert(t.title,t.message):t instanceof a?this._app.error(t.title,t.message):this._app.isDebugMode().then((e=>{if(e)if(t instanceof Error)this._app.error(t.name,t.message);else{const e=(null==t?void 0:t.title)||"Erro detectado",s="string"==typeof t?t:t.message||`Erro interno "${o.objectToString(t)}"`;this._app.error(e,s)}}))}}class A{constructor(){this._defaultPageSize=100,this._templateByQuery=new Map,this.buldTemplates()}buldTemplates(){this._templateByQuery.set("search",g.gql`query($entityName: String! $argument: String $criteria: InputSearchCriteria $options: InputSearchOptions) {
|
|
2
2
|
$queryAlias$: search(entityName: $entityName argument: $argument criteria: $criteria options: $options){
|
|
3
3
|
value
|
|
4
4
|
label
|
|
5
5
|
}
|
|
6
|
-
}`)}loadSearchOptions(t,e,s,i){const r=(null==e?void 0:e.trim())||void 0;return e=isNaN(Number(r))&&r?`%${r}`:r,new Promise(((r,n)=>{
|
|
6
|
+
}`)}loadSearchOptions(t,e,s,i){const r=(null==e?void 0:e.trim())||void 0;return e=isNaN(Number(r))&&r?`%${r}`:r,new Promise(((r,n)=>{v.get().callGraphQL({values:{argument:e,entityName:t,criteria:s,options:i},query:this._templateByQuery.get("search")}).then((t=>{r(t)})).catch((t=>{n(t)}))}))}loadAdvancedSearch(t,e,s,i){const r={query:{$:null==s?void 0:s.expression}};(null==s?void 0:s.params.length)>0&&(r.params={param:s.params.map((t=>{let e=t.value,s=t.dataType;return s===c.OBJECT?(e=e.value,s="S"):s=function(t){switch(t){case c.NUMBER:return"I";case c.DATE:return"D";default:return"S"}}(t.dataType),{$:e,type:s}}))});const n={serviceName:"PesquisaSP.getSuggestion",requestBody:{criteria:{entityName:t,compacted:!1,ignoreEntityCriteria:!1,limit:this._defaultPageSize,query:{$:e},orderByDesc:!1,externalCriteria:r,localEntityName:null==i?void 0:i.rootEntity},clientEventList:{clientEvent:[]}}};return new Promise(((t,e)=>{v.get().callServiceBroker("PesquisaSP.getSuggestion",JSON.stringify(n)).then((e=>t(e))).catch((t=>e(t)))}))}}function T(){const t=["2909523kXwted","CompanyName=Sankhya Jiva Tecnologia e Inovao Ltda,LicensedApplication=Sankhya Gestao,LicenseType=SingleApplication,LicensedConcurrentDeveloperCount=2,LicensedProductionInstancesCount=0,AssetReference=AG-019460,ExpiryDate=9_November_2022_[v2]_MTY2Nzk1MjAwMDAwMA==10487151e296ee4360f80961ca960869","1131048CARoeW","502909mLEPmu","447255iQEXuN","428UHbJwW","270AFTxAV","194369jhGqTI","1540nWuTrj","2044062GicUQI","30CkXPWg"];return(T=function(){return t})()}const N=E;function E(t,e){const s=T();return(E=function(t){return s[t-=392]})(t,e)}!function(){const t=E,e=T();for(;;)try{if(951926==-parseInt(t(398))/1+-parseInt(t(393))/2+parseInt(t(395))/3+-parseInt(t(400))/4*(parseInt(t(392))/5)+-parseInt(t(401))/6*(-parseInt(t(402))/7)+parseInt(t(397))/8+-parseInt(t(399))/9*(-parseInt(t(394))/10))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const b=N(396);class q{constructor(){this.templateByQuery=new Map,this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchTotals",g.gql`query($filters: [InputFilter!] $name: String!) {
|
|
7
7
|
$queryAlias$: fetchTotals(name: $name, filters: $filters ){
|
|
8
8
|
name
|
|
9
9
|
value
|
|
10
10
|
}
|
|
11
|
-
}`)}async getTotals(t,e,s){let i={name:`totals://${t}/${e}`,filters:s};return
|
|
11
|
+
}`)}async getTotals(t,e,s){let i={name:`totals://${t}/${e}`,filters:s};return v.get().callGraphQL({values:i,query:this.templateByQuery.get("fetchTotals")})}fetchTotals(t,e,s=[]){return new Promise(((i,r)=>{this.getTotals(t,e,s).then((t=>{if(t.length>0){const e=new Map;t.forEach((t=>{e.set(t.name,parseFloat(t.value))})),i(e)}else r("Não foi possível recuperar os totalizadores")})).catch((t=>{r(t)}))}))}}class U{constructor(){this.templateByQuery=new Map,this._loadDataTimeout={},this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchDataUnit",g.gql`query($name: String!) {
|
|
12
12
|
$queryAlias$: fetchDataUnit(name: $name){
|
|
13
13
|
name
|
|
14
14
|
fields{
|
|
@@ -33,7 +33,7 @@ import{r as t,c as e,h as s}from"./p-9ba3df4c.js";import{WaitingChangeException
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
}`),this.templateByQuery.set("fetchData",
|
|
36
|
+
}`),this.templateByQuery.set("fetchData",g.gql`query($dataunit: String! $limit: Int $offset:Int $filters: [InputFilter!] $sort: [InputSort!]) {
|
|
37
37
|
$queryAlias$: fetchDataUnit(name: $dataunit){
|
|
38
38
|
data(limit: $limit offset: $offset filters: $filters sort: $sort){
|
|
39
39
|
limit
|
|
@@ -49,7 +49,7 @@ import{r as t,c as e,h as s}from"./p-9ba3df4c.js";import{WaitingChangeException
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
}`),this.templateByQuery.set("saveData",
|
|
52
|
+
}`),this.templateByQuery.set("saveData",g.gql`mutation($changes: [InputBatchChange!]!) {
|
|
53
53
|
$queryAlias$: batchOperationDataUnit(changes: $changes){
|
|
54
54
|
oldId
|
|
55
55
|
id
|
|
@@ -58,7 +58,7 @@ import{r as t,c as e,h as s}from"./p-9ba3df4c.js";import{WaitingChangeException
|
|
|
58
58
|
value
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
}`),this.templateByQuery.set("fetchDataRecord",
|
|
61
|
+
}`),this.templateByQuery.set("fetchDataRecord",g.gql`query($dataunit: String! $recordID: [String!]) {
|
|
62
62
|
$queryAlias$: fetchDataUnit(name: $dataunit){
|
|
63
63
|
record(id: $recordID){
|
|
64
64
|
id
|
|
@@ -68,9 +68,9 @@ import{r as t,c as e,h as s}from"./p-9ba3df4c.js";import{WaitingChangeException
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
}`)}getDataUnit(t,e){const s=new
|
|
71
|
+
}`)}getDataUnit(t,e){const s=new h(`dd://${t}/${e}`);return s.metadataLoader=t=>this.loadMetadata(t),s.dataLoader=(t,e)=>this.loadData(t,e),s.saveLoader=(t,e)=>this.saveData(t,e),s.removeLoader=(t,e)=>this.removeRecords(t,e),s.recordLoader=(t,e)=>this.loadRecord(t,e),s}loadMetadata(t){return new Promise(((e,s)=>{v.get().callGraphQL({values:{name:t.name},query:this.templateByQuery.get("fetchDataUnit")}).then((t=>{var s;const i={name:t.name,label:t.name,fields:[]};null===(s=t.fields)||void 0===s||s.forEach((t=>{let e;Array.isArray(t.properties)&&(e={},t.calculated&&(e.gridHeaderTooltip="Campos calculados não podem ser ordenados"),t.properties.forEach((t=>e[t.name]=t.value))),i.fields.push(Object.assign(Object.assign({},t),{properties:e}))})),e(i)})).catch((t=>{s(t)}))}))}loadData(t,e){const s=t.name;return this._loadDataTimeout[s]&&(clearTimeout(this._loadDataTimeout[s]),delete this._loadDataTimeout[s]),new Promise(((i,r)=>{this._loadDataTimeout[s]=setTimeout((()=>{delete this._loadDataTimeout[s],this.doLoadData(t,e).then((t=>i(t))).catch((t=>r(t)))}),200)}))}doLoadData(t,e){return new Promise(((s,i)=>{var r;const{sort:n,filters:a,limit:o,offset:h,quickFilter:l}=e,d={dataunit:t.name,sort:n,filters:a};if(d.limit=o,d.offset=h,!u.isEmpty(null==l?void 0:l.term)){void 0===d.filter&&(d.filter=[]);const t={name:"__QUICK_FILTER__",expression:"__QUICK_FILTER__",params:[{name:"term",dataType:c.TEXT,value:l.term}]};(null===(r=null==l?void 0:l.fields)||void 0===r?void 0:r.length)>0&&t.params.push({name:"fields",dataType:c.OBJECT,value:l.fields}),d.filter.push(t)}v.get().callGraphQL({values:d,query:this.templateByQuery.get("fetchData")}).then((e=>{const{limit:i,offset:r,total:n,hasMore:a,records:o}=e.data;let c;i&&(c={firstRecord:0==n?0:r+1,lastRecord:r+Math.min(o.length,i),total:n,currentPage:r/i,hasMore:a});const h=[];o.forEach((e=>{const s={__record__id__:e.id};e.fields.forEach((({name:e,value:i})=>{s[e]=t.valueFromString(e,i)})),h.push(s)})),s({paginationInfo:c,records:h})})).catch((t=>{i(t)}))}))}saveData(t,e){const s=e.map((e=>{const{dataUnit:s,record:i,updatingFields:r,operation:n}=e;let a;r&&(a=Object.entries(r).map((([e,s])=>{const i=t.getField(e);return{fieldName:e,dataType:i?i.dataType:c.TEXT,value:t.valueToString(e,s)}})));const o={dataUnit:s,fields:a,operation:n,recordId:i.__record__id__};return e.sourceId&&(o.sourceId=e.sourceId),o}));return new Promise(((e,i)=>{v.get().callGraphQL({values:{changes:s},query:this.templateByQuery.get("saveData")}).then((s=>{const i=[];null==s||s.forEach((e=>{const s={__record__id__:e.id};e.oldId&&(s.__old__id__=e.oldId),e.fields.forEach((({name:e,value:i})=>{s[e]=t.valueFromString(e,i)})),i.push(s)})),e(i)})).catch((t=>{i(t)}))}))}removeRecords(t,e){const s=e.map((e=>({dataUnit:t.name,operation:l.DELETE,recordId:e})));return new Promise(((t,i)=>{v.get().callGraphQL({values:{changes:s},query:this.templateByQuery.get("saveData")}).then((()=>{t(e)})).catch((t=>{i(t)}))}))}loadRecord(t,e){return new Promise(((s,i)=>{v.get().callGraphQL({values:{recordID:e,dataunit:t.name},query:this.templateByQuery.get("fetchDataRecord")}).then((e=>{const i=[];e.record.forEach((e=>{const s={__record__id__:e.id};e.fields.forEach((({name:e,value:i})=>{s[e]=t.valueFromString(e,i)})),i.push(s)})),s(i)})).catch((t=>{i(t)}))}))}}var O;class F{static openAppActivity(t,e){var s;null===(s=window.workspace)||void 0===s||s.openAppActivity(t,e)}}F.resourceID=null===(O=window.workspace)||void 0===O?void 0:O.resourceID;class R{constructor(){this.templateByQuery=new Map,this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchParam",g.gql`query($name: String!) {
|
|
72
72
|
$queryAlias$: fetchResource(name: $name){
|
|
73
73
|
name
|
|
74
74
|
resource
|
|
75
75
|
}
|
|
76
|
-
}`)}async getParam(t){const e=`param://application?params=${t}`;return y.get().callGraphQL({values:{name:e},query:this.templateByQuery.get("fetchParam")})}async asString(t){const e=await this.getParam(t);return this.getValue(e)}async asInteger(t){const e=await this.getParam(t);return parseInt(this.getValue(e))}async asFloat(t){const e=await this.getParam(t);return parseFloat(this.getValue(e))}async asBoolean(t){const e=await this.getParam(t);return this.getValue(e).includes('"S"')}async asDate(t){const e=await this.getParam(t);return l.strToDate(this.getValue(e))}async getBatchParams(t){const e=await this.getParam(t.join(",")),s={};return e.forEach((t=>s[t.name]=t.resource)),s}getValue(t={}){return Array.isArray(t)&&t.length>0&&(t=t[0]),h.isEmpty(t.resource)?"":t.resource}}const F=R;function R(t,e){const s=L();return(R=function(t){return s[t-=378]})(t,e)}function L(){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(L=function(){return t})()}!function(){const t=R,e=L();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 j{[F(397)](t){const e=F;if(typeof(t=utxt(t[e(390)]))==e(392)&&(t=JSON[e(400)](t)),null==t)throw Error(e(395));const s=new k("S"===t[e(402)]||!0===t[e(402)]);return Array[e(394)](t[e(391)])&&t[e(391)][e(385)]((t=>s.putAccess(t[e(382)],String(t.status)==e(398)))),s}}class k{constructor(t){const e=F;this.isSup=t,this[e(384)]={}}[F(378)](t,e){this[F(384)][t]=e}[F(393)](t){const e=F;if(this[e(402)])return!0;let s=!0;return this[e(384)][e(380)](t)&&(s=this.actions[t]),s}isUserSup(){return this.isSup}}class M extends g{getData(t){const e=`cfg://auth/${t}`;return new Promise(((t,s)=>{this.loadResource(e).then((e=>{let s=a.stringToObject(e);s&&"object"==typeof s&&t(s)})).catch((t=>{s(t)}))}))}}var x;function B(t){if(null==t)return t;if(t instanceof Date)return t.toISOString();if("object"==typeof t){if(t instanceof Array)return t.map((t=>B(t)));{const e=Object.assign({},t);return Object.keys(t).forEach((s=>{t[s]?e[s]=B(t[s]):delete e[s]})),e}}return t}!function(t){t.INSERT="I",t.UPDATE="A",t.REMOVE="E",t.SHOW="C",t.CONFIG="F",t.CONFIG_NUMBER="N",t.CLONE="D",t.CONFIG_GRID="G"}(x||(x={}));class z extends g{saveConfig(t,e,s){const i=t.map((t=>{const{id:e,value:s,fixed:i,visible:r}=t,n={id:e};return s&&(n.value=B(s)),i&&(n.fixed=i),r&&(n.visible=!0),n}));return this.saveResource(i,`cfg://filter/FilterBarState:${e}/${s}`)}getConfig(t,e){return new Promise(((s,i)=>{this.loadResource(`cfg://filter/FilterBarState:${t}/${e}`).then((t=>{let e;t&&(e=JSON.parse(t).items),s(e||[])})).catch((t=>{i(t)}))}))}}class G extends g{getDefaultValues(t){return new Promise(((e,s)=>{this.loadResource(`cfg://defaultValues/${t}`).then((t=>{let s;t&&(s=JSON.parse(t)),e(s)})).catch((t=>{s(t)}))}))}}const J=class{constructor(s){t(this,s),this.applicationLoaded=e(this,"applicationLoaded",7),this.applicationLoading=e(this,"applicationLoading",7),this._authPromises=[],this._duCache=new Map,this._duPromises=new Map,this._requestListener=new H}get parameters(){return this._parameters||(this._parameters=new O),this._parameters}get resourceID(){return this._resourceID||(this._resourceID=this.urlParams.get("workspaceResourceID")||this.urlParams.get("resourceID")||U.resourceID||"unknown.resource.id"),this._resourceID}get auth(){return this._auth?Promise.resolve(this._auth):new Promise(((t,e)=>{const s=this._authPromises.length>0;this._authPromises.push(new V(t,e)),s||this.authFetcher.getData(this.resourceID).then((t=>{for(this._auth=t;this._authPromises.length>0;)this._authPromises.pop().resolve(this._auth)})).catch((t=>{for(;this._authPromises.length>0;)this._authPromises.pop().reject(t)}))}))}async isUserSup(){return new Promise(((t,e)=>{this.auth.then((s=>{this.getAuthList(s).then((e=>{t(e.isSup)})).catch((t=>e(t)))}))}))}async hasAccess(t){return new Promise(((e,s)=>{this.auth.then((i=>{this.getAuthList(i).then((s=>{e(s.isSup||s.actions[t])})).catch((t=>s(t)))}))}))}async getAllAccess(){return new Promise(((t,e)=>{this.auth.then((s=>{this.getAuthList(s).then((e=>{const s={};s.isSup=e.isSup,Object.entries(x).forEach((t=>{s[t[0]]=e.actions[t[1]]||!1})),t(s)})).catch((t=>e(t)))}))}))}async getStringParam(t){return this.parameters.asString(t)}async getIntParam(t){return this.parameters.asInteger(t)}async getFloatParam(t){return this.parameters.asFloat(t)}async getBooleanParam(t){return this.parameters.asBoolean(t)}async getDateParam(t){return this.parameters.asDate(t)}async showPopUp(t,e="full",s=!0){this.clearContent(this._popUp),this._popUp.appendChild(t),this._popUp.opened=!0,this._popUp.heightMode=e,this._popUp.useHeader=s,"EZ-MODAL-CONTAINER"===t.tagName&&(this._popUp.useHeader=!1)}async showModal(t){this.clearContent(this._rightModal),this._rightModal.appendChild(t),this._rightModal.opened=!0}async closeModal(){this.clearContent(this._rightModal),this._rightModal.opened=!1}async closePopUp(){this.clearContent(this._popUp),this._popUp.opened=!1,this._popUp.useHeader=!0,this._popUp.heightMode="full"}async temOpcional(t){const e=t.split(",");return new Promise(((t,s)=>{this.getAttributeFromHTMLWrapper("opc0009").then((i=>{"1"===i?t(!0):Promise.all(e.map((t=>this.getAttributeFromHTMLWrapper("opc"+t)))).then((e=>{t(e.includes("1"))})).catch((t=>{s(t)}))})).catch((t=>{s(t)}))}))}async getConfig(t){let e={serviceName:"SystemUtilsSP.getConf",requestBody:{config:{chave:t,tipo:"T"}}};return new Promise(((t,s)=>{y.get().callServiceBroker("SystemUtilsSP.getConf",JSON.stringify(e)).then((e=>{var s;return t(null===(s=e.config)||void 0===s?void 0:s.data)})).catch((t=>s(t)))}))}async saveConfig(t,e){let s={serviceName:"SystemUtilsSP.saveConf",requestBody:{config:{chave:t,tipo:"T",data:e}}};return new Promise(((t,e)=>{y.get().callServiceBroker("SystemUtilsSP.saveConf",JSON.stringify(s)).then((e=>t(e))).catch((t=>e(t)))}))}async getAttributeFromHTMLWrapper(t){return Promise.resolve(window[t])}async openApp(t,e){U.openAppActivity(t,e)}getDuPromissesStack(t){let e;return t&&(e=this._duPromises.get(t),e||(e=[],this._duPromises.set(t,e))),e||[]}async createDataunit(t,e){return new Promise(((s,i)=>{const r=this.getDuPromissesStack(e),n=r.length>0;if(r.push(new V(s,i)),!n){const s=this.dataUnitFetcher.getDataUnit(t,this.resourceID);s.loadMetadata().then((()=>{for(e&&this._duCache.set(e,s);r.length>0;)r.pop().resolve(s)})).catch((t=>{for(;r.length>0;)r.pop().reject(t)}))}}))}async getDataUnit(t,e){return new Promise(((s,i)=>{const r=this._duCache.get(e);r?s(r):this.createDataunit(t,e).then((t=>{s(t)})).catch((t=>i(t)))}))}async getResourceID(){return Promise.resolve(this.resourceID)}async getUserID(){return Promise.resolve(window.UID)}async alert(t,e,s,i){return _.alert(t,e,s,i)}async error(t,e,s,i){return _.error(t,e,s,i)}async success(t,e,s,i){return _.success(t,e,s,i)}async message(t,e,s,i){return _.message(t,e,s,i)}async confirm(t,e,s,i,r){return _.confirm(t,e,s,i,r)}async info(t,e){return _.info(t,e)}async loadFormConfig(t){return this.formConfigFetcher.loadFormConfig(t,this.resourceID)}async loadGridConfig(t){return this.gridConfigFetcher.getConfig(t,this.resourceID)}async fetchUserAvailableConfigs(t){return this.formConfigFetcher.fetchUserAvailableConfigs(t,this.resourceID)}async fetchLegacyConfig(t){return this.formConfigFetcher.fetchLegacyConfig(t,this.resourceID)}async fetchDefaultConfig(t){return this.formConfigFetcher.fetchDefaultConfig(t,this.resourceID)}async loadTotals(t,e,s){return this.totalsFetcher.fetchTotals(t,e,s)}async saveGridConfig(t){return this.gridConfigFetcher.saveConfig(t,this.resourceID)}async getFilterBarConfig(t){return new Promise(((e,s)=>{this.configName===t&&this._filterBarConfig?e(this._filterBarConfig):this.configName===t&&null!=this._filterConfigPromise?Promise.all([this._filterConfigPromise]).then((t=>e(t[0]))).catch((t=>s(t[0]))):this.filterBarConfigFetcher.getConfig(this.resourceID,t).then((t=>e(t))).catch((t=>s(t)))}))}async saveFilterBarConfig(t,e){return this.filterBarConfigFetcher.saveConfig(t,this.resourceID,e)}async saveFormConfig(t,e){return this.formConfigFetcher.saveConfig(t,e,this.resourceID)}async getDefaultValues(){return this.defaultValuesFetcher.getDefaultValues(this.resourceID)}async getDefaultValue(t){return this._defaultValues&&this._defaultValues[t]}async getAuthList(t){return await(new j).parseFromJSON(t)}get urlParams(){return this._urlParams||(this._urlParams=v.getQueryParams(location.search)),this._urlParams}get dataUnitFetcher(){return this._dataUnitFetcher||(this._dataUnitFetcher=new b),this._dataUnitFetcher}get formConfigFetcher(){return this._formConfigFetcher||(this._formConfigFetcher=new w),this._formConfigFetcher}get gridConfigFetcher(){return this._gridConfigFetcher||(this._gridConfigFetcher=new I),this._gridConfigFetcher}get totalsFetcher(){return this._totalsFetcher||(this._totalsFetcher=new E),this._totalsFetcher}get pesquisaFetcher(){return this._pesquisaFetcher||(this._pesquisaFetcher=new S),this._pesquisaFetcher}get authFetcher(){return this._authFetcher||(this._authFetcher=new M),this._authFetcher}get filterBarConfigFetcher(){return this._filterBarConfigFetcher||(this._filterBarConfigFetcher=new z),this._filterBarConfigFetcher}get defaultValuesFetcher(){return this._defaultValuesFetcher||(this._defaultValuesFetcher=new G),this._defaultValuesFetcher}async executeSearch(t,e,s){const i=null==s?void 0:s.getField(e);if(i){const{mode:e,argument:r}=t,{ENTITYNAME:n,CODEFIELD:a,DESCRIPTIONFIELD:c,ROOTENTITY:h,DESCRIPTIONENTITY:u}=i.properties,l=i.dependencies;let p;const m={rootEntity:h,descriptionFieldName:c,codeFieldName:a,showInactives:!1};return null==l||l.filter((t=>{var e;return null===(e=t.masterFields)||void 0===e?void 0:e.every((t=>{var e;return null===(e=s.getField(t))||void 0===e?void 0:e.visible}))})).forEach((t=>{var e;t.type===d.SEARCHING&&(null===(e=t.masterFields)||void 0===e?void 0:e.length)>0&&(p={expression:t.expression,params:t.masterFields.map((t=>{const e=s.getField(t),i=(null==e?void 0:e.dataType)||o.TEXT,r=s.getFieldValue(t);if(null==r)throw this.alert("Erro ao pesquisar",`É necessario informar o campo ${e.label} para executar a pesquisa.`),new Error(`É necessario informar o campo ${e.label} para executar a pesquisa.`);return{name:t,value:r,dataType:i}}))})})),this.executePreparedSearch(e,r,{entity:n,entityDescription:u,criteria:p,searchOptions:m})}}async executePreparedSearch(t,e,s){const{entity:i,entityDescription:r,criteria:n,searchOptions:a}=s;return"ADVANCED"===t?new Promise((t=>{const s=document.createElement("snk-pesquisa");s["data-element-id"]=`entity_${i}`,s.argument=e,s.searchLoader=t=>this.pesquisaFetcher.loadAdvancedSearch(i,t,n,a),s.selectItem=e=>{t(e),this.clearPopUpTitle(),this.closePopUp()},this.setPopUpTitle(r),this.showPopUp(s)})):this.pesquisaFetcher.loadSearchOptions(i,e,n,a)}async isDebugMode(){return new Promise((t=>{t(window.isDebugMode)}))}clearContent(t){t&&Array.from(t.children).forEach((e=>{t.removeChild(e)}))}clearPopUpTitle(){this._popUp.ezTitle=""}setPopUpTitle(t){this._popUp.ezTitle=t}componentWillLoad(){this._errorHandler=new D(this),this.messagesBuilder=new $,p.setContextValue("__EZUI__UPLOAD__ADD__URL__",`${v.getUrlBase()}/mge/upload/file`),p.setContextValue("__EZUI__SEARCH__OPTION__LOADER__",((t,e,s)=>this.executeSearch(t,e,s))),p.setContextValue("__EZUI__GRID_LICENSE__",N),this.configName&&(this._filterConfigPromise=new Promise(((t,e)=>{this.filterBarConfigFetcher.getConfig(this.resourceID,this.configName).then((e=>{this._filterBarConfig=e,t(e)})).catch((t=>e(t)))}))),m.init(),P.get(),this.getDefaultValues().then((t=>{this._defaultValues=t}))}connectedCallback(){p.setContextValue("__SNK__APPLICATION__",this),y.addRequestListener(this._requestListener)}disconnectedCallback(){y.removeRequestListener(this._requestListener)}componentDidLoad(){this.applicationLoading.emit(!0),window.requestAnimationFrame((()=>{this.applicationLoaded.emit(!0)}))}render(){return s("div",null,s("ez-loading-bar",{ref:t=>this._requestListener.loadingBar=t}),s("ez-popup",{opened:!1,ref:t=>this._popUp=t,onEzClosePopup:()=>this.closePopUp()}),s("ez-modal",{opened:!1,ref:t=>this._rightModal=t,"modal-size":"small",closeOutsideClick:!0,closeEsc:!0}))}};class H{constructor(){this._debounceTime=1e3,this._ignoredNameTypes=["totals"],this._countRequest=0}onRequestStart(t){this.isIgnoreLoadingOnRequest(t)||(this._countRequest++,this.loadingBar.show(),this._timerLoading&&clearTimeout(this._timerLoading))}onRequestEnd(t){this.isIgnoreLoadingOnRequest(t)||(this._countRequest--,this._timerLoading=setTimeout((()=>{this._countRequest<=0&&this.loadingBar.hide()}),this._debounceTime))}isIgnoreLoadingOnRequest(t){var e;if(1==(null===(e=null==t?void 0:t.requestBody)||void 0===e?void 0:e.length)){const{name:e}=t.requestBody[0].variables;if(e){const t=e.split(":");return this._ignoredNameTypes.indexOf(t[0])>=0}}return!1}}class V{constructor(t,e){this.resolve=t,this.reject=e}}J.style=".sc-snk-application-h{display:flex;flex-direction:column;height:100%}";export{J as snk_application}
|
|
76
|
+
}`)}async getParam(t){const e=`param://application?params=${t}`;return v.get().callGraphQL({values:{name:e},query:this.templateByQuery.get("fetchParam")})}async asString(t){const e=await this.getParam(t);return this.getValue(e)}async asInteger(t){const e=await this.getParam(t);return parseInt(this.getValue(e))}async asFloat(t){const e=await this.getParam(t);return parseFloat(this.getValue(e))}async asBoolean(t){const e=await this.getParam(t);return this.getValue(e).includes('"S"')}async asDate(t){const e=await this.getParam(t);return d.strToDate(this.getValue(e))}async getBatchParams(t){const e=await this.getParam(t.join(",")),s={};return e.forEach((t=>s[t.name]=t.resource)),s}getValue(t={}){return Array.isArray(t)&&t.length>0&&(t=t[0]),u.isEmpty(t.resource)?"":t.resource}}const L=j;function j(t,e){const s=k();return(j=function(t){return s[t-=378]})(t,e)}function k(){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(k=function(){return t})()}!function(){const t=j,e=k();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{[L(397)](t){const e=L;if(typeof(t=utxt(t[e(390)]))==e(392)&&(t=JSON[e(400)](t)),null==t)throw Error(e(395));const s=new x("S"===t[e(402)]||!0===t[e(402)]);return Array[e(394)](t[e(391)])&&t[e(391)][e(385)]((t=>s.putAccess(t[e(382)],String(t.status)==e(398)))),s}}class x{constructor(t){const e=L;this.isSup=t,this[e(384)]={}}[L(378)](t,e){this[L(384)][t]=e}[L(393)](t){const e=L;if(this[e(402)])return!0;let s=!0;return this[e(384)][e(380)](t)&&(s=this.actions[t]),s}isUserSup(){return this.isSup}}class B extends w{getData(t){const e=`cfg://auth/${t}`;return new Promise(((t,s)=>{this.loadResource(e).then((e=>{let s=o.stringToObject(e);s&&"object"==typeof s&&t(s)})).catch((t=>{s(t)}))}))}}var z;function G(t){if(null==t)return t;if(t instanceof Date)return t.toISOString();if("object"==typeof t){if(t instanceof Array)return t.map((t=>G(t)));{const e=Object.assign({},t);return Object.keys(t).forEach((s=>{t[s]?e[s]=G(t[s]):delete e[s]})),e}}return t}!function(t){t.INSERT="I",t.UPDATE="A",t.REMOVE="E",t.SHOW="C",t.CONFIG="F",t.CONFIG_NUMBER="N",t.CLONE="D",t.CONFIG_GRID="G"}(z||(z={}));class J extends w{saveConfig(t,e,s){const i=t.map((t=>{const{id:e,value:s,fixed:i,visible:r}=t,n={id:e};return s&&(n.value=G(s)),i&&(n.fixed=i),r&&(n.visible=!0),n}));return this.saveResource(i,`cfg://filter/FilterBarState:${e}/${s}`)}getConfig(t,e){return new Promise(((s,i)=>{this.loadResource(`cfg://filter/FilterBarState:${t}/${e}`).then((t=>{let e;t&&(e=JSON.parse(t).items),s(e||[])})).catch((t=>{i(t)}))}))}}class H extends w{getDefaultValues(t){return new Promise(((e,s)=>{this.loadResource(`cfg://defaultValues/${t}`).then((t=>{let s;t&&(s=JSON.parse(t)),e(s)})).catch((t=>{s(t)}))}))}}const V=class{constructor(s){t(this,s),this.applicationLoaded=e(this,"applicationLoaded",7),this.applicationLoading=e(this,"applicationLoading",7),this._authPromises=[],this._duCache=new Map,this._duPromises=new Map,this._requestListener=new W}get parameters(){return this._parameters||(this._parameters=new R),this._parameters}get resourceID(){return this._resourceID||(this._resourceID=this.urlParams.get("workspaceResourceID")||this.urlParams.get("resourceID")||F.resourceID||"unknown.resource.id"),this._resourceID}get auth(){return this._auth?Promise.resolve(this._auth):new Promise(((t,e)=>{const s=this._authPromises.length>0;this._authPromises.push(new Z(t,e)),s||this.authFetcher.getData(this.resourceID).then((t=>{for(this._auth=t;this._authPromises.length>0;)this._authPromises.pop().resolve(this._auth)})).catch((t=>{for(;this._authPromises.length>0;)this._authPromises.pop().reject(t)}))}))}async isUserSup(){return new Promise(((t,e)=>{this.auth.then((s=>{this.getAuthList(s).then((e=>{t(e.isSup)})).catch((t=>e(t)))}))}))}async hasAccess(t){return new Promise(((e,s)=>{this.auth.then((i=>{this.getAuthList(i).then((s=>{e(s.isSup||s.actions[t])})).catch((t=>s(t)))}))}))}async getAllAccess(){return new Promise(((t,e)=>{this.auth.then((s=>{this.getAuthList(s).then((e=>{const s={};s.isSup=e.isSup,Object.entries(z).forEach((t=>{s[t[0]]=e.actions[t[1]]||!1})),t(s)})).catch((t=>e(t)))}))}))}async getStringParam(t){return this.parameters.asString(t)}async getIntParam(t){return this.parameters.asInteger(t)}async getFloatParam(t){return this.parameters.asFloat(t)}async getBooleanParam(t){return this.parameters.asBoolean(t)}async getDateParam(t){return this.parameters.asDate(t)}async showPopUp(t,e="full",s=!0){this.clearContent(this._popUp),this._popUp.appendChild(t),this._popUp.opened=!0,this._popUp.heightMode=e,this._popUp.useHeader=s,"EZ-MODAL-CONTAINER"===t.tagName&&(this._popUp.useHeader=!1)}async showModal(t){this.clearContent(this._rightModal),this._rightModal.appendChild(t),this._rightModal.opened=!0}async closeModal(){this.clearContent(this._rightModal),this._rightModal.opened=!1}async closePopUp(){this.clearContent(this._popUp),this._popUp.opened=!1,this._popUp.useHeader=!0,this._popUp.heightMode="full"}async temOpcional(t){const e=t.split(",");return new Promise(((t,s)=>{this.getAttributeFromHTMLWrapper("opc0009").then((i=>{"1"===i?t(!0):Promise.all(e.map((t=>this.getAttributeFromHTMLWrapper("opc"+t)))).then((e=>{t(e.includes("1"))})).catch((t=>{s(t)}))})).catch((t=>{s(t)}))}))}async getConfig(t){let e={serviceName:"SystemUtilsSP.getConf",requestBody:{config:{chave:t,tipo:"T"}}};return new Promise(((t,s)=>{v.get().callServiceBroker("SystemUtilsSP.getConf",JSON.stringify(e)).then((e=>{var s;return t(null===(s=e.config)||void 0===s?void 0:s.data)})).catch((t=>s(t)))}))}async saveConfig(t,e){let s={serviceName:"SystemUtilsSP.saveConf",requestBody:{config:{chave:t,tipo:"T",data:e}}};return new Promise(((t,e)=>{v.get().callServiceBroker("SystemUtilsSP.saveConf",JSON.stringify(s)).then((e=>t(e))).catch((t=>e(t)))}))}async getAttributeFromHTMLWrapper(t){return Promise.resolve(window[t])}async openApp(t,e){F.openAppActivity(t,e)}getDuPromissesStack(t){let e;return t&&(e=this._duPromises.get(t),e||(e=[],this._duPromises.set(t,e))),e||[]}async createDataunit(t,e){return new Promise(((s,i)=>{const r=this.getDuPromissesStack(e),n=r.length>0;if(r.push(new Z(s,i)),!n){const s=this.dataUnitFetcher.getDataUnit(t,this.resourceID);s.loadMetadata().then((()=>{for(e&&this._duCache.set(e,s);r.length>0;)r.pop().resolve(s)})).catch((t=>{for(;r.length>0;)r.pop().reject(t)}))}}))}async getDataUnit(t,e){return new Promise(((s,i)=>{const r=this._duCache.get(e);r?s(r):this.createDataunit(t,e).then((t=>{s(t)})).catch((t=>i(t)))}))}async getResourceID(){return Promise.resolve(this.resourceID)}async getUserID(){return Promise.resolve(window.UID)}async alert(t,e,s,i){return D.alert(t,e,s,i)}async error(t,e,s,i){return D.error(t,e,s,i)}async success(t,e,s,i){return D.success(t,e,s,i)}async message(t,e,s,i){return D.message(t,e,s,i)}async confirm(t,e,s,i,r){return D.confirm(t,e,s,i,r)}async info(t,e){return D.info(t,e)}async loadFormConfig(t){return this.formConfigFetcher.loadFormConfig(t,this.resourceID)}async loadGridConfig(t){return this.gridConfigFetcher.getConfig(t,this.resourceID)}async fetchUserAvailableConfigs(t){return this.formConfigFetcher.fetchUserAvailableConfigs(t,this.resourceID)}async fetchLegacyConfig(t){return this.formConfigFetcher.fetchLegacyConfig(t,this.resourceID)}async fetchDefaultConfig(t){return this.formConfigFetcher.fetchDefaultConfig(t,this.resourceID)}async loadTotals(t,e,s){return this.totalsFetcher.fetchTotals(t,e,s)}async saveGridConfig(t){return this.gridConfigFetcher.saveConfig(t,this.resourceID)}async getFilterBarConfig(t){return new Promise(((e,s)=>{this.configName===t&&this._filterBarConfig?e(this._filterBarConfig):this.configName===t&&null!=this._filterConfigPromise?Promise.all([this._filterConfigPromise]).then((t=>e(t[0]))).catch((t=>s(t[0]))):this.filterBarConfigFetcher.getConfig(this.resourceID,t).then((t=>e(t))).catch((t=>s(t)))}))}async saveFilterBarConfig(t,e){return this.filterBarConfigFetcher.saveConfig(t,this.resourceID,e)}async saveFormConfig(t,e){return this.formConfigFetcher.saveConfig(t,e,this.resourceID)}async getDefaultValues(){return this.defaultValuesFetcher.getDefaultValues(this.resourceID)}async getDefaultValue(t){return this._defaultValues&&this._defaultValues[t]}async getAuthList(t){return await(new M).parseFromJSON(t)}get urlParams(){return this._urlParams||(this._urlParams=I.getQueryParams(location.search)),this._urlParams}get dataUnitFetcher(){return this._dataUnitFetcher||(this._dataUnitFetcher=new U),this._dataUnitFetcher}get formConfigFetcher(){return this._formConfigFetcher||(this._formConfigFetcher=new _),this._formConfigFetcher}get gridConfigFetcher(){return this._gridConfigFetcher||(this._gridConfigFetcher=new P),this._gridConfigFetcher}get totalsFetcher(){return this._totalsFetcher||(this._totalsFetcher=new q),this._totalsFetcher}get pesquisaFetcher(){return this._pesquisaFetcher||(this._pesquisaFetcher=new A),this._pesquisaFetcher}get authFetcher(){return this._authFetcher||(this._authFetcher=new B),this._authFetcher}get filterBarConfigFetcher(){return this._filterBarConfigFetcher||(this._filterBarConfigFetcher=new J),this._filterBarConfigFetcher}get defaultValuesFetcher(){return this._defaultValuesFetcher||(this._defaultValuesFetcher=new H),this._defaultValuesFetcher}async executeSearch(t,e,s){const i=null==s?void 0:s.getField(e);if(i){const{mode:e,argument:r}=t,{ENTITYNAME:n,CODEFIELD:a,DESCRIPTIONFIELD:o,ROOTENTITY:h,DESCRIPTIONENTITY:u}=i.properties,l=i.dependencies;let d;const m={rootEntity:h,descriptionFieldName:o,codeFieldName:a,showInactives:!1};return null==l||l.filter((t=>{var e;return null===(e=t.masterFields)||void 0===e?void 0:e.every((t=>{var e;return null===(e=s.getField(t))||void 0===e?void 0:e.visible}))})).forEach((t=>{var e;t.type===p.SEARCHING&&(null===(e=t.masterFields)||void 0===e?void 0:e.length)>0&&(d={expression:t.expression,params:t.masterFields.map((t=>{const e=s.getField(t),i=(null==e?void 0:e.dataType)||c.TEXT,r=s.getFieldValue(t);if(null==r)throw this.alert("Erro ao pesquisar",`É necessario informar o campo ${e.label} para executar a pesquisa.`),new Error(`É necessario informar o campo ${e.label} para executar a pesquisa.`);return{name:t,value:r,dataType:i}}))})})),this.executePreparedSearch(e,r,{entity:n,entityDescription:u,criteria:d,searchOptions:m})}}async executePreparedSearch(t,e,s){const{entity:i,entityDescription:r,criteria:n,searchOptions:a}=s;return"ADVANCED"===t?new Promise((t=>{const s=document.createElement("snk-pesquisa");s["data-element-id"]=`entity_${i}`,s.argument=e,s.searchLoader=t=>this.pesquisaFetcher.loadAdvancedSearch(i,t,n,a),s.selectItem=e=>{t(e),this.clearPopUpTitle(),this.closePopUp()},this.setPopUpTitle(r),this.showPopUp(s)})):this.pesquisaFetcher.loadSearchOptions(i,e,n,a)}async isDebugMode(){return new Promise((t=>{t(window.isDebugMode)}))}clearContent(t){t&&Array.from(t.children).forEach((e=>{t.removeChild(e)}))}clearPopUpTitle(){this._popUp.ezTitle=""}setPopUpTitle(t){this._popUp.ezTitle=t}componentWillLoad(){this._errorHandler=new C(this),this.messagesBuilder=new S,m.setContextValue("__EZUI__UPLOAD__ADD__URL__",`${I.getUrlBase()}/mge/upload/file`),m.setContextValue("__EZUI__SEARCH__OPTION__LOADER__",((t,e,s)=>this.executeSearch(t,e,s))),m.setContextValue("__EZUI__GRID_LICENSE__",b),this.configName&&(this._filterConfigPromise=new Promise(((t,e)=>{this.filterBarConfigFetcher.getConfig(this.resourceID,this.configName).then((e=>{this._filterBarConfig=e,t(e)})).catch((t=>e(t)))}))),f.init(),$.get(),this.getDefaultValues().then((t=>{this._defaultValues=t}))}connectedCallback(){m.setContextValue("__SNK__APPLICATION__",this),v.addRequestListener(this._requestListener)}disconnectedCallback(){v.removeRequestListener(this._requestListener)}componentDidLoad(){this.applicationLoading.emit(!0),window.requestAnimationFrame((()=>{this.applicationLoaded.emit(!0)})),y.addIDInfo(this._element,`resource_${this._resourceID}`)}render(){return s("div",null,s("ez-loading-bar",{ref:t=>this._requestListener.loadingBar=t}),s("ez-popup",{opened:!1,ref:t=>this._popUp=t,onEzClosePopup:()=>this.closePopUp()}),s("ez-modal",{opened:!1,ref:t=>this._rightModal=t,"modal-size":"small",closeOutsideClick:!0,closeEsc:!0}))}get _element(){return i(this)}};class W{constructor(){this._debounceTime=1e3,this._ignoredNameTypes=["totals"],this._countRequest=0}onRequestStart(t){this.isIgnoreLoadingOnRequest(t)||(this._countRequest++,this.loadingBar.show(),this._timerLoading&&clearTimeout(this._timerLoading))}onRequestEnd(t){this.isIgnoreLoadingOnRequest(t)||(this._countRequest--,this._timerLoading=setTimeout((()=>{this._countRequest<=0&&this.loadingBar.hide()}),this._debounceTime))}isIgnoreLoadingOnRequest(t){var e;if(1==(null===(e=null==t?void 0:t.requestBody)||void 0===e?void 0:e.length)){const{name:e}=t.requestBody[0].variables;if(e){const t=e.split(":");return this._ignoredNameTypes.indexOf(t[0])>=0}}return!1}}class Z{constructor(t,e){this.resolve=t,this.reject=e}}V.style=".sc-snk-application-h{display:flex;flex-direction:column;height:100%}";export{V as snk_application}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as e}from"./p-9ba3df4c.js";var t,n,a;!function(e){e.PREVIOUS="PREVIOUS",e.NEXT="NEXT",e.REFRESH="REFRESH",e.UPDATE="UPDATE",e.CLONE="CLONE",e.REMOVE="REMOVE",e.INSERT="INSERT",e.CANCEL="CANCEL",e.SAVE="SAVE",e.GRID_MODE="GRID_MODE",e.FORM_MODE="FORM_MODE",e.MORE_OPTIONS="MORE_OPTIONS",e.DIVIDER="DIVIDER",e.CONFIGURATOR="CONFIGURATOR"}(t||(t={})),function(e){e.UPDATE="UPDATE",e.CLONE="CLONE",e.REMOVE="REMOVE",e.INSERT="INSERT",e.CONFIGURATOR="CONFIGURATOR"}(n||(n={})),function(e){e.CONFIGURATOR="CONFIGURATOR"}(a||(a={}));const r=(e,t,n,a,r)=>{const{hint:s,text:o,iconName:u}=e;return u?o?l(u,e.name,t,n,s,o,a,r):c(u,e.name,t,n,s,a,r):i(e.name,t,n,o,s,a,r)},s=(n,a,r,s,o,u,d)=>{const E=s(n);switch(n){case t.PREVIOUS:return c("chevron-left",n,a,r,E,o,u);case t.NEXT:return c("chevron-right",n,a,r,E,o,u);case t.REFRESH:return c("sync",n,a,r,E,o,u);case t.UPDATE:return c("edit",n,a,r,E,o,u);case t.CLONE:return c("copy",n,a,r,E,o,u);case t.REMOVE:return c("delete",n,a,r,E,o,u);case t.INSERT:return l("plus",n,a,r,E,E,o,u);case t.CANCEL:return i(n,a,r,E,E,o,u);case t.SAVE:return l("save",n,a,r,E,E,o,u);case t.GRID_MODE:return c("table",n,a,r,E,o,u);case t.FORM_MODE:return c("list",n,a,r,E,o,u);case t.CONFIGURATOR:return c("settings-inverted",n,a,r,E,o,u);case t.MORE_OPTIONS:return function(t,n,a,r,s,i,c){return c&&c.length>0?e("ez-actions-button",{title:r,size:"small","data-element-id":a,arrowActive:!0,class:n,enabled:i(t),onEzAction:e=>s(e.detail.value),actions:c}):void 0}(n,a,r,E,o,u,d);case t.DIVIDER:return e("hr",{class:"ez-divider-vertical ez-divider--dark ez-margin-horizontal--medium","data-taskbar-divider":!0})}};function i(t,n,a,r,s,i,c){return e("ez-button",{title:s,label:r,size:"small",class:n,"data-element-id":a,enabled:c(t),onClick:()=>i(t)})}function c(t,n,a,r,s,i,c){return e("ez-button",{name:t,title:s,mode:"icon",size:"small",class:a,"data-element-id":r,iconName:t,enabled:c(n),onClick:()=>i(n)})}function l(t,n,a,r,s,i,c,l){return e("ez-button",{name:t,title:i,label:s,size:"small",class:a,"data-element-id":r,enabled:l(n),onClick:()=>c(n)},e("ez-icon",{class:"ez-padding-right--small",slot:"leftIcon",iconName:t}))}export{n as A,t as T,a as V,r as a,s as b}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,c as i,h as s,g as e}from"./p-9ba3df4c.js";import{ApplicationContext as a,ElementIDUtils as n}from"@sankhyalabs/core";import{c as h}from"./p-6673c77c.js";import{T as o}from"./p-4cbc4ae3.js";const r=h.grid,c=h.form,d=class{constructor(s){t(this,s),this.actionClick=i(this,"actionClick",7),this._viewMode=r.name,this.multipleSelection=!0}async goToView(t){this.executeAction(t)}async gridToForm(t=!1){this._backToGrid=!t&&await this._viewStack.getSelectedIndex()===r.index,this.setViewMode(c)}async executeAction(t){t===o.GRID_MODE?this.setViewMode(r):t===o.FORM_MODE||t===o.UPDATE?this.gridToForm(t!==o.UPDATE):t===o.CONFIGURATOR&&this._snkConfigurator.open()}setViewMode(t){this._viewStack.show(t.index),this._viewMode=t.name}openConfig(t){this._snkConfigurator.close(),t===r.name?this._snkGrid.showConfig():t===c.name&&this._snkForm.showConfig()}insertionModeHandler(){this.gridToForm()}cancelHandler(){this._backToGrid&&this.setViewMode(r)}getDataElementId(t){return`${this._element.getAttribute("data-element-id")}_${t}`}componentWillLoad(){let t=this._element.parentElement;for(;t;){if("SNK-DATA-UNIT"===t.tagName.toUpperCase()){this._snkDataUnit=t,this._snkDataUnit.addEventListener("insertionMode",(()=>this.insertionModeHandler())),this._snkDataUnit.addEventListener("cancelEdition",(()=>this.cancelHandler())),this._dataUnit=this._snkDataUnit.dataUnit,this._dataState=this._snkDataUnit.dataState,this._dataUnit||this._snkDataUnit.addEventListener("dataUnitReady",(t=>{this._dataUnit=t.detail})),this._snkDataUnit.addEventListener("dataStateChange",(t=>{this._dataState=t.detail}));break}t=t.parentElement}if(!this.configName){const t=a.getContextValue("__SNK__APPLICATION__");this.configName=t.configName}}componentDidLoad(){n.addIDInfo(this._element,null,{dataUnit:this._dataUnit})}render(){return s("ez-view-stack",{ref:t=>this._viewStack=t,"data-element-id":this.getDataElementId("crud_ViewStack")},s("stack-item",null,s("snk-grid",{ref:t=>this._snkGrid=t,"data-element-id":this.getDataElementId("crud_grid"),configName:this.configName,onGridDoubleClick:()=>this.gridToForm(!0),taskbarManager:this.taskbarManager,onActionClick:t=>this.executeAction(t.detail),actionsList:this.actionsList,statusResolver:this.statusResolver,multipleSelection:this.multipleSelection},s("slot",{name:"SnkGridHeader"}),s("slot",{name:"SnkGridFooter"}),s("slot",{name:"SnkGridTaskBar"}))),s("stack-item",null,s("snk-form",{ref:t=>this._snkForm=t,"data-element-id":this.getDataElementId("crud_form"),configName:this.configName,actionsList:this.actionsList,onExit:()=>this.setViewMode(r),recordsValidator:this.recordsValidator,taskbarManager:this.taskbarManager,onActionClick:t=>this.executeAction(t.detail)},s("slot",{name:"SnkFormTaskBar"}))),s("snk-configurator",{ref:t=>this._snkConfigurator=t,viewMode:this._viewMode,onConfigSelected:t=>this.executeAction(t.detail),onOpenConfig:t=>this.openConfig(t.detail)}))}get _element(){return e(this)}};d.style=".sc-snk-crud-h{display:flex;flex-direction:column;height:100%;width:100%}";export{d as snk_crud}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,h as i,H as e,g as s,c as r}from"./p-9ba3df4c.js";import{DataType as n,ObjectUtils as l,ElementIDUtils as a,StringUtils as o,ErrorException as h,ApplicationContext as d,FloatingManager as c,ArrayUtils as f}from"@sankhyalabs/core";import{F as u}from"./p-9dd2b8cb.js";import{ModalAction as m,ModalButtonStatus as g}from"@sankhyalabs/ezui/dist/collection/components/ez-modal-container";import{toString as b}from"@sankhyalabs/core/dist/dataunit/metadata/DataType";import{CheckMode as k,ApplicationUtils as p,DialogType as _}from"@sankhyalabs/ezui/dist/collection/utils";import{C as v}from"./p-6ba8f415.js";import{O as x}from"./p-6673c77c.js";import{A as z}from"./p-dc36cfbf.js";import{T as y,V as C,A as F,b as w,a as T}from"./p-09720dd1.js";import"./p-112455b1.js";const L=class{constructor(i){t(this,i),this._updateSequence=[],this._loadingPending=!1,this._configUpdated=!1,this._pendingFilters=[],this._calculateSortIndex=t=>{let i=t.hardFixed?1e6:0;return t.hardFixed||(i+=t.fixed?1e5:0,i+=null==t.value?0:1e4,i+=this._updateSequence.lastIndexOf(t.id)+1),i},this._filtersComparator=(t,i)=>this._calculateSortIndex(i)-this._calculateSortIndex(t),this.scrollerLocked=!1}observeFilterConfig(t,i){if(null!=i&&null==t)this._loadingPending=!0,this._configUpdated=!0;else{const e=new Map(i?i.map((t=>[t.id,t])):void 0);t.forEach((t=>{const i=e.get(t.id);null!=i?(this._configUpdated=this._configUpdated||l.objectToString(i)!=l.objectToString(t),this._loadingPending=this._loadingPending||l.objectToString(i.value)!==l.objectToString(t.value)):(this._configUpdated=!0,this._loadingPending=this._loadingPending||null!=t.value)}))}this.processAfterUpdateConfig()}componentDidLoad(){if(this._element){a.addIDInfo(this._element,null,{dataUnit:this.dataUnit});const t=this._element.getAttribute("data-element-id");this._idSnkFilterItem=t,this._idSnkFilterList=t}}processPendingFilter(){this._pendingFilters.length>0&&null==this._currentPendingFilter&&(this._currentPendingFilter=this._element.querySelector("#filter-"+this._pendingFilters.pop()),this._currentPendingFilter&&this._currentPendingFilter.showUp(!0).then((()=>{this._currentPendingFilter=void 0,this.processPendingFilter()}))),null==this._currentPendingFilter&&this.processAfterUpdateConfig()}processAfterUpdateConfig(){this._pendingFilters.length>0||(this._loadingPending&&(this._loadingPending=!1,this.dataUnit.loadData()),this._configUpdated&&(this._configUpdated=!1,this._application.saveFilterBarConfig(this.filterConfig,this.configName)))}getMessage(t,i){return this._application.messagesBuilder.getMessage(t,i)}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 u.DEFAULT_FILTER:return function(t){return{name:t.id,expression:t.props.expression,params:[]}}(t);case u.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 u.MULTI_SELECT:return function(t){const{id:i,value:e,props:s}=t;return{name:i,expression:s.expression,params:[{name:i,dataType:n.TEXT,value:e}]}}(t);case u.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 a=[];let o;return r&&l?(o=s.expression.fullfill,a.push({name:`${i}.START`,dataType:n.DATE,value:b(n.DATE,l)},{name:`${i}.END`,dataType:n.DATE,value:b(n.DATE,r)})):l?(o=s.expression.onlystart,a.push({name:i,dataType:n.DATE,value:b(n.DATE,l)})):(o=s.expression.onlyend,a.push({name:i,dataType:n.DATE,value:b(n.DATE,r)})),{name:i,expression:o,params:a}}(t);case u.SEARCH:return function(t){const{id:i,value:e,props:s}=t;return{name:i,expression:s.expression,params:[{name:i,dataType:n.TEXT,value:b(n.TEXT,e.value)}]}}(t);case u.TEXT:return function(t){const{id:i,value:e,props:s}=t;return{name:i,expression:s.expression,params:[{name:i,dataType:n.TEXT,value:b(n.TEXT,e)}]}}(t);case u.NUMBER:return function(t){const{id:i,value:e,props:s}=t;return{name:i,expression:s.expression,params:[{name:i,dataType:n.NUMBER,value:b(n.NUMBER,e)}]}}(t);case u.PERSONALIZED:return function(t){var i;const{id:e,value:s,props:r}=t;return{name:e,expression:r.expression,params:((null===(i=r.personalizedFilter)||void 0===i?void 0:i.parameters)||[]).map(((t,i)=>{const e=Array.from(s),r=t.dataType;let l=i>=0&&i<e.length?e[i]:null;return null!=l&&"object"==typeof l&&"value"in l&&(l=l.value),null==l&&r===n.BOOLEAN&&(l=!1),{name:t.name,dataType:r,value:"string"==typeof l?l:b(r,l)}}))}}(t);default:return}})(t);i&&e.push(i)})),e}isActiveFilter(t){return t.visible&&null!=t.value||t.type===u.DEFAULT_FILTER}registryFilterProvider(){this.dataUnit.addFilterProvider(this),this.filterConfig&&this.dataUnit.loadData()}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()}))}getFilterItems(){const t=[],e=[];this.filterConfig.filter((t=>t.visible)).forEach(((s,r)=>{const n=`filter-${s.id}`,l=i("snk-filter-item",{onVisibleChanged:t=>this.scrollerLocked=t.detail,onFocusin:()=>this.itemFocused(n),id:n,config:s,class:r>0?"ez-padding-left--medium":"",getMessage:(t,i)=>this.getMessage(t,i),key:s.id});return s.fixed||s.hardFixed?t.push(l):e.push(l),l}));const s=[];return s.push(...t),t.length>0&&e.length>0&&s.push(i("hr",{class:"ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-filter-bar__divider"})),s.push(...e),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){this.filterConfig=this.filterConfig.map((i=>(t=this.normalizeItem(t),i.id===t.id?(l.objectToString(i)!=l.objectToString(t)&&this.calculateUpdateSequence(t),t):i))).sort(((t,i)=>this._filtersComparator(t,i)))}getAddListItems(){const t=this.filterConfig.filter((t=>!t.visible&&this.isListable(t))),i=[{name:"PERSONALIZED_FILTER",label:this.getMessage("snkFilterBar.customFilter"),iconName:"tune",kind:"FOOTER"}];return this.allowDefault&&i.push({name:"DEFAULT_FILTER",label:this.getMessage("snkFilterBar.defaultFilter"),iconName:"configuration",kind:"FOOTER"}),t.map((t=>({name:t.id,label:t.label,kind:"FILTER",iconName:null}))).concat(i)}getActiveClass(){return this.filterConfig.filter((t=>null!=t.value)).length>0?"sc-snk-filter-bar snk-filter-bar__filter-list-items-button--active":""}isListable(t,i=!1){return t.type!==u.DEFAULT_FILTER&&(i||t.type!==u.PERSONALIZED)}getAppliedListItems(){return this.filterConfig.filter((t=>this.isActiveFilter(t)&&this.isListable(t,!0))).map((t=>({name:t.id,label:t.label,kind:"FILTER",iconName:null}))).concat([{name:"CLEAR_ALL_FILTERS",label:this.getMessage("snkFilterBar.clearAllFilters"),iconName:"cleaning",kind:"FOOTER"}])}addPersonalizedFilters(t){const i={};t.forEach((t=>{t.active&&(i[t.id]=!0)})),this.filterConfig=this.filterConfig.map((t=>{var e,s;if(t.type===u.PERSONALIZED){const r=i[t.id];return!t.visible&&r&&(this.calculateUpdateSequence(t),null!=(null===(s=null===(e=t.props)||void 0===e?void 0:e.personalizedFilter)||void 0===s?void 0:s.parameters)&&this._pendingFilters.push(t.id)),this.normalizeItem(Object.assign(Object.assign({},t),r?{visible:r}:{visible:r,value:void 0,fixed:void 0}))}return t})).sort(((t,i)=>this._filtersComparator(t,i)))}openDefaultFilterModal(){const t=document.createElement("snk-filter-modal"),i=this.filterConfig.filter((t=>t.type===u.DEFAULT_FILTER));t.getMessage=(t,i)=>this.getMessage(t,i),t.modalTitle=this.getMessage("snkFilterBar.modalDefaultFilterTitle"),t.infoText=this.getMessage(0==i.length?"snkFilterBar.modalInfoTextCreateDefault":"snkFilterBar.modalInfoTextEditDefault"),t.items=i.map((t=>({id:t.id,active:!0,enabled:!1,label:t.label}))),t.processModalAction=()=>{this._application.closeModal()},this._application.showModal(t)}openPersonalizedModal(){const t=document.createElement("snk-filter-modal"),i=this.filterConfig.filter((t=>t.type===u.PERSONALIZED)).sort(((t,i)=>o.compare(t.label,i.label)));t.getMessage=(t,i)=>this.getMessage(t,i),t.modalTitle=this.getMessage("snkFilterBar.modalPersonalizedFilterTitle"),t.modalSubTitle=this.getMessage("snkFilterBar.modalPersonalizedFilterSubTitle"),t.okButtonLabel=this.getMessage("snkFilterBar.modalOkButtonLabel"),t.cancelButtonLabel=this.getMessage("snkFilterBar.modalCancelButtonLabel"),t.infoText=this.getMessage("snkFilterBar.modalInfoTextCreateEditPersonalized"),t.useSearch=!0,t.items=i.map((t=>({id:t.id,active:t.visible,enabled:!0,label:t.label}))),t.processModalAction=i=>{i===m.CANCEL?t.items=t.items.map((t=>Object.assign(Object.assign({},t),{active:!1}))):(i===m.OK&&this.addPersonalizedFilters(t.items),this._application.closeModal())},this._application.showModal(t)}clearFilters(){let t=!1;return this.filterConfig=this.filterConfig.map((i=>(null!=i.value&&(t=!0),Object.assign(Object.assign({},i),{value:void 0})))).sort(((t,i)=>this._filtersComparator(t,i))),t}loadPermitions(){this._application.isUserSup().then((t=>this.allowDefault=t))}loadConfigFromApplication(){this._application.getFilterBarConfig(this.configName).then((t=>{this.filterConfig=t.map((t=>this.normalizeItem(t))),this.dataUnit&&this.dataUnit.loadData()})).catch((t=>{throw new h(this.getMessage("snkFilterBar.failToLoadConfig"),t)}))}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?this.registryFilterProvider():i.addEventListener("dataUnitReady",(t=>{this.dataUnit=t.detail,this.registryFilterProvider()}));break}t=t.parentElement}else this.registryFilterProvider()}filterChangeListener(t){this.updateFilter(t.detail)}addFilterHandler(t){const i=this.filterConfig.find((i=>i.id===t));"PERSONALIZED_FILTER"===t?this.openPersonalizedModal():"DEFAULT_FILTER"===t?this.openDefaultFilterModal():i&&(this._pendingFilters.push(t),this.updateFilter(Object.assign(Object.assign({},i),{visible:!0})))}appliedFilterHandler(t){if("CLEAR_ALL_FILTERS"===t)this.clearFilters()&&this._application.info(this.getMessage("snkFilterBar.successfullyCleaned"),{iconName:"check"});else{const i=this._element.querySelector("#filter-"+t);i&&i.showUp(!0)}}componentWillLoad(){this._application=d.getContextValue("__SNK__APPLICATION__"),this._application&&(this.loadPermitions(),this.loadConfigFromApplication()),this.attachDataUnit()}componentDidRender(){this.processPendingFilter()}render(){if(this.dataUnit&&this.filterConfig&&0!==this.filterConfig.length)return i(e,null,i("ez-scroller",{direction:"horizontal",activeShadow:!0,locked:this.scrollerLocked},this.getFilterItems()),i("snk-filter-list",{id:"APPLIED_FILTERS",onFocusin:()=>this.itemFocused("APPLIED_FILTERS"),items:this.getAppliedListItems(),getMessage:(t,i)=>this.getMessage(t,i),emptyText:this.getMessage("snkFilterBar.emptyAppliedFiltersList"),findFilterText:this.getMessage("snkFilterBar.findFilter"),iconName:"filter",class:"ez-padding-left--medium",buttonClass:this.getActiveClass(),onSnkItemSelected:t=>this.appliedFilterHandler(t.detail),"data-element-id":this._idSnkFilterList}),i("snk-filter-list",{id:"ADD_FILTER",onFocusin:()=>this.itemFocused("ADD_FILTER"),items:this.getAddListItems(),label:this.getMessage("snkFilterBar.addFilter"),getMessage:(t,i)=>this.getMessage(t,i),emptyText:this.getMessage("snkFilterBar.emptyFiltersList"),findFilterText:this.getMessage("snkFilterBar.findField"),class:"ez-padding-left--medium",onSnkItemSelected:t=>this.addFilterHandler(t.detail),"data-element-id":this._idSnkFilterList},i("ez-icon",{slot:"leftIcon",class:"ez-padding-right--small",iconName:"plus"})))}get _element(){return s(this)}static get watchers(){return{filterConfig:["observeFilterConfig"]}}};L.style='.sc-snk-filter-bar-h{display:grid;grid-template-columns:minmax(100px, 100%) 1fr 1fr}.snk-filter__popover-container.sc-snk-filter-bar{display:flex;cursor:auto}.snk-filter__popover.sc-snk-filter-bar{display:flex;flex-direction:column;position:absolute;width:fit-content;height:fit-content;min-width:265px;z-index:var(--more-visible, 2);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)}.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 I=class{constructor(i){t(this,i),this.visibleChanged=r(this,"visibleChanged",7),this.filterChange=r(this,"filterChange",7),this.innerClickCheck=(t,i)=>i.id!=c.MODAL_ELEMENT_ID||(this.detailIsVisible=!1,!1)}observeDetailIsVisible(t){this.visibleChanged.emit(t)}async showUp(t=!1){return new Promise((i=>{this._filterItemElement.scrollIntoView({behavior:"auto",block:"nearest",inline:"nearest"}),t&&(this._closeCallback=i,window.requestAnimationFrame((()=>{this._floatingID=c.float(this._popover,this._popoverContainer,{autoClose:!0,innerClickTest:this.innerClickCheck,backClickListener:()=>this.onDetailCloseCallback(),left:this.getScrollOffset(),useOverlay:!0}),this._popover.show(),this.detailIsVisible=!0})))}))}getScrollOffset(){const t=getComputedStyle(this._filterItemElement).getPropertyValue("padding-left");return`calc(${this._filterItemElement.getBoundingClientRect().left}px + ${t})`}async hideDetail(){this.detailIsVisible&&null!=this._floatingID&&c.close(this._floatingID)}onDetailCloseCallback(){this._floatingID=void 0,this.detailIsVisible=!1,this._closeCallback&&(this._closeCallback(),this._closeCallback=void 0)}clickListener(t){[this._chipElement,this._leftIconElement,this._rightIconElement].includes(t.target)&&(t.target===this._rightIconElement&&null!=this.config.value?this.filterChange.emit(Object.assign(Object.assign({},this.config),{value:void 0})):this.detailIsVisible?this.hideDetail():this.showUp(!0),t.preventDefault(),t.stopImmediatePropagation(),t.stopPropagation())}mouseDownListener(t){this.detailIsVisible&&[this._chipElement,this._leftIconElement,this._rightIconElement].includes(t.target)&&(t.preventDefault(),t.stopImmediatePropagation(),t.stopPropagation())}getLabel(){const{type:t,value:i,label:e,props:s}=this.config;if(i){if(t===u.BINARY_SELECT){const[t,e]=s.options;if(t.name===i)return t.label;if(e.name===i)return e.label}if(t===u.MULTI_SELECT)return`${e}: ${s.options.find((t=>t.value===i)).label}`;if(t===u.PERIOD){let{end:t,start:s}=i;"string"==typeof t&&(t=new Date(t),t.setMinutes(t.getMinutes()+t.getTimezoneOffset())),"string"==typeof s&&(s=new Date(s),s.setMinutes(s.getMinutes()+s.getTimezoneOffset()));const r=new Intl.DateTimeFormat("pt-BR");return t&&s?`${e}: ${r.format(s)} a ${r.format(t)}`:s?`${e}: A partir de ${r.format(s)}`:t?`${e}: Até ${r.format(t)}`:e}return t===u.SEARCH?`${e}: ${i.value} - ${i.label}`:t===u.PERSONALIZED?e:`${e}: ${i}`}return e}componentDidLoad(){if(this._filterItemElement){a.addIDInfo(this._filterItemElement);const t=this._filterItemElement.getAttribute("data-element-id");this._idSnkFilterDetail=`${t}_${this.config.id}`,this._idEzChip=`${t}_${this.config.id}`}}componentDidRender(){null==this._floatingID&&this._popover&&this._popover.remove()}filterChangeListener(){this.hideDetail()}getRightIconName(){return null!=this.config.value?"close":this.detailIsVisible?"chevron-up":"chevron-down"}getLeftIconName(){switch(this.config.type){case u.PERIOD:return"calendar";case u.PERSONALIZED:return"tune"}}render(){const t=this.getLeftIconName();return i(e,null,i("ez-chip",{ref:t=>this._chipElement=t,label:this.getLabel(),value:null!=this.config.value,"data-element-id":this._idEzChip},t?i("ez-icon",{ref:t=>this._leftIconElement=t,iconName:t,class:"ez-padding-right--small",slot:"leftIcon"}):void 0,i("ez-icon",{ref:t=>this._rightIconElement=t,iconName:this.getRightIconName(),class:"ez-padding-left--small",slot:"rightIcon"})),i("section",{class:"ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container",ref:t=>this._popoverContainer=t},i("snk-filter-detail",{config:this.config,getMessage:this.getMessage,class:"sc-snk-filter-bar snk-filter__popover ez-padding--small",ref:t=>this._popover=t,key:this.config.id,"data-element-id":this._idSnkFilterDetail})))}get _filterItemElement(){return s(this)}static get watchers(){return{detailIsVisible:["observeDetailIsVisible"]}}},E=class{constructor(i){t(this,i),this.snkItemSelected=r(this,"snkItemSelected",7),this._preselection=-1,this.innerClickCheck=(t,i)=>i.id!=c.MODAL_ELEMENT_ID||(this._detailIsVisible=!1,!1)}showDetail(){this._preselection=-1,this._floatingID=c.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&&c.close(this._floatingID)}onListCloseCallback(){this._floatingID=void 0,this._detailIsVisible=!1}buttonClick(){this._detailIsVisible?this.hideDetail():this.showDetail()}componentDidLoad(){this._element&&a.addIDInfo(this._element)}componentDidRender(){null==this._floatingID&&this._popover&&this._popover.remove()}buildItemElement(t){const e=++this._selectableItemsCount;return this._buttonElement&&a.addIDInfo(this._buttonElement),i("button",{id:`filter-item${e}`,onFocusin:()=>this._preselection=e,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),ref:t=>this._buttonElement=t},t.iconName?i("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,i("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){"__SHOWMORE__"===t?this._showAll=!0:(this.hideDetail(),this.snkItemSelected.emit(t))}getFilterItems(){const t=this.items?f.applyStringFilter(this._filterArgument,this.items.filter((t=>"FILTER"===t.kind))):[];return 0===t.length?i("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:"Mostrar mais",iconName:"dots-horizontal",name:"__SHOWMORE__",iconClass:"snk-filter-bar__filter-list-item__icon--secondary",labelClass:"snk-filter-bar__filter-list-item__label--secondary"})),this._selectableItemsCount=0,i("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 i(e,{class:"ez-flex ez-flex--column"},i("ez-button",{class:this.buttonClass,label:this.label,onClick:()=>this.buttonClick(),mode:this.iconName?"icon":void 0,iconName:this.iconName,size:"small"},i("slot",{name:"leftIcon"})),i("section",{class:"ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container",ref:t=>this._popoverContainer=t},i("div",{class:"sc-snk-filter-bar snk-filter__popover ez-padding--small",ref:t=>this._popover=t},i("ez-filter-input",{ref:t=>this._filterInput=t,mode:"slim",label:this.findFilterText,value:this._filterArgument,onEzChange:t=>this._filterArgument=t.detail,onFocus:()=>this._preselection=0}),this.getFilterItems(),i("hr",{class:"sc-snk-filter-bar snk-filter__popover-rule"}),this.items?this.getFooterItems().map((t=>this.buildItemElement(t))):void 0)))}get _element(){return s(this)}},A=class{constructor(i){t(this,i)}updateValue(t,i){this.items=this.items.map((e=>e.id===t&&e.enabled?(null==i&&(i=!e.active),Object.assign(Object.assign({},e),{active:i})):e))}getActiveFiltersMsg(){const t=this.items.filter((t=>t.active)).length;return 0===t?this.getMessage("snkFilterBar.noActiveFilters"):this.getMessage(t>1?"snkFilterBar.activeFilters":"snkFilterBar.activeFilter",{ACTIVE_FILTERS:t})}buildItems(t){return t.map((t=>i("button",{onClick:()=>this.updateValue(t.id),class:"ez-padding--medium sc-snk-filter-bar snk-filter-bar__filter-modal-item ez-align--middle ez-margin-bottom--small"},i("ez-check",{id:`checkbox_${t.id}`,tabIndex:"-1",class:"sc-snk-filter-bar snk-filter-bar__filter-modal-item__check",onEzChange:i=>this.updateValue(t.id,i.detail),enabled:t.enabled,value:t.active,mode:k.SWITCH}),i("div",{class:"ez-text ez-title--primary ez-text--medium ez-margin-left--medium sc-snk-filter-bar snk-filter-bar__filter-modal-item__label"},t.label))))}itemKeyBoardSelect(t,i){"Enter"!==t.key&&" "!==t.key||this.updateValue(i.id)}modalActionListener(t){const i=t.detail;i===m.LOAD?this._filterInput&&this._filterInput.setFocus():this.processModalAction(i)}render(){const t=this.items.filter((t=>t.active)).length>0,e=this.items?f.applyStringFilter(this._filterArgument,this.items):[];return i("ez-modal-container",{class:"snk-filter__modal-container",modalTitle:this.modalTitle,modalSubTitle:this.modalSubTitle,cancelButtonLabel:this.cancelButtonLabel,okButtonLabel:this.okButtonLabel,onEzModalAction:t=>this.modalActionListener(t),cancelButtonStatus:t?g.ENABLED:g.DISABLED},i("div",{class:"sc-snk-filter-bar snk-filter-bar__filter-modal-content"},i("div",null,this.useSearch?i("ez-filter-input",{ref:t=>this._filterInput=t,label:this.getMessage("snkFilterBar.modalFindFilter"),onEzChange:t=>this._filterArgument=t.detail}):void 0),e.length>0?i("div",{class:"ez-text ez-text--medium ez-text--primary ez-padding-bottom--small"},this.getActiveFiltersMsg()):void 0,i("div",null,this.buildItems(e)),i("div",{class:"ez-text ez-text--large ez-align--middle ez-text--secondary ez-text--center ez-padding-bottom--large"},this.infoText)))}};A.style=".snk-filter__modal-container{width:359px;max-width:359px}";const D=class{constructor(i){t(this,i),this.configChange=r(this,"configChange",7),this.configCancel=r(this,"configCancel",7),this._orderListItems=[],this._orderPriorityList=[],this._columListItems=[],this._selectedIndex=-1,this._dataChanged=!1,this._componenteInternalKey=Date.now(),this.selectedIndex=0}async saveConfig(t){var i;null!=t&&null!=(null===(i=this._application)||void 0===i?void 0:i.configName)&&v.saveGridConfig(t,this._application.configName).then((i=>{null!=(null==i?void 0:i.resource)&&(this.configChange.emit(t),this._orderList.clearHistory())}))}getMessage(t,i){return this._application.messagesBuilder.getMessage(t,i)}createOrderList(){let t=[];this.columns.filter((t=>{var i;return o.getBooleanValue(null===(i=null==t?void 0:t.props)||void 0===i?void 0:i.get("sortable"),!0)})).forEach((i=>{var e;let s=null===(e=this.config)||void 0===e?void 0:e.columns.find((t=>t.name===i.name)),r={name:i.name,label:i.label};s&&(r.orderIndex=s.orderIndex,r.ascending=s.ascending),i.hidden||t.push(r)})),t.sort(((t,i)=>0!=t.orderIndex||0!=i.orderIndex||null==t.ascending&&null==i.ascending?null!=t.ascending&&null!=i.ascending?t.orderIndex-i.orderIndex:null!=t.ascending||null!=i.ascending?null!=t.ascending?-1:null!=i.ascending?1:0:t.orderIndex-i.orderIndex:null!=t.ascending?-1:null!=i.ascending?1:0)),this._orderListItems=t}createColumnList(){let t={group:this.getMessage("snkGridConfig.group.visible"),items:[]},i={group:this.getMessage("snkGridConfig.group.hidden"),items:[],sort:x.asc.value};this.columns.forEach((e=>{let s={label:e.label};e.hidden?i.items.push(s):t.items.push(s)})),this._columListItems=[t,i]}buildColumnListSlot(t,e){const s=`${this._element.getAttribute("data-element-id")}_configItem_${o.toCamelCase(t.label)}`;return i("div",null,i("ez-check",{mode:"switch",id:"switch"+((null==t?void 0:t.label)||"")+((null==e?void 0:e.group)||""),value:e.group===this.getMessage("snkGridConfig.group.visible"),"data-element-id":s,onEzChange:i=>{this.switchColumnGroup(i,t)}}))}buildOrderListSlot(t){const e=`${this._element.getAttribute("data-element-id")}_configItem_${o.toCamelCase(t.label)}`;let s=x.none.value;return null!=(null==t?void 0:t.ascending)&&(s=1==t.ascending?x.asc.value:x.desc.value),i("div",null,i("snk-select-box",{selectedOption:s,key:"snk-select-box-"+this._componenteInternalKey+"-"+t,"data-element-id":e,onEzChange:i=>{i.stopPropagation(),this.updateOrder(i.detail,t.label)}}))}updateOrder(t,i){var e;this._dataChanged=!0;let s,r=[...this.columns],n=r.find((t=>t.label===i));n&&(n.sort=t.value===x.none.value?void 0:t.value),(null===(e=this._orderPriorityList)||void 0===e?void 0:e.length)>0?(this._orderPriorityList.find((t=>t.label===n.label)).sort=t,this._orderPriorityList.filter((t=>t.sort)).map(((t,i)=>{t.label===n.label&&(n.sortIndex=i)}))):(s=r.filter((t=>t.sort&&!0!==t.hidden)).map(((t,i)=>({label:t.label,orderIndex:i}))),s.forEach((t=>{r.find((i=>i.label===t.label)).sortIndex=t.orderIndex}))),this.columns=r}switchColumnGroup(t,i){t.stopPropagation();let e=[...this._columListItems];if(this._dataChanged=!0,!0===t.detail){let t=e.find((t=>t.group===this.getMessage("snkGridConfig.group.hidden"))),s=t.items.findIndex((t=>t.label===i.label));s>=0&&t.items.splice(s,1),e.find((t=>t.group===this.getMessage("snkGridConfig.group.visible"))).items.push(i),this._columListItems=e,this.createOrderList()}else if(!1===t.detail){let t=e.find((t=>t.group===this.getMessage("snkGridConfig.group.visible"))),s=t.items.findIndex((t=>t.label===i.label));s>=0&&t.items.splice(s,1),e.find((t=>t.group===this.getMessage("snkGridConfig.group.hidden"))).items.push(i),this._columListItems=e,this.createOrderList()}}finish(){if(!this._dataChanged)return void this.closeConfig();let t=[];this._columListItems.forEach((i=>{i.items.forEach((e=>{const s=this.columns.find((t=>t.label===e.label));let r=Object.assign({},s);r.hidden=i.group===this.getMessage("snkGridConfig.group.hidden"),t.push(r)}))})),this.columns=t,this._dataChanged=!1,this.closeConfig(),this.save()}save(){var t;let i;i=this.config?this.config:this.createConfigFromState(this.columns);let e,s=[];if((null===(t=this._orderPriorityList)||void 0===t?void 0:t.length)>0){e=this.columns.filter((t=>t.sort&&!0!==t.hidden)).map((t=>({label:t.label,orderIndex:0})));let t=0,i=[];this._orderPriorityList.forEach((s=>{let r=e.find((t=>t.label===s.label));r&&(r.orderIndex=t,i.push(r),t++)})),i.length>0&&(e=i)}for(let t=0;t<this.columns.length;t++){const n=this.columns[t];let l=i.columns.find((t=>n.name===t.name));!0===n.hidden&&l||(l?l.width=n.width:!1===n.hidden&&(l={name:n.name,width:n.width,orderIndex:0}),l&&(n.sort?(l.ascending=n.sort.toUpperCase()===x.asc.value,e?r(n,l):l.orderIndex=n.sortIndex):(delete l.ascending,l.orderIndex=0),s.push(l)))}function r(t,i){if(e){let s=e.find((i=>i.label===t.label));s&&(i.orderIndex=s.orderIndex)}}i.columns=s,this.saveConfig(i).then((()=>{p.info(this.getMessage("snkGridConfig.info.successfullyConfigSaved"),{iconName:"check"})}))}createConfigFromState(t){let i={columns:[]};return t.forEach((t=>{if(!t.hidden){let e={name:t.name};t.width&&(e.width=t.width),t.sort?(e.ascending=t.sort.toUpperCase()===x.asc.value,e.orderIndex=t.sortIndex):e.orderIndex=0,e&&i.columns.push(e)}})),i}async locateColumn(t,i){var e;const s="Enter"===t.key;i||(i=null===(e=t.currentTarget)||void 0===e?void 0:e.value);let r=-1;if(1===this.selectedIndex)if(i){const t=[];let e,n;if(await this._orderList.getList().then((s=>{e=s,e.forEach(((e,s)=>{this.compareWords(e,i)&&t.push(s)}))})),t.length>0){if(s)for(let i=0;i<t.length;i++)if(t[i]>this._selectedIndex){r=t[i];break}-1===r&&(r=t[0])}this._selectedIndex=r,n=e[r],n?this._orderList.setSelection({label:n.label},!0):this._orderList.setSelection(void 0)}else this._orderList.setSelection(void 0);else if(i){const t=[];if(this.columns.forEach(((e,s)=>{this.compareWords(e,i)&&t.push(s)})),t.length>0){if(s)for(let i=0;i<t.length;i++)if(t[i]>this._selectedIndex){r=t[i];break}-1===r&&(r=t[0])}this._selectedIndex=r;let e=this.columns[r];e?this._columnList.setSelection({label:e.label},!0):this._columnList.setSelection(void 0)}else this._columnList.setSelection(void 0)}compareWords(t,i){return o.replaceAccentuatedChars(t.label).indexOf(o.replaceAccentuatedChars(i))>-1}getColumnNames(){const t=[];return t.push(this.getMessage("snkGridConfig.tab.columns")),t.push(this.getMessage("snkGridConfig.tab.lineOrdering")),t.join(",")}closeConfig(){if(this._orderList.scrollToTop(),this._columnList.scrollToTop(),this._searchElement.value="",this._dataChanged){let t={canClose:!1,labelCancel:this.getMessage("snkGridConfig.confirm.cancel"),labelConfirm:this.getMessage("snkGridConfig.confirm.save"),btnConfirmDanger:!1};p.confirm(this.getMessage("snkGridConfig.confirm.alert"),this.getMessage("snkGridConfig.confirm.msgCancel"),null,_.WARN,t).then((t=>{t?this.finish():(this._dataChanged=!1,this.configCancel.emit(),this._orderList.clearHistory(),this._componenteInternalKey=Date.now())}))}else this.configCancel.emit(),this._orderList.clearHistory()}handleTabChange(t){null!=(null==t?void 0:t.index)&&(this.selectedIndex!==t.index&&(0===t.index?this._orderList.scrollToTop():1===t.index&&this._columnList.scrollToTop(),this._searchElement.value=""),1===t.index&&this.createOrderList(),this.selectedIndex=t.index)}handleColumnListChange(t){var i;if(t.detail){let e=null===(i=t.detail.find((t=>t.group===this.getMessage("snkGridConfig.group.visible"))))||void 0===i?void 0:i.items;e&&(this._dataChanged=!0,this._orderListItems=e)}}handleOrderListChange(t){if(t.detail){let i=t.detail;i&&(this._dataChanged=!0,this._orderPriorityList=i)}}componentWillRender(){var t;(null===(t=this.columns)||void 0===t?void 0:t.length)>0&&this.createColumnList()}componentDidRender(){var t;(null===(t=this.columns)||void 0===t?void 0:t.length)>0&&this.locateColumn(new KeyboardEvent("arrow-right",{key:"ArrowRight"}),this._searchElement.value)}componentWillLoad(){this._application=d.getContextValue("__SNK__APPLICATION__")}componentDidLoad(){a.addIDInfo(this._element)}render(){return i(e,null,i("div",{class:"grid-config__header"},i("div",{class:"title-container"},i("div",{class:""},i("label",{class:"title"},this.getMessage("snkGridConfig.gridConfiguration")),i("label",{class:"subtitle"},this.getMessage("snkGridConfig.columnVisibilityOrder"))),i("div",{class:"button-close"},i("ez-button",{mode:"icon",iconName:"close",size:"medium",onClick:()=>this.closeConfig()}))),i("div",{class:"tabselector-container"},i("ez-tabselector",{selectedIndex:this.selectedIndex,onEzChange:t=>{this.handleTabChange(t.detail)},tabs:this.getColumnNames()})),i("div",null,i("ez-text-input",{ref:t=>this._searchElement=t,label:this.getMessage("snkGridConfig.findColumn"),onKeyUp:t=>this.locateColumn(t)},i("ez-icon",{slot:"leftIcon",size:"medium",iconName:"search"})))),i("div",{class:"grid-config__main"},i("ez-list",{ref:t=>this._columnList=t,class:0===this.selectedIndex?"":"hidden",dataSource:this._columListItems,onEzChange:t=>this.handleColumnListChange(t),ezDraggable:!0,ezSelectable:!0,itemSlotBuilder:(t,i)=>this.buildColumnListSlot(t,i),useGroups:!0}),i("div",{class:1===this.selectedIndex?"group-name":"hidden"},this.getMessage("snkGridConfig.info.sortingSequence")),i("ez-list",{ref:t=>this._orderList=t,class:1===this.selectedIndex?"height-calc":"hidden",dataSource:this._orderListItems,ezSelectable:!0,onEzChange:t=>this.handleOrderListChange(t),ezDraggable:!0,itemSlotBuilder:t=>this.buildOrderListSlot(t)})),i("div",{class:"grid-config__footer"},i("ez-button",{class:"padding-right--medium",label:this.getMessage("snkGridConfig.cancel"),onClick:()=>this.closeConfig()}),i("ez-button",{label:this.getMessage("snkGridConfig.complete"),class:"ez-button--primary",onClick:()=>this.finish()})))}static get assetsDirs(){return["../assets"]}get _element(){return s(this)}};D.style='.sc-snk-grid-config-h{--snk-grid-config__footer--padding-top:var(--space--medium, 12px);--snk-grid-config__main--padding-right:var(--space--medium, 12px);--snk-grid-config__tabselector-container--padding:var(--space--medium, 12px);--snk-grid-config__button-close--padding-left:var(--space--medium, 12px);--snk-grid-config__title--color:var(--title--primary, #2B3A54);--snk-grid-config__title--font-family:var(--font-pattern, "Roboto");--snk-grid-config__title--font-size:var(--title--large, 20px);--snk-grid-config__title--font-weight:var(--text-weight--extra-large, 700);--snk-grid-config__subtitle--font-family:var(--font-pattern, "Roboto");--snk-grid-config__subtitle--font-size:var(--text--medium, 14px);--snk-grid-config__scrollbar--width:var(--space--medium, 12px);--snk-grid-config__scrollbar--background-color-primary:var(--scrollbar--primary, #2B3A54);--snk-grid-config__scrollbar--background-color-secondary:var(--scrollbar--secondary, #E5EAF0);--snk-grid-config__scrollbar--border-radius:var(--border--radius-small, 6px);--snk-grid-config__group--font-family:var(--font-pattern, "Roboto");--snk-grid-config__group--font-size:var(--text--medium, 14px);--snk-grid-config__group--font-weight:var(--text-weight--large, 600);--snk-grid-config__group--padding-bottom:var(--space-small, 6px);display:grid;grid-template-rows:auto 1fr auto;max-height:100%;width:100%}@media screen and (min-width: 480px){.sc-snk-grid-config-h{width:359px;max-width:359px}}.padding-right--medium.sc-snk-grid-config{padding-right:var(--space--medium)}ez-list.sc-snk-grid-config{height:100%}.height-calc.sc-snk-grid-config{max-height:calc(100% - 24px)}.grid-config__footer.sc-snk-grid-config{display:flex;justify-content:flex-end;width:100%;padding-top:var(--snk-grid-config__footer--padding-top)}.hidden.sc-snk-grid-config{display:none}.tabselector-container.sc-snk-grid-config{padding:var(--snk-grid-config__tabselector-container--padding) 0}.button-close.sc-snk-grid-config{padding-left:var(--snk-grid-config__button-close--padding-left)}.title-container.sc-snk-grid-config{display:flex;justify-content:space-between;align-items:center;width:100%}.title.sc-snk-grid-config{display:flex;margin:0;line-height:normal;letter-spacing:0em;text-align:left;color:var(--snk-grid-config__title--color);font-size:var(--snk-grid-config__title--font-size);font-family:var(--snk-grid-config__title--font-family);font-weight:var(--snk-grid-config__title--font-weight)}.subtitle.sc-snk-grid-config{color:var(--text--primary);font-size:var(--snk-grid-config__subtitle--font-size);font-family:var(--snk-grid-config__subtitle--font-family)}.grid-config__main.sc-snk-grid-config{overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--snk-grid-config__scrollbar--background-color-primary) var(--snk-grid-config__scrollbar--background-color-secondary);padding-right:var(--snk-grid-config__main--padding-right)}.grid-config__main.sc-snk-grid-config::-webkit-scrollbar-track{background-color:var(--snk-grid-config__scrollbar--background-color-secondary)}.grid-config__main.sc-snk-grid-config::-webkit-scrollbar-thumb{background-color:var(--snk-grid-config__scrollbar--background-color-primary);border-radius:var(--snk-grid-config__scrollbar--border-radius)}.grid-config__main.sc-snk-grid-config::-webkit-scrollbar{width:var(--snk-grid-config__scrollbar--width);max-width:var(--snk-grid-config__scrollbar--width);min-width:var(--snk-grid-config__scrollbar--width);background-color:var(--snk-grid-config__scrollbar--background-color-secondary)}.group-name.sc-snk-grid-config{font-family:var(--snk-grid-config__group--font-family);font-size:var(--snk-grid-config__group--font-size);font-weight:var(--snk-grid-config__group--font-weight);padding-bottom:var(--snk-grid-config__group--padding-bottom)}';const O=class{constructor(i){t(this,i),this.ezChange=r(this,"ezChange",7),this.selectedOption=x.none}render(){return i("ez-combo-box",{class:"grid-config-combo ez-input--inverted",label:"",suppressSearch:!0,value:this.selectedOption,enabled:!0,canShowError:!1,suppressEmptyOption:!0},Object.keys(x).map((t=>i("option",{value:x[t].value},x[t].label))))}static get assetsDirs(){return["../assets"]}};O.style="ez-combo-box{width:100px}.grid-config-combo{--ez-text-input--height:28px;--ez-text-input__input--background-color:#fff;--ez-text-input__input--border-color:#dce0e8}";const S=class{constructor(i){t(this,i),this.actionClick=r(this,"actionClick",7),this.actionChange=r(this,"actionChange",7),this._titleKeyByElement={[y.UPDATE]:"snkTaskbar.titleUpdate",[y.PREVIOUS]:"snkTaskbar.titlePrevious",[y.NEXT]:"snkTaskbar.titleNext",[y.REFRESH]:"snkTaskbar.titleRefresh",[y.CLONE]:"snkTaskbar.titleClone",[y.REMOVE]:"snkTaskbar.titleRemove",[y.MORE_OPTIONS]:"snkTaskbar.titleMoreOptions",[y.INSERT]:"snkTaskbar.titleInsert",[y.CANCEL]:"snkTaskbar.titleCancel",[y.SAVE]:"snkTaskbar.titleSave",[y.GRID_MODE]:"snkTaskbar.titleGridMode",[y.FORM_MODE]:"snkTaskbar.titleFormMode",[y.CONFIGURATOR]:"snkTaskbar.titleConfigurator"}}observeButtons(){this._definitions=void 0}elementsFromString(t){const i=[];return null==t||t.split(",").forEach((t=>{t=t.trim(),(C[t]||this.isAllowed(t))&&i.push(t.trim())})),i}isAllowed(t){return t===F.CONFIGURATOR?!!this._permissions&&(this._permissions.isSup||this._permissions[z.CONFIG_GRID]||this._permissions[z.CONFIG]):!F[t]||!!this._permissions&&(this._permissions.isSup||this._permissions[t])}getTitle(t){let i;return i=this.isAllowed(t)?this._titleKeyByElement[t]:"snkTaskbar.forbidden",i?this._application.messagesBuilder.getMessage(i,{}):""}elementClick(t){if(this.dataUnit)switch(t){case y.PREVIOUS:this.dataUnit.previousRecord();break;case y.NEXT:this.dataUnit.nextRecord();break;case y.REFRESH:this.dataUnit.loadData();break;case y.CLONE:this.dataUnit.copySelected();break;case y.REMOVE:this.dataUnit.removeSelectedRecords();break;case y.INSERT:this.dataUnit.addRecord();break;case y.CANCEL:this.dataUnit.cancelEdition();break;case y.SAVE:this.dataUnit.saveData()}this.actionClick.emit(t)}isEnabled(t){return!(!this.isAllowed(t)||this.disabledButtons&&this.disabledButtons.includes(t))}getElement(t,i){let e=i===this.primaryButton?"ez-button--primary ":"";return t>1&&(e+="ez-padding-left--medium"),y[i.toString()]?w(i,e,(t=>this.getTitle(t)),(t=>this.elementClick(t)),(t=>this.isEnabled(t)),this.actionsList):T(i,e,(t=>this.elementClick(t)),(t=>this.isEnabled(t)))}componentWillLoad(){this._application=d.getContextValue("__SNK__APPLICATION__"),this._application?this._application.getAllAccess().then((t=>this._permissions=t)):this._permissions={}}componentWillRender(){null==this._definitions&&this._permissions&&(this._definitions=this.elementsFromString(this.buttons))}isDivider(t){var i;return void 0!==t&&(null===(i=t.t)||void 0===i?void 0:i["data-taskbar-divider"])}removeEmpty(t){let i;return t.filter((t=>!(null==t||this.isDivider(i)&&this.isDivider(t)||(i=t,0))))}render(){if(void 0===this._definitions)return;let t=0;return i(e,null,this.removeEmpty(this._definitions.map((e=>(e===y.DIVIDER?t=0:t++,y[e]?this.getElement(t,y[e]):this.customButtons.has(e)?this.getElement(t,this.customButtons.get(e)):i("slot",{name:e}))))))}static get watchers(){return{buttons:["observeButtons"]}}};S.style=".sc-snk-taskbar-h{display:flex}";export{L as snk_filter_bar,I as snk_filter_item,E as snk_filter_list,A as snk_filter_modal,D as snk_grid_config,O as snk_select_box,S as snk_taskbar}
|
|
1
|
+
import{r as t,h as i,H as e,g as s,c as r}from"./p-9ba3df4c.js";import{DataType as n,ObjectUtils as l,ElementIDUtils as a,StringUtils as o,ErrorException as h,ApplicationContext as d,FloatingManager as c,ArrayUtils as f}from"@sankhyalabs/core";import{F as u}from"./p-9dd2b8cb.js";import{ModalAction as m,ModalButtonStatus as g}from"@sankhyalabs/ezui/dist/collection/components/ez-modal-container";import{toString as b}from"@sankhyalabs/core/dist/dataunit/metadata/DataType";import{CheckMode as k,ApplicationUtils as p,DialogType as _}from"@sankhyalabs/ezui/dist/collection/utils";import{C as v}from"./p-6ba8f415.js";import{O as x}from"./p-6673c77c.js";import{A as z}from"./p-dc36cfbf.js";import{T as y,V as C,A as F,b as w,a as T}from"./p-4cbc4ae3.js";import"./p-112455b1.js";const L=class{constructor(i){t(this,i),this._updateSequence=[],this._loadingPending=!1,this._configUpdated=!1,this._pendingFilters=[],this._calculateSortIndex=t=>{let i=t.hardFixed?1e6:0;return t.hardFixed||(i+=t.fixed?1e5:0,i+=null==t.value?0:1e4,i+=this._updateSequence.lastIndexOf(t.id)+1),i},this._filtersComparator=(t,i)=>this._calculateSortIndex(i)-this._calculateSortIndex(t),this.scrollerLocked=!1}observeFilterConfig(t,i){if(null!=i&&null==t)this._loadingPending=!0,this._configUpdated=!0;else{const e=new Map(i?i.map((t=>[t.id,t])):void 0);t.forEach((t=>{const i=e.get(t.id);null!=i?(this._configUpdated=this._configUpdated||l.objectToString(i)!=l.objectToString(t),this._loadingPending=this._loadingPending||l.objectToString(i.value)!==l.objectToString(t.value)):(this._configUpdated=!0,this._loadingPending=this._loadingPending||null!=t.value)}))}this.processAfterUpdateConfig()}componentDidLoad(){if(this._element){a.addIDInfo(this._element,null,{dataUnit:this.dataUnit});const t=this._element.getAttribute("data-element-id");this._idSnkFilterItem=t,this._idSnkFilterList=t}}processPendingFilter(){this._pendingFilters.length>0&&null==this._currentPendingFilter&&(this._currentPendingFilter=this._element.querySelector("#filter-"+this._pendingFilters.pop()),this._currentPendingFilter&&this._currentPendingFilter.showUp(!0).then((()=>{this._currentPendingFilter=void 0,this.processPendingFilter()}))),null==this._currentPendingFilter&&this.processAfterUpdateConfig()}processAfterUpdateConfig(){this._pendingFilters.length>0||(this._loadingPending&&(this._loadingPending=!1,this.dataUnit.loadData()),this._configUpdated&&(this._configUpdated=!1,this._application.saveFilterBarConfig(this.filterConfig,this.configName)))}getMessage(t,i){return this._application.messagesBuilder.getMessage(t,i)}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 u.DEFAULT_FILTER:return function(t){return{name:t.id,expression:t.props.expression,params:[]}}(t);case u.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 u.MULTI_SELECT:return function(t){const{id:i,value:e,props:s}=t;return{name:i,expression:s.expression,params:[{name:i,dataType:n.TEXT,value:e}]}}(t);case u.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 a=[];let o;return r&&l?(o=s.expression.fullfill,a.push({name:`${i}.START`,dataType:n.DATE,value:b(n.DATE,l)},{name:`${i}.END`,dataType:n.DATE,value:b(n.DATE,r)})):l?(o=s.expression.onlystart,a.push({name:i,dataType:n.DATE,value:b(n.DATE,l)})):(o=s.expression.onlyend,a.push({name:i,dataType:n.DATE,value:b(n.DATE,r)})),{name:i,expression:o,params:a}}(t);case u.SEARCH:return function(t){const{id:i,value:e,props:s}=t;return{name:i,expression:s.expression,params:[{name:i,dataType:n.TEXT,value:b(n.TEXT,e.value)}]}}(t);case u.TEXT:return function(t){const{id:i,value:e,props:s}=t;return{name:i,expression:s.expression,params:[{name:i,dataType:n.TEXT,value:b(n.TEXT,e)}]}}(t);case u.NUMBER:return function(t){const{id:i,value:e,props:s}=t;return{name:i,expression:s.expression,params:[{name:i,dataType:n.NUMBER,value:b(n.NUMBER,e)}]}}(t);case u.PERSONALIZED:return function(t){var i;const{id:e,value:s,props:r}=t;return{name:e,expression:r.expression,params:((null===(i=r.personalizedFilter)||void 0===i?void 0:i.parameters)||[]).map(((t,i)=>{const e=Array.from(s),r=t.dataType;let l=i>=0&&i<e.length?e[i]:null;return null!=l&&"object"==typeof l&&"value"in l&&(l=l.value),null==l&&r===n.BOOLEAN&&(l=!1),{name:t.name,dataType:r,value:"string"==typeof l?l:b(r,l)}}))}}(t);default:return}})(t);i&&e.push(i)})),e}isActiveFilter(t){return t.visible&&null!=t.value||t.type===u.DEFAULT_FILTER}registryFilterProvider(){this.dataUnit.addFilterProvider(this),this.filterConfig&&this.dataUnit.loadData()}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()}))}getFilterItems(){const t=[],e=[];this.filterConfig.filter((t=>t.visible)).forEach(((s,r)=>{const n=`filter-${s.id}`,l=i("snk-filter-item",{onVisibleChanged:t=>this.scrollerLocked=t.detail,onFocusin:()=>this.itemFocused(n),id:n,config:s,class:r>0?"ez-padding-left--medium":"",getMessage:(t,i)=>this.getMessage(t,i),key:s.id});return s.fixed||s.hardFixed?t.push(l):e.push(l),l}));const s=[];return s.push(...t),t.length>0&&e.length>0&&s.push(i("hr",{class:"ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-filter-bar__divider"})),s.push(...e),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){this.filterConfig=this.filterConfig.map((i=>(t=this.normalizeItem(t),i.id===t.id?(l.objectToString(i)!=l.objectToString(t)&&this.calculateUpdateSequence(t),t):i))).sort(((t,i)=>this._filtersComparator(t,i)))}getAddListItems(){const t=this.filterConfig.filter((t=>!t.visible&&this.isListable(t))),i=[{name:"PERSONALIZED_FILTER",label:this.getMessage("snkFilterBar.customFilter"),iconName:"tune",kind:"FOOTER"}];return this.allowDefault&&i.push({name:"DEFAULT_FILTER",label:this.getMessage("snkFilterBar.defaultFilter"),iconName:"configuration",kind:"FOOTER"}),t.map((t=>({name:t.id,label:t.label,kind:"FILTER",iconName:null}))).concat(i)}getActiveClass(){return this.filterConfig.filter((t=>null!=t.value)).length>0?"sc-snk-filter-bar snk-filter-bar__filter-list-items-button--active":""}isListable(t,i=!1){return t.type!==u.DEFAULT_FILTER&&(i||t.type!==u.PERSONALIZED)}getAppliedListItems(){return this.filterConfig.filter((t=>this.isActiveFilter(t)&&this.isListable(t,!0))).map((t=>({name:t.id,label:t.label,kind:"FILTER",iconName:null}))).concat([{name:"CLEAR_ALL_FILTERS",label:this.getMessage("snkFilterBar.clearAllFilters"),iconName:"cleaning",kind:"FOOTER"}])}addPersonalizedFilters(t){const i={};t.forEach((t=>{t.active&&(i[t.id]=!0)})),this.filterConfig=this.filterConfig.map((t=>{var e,s;if(t.type===u.PERSONALIZED){const r=i[t.id];return!t.visible&&r&&(this.calculateUpdateSequence(t),null!=(null===(s=null===(e=t.props)||void 0===e?void 0:e.personalizedFilter)||void 0===s?void 0:s.parameters)&&this._pendingFilters.push(t.id)),this.normalizeItem(Object.assign(Object.assign({},t),r?{visible:r}:{visible:r,value:void 0,fixed:void 0}))}return t})).sort(((t,i)=>this._filtersComparator(t,i)))}openDefaultFilterModal(){const t=document.createElement("snk-filter-modal"),i=this.filterConfig.filter((t=>t.type===u.DEFAULT_FILTER));t.getMessage=(t,i)=>this.getMessage(t,i),t.modalTitle=this.getMessage("snkFilterBar.modalDefaultFilterTitle"),t.infoText=this.getMessage(0==i.length?"snkFilterBar.modalInfoTextCreateDefault":"snkFilterBar.modalInfoTextEditDefault"),t.items=i.map((t=>({id:t.id,active:!0,enabled:!1,label:t.label}))),t.processModalAction=()=>{this._application.closeModal()},this._application.showModal(t)}openPersonalizedModal(){const t=document.createElement("snk-filter-modal"),i=this.filterConfig.filter((t=>t.type===u.PERSONALIZED)).sort(((t,i)=>o.compare(t.label,i.label)));t.getMessage=(t,i)=>this.getMessage(t,i),t.modalTitle=this.getMessage("snkFilterBar.modalPersonalizedFilterTitle"),t.modalSubTitle=this.getMessage("snkFilterBar.modalPersonalizedFilterSubTitle"),t.okButtonLabel=this.getMessage("snkFilterBar.modalOkButtonLabel"),t.cancelButtonLabel=this.getMessage("snkFilterBar.modalCancelButtonLabel"),t.infoText=this.getMessage("snkFilterBar.modalInfoTextCreateEditPersonalized"),t.useSearch=!0,t.items=i.map((t=>({id:t.id,active:t.visible,enabled:!0,label:t.label}))),t.processModalAction=i=>{i===m.CANCEL?t.items=t.items.map((t=>Object.assign(Object.assign({},t),{active:!1}))):(i===m.OK&&this.addPersonalizedFilters(t.items),this._application.closeModal())},this._application.showModal(t)}clearFilters(){let t=!1;return this.filterConfig=this.filterConfig.map((i=>(null!=i.value&&(t=!0),Object.assign(Object.assign({},i),{value:void 0})))).sort(((t,i)=>this._filtersComparator(t,i))),t}loadPermitions(){this._application.isUserSup().then((t=>this.allowDefault=t))}loadConfigFromApplication(){this._application.getFilterBarConfig(this.configName).then((t=>{this.filterConfig=t.map((t=>this.normalizeItem(t))),this.dataUnit&&this.dataUnit.loadData()})).catch((t=>{throw new h(this.getMessage("snkFilterBar.failToLoadConfig"),t)}))}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?this.registryFilterProvider():i.addEventListener("dataUnitReady",(t=>{this.dataUnit=t.detail,this.registryFilterProvider()}));break}t=t.parentElement}else this.registryFilterProvider()}filterChangeListener(t){this.updateFilter(t.detail)}addFilterHandler(t){const i=this.filterConfig.find((i=>i.id===t));"PERSONALIZED_FILTER"===t?this.openPersonalizedModal():"DEFAULT_FILTER"===t?this.openDefaultFilterModal():i&&(this._pendingFilters.push(t),this.updateFilter(Object.assign(Object.assign({},i),{visible:!0})))}appliedFilterHandler(t){if("CLEAR_ALL_FILTERS"===t)this.clearFilters()&&this._application.info(this.getMessage("snkFilterBar.successfullyCleaned"),{iconName:"check"});else{const i=this._element.querySelector("#filter-"+t);i&&i.showUp(!0)}}componentWillLoad(){this._application=d.getContextValue("__SNK__APPLICATION__"),this._application&&(this.loadPermitions(),this.loadConfigFromApplication()),this.attachDataUnit()}componentDidRender(){this.processPendingFilter()}render(){if(this.dataUnit&&this.filterConfig&&0!==this.filterConfig.length)return i(e,null,i("ez-scroller",{direction:"horizontal",activeShadow:!0,locked:this.scrollerLocked},this.getFilterItems()),i("snk-filter-list",{id:"APPLIED_FILTERS",onFocusin:()=>this.itemFocused("APPLIED_FILTERS"),items:this.getAppliedListItems(),getMessage:(t,i)=>this.getMessage(t,i),emptyText:this.getMessage("snkFilterBar.emptyAppliedFiltersList"),findFilterText:this.getMessage("snkFilterBar.findFilter"),iconName:"filter",class:"ez-padding-left--medium",buttonClass:this.getActiveClass(),onSnkItemSelected:t=>this.appliedFilterHandler(t.detail),"data-element-id":this._idSnkFilterList}),i("snk-filter-list",{id:"ADD_FILTER",onFocusin:()=>this.itemFocused("ADD_FILTER"),items:this.getAddListItems(),label:this.getMessage("snkFilterBar.addFilter"),getMessage:(t,i)=>this.getMessage(t,i),emptyText:this.getMessage("snkFilterBar.emptyFiltersList"),findFilterText:this.getMessage("snkFilterBar.findField"),class:"ez-padding-left--medium",onSnkItemSelected:t=>this.addFilterHandler(t.detail),"data-element-id":this._idSnkFilterList},i("ez-icon",{slot:"leftIcon",class:"ez-padding-right--small",iconName:"plus"})))}get _element(){return s(this)}static get watchers(){return{filterConfig:["observeFilterConfig"]}}};L.style='.sc-snk-filter-bar-h{display:grid;grid-template-columns:minmax(100px, 100%) 1fr 1fr}.snk-filter__popover-container.sc-snk-filter-bar{display:flex;cursor:auto}.snk-filter__popover.sc-snk-filter-bar{display:flex;flex-direction:column;position:absolute;width:fit-content;height:fit-content;min-width:265px;z-index:var(--more-visible, 2);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)}.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 I=class{constructor(i){t(this,i),this.visibleChanged=r(this,"visibleChanged",7),this.filterChange=r(this,"filterChange",7),this.innerClickCheck=(t,i)=>i.id!=c.MODAL_ELEMENT_ID||(this.detailIsVisible=!1,!1)}observeDetailIsVisible(t){this.visibleChanged.emit(t)}async showUp(t=!1){return new Promise((i=>{this._filterItemElement.scrollIntoView({behavior:"auto",block:"nearest",inline:"nearest"}),t&&(this._closeCallback=i,window.requestAnimationFrame((()=>{this._floatingID=c.float(this._popover,this._popoverContainer,{autoClose:!0,innerClickTest:this.innerClickCheck,backClickListener:()=>this.onDetailCloseCallback(),left:this.getScrollOffset(),useOverlay:!0}),this._popover.show(),this.detailIsVisible=!0})))}))}getScrollOffset(){const t=getComputedStyle(this._filterItemElement).getPropertyValue("padding-left");return`calc(${this._filterItemElement.getBoundingClientRect().left}px + ${t})`}async hideDetail(){this.detailIsVisible&&null!=this._floatingID&&c.close(this._floatingID)}onDetailCloseCallback(){this._floatingID=void 0,this.detailIsVisible=!1,this._closeCallback&&(this._closeCallback(),this._closeCallback=void 0)}clickListener(t){[this._chipElement,this._leftIconElement,this._rightIconElement].includes(t.target)&&(t.target===this._rightIconElement&&null!=this.config.value?this.filterChange.emit(Object.assign(Object.assign({},this.config),{value:void 0})):this.detailIsVisible?this.hideDetail():this.showUp(!0),t.preventDefault(),t.stopImmediatePropagation(),t.stopPropagation())}mouseDownListener(t){this.detailIsVisible&&[this._chipElement,this._leftIconElement,this._rightIconElement].includes(t.target)&&(t.preventDefault(),t.stopImmediatePropagation(),t.stopPropagation())}getLabel(){const{type:t,value:i,label:e,props:s}=this.config;if(i){if(t===u.BINARY_SELECT){const[t,e]=s.options;if(t.name===i)return t.label;if(e.name===i)return e.label}if(t===u.MULTI_SELECT)return`${e}: ${s.options.find((t=>t.value===i)).label}`;if(t===u.PERIOD){let{end:t,start:s}=i;"string"==typeof t&&(t=new Date(t),t.setMinutes(t.getMinutes()+t.getTimezoneOffset())),"string"==typeof s&&(s=new Date(s),s.setMinutes(s.getMinutes()+s.getTimezoneOffset()));const r=new Intl.DateTimeFormat("pt-BR");return t&&s?`${e}: ${r.format(s)} a ${r.format(t)}`:s?`${e}: A partir de ${r.format(s)}`:t?`${e}: Até ${r.format(t)}`:e}return t===u.SEARCH?`${e}: ${i.value} - ${i.label}`:t===u.PERSONALIZED?e:`${e}: ${i}`}return e}componentDidLoad(){if(this._filterItemElement){a.addIDInfo(this._filterItemElement);const t=this._filterItemElement.getAttribute("data-element-id");this._idSnkFilterDetail=`${t}_${this.config.id}`,this._idEzChip=`${t}_${this.config.id}`}}componentDidRender(){null==this._floatingID&&this._popover&&this._popover.remove()}filterChangeListener(){this.hideDetail()}getRightIconName(){return null!=this.config.value?"close":this.detailIsVisible?"chevron-up":"chevron-down"}getLeftIconName(){switch(this.config.type){case u.PERIOD:return"calendar";case u.PERSONALIZED:return"tune"}}render(){const t=this.getLeftIconName();return i(e,null,i("ez-chip",{ref:t=>this._chipElement=t,label:this.getLabel(),value:null!=this.config.value,"data-element-id":this._idEzChip},t?i("ez-icon",{ref:t=>this._leftIconElement=t,iconName:t,class:"ez-padding-right--small",slot:"leftIcon"}):void 0,i("ez-icon",{ref:t=>this._rightIconElement=t,iconName:this.getRightIconName(),class:"ez-padding-left--small",slot:"rightIcon"})),i("section",{class:"ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container",ref:t=>this._popoverContainer=t},i("snk-filter-detail",{config:this.config,getMessage:this.getMessage,class:"sc-snk-filter-bar snk-filter__popover ez-padding--small",ref:t=>this._popover=t,key:this.config.id,"data-element-id":this._idSnkFilterDetail})))}get _filterItemElement(){return s(this)}static get watchers(){return{detailIsVisible:["observeDetailIsVisible"]}}},E=class{constructor(i){t(this,i),this.snkItemSelected=r(this,"snkItemSelected",7),this._preselection=-1,this.innerClickCheck=(t,i)=>i.id!=c.MODAL_ELEMENT_ID||(this._detailIsVisible=!1,!1)}showDetail(){this._preselection=-1,this._floatingID=c.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&&c.close(this._floatingID)}onListCloseCallback(){this._floatingID=void 0,this._detailIsVisible=!1}buttonClick(){this._detailIsVisible?this.hideDetail():this.showDetail()}componentDidLoad(){this._element&&a.addIDInfo(this._element)}componentDidRender(){null==this._floatingID&&this._popover&&this._popover.remove()}buildItemElement(t){const e=++this._selectableItemsCount;return this._buttonElement&&a.addIDInfo(this._buttonElement),i("button",{id:`filter-item${e}`,onFocusin:()=>this._preselection=e,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),ref:t=>this._buttonElement=t},t.iconName?i("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,i("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){"__SHOWMORE__"===t?this._showAll=!0:(this.hideDetail(),this.snkItemSelected.emit(t))}getFilterItems(){const t=this.items?f.applyStringFilter(this._filterArgument,this.items.filter((t=>"FILTER"===t.kind))):[];return 0===t.length?i("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:"Mostrar mais",iconName:"dots-horizontal",name:"__SHOWMORE__",iconClass:"snk-filter-bar__filter-list-item__icon--secondary",labelClass:"snk-filter-bar__filter-list-item__label--secondary"})),this._selectableItemsCount=0,i("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 i(e,{class:"ez-flex ez-flex--column"},i("ez-button",{class:this.buttonClass,label:this.label,onClick:()=>this.buttonClick(),mode:this.iconName?"icon":void 0,iconName:this.iconName,size:"small"},i("slot",{name:"leftIcon"})),i("section",{class:"ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container",ref:t=>this._popoverContainer=t},i("div",{class:"sc-snk-filter-bar snk-filter__popover ez-padding--small",ref:t=>this._popover=t},i("ez-filter-input",{ref:t=>this._filterInput=t,mode:"slim",label:this.findFilterText,value:this._filterArgument,onEzChange:t=>this._filterArgument=t.detail,onFocus:()=>this._preselection=0}),this.getFilterItems(),i("hr",{class:"sc-snk-filter-bar snk-filter__popover-rule"}),this.items?this.getFooterItems().map((t=>this.buildItemElement(t))):void 0)))}get _element(){return s(this)}},A=class{constructor(i){t(this,i)}updateValue(t,i){this.items=this.items.map((e=>e.id===t&&e.enabled?(null==i&&(i=!e.active),Object.assign(Object.assign({},e),{active:i})):e))}getActiveFiltersMsg(){const t=this.items.filter((t=>t.active)).length;return 0===t?this.getMessage("snkFilterBar.noActiveFilters"):this.getMessage(t>1?"snkFilterBar.activeFilters":"snkFilterBar.activeFilter",{ACTIVE_FILTERS:t})}buildItems(t){return t.map((t=>i("button",{onClick:()=>this.updateValue(t.id),class:"ez-padding--medium sc-snk-filter-bar snk-filter-bar__filter-modal-item ez-align--middle ez-margin-bottom--small"},i("ez-check",{id:`checkbox_${t.id}`,tabIndex:"-1",class:"sc-snk-filter-bar snk-filter-bar__filter-modal-item__check",onEzChange:i=>this.updateValue(t.id,i.detail),enabled:t.enabled,value:t.active,mode:k.SWITCH}),i("div",{class:"ez-text ez-title--primary ez-text--medium ez-margin-left--medium sc-snk-filter-bar snk-filter-bar__filter-modal-item__label"},t.label))))}itemKeyBoardSelect(t,i){"Enter"!==t.key&&" "!==t.key||this.updateValue(i.id)}modalActionListener(t){const i=t.detail;i===m.LOAD?this._filterInput&&this._filterInput.setFocus():this.processModalAction(i)}render(){const t=this.items.filter((t=>t.active)).length>0,e=this.items?f.applyStringFilter(this._filterArgument,this.items):[];return i("ez-modal-container",{class:"snk-filter__modal-container",modalTitle:this.modalTitle,modalSubTitle:this.modalSubTitle,cancelButtonLabel:this.cancelButtonLabel,okButtonLabel:this.okButtonLabel,onEzModalAction:t=>this.modalActionListener(t),cancelButtonStatus:t?g.ENABLED:g.DISABLED},i("div",{class:"sc-snk-filter-bar snk-filter-bar__filter-modal-content"},i("div",null,this.useSearch?i("ez-filter-input",{ref:t=>this._filterInput=t,label:this.getMessage("snkFilterBar.modalFindFilter"),onEzChange:t=>this._filterArgument=t.detail}):void 0),e.length>0?i("div",{class:"ez-text ez-text--medium ez-text--primary ez-padding-bottom--small"},this.getActiveFiltersMsg()):void 0,i("div",null,this.buildItems(e)),i("div",{class:"ez-text ez-text--large ez-align--middle ez-text--secondary ez-text--center ez-padding-bottom--large"},this.infoText)))}};A.style=".snk-filter__modal-container{width:359px;max-width:359px}";const D=class{constructor(i){t(this,i),this.configChange=r(this,"configChange",7),this.configCancel=r(this,"configCancel",7),this._orderListItems=[],this._orderPriorityList=[],this._columListItems=[],this._selectedIndex=-1,this._dataChanged=!1,this._componenteInternalKey=Date.now(),this.selectedIndex=0}async saveConfig(t){var i;null!=t&&null!=(null===(i=this._application)||void 0===i?void 0:i.configName)&&v.saveGridConfig(t,this._application.configName).then((i=>{null!=(null==i?void 0:i.resource)&&(this.configChange.emit(t),this._orderList.clearHistory())}))}getMessage(t,i){return this._application.messagesBuilder.getMessage(t,i)}createOrderList(){let t=[];this.columns.filter((t=>{var i;return o.getBooleanValue(null===(i=null==t?void 0:t.props)||void 0===i?void 0:i.get("sortable"),!0)})).forEach((i=>{var e;let s=null===(e=this.config)||void 0===e?void 0:e.columns.find((t=>t.name===i.name)),r={name:i.name,label:i.label};s&&(r.orderIndex=s.orderIndex,r.ascending=s.ascending),i.hidden||t.push(r)})),t.sort(((t,i)=>0!=t.orderIndex||0!=i.orderIndex||null==t.ascending&&null==i.ascending?null!=t.ascending&&null!=i.ascending?t.orderIndex-i.orderIndex:null!=t.ascending||null!=i.ascending?null!=t.ascending?-1:null!=i.ascending?1:0:t.orderIndex-i.orderIndex:null!=t.ascending?-1:null!=i.ascending?1:0)),this._orderListItems=t}createColumnList(){let t={group:this.getMessage("snkGridConfig.group.visible"),items:[]},i={group:this.getMessage("snkGridConfig.group.hidden"),items:[],sort:x.asc.value};this.columns.forEach((e=>{let s={label:e.label};e.hidden?i.items.push(s):t.items.push(s)})),this._columListItems=[t,i]}buildColumnListSlot(t,e){const s=`${this._element.getAttribute("data-element-id")}_configItem_${o.toCamelCase(t.label)}`;return i("div",null,i("ez-check",{mode:"switch",id:"switch"+((null==t?void 0:t.label)||"")+((null==e?void 0:e.group)||""),value:e.group===this.getMessage("snkGridConfig.group.visible"),"data-element-id":s,onEzChange:i=>{this.switchColumnGroup(i,t)}}))}buildOrderListSlot(t){const e=`${this._element.getAttribute("data-element-id")}_configItem_${o.toCamelCase(t.label)}`;let s=x.none.value;return null!=(null==t?void 0:t.ascending)&&(s=1==t.ascending?x.asc.value:x.desc.value),i("div",null,i("snk-select-box",{selectedOption:s,key:"snk-select-box-"+this._componenteInternalKey+"-"+t,"data-element-id":e,onEzChange:i=>{i.stopPropagation(),this.updateOrder(i.detail,t.label)}}))}updateOrder(t,i){var e;this._dataChanged=!0;let s,r=[...this.columns],n=r.find((t=>t.label===i));n&&(n.sort=t.value===x.none.value?void 0:t.value),(null===(e=this._orderPriorityList)||void 0===e?void 0:e.length)>0?(this._orderPriorityList.find((t=>t.label===n.label)).sort=t,this._orderPriorityList.filter((t=>t.sort)).map(((t,i)=>{t.label===n.label&&(n.sortIndex=i)}))):(s=r.filter((t=>t.sort&&!0!==t.hidden)).map(((t,i)=>({label:t.label,orderIndex:i}))),s.forEach((t=>{r.find((i=>i.label===t.label)).sortIndex=t.orderIndex}))),this.columns=r}switchColumnGroup(t,i){t.stopPropagation();let e=[...this._columListItems];if(this._dataChanged=!0,!0===t.detail){let t=e.find((t=>t.group===this.getMessage("snkGridConfig.group.hidden"))),s=t.items.findIndex((t=>t.label===i.label));s>=0&&t.items.splice(s,1),e.find((t=>t.group===this.getMessage("snkGridConfig.group.visible"))).items.push(i),this._columListItems=e,this.createOrderList()}else if(!1===t.detail){let t=e.find((t=>t.group===this.getMessage("snkGridConfig.group.visible"))),s=t.items.findIndex((t=>t.label===i.label));s>=0&&t.items.splice(s,1),e.find((t=>t.group===this.getMessage("snkGridConfig.group.hidden"))).items.push(i),this._columListItems=e,this.createOrderList()}}finish(){if(!this._dataChanged)return void this.closeConfig();let t=[];this._columListItems.forEach((i=>{i.items.forEach((e=>{const s=this.columns.find((t=>t.label===e.label));let r=Object.assign({},s);r.hidden=i.group===this.getMessage("snkGridConfig.group.hidden"),t.push(r)}))})),this.columns=t,this._dataChanged=!1,this.closeConfig(),this.save()}save(){var t;let i;i=this.config?this.config:this.createConfigFromState(this.columns);let e,s=[];if((null===(t=this._orderPriorityList)||void 0===t?void 0:t.length)>0){e=this.columns.filter((t=>t.sort&&!0!==t.hidden)).map((t=>({label:t.label,orderIndex:0})));let t=0,i=[];this._orderPriorityList.forEach((s=>{let r=e.find((t=>t.label===s.label));r&&(r.orderIndex=t,i.push(r),t++)})),i.length>0&&(e=i)}for(let t=0;t<this.columns.length;t++){const n=this.columns[t];let l=i.columns.find((t=>n.name===t.name));!0===n.hidden&&l||(l?l.width=n.width:!1===n.hidden&&(l={name:n.name,width:n.width,orderIndex:0}),l&&(n.sort?(l.ascending=n.sort.toUpperCase()===x.asc.value,e?r(n,l):l.orderIndex=n.sortIndex):(delete l.ascending,l.orderIndex=0),s.push(l)))}function r(t,i){if(e){let s=e.find((i=>i.label===t.label));s&&(i.orderIndex=s.orderIndex)}}i.columns=s,this.saveConfig(i).then((()=>{p.info(this.getMessage("snkGridConfig.info.successfullyConfigSaved"),{iconName:"check"})}))}createConfigFromState(t){let i={columns:[]};return t.forEach((t=>{if(!t.hidden){let e={name:t.name};t.width&&(e.width=t.width),t.sort?(e.ascending=t.sort.toUpperCase()===x.asc.value,e.orderIndex=t.sortIndex):e.orderIndex=0,e&&i.columns.push(e)}})),i}async locateColumn(t,i){var e;const s="Enter"===t.key;i||(i=null===(e=t.currentTarget)||void 0===e?void 0:e.value);let r=-1;if(1===this.selectedIndex)if(i){const t=[];let e,n;if(await this._orderList.getList().then((s=>{e=s,e.forEach(((e,s)=>{this.compareWords(e,i)&&t.push(s)}))})),t.length>0){if(s)for(let i=0;i<t.length;i++)if(t[i]>this._selectedIndex){r=t[i];break}-1===r&&(r=t[0])}this._selectedIndex=r,n=e[r],n?this._orderList.setSelection({label:n.label},!0):this._orderList.setSelection(void 0)}else this._orderList.setSelection(void 0);else if(i){const t=[];if(this.columns.forEach(((e,s)=>{this.compareWords(e,i)&&t.push(s)})),t.length>0){if(s)for(let i=0;i<t.length;i++)if(t[i]>this._selectedIndex){r=t[i];break}-1===r&&(r=t[0])}this._selectedIndex=r;let e=this.columns[r];e?this._columnList.setSelection({label:e.label},!0):this._columnList.setSelection(void 0)}else this._columnList.setSelection(void 0)}compareWords(t,i){return o.replaceAccentuatedChars(t.label).indexOf(o.replaceAccentuatedChars(i))>-1}getColumnNames(){const t=[];return t.push(this.getMessage("snkGridConfig.tab.columns")),t.push(this.getMessage("snkGridConfig.tab.lineOrdering")),t.join(",")}closeConfig(){if(this._orderList.scrollToTop(),this._columnList.scrollToTop(),this._searchElement.value="",this._dataChanged){let t={canClose:!1,labelCancel:this.getMessage("snkGridConfig.confirm.cancel"),labelConfirm:this.getMessage("snkGridConfig.confirm.save"),btnConfirmDanger:!1};p.confirm(this.getMessage("snkGridConfig.confirm.alert"),this.getMessage("snkGridConfig.confirm.msgCancel"),null,_.WARN,t).then((t=>{t?this.finish():(this._dataChanged=!1,this.configCancel.emit(),this._orderList.clearHistory(),this._componenteInternalKey=Date.now())}))}else this.configCancel.emit(),this._orderList.clearHistory()}handleTabChange(t){null!=(null==t?void 0:t.index)&&(this.selectedIndex!==t.index&&(0===t.index?this._orderList.scrollToTop():1===t.index&&this._columnList.scrollToTop(),this._searchElement.value=""),1===t.index&&this.createOrderList(),this.selectedIndex=t.index)}handleColumnListChange(t){var i;if(t.detail){let e=null===(i=t.detail.find((t=>t.group===this.getMessage("snkGridConfig.group.visible"))))||void 0===i?void 0:i.items;e&&(this._dataChanged=!0,this._orderListItems=e)}}handleOrderListChange(t){if(t.detail){let i=t.detail;i&&(this._dataChanged=!0,this._orderPriorityList=i)}}componentWillRender(){var t;(null===(t=this.columns)||void 0===t?void 0:t.length)>0&&this.createColumnList()}componentDidRender(){var t;(null===(t=this.columns)||void 0===t?void 0:t.length)>0&&this.locateColumn(new KeyboardEvent("arrow-right",{key:"ArrowRight"}),this._searchElement.value)}componentWillLoad(){this._application=d.getContextValue("__SNK__APPLICATION__")}componentDidLoad(){a.addIDInfo(this._element)}render(){return i(e,null,i("div",{class:"grid-config__header"},i("div",{class:"title-container"},i("div",{class:""},i("label",{class:"title"},this.getMessage("snkGridConfig.gridConfiguration")),i("label",{class:"subtitle"},this.getMessage("snkGridConfig.columnVisibilityOrder"))),i("div",{class:"button-close"},i("ez-button",{mode:"icon",iconName:"close",size:"medium",onClick:()=>this.closeConfig()}))),i("div",{class:"tabselector-container"},i("ez-tabselector",{selectedIndex:this.selectedIndex,onEzChange:t=>{this.handleTabChange(t.detail)},tabs:this.getColumnNames()})),i("div",null,i("ez-text-input",{ref:t=>this._searchElement=t,label:this.getMessage("snkGridConfig.findColumn"),onKeyUp:t=>this.locateColumn(t)},i("ez-icon",{slot:"leftIcon",size:"medium",iconName:"search"})))),i("div",{class:"grid-config__main"},i("ez-list",{ref:t=>this._columnList=t,class:0===this.selectedIndex?"":"hidden",dataSource:this._columListItems,onEzChange:t=>this.handleColumnListChange(t),ezDraggable:!0,ezSelectable:!0,itemSlotBuilder:(t,i)=>this.buildColumnListSlot(t,i),useGroups:!0}),i("div",{class:1===this.selectedIndex?"group-name":"hidden"},this.getMessage("snkGridConfig.info.sortingSequence")),i("ez-list",{ref:t=>this._orderList=t,class:1===this.selectedIndex?"height-calc":"hidden",dataSource:this._orderListItems,ezSelectable:!0,onEzChange:t=>this.handleOrderListChange(t),ezDraggable:!0,itemSlotBuilder:t=>this.buildOrderListSlot(t)})),i("div",{class:"grid-config__footer"},i("ez-button",{class:"padding-right--medium",label:this.getMessage("snkGridConfig.cancel"),onClick:()=>this.closeConfig()}),i("ez-button",{label:this.getMessage("snkGridConfig.complete"),class:"ez-button--primary",onClick:()=>this.finish()})))}static get assetsDirs(){return["../assets"]}get _element(){return s(this)}};D.style='.sc-snk-grid-config-h{--snk-grid-config__footer--padding-top:var(--space--medium, 12px);--snk-grid-config__main--padding-right:var(--space--medium, 12px);--snk-grid-config__tabselector-container--padding:var(--space--medium, 12px);--snk-grid-config__button-close--padding-left:var(--space--medium, 12px);--snk-grid-config__title--color:var(--title--primary, #2B3A54);--snk-grid-config__title--font-family:var(--font-pattern, "Roboto");--snk-grid-config__title--font-size:var(--title--large, 20px);--snk-grid-config__title--font-weight:var(--text-weight--extra-large, 700);--snk-grid-config__subtitle--font-family:var(--font-pattern, "Roboto");--snk-grid-config__subtitle--font-size:var(--text--medium, 14px);--snk-grid-config__scrollbar--width:var(--space--medium, 12px);--snk-grid-config__scrollbar--background-color-primary:var(--scrollbar--primary, #2B3A54);--snk-grid-config__scrollbar--background-color-secondary:var(--scrollbar--secondary, #E5EAF0);--snk-grid-config__scrollbar--border-radius:var(--border--radius-small, 6px);--snk-grid-config__group--font-family:var(--font-pattern, "Roboto");--snk-grid-config__group--font-size:var(--text--medium, 14px);--snk-grid-config__group--font-weight:var(--text-weight--large, 600);--snk-grid-config__group--padding-bottom:var(--space-small, 6px);display:grid;grid-template-rows:auto 1fr auto;max-height:100%;width:100%}@media screen and (min-width: 480px){.sc-snk-grid-config-h{width:359px;max-width:359px}}.padding-right--medium.sc-snk-grid-config{padding-right:var(--space--medium)}ez-list.sc-snk-grid-config{height:100%}.height-calc.sc-snk-grid-config{max-height:calc(100% - 24px)}.grid-config__footer.sc-snk-grid-config{display:flex;justify-content:flex-end;width:100%;padding-top:var(--snk-grid-config__footer--padding-top)}.hidden.sc-snk-grid-config{display:none}.tabselector-container.sc-snk-grid-config{padding:var(--snk-grid-config__tabselector-container--padding) 0}.button-close.sc-snk-grid-config{padding-left:var(--snk-grid-config__button-close--padding-left)}.title-container.sc-snk-grid-config{display:flex;justify-content:space-between;align-items:center;width:100%}.title.sc-snk-grid-config{display:flex;margin:0;line-height:normal;letter-spacing:0em;text-align:left;color:var(--snk-grid-config__title--color);font-size:var(--snk-grid-config__title--font-size);font-family:var(--snk-grid-config__title--font-family);font-weight:var(--snk-grid-config__title--font-weight)}.subtitle.sc-snk-grid-config{color:var(--text--primary);font-size:var(--snk-grid-config__subtitle--font-size);font-family:var(--snk-grid-config__subtitle--font-family)}.grid-config__main.sc-snk-grid-config{overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--snk-grid-config__scrollbar--background-color-primary) var(--snk-grid-config__scrollbar--background-color-secondary);padding-right:var(--snk-grid-config__main--padding-right)}.grid-config__main.sc-snk-grid-config::-webkit-scrollbar-track{background-color:var(--snk-grid-config__scrollbar--background-color-secondary)}.grid-config__main.sc-snk-grid-config::-webkit-scrollbar-thumb{background-color:var(--snk-grid-config__scrollbar--background-color-primary);border-radius:var(--snk-grid-config__scrollbar--border-radius)}.grid-config__main.sc-snk-grid-config::-webkit-scrollbar{width:var(--snk-grid-config__scrollbar--width);max-width:var(--snk-grid-config__scrollbar--width);min-width:var(--snk-grid-config__scrollbar--width);background-color:var(--snk-grid-config__scrollbar--background-color-secondary)}.group-name.sc-snk-grid-config{font-family:var(--snk-grid-config__group--font-family);font-size:var(--snk-grid-config__group--font-size);font-weight:var(--snk-grid-config__group--font-weight);padding-bottom:var(--snk-grid-config__group--padding-bottom)}';const O=class{constructor(i){t(this,i),this.ezChange=r(this,"ezChange",7),this.selectedOption=x.none}render(){return i("ez-combo-box",{class:"grid-config-combo ez-input--inverted",label:"",suppressSearch:!0,value:this.selectedOption,enabled:!0,canShowError:!1,suppressEmptyOption:!0},Object.keys(x).map((t=>i("option",{value:x[t].value},x[t].label))))}static get assetsDirs(){return["../assets"]}};O.style="ez-combo-box{width:100px}.grid-config-combo{--ez-text-input--height:28px;--ez-text-input__input--background-color:#fff;--ez-text-input__input--border-color:#dce0e8}";const S=class{constructor(i){t(this,i),this.actionClick=r(this,"actionClick",7),this.actionChange=r(this,"actionChange",7),this._titleKeyByElement={[y.UPDATE]:"snkTaskbar.titleUpdate",[y.PREVIOUS]:"snkTaskbar.titlePrevious",[y.NEXT]:"snkTaskbar.titleNext",[y.REFRESH]:"snkTaskbar.titleRefresh",[y.CLONE]:"snkTaskbar.titleClone",[y.REMOVE]:"snkTaskbar.titleRemove",[y.MORE_OPTIONS]:"snkTaskbar.titleMoreOptions",[y.INSERT]:"snkTaskbar.titleInsert",[y.CANCEL]:"snkTaskbar.titleCancel",[y.SAVE]:"snkTaskbar.titleSave",[y.GRID_MODE]:"snkTaskbar.titleGridMode",[y.FORM_MODE]:"snkTaskbar.titleFormMode",[y.CONFIGURATOR]:"snkTaskbar.titleConfigurator"}}observeButtons(){this._definitions=void 0}elementsFromString(t){const i=[];return null==t||t.split(",").forEach((t=>{t=t.trim(),(C[t]||this.isAllowed(t))&&i.push(t.trim())})),i}isAllowed(t){return t===F.CONFIGURATOR?!!this._permissions&&(this._permissions.isSup||this._permissions[z.CONFIG_GRID]||this._permissions[z.CONFIG]):!F[t]||!!this._permissions&&(this._permissions.isSup||this._permissions[t])}getTitle(t){let i;return i=this.isAllowed(t)?this._titleKeyByElement[t]:"snkTaskbar.forbidden",i?this._application.messagesBuilder.getMessage(i,{}):""}elementClick(t){if(this.dataUnit)switch(t){case y.PREVIOUS:this.dataUnit.previousRecord();break;case y.NEXT:this.dataUnit.nextRecord();break;case y.REFRESH:this.dataUnit.loadData();break;case y.CLONE:this.dataUnit.copySelected();break;case y.REMOVE:this.dataUnit.removeSelectedRecords();break;case y.INSERT:this.dataUnit.addRecord();break;case y.CANCEL:this.dataUnit.cancelEdition();break;case y.SAVE:this.dataUnit.saveData()}this.actionClick.emit(t)}isEnabled(t){return!(!this.isAllowed(t)||this.disabledButtons&&this.disabledButtons.includes(t))}getElement(t,i){let e=i===this.primaryButton?"ez-button--primary ":"";return t>1&&(e+="ez-padding-left--medium"),y[i.toString()]?w(i,e,this.getIdElemBtnNative(i),(t=>this.getTitle(t)),(t=>this.elementClick(t)),(t=>this.isEnabled(t)),this.actionsList):T(i,e,this.getIdElemBtnCustom(i),(t=>this.elementClick(t)),(t=>this.isEnabled(t)))}getIdElemBtnNative(t){return`${this._element.getAttribute("data-element-id")}_${o.toCamelCase(t)}`}getIdElemBtnCustom(t){return`${this._element.getAttribute("data-element-id")}_${o.toCamelCase(t.name)}`}isDivider(t){var i;return void 0!==t&&(null===(i=t.t)||void 0===i?void 0:i["data-taskbar-divider"])}removeEmpty(t){let i;return t.filter((t=>!(null==t||this.isDivider(i)&&this.isDivider(t)||(i=t,0))))}componentWillLoad(){this._application=d.getContextValue("__SNK__APPLICATION__"),this._application?this._application.getAllAccess().then((t=>this._permissions=t)):this._permissions={}}componentWillRender(){null==this._definitions&&this._permissions&&(this._definitions=this.elementsFromString(this.buttons))}componentDidLoad(){a.addIDInfo(this._element,null,{dataUnit:this.dataUnit})}render(){if(void 0===this._definitions)return;let t=0;return i(e,null,this.removeEmpty(this._definitions.map((e=>(e===y.DIVIDER?t=0:t++,y[e]?this.getElement(t,y[e]):this.customButtons.has(e)?this.getElement(t,this.customButtons.get(e)):i("slot",{name:e}))))))}get _element(){return s(this)}static get watchers(){return{buttons:["observeButtons"]}}};S.style=".sc-snk-taskbar-h{display:flex}";export{L as snk_filter_bar,I as snk_filter_item,E as snk_filter_list,A as snk_filter_modal,D as snk_grid_config,O as snk_select_box,S as snk_taskbar}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,c as i,h as s,g as e}from"./p-9ba3df4c.js";import{DateUtils as a,ObjectUtils as o,ElementIDUtils as r,ApplicationContext as n}from"@sankhyalabs/core";import{T as h}from"./p-03f9c407.js";import{C as d}from"./p-6ba8f415.js";import"./p-112455b1.js";const l=class{constructor(s){t(this,s),this.exit=i(this,"exit",7),this.actionClick=i(this,"actionClick",7),this._renderTimer=500,this._taskbarProcessor=new h({"snkForm.regular":["PREVIOUS","NEXT","DIVIDER","CLONE","REMOVE","MORE_OPTIONS","DIVIDER","GRID_MODE","CONFIGURATOR","INSERT"],"snkForm.finish_edition":["CANCEL","SAVE"]}),this._editionFormConfig={},this._insertionFormConfig={},this._showFormConfig=!1}async showConfig(){this._showFormConfig=!0}async hideConfig(){this._showFormConfig=!1}loadConfig(){d.get().loadFormConfig(this.configName).then((t=>{this.setConfig(t)||this.loadInsertionConfig()})).catch((t=>{console.warn(t)}))}setConfig(t){return null!=(null==t?void 0:t.fields)&&(setTimeout((async()=>{for(const i of t.fields)if(i.defaultValue&&"value"in i.defaultValue){const t=i.defaultValue.value;await this.getFormattedValue(t).then((t=>{i.defaultValue.formattedValue=t}))}this._editionFormConfig=t,this.loadInsertionConfig()}),this._renderTimer),!0)}async getFormattedValue(t){switch(t){case"${data}":return()=>a.getToday();case"${datahora}":return()=>a.getToday(!0);case"${usuario}":case"${usuario.empresa}":case"${usuario.vendedor}":case"${usuario.centroresultado}":let i;return await this._application.getDefaultValue(t).then((t=>{i=t})),i;default:return t}}loadInsertionConfig(){var t;if(this._dataUnit){const i=o.copy(this._editionFormConfig||{});i.fields=null===(t=i.fields)||void 0===t?void 0:t.filter((t=>{const i=this._dataUnit.getField(t.name);return!(null==i?void 0:i.readOnly)})),this._insertionFormConfig=i}}getFormConfig(){return this._dataState&&this._dataState.insertionMode?this._insertionFormConfig:this._editionFormConfig}exitForm(){this._dataUnit.isDirty()?this._dataUnit.cancelEdition({after:()=>this.exit.emit()}):this.exit.emit()}getMessage(t){return this._application.messagesBuilder.getMessage(t,this.getMessageParams())}getMessageParams(){var t;return(null===(t=this._dataState)||void 0===t?void 0:t.selectedRecords)?this._dataState.selectedRecords[0]:void 0}changeConfig(t){this._editionFormConfig={},this.setConfig(t)||this.loadInsertionConfig()}closeConfig(){this.hideConfig()}getDisabledButtons(){const t=[];return this._dataState.hasPrevious||t.push("PREVIOUS"),this._dataState.hasNext||t.push("NEXT"),t}dataunitReady(){this.loadInsertionConfig(),r.addIDInfo(this._element,null,{dataUnit:this._dataUnit})}getDataElementId(t){return`${this._element.getAttribute("data-element-id")}_${t}`}componentWillLoad(){this._application=n.getContextValue("__SNK__APPLICATION__");let t=this._element.parentElement;for(;t;){if("SNK-DATA-UNIT"===t.tagName.toUpperCase()){this._snkDataUnit=t,this._dataUnit=this._snkDataUnit.dataUnit,this._dataState=this._snkDataUnit.dataState,this._dataUnit?this.dataunitReady():this._snkDataUnit.addEventListener("dataUnitReady",(t=>{this._dataUnit=t.detail,this.loadInsertionConfig()})),this._snkDataUnit.addEventListener("dataStateChange",(t=>{this._dataState=t.detail}));break}t=t.parentElement}this.loadConfig()}componentWillRender(){var t;const i=(null===(t=this._dataState)||void 0===t?void 0:t.isDirty)?"snkForm.finish_edition":"snkForm.regular",s=[];this._dataState&&this._dataState.hasPrevious||s.push("PREVIOUS"),this._dataState&&this._dataState.hasNext||s.push("NEXT"),this._taskbarProcessor.process(i,this.taskbarManager,this._dataState,s)}render(){var t;if(this._dataUnit&&this._dataState)return s("section",{class:"snk-form"},s("div",{class:"snk-form__header snk-form__header--fixed ez-row"},s("div",{class:"ez-col ez-col--sd-6 ez-col--tb-6",key:"formHeader"},s("ez-button",{title:this.getMessage("snkForm.goBackTitle"),mode:"icon",iconName:"arrow_back",class:"ez-padding-right--medium",size:"small",onClick:()=>this.exitForm()}),s("h1",{class:"ez-title ez-title--primary ez-title--xlarge ez-align--middle"},this.getMessage("snkForm.title"))),s("div",{class:"ez-col ez-col--sd-6 ez-col--tb-6 ez-align--right"},s("snk-taskbar",{key:"formTaskbar","data-element-id":this.getDataElementId("form_taskbar"),configName:this.configName,buttons:this._taskbarProcessor.buttons,disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,actionsList:this.actionsList,primaryButton:(null===(t=this._dataState)||void 0===t?void 0:t.isDirty)?"SAVE":"INSERT",dataUnit:this._dataUnit}))),s("section",null,s("div",{class:"ez-row"},s("div",{class:"ez-col ez-col--sd-12"},s("ez-form",{key:"ezForm"+this._snkDataUnit.entityName,"data-element-id":this.getDataElementId("internal_form"),dataUnit:this._dataUnit,config:this.getFormConfig(),recordsValidator:this.recordsValidator,class:this._showFormConfig?"snk-form__form--hidden":""}),this._showFormConfig&&s("snk-form-config",{dataUnit:this._dataUnit,formConfig:this.getFormConfig(),"data-element-id":this._element.getAttribute("data-element-id"),configName:this.configName,onConfigChange:t=>this.changeConfig(t.detail),onConfigClose:()=>this.closeConfig()})))))}get _element(){return e(this)}};l.style=".sc-snk-form-h{display:block}.snk-form.sc-snk-form{position:relative;padding:var(--space--large);padding-top:var(--space--medium)}.snk-form__header.sc-snk-form{position:relative;padding-top:var(--space--medium);padding-bottom:var(--space--medium);margin-bottom:var(--space--medium)}.snk-form__header--fixed.sc-snk-form{position:sticky;top:0;background:var(--background--body);z-index:var(--more-visible, 2);padding-left:var(--space--large);padding-right:var(--space--large);margin-left:calc(var(--space--large) * -1);margin-right:calc(var(--space--large) * -1);width:calc(100% + (var(--space--large) * 2))}.snk-form__form--hidden.sc-snk-form{display:none}";export{l as snk_form}
|