@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-kb-74339.1 → 0.0.0-bugfix-dev-KB-76362.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 (152) hide show
  1. package/dist/cjs/{ConfigStorage-ecc0ed20.js → ConfigStorage-f079f5fd.js} +2 -2
  2. package/dist/cjs/{ContinuousInsertUtils-29b65619.js → ContinuousInsertUtils-64e47516.js} +29 -20
  3. package/dist/cjs/{DataFetcher-cadeef8e.js → DataFetcher-e059eb72.js} +7 -5
  4. package/dist/cjs/{SnkFormConfigManager-f1c92f79.js → SnkFormConfigManager-63369164.js} +2 -2
  5. package/dist/cjs/{SnkMessageBuilder-bae64d0d.js → SnkMessageBuilder-7691a2c1.js} +10 -0
  6. package/dist/cjs/{auth-fetcher-d68841bc.js → auth-fetcher-4f853233.js} +1 -1
  7. package/dist/cjs/{dataunit-fetcher-f89461c1.js → dataunit-fetcher-228016f4.js} +3 -3
  8. package/dist/cjs/{form-config-fetcher-ed497282.js → form-config-fetcher-39397ac5.js} +1 -1
  9. package/dist/cjs/index-f9e81701.js +8 -0
  10. package/dist/cjs/input-distinct-search_2.cjs.entry.js +471 -0
  11. package/dist/cjs/loader.cjs.js +1 -1
  12. package/dist/cjs/{pesquisa-fetcher-ca89181c.js → pesquisa-fetcher-a9bfeb22.js} +7 -2
  13. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  14. package/dist/cjs/snk-actions-button_4.cjs.entry.js +5 -5
  15. package/dist/cjs/snk-application.cjs.entry.js +102 -60
  16. package/dist/cjs/snk-attach.cjs.entry.js +5 -5
  17. package/dist/cjs/snk-config-options_3.cjs.entry.js +4 -4
  18. package/dist/cjs/snk-crud.cjs.entry.js +5 -5
  19. package/dist/cjs/snk-data-exporter.cjs.entry.js +6 -6
  20. package/dist/cjs/{snk-data-unit-668dc5e8.js → snk-data-unit-7dbdad0e.js} +2 -2
  21. package/dist/cjs/snk-data-unit.cjs.entry.js +4 -4
  22. package/dist/cjs/snk-detail-view.cjs.entry.js +8 -8
  23. package/dist/cjs/snk-distinct-search.cjs.entry.js +123 -0
  24. package/dist/cjs/snk-filter-bar_4.cjs.entry.js +3 -3
  25. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +3 -3
  26. package/dist/cjs/snk-grid.cjs.entry.js +6 -6
  27. package/dist/cjs/{snk-guides-viewer-4236cb9d.js → snk-guides-viewer-eee43c8b.js} +8 -5
  28. package/dist/cjs/snk-guides-viewer.cjs.entry.js +7 -7
  29. package/dist/cjs/snk-personalized-filter.cjs.entry.js +3 -3
  30. package/dist/cjs/snk-simple-crud.cjs.entry.js +10 -8
  31. package/dist/collection/collection-manifest.json +3 -0
  32. package/dist/collection/components/snk-application/request-listener/DebouncedRequestListener.js +28 -0
  33. package/dist/collection/components/snk-application/request-listener/RequestListenerFactory.js +16 -0
  34. package/dist/collection/components/snk-application/request-listener/RequestListenerLoadingBar.js +52 -0
  35. package/dist/collection/components/snk-application/snk-application.js +3 -53
  36. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +3 -0
  37. package/dist/collection/components/snk-distinct-search/snk-distinct-search.css +4 -0
  38. package/dist/collection/components/snk-distinct-search/snk-distinct-search.js +372 -0
  39. package/dist/collection/components/snk-distinct-search/subcomponents/input-distinct-search/input-distinct-search.css +110 -0
  40. package/dist/collection/components/snk-distinct-search/subcomponents/input-distinct-search/input-distinct-search.js +544 -0
  41. package/dist/collection/components/snk-distinct-search/subcomponents/search-modal/search-modal.css +28 -0
  42. package/dist/collection/components/snk-distinct-search/subcomponents/search-modal/search-modal.js +593 -0
  43. package/dist/collection/components/snk-distinct-search/types/index.js +1 -0
  44. package/dist/collection/components/snk-distinct-search/utils/filter-distinct-search.js +15 -0
  45. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +3 -1
  46. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +8 -6
  47. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.js +2 -2
  48. package/dist/collection/lib/http/data-fetcher/fetchers/distinct-search-fetcher.js +25 -0
  49. package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +6 -1
  50. package/dist/collection/lib/message/SnkMessageBuilder.js +2 -0
  51. package/dist/collection/lib/message/resources/snk-distinct-search.msg.js +9 -0
  52. package/dist/collection/lib/utils/CrudUtils.js +25 -16
  53. package/dist/components/ContinuousInsertUtils.js +25 -16
  54. package/dist/components/DataFetcher.js +7 -5
  55. package/dist/components/SnkMessageBuilder.js +10 -0
  56. package/dist/components/dataunit-fetcher.js +2 -2
  57. package/dist/components/filter-distinct-search.js +17 -0
  58. package/dist/components/index.d.ts +3 -0
  59. package/dist/components/index.js +3 -0
  60. package/dist/components/input-distinct-search.d.ts +11 -0
  61. package/dist/components/input-distinct-search.js +6 -0
  62. package/dist/components/input-distinct-search2.js +264 -0
  63. package/dist/components/pesquisa-fetcher.js +6 -1
  64. package/dist/components/search-modal.d.ts +11 -0
  65. package/dist/components/search-modal.js +6 -0
  66. package/dist/components/search-modal2.js +264 -0
  67. package/dist/components/snk-application2.js +95 -53
  68. package/dist/components/snk-detail-view2.js +3 -0
  69. package/dist/components/snk-distinct-search.d.ts +11 -0
  70. package/dist/components/snk-distinct-search.js +163 -0
  71. package/dist/components/snk-simple-crud2.js +3 -1
  72. package/dist/esm/{ConfigStorage-7b36d041.js → ConfigStorage-6514d66e.js} +2 -2
  73. package/dist/esm/{ContinuousInsertUtils-30caa626.js → ContinuousInsertUtils-b62906f9.js} +29 -20
  74. package/dist/esm/{DataFetcher-a9c598f2.js → DataFetcher-5034df59.js} +7 -5
  75. package/dist/esm/{SnkFormConfigManager-f1a0fc92.js → SnkFormConfigManager-b409c745.js} +2 -2
  76. package/dist/esm/{SnkMessageBuilder-6fff4a4c.js → SnkMessageBuilder-7ace6803.js} +10 -0
  77. package/dist/esm/{auth-fetcher-749d880f.js → auth-fetcher-ca5d3a49.js} +1 -1
  78. package/dist/esm/{dataunit-fetcher-c24c76c6.js → dataunit-fetcher-56cb648b.js} +3 -3
  79. package/dist/esm/{form-config-fetcher-adbe5d34.js → form-config-fetcher-a7d3e277.js} +1 -1
  80. package/dist/esm/index-a7d3d3f1.js +8 -0
  81. package/dist/esm/input-distinct-search_2.entry.js +466 -0
  82. package/dist/esm/loader.js +1 -1
  83. package/dist/esm/{pesquisa-fetcher-8edaa8cd.js → pesquisa-fetcher-6bc2e41a.js} +7 -2
  84. package/dist/esm/sankhyablocks.js +1 -1
  85. package/dist/esm/snk-actions-button_4.entry.js +5 -5
  86. package/dist/esm/snk-application.entry.js +102 -60
  87. package/dist/esm/snk-attach.entry.js +5 -5
  88. package/dist/esm/snk-config-options_3.entry.js +4 -4
  89. package/dist/esm/snk-crud.entry.js +5 -5
  90. package/dist/esm/snk-data-exporter.entry.js +6 -6
  91. package/dist/esm/{snk-data-unit-0fdfb6c2.js → snk-data-unit-7a579dbd.js} +2 -2
  92. package/dist/esm/snk-data-unit.entry.js +4 -4
  93. package/dist/esm/snk-detail-view.entry.js +8 -8
  94. package/dist/esm/snk-distinct-search.entry.js +119 -0
  95. package/dist/esm/snk-filter-bar_4.entry.js +3 -3
  96. package/dist/esm/snk-filter-modal-item.entry.js +3 -3
  97. package/dist/esm/snk-grid.entry.js +6 -6
  98. package/dist/esm/{snk-guides-viewer-8fa1321a.js → snk-guides-viewer-e8ca764a.js} +8 -5
  99. package/dist/esm/snk-guides-viewer.entry.js +7 -7
  100. package/dist/esm/snk-personalized-filter.entry.js +3 -3
  101. package/dist/esm/snk-simple-crud.entry.js +10 -8
  102. package/dist/sankhyablocks/{p-f3434fc4.js → p-00278e07.js} +1 -1
  103. package/dist/sankhyablocks/{p-49b01ec2.entry.js → p-00f9fe5c.entry.js} +1 -1
  104. package/dist/sankhyablocks/{p-fadc8339.js → p-0e206e62.js} +1 -1
  105. package/dist/sankhyablocks/{p-ab05d5f2.entry.js → p-0e250436.entry.js} +1 -1
  106. package/dist/sankhyablocks/{p-06421fdb.js → p-126c58ea.js} +1 -1
  107. package/dist/sankhyablocks/p-154aa2a6.entry.js +11 -0
  108. package/dist/sankhyablocks/p-18cb1acb.entry.js +1 -0
  109. package/dist/sankhyablocks/{p-a75d242d.entry.js → p-1dbd5c18.entry.js} +1 -1
  110. package/dist/sankhyablocks/{p-fa6c5826.entry.js → p-30ebcbe0.entry.js} +1 -1
  111. package/dist/sankhyablocks/{p-1bf06cd3.js → p-341465ce.js} +2 -2
  112. package/dist/sankhyablocks/p-3755b46f.entry.js +1 -0
  113. package/dist/sankhyablocks/{p-052213ba.entry.js → p-3858a2e4.entry.js} +1 -1
  114. package/dist/sankhyablocks/p-42130213.entry.js +1 -0
  115. package/dist/sankhyablocks/{p-7ac7932c.js → p-47d24ac8.js} +2 -2
  116. package/dist/sankhyablocks/{p-8dfc2ba9.entry.js → p-563b7c28.entry.js} +1 -1
  117. package/dist/sankhyablocks/{p-4d9549cf.js → p-9ffd9fc7.js} +1 -1
  118. package/dist/sankhyablocks/{p-c2e4ac99.entry.js → p-a2c790ac.entry.js} +1 -1
  119. package/dist/sankhyablocks/{p-212213d9.entry.js → p-aa003d4e.entry.js} +1 -1
  120. package/dist/sankhyablocks/p-aaf94476.js +1 -0
  121. package/dist/sankhyablocks/{p-2ef45894.entry.js → p-b389ed49.entry.js} +1 -1
  122. package/dist/sankhyablocks/{p-5dd8cf4f.js → p-c75fae8e.js} +1 -1
  123. package/dist/sankhyablocks/p-d8665750.js +1 -0
  124. package/dist/sankhyablocks/{p-ee7023c4.js → p-e3a285a2.js} +1 -1
  125. package/dist/sankhyablocks/p-e4391e16.js +1 -0
  126. package/dist/sankhyablocks/{p-42288374.entry.js → p-f0aaad2b.entry.js} +1 -1
  127. package/dist/sankhyablocks/{p-b9c67e45.entry.js → p-f4e221b2.entry.js} +1 -1
  128. package/dist/sankhyablocks/{p-fb34e0cf.entry.js → p-fca0e5cc.entry.js} +1 -1
  129. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  130. package/dist/types/components/snk-application/request-listener/DebouncedRequestListener.d.ts +11 -0
  131. package/dist/types/components/snk-application/request-listener/RequestListenerFactory.d.ts +12 -0
  132. package/dist/types/components/snk-application/request-listener/RequestListenerLoadingBar.d.ts +13 -0
  133. package/dist/types/components/snk-application/snk-application.d.ts +3 -12
  134. package/dist/types/components/snk-distinct-search/snk-distinct-search.d.ts +83 -0
  135. package/dist/types/components/snk-distinct-search/subcomponents/input-distinct-search/input-distinct-search.d.ts +105 -0
  136. package/dist/types/components/snk-distinct-search/subcomponents/search-modal/search-modal.d.ts +127 -0
  137. package/dist/types/components/snk-distinct-search/types/index.d.ts +12 -0
  138. package/dist/types/components/snk-distinct-search/utils/filter-distinct-search.d.ts +4 -0
  139. package/dist/types/components.d.ts +393 -1
  140. package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +1 -0
  141. package/dist/types/lib/http/data-fetcher/fetchers/distinct-search-fetcher.d.ts +6 -0
  142. package/dist/types/lib/message/resources/snk-distinct-search.msg.d.ts +2 -0
  143. package/dist/types/lib/utils/CrudUtils.d.ts +1 -0
  144. package/package.json +1 -1
  145. package/react/components.d.ts +3 -0
  146. package/react/components.js +3 -0
  147. package/react/components.js.map +1 -1
  148. package/dist/sankhyablocks/p-17425c72.js +0 -1
  149. package/dist/sankhyablocks/p-2923c1b5.js +0 -1
  150. package/dist/sankhyablocks/p-7281cdab.entry.js +0 -1
  151. package/dist/sankhyablocks/p-a42e7a1e.entry.js +0 -11
  152. package/dist/sankhyablocks/p-ca5ec380.js +0 -1
