@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-75070.0 → 0.0.0-bugfix-dev-KB-77074.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/dist/cjs/{SnkMessageBuilder-bae64d0d.js → SnkMessageBuilder-7691a2c1.js} +10 -0
  2. package/dist/cjs/index-f9e81701.js +8 -0
  3. package/dist/cjs/input-distinct-search_2.cjs.entry.js +469 -0
  4. package/dist/cjs/loader.cjs.js +1 -1
  5. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  6. package/dist/cjs/snk-actions-button_4.cjs.entry.js +22 -25
  7. package/dist/cjs/snk-application.cjs.entry.js +1 -11
  8. package/dist/cjs/snk-crud.cjs.entry.js +2 -8
  9. package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
  10. package/dist/cjs/{snk-data-unit-3d9b6ed4.js → snk-data-unit-7dbdad0e.js} +14 -26
  11. package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
  12. package/dist/cjs/snk-detail-view.cjs.entry.js +1 -1
  13. package/dist/cjs/snk-distinct-search.cjs.entry.js +123 -0
  14. package/dist/cjs/snk-filter-bar_4.cjs.entry.js +0 -3
  15. package/dist/cjs/snk-grid.cjs.entry.js +2 -10
  16. package/dist/cjs/snk-simple-crud.cjs.entry.js +4 -39
  17. package/dist/cjs/snk-taskbar.cjs.entry.js +35 -37
  18. package/dist/collection/collection-manifest.json +3 -0
  19. package/dist/collection/components/snk-actions-button/snk-actions-button.js +26 -27
  20. package/dist/collection/components/snk-application/snk-application.js +1 -41
  21. package/dist/collection/components/snk-crud/snk-crud.js +2 -26
  22. package/dist/collection/components/snk-data-unit/snk-data-unit.js +13 -25
  23. package/dist/collection/components/snk-distinct-search/snk-distinct-search.css +4 -0
  24. package/dist/collection/components/snk-distinct-search/snk-distinct-search.js +372 -0
  25. package/dist/collection/components/snk-distinct-search/subcomponents/input-distinct-search/input-distinct-search.css +109 -0
  26. package/dist/collection/components/snk-distinct-search/subcomponents/input-distinct-search/input-distinct-search.js +542 -0
  27. package/dist/collection/components/snk-distinct-search/subcomponents/search-modal/search-modal.css +27 -0
  28. package/dist/collection/components/snk-distinct-search/subcomponents/search-modal/search-modal.js +600 -0
  29. package/dist/collection/components/snk-distinct-search/utils/filter-distinct-search.js +13 -0
  30. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +0 -18
  31. package/dist/collection/components/snk-grid/snk-grid.js +2 -28
  32. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +5 -58
  33. package/dist/collection/components/snk-taskbar/snk-taskbar.js +36 -38
  34. package/dist/collection/lib/http/data-fetcher/fetchers/distinct-search-fetcher.js +25 -0
  35. package/dist/collection/lib/message/SnkMessageBuilder.js +2 -0
  36. package/dist/collection/lib/message/resources/snk-distinct-search.msg.js +9 -0
  37. package/dist/components/SnkMessageBuilder.js +10 -0
  38. package/dist/components/filter-distinct-search.js +15 -0
  39. package/dist/components/index.d.ts +3 -0
  40. package/dist/components/index.js +3 -0
  41. package/dist/components/input-distinct-search.d.ts +11 -0
  42. package/dist/components/input-distinct-search.js +6 -0
  43. package/dist/components/input-distinct-search2.js +262 -0
  44. package/dist/components/search-modal.d.ts +11 -0
  45. package/dist/components/search-modal.js +6 -0
  46. package/dist/components/search-modal2.js +264 -0
  47. package/dist/components/snk-actions-button2.js +26 -27
  48. package/dist/components/snk-application2.js +1 -12
  49. package/dist/components/snk-crud.js +2 -9
  50. package/dist/components/snk-data-unit2.js +13 -25
  51. package/dist/components/snk-distinct-search.d.ts +11 -0
  52. package/dist/components/snk-distinct-search.js +163 -0
  53. package/dist/components/snk-filter-bar2.js +0 -4
  54. package/dist/components/snk-grid2.js +2 -11
  55. package/dist/components/snk-simple-crud2.js +5 -41
  56. package/dist/components/snk-taskbar2.js +36 -38
  57. package/dist/esm/{SnkMessageBuilder-6fff4a4c.js → SnkMessageBuilder-7ace6803.js} +10 -0
  58. package/dist/esm/index-a7d3d3f1.js +8 -0
  59. package/dist/esm/input-distinct-search_2.entry.js +464 -0
  60. package/dist/esm/loader.js +1 -1
  61. package/dist/esm/sankhyablocks.js +1 -1
  62. package/dist/esm/snk-actions-button_4.entry.js +23 -26
  63. package/dist/esm/snk-application.entry.js +2 -12
  64. package/dist/esm/snk-crud.entry.js +2 -8
  65. package/dist/esm/snk-data-exporter.entry.js +2 -2
  66. package/dist/esm/{snk-data-unit-9fa7d2b9.js → snk-data-unit-7a579dbd.js} +14 -26
  67. package/dist/esm/snk-data-unit.entry.js +2 -2
  68. package/dist/esm/snk-detail-view.entry.js +1 -1
  69. package/dist/esm/snk-distinct-search.entry.js +119 -0
  70. package/dist/esm/snk-filter-bar_4.entry.js +0 -3
  71. package/dist/esm/snk-grid.entry.js +2 -10
  72. package/dist/esm/snk-simple-crud.entry.js +5 -40
  73. package/dist/esm/snk-taskbar.entry.js +36 -38
  74. package/dist/sankhyablocks/{p-7075b789.entry.js → p-00f9fe5c.entry.js} +1 -1
  75. package/dist/sankhyablocks/p-0e250436.entry.js +1 -0
  76. package/dist/sankhyablocks/p-154aa2a6.entry.js +11 -0
  77. package/dist/sankhyablocks/p-18cb1acb.entry.js +1 -0
  78. package/dist/sankhyablocks/p-1dbd5c18.entry.js +1 -0
  79. package/dist/sankhyablocks/p-2aae03a1.entry.js +1 -0
  80. package/dist/sankhyablocks/p-37074cc3.entry.js +1 -0
  81. package/dist/sankhyablocks/p-3858a2e4.entry.js +1 -0
  82. package/dist/sankhyablocks/p-563b7c28.entry.js +1 -0
  83. package/dist/sankhyablocks/{p-43353d86.entry.js → p-b389ed49.entry.js} +1 -1
  84. package/dist/sankhyablocks/p-c75fae8e.js +1 -0
  85. package/dist/sankhyablocks/p-d8665750.js +1 -0
  86. package/dist/sankhyablocks/p-f0aaad2b.entry.js +1 -0
  87. package/dist/sankhyablocks/{p-0d2a2e9e.entry.js → p-f4e221b2.entry.js} +1 -1
  88. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  89. package/dist/types/components/snk-actions-button/snk-actions-button.d.ts +2 -3
  90. package/dist/types/components/snk-application/snk-application.d.ts +1 -6
  91. package/dist/types/components/snk-crud/snk-crud.d.ts +0 -4
  92. package/dist/types/components/snk-distinct-search/snk-distinct-search.d.ts +83 -0
  93. package/dist/types/components/snk-distinct-search/subcomponents/input-distinct-search/input-distinct-search.d.ts +105 -0
  94. package/dist/types/components/snk-distinct-search/subcomponents/search-modal/search-modal.d.ts +126 -0
  95. package/dist/types/components/snk-distinct-search/types/index.d.ts +8 -0
  96. package/dist/types/components/snk-distinct-search/utils/filter-distinct-search.d.ts +3 -0
  97. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +0 -4
  98. package/dist/types/components/snk-grid/snk-grid.d.ts +0 -4
  99. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +0 -3
  100. package/dist/types/components.d.ts +393 -31
  101. package/dist/types/lib/http/data-fetcher/fetchers/distinct-search-fetcher.d.ts +6 -0
  102. package/dist/types/lib/message/resources/snk-distinct-search.msg.d.ts +2 -0
  103. package/package.json +1 -1
  104. package/react/components.d.ts +3 -0
  105. package/react/components.js +3 -0
  106. package/react/components.js.map +1 -1
  107. package/dist/sankhyablocks/p-17425c72.js +0 -1
  108. package/dist/sankhyablocks/p-200a5481.entry.js +0 -11
  109. package/dist/sankhyablocks/p-342eeb3b.js +0 -1
  110. package/dist/sankhyablocks/p-520c7c38.entry.js +0 -1
  111. package/dist/sankhyablocks/p-83e71703.entry.js +0 -1
  112. package/dist/sankhyablocks/p-a3fadd0b.entry.js +0 -1
  113. package/dist/sankhyablocks/p-ac26df7a.entry.js +0 -1
  114. package/dist/sankhyablocks/p-af7f7b3e.entry.js +0 -1
  115. package/dist/sankhyablocks/p-c51ad0e7.entry.js +0 -1
  116. package/dist/types/components/snk-actions-button/interfaces/index.d.ts +0 -3
  117. /package/dist/collection/components/{snk-actions-button/interfaces → snk-distinct-search/types}/index.js +0 -0
