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

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 (152) 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 +53 -217
  5. package/dist/cjs/snk-crud.cjs.entry.js +9 -3
  6. package/dist/cjs/snk-data-unit.cjs.entry.js +23 -23
  7. package/dist/cjs/snk-filter-bar_5.cjs.entry.js +883 -0
  8. package/dist/cjs/snk-filter-binary-select.cjs.entry.js +1 -1
  9. package/dist/cjs/snk-filter-detail.cjs.entry.js +32 -21
  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 -31
  14. package/dist/cjs/snk-filter-search.cjs.entry.js +3 -12
  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/collection/components/snk-crud/snk-crud.js +29 -0
  21. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-personalized.js +0 -39
  22. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-search.js +0 -39
  23. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +30 -36
  24. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +3 -14
  25. package/dist/collection/components/snk-filter-bar/filter-list/snk-filter-list.js +4 -12
  26. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +3 -3
  27. package/dist/components/index.js +0 -4
  28. package/dist/components/snk-application2.js +13 -177
  29. package/dist/components/snk-crud.js +9 -2
  30. package/dist/components/snk-data-unit.js +2 -2
  31. package/dist/components/snk-filter-bar2.js +4 -2
  32. package/dist/components/snk-filter-detail2.js +31 -21
  33. package/dist/components/snk-filter-item2.js +4 -15
  34. package/dist/components/snk-filter-list2.js +5 -13
  35. package/dist/components/snk-filter-modal2.js +4 -19
  36. package/dist/components/snk-filter-personalized.js +3 -13
  37. package/dist/components/snk-filter-search.js +2 -13
  38. package/dist/components/snk-form2.js +1 -1
  39. package/dist/components/snk-grid2.js +1 -1
  40. package/dist/components/snk-pesquisa2.js +1 -1
  41. package/dist/components/snk-taskbar2.js +1 -1
  42. package/dist/components/teste-pesquisa.js +1 -1
  43. package/dist/{sankhyablocks/index-2b4d2d14.js → esm/index-81dda3cf.js} +160 -1508
  44. package/dist/esm/loader.js +2 -18
  45. package/dist/esm/sankhyablocks.js +4 -116
  46. package/dist/esm/snk-application.entry.js +14 -178
  47. package/dist/esm/snk-crud.entry.js +8 -2
  48. package/dist/esm/snk-data-unit.entry.js +3 -3
  49. package/dist/esm/{snk-filter-bar.entry.js → snk-filter-bar_5.entry.js} +417 -4
  50. package/dist/esm/snk-filter-binary-select.entry.js +1 -1
  51. package/dist/esm/snk-filter-detail.entry.js +32 -21
  52. package/dist/esm/snk-filter-multi-select.entry.js +1 -1
  53. package/dist/esm/snk-filter-number.entry.js +1 -1
  54. package/dist/esm/snk-filter-period.entry.js +1 -1
  55. package/dist/esm/snk-filter-personalized.entry.js +3 -11
  56. package/dist/esm/snk-filter-search.entry.js +2 -11
  57. package/dist/esm/snk-filter-text.entry.js +1 -1
  58. package/dist/{sankhyablocks/snk-form.entry.js → esm/snk-form_2.entry.js} +117 -4
  59. package/dist/esm/snk-pesquisa.entry.js +2 -2
  60. package/dist/esm/{taskbar-elements-35d64ff9.js → taskbar-elements-38eb5d51.js} +1 -1
  61. package/dist/esm/teste-pesquisa.entry.js +2 -2
  62. package/dist/sankhyablocks/index.esm.js +0 -1
  63. package/dist/sankhyablocks/p-01823784.entry.js +1 -0
  64. package/dist/sankhyablocks/p-0352c0e2.entry.js +1 -0
  65. package/dist/sankhyablocks/p-07ebda01.entry.js +1 -0
  66. package/dist/sankhyablocks/p-46caa101.entry.js +1 -0
  67. package/dist/sankhyablocks/p-586e2522.js +1 -0
  68. package/dist/sankhyablocks/p-6f8303f3.entry.js +1 -0
  69. package/dist/sankhyablocks/p-746fc78b.entry.js +1 -0
  70. package/dist/sankhyablocks/p-77216252.entry.js +1 -0
  71. package/dist/sankhyablocks/p-86f15ffe.js +1 -0
  72. package/dist/sankhyablocks/p-8bbc0cbb.entry.js +74 -0
  73. package/dist/sankhyablocks/p-8f3c5709.entry.js +1 -0
  74. package/dist/sankhyablocks/p-97009a2c.entry.js +1 -0
  75. package/dist/sankhyablocks/p-9dd2b8cb.js +1 -0
  76. package/dist/sankhyablocks/p-aecf3e0a.entry.js +1 -0
  77. package/dist/sankhyablocks/p-c1c3b5d8.entry.js +1 -0
  78. package/dist/sankhyablocks/p-c9eec639.entry.js +1 -0
  79. package/dist/sankhyablocks/p-eea6444c.entry.js +1 -0
  80. package/dist/sankhyablocks/p-fac2b6a9.js +2 -0
  81. package/dist/sankhyablocks/p-fb705f81.entry.js +1 -0
  82. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -129
  83. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-personalized.d.ts +0 -2
  84. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-search.d.ts +0 -2
  85. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +1 -1
  86. package/dist/types/components/snk-filter-bar/filter-list/snk-filter-list.d.ts +1 -1
  87. package/dist/types/components.d.ts +4 -10
  88. package/package.json +1 -1
  89. package/react/components.d.ts +19 -0
  90. package/react/components.js +19 -0
  91. package/react/components.js.map +1 -1
  92. package/dist/cjs/app-globals-3a1e7e63.js +0 -5
  93. package/dist/cjs/css-shim-b8158822.js +0 -6
  94. package/dist/cjs/dom-36862b77.js +0 -75
  95. package/dist/cjs/index-84fe3b86.js +0 -20
  96. package/dist/cjs/index-93965c41.js +0 -141
  97. package/dist/cjs/index-e90ae303.js +0 -2408
  98. package/dist/cjs/shadow-css-346c0795.js +0 -389
  99. package/dist/cjs/snk-filter-bar.cjs.entry.js +0 -466
  100. package/dist/cjs/snk-filter-item.cjs.entry.js +0 -177
  101. package/dist/cjs/snk-filter-list.cjs.entry.js +0 -91
  102. package/dist/cjs/snk-filter-modal.cjs.entry.js +0 -37
  103. package/dist/cjs/snk-grid.cjs.entry.js +0 -79
  104. package/dist/cjs/snk-taskbar.cjs.entry.js +0 -160
  105. package/dist/cjs/taskbar-processor-6bd0d35c.js +0 -47
  106. package/dist/components/index2.js +0 -2394
  107. package/dist/components/index3.js +0 -139
  108. package/dist/esm/app-globals-0f993ce5.js +0 -3
  109. package/dist/esm/css-shim-b3f2ee8d.js +0 -4
  110. package/dist/esm/dom-665d6011.js +0 -73
  111. package/dist/esm/index-2b4d2d14.js +0 -3262
  112. package/dist/esm/index-5992b7e6.js +0 -139
  113. package/dist/esm/index-c683b2b0.js +0 -2394
  114. package/dist/esm/index-c71285cb.js +0 -17
  115. package/dist/esm/shadow-css-b18e99d7.js +0 -387
  116. package/dist/esm/snk-filter-item.entry.js +0 -173
  117. package/dist/esm/snk-filter-list.entry.js +0 -87
  118. package/dist/esm/snk-filter-modal.entry.js +0 -33
  119. package/dist/esm/snk-form.entry.js +0 -129
  120. package/dist/esm/snk-grid.entry.js +0 -75
  121. package/dist/esm/snk-taskbar.entry.js +0 -156
  122. package/dist/esm/taskbar-processor-aa6772c9.js +0 -45
  123. package/dist/sankhyablocks/SnkMessageBuilder-35a20271.js +0 -199
  124. package/dist/sankhyablocks/app-globals-0f993ce5.js +0 -3
  125. package/dist/sankhyablocks/css-shim-b3f2ee8d.js +0 -4
  126. package/dist/sankhyablocks/dom-665d6011.js +0 -73
  127. package/dist/sankhyablocks/filter-item-type.enum-a79b2fa8.js +0 -14
  128. package/dist/sankhyablocks/index-5992b7e6.js +0 -139
  129. package/dist/sankhyablocks/index-c683b2b0.js +0 -2394
  130. package/dist/sankhyablocks/index-c71285cb.js +0 -17
  131. package/dist/sankhyablocks/shadow-css-b18e99d7.js +0 -387
  132. package/dist/sankhyablocks/snk-application.entry.js +0 -8166
  133. package/dist/sankhyablocks/snk-crud.entry.js +0 -66
  134. package/dist/sankhyablocks/snk-data-unit.entry.js +0 -268
  135. package/dist/sankhyablocks/snk-filter-bar.entry.js +0 -462
  136. package/dist/sankhyablocks/snk-filter-binary-select.entry.js +0 -43
  137. package/dist/sankhyablocks/snk-filter-detail.entry.js +0 -80
  138. package/dist/sankhyablocks/snk-filter-item.entry.js +0 -173
  139. package/dist/sankhyablocks/snk-filter-list.entry.js +0 -87
  140. package/dist/sankhyablocks/snk-filter-modal.entry.js +0 -33
  141. package/dist/sankhyablocks/snk-filter-multi-select.entry.js +0 -19
  142. package/dist/sankhyablocks/snk-filter-number.entry.js +0 -20
  143. package/dist/sankhyablocks/snk-filter-period.entry.js +0 -33
  144. package/dist/sankhyablocks/snk-filter-personalized.entry.js +0 -85
  145. package/dist/sankhyablocks/snk-filter-search.entry.js +0 -40
  146. package/dist/sankhyablocks/snk-filter-text.entry.js +0 -18
  147. package/dist/sankhyablocks/snk-grid.entry.js +0 -75
  148. package/dist/sankhyablocks/snk-pesquisa.entry.js +0 -311
  149. package/dist/sankhyablocks/snk-taskbar.entry.js +0 -156
  150. package/dist/sankhyablocks/taskbar-elements-35d64ff9.js +0 -90
  151. package/dist/sankhyablocks/taskbar-processor-aa6772c9.js +0 -45
  152. package/dist/sankhyablocks/teste-pesquisa.entry.js +0 -33
