@sankhyalabs/sankhyablocks 1.4.0-beta.1 → 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 (163) hide show
  1. package/dist/cjs/{SnkMessageBuilder-7717f1e4.js → SnkMessageBuilder-d8215915.js} +14 -119
  2. package/dist/cjs/{filter-item-type.enum-e2e1bc5b.js → filter-item-type.enum-3daf58d3.js} +2 -0
  3. package/dist/cjs/{index-b0b676c5.js → index-6fcf07f3.js} +159 -1515
  4. package/dist/cjs/loader.cjs.js +2 -18
  5. package/dist/cjs/sankhyablocks.cjs.js +4 -116
  6. package/dist/cjs/snk-application.cjs.entry.js +84 -230
  7. package/dist/cjs/snk-crud.cjs.entry.js +3 -3
  8. package/dist/cjs/snk-data-unit.cjs.entry.js +24 -32
  9. package/dist/cjs/snk-filter-bar_5.cjs.entry.js +902 -0
  10. package/dist/cjs/snk-filter-binary-select.cjs.entry.js +2 -2
  11. package/dist/cjs/snk-filter-detail.cjs.entry.js +38 -3
  12. package/dist/cjs/snk-filter-multi-select.cjs.entry.js +2 -2
  13. package/dist/cjs/snk-filter-number.cjs.entry.js +2 -2
  14. package/dist/cjs/snk-filter-period.cjs.entry.js +2 -2
  15. package/dist/cjs/snk-filter-personalized.cjs.entry.js +90 -0
  16. package/dist/cjs/snk-filter-search.cjs.entry.js +4 -4
  17. package/dist/cjs/snk-filter-text.cjs.entry.js +1 -1
  18. package/dist/cjs/{snk-form.cjs.entry.js → snk-form_2.cjs.entry.js} +119 -5
  19. package/dist/cjs/snk-pesquisa.cjs.entry.js +5 -5
  20. package/dist/cjs/{taskbar-elements-283c737e.js → taskbar-elements-aedfeae6.js} +1 -1
  21. package/dist/cjs/teste-pesquisa.cjs.entry.js +5 -5
  22. package/dist/collection/collection-manifest.json +2 -0
  23. package/dist/collection/components/snk-application/snk-application.js +54 -7
  24. package/dist/collection/components/snk-crud/snk-crud.js +2 -4
  25. package/dist/collection/components/snk-data-unit/snk-data-unit.js +0 -27
  26. package/dist/collection/components/snk-filter-bar/filter-item/dataunitfilter/data-unit-filter-builder.js +100 -0
  27. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-personalized.js +161 -0
  28. package/dist/collection/components/snk-filter-bar/filter-item/filter-item-type.enum.js +2 -0
  29. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +36 -1
  30. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +32 -9
  31. package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +196 -0
  32. package/dist/collection/components/snk-filter-bar/snk-filter-bar.css +22 -0
  33. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +238 -139
  34. package/dist/collection/components/snk-grid/snk-grid.js +2 -4
  35. package/dist/collection/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.js +18 -10
  36. package/dist/collection/lib/message/resources/snk-filter-bar.msg.js +14 -2
  37. package/dist/components/SnkMessageBuilder.js +15 -119
  38. package/dist/components/filter-item-type.enum.js +2 -0
  39. package/dist/components/index.d.ts +2 -0
  40. package/dist/components/index.js +2 -4
  41. package/dist/components/snk-application2.js +47 -191
  42. package/dist/components/snk-crud.js +16 -10
  43. package/dist/components/snk-data-unit.js +3 -12
  44. package/dist/components/snk-filter-bar2.js +342 -146
  45. package/dist/components/snk-filter-detail2.js +36 -1
  46. package/dist/components/snk-filter-item2.js +33 -10
  47. package/dist/components/snk-filter-list2.js +1 -1
  48. package/dist/components/snk-filter-modal.d.ts +11 -0
  49. package/dist/components/snk-filter-modal.js +6 -0
  50. package/dist/components/snk-filter-modal2.js +58 -0
  51. package/dist/components/snk-filter-personalized.d.ts +11 -0
  52. package/dist/components/snk-filter-personalized.js +108 -0
  53. package/dist/components/snk-filter-search.js +1 -1
  54. package/dist/components/snk-form2.js +1 -1
  55. package/dist/components/snk-grid2.js +16 -10
  56. package/dist/components/snk-pesquisa2.js +1 -1
  57. package/dist/components/snk-taskbar2.js +1 -1
  58. package/dist/components/teste-pesquisa.js +1 -1
  59. package/dist/{sankhyablocks/SnkMessageBuilder-a7da466b.js → esm/SnkMessageBuilder-35a20271.js} +15 -119
  60. package/dist/esm/{filter-item-type.enum-61fbf80a.js → filter-item-type.enum-a79b2fa8.js} +2 -0
  61. package/dist/{sankhyablocks/index-2b4d2d14.js → esm/index-81dda3cf.js} +160 -1508
  62. package/dist/esm/loader.js +2 -18
  63. package/dist/esm/sankhyablocks.js +4 -116
  64. package/dist/esm/snk-application.entry.js +46 -192
  65. package/dist/esm/snk-crud.entry.js +2 -2
  66. package/dist/esm/snk-data-unit.entry.js +4 -12
  67. package/dist/esm/snk-filter-bar_5.entry.js +894 -0
  68. package/dist/esm/snk-filter-binary-select.entry.js +2 -2
  69. package/dist/esm/snk-filter-detail.entry.js +38 -3
  70. package/dist/esm/snk-filter-multi-select.entry.js +2 -2
  71. package/dist/esm/snk-filter-number.entry.js +2 -2
  72. package/dist/esm/snk-filter-period.entry.js +2 -2
  73. package/dist/esm/snk-filter-personalized.entry.js +86 -0
  74. package/dist/esm/snk-filter-search.entry.js +3 -3
  75. package/dist/esm/snk-filter-text.entry.js +1 -1
  76. package/dist/esm/{snk-form.entry.js → snk-form_2.entry.js} +117 -4
  77. package/dist/esm/snk-pesquisa.entry.js +2 -2
  78. package/dist/{sankhyablocks/taskbar-elements-35d64ff9.js → esm/taskbar-elements-38eb5d51.js} +1 -1
  79. package/dist/esm/teste-pesquisa.entry.js +2 -2
  80. package/dist/sankhyablocks/index.esm.js +0 -1
  81. package/dist/sankhyablocks/p-0352c0e2.entry.js +1 -0
  82. package/dist/sankhyablocks/p-07ebda01.entry.js +1 -0
  83. package/dist/sankhyablocks/p-322c0df2.entry.js +1 -0
  84. package/dist/sankhyablocks/p-46caa101.entry.js +1 -0
  85. package/dist/sankhyablocks/p-473cedf9.entry.js +1 -0
  86. package/dist/sankhyablocks/p-586e2522.js +1 -0
  87. package/dist/sankhyablocks/p-86f15ffe.js +1 -0
  88. package/dist/sankhyablocks/p-8f3c5709.entry.js +1 -0
  89. package/dist/sankhyablocks/p-97009a2c.entry.js +1 -0
  90. package/dist/sankhyablocks/p-9be74b46.entry.js +74 -0
  91. package/dist/sankhyablocks/p-9dd2b8cb.js +1 -0
  92. package/dist/sankhyablocks/p-a8b59c61.entry.js +1 -0
  93. package/dist/sankhyablocks/p-aecf3e0a.entry.js +1 -0
  94. package/dist/sankhyablocks/p-c1c3b5d8.entry.js +1 -0
  95. package/dist/sankhyablocks/p-c78cb79a.entry.js +1 -0
  96. package/dist/sankhyablocks/p-c9eec639.entry.js +1 -0
  97. package/dist/sankhyablocks/p-dc482a42.entry.js +1 -0
  98. package/dist/sankhyablocks/p-fac2b6a9.js +2 -0
  99. package/dist/sankhyablocks/p-fb705f81.entry.js +1 -0
  100. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -129
  101. package/dist/types/components/snk-application/snk-application.d.ts +4 -1
  102. package/dist/types/components/snk-filter-bar/filter-item/dataunitfilter/data-unit-filter-builder.d.ts +4 -0
  103. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-personalized.d.ts +23 -0
  104. package/dist/types/components/snk-filter-bar/filter-item/filter-item-type.enum.d.ts +3 -1
  105. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +2 -0
  106. package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +23 -0
  107. package/dist/types/components.d.ts +56 -8
  108. package/package.json +3 -3
  109. package/react/components.d.ts +19 -0
  110. package/react/components.js +19 -0
  111. package/react/components.js.map +1 -1
  112. package/dist/cjs/app-globals-3a1e7e63.js +0 -5
  113. package/dist/cjs/css-shim-b8158822.js +0 -6
  114. package/dist/cjs/dom-36862b77.js +0 -75
  115. package/dist/cjs/index-02201bc9.js +0 -2397
  116. package/dist/cjs/shadow-css-346c0795.js +0 -389
  117. package/dist/cjs/snk-filter-bar.cjs.entry.js +0 -278
  118. package/dist/cjs/snk-filter-item.cjs.entry.js +0 -154
  119. package/dist/cjs/snk-filter-list.cjs.entry.js +0 -91
  120. package/dist/cjs/snk-grid.cjs.entry.js +0 -79
  121. package/dist/cjs/snk-taskbar.cjs.entry.js +0 -160
  122. package/dist/cjs/taskbar-processor-6bd0d35c.js +0 -47
  123. package/dist/components/index2.js +0 -2384
  124. package/dist/esm/SnkMessageBuilder-a7da466b.js +0 -303
  125. package/dist/esm/app-globals-0f993ce5.js +0 -3
  126. package/dist/esm/css-shim-b3f2ee8d.js +0 -4
  127. package/dist/esm/dom-665d6011.js +0 -73
  128. package/dist/esm/index-2b4d2d14.js +0 -3262
  129. package/dist/esm/index-f1d3e4da.js +0 -2384
  130. package/dist/esm/shadow-css-b18e99d7.js +0 -387
  131. package/dist/esm/snk-filter-bar.entry.js +0 -274
  132. package/dist/esm/snk-filter-item.entry.js +0 -150
  133. package/dist/esm/snk-filter-list.entry.js +0 -87
  134. package/dist/esm/snk-grid.entry.js +0 -75
  135. package/dist/esm/snk-taskbar.entry.js +0 -156
  136. package/dist/esm/taskbar-elements-35d64ff9.js +0 -90
  137. package/dist/esm/taskbar-processor-aa6772c9.js +0 -45
  138. package/dist/sankhyablocks/app-globals-0f993ce5.js +0 -3
  139. package/dist/sankhyablocks/css-shim-b3f2ee8d.js +0 -4
  140. package/dist/sankhyablocks/dom-665d6011.js +0 -73
  141. package/dist/sankhyablocks/filter-item-type.enum-61fbf80a.js +0 -12
  142. package/dist/sankhyablocks/index-f1d3e4da.js +0 -2384
  143. package/dist/sankhyablocks/shadow-css-b18e99d7.js +0 -387
  144. package/dist/sankhyablocks/snk-application.entry.js +0 -8148
  145. package/dist/sankhyablocks/snk-crud.entry.js +0 -66
  146. package/dist/sankhyablocks/snk-data-unit.entry.js +0 -276
  147. package/dist/sankhyablocks/snk-filter-bar.entry.js +0 -274
  148. package/dist/sankhyablocks/snk-filter-binary-select.entry.js +0 -43
  149. package/dist/sankhyablocks/snk-filter-detail.entry.js +0 -45
  150. package/dist/sankhyablocks/snk-filter-item.entry.js +0 -150
  151. package/dist/sankhyablocks/snk-filter-list.entry.js +0 -87
  152. package/dist/sankhyablocks/snk-filter-multi-select.entry.js +0 -19
  153. package/dist/sankhyablocks/snk-filter-number.entry.js +0 -20
  154. package/dist/sankhyablocks/snk-filter-period.entry.js +0 -33
  155. package/dist/sankhyablocks/snk-filter-search.entry.js +0 -40
  156. package/dist/sankhyablocks/snk-filter-text.entry.js +0 -18
  157. package/dist/sankhyablocks/snk-form.entry.js +0 -129
  158. package/dist/sankhyablocks/snk-grid.entry.js +0 -75
  159. package/dist/sankhyablocks/snk-pesquisa.entry.js +0 -311
  160. package/dist/sankhyablocks/snk-taskbar.entry.js +0 -156
  161. package/dist/sankhyablocks/taskbar-processor-aa6772c9.js +0 -45
  162. package/dist/sankhyablocks/teste-pesquisa.entry.js +0 -33
  163. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +0 -51