@@ -0,0 +1,262 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h, Fragment, Host } from '@stencil/core/internal/client';
2
+ import { KeyboardManager } from '@sankhyalabs/core';
3
+ import { f as filterItems, n as normalizeString, g as getMatchOption } from './filter-distinct-search.js';
4
+
5
+ const inputDistinctSearchCss = ":host{--max-height-popover:180px;--scrollbar--color-default:var(--scrollbar--default, #626e82);--scrollbar--color-background:var(--scrollbar--background, #E5EAF0);--scrollbar--color-hover:var(--scrollbar--hover, #2B3A54);--scrollbar--color-clicked:var(--scrollbar--clicked, #a2abb9);--scrollbar--border-radius:var(--border--radius-small, 6px);--scrollbar--width:var(--space--medium, 12px)}.divider{margin:var(--space--extra-small, 3px) 0;border:var(--border--small, 1px solid) var(--color--disable-secondary, #F2F5F8)}.new-value{color:var(--text--primary, #626e82);padding:var(--space--2xs, 8px) var(--space--3xs, 4px);font-size:var(--text--medium, 14px);font-family:var(--font-pattern, Roboto);cursor:pointer;border-radius:var(--border--radius-small, 6px);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border:none;background:none;width:100%;display:flex;min-height:max-content}.new-value-selected{background-color:var(--color--primary-300, #E2F4EF)}.new-value:hover{background-color:var(--background--medium, #e0e0e0)}.popover-content{margin:var(--space--2xs, 6px);max-height:var(--max-height-popover);display:flex;flex-direction:column}.list-container{overflow:auto;scrollbar-width:thin;scrollbar-color:var(--scrollbar--color-clicked) var(--scrollbar--color-background)}.list-container::-webkit-scrollbar{background-color:var(--scrollbar--color-background);width:var(--scrollbar--width);max-width:var(--scrollbar--width);min-width:var(--scrollbar--width)}.list-container::-webkit-scrollbar-track{background-color:var(--scrollbar--color-background);border-radius:var(--scrollbar--border-radius)}.list-container::-webkit-scrollbar-thumb{background-color:var(--scrollbar--color-default);border-radius:var(--scrollbar--border-radius)}.list-container::-webkit-scrollbar-thumb:vertical:hover,.list-container::-webkit-scrollbar-thumb:horizontal:hover{background-color:var(--scrollbar--color-hover)}.list-container::-webkit-scrollbar-thumb:vertical:active,.list-container::-webkit-scrollbar-thumb:horizontal:active{background-color:var(--scrollbar--color-clicked)}ez-popover{--ez-popover__box--z-index:15}.space-error{--ez-popover__margin:-19px 0 0 0}ez-list{--ez-list__item--margin:0}ez-text-input{--ez-text-input__icon--margin:var(--space--xs, 12px)}.badge-primary{--ez-badge--background-color:var(--color--primary-300);--ez-badge--color:var(--color--primary)}";
6
+
7
+ const InputDistinctSearch = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
8
+ constructor() {
9
+ super();
10
+ this.__registerHost();
11
+ this.__attachShadow();
12
+ this.changeValue = createEvent(this, "changeValue", 7);
13
+ this.iconClick = createEvent(this, "iconClick", 7);
14
+ this.textValue = "";
15
+ this.isNewItem = false;
16
+ this.filteredItems = [];
17
+ this.isNewItemSelected = false;
18
+ this.application = undefined;
19
+ this.distinctItems = [];
20
+ this.label = "";
21
+ this.value = "";
22
+ this.maxItems = 100;
23
+ this.debounceTime = 300;
24
+ this.canShowError = false;
25
+ this.mode = 'regular';
26
+ this.restrict = undefined;
27
+ this.errorMessage = undefined;
28
+ }
29
+ async observerValue(newValue) {
30
+ await this.selectedNewItem(newValue, true);
31
+ }
32
+ /**
33
+ * Seleciona um item
34
+ */
35
+ async selectValue(value, isNewItem = false) {
36
+ this.isNewItem = isNewItem;
37
+ this.textValue = value;
38
+ await this._refFilterInput.setValue(value);
39
+ }
40
+ /**
41
+ * Método para limpa o campo de entrada de pesquisa
42
+ */
43
+ clearInput() {
44
+ this._refFilterInput.setValue("");
45
+ }
46
+ /**
47
+ * Retorna se o conteúdo é inválido.
48
+ */
49
+ isInvalid() {
50
+ return this._refFilterInput.isInvalid();
51
+ }
52
+ /**
53
+ * Remove o foco do campo
54
+ */
55
+ setBlur() {
56
+ this._refFilterInput.setBlur();
57
+ }
58
+ /**
59
+ * Aplica o foco do campo
60
+ */
61
+ setFocus() {
62
+ this._refFilterInput.setFocus();
63
+ }
64
+ getMessage(key) {
65
+ return this.application.messagesBuilder.getMessage(key, null);
66
+ }
67
+ async optionLoader(searchArgument) {
68
+ return new Promise((resolve) => {
69
+ if (this._debounceTimeout) {
70
+ clearTimeout(this._debounceTimeout);
71
+ }
72
+ this._debounceTimeout = setTimeout(() => {
73
+ this.filteredItems = filterItems(searchArgument, this.distinctItems, this.maxItems);
74
+ resolve();
75
+ }, this.debounceTime);
76
+ });
77
+ }
78
+ async openPopOver() {
79
+ var _a;
80
+ await ((_a = this._refPopOver) === null || _a === void 0 ? void 0 : _a.showUnder(this._refFilterInput));
81
+ }
82
+ async closePopOver() {
83
+ var _a;
84
+ this.isNewItemSelected = false;
85
+ await ((_a = this._refPopOver) === null || _a === void 0 ? void 0 : _a.hide());
86
+ await this._refList.removeSelection();
87
+ }
88
+ async onTextChange(event) {
89
+ this.textValue = event.detail;
90
+ await this.optionLoader(event.detail);
91
+ await this.selectFirstItem();
92
+ }
93
+ onIconClick() {
94
+ this.iconClick.emit();
95
+ }
96
+ buidItems() {
97
+ var _a;
98
+ const items = (_a = this.filteredItems) === null || _a === void 0 ? void 0 : _a.map((item) => ({
99
+ label: item,
100
+ id: normalizeString(item),
101
+ }));
102
+ return items;
103
+ }
104
+ async setValue(value, isNewItem = false, preventEventEmit = false) {
105
+ this.isNewItem = isNewItem;
106
+ this.textValue = value;
107
+ await this._refFilterInput.setValue(value);
108
+ await this.closePopOver();
109
+ if (!preventEventEmit) {
110
+ this.changeValue.emit({
111
+ value,
112
+ isNewItem,
113
+ });
114
+ }
115
+ }
116
+ async selectedNewItem(value, preventEventEmit = false) {
117
+ if (!this.textValue && !value) {
118
+ await this.setValue("", false, preventEventEmit);
119
+ return;
120
+ }
121
+ const item = getMatchOption(value !== null && value !== void 0 ? value : this.textValue, this.distinctItems);
122
+ if (item) {
123
+ await this.setValue(item, false, preventEventEmit);
124
+ return;
125
+ }
126
+ await this.setValue(this.textValue || value, true, preventEventEmit);
127
+ }
128
+ async setSelectedValue() {
129
+ const selectedValue = await this._refList.getSelection();
130
+ await this.selectedNewItem((selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.label) || this.textValue, true);
131
+ await this._refFilterInput.setBlur();
132
+ this._element.focus();
133
+ }
134
+ async selectNextItem() {
135
+ if (this.isNewItemSelected) {
136
+ return;
137
+ }
138
+ const itemSelected = await this._refList.getSelection();
139
+ const itemsAmount = this.filteredItems.length;
140
+ const indexSelected = this.filteredItems.findIndex((item) => item === (itemSelected === null || itemSelected === void 0 ? void 0 : itemSelected.label));
141
+ const isLastItemSelected = indexSelected === (itemsAmount - 1);
142
+ const optionNewItemIsAvailable = !!this.textValue;
143
+ if (!isLastItemSelected || !optionNewItemIsAvailable) {
144
+ this.isNewItemSelected = false;
145
+ await this._refList.selectNextItem();
146
+ return;
147
+ }
148
+ this.isNewItemSelected = true;
149
+ await this._refList.removeSelection();
150
+ }
151
+ async selectPreviousItem() {
152
+ const itemsAmount = this.filteredItems.length;
153
+ const lastItem = this.filteredItems[itemsAmount - 1];
154
+ if (this.isNewItemSelected && lastItem) {
155
+ this.isNewItemSelected = false;
156
+ await this._refList.setSelection({
157
+ id: normalizeString(lastItem),
158
+ label: lastItem
159
+ });
160
+ return;
161
+ }
162
+ await this._refList.selectPreviousItem();
163
+ }
164
+ bindKeyboardManager() {
165
+ this._keyboardManager = new KeyboardManager({ propagate: false, element: this._element });
166
+ this._keyboardManager
167
+ .bind("ArrowDown", () => { this.selectNextItem(); })
168
+ .bind("ArrowUp", () => { this.selectPreviousItem(); })
169
+ .bind("Enter", () => { this.setSelectedValue(); })
170
+ .bind("Tab", () => { this.setSelectedValue(); });
171
+ }
172
+ unbindKeyboardManager() {
173
+ this._keyboardManager
174
+ .unbind("ArrowDown")
175
+ .unbind("ArrowUp")
176
+ .unbind("Enter")
177
+ .unbind("Tab");
178
+ }
179
+ async selectFirstItem() {
180
+ if (!this.filteredItems.length) {
181
+ await this._refList.removeSelection();
182
+ this.isNewItemSelected = true;
183
+ return;
184
+ }
185
+ const firstItem = this.filteredItems[0];
186
+ this.isNewItemSelected = false;
187
+ await this._refList.setSelection({
188
+ id: normalizeString(firstItem),
189
+ label: firstItem,
190
+ });
191
+ }
192
+ initializeComponent() {
193
+ this.filteredItems = this.distinctItems;
194
+ }
195
+ componentWillLoad() {
196
+ this.initializeComponent();
197
+ }
198
+ async componentDidLoad() {
199
+ this.bindKeyboardManager();
200
+ this.selectFirstItem();
201
+ await this.selectedNewItem(this.value, true);
202
+ }
203
+ disconnectedCallback() {
204
+ this.unbindKeyboardManager();
205
+ }
206
+ buildNewItemOption() {
207
+ if (!this.textValue) {
208
+ return;
209
+ }
210
+ return (h(Fragment, null, !!this.filteredItems.length &&
211
+ h("hr", { class: "divider" }), h("button", { slot: "bottomSlot", class: {
212
+ "new-value": true,
213
+ "new-value-selected": this.isNewItemSelected,
214
+ }, title: `${this.getMessage("snkDistinctSearch.titleAdd")} '${this.textValue}'`, onClick: () => this.selectedNewItem.bind(this)(undefined, true) }, this.getMessage("snkDistinctSearch.titleAdd"), " '", this.textValue, "'")));
215
+ }
216
+ render() {
217
+ return (h(Host, { onBlur: () => this.selectedNewItem.bind(this)() }, h("ez-filter-input", { ref: (ref) => this._refFilterInput = ref, label: this.label, value: this.textValue, onEzChange: this.onTextChange.bind(this), onEzIconClick: this.onIconClick.bind(this), onEzFocusIn: this.openPopOver.bind(this), canShowError: this.canShowError, mode: this.mode, restrict: this.restrict, errorMessage: this.errorMessage, enabledIconClick: true }, this.isNewItem &&
218
+ h("ez-badge", { slot: "right", label: this.getMessage("snkDistinctSearch.titleBadgeNew"), size: "small-medium", class: "badge-primary" })), h("ez-popover", { ref: (ref) => this._refPopOver = ref, boxWidth: "full-width", autoClose: false, overlayType: "none", class: {
219
+ 'space-error': this.canShowError,
220
+ } }, h("div", { class: "popover-content" }, h("section", { class: "list-container" }, h("ez-list", { ref: (ref) => this._refList = ref, dataSource: this.buidItems(), onEzClickItem: ({ detail }) => this.setValue.bind(this)(detail.label, false, true), ezSelectable: true, hoverFeedback: true, disableShortcuts: true })), this.buildNewItemOption()))));
221
+ }
222
+ get _element() { return this; }
223
+ static get watchers() { return {
224
+ "value": ["observerValue"]
225
+ }; }
226
+ static get style() { return inputDistinctSearchCss; }
227
+ }, [1, "input-distinct-search", {
228
+ "application": [16],
229
+ "distinctItems": [16],
230
+ "label": [1],
231
+ "value": [1],
232
+ "maxItems": [2, "max-items"],
233
+ "debounceTime": [2, "debounce-time"],
234
+ "canShowError": [4, "can-show-error"],
235
+ "mode": [1],
236
+ "restrict": [1],
237
+ "errorMessage": [1, "error-message"],
238
+ "textValue": [32],
239
+ "isNewItem": [32],
240
+ "filteredItems": [32],
241
+ "isNewItemSelected": [32],
242
+ "selectValue": [64],
243
+ "clearInput": [64],
244
+ "isInvalid": [64],
245
+ "setBlur": [64],
246
+ "setFocus": [64]
247
+ }]);
248
+ function defineCustomElement() {
249
+ if (typeof customElements === "undefined") {
250
+ return;
251
+ }
252
+ const components = ["input-distinct-search"];
253
+ components.forEach(tagName => { switch (tagName) {
254
+ case "input-distinct-search":
255
+ if (!customElements.get(tagName)) {
256
+ customElements.define(tagName, InputDistinctSearch);
257
+ }
258
+ break;
259
+ } });
260
+ }
261
+
262
+ export { InputDistinctSearch as I, defineCustomElement as d };
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface SearchModal extends Components.SearchModal, HTMLElement {}
4
+ export const SearchModal: {
5
+ prototype: SearchModal;
6
+ new (): SearchModal;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,6 @@
1
+ import { S as SearchModal$1, d as defineCustomElement$1 } from './search-modal2.js';
2
+
3
+ const SearchModal = SearchModal$1;
4
+ const defineCustomElement = defineCustomElement$1;
5
+
6
+ export { SearchModal, defineCustomElement };
@@ -0,0 +1,264 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
+ import { EzScrollDirection } from '@sankhyalabs/ezui/dist/collection/components/ez-scroller/EzScrollDirection';
3
+ import { KeyboardManager } from '@sankhyalabs/core';
4
+ import { f as filterItems, n as normalizeString, g as getMatchOption } from './filter-distinct-search.js';
5
+
6
+ const searchModalCss = ".sc-search-modal-h{display:block}ez-popup.sc-search-modal{--ez-popup__title--font-size:var(--title--large, 20px)}.search-modal-scroller.sc-search-modal{height:174px}.search-modal-text.sc-search-modal{font-family:var(--font-pattern);color:var(--text--primary);font-size:var(--text--medium)}ez-filter-input.sc-search-modal>input.sc-search-modal{text-overflow:ellipsis}.ez-content.sc-search-modal{height:190px;display:flex;align-items:center;justify-content:center}";
7
+
8
+ const SearchModal = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
9
+ constructor() {
10
+ super();
11
+ this.__registerHost();
12
+ this.popupClose = createEvent(this, "popupClose", 7);
13
+ this.changeValue = createEvent(this, "changeValue", 7);
14
+ this._searchFocus = false;
15
+ this.debounceTimeout = null;
16
+ this.filteredItems = [];
17
+ this.application = undefined;
18
+ this.listItens = [];
19
+ this.opened = false;
20
+ this.value = undefined;
21
+ this.canShowError = false;
22
+ this.emptyMessage = undefined;
23
+ this.debounceTime = 300;
24
+ this.maxItens = 100;
25
+ this.label = 'Pesquisar';
26
+ this.mode = 'regular';
27
+ this.restrict = undefined;
28
+ this.errorMessage = undefined;
29
+ }
30
+ /**
31
+ * Método para adicionar a nova palavra e chamar o método closeModal() para fechar o modal
32
+ */
33
+ addNewItem() {
34
+ this.closeModal();
35
+ this.changeValue.emit({ isNewItem: true, value: this.value });
36
+ }
37
+ /**
38
+ * Método para limpa o campo de entrada de pesquisa
39
+ */
40
+ clearInput() {
41
+ this._refFilterInput.setValue("");
42
+ }
43
+ /**
44
+ * Método para fechar o modal
45
+ */
46
+ closeModal() {
47
+ this._popupElement.opened = false;
48
+ this.popupClose.emit(false);
49
+ }
50
+ /**
51
+ * Método para abrir o modal
52
+ */
53
+ openModal() {
54
+ this._popupElement.opened = true;
55
+ setTimeout(() => this.setFocus(), 100);
56
+ }
57
+ /**
58
+ * Retorna se o conteúdo é inválido.
59
+ */
60
+ isInvalid() {
61
+ this._refFilterInput.isInvalid();
62
+ }
63
+ /**
64
+ * Remove o foco do campo
65
+ */
66
+ async setBlur() {
67
+ this._searchFocus = false;
68
+ }
69
+ /**
70
+ * Aplica o foco do campo
71
+ */
72
+ async setFocus() {
73
+ this._searchFocus = true;
74
+ await this._refFilterInput.setFocus();
75
+ }
76
+ /**
77
+ * Método para tratar a mensagem de erro
78
+ */
79
+ watchPropErrorMessage() {
80
+ this._refFilterInput.errorMessage = this.errorMessage;
81
+ }
82
+ /**
83
+ * Método para tratar o value do input
84
+ */
85
+ watchPropValue() {
86
+ this._refFilterInput.value = this.value;
87
+ }
88
+ /**
89
+ * Atualiza a lista de itens à medida que o usuário digita no campo de pesquisa.
90
+ */
91
+ async handleInput(event) {
92
+ var _a;
93
+ if (this.debounceTimeout) {
94
+ clearTimeout(this.debounceTimeout);
95
+ }
96
+ this.value = event.detail;
97
+ await ((_a = this._refList) === null || _a === void 0 ? void 0 : _a.removeSelection());
98
+ this.debounceTimeout = setTimeout(() => {
99
+ this.filteredItems = filterItems(event.detail, this.listItens, this.maxItens);
100
+ }, this.debounceTime);
101
+ }
102
+ initializeComponent() {
103
+ this.filteredItems = this.listItens;
104
+ }
105
+ getMessage(key) {
106
+ return this.application.messagesBuilder.getMessage(key, null);
107
+ }
108
+ componentWillLoad() {
109
+ this.initializeComponent();
110
+ }
111
+ componentDidLoad() {
112
+ this.bindKeyboardManager();
113
+ this._refFilterInput.value = this.value;
114
+ this.filteredItems = filterItems(this.value, this.listItens, this.maxItens);
115
+ }
116
+ disconnectedCallback() {
117
+ this.unbindKeyboardManager();
118
+ }
119
+ buildItems() {
120
+ var _a;
121
+ const items = (_a = this.filteredItems) === null || _a === void 0 ? void 0 : _a.map((item) => ({
122
+ label: item,
123
+ id: normalizeString(item),
124
+ }));
125
+ return items;
126
+ }
127
+ async tabSelect() {
128
+ var _a;
129
+ const selectedValue = await this._refList.getSelection();
130
+ if (this._searchFocus) {
131
+ await this.setBlur();
132
+ await this.selectFirstItem();
133
+ }
134
+ else if (selectedValue) {
135
+ await ((_a = this._refList) === null || _a === void 0 ? void 0 : _a.removeSelection());
136
+ await this._refButton.setFocus();
137
+ }
138
+ else {
139
+ await this._refButton.setBlur();
140
+ await this.setFocus();
141
+ }
142
+ }
143
+ bindKeyboardManager() {
144
+ this._keyboardManager = new KeyboardManager({ propagate: false, element: this._element });
145
+ this._keyboardManager
146
+ .bind("ArrowDown", () => { this.selectNextItem(); })
147
+ .bind("ArrowUp", () => { this.selectPreviousItem(); })
148
+ .bind("Enter", () => { this.setSelectedValue(); })
149
+ .bind("Tab", () => { this.tabSelect(); });
150
+ }
151
+ unbindKeyboardManager() {
152
+ this._keyboardManager
153
+ .unbind("ArrowDown")
154
+ .unbind("ArrowUp")
155
+ .unbind("Enter")
156
+ .unbind("Tab");
157
+ }
158
+ async setSelectedValue() {
159
+ var _a;
160
+ const selectedValue = await ((_a = this._refList) === null || _a === void 0 ? void 0 : _a.getSelection());
161
+ if (selectedValue) {
162
+ this.changeValue.emit({ isNewItem: false, value: selectedValue.label });
163
+ this.closeModal();
164
+ }
165
+ else if (this.enabledButtonNewItem()) {
166
+ this.addNewItem();
167
+ }
168
+ }
169
+ async selectNextItem() {
170
+ var _a;
171
+ if (this._searchFocus) {
172
+ this.setBlur();
173
+ }
174
+ if (!this._refList) {
175
+ await this._refButton.setFocus();
176
+ return;
177
+ }
178
+ await ((_a = this._refList) === null || _a === void 0 ? void 0 : _a.selectNextItem());
179
+ }
180
+ async selectPreviousItem() {
181
+ var _a;
182
+ const itemSelected = await ((_a = this._refList) === null || _a === void 0 ? void 0 : _a.getSelection());
183
+ if (!itemSelected) {
184
+ return;
185
+ }
186
+ if (itemSelected.label === this.filteredItems[0]) {
187
+ await this._refList.removeSelection();
188
+ await this._refFilterInput.setFocus();
189
+ return;
190
+ }
191
+ await this._refList.selectPreviousItem();
192
+ }
193
+ async selectFirstItem() {
194
+ var _a;
195
+ if (!this.filteredItems.length) {
196
+ await ((_a = this._refList) === null || _a === void 0 ? void 0 : _a.removeSelection());
197
+ return;
198
+ }
199
+ const firstItem = this.filteredItems[0];
200
+ await this._refList.setSelection({
201
+ id: normalizeString(firstItem),
202
+ label: firstItem,
203
+ });
204
+ }
205
+ enabledButtonNewItem() {
206
+ if (this.value === undefined)
207
+ return false;
208
+ if (getMatchOption(this.value, this.listItens))
209
+ return false;
210
+ return this.value.trim().length === 0 ? false : true;
211
+ }
212
+ async handleActionPopUp({ detail }) {
213
+ if (detail === "OK") {
214
+ await this.setSelectedValue();
215
+ }
216
+ }
217
+ render() {
218
+ var _a;
219
+ return (h(Host, null, h("ez-popup", { ref: (ref) => this._popupElement = ref, size: "x-small", "ez-title": this.label, onEzClosePopup: () => this.popupClose.emit(false), "height-mode": "auto", onEzPopupAction: this.handleActionPopUp.bind(this) }, h("div", null, h("ez-filter-input", { ref: (ref) => this._refFilterInput = ref, label: "Pesquisar", onEzChange: this.handleInput.bind(this), onBlur: () => this._searchFocus = false, onEzFocusIn: () => this._searchFocus = true, errorMessage: this.errorMessage, canShowError: this.canShowError, mode: this.mode, value: this.value, restrict: this.restrict }), this.buildItems().length === 0 ? (h("div", { class: "ez-content" }, h("div", { class: "ez-text--center search-modal-text" }, this.emptyMessage))) : (h("div", null, h("div", { class: "search-modal-text ez-padding-vertical--medium" }, this.listItens.length > this.maxItens ? this.getMessage("snkDistinctSearch.limitResult") :
220
+ this.buildItems().length, " ", this.buildItems().length > 1 ? this.getMessage("snkDistinctSearch.availableResults") : this.getMessage("snkDistinctSearch.availableResult")), h("ez-scroller", { class: "search-modal-scroller", direction: EzScrollDirection.VERTICAL }, h("ez-list", { ref: (ref) => this._refList = ref, dataSource: this.buildItems(), onEzClickItem: ({ label }) => this.setSelectedValue.bind(this)(label), ezSelectable: true, hoverFeedback: true, disableShortcuts: true })))), h("div", { class: "ez-flex ez-flex--justify-end" }, h("ez-button", { ref: (ref) => this._refButton = ref, class: "ez-button--tertiary", enabled: this.enabledButtonNewItem(), label: `${this.getMessage("snkDistinctSearch.titleAdd")} ${(_a = this.label) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase()}`, onClick: () => this.addNewItem() }))))));
221
+ }
222
+ get _element() { return this; }
223
+ static get watchers() { return {
224
+ "errorMessage": ["watchPropErrorMessage"],
225
+ "value": ["watchPropValue"]
226
+ }; }
227
+ static get style() { return searchModalCss; }
228
+ }, [2, "search-modal", {
229
+ "application": [16],
230
+ "listItens": [1040],
231
+ "opened": [1540],
232
+ "value": [1],
233
+ "canShowError": [4, "can-show-error"],
234
+ "emptyMessage": [1, "empty-message"],
235
+ "debounceTime": [2, "debounce-time"],
236
+ "maxItens": [2, "max-itens"],
237
+ "label": [1],
238
+ "mode": [1],
239
+ "restrict": [1],
240
+ "errorMessage": [1, "error-message"],
241
+ "filteredItems": [32],
242
+ "addNewItem": [64],
243
+ "clearInput": [64],
244
+ "closeModal": [64],
245
+ "openModal": [64],
246
+ "isInvalid": [64],
247
+ "setBlur": [64],
248
+ "setFocus": [64]
249
+ }]);
250
+ function defineCustomElement() {
251
+ if (typeof customElements === "undefined") {
252
+ return;
253
+ }
254
+ const components = ["search-modal"];
255
+ components.forEach(tagName => { switch (tagName) {
256
+ case "search-modal":
257
+ if (!customElements.get(tagName)) {
258
+ customElements.define(tagName, SearchModal);
259
+ }
260
+ break;
261
+ } });
262
+ }
263
+
264
+ export { SearchModal as S, defineCustomElement as d };
@@ -1,5 +1,5 @@
1
1
  import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