@@ -1,462 +0,0 @@
1
- import { r as registerInstance, h, f as Host, g as getElement } from './index-2b4d2d14.js';
2
- import { t as toString, b as DataType, O as ObjectUtils, S as StringUtils, E as ErrorException, A as ApplicationContext } from './index-c683b2b0.js';
3
- import { F as FilterItemType } from './filter-item-type.enum-a79b2fa8.js';
4
- import { M as ModalAction } from './index-c71285cb.js';
5
-
6
- const buildFilter = (item) => {
7
- switch (item.type) {
8
- case FilterItemType.DEFAULT_FILTER:
9
- return buildDefault(item);
10
- case FilterItemType.BINARY_SELECT:
11
- return buildBinary(item);
12
- case FilterItemType.MULTI_SELECT:
13
- return buildMultSelect(item);
14
- case FilterItemType.PERIOD:
15
- return buildPeriod(item);
16
- case FilterItemType.SEARCH:
17
- return buildSearch(item);
18
- case FilterItemType.TEXT:
19
- return buildText(item);
20
- case FilterItemType.NUMBER:
21
- return buildNumber(item);
22
- case FilterItemType.PERSONALIZED:
23
- return buildPersonalized(item);
24
- default:
25
- return undefined;
26
- }
27
- };
28
- function buildDefault(item) {
29
- return { name: item.id, expression: item.props.expression, params: [] };
30
- }
31
- function buildBinary(item) {
32
- const { id, value, props } = item;
33
- const options = props.options;
34
- const selectedOption = options.find(opt => opt.name === value);
35
- return { name: id, expression: selectedOption.expression, params: [] };
36
- }
37
- function buildMultSelect(item) {
38
- const { id, value, props } = item;
39
- return { name: id, expression: props.expression, params: [{ name: id, dataType: DataType.TEXT, value }] };
40
- }
41
- function buildPeriod(item) {
42
- const { id, value, props } = item;
43
- let { end, start } = value;
44
- if (typeof end === "string") {
45
- end = new Date(end);
46
- }
47
- if (typeof start === "string") {
48
- start = new Date(start);
49
- }
50
- const params = [];
51
- let expression;
52
- if (end && start) {
53
- expression = props.expression.fullfill;
54
- params.push({ name: `${id}.START`, dataType: DataType.DATE, value: toString(DataType.DATE, start) }, { name: `${id}.END`, dataType: DataType.DATE, value: toString(DataType.DATE, end) });
55
- }
56
- else {
57
- if (start) {
58
- expression = props.expression.onlystart;
59
- params.push({ name: id, dataType: DataType.DATE, value: toString(DataType.DATE, start) });
60
- }
61
- else {
62
- expression = props.expression.onlyend;
63
- params.push({ name: id, dataType: DataType.DATE, value: toString(DataType.DATE, end) });
64
- }
65
- }
66
- return { name: id, expression, params };
67
- }
68
- function buildSearch(item) {
69
- const { id, value, props } = item;
70
- const expression = props.expression;
71
- return { name: id, expression, params: [{ name: id, dataType: DataType.TEXT, value: toString(DataType.TEXT, value.value) }] };
72
- }
73
- function buildText(item) {
74
- const { id, value, props } = item;
75
- const expression = props.expression;
76
- return { name: id, expression, params: [{ name: id, dataType: DataType.TEXT, value: toString(DataType.TEXT, value) }] };
77
- }
78
- function buildNumber(item) {
79
- const { id, value, props } = item;
80
- const expression = props.expression;
81
- return { name: id, expression, params: [{ name: id, dataType: DataType.NUMBER, value: toString(DataType.NUMBER, value) }] };
82
- }
83
- function buildPersonalized(item) {
84
- var _a;
85
- const { id, value, props } = item;
86
- const expression = props.expression;
87
- return {
88
- name: id, expression, params: (((_a = props.personalizedFilter) === null || _a === void 0 ? void 0 : _a.parameters) || []).map((param, index) => {
89
- const valuesArray = Array.from(value);
90
- const dataType = param.dataType;
91
- let paramValue = (index >= 0 && index < valuesArray.length ? valuesArray[index] : null);
92
- if (paramValue != undefined && typeof paramValue === "object" && "value" in paramValue) {
93
- paramValue = paramValue["value"];
94
- }
95
- if (paramValue == undefined && dataType === DataType.BOOLEAN) {
96
- paramValue = false;
97
- }
98
- return { name: param.name, dataType, value: typeof paramValue === "string" ? paramValue : toString(dataType, paramValue) };
99
- })
100
- };
101
- }
102
-
103
- 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%}";
104
-
105
- const PERSONALIZED_FILTER = "PERSONALIZED_FILTER";
106
- const DEFAULT_FILTER = "DEFAULT_FILTER";
107
- const CLEAR_ALL_FILTERS = "CLEAR_ALL_FILTERS";
108
- const SnkFilterBar = class {
109
- constructor(hostRef) {
110
- registerInstance(this, hostRef);
111
- this._updateSequence = [];
112
- this._loadingPending = false;
113
- this._configUpdated = false;
114
- this._pendingFilters = [];
115
- this._calculateSortIndex = (item) => {
116
- let index = item.hardFixed ? 1000000 : 0;
117
- //campos Hard Fixed não variam a ordem
118
- if (!item.hardFixed) {
119
- index += item.fixed ? 100000 : 0;
120
- index += item.value == undefined ? 0 : 10000;
121
- index += this._updateSequence.lastIndexOf(item.id) + 1;
122
- }
123
- return index;
124
- };
125
- this._filtersComparator = (a, b) => {
126
- return this._calculateSortIndex(b) - this._calculateSortIndex(a);
127
- };
128
- }
129
- observeFilterConfig(newValue, oldValue) {
130
- if (oldValue != undefined && newValue == undefined) {
131
- this._loadingPending = true;
132
- this._configUpdated = true;
133
- }
134
- else {
135
- const oldItems = new Map(oldValue ? oldValue.map(item => [item.id, item]) : undefined);
136
- newValue.forEach(newItem => {
137
- const oldItem = oldItems.get(newItem.id);
138
- if (oldItem != undefined) {
139
- this._configUpdated = this._configUpdated || ObjectUtils.objectToString(oldItem) != ObjectUtils.objectToString(newItem);
140
- this._loadingPending = this._loadingPending || ObjectUtils.objectToString(oldItem.value) !== ObjectUtils.objectToString(newItem.value);
141
- }
142
- else {
143
- this._configUpdated = true;
144
- this._loadingPending = this._loadingPending || newItem.value != undefined;
145
- }
146
- });
147
- }
148
- this.processAfterUpdateConfig();
149
- }
150
- processPendingFilter() {
151
- if (this._pendingFilters.length > 0 && this._currentPendingFilter == undefined) {
152
- this._currentPendingFilter = this._element.querySelector("#filter-" + this._pendingFilters.pop());
153
- if (this._currentPendingFilter) {
154
- this._currentPendingFilter.showUp(true).then(() => {
155
- this._currentPendingFilter = undefined;
156
- this.processPendingFilter();
157
- });
158
- }
159
- }
160
- if (this._currentPendingFilter == undefined) {
161
- this.processAfterUpdateConfig();
162
- }
163
- }
164
- processAfterUpdateConfig() {
165
- if (this._pendingFilters.length > 0) {
166
- return;
167
- }
168
- if (this._loadingPending) {
169
- this._loadingPending = false;
170
- this.dataUnit.loadData();
171
- }
172
- if (this._configUpdated) {
173
- this._configUpdated = false;
174
- this._application.saveFilterBarConfig(this.filterConfig, this.configName);
175
- }
176
- }
177
- /**
178
- * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
179
- * através de um pequeno modulo na estrutura da aplicação:
180
- * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
181
- * Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-filter-bar.msg.ts"
182
- */
183
- getMessage(key, params) {
184
- return this._application.messagesBuilder.getMessage(key, params);
185
- }
186
- getFilter(_dataUnit) {
187
- var _a;
188
- const filters = [];
189
- (_a = this.filterConfig) === null || _a === void 0 ? void 0 : _a.filter(item => this.isActiveFilter(item)).forEach(item => {
190
- const filter = buildFilter(item);
191
- if (filter) {
192
- filters.push(filter);
193
- }
194
- });
195
- return filters;
196
- }
197
- isActiveFilter(item) {
198
- return (item.visible && item.value != undefined) || item.type === FilterItemType.DEFAULT_FILTER;
199
- }
200
- registryFilterProvider() {
201
- this.dataUnit.addFilterProvider(this);
202
- if (this.filterConfig) {
203
- this.dataUnit.loadData();
204
- }
205
- }
206
- getFilterItems() {
207
- const pinnedItems = [];
208
- const unpinnedItems = [];
209
- this.filterConfig
210
- .filter(item => item.visible)
211
- .forEach((item, index) => {
212
- const filterItem = (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 }));
213
- if (item.fixed || item.hardFixed) {
214
- pinnedItems.push(filterItem);
215
- }
216
- else {
217
- unpinnedItems.push(filterItem);
218
- }
219
- return filterItem;
220
- });
221
- const elements = [];
222
- elements.push(...pinnedItems);
223
- if (pinnedItems.length > 0 && unpinnedItems.length > 0) {
224
- elements.push(h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-filter-bar__divider" }));
225
- }
226
- elements.push(...unpinnedItems);
227
- return elements;
228
- }
229
- calculateUpdateSequence(item) {
230
- if (item) {
231
- this._updateSequence = this._updateSequence.filter(itemId => item.id !== itemId);
232
- this._updateSequence.push(item.id);
233
- }
234
- }
235
- normalizeItem(item) {
236
- const normalized = Object.assign({}, item);
237
- const optionals = ["props", "value", "hardFixed", "fixed"];
238
- optionals.forEach(prop => {
239
- if (normalized[prop] == undefined) {
240
- delete normalized[prop];
241
- }
242
- });
243
- if (item.value === "") {
244
- delete item.value;
245
- }
246
- return normalized;
247
- }
248
- updateFilter(newItem) {
249
- this.filterConfig = this.filterConfig.map(item => {
250
- newItem = this.normalizeItem(newItem);
251
- if (item.id === newItem.id) {
252
- if (ObjectUtils.objectToString(item) != ObjectUtils.objectToString(newItem)) {
253
- this.calculateUpdateSequence(newItem);
254
- }
255
- return newItem;
256
- }
257
- return item;
258
- }).sort((a, b) => this._filtersComparator(a, b));
259
- }
260
- getAddListItems() {
261
- const hiddenItems = this.filterConfig
262
- .filter(item => !item.visible && this.isListable(item));
263
- const footerItems = [{ name: PERSONALIZED_FILTER, label: this.getMessage("snkFilterBar.customFilter"), iconName: "tune", kind: "FOOTER" }];
264
- if (this.allowDefault) {
265
- footerItems.push({ name: DEFAULT_FILTER, label: this.getMessage("snkFilterBar.defaultFilter"), iconName: "configuration", kind: "FOOTER" });
266
- }
267
- return hiddenItems.map(filter => { return { name: filter.id, label: filter.label, kind: "FILTER", iconName: null }; })
268
- .concat(footerItems);
269
- }
270
- getActiveClass() {
271
- const filterApplied = this.filterConfig.filter(item => item.value != undefined).length > 0;
272
- return filterApplied ? "sc-snk-filter-bar snk-filter-bar__filter-list-items-button--active" : "";
273
- }
274
- isListable(item, allowPersonalized = false) {
275
- return item.type !== FilterItemType.DEFAULT_FILTER && (allowPersonalized || item.type !== FilterItemType.PERSONALIZED);
276
- }
277
- getAppliedListItems() {
278
- const appliedItems = this.filterConfig
279
- .filter(item => this.isActiveFilter(item) && this.isListable(item, true));
280
- return appliedItems.map(filter => {
281
- return { name: filter.id, label: filter.label, kind: "FILTER", iconName: null };
282
- }).concat([
283
- { name: CLEAR_ALL_FILTERS, label: this.getMessage("snkFilterBar.clearAllFilters"), iconName: "cleaning", kind: "FOOTER" }
284
- ]);
285
- }
286
- addPersonalizedFilters(personalizedItems) {
287
- const activeFilters = {};
288
- personalizedItems.forEach(item => {
289
- if (item.active) {
290
- activeFilters[item.id] = true;
291
- }
292
- });
293
- this.filterConfig = this.filterConfig.map(item => {
294
- var _a, _b;
295
- if (item.type === FilterItemType.PERSONALIZED) {
296
- const visible = activeFilters[item.id];
297
- if (!item.visible && visible) {
298
- this.calculateUpdateSequence(item);
299
- if (((_b = (_a = item.props) === null || _a === void 0 ? void 0 : _a.personalizedFilter) === null || _b === void 0 ? void 0 : _b.parameters) != undefined) {
300
- this._pendingFilters.push(item.id);
301
- }
302
- }
303
- return this.normalizeItem(visible ? Object.assign(Object.assign({}, item), { visible }) : Object.assign(Object.assign({}, item), { visible, value: undefined, fixed: undefined }));
304
- }
305
- return item;
306
- }).sort((a, b) => this._filtersComparator(a, b));
307
- }
308
- openDefaultFilterModal() {
309
- const filterModal = document.createElement("snk-filter-modal");
310
- const defaultFilter = this.filterConfig.filter(item => item.type === FilterItemType.DEFAULT_FILTER);
311
- filterModal.getMessage = (key, props) => this.getMessage(key, props);
312
- filterModal.modalTitle = this.getMessage("snkFilterBar.modalDefaultFilterTitle");
313
- filterModal.infoText = this.getMessage(defaultFilter.length == 0 ? "snkFilterBar.modalInfoTextCreateDefault" : "snkFilterBar.modalInfoTextEditDefault");
314
- filterModal.items = defaultFilter.map(item => {
315
- return { id: item.id, active: true, enabled: false, label: item.label };
316
- });
317
- filterModal.processModalAction = (_action) => {
318
- this._application.closeModal();
319
- };
320
- this._application.showModal(filterModal);
321
- }
322
- openPersonalizedModal() {
323
- const filterModal = document.createElement("snk-filter-modal");
324
- const personalizedFilter = this.filterConfig
325
- .filter(item => item.type === FilterItemType.PERSONALIZED)
326
- .sort((itemA, itemB) => StringUtils.compare(itemA.label, itemB.label));
327
- filterModal.getMessage = (key, props) => this.getMessage(key, props);
328
- filterModal.modalTitle = this.getMessage("snkFilterBar.modalPersonalizedFilterTitle");
329
- filterModal.modalSubTitle = this.getMessage("snkFilterBar.modalPersonalizedFilterSubTitle");
330
- filterModal.okButtonLabel = this.getMessage("snkFilterBar.modalOkButtonLabel");
331
- filterModal.cancelButtonLabel = this.getMessage("snkFilterBar.modalCancelButtonLabel");
332
- filterModal.infoText = this.getMessage("snkFilterBar.modalInfoTextCreateEditPersonalized");
333
- filterModal.useSearch = true;
334
- filterModal.items = personalizedFilter.map(item => {
335
- return { id: item.id, active: item.visible, enabled: true, label: item.label };
336
- });
337
- filterModal.processModalAction = (action) => {
338
- if (action === ModalAction.CANCEL) {
339
- // O Botão de cancelar, tem efeito específico:
340
- // - Desmarcar todos os filtros personalizados.
341
- filterModal.items = filterModal.items.map(item => {
342
- return Object.assign(Object.assign({}, item), { active: false });
343
- });
344
- }
345
- else {
346
- if (action === ModalAction.OK) {
347
- this.addPersonalizedFilters(filterModal.items);
348
- }
349
- this._application.closeModal();
350
- }
351
- };
352
- this._application.showModal(filterModal);
353
- }
354
- clearFilters() {
355
- let changed = false;
356
- this.filterConfig = this.filterConfig.map(item => {
357
- if (item.value != undefined) {
358
- changed = true;
359
- }
360
- return Object.assign(Object.assign({}, item), { value: undefined });
361
- }).sort((a, b) => this._filtersComparator(a, b));
362
- return changed;
363
- }
364
- loadPermitions() {
365
- this._application.isUserSup().then(value => this.allowDefault = value);
366
- }
367
- loadConfigFromApplication() {
368
- this._application.getFilterBarConfig(this.configName)
369
- .then((filters) => {
370
- this.filterConfig = filters.map(item => this.normalizeItem(item));
371
- if (this.dataUnit) {
372
- this.dataUnit.loadData();
373
- }
374
- })
375
- .catch(reason => {
376
- throw new ErrorException(this.getMessage("snkFilterBar.failToLoadConfig"), reason);
377
- });
378
- }
379
- attachDataUnit() {
380
- if (this.dataUnit == undefined) {
381
- let parent = this._element.parentElement;
382
- while (parent) {
383
- if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
384
- const snkDataUnit = parent;
385
- this.dataUnit = snkDataUnit.dataUnit;
386
- if (this.dataUnit) {
387
- this.registryFilterProvider();
388
- }
389
- else {
390
- snkDataUnit.addEventListener("dataUnitReady", (evt) => {
391
- this.dataUnit = evt.detail;
392
- this.registryFilterProvider();
393
- });
394
- }
395
- break;
396
- }
397
- }
398
- parent = parent.parentElement;
399
- }
400
- else {
401
- this.registryFilterProvider();
402
- }
403
- }
404
- filterChangeListener(evt) {
405
- this.updateFilter(evt.detail);
406
- }
407
- addFilterHandler(itemName) {
408
- const filterItem = this.filterConfig.find(currentFilter => currentFilter.id === itemName);
409
- if (itemName === PERSONALIZED_FILTER) {
410
- this.openPersonalizedModal();
411
- }
412
- else if (itemName === DEFAULT_FILTER) {
413
- this.openDefaultFilterModal();
414
- }
415
- else if (filterItem) {
416
- this.updateFilter(Object.assign(Object.assign({}, filterItem), { visible: true }));
417
- window.requestAnimationFrame(() => {
418
- const filterItemElement = this._element.querySelector("#filter-" + itemName);
419
- if (filterItemElement) {
420
- filterItemElement.showUp();
421
- }
422
- });
423
- }
424
- }
425
- appliedFilterHandler(itemName) {
426
- if (itemName === CLEAR_ALL_FILTERS) {
427
- if (this.clearFilters()) {
428
- this._application.info(this.getMessage("snkFilterBar.successfullyCleaned"), { iconName: "check" });
429
- }
430
- }
431
- else {
432
- const filterItemElement = this._element.querySelector("#filter-" + itemName);
433
- if (filterItemElement) {
434
- filterItemElement.showUp(true);
435
- }
436
- }
437
- }
438
- componentWillLoad() {
439
- this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
440
- if (this._application) {
441
- this.loadPermitions();
442
- this.loadConfigFromApplication();
443
- }
444
- this.attachDataUnit();
445
- }
446
- componentDidRender() {
447
- this.processPendingFilter();
448
- }
449
- render() {
450
- if (!this.dataUnit || !this.filterConfig || this.filterConfig.length === 0) {
451
- return undefined;
452
- }
453
- return (h(Host, null, h("ez-scroller", { direction: "horizontal" }, this.getFilterItems()), 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) }), 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) }, h("ez-icon", { slot: "leftIcon", class: "ez-padding-right--small", iconName: "plus" }))));
454
- }
455
- get _element() { return getElement(this); }
456
- static get watchers() { return {
457
- "filterConfig": ["observeFilterConfig"]
458
- }; }
459
- };
460
- SnkFilterBar.style = snkFilterBarCss;
461
-
462
- export { SnkFilterBar as snk_filter_bar };
@@ -1,43 +0,0 @@
1
- import { r as registerInstance, h, f as Host } from './index-2b4d2d14.js';
2
- import { F as FilterItemType } from './filter-item-type.enum-a79b2fa8.js';
3
-
4
- const SnkFilterBinarySelect = class {
5
- constructor(hostRef) {
6
- registerInstance(this, hostRef);
7
- }
8
- isSelected(option) {
9
- return this.value == undefined || this.value === option;
10
- }
11
- ezChangeListener(evt) {
12
- if (!evt.detail) {
13
- this.assertCheckedOption(evt.target);
14
- }
15
- this.updateValue();
16
- }
17
- assertCheckedOption(updatingCheck) {
18
- if (updatingCheck === this._checkOne) {
19
- this._checkTwo.value = true;
20
- }
21
- else {
22
- this._checkOne.value = true;
23
- }
24
- }
25
- updateValue() {
26
- if (!this._checkOne.value || !this._checkTwo.value) {
27
- const [optOne, optTwo] = this.config.props.options;
28
- this.value = this._checkOne.value ? optOne.name : optTwo.name;
29
- }
30
- else {
31
- this.value = undefined;
32
- }
33
- }
34
- render() {
35
- if (!this.config || this.config.type !== FilterItemType.BINARY_SELECT) {
36
- return undefined;
37
- }
38
- const [optOne, optTwo] = this.config.props.options;
39
- return (h(Host, null, h("ez-check", { label: optOne.label, class: "sc-snk-filter-bar editor__ez-check", ref: (ref) => this._checkOne = ref, value: this.isSelected(optOne.name) }), h("ez-check", { label: optTwo.label, class: "sc-snk-filter-bar editor__ez-check", ref: (ref) => this._checkTwo = ref, value: this.isSelected(optTwo.name) })));
40
- }
41
- };
42
-
43
- export { SnkFilterBinarySelect as snk_filter_binary_select };
@@ -1,80 +0,0 @@
1
- import { r as registerInstance, e as createEvent, h, f as Host } from './index-2b4d2d14.js';
2
- import { A as ApplicationUtils } from './index-5992b7e6.js';
3
- import { F as FilterItemType } from './filter-item-type.enum-a79b2fa8.js';
4
-
5
- const SnkFilterDetail = class {
6
- constructor(hostRef) {
7
- registerInstance(this, hostRef);
8
- this.filterChange = createEvent(this, "filterChange", 7);
9
- }
10
- changeConfig(newConfig) {
11
- this.filterChange.emit(newConfig);
12
- }
13
- getContentEditor() {
14
- switch (this.config.type) {
15
- case FilterItemType.BINARY_SELECT:
16
- return "snk-filter-binary-select";
17
- case FilterItemType.MULTI_SELECT:
18
- return "snk-filter-multi-select";
19
- case FilterItemType.PERIOD:
20
- return "snk-filter-period";
21
- case FilterItemType.SEARCH:
22
- return "snk-filter-search";
23
- case FilterItemType.NUMBER:
24
- return "snk-filter-number";
25
- case FilterItemType.PERSONALIZED:
26
- return "snk-filter-personalized";
27
- }
28
- return "snk-filter-text";
29
- }
30
- removeItem() {
31
- this.changeConfig(Object.assign(Object.assign({}, this.config), { visible: false, fixed: false, value: undefined }));
32
- }
33
- getPopUpHeaderButtons() {
34
- if (this.config.hardFixed) {
35
- return undefined;
36
- }
37
- return ([
38
- h("ez-icon", { title: this.getMessage("snkFilterBar.removeFilter"), class: "sc-snk-filter-bar snk-filter-item__editor-header-button", iconName: "delete", onClick: () => this.removeItem() }),
39
- h("ez-icon", { title: this.getMessage(this.config.fixed ? "snkFilterBar.unpinFilter" : "snkFilterBar.pinFilter"), class: "ez-margin-left--small sc-snk-filter-bar snk-filter-item__editor-header-button", iconName: this.config.fixed ? "un-pin" : "push-pin", onClick: () => this.changeConfig(Object.assign(Object.assign({}, this.config), { fixed: !this.config.fixed })) })
40
- ]);
41
- }
42
- apply() {
43
- var _a;
44
- let isValid = true;
45
- const value = this._editor["value"];
46
- /* WARNING: Temporário. Isso só está sendo feito até desconsiderar os parametros não informados para PersonalizedFilter*/
47
- if (value != undefined && this.config.type === FilterItemType.PERSONALIZED) {
48
- const params = ((_a = this.config.props.personalizedFilter) === null || _a === void 0 ? void 0 : _a.parameters) || [];
49
- if (params.length > 1) {
50
- if (params.length > value.length) {
51
- isValid = false;
52
- }
53
- else {
54
- value.forEach(item => {
55
- if (item == undefined) {
56
- isValid = false;
57
- }
58
- });
59
- }
60
- }
61
- if (!isValid) {
62
- this.keepOpened = true;
63
- ApplicationUtils.alert("Filtro parcialmente preenchido", "Favor completar todas as informações do filtro.").then(() => setTimeout(() => this.keepOpened = false, 1));
64
- }
65
- }
66
- /* WARNING: Temporário.*/
67
- if (isValid) {
68
- this.changeConfig(Object.assign(Object.assign({}, this.config), { value: value }));
69
- }
70
- }
71
- clear() {
72
- this.changeConfig(Object.assign(Object.assign({}, this.config), { value: undefined }));
73
- }
74
- render() {
75
- const ContentEditor = this.getContentEditor();
76
- return (h(Host, null, h("div", { class: "col ez-col--sd-12 ez-align--right ez-padding-medium ez-flex--align-items-center" }, h("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()), h(ContentEditor, { ref: ref => this._editor = ref, value: this.config.value, config: this.config, fix: () => this.keepOpened = true, unfix: () => this.keepOpened = false }), h("hr", { class: "sc-snk-filter-bar snk-filter__popover-rule" }), h("div", { class: "ez-col ez-col--sd-12 ez-align--right" }, h("ez-button", { label: this.getMessage("snkFilterBar.cleanFilter"), onClick: () => this.clear(), size: "small" }), h("ez-button", { label: this.getMessage("snkFilterBar.applyFilter"), onClick: () => this.apply(), size: "small", class: "ez-button--primary ez-padding-left--medium" }))));
77
- }
78
- };
79
-
80
- export { SnkFilterDetail as snk_filter_detail };