@@ -0,0 +1,894 @@
1
+ import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-81dda3cf.js';
2
+ import { DataType, ObjectUtils, StringUtils, ErrorException, ApplicationContext, FloatingManager, ArrayUtils } from '@sankhyalabs/core';
3
+ import { F as FilterItemType } from './filter-item-type.enum-a79b2fa8.js';
4
+ import { ModalAction, ModalButtonStatus } from '@sankhyalabs/ezui/dist/collection/components/ez-modal-container';
5
+ import { toString } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
6
+ import { T as TaskbarElement, V as VisibleWhenForbidden, A as AuthorizationElements, b as buildElem, a as buildCustomButton } from './taskbar-elements-38eb5d51.js';
7
+
8
+ const buildFilter = (item) => {
9
+ switch (item.type) {
10
+ case FilterItemType.DEFAULT_FILTER:
11
+ return buildDefault(item);
12
+ case FilterItemType.BINARY_SELECT:
13
+ return buildBinary(item);
14
+ case FilterItemType.MULTI_SELECT:
15
+ return buildMultSelect(item);
16
+ case FilterItemType.PERIOD:
17
+ return buildPeriod(item);
18
+ case FilterItemType.SEARCH:
19
+ return buildSearch(item);
20
+ case FilterItemType.TEXT:
21
+ return buildText(item);
22
+ case FilterItemType.NUMBER:
23
+ return buildNumber(item);
24
+ case FilterItemType.PERSONALIZED:
25
+ return buildPersonalized(item);
26
+ default:
27
+ return undefined;
28
+ }
29
+ };
30
+ function buildDefault(item) {
31
+ return { name: item.id, expression: item.props.expression, params: [] };
32
+ }
33
+ function buildBinary(item) {
34
+ const { id, value, props } = item;
35
+ const options = props.options;
36
+ const selectedOption = options.find(opt => opt.name === value);
37
+ return { name: id, expression: selectedOption.expression, params: [] };
38
+ }
39
+ function buildMultSelect(item) {
40
+ const { id, value, props } = item;
41
+ return { name: id, expression: props.expression, params: [{ name: id, dataType: DataType.TEXT, value }] };
42
+ }
43
+ function buildPeriod(item) {
44
+ const { id, value, props } = item;
45
+ let { end, start } = value;
46
+ if (typeof end === "string") {
47
+ end = new Date(end);
48
+ }
49
+ if (typeof start === "string") {
50
+ start = new Date(start);
51
+ }
52
+ const params = [];
53
+ let expression;
54
+ if (end && start) {
55
+ expression = props.expression.fullfill;
56
+ params.push({ name: `${id}.START`, dataType: DataType.DATE, value: toString(DataType.DATE, start) }, { name: `${id}.END`, dataType: DataType.DATE, value: toString(DataType.DATE, end) });
57
+ }
58
+ else {
59
+ if (start) {
60
+ expression = props.expression.onlystart;
61
+ params.push({ name: id, dataType: DataType.DATE, value: toString(DataType.DATE, start) });
62
+ }
63
+ else {
64
+ expression = props.expression.onlyend;
65
+ params.push({ name: id, dataType: DataType.DATE, value: toString(DataType.DATE, end) });
66
+ }
67
+ }
68
+ return { name: id, expression, params };
69
+ }
70
+ function buildSearch(item) {
71
+ const { id, value, props } = item;
72
+ const expression = props.expression;
73
+ return { name: id, expression, params: [{ name: id, dataType: DataType.TEXT, value: toString(DataType.TEXT, value.value) }] };
74
+ }
75
+ function buildText(item) {
76
+ const { id, value, props } = item;
77
+ const expression = props.expression;
78
+ return { name: id, expression, params: [{ name: id, dataType: DataType.TEXT, value: toString(DataType.TEXT, value) }] };
79
+ }
80
+ function buildNumber(item) {
81
+ const { id, value, props } = item;
82
+ const expression = props.expression;
83
+ return { name: id, expression, params: [{ name: id, dataType: DataType.NUMBER, value: toString(DataType.NUMBER, value) }] };
84
+ }
85
+ function buildPersonalized(item) {
86
+ var _a;
87
+ const { id, value, props } = item;
88
+ const expression = props.expression;
89
+ return {
90
+ name: id, expression, params: (((_a = props.personalizedFilter) === null || _a === void 0 ? void 0 : _a.parameters) || []).map((param, index) => {
91
+ const valuesArray = Array.from(value);
92
+ const dataType = param.dataType;
93
+ let paramValue = (index >= 0 && index < valuesArray.length ? valuesArray[index] : null);
94
+ if (paramValue != undefined && typeof paramValue === "object" && "value" in paramValue) {
95
+ paramValue = paramValue["value"];
96
+ }
97
+ if (paramValue == undefined && dataType === DataType.BOOLEAN) {
98
+ paramValue = false;
99
+ }
100
+ return { name: param.name, dataType, value: typeof paramValue === "string" ? paramValue : toString(dataType, paramValue) };
101
+ })
102
+ };
103
+ }
104
+
105
+ 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%}";
106
+
107
+ const PERSONALIZED_FILTER = "PERSONALIZED_FILTER";
108
+ const DEFAULT_FILTER = "DEFAULT_FILTER";
109
+ const CLEAR_ALL_FILTERS = "CLEAR_ALL_FILTERS";
110
+ const SnkFilterBar = class {
111
+ constructor(hostRef) {
112
+ registerInstance(this, hostRef);
113
+ this._updateSequence = [];
114
+ this._loadingPending = false;
115
+ this._configUpdated = false;
116
+ this._pendingFilters = [];
117
+ this._calculateSortIndex = (item) => {
118
+ let index = item.hardFixed ? 1000000 : 0;
119
+ //campos Hard Fixed não variam a ordem
120
+ if (!item.hardFixed) {
121
+ index += item.fixed ? 100000 : 0;
122
+ index += item.value == undefined ? 0 : 10000;
123
+ index += this._updateSequence.lastIndexOf(item.id) + 1;
124
+ }
125
+ return index;
126
+ };
127
+ this._filtersComparator = (a, b) => {
128
+ return this._calculateSortIndex(b) - this._calculateSortIndex(a);
129
+ };
130
+ }
131
+ observeFilterConfig(newValue, oldValue) {
132
+ if (oldValue != undefined && newValue == undefined) {
133
+ this._loadingPending = true;
134
+ this._configUpdated = true;
135
+ }
136
+ else {
137
+ const oldItems = new Map(oldValue ? oldValue.map(item => [item.id, item]) : undefined);
138
+ newValue.forEach(newItem => {
139
+ const oldItem = oldItems.get(newItem.id);
140
+ if (oldItem != undefined) {
141
+ this._configUpdated = this._configUpdated || ObjectUtils.objectToString(oldItem) != ObjectUtils.objectToString(newItem);
142
+ this._loadingPending = this._loadingPending || ObjectUtils.objectToString(oldItem.value) !== ObjectUtils.objectToString(newItem.value);
143
+ }
144
+ else {
145
+ this._configUpdated = true;
146
+ this._loadingPending = this._loadingPending || newItem.value != undefined;
147
+ }
148
+ });
149
+ }
150
+ this.processAfterUpdateConfig();
151
+ }
152
+ processPendingFilter() {
153
+ if (this._pendingFilters.length > 0 && this._currentPendingFilter == undefined) {
154
+ this._currentPendingFilter = this._element.querySelector("#filter-" + this._pendingFilters.pop());
155
+ if (this._currentPendingFilter) {
156
+ this._currentPendingFilter.showUp(true).then(() => {
157
+ this._currentPendingFilter = undefined;
158
+ this.processPendingFilter();
159
+ });
160
+ }
161
+ }
162
+ if (this._currentPendingFilter == undefined) {
163
+ this.processAfterUpdateConfig();
164
+ }
165
+ }
166
+ processAfterUpdateConfig() {
167
+ if (this._pendingFilters.length > 0) {
168
+ return;
169
+ }
170
+ if (this._loadingPending) {
171
+ this._loadingPending = false;
172
+ this.dataUnit.loadData();
173
+ }
174
+ if (this._configUpdated) {
175
+ this._configUpdated = false;
176
+ this._application.saveFilterBarConfig(this.filterConfig, this.configName);
177
+ }
178
+ }
179
+ /**
180
+ * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
181
+ * através de um pequeno modulo na estrutura da aplicação:
182
+ * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
183
+ * Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-filter-bar.msg.ts"
184
+ */
185
+ getMessage(key, params) {
186
+ return this._application.messagesBuilder.getMessage(key, params);
187
+ }
188
+ getFilter(_dataUnit) {
189
+ var _a;
190
+ const filters = [];
191
+ (_a = this.filterConfig) === null || _a === void 0 ? void 0 : _a.filter(item => this.isActiveFilter(item)).forEach(item => {
192
+ const filter = buildFilter(item);
193
+ if (filter) {
194
+ filters.push(filter);
195
+ }
196
+ });
197
+ return filters;
198
+ }
199
+ isActiveFilter(item) {
200
+ return (item.visible && item.value != undefined) || item.type === FilterItemType.DEFAULT_FILTER;
201
+ }
202
+ registryFilterProvider() {
203
+ this.dataUnit.addFilterProvider(this);
204
+ if (this.filterConfig) {
205
+ this.dataUnit.loadData();
206
+ }
207
+ }
208
+ getFilterItems() {
209
+ const pinnedItems = [];
210
+ const unpinnedItems = [];
211
+ this.filterConfig
212
+ .filter(item => item.visible)
213
+ .forEach((item, index) => {
214
+ 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 }));
215
+ if (item.fixed || item.hardFixed) {
216
+ pinnedItems.push(filterItem);
217
+ }
218
+ else {
219
+ unpinnedItems.push(filterItem);
220
+ }
221
+ return filterItem;
222
+ });
223
+ const elements = [];
224
+ elements.push(...pinnedItems);
225
+ if (pinnedItems.length > 0 && unpinnedItems.length > 0) {
226
+ elements.push(h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-filter-bar__divider" }));
227
+ }
228
+ elements.push(...unpinnedItems);
229
+ return elements;
230
+ }
231
+ calculateUpdateSequence(item) {
232
+ if (item) {
233
+ this._updateSequence = this._updateSequence.filter(itemId => item.id !== itemId);
234
+ this._updateSequence.push(item.id);
235
+ }
236
+ }
237
+ normalizeItem(item) {
238
+ const normalized = Object.assign({}, item);
239
+ const optionals = ["props", "value", "hardFixed", "fixed"];
240
+ optionals.forEach(prop => {
241
+ if (normalized[prop] == undefined) {
242
+ delete normalized[prop];
243
+ }
244
+ });
245
+ if (item.value === "") {
246
+ delete item.value;
247
+ }
248
+ return normalized;
249
+ }
250
+ updateFilter(newItem) {
251
+ this.filterConfig = this.filterConfig.map(item => {
252
+ newItem = this.normalizeItem(newItem);
253
+ if (item.id === newItem.id) {
254
+ if (ObjectUtils.objectToString(item) != ObjectUtils.objectToString(newItem)) {
255
+ this.calculateUpdateSequence(newItem);
256
+ }
257
+ return newItem;
258
+ }
259
+ return item;
260
+ }).sort((a, b) => this._filtersComparator(a, b));
261
+ }
262
+ getAddListItems() {
263
+ const hiddenItems = this.filterConfig
264
+ .filter(item => !item.visible && this.isListable(item));
265
+ const footerItems = [{ name: PERSONALIZED_FILTER, label: this.getMessage("snkFilterBar.customFilter"), iconName: "tune", kind: "FOOTER" }];
266
+ if (this.allowDefault) {
267
+ footerItems.push({ name: DEFAULT_FILTER, label: this.getMessage("snkFilterBar.defaultFilter"), iconName: "configuration", kind: "FOOTER" });
268
+ }
269
+ return hiddenItems.map(filter => { return { name: filter.id, label: filter.label, kind: "FILTER", iconName: null }; })
270
+ .concat(footerItems);
271
+ }
272
+ getActiveClass() {
273
+ const filterApplied = this.filterConfig.filter(item => item.value != undefined).length > 0;
274
+ return filterApplied ? "sc-snk-filter-bar snk-filter-bar__filter-list-items-button--active" : "";
275
+ }
276
+ isListable(item, allowPersonalized = false) {
277
+ return item.type !== FilterItemType.DEFAULT_FILTER && (allowPersonalized || item.type !== FilterItemType.PERSONALIZED);
278
+ }
279
+ getAppliedListItems() {
280
+ const appliedItems = this.filterConfig
281
+ .filter(item => this.isActiveFilter(item) && this.isListable(item, true));
282
+ return appliedItems.map(filter => {
283
+ return { name: filter.id, label: filter.label, kind: "FILTER", iconName: null };
284
+ }).concat([
285
+ { name: CLEAR_ALL_FILTERS, label: this.getMessage("snkFilterBar.clearAllFilters"), iconName: "cleaning", kind: "FOOTER" }
286
+ ]);
287
+ }
288
+ addPersonalizedFilters(personalizedItems) {
289
+ const activeFilters = {};
290
+ personalizedItems.forEach(item => {
291
+ if (item.active) {
292
+ activeFilters[item.id] = true;
293
+ }
294
+ });
295
+ this.filterConfig = this.filterConfig.map(item => {
296
+ var _a, _b;
297
+ if (item.type === FilterItemType.PERSONALIZED) {
298
+ const visible = activeFilters[item.id];
299
+ if (!item.visible && visible) {
300
+ this.calculateUpdateSequence(item);
301
+ if (((_b = (_a = item.props) === null || _a === void 0 ? void 0 : _a.personalizedFilter) === null || _b === void 0 ? void 0 : _b.parameters) != undefined) {
302
+ this._pendingFilters.push(item.id);
303
+ }
304
+ }
305
+ return this.normalizeItem(visible ? Object.assign(Object.assign({}, item), { visible }) : Object.assign(Object.assign({}, item), { visible, value: undefined, fixed: undefined }));
306
+ }
307
+ return item;
308
+ }).sort((a, b) => this._filtersComparator(a, b));
309
+ }
310
+ openDefaultFilterModal() {
311
+ const filterModal = document.createElement("snk-filter-modal");
312
+ const defaultFilter = this.filterConfig.filter(item => item.type === FilterItemType.DEFAULT_FILTER);
313
+ filterModal.getMessage = (key, props) => this.getMessage(key, props);
314
+ filterModal.modalTitle = this.getMessage("snkFilterBar.modalDefaultFilterTitle");
315
+ filterModal.infoText = this.getMessage(defaultFilter.length == 0 ? "snkFilterBar.modalInfoTextCreateDefault" : "snkFilterBar.modalInfoTextEditDefault");
316
+ filterModal.items = defaultFilter.map(item => {
317
+ return { id: item.id, active: true, enabled: false, label: item.label };
318
+ });
319
+ filterModal.processModalAction = (_action) => {
320
+ this._application.closeModal();
321
+ };
322
+ this._application.showModal(filterModal);
323
+ }
324
+ openPersonalizedModal() {
325
+ const filterModal = document.createElement("snk-filter-modal");
326
+ const personalizedFilter = this.filterConfig
327
+ .filter(item => item.type === FilterItemType.PERSONALIZED)
328
+ .sort((itemA, itemB) => StringUtils.compare(itemA.label, itemB.label));
329
+ filterModal.getMessage = (key, props) => this.getMessage(key, props);
330
+ filterModal.modalTitle = this.getMessage("snkFilterBar.modalPersonalizedFilterTitle");
331
+ filterModal.modalSubTitle = this.getMessage("snkFilterBar.modalPersonalizedFilterSubTitle");
332
+ filterModal.okButtonLabel = this.getMessage("snkFilterBar.modalOkButtonLabel");
333
+ filterModal.cancelButtonLabel = this.getMessage("snkFilterBar.modalCancelButtonLabel");
334
+ filterModal.infoText = this.getMessage("snkFilterBar.modalInfoTextCreateEditPersonalized");
335
+ filterModal.useSearch = true;
336
+ filterModal.items = personalizedFilter.map(item => {
337
+ return { id: item.id, active: item.visible, enabled: true, label: item.label };
338
+ });
339
+ filterModal.processModalAction = (action) => {
340
+ if (action === ModalAction.CANCEL) {
341
+ // O Botão de cancelar, tem efeito específico:
342
+ // - Desmarcar todos os filtros personalizados.
343
+ filterModal.items = filterModal.items.map(item => {
344
+ return Object.assign(Object.assign({}, item), { active: false });
345
+ });
346
+ }
347
+ else {
348
+ if (action === ModalAction.OK) {
349
+ this.addPersonalizedFilters(filterModal.items);
350
+ }
351
+ this._application.closeModal();
352
+ }
353
+ };
354
+ this._application.showModal(filterModal);
355
+ }
356
+ clearFilters() {
357
+ let changed = false;
358
+ this.filterConfig = this.filterConfig.map(item => {
359
+ if (item.value != undefined) {
360
+ changed = true;
361
+ }
362
+ return Object.assign(Object.assign({}, item), { value: undefined });
363
+ }).sort((a, b) => this._filtersComparator(a, b));
364
+ return changed;
365
+ }
366
+ loadPermitions() {
367
+ this._application.isUserSup().then(value => this.allowDefault = value);
368
+ }
369
+ loadConfigFromApplication() {
370
+ this._application.getFilterBarConfig(this.configName)
371
+ .then((filters) => {
372
+ this.filterConfig = filters.map(item => this.normalizeItem(item));
373
+ if (this.dataUnit) {
374
+ this.dataUnit.loadData();
375
+ }
376
+ })
377
+ .catch(reason => {
378
+ throw new ErrorException(this.getMessage("snkFilterBar.failToLoadConfig"), reason);
379
+ });
380
+ }
381
+ attachDataUnit() {
382
+ if (this.dataUnit == undefined) {
383
+ let parent = this._element.parentElement;
384
+ while (parent) {
385
+ if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
386
+ const snkDataUnit = parent;
387
+ this.dataUnit = snkDataUnit.dataUnit;
388
+ if (this.dataUnit) {
389
+ this.registryFilterProvider();
390
+ }
391
+ else {
392
+ snkDataUnit.addEventListener("dataUnitReady", (evt) => {
393
+ this.dataUnit = evt.detail;
394
+ this.registryFilterProvider();
395
+ });
396
+ }
397
+ break;
398
+ }
399
+ }
400
+ parent = parent.parentElement;
401
+ }
402
+ else {
403
+ this.registryFilterProvider();
404
+ }
405
+ }
406
+ filterChangeListener(evt) {
407
+ this.updateFilter(evt.detail);
408
+ }
409
+ addFilterHandler(itemName) {
410
+ const filterItem = this.filterConfig.find(currentFilter => currentFilter.id === itemName);
411
+ if (itemName === PERSONALIZED_FILTER) {
412
+ this.openPersonalizedModal();
413
+ }
414
+ else if (itemName === DEFAULT_FILTER) {
415
+ this.openDefaultFilterModal();
416
+ }
417
+ else if (filterItem) {
418
+ this.updateFilter(Object.assign(Object.assign({}, filterItem), { visible: true }));
419
+ window.requestAnimationFrame(() => {
420
+ const filterItemElement = this._element.querySelector("#filter-" + itemName);
421
+ if (filterItemElement) {
422
+ filterItemElement.showUp();
423
+ }
424
+ });
425
+ }
426
+ }
427
+ appliedFilterHandler(itemName) {
428
+ if (itemName === CLEAR_ALL_FILTERS) {
429
+ if (this.clearFilters()) {
430
+ this._application.info(this.getMessage("snkFilterBar.successfullyCleaned"), { iconName: "check" });
431
+ }
432
+ }
433
+ else {
434
+ const filterItemElement = this._element.querySelector("#filter-" + itemName);
435
+ if (filterItemElement) {
436
+ filterItemElement.showUp(true);
437
+ }
438
+ }
439
+ }
440
+ componentWillLoad() {
441
+ this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
442
+ if (this._application) {
443
+ this.loadPermitions();
444
+ this.loadConfigFromApplication();
445
+ }
446
+ this.attachDataUnit();
447
+ }
448
+ componentDidRender() {
449
+ this.processPendingFilter();
450
+ }
451
+ render() {
452
+ if (!this.dataUnit || !this.filterConfig || this.filterConfig.length === 0) {
453
+ return undefined;
454
+ }
455
+ 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" }))));
456
+ }
457
+ get _element() { return getElement(this); }
458
+ static get watchers() { return {
459
+ "filterConfig": ["observeFilterConfig"]
460
+ }; }
461
+ };
462
+ SnkFilterBar.style = snkFilterBarCss;
463
+
464
+ const SnkFilterItem = class {
465
+ constructor(hostRef) {
466
+ registerInstance(this, hostRef);
467
+ this.filterChange = createEvent(this, "filterChange", 7);
468
+ this.innerClickCheck = (floatingContainer, node) => {
469
+ if (this._popover.keepOpened) {
470
+ return true;
471
+ }
472
+ if (node && floatingContainer) {
473
+ if (!node.offsetParent) {
474
+ return true;
475
+ }
476
+ let current = node;
477
+ do {
478
+ if (current === floatingContainer) {
479
+ return true;
480
+ }
481
+ } while ((current = current.offsetParent) != null);
482
+ }
483
+ this.detailIsVisible = false;
484
+ this.executeCloseCallback();
485
+ return false;
486
+ };
487
+ }
488
+ async showUp(open = false) {
489
+ return new Promise(resolve => {
490
+ this._filterItemElement.scrollIntoView({ behavior: "auto", block: "nearest", inline: "nearest" });
491
+ if (open) {
492
+ window.requestAnimationFrame(() => {
493
+ this._closeCallback = resolve;
494
+ this.showDetail();
495
+ });
496
+ }
497
+ });
498
+ }
499
+ showDetail() {
500
+ this._floatingID = FloatingManager.float(this._popover, this._popoverContainer, { autoClose: true, innerClickTest: this.innerClickCheck, left: this.getScrollOffset() });
501
+ this.detailIsVisible = true;
502
+ }
503
+ getScrollOffset() {
504
+ return `${this._filterItemElement.getBoundingClientRect().left + 12}px`;
505
+ }
506
+ hideDetail() {
507
+ if (this._floatingID != undefined) {
508
+ FloatingManager.close(this._floatingID);
509
+ }
510
+ this._floatingID = undefined;
511
+ this.detailIsVisible = false;
512
+ this.executeCloseCallback();
513
+ }
514
+ executeCloseCallback() {
515
+ if (this._closeCallback) {
516
+ this._closeCallback();
517
+ this._closeCallback = undefined;
518
+ }
519
+ }
520
+ //---------------------------------------------
521
+ // Event handlers
522
+ //---------------------------------------------
523
+ clickListener(evt) {
524
+ if ([this._chipElement, this._leftIconElement, this._rightIconElement].includes(evt.target)) {
525
+ if (evt.target === this._rightIconElement && this.config.value != undefined) {
526
+ this.filterChange.emit(Object.assign(Object.assign({}, this.config), { value: undefined }));
527
+ }
528
+ else {
529
+ if (this.detailIsVisible) {
530
+ this.hideDetail();
531
+ }
532
+ else {
533
+ this.showDetail();
534
+ }
535
+ }
536
+ evt.preventDefault();
537
+ evt.stopImmediatePropagation();
538
+ evt.stopPropagation();
539
+ }
540
+ }
541
+ mouseDownListener(evt) {
542
+ if (this.detailIsVisible && [this._chipElement, this._leftIconElement, this._rightIconElement].includes(evt.target)) {
543
+ evt.preventDefault();
544
+ evt.stopImmediatePropagation();
545
+ evt.stopPropagation();
546
+ }
547
+ }
548
+ getLabel() {
549
+ const { type, value, label, props } = this.config;
550
+ if (value) {
551
+ if (type === FilterItemType.BINARY_SELECT) {
552
+ const [optOne, optTwo] = props.options;
553
+ if (optOne.name === value) {
554
+ return optOne.label;
555
+ }
556
+ if (optTwo.name === value) {
557
+ return optTwo.label;
558
+ }
559
+ }
560
+ if (type === FilterItemType.MULTI_SELECT) {
561
+ const opt = props.options.find(opt => opt.value === value);
562
+ return `${label}: ${opt.label}`;
563
+ }
564
+ if (type === FilterItemType.PERIOD) {
565
+ let { end, start } = value;
566
+ if (typeof end === "string") {
567
+ end = new Date(end);
568
+ end.setMinutes(end.getMinutes() + end.getTimezoneOffset());
569
+ }
570
+ if (typeof start === "string") {
571
+ start = new Date(start);
572
+ start.setMinutes(start.getMinutes() + start.getTimezoneOffset());
573
+ }
574
+ const dateFormater = new Intl.DateTimeFormat("pt-BR");
575
+ if (end && start) {
576
+ return `${label}: ${dateFormater.format(start)} a ${dateFormater.format(end)}`;
577
+ }
578
+ else {
579
+ if (start) {
580
+ return `${label}: A partir de ${dateFormater.format(start)}`;
581
+ }
582
+ else if (end) {
583
+ return `${label}: Até ${dateFormater.format(end)}`;
584
+ }
585
+ else {
586
+ return label;
587
+ }
588
+ }
589
+ }
590
+ if (type === FilterItemType.SEARCH) {
591
+ return `${label}: ${value.value} - ${value.label}`;
592
+ }
593
+ if (type === FilterItemType.PERSONALIZED) {
594
+ return label;
595
+ }
596
+ return `${label}: ${value}`;
597
+ }
598
+ return label;
599
+ }
600
+ componentDidRender() {
601
+ if (this._floatingID == undefined) {
602
+ if (this._popover) {
603
+ this._popover.remove();
604
+ }
605
+ }
606
+ }
607
+ filterChangeListener() {
608
+ this.hideDetail();
609
+ }
610
+ getRightIconName() {
611
+ if (this.config.value != undefined) {
612
+ return "close";
613
+ }
614
+ return this.detailIsVisible ? "chevron-up" : "chevron-down";
615
+ }
616
+ getLeftIconName() {
617
+ switch (this.config.type) {
618
+ case FilterItemType.PERIOD:
619
+ return "calendar";
620
+ case FilterItemType.PERSONALIZED:
621
+ return "tune";
622
+ }
623
+ return undefined;
624
+ }
625
+ render() {
626
+ const leftIcon = this.getLeftIconName();
627
+ return (h(Host, null, h("ez-chip", { ref: ref => this._chipElement = ref, label: this.getLabel(), value: this.config.value != undefined }, leftIcon ? h("ez-icon", { ref: ref => this._leftIconElement = ref, iconName: leftIcon, class: "ez-padding-right--small", slot: "leftIcon" }) : undefined, h("ez-icon", { ref: ref => this._rightIconElement = ref, iconName: this.getRightIconName(), class: "ez-padding-left--small", slot: "rightIcon" })), h("section", { class: "ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container", ref: elem => this._popoverContainer = elem }, 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 }))));
628
+ }
629
+ get _filterItemElement() { return getElement(this); }
630
+ };
631
+
632
+ const SHOW_MORE_ITEM_NAME = "__SHOWMORE__";
633
+ const MAX_FILTERS = 5;
634
+ const SnkFilterList = class {
635
+ constructor(hostRef) {
636
+ registerInstance(this, hostRef);
637
+ this.snkItemSelected = createEvent(this, "snkItemSelected", 7);
638
+ this.innerClickCheck = (floatingContainer, node) => {
639
+ if (node && floatingContainer) {
640
+ if (!node.offsetParent) {
641
+ return true;
642
+ }
643
+ let current = node;
644
+ do {
645
+ if (current === floatingContainer || current === this._element) {
646
+ return true;
647
+ }
648
+ } while ((current = current.offsetParent) != null);
649
+ }
650
+ this._detailIsVisible = false;
651
+ return false;
652
+ };
653
+ }
654
+ showList() {
655
+ this._floatingID = FloatingManager.float(this._popover, this._popoverContainer, { autoClose: true, innerClickTest: this.innerClickCheck });
656
+ this._detailIsVisible = true;
657
+ this._showAll = false;
658
+ this._filterArgument = "";
659
+ }
660
+ hideList() {
661
+ if (this._floatingID != undefined) {
662
+ FloatingManager.close(this._floatingID);
663
+ }
664
+ this._floatingID = undefined;
665
+ this._detailIsVisible = false;
666
+ }
667
+ buttonClick() {
668
+ if (this._detailIsVisible) {
669
+ this.hideList();
670
+ }
671
+ else {
672
+ this.showList();
673
+ }
674
+ }
675
+ componentDidRender() {
676
+ if (this._floatingID == undefined) {
677
+ if (this._popover) {
678
+ this._popover.remove();
679
+ }
680
+ }
681
+ }
682
+ buildItemElement(item) {
683
+ return (h("div", { 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(item.name) }, item.iconName ? h("ez-icon", { iconName: item.iconName, size: "small", class: `ez-padding-right--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-item__icon ${item.iconClass || ""}` }) : undefined, h("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 ${item.labelClass || ""}` }, item.label)));
684
+ }
685
+ itemSelected(itemName) {
686
+ if (itemName === SHOW_MORE_ITEM_NAME) {
687
+ this._showAll = true;
688
+ }
689
+ else {
690
+ this.hideList();
691
+ this.snkItemSelected.emit(itemName);
692
+ }
693
+ }
694
+ getFilterItems() {
695
+ const items = this.items ? ArrayUtils.applyStringFilter(this._filterArgument, this.items.filter(item => item.kind === "FILTER")) : [];
696
+ if (items.length === 0) {
697
+ return h("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);
698
+ }
699
+ const hideItems = !this._filterArgument && !this._showAll && (items.length > MAX_FILTERS + 1);
700
+ if (hideItems) {
701
+ items.splice(MAX_FILTERS);
702
+ items.push({ kind: "INTERNAL", label: "Mostrar mais", iconName: "dots-horizontal", name: SHOW_MORE_ITEM_NAME, iconClass: "snk-filter-bar__filter-list-item__icon--secondary", labelClass: "snk-filter-bar__filter-list-item__label--secondary" });
703
+ }
704
+ return h("div", { class: "sc-snk-filter-bar snk-filter-bar__filter-list-items-container" }, items.map(item => this.buildItemElement(item)));
705
+ }
706
+ getFooterItems() {
707
+ return this.items.filter(item => item.kind === "FOOTER");
708
+ }
709
+ render() {
710
+ return (h(Host, { class: "ez-flex ez-flex--column" }, h("ez-button", { class: this.buttonClass, label: this.label, onClick: () => this.buttonClick(), mode: this.iconName ? "icon" : undefined, iconName: this.iconName, size: "small" }, h("slot", { name: "leftIcon" })), h("section", { class: "ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container", ref: elem => this._popoverContainer = elem }, h("div", { class: "sc-snk-filter-bar snk-filter__popover ez-padding--small", ref: elem => this._popover = elem }, h("ez-filter-input", { ref: ref => this._filterInput = ref, mode: "slim", label: this.findFilterText, value: this._filterArgument, onEzChange: (evt) => this._filterArgument = evt.detail }), this.getFilterItems(), h("hr", { class: "sc-snk-filter-bar snk-filter__popover-rule" }), this.items ? this.getFooterItems().map(item => this.buildItemElement(item)) : undefined))));
711
+ }
712
+ get _element() { return getElement(this); }
713
+ };
714
+
715
+ const SnkFilterModal = class {
716
+ constructor(hostRef) {
717
+ registerInstance(this, hostRef);
718
+ }
719
+ updateValue(id, value) {
720
+ this.items = this.items.map(item => {
721
+ if (item.id === id) {
722
+ return Object.assign(Object.assign({}, item), { active: value });
723
+ }
724
+ return item;
725
+ });
726
+ }
727
+ getActiveFiltersMsg() {
728
+ const activeFilters = this.items.filter(item => item.active).length;
729
+ if (activeFilters === 0) {
730
+ return this.getMessage("snkFilterBar.noActiveFilters");
731
+ }
732
+ return this.getMessage(activeFilters > 1 ? "snkFilterBar.activeFilters" : "snkFilterBar.activeFilter", { ACTIVE_FILTERS: activeFilters });
733
+ }
734
+ getFilteredItems() {
735
+ return this.items ? ArrayUtils.applyStringFilter(this._filterArgument, this.items) : [];
736
+ }
737
+ render() {
738
+ const allowCancel = this.items.filter(item => item.active).length > 0;
739
+ return (h("ez-modal-container", { modalTitle: this.modalTitle, modalSubTitle: this.modalSubTitle, cancelButtonLabel: this.cancelButtonLabel, okButtonLabel: this.okButtonLabel, onEzModalAction: evt => this.processModalAction(evt.detail), cancelButtonStatus: allowCancel ? ModalButtonStatus.ENABLED : ModalButtonStatus.DISABLED }, h("div", { class: "sc-snk-filter-bar snk-filter-bar__filter-modal-content" }, h("div", null, this.useSearch ? h("ez-filter-input", { label: this.getMessage("snkFilterBar.modalFindFilter"), onEzChange: (evt) => this._filterArgument = evt.detail }) : undefined), this.getFilteredItems().length > 0 ? h("div", { class: "ez-text ez-text--medium ez-text--primary ez-padding-bottom--small" }, this.getActiveFiltersMsg()) : undefined, h("div", null, this.getFilteredItems().map(item => h("div", { class: "ez-padding--medium sc-snk-filter-bar snk-filter-bar__filter-modal-item ez-align--middle ez-margin-bottom--small" }, h("ez-check", { class: "sc-snk-filter-bar snk-filter-bar__filter-modal-item__check", onEzChange: evt => this.updateValue(item.id, evt.detail), enabled: item.enabled, value: item.active, mode: "switch" }), h("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" }, item.label)))), h("div", { class: "ez-text ez-text--large ez-align--middle ez-text--secondary ez-text--center ez-padding-bottom--large" }, this.infoText))));
740
+ }
741
+ };
742
+
743
+ const snkTaskbarCss = ".sc-snk-taskbar-h{display:flex}";
744
+
745
+ const SnkTaskbar = class {
746
+ constructor(hostRef) {
747
+ registerInstance(this, hostRef);
748
+ this.actionClick = createEvent(this, "actionClick", 7);
749
+ this._titleKeyByElement = {
750
+ [TaskbarElement.UPDATE]: "snkTaskbar.titleUpdate",
751
+ [TaskbarElement.PREVIOUS]: "snkTaskbar.titlePrevious",
752
+ [TaskbarElement.NEXT]: "snkTaskbar.titleNext",
753
+ [TaskbarElement.REFRESH]: "snkTaskbar.titleRefresh",
754
+ [TaskbarElement.CLONE]: "snkTaskbar.titleClone",
755
+ [TaskbarElement.REMOVE]: "snkTaskbar.titleRemove",
756
+ [TaskbarElement.MORE_OPTIONS]: "snkTaskbar.titleMoreOptions",
757
+ [TaskbarElement.INSERT]: "snkTaskbar.titleInsert",
758
+ [TaskbarElement.CANCEL]: "snkTaskbar.titleCancel",
759
+ [TaskbarElement.SAVE]: "snkTaskbar.titleSave",
760
+ [TaskbarElement.GRID_MODE]: "snkTaskbar.titleGridMode",
761
+ [TaskbarElement.CONFIG_GRID]: "snkTaskbar.titleConfigGrid",
762
+ [TaskbarElement.FORM_MODE]: "snkTaskbar.titleFormMode"
763
+ };
764
+ }
765
+ observeButtons() {
766
+ this._definitions = undefined;
767
+ }
768
+ // Internal methods
769
+ elementsFromString(strButtons) {
770
+ const elements = [];
771
+ if (strButtons) {
772
+ strButtons.split(",").forEach(buttonName => {
773
+ buttonName = buttonName.trim();
774
+ if (VisibleWhenForbidden[buttonName] || this.isAllowed(buttonName)) {
775
+ elements.push(buttonName.trim());
776
+ }
777
+ });
778
+ }
779
+ return elements;
780
+ }
781
+ isAllowed(buttonName) {
782
+ if (AuthorizationElements[buttonName]) {
783
+ return this._permissions ? this._permissions.isSup || this._permissions[buttonName] : false;
784
+ }
785
+ return true;
786
+ }
787
+ /**
788
+ * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
789
+ * através de um pequeno modulo na estrutura da aplicação:
790
+ * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
791
+ * Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-taskbar.msg.ts"
792
+ */
793
+ getTitle(element) {
794
+ let key;
795
+ if (this.isAllowed(element)) {
796
+ key = this._titleKeyByElement[element];
797
+ }
798
+ else {
799
+ key = "snkTaskbar.forbidden";
800
+ }
801
+ return key ? this._application.messagesBuilder.getMessage(key, {}) : "";
802
+ }
803
+ elementClick(elem) {
804
+ if (this.dataUnit) {
805
+ switch (elem) {
806
+ case TaskbarElement.PREVIOUS:
807
+ this.dataUnit.previousRecord();
808
+ break;
809
+ case TaskbarElement.NEXT:
810
+ this.dataUnit.nextRecord();
811
+ break;
812
+ case TaskbarElement.REFRESH:
813
+ this.dataUnit.loadData();
814
+ break;
815
+ case TaskbarElement.CLONE:
816
+ this.dataUnit.copySelected();
817
+ break;
818
+ case TaskbarElement.REMOVE:
819
+ this.dataUnit.removeSelectedRecords();
820
+ break;
821
+ case TaskbarElement.INSERT:
822
+ this.dataUnit.addRecord();
823
+ break;
824
+ case TaskbarElement.CANCEL:
825
+ this.dataUnit.cancelEdition();
826
+ break;
827
+ case TaskbarElement.SAVE:
828
+ this.dataUnit.saveData();
829
+ break;
830
+ }
831
+ }
832
+ this.actionClick.emit(elem);
833
+ }
834
+ isEnabled(elem) {
835
+ if (!this.isAllowed(elem)) {
836
+ return false;
837
+ }
838
+ return !(this.disabledButtons && this.disabledButtons.includes(elem));
839
+ }
840
+ getElement(index, def) {
841
+ let className = def === this.primaryButton ? "ez-button--primary " : "";
842
+ if (index > 1) {
843
+ className += "ez-padding-left--medium";
844
+ }
845
+ if (TaskbarElement[def.toString()]) {
846
+ return buildElem(def, className, elem => this.getTitle(elem), elem => this.elementClick(elem), elem => this.isEnabled(elem), this.actionsList);
847
+ }
848
+ else {
849
+ return buildCustomButton(def, className, elem => this.elementClick(elem), elem => this.isEnabled(elem));
850
+ }
851
+ }
852
+ // Lifecycle
853
+ componentWillLoad() {
854
+ this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
855
+ if (this._application) {
856
+ this._application.getAllAccess().then(access => this._permissions = access);
857
+ }
858
+ else {
859
+ this._permissions = {};
860
+ }
861
+ }
862
+ componentWillRender() {
863
+ if (this._definitions == undefined && this._permissions) {
864
+ this._definitions = this.elementsFromString(this.buttons);
865
+ }
866
+ }
867
+ render() {
868
+ if (this._definitions === undefined) {
869
+ return undefined;
870
+ }
871
+ let index = 0;
872
+ return (h(Host, null, this._definitions.map((elem) => {
873
+ if (elem === TaskbarElement.DIVIDER) {
874
+ index = 0;
875
+ }
876
+ else {
877
+ index++;
878
+ }
879
+ if (TaskbarElement[elem]) {
880
+ return this.getElement(index, TaskbarElement[elem]);
881
+ }
882
+ if (this.customButtons.has(elem)) {
883
+ return this.getElement(index, this.customButtons.get(elem));
884
+ }
885
+ return h("slot", { name: elem });
886
+ })));
887
+ }
888
+ static get watchers() { return {
889
+ "buttons": ["observeButtons"]
890
+ }; }
891
+ };
892
+ SnkTaskbar.style = snkTaskbarCss;
893
+
894
+ export { SnkFilterBar as snk_filter_bar, SnkFilterItem as snk_filter_item, SnkFilterList as snk_filter_list, SnkFilterModal as snk_filter_modal, SnkTaskbar as snk_taskbar };