@sankhyalabs/sankhyablocks 1.4.0-beta.2 → 1.4.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/dist/cjs/{index-b0b676c5.js → index-6fcf07f3.js} +159 -1515
  2. package/dist/cjs/loader.cjs.js +2 -18
  3. package/dist/cjs/sankhyablocks.cjs.js +4 -116
  4. package/dist/cjs/snk-application.cjs.entry.js +50 -214
  5. package/dist/cjs/snk-crud.cjs.entry.js +3 -3
  6. package/dist/cjs/snk-data-unit.cjs.entry.js +23 -23
  7. package/dist/cjs/snk-filter-bar_5.cjs.entry.js +902 -0
  8. package/dist/cjs/snk-filter-binary-select.cjs.entry.js +1 -1
  9. package/dist/cjs/snk-filter-detail.cjs.entry.js +3 -3
  10. package/dist/cjs/snk-filter-multi-select.cjs.entry.js +1 -1
  11. package/dist/cjs/snk-filter-number.cjs.entry.js +1 -1
  12. package/dist/cjs/snk-filter-period.cjs.entry.js +1 -1
  13. package/dist/cjs/snk-filter-personalized.cjs.entry.js +23 -22
  14. package/dist/cjs/snk-filter-search.cjs.entry.js +3 -3
  15. package/dist/cjs/snk-filter-text.cjs.entry.js +1 -1
  16. package/dist/cjs/{snk-form.cjs.entry.js → snk-form_2.cjs.entry.js} +119 -5
  17. package/dist/cjs/snk-pesquisa.cjs.entry.js +5 -5
  18. package/dist/cjs/{taskbar-elements-283c737e.js → taskbar-elements-aedfeae6.js} +1 -1
  19. package/dist/cjs/teste-pesquisa.cjs.entry.js +5 -5
  20. package/dist/components/index.js +0 -4
  21. package/dist/components/snk-application2.js +10 -174
  22. package/dist/components/snk-crud.js +1 -1
  23. package/dist/components/snk-data-unit.js +2 -2
  24. package/dist/components/snk-filter-bar2.js +4 -2
  25. package/dist/components/snk-filter-detail2.js +1 -1
  26. package/dist/components/snk-filter-item2.js +1 -1
  27. package/dist/components/snk-filter-list2.js +1 -1
  28. package/dist/components/snk-filter-modal2.js +4 -19
  29. package/dist/components/snk-filter-personalized.js +2 -1
  30. package/dist/components/snk-filter-search.js +1 -1
  31. package/dist/components/snk-form2.js +1 -1
  32. package/dist/components/snk-grid2.js +1 -1
  33. package/dist/components/snk-pesquisa2.js +1 -1
  34. package/dist/components/snk-taskbar2.js +1 -1
  35. package/dist/components/teste-pesquisa.js +1 -1
  36. package/dist/{sankhyablocks/index-2b4d2d14.js → esm/index-81dda3cf.js} +160 -1508
  37. package/dist/esm/loader.js +2 -18
  38. package/dist/esm/sankhyablocks.js +4 -116
  39. package/dist/esm/snk-application.entry.js +11 -175
  40. package/dist/esm/snk-crud.entry.js +2 -2
  41. package/dist/esm/snk-data-unit.entry.js +3 -3
  42. package/dist/esm/{snk-filter-bar.entry.js → snk-filter-bar_5.entry.js} +436 -4
  43. package/dist/esm/snk-filter-binary-select.entry.js +1 -1
  44. package/dist/esm/snk-filter-detail.entry.js +2 -2
  45. package/dist/esm/snk-filter-multi-select.entry.js +1 -1
  46. package/dist/esm/snk-filter-number.entry.js +1 -1
  47. package/dist/esm/snk-filter-period.entry.js +1 -1
  48. package/dist/esm/snk-filter-personalized.entry.js +3 -2
  49. package/dist/esm/snk-filter-search.entry.js +2 -2
  50. package/dist/esm/snk-filter-text.entry.js +1 -1
  51. package/dist/{sankhyablocks/snk-form.entry.js → esm/snk-form_2.entry.js} +117 -4
  52. package/dist/esm/snk-pesquisa.entry.js +2 -2
  53. package/dist/esm/{taskbar-elements-35d64ff9.js → taskbar-elements-38eb5d51.js} +1 -1
  54. package/dist/esm/teste-pesquisa.entry.js +2 -2
  55. package/dist/sankhyablocks/index.esm.js +0 -1
  56. package/dist/sankhyablocks/p-0352c0e2.entry.js +1 -0
  57. package/dist/sankhyablocks/p-07ebda01.entry.js +1 -0
  58. package/dist/sankhyablocks/p-322c0df2.entry.js +1 -0
  59. package/dist/sankhyablocks/p-46caa101.entry.js +1 -0
  60. package/dist/sankhyablocks/p-473cedf9.entry.js +1 -0
  61. package/dist/sankhyablocks/p-586e2522.js +1 -0
  62. package/dist/sankhyablocks/p-86f15ffe.js +1 -0
  63. package/dist/sankhyablocks/p-8f3c5709.entry.js +1 -0
  64. package/dist/sankhyablocks/p-97009a2c.entry.js +1 -0
  65. package/dist/sankhyablocks/p-9be74b46.entry.js +74 -0
  66. package/dist/sankhyablocks/p-9dd2b8cb.js +1 -0
  67. package/dist/sankhyablocks/p-a8b59c61.entry.js +1 -0
  68. package/dist/sankhyablocks/p-aecf3e0a.entry.js +1 -0
  69. package/dist/sankhyablocks/p-c1c3b5d8.entry.js +1 -0
  70. package/dist/sankhyablocks/p-c78cb79a.entry.js +1 -0
  71. package/dist/sankhyablocks/p-c9eec639.entry.js +1 -0
  72. package/dist/sankhyablocks/p-dc482a42.entry.js +1 -0
  73. package/dist/sankhyablocks/p-fac2b6a9.js +2 -0
  74. package/dist/sankhyablocks/p-fb705f81.entry.js +1 -0
  75. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -129
  76. package/package.json +1 -1
  77. package/react/components.d.ts +19 -0
  78. package/react/components.js +19 -0
  79. package/react/components.js.map +1 -1
  80. package/dist/cjs/app-globals-3a1e7e63.js +0 -5
  81. package/dist/cjs/css-shim-b8158822.js +0 -6
  82. package/dist/cjs/dom-36862b77.js +0 -75
  83. package/dist/cjs/index-84fe3b86.js +0 -20
  84. package/dist/cjs/index-93965c41.js +0 -141
  85. package/dist/cjs/index-e90ae303.js +0 -2408
  86. package/dist/cjs/shadow-css-346c0795.js +0 -389
  87. package/dist/cjs/snk-filter-bar.cjs.entry.js +0 -466
  88. package/dist/cjs/snk-filter-item.cjs.entry.js +0 -177
  89. package/dist/cjs/snk-filter-list.cjs.entry.js +0 -91
  90. package/dist/cjs/snk-filter-modal.cjs.entry.js +0 -37
  91. package/dist/cjs/snk-grid.cjs.entry.js +0 -79
  92. package/dist/cjs/snk-taskbar.cjs.entry.js +0 -160
  93. package/dist/cjs/taskbar-processor-6bd0d35c.js +0 -47
  94. package/dist/components/index2.js +0 -2394
  95. package/dist/components/index3.js +0 -139
  96. package/dist/esm/app-globals-0f993ce5.js +0 -3
  97. package/dist/esm/css-shim-b3f2ee8d.js +0 -4
  98. package/dist/esm/dom-665d6011.js +0 -73
  99. package/dist/esm/index-2b4d2d14.js +0 -3262
  100. package/dist/esm/index-5992b7e6.js +0 -139
  101. package/dist/esm/index-c683b2b0.js +0 -2394
  102. package/dist/esm/index-c71285cb.js +0 -17
  103. package/dist/esm/shadow-css-b18e99d7.js +0 -387
  104. package/dist/esm/snk-filter-item.entry.js +0 -173
  105. package/dist/esm/snk-filter-list.entry.js +0 -87
  106. package/dist/esm/snk-filter-modal.entry.js +0 -33
  107. package/dist/esm/snk-form.entry.js +0 -129
  108. package/dist/esm/snk-grid.entry.js +0 -75
  109. package/dist/esm/snk-taskbar.entry.js +0 -156
  110. package/dist/esm/taskbar-processor-aa6772c9.js +0 -45
  111. package/dist/sankhyablocks/SnkMessageBuilder-35a20271.js +0 -199
  112. package/dist/sankhyablocks/app-globals-0f993ce5.js +0 -3
  113. package/dist/sankhyablocks/css-shim-b3f2ee8d.js +0 -4
  114. package/dist/sankhyablocks/dom-665d6011.js +0 -73
  115. package/dist/sankhyablocks/filter-item-type.enum-a79b2fa8.js +0 -14
  116. package/dist/sankhyablocks/index-5992b7e6.js +0 -139
  117. package/dist/sankhyablocks/index-c683b2b0.js +0 -2394
  118. package/dist/sankhyablocks/index-c71285cb.js +0 -17
  119. package/dist/sankhyablocks/shadow-css-b18e99d7.js +0 -387
  120. package/dist/sankhyablocks/snk-application.entry.js +0 -8166
  121. package/dist/sankhyablocks/snk-crud.entry.js +0 -66
  122. package/dist/sankhyablocks/snk-data-unit.entry.js +0 -268
  123. package/dist/sankhyablocks/snk-filter-bar.entry.js +0 -462
  124. package/dist/sankhyablocks/snk-filter-binary-select.entry.js +0 -43
  125. package/dist/sankhyablocks/snk-filter-detail.entry.js +0 -80
  126. package/dist/sankhyablocks/snk-filter-item.entry.js +0 -173
  127. package/dist/sankhyablocks/snk-filter-list.entry.js +0 -87
  128. package/dist/sankhyablocks/snk-filter-modal.entry.js +0 -33
  129. package/dist/sankhyablocks/snk-filter-multi-select.entry.js +0 -19
  130. package/dist/sankhyablocks/snk-filter-number.entry.js +0 -20
  131. package/dist/sankhyablocks/snk-filter-period.entry.js +0 -33
  132. package/dist/sankhyablocks/snk-filter-personalized.entry.js +0 -85
  133. package/dist/sankhyablocks/snk-filter-search.entry.js +0 -40
  134. package/dist/sankhyablocks/snk-filter-text.entry.js +0 -18
  135. package/dist/sankhyablocks/snk-grid.entry.js +0 -75
  136. package/dist/sankhyablocks/snk-pesquisa.entry.js +0 -311
  137. package/dist/sankhyablocks/snk-taskbar.entry.js +0 -156
  138. package/dist/sankhyablocks/taskbar-elements-35d64ff9.js +0 -90
  139. package/dist/sankhyablocks/taskbar-processor-aa6772c9.js +0 -45
  140. package/dist/sankhyablocks/teste-pesquisa.entry.js +0 -33