@@ -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);--ez-popup__container--height:380px}.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.debounceTimeout = null;
15
+ this.filteredItems = [];
16
+ this.searchFocus = false;
17
+ this.isLimited = false;
18
+ this.application = undefined;
19
+ this.listItens = [];
20
+ this.opened = false;
21
+ this.value = undefined;
22
+ this.canShowError = false;
23
+ this.emptyMessage = undefined;
24
+ this.debounceTime = 300;
25
+ this.maxItens = 100;
26
+ this.label = 'Pesquisar';
27
+ this.mode = 'regular';
28
+ this.restrict = undefined;
29
+ this.errorMessage = undefined;
30
+ }
31
+ /**
32
+ * Método para adicionar a nova palavra e chamar o método closeModal() para fechar o modal
33
+ */
34
+ addNewItem() {
35
+ this.closeModal();
36
+ this.changeValue.emit({ isNewItem: true, value: this.value });
37
+ }
38
+ /**
39
+ * Método para limpa o campo de entrada de pesquisa
40
+ */
41
+ clearInput() {
42
+ this._refFilterInput.setValue("");
43
+ }
44
+ /**
45
+ * Método para fechar o modal
46
+ */
47
+ closeModal() {
48
+ this._popupElement.opened = false;
49
+ this.popupClose.emit(false);
50
+ }
51
+ /**
52
+ * Método para abrir o modal
53
+ */
54
+ openModal() {
55
+ this._popupElement.opened = true;
56
+ setTimeout(() => this.setFocus(), 100);
57
+ }
58
+ /**
59
+ * Retorna se o conteúdo é inválido.
60
+ */
61
+ isInvalid() {
62
+ this._refFilterInput.isInvalid();
63
+ }
64
+ /**
65
+ * Remove o foco do campo
66
+ */
67
+ setBlur() {
68
+ this._refFilterInput.setBlur();
69
+ this.searchFocus = false;
70
+ }
71
+ /**
72
+ * Aplica o foco do campo
73
+ */
74
+ setFocus() {
75
+ this._refFilterInput.setFocus();
76
+ this.searchFocus = true;
77
+ }
78
+ /**
79
+ * Método para tratar a mensagem de erro
80
+ */
81
+ watchPropErrorMessage() {
82
+ this._refFilterInput.errorMessage = this.errorMessage;
83
+ }
84
+ /**
85
+ * Método para tratar o value do input
86
+ */
87
+ watchPropValue() {
88
+ this._refFilterInput.value = this.value;
89
+ }
90
+ /**
91
+ * Atualiza a lista de itens à medida que o usuário digita no campo de pesquisa.
92
+ */
93
+ async handleInput(event) {
94
+ if (this.debounceTimeout) {
95
+ clearTimeout(this.debounceTimeout);
96
+ }
97
+ this.value = event.detail;
98
+ this.debounceTimeout = setTimeout(async () => {
99
+ var _a;
100
+ const { isLimited, items } = filterItems(event.detail, this.listItens, this.maxItens);
101
+ this.filteredItems = items;
102
+ this.isLimited = isLimited;
103
+ await ((_a = this._refList) === null || _a === void 0 ? void 0 : _a.removeSelection());
104
+ }, this.debounceTime);
105
+ }
106
+ initializeComponent() {
107
+ this.filteredItems = this.listItens;
108
+ }
109
+ getMessage(key) {
110
+ return this.application.messagesBuilder.getMessage(key, null);
111
+ }
112
+ componentWillLoad() {
113
+ this.initializeComponent();
114
+ }
115
+ componentDidLoad() {
116
+ this.bindKeyboardManager();
117
+ this._refFilterInput.value = this.value;
118
+ const { isLimited, items } = filterItems(this.value, this.listItens, this.maxItens);
119
+ this.filteredItems = items;
120
+ this.isLimited = isLimited;
121
+ }
122
+ disconnectedCallback() {
123
+ this.unbindKeyboardManager();
124
+ }
125
+ buildItems() {
126
+ var _a;
127
+ const items = (_a = this.filteredItems) === null || _a === void 0 ? void 0 : _a.map((item) => ({
128
+ label: item,
129
+ id: normalizeString(item),
130
+ }));
131
+ return items;
132
+ }
133
+ async tabSelect() {
134
+ var _a;
135
+ const selectedValue = await ((_a = this._refList) === null || _a === void 0 ? void 0 : _a.getSelection());
136
+ if (this.searchFocus && this._refList) {
137
+ this.searchFocus = false;
138
+ this._refList.focus();
139
+ await this.selectFirstItem();
140
+ }
141
+ else if (selectedValue) {
142
+ await this._refList.removeSelection();
143
+ await this._refButton.setFocus();
144
+ }
145
+ else {
146
+ await this._refButton.setBlur();
147
+ this.setFocus();
148
+ }
149
+ }
150
+ bindKeyboardManager() {
151
+ this._keyboardManager = new KeyboardManager({ propagate: false, element: this._element });
152
+ this._keyboardManager
153
+ .bind("ArrowDown", () => { this.selectNextItem(); })
154
+ .bind("ArrowUp", () => { this.selectPreviousItem(); })
155
+ .bind("Enter", () => { this.setSelectedValue(); })
156
+ .bind("Tab", () => { this.tabSelect(); });
157
+ }
158
+ unbindKeyboardManager() {
159
+ this._keyboardManager
160
+ .unbind("ArrowDown")
161
+ .unbind("ArrowUp")
162
+ .unbind("Enter")
163
+ .unbind("Tab");
164
+ }
165
+ async setSelectedValue() {
166
+ var _a;
167
+ const selectedValue = await ((_a = this._refList) === null || _a === void 0 ? void 0 : _a.getSelection());
168
+ if (selectedValue) {
169
+ this.changeValue.emit({ isNewItem: false, value: selectedValue.label });
170
+ this.closeModal();
171
+ }
172
+ else if (this.searchFocus && this.enabledButtonNewItem()) {
173
+ this.addNewItem();
174
+ }
175
+ }
176
+ async selectNextItem() {
177
+ var _a;
178
+ const itemSelected = await ((_a = this._refList) === null || _a === void 0 ? void 0 : _a.getSelection());
179
+ if (this.searchFocus && !itemSelected) {
180
+ this.setBlur();
181
+ await this.selectFirstItem();
182
+ return;
183
+ }
184
+ await this._refList.selectNextItem();
185
+ }
186
+ async selectPreviousItem() {
187
+ const itemSelected = await this._refList.getSelection();
188
+ if (itemSelected === undefined)
189
+ return;
190
+ await this._refList.selectPreviousItem();
191
+ }
192
+ async selectFirstItem() {
193
+ if (!this.filteredItems.length) {
194
+ await this._refList.removeSelection();
195
+ return;
196
+ }
197
+ const firstItem = this.filteredItems[0];
198
+ await this._refList.setSelection({
199
+ id: normalizeString(firstItem),
200
+ label: firstItem,
201
+ });
202
+ }
203
+ enabledButtonNewItem() {
204
+ if (this.value === undefined)
205
+ return false;
206
+ if (getMatchOption(this.value, this.listItens))
207
+ return false;
208
+ return this.value.trim().length === 0 ? false : true;
209
+ }
210
+ buildMessage() {
211
+ if (this.isLimited) {
212
+ return this.getMessage("snkDistinctSearch.limitResult");
213
+ }
214
+ return `${this.filteredItems.length} ${this.filteredItems.length > 1 ? this.getMessage("snkDistinctSearch.availableResults") : this.getMessage("snkDistinctSearch.availableResult")}`;
215
+ }
216
+ render() {
217
+ var _a;
218
+ return (h(Host, null, h("ez-popup", { ref: (ref) => this._popupElement = ref, size: "400px", "ez-title": this.label, onEzClosePopup: () => this.popupClose.emit(false), "height-mode": "full" }, 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.filteredItems.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.buildMessage()), 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() }))))));
219
+ }
220
+ get _element() { return this; }
221
+ static get watchers() { return {
222
+ "errorMessage": ["watchPropErrorMessage"],
223
+ "value": ["watchPropValue"]
224
+ }; }
225
+ static get style() { return searchModalCss; }
226
+ }, [2, "search-modal", {
227
+ "application": [16],
228
+ "listItens": [1040],
229
+ "opened": [1540],
230
+ "value": [1],
231
+ "canShowError": [4, "can-show-error"],
232
+ "emptyMessage": [1, "empty-message"],
233
+ "debounceTime": [2, "debounce-time"],
234
+ "maxItens": [2, "max-itens"],
235
+ "label": [1],
236
+ "mode": [1],
237
+ "restrict": [1],
238
+ "errorMessage": [1, "error-message"],
239
+ "filteredItems": [32],
240
+ "searchFocus": [32],
241
+ "isLimited": [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 };
@@ -274,6 +274,99 @@ class SnkErrorHandler {
274
274
  }
275
275
  }
276
276
 
277
+ class DebouncedRequestListener {
278
+ constructor() {
279
+ this._debounceTime = 1500;
280
+ this.requests = new Map();
281
+ this.requestsLoadingBar = [];
282
+ }
283
+ onRequestStart(param) {
284
+ if (param.url.includes("quietMode=true")) {
285
+ return;
286
+ }
287
+ this.requestsLoadingBar.push(param.requestId);
288
+ const timeout = setTimeout(() => {
289
+ this.ezLoadingBar.show();
290
+ }, this._debounceTime);
291
+ this.requests.set(param.requestId, timeout);
292
+ }
293
+ ;
294
+ onRequestEnd(param) {
295
+ const timeoutId = this.requests.get(param.requestId);
296
+ clearTimeout(timeoutId);
297
+ if (this.requestsLoadingBar.includes(param.requestId)) {
298
+ this.requestsLoadingBar = this.requestsLoadingBar.filter(id => id !== param.requestId);
299
+ !this.requestsLoadingBar.length && this.ezLoadingBar.hide();
300
+ }
301
+ }
302
+ ;
303
+ }
304
+
305
+ class RequestListenerLoadingBar {
306
+ constructor() {
307
+ this._debounceTime = 1000;
308
+ this._ignoredNameTypes = ["totals"];
309
+ this._countRequest = 0;
310
+ }
311
+ onRequestStart(param) {
312
+ if (this.isIgnoreLoadingOnRequest(param)) {
313
+ return;
314
+ }
315
+ this._countRequest++;
316
+ this.ezLoadingBar.show();
317
+ if (this._timerLoading) {
318
+ clearTimeout(this._timerLoading);
319
+ }
320
+ }
321
+ ;
322
+ onRequestEnd(param) {
323
+ if (this.isIgnoreLoadingOnRequest(param)) {
324
+ return;
325
+ }
326
+ this._countRequest--;
327
+ this._timerLoading = setTimeout(() => {
328
+ if (this._countRequest <= 0) {
329
+ this.ezLoadingBar.hide();
330
+ }
331
+ }, this._debounceTime);
332
+ }
333
+ ;
334
+ isIgnoreLoadingOnRequest(param) {
335
+ if (param == undefined) {
336
+ return false;
337
+ }
338
+ if (param.url.includes("quietMode=true")) {
339
+ return true;
340
+ }
341
+ if (param.requestBody == undefined) {
342
+ return false;
343
+ }
344
+ if (param.requestBody.length == 1) {
345
+ const { name } = param.requestBody[0].variables;
346
+ if (name) {
347
+ const nameParts = name.split(":");
348
+ const nameType = nameParts[0];
349
+ return this._ignoredNameTypes.indexOf(nameType) >= 0;
350
+ }
351
+ }
352
+ return false;
353
+ }
354
+ ;
355
+ }
356
+
357
+ class RequestListenerFactory {
358
+ static create({ strategy }) {
359
+ switch (strategy) {
360
+ case 'request_name':
361
+ return new RequestListenerLoadingBar();
362
+ case 'request_time':
363
+ return new DebouncedRequestListener();
364
+ default:
365
+ throw new Error('Strategy not found');
366
+ }
367
+ }
368
+ }
369
+
277
370
  const snkApplicationCss = ".sc-snk-application-h{display:flex;flex-direction:column;height:100%}";
278
371
 
279
372
  const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
@@ -288,7 +381,7 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
288
381
  this._waitingAppReady = new Array();
289
382
  this._duCache = new Map();
290
383
  this._duPromises = new Map();
291
- this._requestListener = new RequestListenerLoadingBar();
384
+ this._requestListener = RequestListenerFactory.create({ strategy: 'request_time' });
292
385
  this._pendingActions = new Map;
293
386
  this._loadPkParameter = null;
294
387
  this._isLoadedByPk = false;
@@ -1262,7 +1355,7 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
1262
1355
  .unbind("F1");
1263
1356
  }