2
- import { ApplicationContext, StringUtils, ErrorException, WarningException, ObjectUtils, DateUtils, ServiceUtils, StorageType, ArrayUtils, ElementIDUtils } from '@sankhyalabs/core';
2
+ import { ApplicationContext, StringUtils, ErrorException, WarningException, ObjectUtils, DateUtils, ArrayUtils, ElementIDUtils } from '@sankhyalabs/core';
3
3
  import { D as DataFetcher } from './DataFetcher.js';
4
4
  import { P as ParamType } from './ParamType.js';
5
5
  import './pesquisa-fetcher.js';
@@ -598,7 +598,6 @@ const SnkActionsButton = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
598
598
  super();
599
599
  this.__registerHost();
600
600
  this.CLIENT_EVENT_CONFIRM_NAME = "br.com.sankhya.actionbutton.clientconfirm";
601
- this._actions = [];
602
601
  this.handleClick = (evt) => {
603
602
  const selectedAction = this._actions.find((action) => action.actionID == evt.detail.id);
604
603
  const executor = new ExecutorFactory(selectedAction.type).executor;
@@ -608,22 +607,27 @@ const SnkActionsButton = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
608
607
  };
609
608
  this._items = [];
610
609
  this._showDropdown = false;
610
+ this._actions = [];
611
+ this._isOrderActions = false;
611
612
  }