@@ -1,466 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const index$1 = require('./index-b0b676c5.js');
6
- const index = require('./index-e90ae303.js');
7
- const filterItemType_enum = require('./filter-item-type.enum-3daf58d3.js');
8
- const index$2 = require('./index-84fe3b86.js');
9
-
10
- const buildFilter = (item) => {
11
- switch (item.type) {
12
- case filterItemType_enum.FilterItemType.DEFAULT_FILTER:
13
- return buildDefault(item);
14
- case filterItemType_enum.FilterItemType.BINARY_SELECT:
15
- return buildBinary(item);
16
- case filterItemType_enum.FilterItemType.MULTI_SELECT:
17
- return buildMultSelect(item);
18
- case filterItemType_enum.FilterItemType.PERIOD:
19
- return buildPeriod(item);
20
- case filterItemType_enum.FilterItemType.SEARCH:
21
- return buildSearch(item);
22
- case filterItemType_enum.FilterItemType.TEXT:
23
- return buildText(item);
24
- case filterItemType_enum.FilterItemType.NUMBER:
25
- return buildNumber(item);
26
- case filterItemType_enum.FilterItemType.PERSONALIZED:
27
- return buildPersonalized(item);
28
- default:
29
- return undefined;
30
- }
31
- };
32
- function buildDefault(item) {
33
- return { name: item.id, expression: item.props.expression, params: [] };
34
- }
35
- function buildBinary(item) {
36
- const { id, value, props } = item;
37
- const options = props.options;
38
- const selectedOption = options.find(opt => opt.name === value);
39
- return { name: id, expression: selectedOption.expression, params: [] };
40
- }
41
- function buildMultSelect(item) {
42
- const { id, value, props } = item;
43
- return { name: id, expression: props.expression, params: [{ name: id, dataType: index.DataType.TEXT, value }] };
44
- }
45
- function buildPeriod(item) {
46
- const { id, value, props } = item;
47
- let { end, start } = value;
48
- if (typeof end === "string") {
49
- end = new Date(end);
50
- }
51
- if (typeof start === "string") {
52
- start = new Date(start);
53
- }
54
- const params = [];
55
- let expression;
56
- if (end && start) {
57
- expression = props.expression.fullfill;
58
- params.push({ name: `${id}.START`, dataType: index.DataType.DATE, value: index.toString(index.DataType.DATE, start) }, { name: `${id}.END`, dataType: index.DataType.DATE, value: index.toString(index.DataType.DATE, end) });
59
- }
60
- else {
61
- if (start) {
62
- expression = props.expression.onlystart;
63
- params.push({ name: id, dataType: index.DataType.DATE, value: index.toString(index.DataType.DATE, start) });
64
- }
65
- else {
66
- expression = props.expression.onlyend;
67
- params.push({ name: id, dataType: index.DataType.DATE, value: index.toString(index.DataType.DATE, end) });
68
- }
69
- }
70
- return { name: id, expression, params };
71
- }
72
- function buildSearch(item) {
73
- const { id, value, props } = item;
74
- const expression = props.expression;
75
- return { name: id, expression, params: [{ name: id, dataType: index.DataType.TEXT, value: index.toString(index.DataType.TEXT, value.value) }] };
76
- }
77
- function buildText(item) {
78
- const { id, value, props } = item;
79
- const expression = props.expression;
80
- return { name: id, expression, params: [{ name: id, dataType: index.DataType.TEXT, value: index.toString(index.DataType.TEXT, value) }] };
81
- }
82
- function buildNumber(item) {
83
- const { id, value, props } = item;
84
- const expression = props.expression;
85
- return { name: id, expression, params: [{ name: id, dataType: index.DataType.NUMBER, value: index.toString(index.DataType.NUMBER, value) }] };
86
- }
87
- function buildPersonalized(item) {
88
- var _a;
89
- const { id, value, props } = item;
90
- const expression = props.expression;
91
- return {
92
- name: id, expression, params: (((_a = props.personalizedFilter) === null || _a === void 0 ? void 0 : _a.parameters) || []).map((param, index$1) => {
93
- const valuesArray = Array.from(value);
94
- const dataType = param.dataType;
95
- let paramValue = (index$1 >= 0 && index$1 < valuesArray.length ? valuesArray[index$1] : null);
96
- if (paramValue != undefined && typeof paramValue === "object" && "value" in paramValue) {
97
- paramValue = paramValue["value"];
98
- }
99
- if (paramValue == undefined && dataType === index.DataType.BOOLEAN) {
100
- paramValue = false;
101
- }
102
- return { name: param.name, dataType, value: typeof paramValue === "string" ? paramValue : index.toString(dataType, paramValue) };
103
- })
104
- };
105
- }
106
-
107
- const snkFilterBarCss = ".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, 1);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;flex-grow:0}.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)}.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.preselected.sc-snk-filter-bar{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{display:flex;flex-direction:row;border-radius:var(--border--radius-medium, 12px);background-color:var(--background--medium, #f0f3f7)}.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);width:100%}.snk-filter-bar__filter-modal-content.sc-snk-filter-bar{display:grid;grid-template-rows:auto auto 1fr auto;width:100%;height:100%}";
108
-
109
- const PERSONALIZED_FILTER = "PERSONALIZED_FILTER";
110
- const DEFAULT_FILTER = "DEFAULT_FILTER";
111
- const CLEAR_ALL_FILTERS = "CLEAR_ALL_FILTERS";
112
- const SnkFilterBar = class {
113
- constructor(hostRef) {
114
- index$1.registerInstance(this, hostRef);
115
- this._updateSequence = [];
116
- this._loadingPending = false;
117
- this._configUpdated = false;
118
- this._pendingFilters = [];
119
- this._calculateSortIndex = (item) => {
120
- let index = item.hardFixed ? 1000000 : 0;
121
- //campos Hard Fixed não variam a ordem
122
- if (!item.hardFixed) {
123
- index += item.fixed ? 100000 : 0;
124
- index += item.value == undefined ? 0 : 10000;
125
- index += this._updateSequence.lastIndexOf(item.id) + 1;
126
- }
127
- return index;
128
- };
129
- this._filtersComparator = (a, b) => {
130
- return this._calculateSortIndex(b) - this._calculateSortIndex(a);
131
- };
132
- }
133
- observeFilterConfig(newValue, oldValue) {
134
- if (oldValue != undefined && newValue == undefined) {
135
- this._loadingPending = true;
136
- this._configUpdated = true;
137
- }
138
- else {
139
- const oldItems = new Map(oldValue ? oldValue.map(item => [item.id, item]) : undefined);
140
- newValue.forEach(newItem => {
141
- const oldItem = oldItems.get(newItem.id);
142
- if (oldItem != undefined) {
143
- this._configUpdated = this._configUpdated || index.ObjectUtils.objectToString(oldItem) != index.ObjectUtils.objectToString(newItem);
144
- this._loadingPending = this._loadingPending || index.ObjectUtils.objectToString(oldItem.value) !== index.ObjectUtils.objectToString(newItem.value);
145
- }
146
- else {
147
- this._configUpdated = true;
148
- this._loadingPending = this._loadingPending || newItem.value != undefined;
149
- }
150
- });
151
- }
152
- this.processAfterUpdateConfig();
153
- }
154
- processPendingFilter() {
155
- if (this._pendingFilters.length > 0 && this._currentPendingFilter == undefined) {
156
- this._currentPendingFilter = this._element.querySelector("#filter-" + this._pendingFilters.pop());
157
- if (this._currentPendingFilter) {
158
- this._currentPendingFilter.showUp(true).then(() => {
159
- this._currentPendingFilter = undefined;
160
- this.processPendingFilter();
161
- });
162
- }
163
- }
164
- if (this._currentPendingFilter == undefined) {
165
- this.processAfterUpdateConfig();
166
- }
167
- }
168
- processAfterUpdateConfig() {
169
- if (this._pendingFilters.length > 0) {
170
- return;
171
- }
172
- if (this._loadingPending) {
173
- this._loadingPending = false;
174
- this.dataUnit.loadData();
175
- }
176
- if (this._configUpdated) {
177
- this._configUpdated = false;
178
- this._application.saveFilterBarConfig(this.filterConfig, this.configName);
179
- }
180
- }
181
- /**
182
- * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
183
- * através de um pequeno modulo na estrutura da aplicação:
184
- * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
185
- * Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-filter-bar.msg.ts"
186
- */
187
- getMessage(key, params) {
188
- return this._application.messagesBuilder.getMessage(key, params);
189
- }
190
- getFilter(_dataUnit) {
191
- var _a;
192
- const filters = [];
193
- (_a = this.filterConfig) === null || _a === void 0 ? void 0 : _a.filter(item => this.isActiveFilter(item)).forEach(item => {
194
- const filter = buildFilter(item);
195
- if (filter) {
196
- filters.push(filter);
197
- }
198
- });
199
- return filters;
200
- }
201
- isActiveFilter(item) {
202
- return (item.visible && item.value != undefined) || item.type === filterItemType_enum.FilterItemType.DEFAULT_FILTER;
203
- }
204
- registryFilterProvider() {
205
- this.dataUnit.addFilterProvider(this);
206
- if (this.filterConfig) {
207
- this.dataUnit.loadData();
208
- }
209
- }
210
- getFilterItems() {
211
- const pinnedItems = [];
212
- const unpinnedItems = [];
213
- this.filterConfig
214
- .filter(item => item.visible)
215
- .forEach((item, index) => {
216
- const filterItem = (index$1.h("snk-filter-item", { id: `filter-${item.id}`, config: item, class: index > 0 ? "ez-padding-left--medium" : "", getMessage: (key, props) => this.getMessage(key, props), key: item.id }));
217
- if (item.fixed || item.hardFixed) {
218
- pinnedItems.push(filterItem);
219
- }
220
- else {
221
- unpinnedItems.push(filterItem);
222
- }
223
- return filterItem;
224
- });
225
- const elements = [];
226
- elements.push(...pinnedItems);
227
- if (pinnedItems.length > 0 && unpinnedItems.length > 0) {
228
- elements.push(index$1.h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-filter-bar__divider" }));
229
- }
230
- elements.push(...unpinnedItems);
231
- return elements;
232
- }
233
- calculateUpdateSequence(item) {
234
- if (item) {
235
- this._updateSequence = this._updateSequence.filter(itemId => item.id !== itemId);
236
- this._updateSequence.push(item.id);
237
- }
238
- }
239
- normalizeItem(item) {
240
- const normalized = Object.assign({}, item);
241
- const optionals = ["props", "value", "hardFixed", "fixed"];
242
- optionals.forEach(prop => {
243
- if (normalized[prop] == undefined) {
244
- delete normalized[prop];
245
- }
246
- });
247
- if (item.value === "") {
248
- delete item.value;
249
- }
250
- return normalized;
251
- }
252
- updateFilter(newItem) {
253
- this.filterConfig = this.filterConfig.map(item => {
254
- newItem = this.normalizeItem(newItem);
255
- if (item.id === newItem.id) {
256
- if (index.ObjectUtils.objectToString(item) != index.ObjectUtils.objectToString(newItem)) {
257
- this.calculateUpdateSequence(newItem);
258
- }
259
- return newItem;
260
- }
261
- return item;
262
- }).sort((a, b) => this._filtersComparator(a, b));
263
- }
264
- getAddListItems() {
265
- const hiddenItems = this.filterConfig
266
- .filter(item => !item.visible && this.isListable(item));
267
- const footerItems = [{ name: PERSONALIZED_FILTER, label: this.getMessage("snkFilterBar.customFilter"), iconName: "tune", kind: "FOOTER" }];
268
- if (this.allowDefault) {
269
- footerItems.push({ name: DEFAULT_FILTER, label: this.getMessage("snkFilterBar.defaultFilter"), iconName: "configuration", kind: "FOOTER" });
270
- }
271
- return hiddenItems.map(filter => { return { name: filter.id, label: filter.label, kind: "FILTER", iconName: null }; })
272
- .concat(footerItems);
273
- }
274
- getActiveClass() {
275
- const filterApplied = this.filterConfig.filter(item => item.value != undefined).length > 0;
276
- return filterApplied ? "sc-snk-filter-bar snk-filter-bar__filter-list-items-button--active" : "";
277
- }
278
- isListable(item, allowPersonalized = false) {
279
- return item.type !== filterItemType_enum.FilterItemType.DEFAULT_FILTER && (allowPersonalized || item.type !== filterItemType_enum.FilterItemType.PERSONALIZED);
280
- }
281
- getAppliedListItems() {
282
- const appliedItems = this.filterConfig
283
- .filter(item => this.isActiveFilter(item) && this.isListable(item, true));
284
- return appliedItems.map(filter => {
285
- return { name: filter.id, label: filter.label, kind: "FILTER", iconName: null };
286
- }).concat([
287
- { name: CLEAR_ALL_FILTERS, label: this.getMessage("snkFilterBar.clearAllFilters"), iconName: "cleaning", kind: "FOOTER" }
288
- ]);
289
- }
290
- addPersonalizedFilters(personalizedItems) {
291
- const activeFilters = {};
292
- personalizedItems.forEach(item => {
293
- if (item.active) {
294
- activeFilters[item.id] = true;
295
- }
296
- });
297
- this.filterConfig = this.filterConfig.map(item => {
298
- var _a, _b;
299
- if (item.type === filterItemType_enum.FilterItemType.PERSONALIZED) {
300
- const visible = activeFilters[item.id];
301
- if (!item.visible && visible) {
302
- this.calculateUpdateSequence(item);
303
- if (((_b = (_a = item.props) === null || _a === void 0 ? void 0 : _a.personalizedFilter) === null || _b === void 0 ? void 0 : _b.parameters) != undefined) {
304
- this._pendingFilters.push(item.id);
305
- }
306
- }
307
- return this.normalizeItem(visible ? Object.assign(Object.assign({}, item), { visible }) : Object.assign(Object.assign({}, item), { visible, value: undefined, fixed: undefined }));
308
- }
309
- return item;
310
- }).sort((a, b) => this._filtersComparator(a, b));
311
- }
312
- openDefaultFilterModal() {
313
- const filterModal = document.createElement("snk-filter-modal");
314
- const defaultFilter = this.filterConfig.filter(item => item.type === filterItemType_enum.FilterItemType.DEFAULT_FILTER);
315
- filterModal.getMessage = (key, props) => this.getMessage(key, props);
316
- filterModal.modalTitle = this.getMessage("snkFilterBar.modalDefaultFilterTitle");
317
- filterModal.infoText = this.getMessage(defaultFilter.length == 0 ? "snkFilterBar.modalInfoTextCreateDefault" : "snkFilterBar.modalInfoTextEditDefault");
318
- filterModal.items = defaultFilter.map(item => {
319
- return { id: item.id, active: true, enabled: false, label: item.label };
320
- });
321
- filterModal.processModalAction = (_action) => {
322
- this._application.closeModal();
323
- };
324
- this._application.showModal(filterModal);
325
- }
326
- openPersonalizedModal() {
327
- const filterModal = document.createElement("snk-filter-modal");
328
- const personalizedFilter = this.filterConfig
329
- .filter(item => item.type === filterItemType_enum.FilterItemType.PERSONALIZED)
330
- .sort((itemA, itemB) => index.StringUtils.compare(itemA.label, itemB.label));
331
- filterModal.getMessage = (key, props) => this.getMessage(key, props);
332
- filterModal.modalTitle = this.getMessage("snkFilterBar.modalPersonalizedFilterTitle");
333
- filterModal.modalSubTitle = this.getMessage("snkFilterBar.modalPersonalizedFilterSubTitle");
334
- filterModal.okButtonLabel = this.getMessage("snkFilterBar.modalOkButtonLabel");
335
- filterModal.cancelButtonLabel = this.getMessage("snkFilterBar.modalCancelButtonLabel");
336
- filterModal.infoText = this.getMessage("snkFilterBar.modalInfoTextCreateEditPersonalized");
337
- filterModal.useSearch = true;
338
- filterModal.items = personalizedFilter.map(item => {
339
- return { id: item.id, active: item.visible, enabled: true, label: item.label };
340
- });
341
- filterModal.processModalAction = (action) => {
342
- if (action === index$2.ModalAction.CANCEL) {
343
- // O Botão de cancelar, tem efeito específico:
344
- // - Desmarcar todos os filtros personalizados.
345
- filterModal.items = filterModal.items.map(item => {
346
- return Object.assign(Object.assign({}, item), { active: false });
347
- });
348
- }
349
- else {
350
- if (action === index$2.ModalAction.OK) {
351
- this.addPersonalizedFilters(filterModal.items);
352
- }
353
- this._application.closeModal();
354
- }
355
- };
356
- this._application.showModal(filterModal);
357
- }
358
- clearFilters() {
359
- let changed = false;
360
- this.filterConfig = this.filterConfig.map(item => {
361
- if (item.value != undefined) {
362
- changed = true;
363
- }
364
- return Object.assign(Object.assign({}, item), { value: undefined });
365
- }).sort((a, b) => this._filtersComparator(a, b));
366
- return changed;
367
- }
368
- loadPermitions() {
369
- this._application.isUserSup().then(value => this.allowDefault = value);
370
- }
371
- loadConfigFromApplication() {
372
- this._application.getFilterBarConfig(this.configName)
373
- .then((filters) => {
374
- this.filterConfig = filters.map(item => this.normalizeItem(item));
375
- if (this.dataUnit) {
376
- this.dataUnit.loadData();
377
- }
378
- })
379
- .catch(reason => {
380
- throw new index.ErrorException(this.getMessage("snkFilterBar.failToLoadConfig"), reason);
381
- });
382
- }
383
- attachDataUnit() {
384
- if (this.dataUnit == undefined) {
385
- let parent = this._element.parentElement;
386
- while (parent) {
387
- if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
388
- const snkDataUnit = parent;
389
- this.dataUnit = snkDataUnit.dataUnit;
390
- if (this.dataUnit) {
391
- this.registryFilterProvider();
392
- }
393
- else {
394
- snkDataUnit.addEventListener("dataUnitReady", (evt) => {
395
- this.dataUnit = evt.detail;
396
- this.registryFilterProvider();
397
- });
398
- }
399
- break;
400
- }
401
- }
402
- parent = parent.parentElement;
403
- }
404
- else {
405
- this.registryFilterProvider();
406
- }
407
- }
408
- filterChangeListener(evt) {
409
- this.updateFilter(evt.detail);
410
- }
411
- addFilterHandler(itemName) {
412
- const filterItem = this.filterConfig.find(currentFilter => currentFilter.id === itemName);
413
- if (itemName === PERSONALIZED_FILTER) {
414
- this.openPersonalizedModal();
415
- }
416
- else if (itemName === DEFAULT_FILTER) {
417
- this.openDefaultFilterModal();
418
- }
419
- else if (filterItem) {
420
- this.updateFilter(Object.assign(Object.assign({}, filterItem), { visible: true }));
421
- window.requestAnimationFrame(() => {
422
- const filterItemElement = this._element.querySelector("#filter-" + itemName);
423
- if (filterItemElement) {
424
- filterItemElement.showUp();
425
- }
426
- });
427
- }
428
- }
429
- appliedFilterHandler(itemName) {
430
- if (itemName === CLEAR_ALL_FILTERS) {
431
- if (this.clearFilters()) {
432
- this._application.info(this.getMessage("snkFilterBar.successfullyCleaned"), { iconName: "check" });
433
- }
434
- }
435
- else {
436
- const filterItemElement = this._element.querySelector("#filter-" + itemName);
437
- if (filterItemElement) {
438
- filterItemElement.showUp(true);
439
- }
440
- }
441
- }
442
- componentWillLoad() {
443
- this._application = index.ApplicationContext.getContextValue("__SNK__APPLICATION__");
444
- if (this._application) {
445
- this.loadPermitions();
446
- this.loadConfigFromApplication();
447
- }
448
- this.attachDataUnit();
449
- }
450
- componentDidRender() {
451
- this.processPendingFilter();
452
- }
453
- render() {
454
- if (!this.dataUnit || !this.filterConfig || this.filterConfig.length === 0) {
455
- return undefined;
456
- }
457
- return (index$1.h(index$1.Host, null, index$1.h("ez-scroller", { direction: "horizontal" }, this.getFilterItems()), index$1.h("snk-filter-list", { items: this.getAppliedListItems(), getMessage: (key, params) => this.getMessage(key, params), emptyText: this.getMessage("snkFilterBar.emptyAppliedFiltersList"), findFilterText: this.getMessage("snkFilterBar.findFilter"), iconName: "filter", class: "ez-padding-left--medium", buttonClass: this.getActiveClass(), onSnkItemSelected: evt => this.appliedFilterHandler(evt.detail) }), index$1.h("snk-filter-list", { items: this.getAddListItems(), label: this.getMessage("snkFilterBar.addFilter"), getMessage: (key, params) => this.getMessage(key, params), emptyText: this.getMessage("snkFilterBar.emptyFiltersList"), findFilterText: this.getMessage("snkFilterBar.findField"), class: "ez-padding-left--medium", onSnkItemSelected: evt => this.addFilterHandler(evt.detail) }, index$1.h("ez-icon", { slot: "leftIcon", class: "ez-padding-right--small", iconName: "plus" }))));
458
- }
459
- get _element() { return index$1.getElement(this); }
460
- static get watchers() { return {
461
- "filterConfig": ["observeFilterConfig"]
462
- }; }
463
- };
464
- SnkFilterBar.style = snkFilterBarCss;
465
-
466
- exports.snk_filter_bar = SnkFilterBar;
@@ -1,177 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const index = require('./index-b0b676c5.js');
6
- const index$1 = require('./index-e90ae303.js');
7
- const filterItemType_enum = require('./filter-item-type.enum-3daf58d3.js');
8
-
9
- const SnkFilterItem = class {
10
- constructor(hostRef) {
11
- index.registerInstance(this, hostRef);
12
- this.filterChange = index.createEvent(this, "filterChange", 7);
13
- this.innerClickCheck = (floatingContainer, node) => {
14
- if (this._popover.keepOpened) {
15
- return true;
16
- }
17
- if (node && floatingContainer) {
18
- if (!node.offsetParent) {
19
- return true;
20
- }
21
- let current = node;
22
- do {
23
- if (current === floatingContainer) {
24
- return true;
25
- }
26
- } while ((current = current.offsetParent) != null);
27
- }
28
- this.detailIsVisible = false;
29
- this.executeCloseCallback();
30
- return false;
31
- };
32
- }
33
- async showUp(open = false) {
34
- return new Promise(resolve => {
35
- this._filterItemElement.scrollIntoView({ behavior: "auto", block: "nearest", inline: "nearest" });
36
- if (open) {
37
- window.requestAnimationFrame(() => {
38
- this._closeCallback = resolve;
39
- this.showDetail();
40
- });
41
- }
42
- });
43
- }
44
- showDetail() {
45
- this._floatingID = index$1.FloatingManager.float(this._popover, this._popoverContainer, { autoClose: true, innerClickTest: this.innerClickCheck, left: this.getScrollOffset() });
46
- this.detailIsVisible = true;
47
- }
48
- getScrollOffset() {
49
- return `${this._filterItemElement.getBoundingClientRect().left + 12}px`;
50
- }
51
- hideDetail() {
52
- if (this._floatingID != undefined) {
53
- index$1.FloatingManager.close(this._floatingID);
54
- }
55
- this._floatingID = undefined;
56
- this.detailIsVisible = false;
57
- this.executeCloseCallback();
58
- }
59
- executeCloseCallback() {
60
- if (this._closeCallback) {
61
- this._closeCallback();
62
- this._closeCallback = undefined;
63
- }
64
- }
65
- //---------------------------------------------
66
- // Event handlers
67
- //---------------------------------------------
68
- clickListener(evt) {
69
- if ([this._chipElement, this._leftIconElement, this._rightIconElement].includes(evt.target)) {
70
- if (evt.target === this._rightIconElement && this.config.value != undefined) {
71
- this.filterChange.emit(Object.assign(Object.assign({}, this.config), { value: undefined }));
72
- }
73
- else {
74
- if (this.detailIsVisible) {
75
- this.hideDetail();
76
- }
77
- else {
78
- this.showDetail();
79
- }
80
- }
81
- evt.preventDefault();
82
- evt.stopImmediatePropagation();
83
- evt.stopPropagation();
84
- }
85
- }
86
- mouseDownListener(evt) {
87
- if (this.detailIsVisible && [this._chipElement, this._leftIconElement, this._rightIconElement].includes(evt.target)) {
88
- evt.preventDefault();
89
- evt.stopImmediatePropagation();
90
- evt.stopPropagation();
91
- }
92
- }
93
- getLabel() {
94
- const { type, value, label, props } = this.config;
95
- if (value) {
96
- if (type === filterItemType_enum.FilterItemType.BINARY_SELECT) {
97
- const [optOne, optTwo] = props.options;
98
- if (optOne.name === value) {
99
- return optOne.label;
100
- }
101
- if (optTwo.name === value) {
102
- return optTwo.label;
103
- }
104
- }
105
- if (type === filterItemType_enum.FilterItemType.MULTI_SELECT) {
106
- const opt = props.options.find(opt => opt.value === value);
107
- return `${label}: ${opt.label}`;
108
- }
109
- if (type === filterItemType_enum.FilterItemType.PERIOD) {
110
- let { end, start } = value;
111
- if (typeof end === "string") {
112
- end = new Date(end);
113
- end.setMinutes(end.getMinutes() + end.getTimezoneOffset());
114
- }
115
- if (typeof start === "string") {
116
- start = new Date(start);
117
- start.setMinutes(start.getMinutes() + start.getTimezoneOffset());
118
- }
119
- const dateFormater = new Intl.DateTimeFormat("pt-BR");
120
- if (end && start) {
121
- return `${label}: ${dateFormater.format(start)} a ${dateFormater.format(end)}`;
122
- }
123
- else {
124
- if (start) {
125
- return `${label}: A partir de ${dateFormater.format(start)}`;
126
- }
127
- else if (end) {
128
- return `${label}: Até ${dateFormater.format(end)}`;
129
- }
130
- else {
131
- return label;
132
- }
133
- }
134
- }
135
- if (type === filterItemType_enum.FilterItemType.SEARCH) {
136
- return `${label}: ${value.value} - ${value.label}`;
137
- }
138
- if (type === filterItemType_enum.FilterItemType.PERSONALIZED) {
139
- return label;
140
- }
141
- return `${label}: ${value}`;
142
- }
143
- return label;
144
- }
145
- componentDidRender() {
146
- if (this._floatingID == undefined) {
147
- if (this._popover) {
148
- this._popover.remove();
149
- }
150
- }
151
- }
152
- filterChangeListener() {
153
- this.hideDetail();
154
- }
155
- getRightIconName() {
156
- if (this.config.value != undefined) {
157
- return "close";
158
- }
159
- return this.detailIsVisible ? "chevron-up" : "chevron-down";
160
- }
161
- getLeftIconName() {
162
- switch (this.config.type) {
163
- case filterItemType_enum.FilterItemType.PERIOD:
164
- return "calendar";
165
- case filterItemType_enum.FilterItemType.PERSONALIZED:
166
- return "tune";
167
- }
168
- return undefined;
169
- }
170
- render() {
171
- const leftIcon = this.getLeftIconName();
172
- return (index.h(index.Host, null, index.h("ez-chip", { ref: ref => this._chipElement = ref, label: this.getLabel(), value: this.config.value != undefined }, leftIcon ? index.h("ez-icon", { ref: ref => this._leftIconElement = ref, iconName: leftIcon, class: "ez-padding-right--small", slot: "leftIcon" }) : undefined, index.h("ez-icon", { ref: ref => this._rightIconElement = ref, iconName: this.getRightIconName(), class: "ez-padding-left--small", slot: "rightIcon" })), index.h("section", { class: "ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container", ref: elem => this._popoverContainer = elem }, index.h("snk-filter-detail", { config: this.config, getMessage: this.getMessage, class: "sc-snk-filter-bar snk-filter__popover ez-padding--small", ref: elem => this._popover = elem, key: this.config.id }))));
173
- }
174
- get _filterItemElement() { return index.getElement(this); }
175
- };
176
-
177
- exports.snk_filter_item = SnkFilterItem;