1264
1357
  render() {
1265
- return (h("div", null, h("ez-loading-bar", { ref: (ref) => this._requestListener.loadingBar = ref }), h("ez-popup", { opened: false, ref: (ref) => this._popUp = ref, onEzClosePopup: () => this.closePopUp() }), h("ez-modal", { opened: false, ref: (ref) => this._rightModal = ref, "modal-size": "small", closeOutsideClick: true, closeEsc: true })));
1358
+ return (h("div", null, h("ez-loading-bar", { ref: (ref) => this._requestListener.ezLoadingBar = ref }), h("ez-popup", { opened: false, ref: (ref) => this._popUp = ref, onEzClosePopup: () => this.closePopUp() }), h("ez-modal", { opened: false, ref: (ref) => this._rightModal = ref, "modal-size": "small", closeOutsideClick: true, closeEsc: true })));
1266
1359
  }
1267
1360
  get _element() { return this; }
1268
1361
  static get watchers() { return {
@@ -1326,57 +1419,6 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
1326
1419
  "whenApplicationReady": [64],
1327
1420
  "setSearchFilterContext": [64]
1328
1421
  }]);
1329
- class RequestListenerLoadingBar {
1330
- constructor() {
1331
- this._debounceTime = 1000;
1332
- this._ignoredNameTypes = ["totals"];
1333
- this._countRequest = 0;
1334
- }
1335
- onRequestStart(param) {
1336
- if (this.isIgnoreLoadingOnRequest(param)) {
1337
- return;
1338
- }
1339
- this._countRequest++;
1340
- this.loadingBar.show();
1341
- if (this._timerLoading) {
1342
- clearTimeout(this._timerLoading);
1343
- }
1344
- }
1345
- ;
1346
- onRequestEnd(param) {
1347
- if (this.isIgnoreLoadingOnRequest(param)) {
1348
- return;
1349
- }
1350
- this._countRequest--;
1351
- this._timerLoading = setTimeout(() => {
1352
- if (this._countRequest <= 0) {
1353
- this.loadingBar.hide();
1354
- }
1355
- }, this._debounceTime);
1356
- }
1357
- ;
1358
- isIgnoreLoadingOnRequest(param) {
1359
- if (param == undefined) {
1360
- return false;
1361
- }
1362
- if (param.url.includes("quietMode=true")) {
1363
- return true;
1364
- }
1365
- if (param.requestBody == undefined) {
1366
- return false;
1367
- }
1368
- if (param.requestBody.length == 1) {
1369
- const { name } = param.requestBody[0].variables;
1370
- if (name) {
1371
- const nameParts = name.split(":");
1372
- const nameType = nameParts[0];
1373
- return this._ignoredNameTypes.indexOf(nameType) >= 0;
1374
- }
1375
- }
1376
- return false;
1377
- }
1378
- ;
1379
- }
1380
1422
  class PendingPromise {
1381
1423
  constructor(resolve, reject) {
1382
1424
  this.resolve = resolve;
@@ -482,6 +482,9 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
482
482
  await this.addErrorBadgeToGuide(guideName);
483
483
  await this.openGuideNavigator(guideName);
484
484
  }
485
+ if (action.type === Action.METADATA_LOADED) {
486
+ this.loadGuides(false);
487
+ }
485
488
  }