612
613
  async getActions() {
613
- const actions = await ServiceUtils.useCacheWithService(`SnkActionsButton_${this._entityName}-${this._resourceID}`, async () => {
614
+ let param = {
615
+ param: {
616
+ entityName: this._entityName,
617
+ resourceID: this._resourceID
618
+ }
619
+ };
620
+ return DataFetcher.get().callServiceBroker('ActionButtonsSP.getActions', param).then((result) => {
614
621
  var _a;
615
- const param = {
616
- param: {
617
- entityName: this._entityName,
618
- resourceID: this._resourceID,
619
- },
620
- };
621
- const result = await DataFetcher.get().callServiceBroker('ActionButtonsSP.getActions', param);
622
- return ((_a = result.actions) === null || _a === void 0 ? void 0 : _a.action) || [];
623
- }, StorageType.IN_MEMORY_CACHE);
624
- this._actions = SnkActionsButton.parameters.isOrderActions
625
- ? ArrayUtils.sortAlphabetically(actions, 'description')
626
- : actions;
622
+ if (!((_a = result.actions) === null || _a === void 0 ? void 0 : _a.action))
623
+ return;
624
+ if (this._isOrderActions) {
625
+ this._actions = ArrayUtils.sortAlphabetically(result.actions.action, 'description');
626
+ }
627
+ else {
628
+ this._actions = result.actions.action;
629
+ }
630
+ });
627
631
  }
628
632
  controlDropdown() {
629
633
  this._showDropdown = !this._showDropdown;
@@ -656,7 +660,7 @@ const SnkActionsButton = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
656
660
  }
657
661
  async componentWillLoad() {
658
662
  this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
659
- await this.loadParameters();
663
+ this._isOrderActions = await this._application.getBooleanParam('global.ordenar.acoes.personalizadas');
660
664
  const snkDataUnit = this._element.parentElement;
661
665
  this._dataUnit = snkDataUnit === null || snkDataUnit === void 0 ? void 0 : snkDataUnit.dataUnit;
662
666
  this._resourceID = snkDataUnit === null || snkDataUnit === void 0 ? void 0 : snkDataUnit.resourceID;
@@ -665,8 +669,9 @@ const SnkActionsButton = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
665
669
  this._resourceID = await ResourceIDUtils.getResourceID();
666
670
  }
667
671
  this.setEvents();
668
- await this.getActions();
669
- this.loadItems();
672
+ this.getActions().then(() => {
673
+ this.loadItems();
674
+ });
670
675
  }
671
676
  async componentDidLoad() {
672
677
  if (!this._element)
@@ -693,11 +698,6 @@ const SnkActionsButton = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
693
698
  [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: ElementIDUtils.getInternalIDInfo(sufix)
694
699
  };
695
700
  }