486
489
  async addErrorBadgeToGuide(guideName) {
487
490
  var _a;
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface SnkDistinctSearch extends Components.SnkDistinctSearch, HTMLElement {}
4
+ export const SnkDistinctSearch: {
5
+ prototype: SnkDistinctSearch;
6
+ new (): SnkDistinctSearch;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,163 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
+ import { D as DataFetcher } from './DataFetcher.js';
3
+ import { ApplicationContext } from '@sankhyalabs/core';
4
+ import { d as defineCustomElement$3 } from './input-distinct-search2.js';
5
+ import { d as defineCustomElement$2 } from './search-modal2.js';
6
+
7
+ class DistinctSearchFetcher {
8
+ constructor() {
9
+ this.SERVICE = 'mge@Pesquisa.getSelectDistinct';
10
+ }
11
+ buildRequestBody(coluna, instancia) {
12
+ return {
13
+ selectDistinct: {
14
+ instancia,
15
+ coluna,
16
+ }
17
+ };
18
+ }
19
+ parseResponseBody(response) {
20
+ var _a, _b, _c;
21
+ const ocorrencias = (_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.ocorrencias) === null || _a === void 0 ? void 0 : _a.ocorrencia) === null || _b === void 0 ? void 0 : _b.map(({ $ }) => $)) !== null && _c !== void 0 ? _c : [];
22
+ return ocorrencias;
23
+ }
24
+ async fetchItens(coluna, instancia) {
25
+ const requestBody = this.buildRequestBody(coluna, instancia);
26
+ const response = await DataFetcher.get().callServiceBroker(this.SERVICE, requestBody);
27
+ const parsedResponse = this.parseResponseBody(response);
28
+ return parsedResponse;
29
+ }
30
+ }
31
+
32
+ const snkDistinctSearchCss = ".sc-snk-distinct-search-h{display:block;width:100%}";
33
+
34
+ const SnkDistinctSearch$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
35
+ constructor() {
36
+ super();
37
+ this.__registerHost();
38
+ this.changeValue = createEvent(this, "changeValue", 7);
39
+ this.onIconClick = () => {
40
+ this._searchModalElement.value = this.value || "";
41
+ this._searchModalElement.openModal();
42
+ };
43
+ this.distinctItems = undefined;
44
+ this.value = "";
45
+ this.label = "";
46
+ this.configSearch = undefined;
47
+ this.maxItems = 100;
48
+ this.debounceTime = 300;
49
+ this.canShowError = false;
50
+ this.mode = 'regular';
51
+ this.restrict = undefined;
52
+ this.errorMessage = undefined;
53
+ }
54
+ /**
55
+ * Método para limpa o campo de entrada de pesquisa
56
+ */
57
+ clearInput() {
58
+ this._inputDistinctSearch.clearInput();
59
+ }
60
+ /**
61
+ * Retorna se o conteúdo é inválido.
62
+ */
63
+ isInvalid() {
64
+ return this._inputDistinctSearch.isInvalid();
65
+ }
66
+ /**
67
+ * Remove o foco do campo
68
+ */
69
+ setBlur() {
70
+ this._inputDistinctSearch.setBlur();
71
+ }
72
+ /**
73
+ * Aplica o foco do campo
74
+ */
75
+ setFocus() {
76
+ this._inputDistinctSearch.setFocus();
77
+ }
78
+ /**
79
+ * Método para fechar o modal
80
+ */
81
+ closeModal() {
82
+ this._searchModalElement.closeModal();
83
+ }
84
+ /**
85
+ * Método para abrir o modal
86
+ */
87
+ openModal() {
88
+ this._searchModalElement.openModal();
89
+ }
90
+ async componentWillLoad() {
91
+ await this.fetchDistinctItems();
92
+ this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
93
+ }
94
+ async fetchDistinctItems() {
95
+ const distinctFetcher = new DistinctSearchFetcher();
96
+ const response = await distinctFetcher.fetchItens(this.configSearch.column, this.configSearch.instance);
97
+ this.distinctItems = [...response];
98
+ }
99
+ onChange(event) {
100
+ event.stopPropagation();
101
+ this.value = event.detail.value;
102
+ this._inputDistinctSearch.selectValue(event.detail.value, event.detail.isNewItem);
103
+ this.changeValue.emit(event.detail);
104
+ }
105
+ onPopupClose() {
106
+ this._inputDistinctSearch.setFocus();
107
+ }
108
+ getMessage(key) {
109
+ return this._application.messagesBuilder.getMessage(key, null);
110
+ }
111
+ renderEmptyMessage() {
112
+ return (h("span", { innerHTML: this.getMessage("snkDistinctSearch.emptyResult") }));
113
+ }
114
+ render() {
115
+ return (h(Host, null, h("input-distinct-search", { ref: (ref) => this._inputDistinctSearch = ref, application: this._application, label: this.label, distinctItems: this.distinctItems, onChangeValue: this.onChange.bind(this), debounceTime: this.debounceTime, value: this.value, onIconClick: this.onIconClick, maxItems: this.maxItems, canShowError: this.canShowError, mode: this.mode, restrict: this.restrict, errorMessage: this.errorMessage }), h("search-modal", { ref: (ref) => this._searchModalElement = ref, application: this._application, listItens: this.distinctItems, onChangeValue: this.onChange.bind(this), restrict: this.restrict, value: this.value, label: this.label, emptyMessage: this.renderEmptyMessage(), maxItens: this.maxItems, debounceTime: this.debounceTime, canShowError: this.canShowError, mode: this.mode, errorMessage: this.errorMessage, onPopupClose: this.onPopupClose.bind(this) })));
116
+ }
117
+ static get style() { return snkDistinctSearchCss; }
118
+ }, [2, "snk-distinct-search", {
119
+ "value": [1025],
120
+ "label": [1],
121
+ "configSearch": [16],
122
+ "maxItems": [2, "max-items"],
123
+ "debounceTime": [2, "debounce-time"],
124
+ "canShowError": [4, "can-show-error"],
125
+ "mode": [1],
126
+ "restrict": [1],
127
+ "errorMessage": [1, "error-message"],
128
+ "distinctItems": [32],
129
+ "clearInput": [64],
130
+ "isInvalid": [64],
131
+ "setBlur": [64],
132
+ "setFocus": [64],
133
+ "closeModal": [64],
134
+ "openModal": [64]
135
+ }]);
136
+ function defineCustomElement$1() {
137
+ if (typeof customElements === "undefined") {
138
+ return;
139
+ }
140
+ const components = ["snk-distinct-search", "input-distinct-search", "search-modal"];
141
+ components.forEach(tagName => { switch (tagName) {
142
+ case "snk-distinct-search":
143
+ if (!customElements.get(tagName)) {
144
+ customElements.define(tagName, SnkDistinctSearch$1);
145
+ }
146
+ break;
147
+ case "input-distinct-search":
148
+ if (!customElements.get(tagName)) {
149
+ defineCustomElement$3();
150
+ }
151
+ break;
152
+ case "search-modal":
153
+ if (!customElements.get(tagName)) {
154
+ defineCustomElement$2();
155
+ }
156
+ break;
157
+ } });
158
+ }
159
+
160
+ const SnkDistinctSearch = SnkDistinctSearch$1;
161
+ const defineCustomElement = defineCustomElement$1;
162
+
163
+ export { SnkDistinctSearch, defineCustomElement };
@@ -726,9 +726,11 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
726
726
  window.removeEventListener("keydown", this._keyDownHandler);
727
727
  }
728
728
  gridConfigChangeHandler(evt) {
729
+ evt.stopPropagation();
730
+ if (!this.configName)
731
+ return;
729
732
  const config = evt.detail;
730
733
  ConfigStorage.saveGridConfig(config, this.configName, this.resolveResourceID());
731
- evt.stopPropagation();
732
734
  }
733
735
  modalConfigChangeHandler(evt) {
734
736
  const config = evt.detail;
@@ -1,7 +1,7 @@
1
- import { R as ResourceFetcher, F as FormConfigFetcher } from './form-config-fetcher-adbe5d34.js';
1
+ import { R as ResourceFetcher, F as FormConfigFetcher } from './form-config-fetcher-a7d3e277.js';
2
2
  import { F as FilterItemType } from './filter-item-type.enum-d45e026f.js';
3
3
  import { ObjectUtils } from '@sankhyalabs/core';
4
- import { d as dist, D as DataFetcher } from './DataFetcher-a9c598f2.js';
4
+ import { d as dist, D as DataFetcher } from './DataFetcher-5034df59.js';
5
5
 
6
6
  class GridConfigFetcher extends ResourceFetcher {
7
7
  constructor() {