696
- async loadParameters() {
697
- if (SnkActionsButton.parameters.isOrderActions != null)
698
- return;
699
- SnkActionsButton.parameters.isOrderActions = await this._application.getBooleanParam('global.ordenar.acoes.personalizadas');
700
- }
701
701
  render() {
702
702
  return (h(Host, null, (this._actions && this._actions.length > 0) &&
703
703
  (h("div", { class: `ez-padding-left--medium snk-actions-button
@@ -713,11 +713,10 @@ const SnkActionsButton = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
713
713
  static get style() { return snkActionsButtonCss; }
714
714
  }, [2, "snk-actions-button", {
715
715
  "_items": [32],
716
- "_showDropdown": [32]
716
+ "_showDropdown": [32],
717
+ "_actions": [32],
718
+ "_isOrderActions": [32]
717
719
  }]);
718
- SnkActionsButton.parameters = {
719
- isOrderActions: null
720
- };
721
720
  function defineCustomElement() {
722
721
  if (typeof customElements === "undefined") {
723
722
  return;
@@ -4,7 +4,7 @@ import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
4
4
  import { C as ConfigStorage } from './ConfigStorage.js';
5
5
  import { d as dist, D as DataFetcher, U as UrlUtils } from './DataFetcher.js';
6
6
  import { A as AutorizationType, a as AuthFetcher } from './auth-fetcher.js';
7
- import { P as PreloadManager, D as DataUnitFetcher } from './dataunit-fetcher.js';
7
+ import { D as DataUnitFetcher } from './dataunit-fetcher.js';
8
8
  import { P as PesquisaFetcher } from './pesquisa-fetcher.js';
9
9
  import { S as SnkMessageBuilder } from './SnkMessageBuilder.js';
10
10
  import { d as defineCustomElement$1 } from './snk-pesquisa2.js';
@@ -869,16 +869,6 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
869
869
  async isLoadedByPk() {
870
870
  return Promise.resolve(this._isLoadedByPk);
871
871
  }
872
- /**
873
- * Remove registro do cache do PreLoader do dataunit.
874
- * Deve ser usado quando existe um dataunit usando loader do application, mas o removeLoader está sendo sobrescrito.
875
- */
876
- async preloadMangerRemoveRecord(dataUnit, recordsIDs) {
877
- const records = recordsIDs.map(id => {
878
- return { "__record__id__": id };
879
- });
880
- PreloadManager.removeRecords(dataUnit, records);
881
- }
882
872
  async getAuthList(auth) {
883
873
  return await (new MGEAuthorization()).parseFromJSON(auth);
884
874
  }
@@ -1417,7 +1407,6 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
1417
1407
  "info": [64],
1418
1408
  "loadTotals": [64],
1419
1409
  "isLoadedByPk": [64],
1420
- "preloadMangerRemoveRecord": [64],
1421
1410
  "executeSearch": [64],
1422
1411
  "executePreparedSearch": [64],
1423
1412
  "isDebugMode": [64],