@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-77074.0 → 0.0.0-bugfix-dev-KB-75047.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 (144) hide show
  1. package/dist/cjs/{SnkMessageBuilder-7691a2c1.js → SnkMessageBuilder-bae64d0d.js} +0 -10
  2. package/dist/cjs/index-f9e81701.js +0 -8
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  5. package/dist/cjs/snk-actions-button_4.cjs.entry.js +25 -22
  6. package/dist/cjs/snk-application.cjs.entry.js +18 -2
  7. package/dist/cjs/snk-config-options_3.cjs.entry.js +17 -5
  8. package/dist/cjs/snk-crud.cjs.entry.js +8 -2
  9. package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
  10. package/dist/cjs/{snk-data-unit-7dbdad0e.js → snk-data-unit-3d9b6ed4.js} +26 -14
  11. package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
  12. package/dist/cjs/snk-detail-view.cjs.entry.js +2 -2
  13. package/dist/cjs/snk-filter-bar_4.cjs.entry.js +9 -0
  14. package/dist/cjs/snk-filter-text.cjs.entry.js +2 -1
  15. package/dist/cjs/snk-grid.cjs.entry.js +10 -2
  16. package/dist/cjs/{snk-guides-viewer-eee43c8b.js → snk-guides-viewer-2139481c.js} +1 -1
  17. package/dist/cjs/snk-guides-viewer.cjs.entry.js +1 -1
  18. package/dist/cjs/snk-simple-crud.cjs.entry.js +7 -4
  19. package/dist/cjs/snk-taskbar.cjs.entry.js +40 -37
  20. package/dist/collection/collection-manifest.json +0 -3
  21. package/dist/collection/components/snk-actions-button/snk-actions-button.js +27 -26
  22. package/dist/collection/components/snk-application/snk-application.js +41 -1
  23. package/dist/collection/components/snk-crud/snk-crud.js +26 -2
  24. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +1 -1
  25. package/dist/collection/components/snk-data-unit/snk-data-unit.js +25 -13
  26. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-text.js +2 -1
  27. package/dist/collection/components/snk-filter-bar/filter-item/filter-item-type-mask.enum.js +8 -0
  28. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +5 -1
  29. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +20 -0
  30. package/dist/collection/components/snk-form-config/snk-form-config.js +17 -5
  31. package/dist/collection/components/snk-grid/snk-grid.js +28 -2
  32. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +25 -4
  33. package/dist/collection/components/snk-taskbar/snk-taskbar.js +41 -38
  34. package/dist/collection/lib/http/data-fetcher/fetchers/parameters-fecher.js +7 -1
  35. package/dist/collection/lib/message/SnkMessageBuilder.js +0 -2
  36. package/dist/components/SnkMessageBuilder.js +0 -10
  37. package/dist/components/index.d.ts +0 -3
  38. package/dist/components/index.js +0 -3
  39. package/dist/components/snk-actions-button2.js +27 -26
  40. package/dist/components/snk-application2.js +19 -2
  41. package/dist/components/snk-crud.js +9 -2
  42. package/dist/components/snk-data-unit2.js +25 -13
  43. package/dist/components/snk-detail-view2.js +1 -1
  44. package/dist/components/snk-filter-bar2.js +6 -0
  45. package/dist/components/snk-filter-item2.js +5 -1
  46. package/dist/components/snk-filter-text.js +2 -1
  47. package/dist/components/snk-form-config2.js +17 -5
  48. package/dist/components/snk-grid2.js +11 -2
  49. package/dist/components/snk-simple-crud2.js +8 -4
  50. package/dist/components/snk-taskbar2.js +41 -38
  51. package/dist/esm/{SnkMessageBuilder-7ace6803.js → SnkMessageBuilder-6fff4a4c.js} +0 -10
  52. package/dist/esm/index-a7d3d3f1.js +0 -8
  53. package/dist/esm/loader.js +1 -1
  54. package/dist/esm/sankhyablocks.js +1 -1
  55. package/dist/esm/snk-actions-button_4.entry.js +26 -23
  56. package/dist/esm/snk-application.entry.js +19 -3
  57. package/dist/esm/snk-config-options_3.entry.js +17 -5
  58. package/dist/esm/snk-crud.entry.js +8 -2
  59. package/dist/esm/snk-data-exporter.entry.js +2 -2
  60. package/dist/esm/{snk-data-unit-7a579dbd.js → snk-data-unit-9fa7d2b9.js} +26 -14
  61. package/dist/esm/snk-data-unit.entry.js +2 -2
  62. package/dist/esm/snk-detail-view.entry.js +2 -2
  63. package/dist/esm/snk-filter-bar_4.entry.js +10 -1
  64. package/dist/esm/snk-filter-text.entry.js +2 -1
  65. package/dist/esm/snk-grid.entry.js +10 -2
  66. package/dist/esm/{snk-guides-viewer-e8ca764a.js → snk-guides-viewer-b7ed39eb.js} +1 -1
  67. package/dist/esm/snk-guides-viewer.entry.js +1 -1
  68. package/dist/esm/snk-simple-crud.entry.js +7 -4
  69. package/dist/esm/snk-taskbar.entry.js +41 -38
  70. package/dist/sankhyablocks/{p-f4e221b2.entry.js → p-0d2a2e9e.entry.js} +1 -1
  71. package/dist/sankhyablocks/p-17425c72.js +1 -0
  72. package/dist/sankhyablocks/p-1d3ce0d9.entry.js +1 -0
  73. package/dist/sankhyablocks/p-342eeb3b.js +1 -0
  74. package/dist/sankhyablocks/p-3728d2aa.entry.js +11 -0
  75. package/dist/sankhyablocks/{p-42130213.entry.js → p-4138da61.entry.js} +1 -1
  76. package/dist/sankhyablocks/p-4e1f992e.entry.js +1 -0
  77. package/dist/sankhyablocks/p-619aeac8.entry.js +1 -0
  78. package/dist/sankhyablocks/{p-00f9fe5c.entry.js → p-7075b789.entry.js} +1 -1
  79. package/dist/sankhyablocks/p-83e71703.entry.js +1 -0
  80. package/dist/sankhyablocks/p-89c92727.entry.js +1 -0
  81. package/dist/sankhyablocks/p-a3fadd0b.entry.js +1 -0
  82. package/dist/sankhyablocks/p-af7f7b3e.entry.js +1 -0
  83. package/dist/sankhyablocks/{p-b389ed49.entry.js → p-e390641b.entry.js} +1 -1
  84. package/dist/sankhyablocks/{p-e3a285a2.js → p-e97be1c8.js} +1 -1
  85. package/dist/sankhyablocks/p-ec43fcc8.entry.js +1 -0
  86. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  87. package/dist/types/components/snk-actions-button/interfaces/index.d.ts +3 -0
  88. package/dist/types/components/snk-actions-button/snk-actions-button.d.ts +3 -2
  89. package/dist/types/components/snk-application/snk-application.d.ts +6 -1
  90. package/dist/types/components/snk-crud/snk-crud.d.ts +4 -0
  91. package/dist/types/components/snk-filter-bar/filter-item/filter-item-type-mask.enum.d.ts +7 -0
  92. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-item.d.ts +2 -0
  93. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +4 -0
  94. package/dist/types/components/snk-grid/snk-grid.d.ts +4 -0
  95. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +2 -0
  96. package/dist/types/components.d.ts +31 -393
  97. package/dist/types/lib/http/data-fetcher/fetchers/parameters-fecher.d.ts +1 -0
  98. package/package.json +1 -1
  99. package/react/components.d.ts +0 -3
  100. package/react/components.js +0 -3
  101. package/react/components.js.map +1 -1
  102. package/dist/cjs/input-distinct-search_2.cjs.entry.js +0 -469
  103. package/dist/cjs/snk-distinct-search.cjs.entry.js +0 -123
  104. package/dist/collection/components/snk-distinct-search/snk-distinct-search.css +0 -4
  105. package/dist/collection/components/snk-distinct-search/snk-distinct-search.js +0 -372
  106. package/dist/collection/components/snk-distinct-search/subcomponents/input-distinct-search/input-distinct-search.css +0 -109
  107. package/dist/collection/components/snk-distinct-search/subcomponents/input-distinct-search/input-distinct-search.js +0 -542
  108. package/dist/collection/components/snk-distinct-search/subcomponents/search-modal/search-modal.css +0 -27
  109. package/dist/collection/components/snk-distinct-search/subcomponents/search-modal/search-modal.js +0 -600
  110. package/dist/collection/components/snk-distinct-search/utils/filter-distinct-search.js +0 -13
  111. package/dist/collection/lib/http/data-fetcher/fetchers/distinct-search-fetcher.js +0 -25
  112. package/dist/collection/lib/message/resources/snk-distinct-search.msg.js +0 -9
  113. package/dist/components/filter-distinct-search.js +0 -15
  114. package/dist/components/input-distinct-search.d.ts +0 -11
  115. package/dist/components/input-distinct-search.js +0 -6
  116. package/dist/components/input-distinct-search2.js +0 -262
  117. package/dist/components/search-modal.d.ts +0 -11
  118. package/dist/components/search-modal.js +0 -6
  119. package/dist/components/search-modal2.js +0 -264
  120. package/dist/components/snk-distinct-search.d.ts +0 -11
  121. package/dist/components/snk-distinct-search.js +0 -163
  122. package/dist/esm/input-distinct-search_2.entry.js +0 -464
  123. package/dist/esm/snk-distinct-search.entry.js +0 -119
  124. package/dist/sankhyablocks/p-0e250436.entry.js +0 -1
  125. package/dist/sankhyablocks/p-154aa2a6.entry.js +0 -11
  126. package/dist/sankhyablocks/p-18cb1acb.entry.js +0 -1
  127. package/dist/sankhyablocks/p-1dbd5c18.entry.js +0 -1
  128. package/dist/sankhyablocks/p-2aae03a1.entry.js +0 -1
  129. package/dist/sankhyablocks/p-30ebcbe0.entry.js +0 -1
  130. package/dist/sankhyablocks/p-37074cc3.entry.js +0 -1
  131. package/dist/sankhyablocks/p-3858a2e4.entry.js +0 -1
  132. package/dist/sankhyablocks/p-563b7c28.entry.js +0 -1
  133. package/dist/sankhyablocks/p-96a89d58.entry.js +0 -1
  134. package/dist/sankhyablocks/p-c75fae8e.js +0 -1
  135. package/dist/sankhyablocks/p-d8665750.js +0 -1
  136. package/dist/sankhyablocks/p-f0aaad2b.entry.js +0 -1
  137. package/dist/types/components/snk-distinct-search/snk-distinct-search.d.ts +0 -83
  138. package/dist/types/components/snk-distinct-search/subcomponents/input-distinct-search/input-distinct-search.d.ts +0 -105
  139. package/dist/types/components/snk-distinct-search/subcomponents/search-modal/search-modal.d.ts +0 -126
  140. package/dist/types/components/snk-distinct-search/types/index.d.ts +0 -8
  141. package/dist/types/components/snk-distinct-search/utils/filter-distinct-search.d.ts +0 -3
  142. package/dist/types/lib/http/data-fetcher/fetchers/distinct-search-fetcher.d.ts +0 -6
  143. package/dist/types/lib/message/resources/snk-distinct-search.msg.d.ts +0 -2
  144. /package/dist/collection/components/{snk-distinct-search/types → snk-actions-button/interfaces}/index.js +0 -0
@@ -1,469 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const index = require('./index-f9e81701.js');
6
- const core = require('@sankhyalabs/core');
7
- const EzScrollDirection = require('@sankhyalabs/ezui/dist/collection/components/ez-scroller/EzScrollDirection');
8
-
9
- function normalizeString(text = "") {
10
- return text.normalize('NFD').replace(/[\u0300-\u036f/\s'"&.-]/g, "").toUpperCase();
11
- }
12
- function filterItems(searchArgument, distinctItems, maxItems) {
13
- const normalizedSearch = normalizeString(searchArgument);
14
- const filteredDistincts = distinctItems.filter((item) => normalizeString(item).startsWith(normalizedSearch));
15
- return filteredDistincts.slice(0, maxItems - 1);
16
- }
17
- function getMatchOption(value, distinctItems) {
18
- const normalizedSearch = normalizeString(value);
19
- const item = distinctItems.find((item) => normalizeString(item) === normalizedSearch);
20
- return item;
21
- }
22
-
23
- 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)}";
24
-
25
- const InputDistinctSearch = class {
26
- constructor(hostRef) {
27
- index.registerInstance(this, hostRef);
28
- this.changeValue = index.createEvent(this, "changeValue", 7);
29
- this.iconClick = index.createEvent(this, "iconClick", 7);
30
- this.textValue = "";
31
- this.isNewItem = false;
32
- this.filteredItems = [];
33
- this.isNewItemSelected = false;
34
- this.application = undefined;
35
- this.distinctItems = [];
36
- this.label = "";
37
- this.value = "";
38
- this.maxItems = 100;
39
- this.debounceTime = 300;
40
- this.canShowError = false;
41
- this.mode = 'regular';
42
- this.restrict = undefined;
43
- this.errorMessage = undefined;
44
- }
45
- async observerValue(newValue) {
46
- await this.selectedNewItem(newValue, true);
47
- }
48
- /**
49
- * Seleciona um item
50
- */
51
- async selectValue(value, isNewItem = false) {
52
- this.isNewItem = isNewItem;
53
- this.textValue = value;
54
- await this._refFilterInput.setValue(value);
55
- }
56
- /**
57
- * Método para limpa o campo de entrada de pesquisa
58
- */
59
- clearInput() {
60
- this._refFilterInput.setValue("");
61
- }
62
- /**
63
- * Retorna se o conteúdo é inválido.
64
- */
65
- isInvalid() {
66
- return this._refFilterInput.isInvalid();
67
- }
68
- /**
69
- * Remove o foco do campo
70
- */
71
- setBlur() {
72
- this._refFilterInput.setBlur();
73
- }
74
- /**
75
- * Aplica o foco do campo
76
- */
77
- setFocus() {
78
- this._refFilterInput.setFocus();
79
- }
80
- getMessage(key) {
81
- return this.application.messagesBuilder.getMessage(key, null);
82
- }
83
- async optionLoader(searchArgument) {
84
- return new Promise((resolve) => {
85
- if (this._debounceTimeout) {
86
- clearTimeout(this._debounceTimeout);
87
- }
88
- this._debounceTimeout = setTimeout(() => {
89
- this.filteredItems = filterItems(searchArgument, this.distinctItems, this.maxItems);
90
- resolve();
91
- }, this.debounceTime);
92
- });
93
- }
94
- async openPopOver() {
95
- var _a;
96
- await ((_a = this._refPopOver) === null || _a === void 0 ? void 0 : _a.showUnder(this._refFilterInput));
97
- }
98
- async closePopOver() {
99
- var _a;
100
- this.isNewItemSelected = false;
101
- await ((_a = this._refPopOver) === null || _a === void 0 ? void 0 : _a.hide());
102
- await this._refList.removeSelection();
103
- }
104
- async onTextChange(event) {
105
- this.textValue = event.detail;
106
- await this.optionLoader(event.detail);
107
- await this.selectFirstItem();
108
- }
109
- onIconClick() {
110
- this.iconClick.emit();
111
- }
112
- buidItems() {
113
- var _a;
114
- const items = (_a = this.filteredItems) === null || _a === void 0 ? void 0 : _a.map((item) => ({
115
- label: item,
116
- id: normalizeString(item),
117
- }));
118
- return items;
119
- }
120
- async setValue(value, isNewItem = false, preventEventEmit = false) {
121
- this.isNewItem = isNewItem;
122
- this.textValue = value;
123
- await this._refFilterInput.setValue(value);
124
- await this.closePopOver();
125
- if (!preventEventEmit) {
126
- this.changeValue.emit({
127
- value,
128
- isNewItem,
129
- });
130
- }
131
- }
132
- async selectedNewItem(value, preventEventEmit = false) {
133
- if (!this.textValue && !value) {
134
- await this.setValue("", false, preventEventEmit);
135
- return;
136
- }
137
- const item = getMatchOption(value !== null && value !== void 0 ? value : this.textValue, this.distinctItems);
138
- if (item) {
139
- await this.setValue(item, false, preventEventEmit);
140
- return;
141
- }
142
- await this.setValue(this.textValue || value, true, preventEventEmit);
143
- }
144
- async setSelectedValue() {
145
- const selectedValue = await this._refList.getSelection();
146
- await this.selectedNewItem((selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.label) || this.textValue, true);
147
- await this._refFilterInput.setBlur();
148
- this._element.focus();
149
- }
150
- async selectNextItem() {
151
- if (this.isNewItemSelected) {
152
- return;
153
- }
154
- const itemSelected = await this._refList.getSelection();
155
- const itemsAmount = this.filteredItems.length;
156
- const indexSelected = this.filteredItems.findIndex((item) => item === (itemSelected === null || itemSelected === void 0 ? void 0 : itemSelected.label));
157
- const isLastItemSelected = indexSelected === (itemsAmount - 1);
158
- const optionNewItemIsAvailable = !!this.textValue;
159
- if (!isLastItemSelected || !optionNewItemIsAvailable) {
160
- this.isNewItemSelected = false;
161
- await this._refList.selectNextItem();
162
- return;
163
- }
164
- this.isNewItemSelected = true;
165
- await this._refList.removeSelection();
166
- }
167
- async selectPreviousItem() {
168
- const itemsAmount = this.filteredItems.length;
169
- const lastItem = this.filteredItems[itemsAmount - 1];
170
- if (this.isNewItemSelected && lastItem) {
171
- this.isNewItemSelected = false;
172
- await this._refList.setSelection({
173
- id: normalizeString(lastItem),
174
- label: lastItem
175
- });
176
- return;
177
- }
178
- await this._refList.selectPreviousItem();
179
- }
180
- bindKeyboardManager() {
181
- this._keyboardManager = new core.KeyboardManager({ propagate: false, element: this._element });
182
- this._keyboardManager
183
- .bind("ArrowDown", () => { this.selectNextItem(); })
184
- .bind("ArrowUp", () => { this.selectPreviousItem(); })
185
- .bind("Enter", () => { this.setSelectedValue(); })
186
- .bind("Tab", () => { this.setSelectedValue(); });
187
- }
188
- unbindKeyboardManager() {
189
- this._keyboardManager
190
- .unbind("ArrowDown")
191
- .unbind("ArrowUp")
192
- .unbind("Enter")
193
- .unbind("Tab");
194
- }
195
- async selectFirstItem() {
196
- if (!this.filteredItems.length) {
197
- await this._refList.removeSelection();
198
- this.isNewItemSelected = true;
199
- return;
200
- }
201
- const firstItem = this.filteredItems[0];
202
- this.isNewItemSelected = false;
203
- await this._refList.setSelection({
204
- id: normalizeString(firstItem),
205
- label: firstItem,
206
- });
207
- }
208
- initializeComponent() {
209
- this.filteredItems = this.distinctItems;
210
- }
211
- componentWillLoad() {
212
- this.initializeComponent();
213
- }
214
- async componentDidLoad() {
215
- this.bindKeyboardManager();
216
- this.selectFirstItem();
217
- await this.selectedNewItem(this.value, true);
218
- }
219
- disconnectedCallback() {
220
- this.unbindKeyboardManager();
221
- }
222
- buildNewItemOption() {
223
- if (!this.textValue) {
224
- return;
225
- }
226
- return (index.h(index.Fragment, null, !!this.filteredItems.length &&
227
- index.h("hr", { class: "divider" }), index.h("button", { slot: "bottomSlot", class: {
228
- "new-value": true,
229
- "new-value-selected": this.isNewItemSelected,
230
- }, title: `${this.getMessage("snkDistinctSearch.titleAdd")} '${this.textValue}'`, onClick: () => this.selectedNewItem.bind(this)(undefined, true) }, this.getMessage("snkDistinctSearch.titleAdd"), " '", this.textValue, "'")));
231
- }
232
- render() {
233
- return (index.h(index.Host, { onBlur: () => this.selectedNewItem.bind(this)() }, index.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 &&
234
- index.h("ez-badge", { slot: "right", label: this.getMessage("snkDistinctSearch.titleBadgeNew"), size: "small-medium", class: "badge-primary" })), index.h("ez-popover", { ref: (ref) => this._refPopOver = ref, boxWidth: "full-width", autoClose: false, overlayType: "none", class: {
235
- 'space-error': this.canShowError,
236
- } }, index.h("div", { class: "popover-content" }, index.h("section", { class: "list-container" }, index.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()))));
237
- }
238
- get _element() { return index.getElement(this); }
239
- static get watchers() { return {
240
- "value": ["observerValue"]
241
- }; }
242
- };
243
- InputDistinctSearch.style = inputDistinctSearchCss;
244
-
245
- 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}";
246
-
247
- const SearchModal = class {
248
- constructor(hostRef) {
249
- index.registerInstance(this, hostRef);
250
- this.popupClose = index.createEvent(this, "popupClose", 7);
251
- this.changeValue = index.createEvent(this, "changeValue", 7);
252
- this._searchFocus = false;
253
- this.debounceTimeout = null;
254
- this.filteredItems = [];
255
- this.application = undefined;
256
- this.listItens = [];
257
- this.opened = false;
258
- this.value = undefined;
259
- this.canShowError = false;
260
- this.emptyMessage = undefined;
261
- this.debounceTime = 300;
262
- this.maxItens = 100;
263
- this.label = 'Pesquisar';
264
- this.mode = 'regular';
265
- this.restrict = undefined;
266
- this.errorMessage = undefined;
267
- }
268
- /**
269
- * Método para adicionar a nova palavra e chamar o método closeModal() para fechar o modal
270
- */
271
- addNewItem() {
272
- this.closeModal();
273
- this.changeValue.emit({ isNewItem: true, value: this.value });
274
- }
275
- /**
276
- * Método para limpa o campo de entrada de pesquisa
277
- */
278
- clearInput() {
279
- this._refFilterInput.setValue("");
280
- }
281
- /**
282
- * Método para fechar o modal
283
- */
284
- closeModal() {
285
- this._popupElement.opened = false;
286
- this.popupClose.emit(false);
287
- }
288
- /**
289
- * Método para abrir o modal
290
- */
291
- openModal() {
292
- this._popupElement.opened = true;
293
- setTimeout(() => this.setFocus(), 100);
294
- }
295
- /**
296
- * Retorna se o conteúdo é inválido.
297
- */
298
- isInvalid() {
299
- this._refFilterInput.isInvalid();
300
- }
301
- /**
302
- * Remove o foco do campo
303
- */
304
- async setBlur() {
305
- this._searchFocus = false;
306
- }
307
- /**
308
- * Aplica o foco do campo
309
- */
310
- async setFocus() {
311
- this._searchFocus = true;
312
- await this._refFilterInput.setFocus();
313
- }
314
- /**
315
- * Método para tratar a mensagem de erro
316
- */
317
- watchPropErrorMessage() {
318
- this._refFilterInput.errorMessage = this.errorMessage;
319
- }
320
- /**
321
- * Método para tratar o value do input
322
- */
323
- watchPropValue() {
324
- this._refFilterInput.value = this.value;
325
- }
326
- /**
327
- * Atualiza a lista de itens à medida que o usuário digita no campo de pesquisa.
328
- */
329
- async handleInput(event) {
330
- var _a;
331
- if (this.debounceTimeout) {
332
- clearTimeout(this.debounceTimeout);
333
- }
334
- this.value = event.detail;
335
- await ((_a = this._refList) === null || _a === void 0 ? void 0 : _a.removeSelection());
336
- this.debounceTimeout = setTimeout(() => {
337
- this.filteredItems = filterItems(event.detail, this.listItens, this.maxItens);
338
- }, this.debounceTime);
339
- }
340
- initializeComponent() {
341
- this.filteredItems = this.listItens;
342
- }
343
- getMessage(key) {
344
- return this.application.messagesBuilder.getMessage(key, null);
345
- }
346
- componentWillLoad() {
347
- this.initializeComponent();
348
- }
349
- componentDidLoad() {
350
- this.bindKeyboardManager();
351
- this._refFilterInput.value = this.value;
352
- this.filteredItems = filterItems(this.value, this.listItens, this.maxItens);
353
- }
354
- disconnectedCallback() {
355
- this.unbindKeyboardManager();
356
- }
357
- buildItems() {
358
- var _a;
359
- const items = (_a = this.filteredItems) === null || _a === void 0 ? void 0 : _a.map((item) => ({
360
- label: item,
361
- id: normalizeString(item),
362
- }));
363
- return items;
364
- }
365
- async tabSelect() {
366
- var _a;
367
- const selectedValue = await this._refList.getSelection();
368
- if (this._searchFocus) {
369
- await this.setBlur();
370
- await this.selectFirstItem();
371
- }
372
- else if (selectedValue) {
373
- await ((_a = this._refList) === null || _a === void 0 ? void 0 : _a.removeSelection());
374
- await this._refButton.setFocus();
375
- }
376
- else {
377
- await this._refButton.setBlur();
378
- await this.setFocus();
379
- }
380
- }
381
- bindKeyboardManager() {
382
- this._keyboardManager = new core.KeyboardManager({ propagate: false, element: this._element });
383
- this._keyboardManager
384
- .bind("ArrowDown", () => { this.selectNextItem(); })
385
- .bind("ArrowUp", () => { this.selectPreviousItem(); })
386
- .bind("Enter", () => { this.setSelectedValue(); })
387
- .bind("Tab", () => { this.tabSelect(); });
388
- }
389
- unbindKeyboardManager() {
390
- this._keyboardManager
391
- .unbind("ArrowDown")
392
- .unbind("ArrowUp")
393
- .unbind("Enter")
394
- .unbind("Tab");
395
- }
396
- async setSelectedValue() {
397
- var _a;
398
- const selectedValue = await ((_a = this._refList) === null || _a === void 0 ? void 0 : _a.getSelection());
399
- if (selectedValue) {
400
- this.changeValue.emit({ isNewItem: false, value: selectedValue.label });
401
- this.closeModal();
402
- }
403
- else if (this.enabledButtonNewItem()) {
404
- this.addNewItem();
405
- }
406
- }
407
- async selectNextItem() {
408
- var _a;
409
- if (this._searchFocus) {
410
- this.setBlur();
411
- }
412
- if (!this._refList) {
413
- await this._refButton.setFocus();
414
- return;
415
- }
416
- await ((_a = this._refList) === null || _a === void 0 ? void 0 : _a.selectNextItem());
417
- }
418
- async selectPreviousItem() {
419
- var _a;
420
- const itemSelected = await ((_a = this._refList) === null || _a === void 0 ? void 0 : _a.getSelection());
421
- if (!itemSelected) {
422
- return;
423
- }
424
- if (itemSelected.label === this.filteredItems[0]) {
425
- await this._refList.removeSelection();
426
- await this._refFilterInput.setFocus();
427
- return;
428
- }
429
- await this._refList.selectPreviousItem();
430
- }
431
- async selectFirstItem() {
432
- var _a;
433
- if (!this.filteredItems.length) {
434
- await ((_a = this._refList) === null || _a === void 0 ? void 0 : _a.removeSelection());
435
- return;
436
- }
437
- const firstItem = this.filteredItems[0];
438
- await this._refList.setSelection({
439
- id: normalizeString(firstItem),
440
- label: firstItem,
441
- });
442
- }
443
- enabledButtonNewItem() {
444
- if (this.value === undefined)
445
- return false;
446
- if (getMatchOption(this.value, this.listItens))
447
- return false;
448
- return this.value.trim().length === 0 ? false : true;
449
- }
450
- async handleActionPopUp({ detail }) {
451
- if (detail === "OK") {
452
- await this.setSelectedValue();
453
- }
454
- }
455
- render() {
456
- var _a;
457
- return (index.h(index.Host, null, index.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) }, index.h("div", null, index.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 ? (index.h("div", { class: "ez-content" }, index.h("div", { class: "ez-text--center search-modal-text" }, this.emptyMessage))) : (index.h("div", null, index.h("div", { class: "search-modal-text ez-padding-vertical--medium" }, this.listItens.length > this.maxItens ? this.getMessage("snkDistinctSearch.limitResult") :
458
- this.buildItems().length, " ", this.buildItems().length > 1 ? this.getMessage("snkDistinctSearch.availableResults") : this.getMessage("snkDistinctSearch.availableResult")), index.h("ez-scroller", { class: "search-modal-scroller", direction: EzScrollDirection.EzScrollDirection.VERTICAL }, index.h("ez-list", { ref: (ref) => this._refList = ref, dataSource: this.buildItems(), onEzClickItem: ({ label }) => this.setSelectedValue.bind(this)(label), ezSelectable: true, hoverFeedback: true, disableShortcuts: true })))), index.h("div", { class: "ez-flex ez-flex--justify-end" }, index.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() }))))));
459
- }
460
- get _element() { return index.getElement(this); }
461
- static get watchers() { return {
462
- "errorMessage": ["watchPropErrorMessage"],
463
- "value": ["watchPropValue"]
464
- }; }
465
- };
466
- SearchModal.style = searchModalCss;
467
-
468
- exports.input_distinct_search = InputDistinctSearch;
469
- exports.search_modal = SearchModal;
@@ -1,123 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const index = require('./index-f9e81701.js');
6
- const DataFetcher = require('./DataFetcher-e059eb72.js');
7
- const core = require('@sankhyalabs/core');
8
- require('./PrintUtils-bcaeb82f.js');
9
- require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
10
-
11
- class DistinctSearchFetcher {
12
- constructor() {
13
- this.SERVICE = 'mge@Pesquisa.getSelectDistinct';
14
- }
15
- buildRequestBody(coluna, instancia) {
16
- return {
17
- selectDistinct: {
18
- instancia,
19
- coluna,
20
- }
21
- };
22
- }
23
- parseResponseBody(response) {
24
- var _a, _b, _c;
25
- 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 : [];
26
- return ocorrencias;
27
- }
28
- async fetchItens(coluna, instancia) {
29
- const requestBody = this.buildRequestBody(coluna, instancia);
30
- const response = await DataFetcher.DataFetcher.get().callServiceBroker(this.SERVICE, requestBody);
31
- const parsedResponse = this.parseResponseBody(response);
32
- return parsedResponse;
33
- }
34
- }
35
-
36
- const snkDistinctSearchCss = ".sc-snk-distinct-search-h{display:block;width:100%}";
37
-
38
- const SnkDistinctSearch = class {
39
- constructor(hostRef) {
40
- index.registerInstance(this, hostRef);
41
- this.changeValue = index.createEvent(this, "changeValue", 7);
42
- this.onIconClick = () => {
43
- this._searchModalElement.value = this.value || "";
44
- this._searchModalElement.openModal();
45
- };
46
- this.distinctItems = undefined;
47
- this.value = "";
48
- this.label = "";
49
- this.configSearch = undefined;
50
- this.maxItems = 100;
51
- this.debounceTime = 300;
52
- this.canShowError = false;
53
- this.mode = 'regular';
54
- this.restrict = undefined;
55
- this.errorMessage = undefined;
56
- }
57
- /**
58
- * Método para limpa o campo de entrada de pesquisa
59
- */
60
- clearInput() {
61
- this._inputDistinctSearch.clearInput();
62
- }
63
- /**
64
- * Retorna se o conteúdo é inválido.
65
- */
66
- isInvalid() {
67
- return this._inputDistinctSearch.isInvalid();
68
- }
69
- /**
70
- * Remove o foco do campo
71
- */
72
- setBlur() {
73
- this._inputDistinctSearch.setBlur();
74
- }
75
- /**
76
- * Aplica o foco do campo
77
- */
78
- setFocus() {
79
- this._inputDistinctSearch.setFocus();
80
- }
81
- /**
82
- * Método para fechar o modal
83
- */
84
- closeModal() {
85
- this._searchModalElement.closeModal();
86
- }
87
- /**
88
- * Método para abrir o modal
89
- */
90
- openModal() {
91
- this._searchModalElement.openModal();
92
- }
93
- async componentWillLoad() {
94
- await this.fetchDistinctItems();
95
- this._application = core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
96
- }
97
- async fetchDistinctItems() {
98
- const distinctFetcher = new DistinctSearchFetcher();
99
- const response = await distinctFetcher.fetchItens(this.configSearch.column, this.configSearch.instance);
100
- this.distinctItems = [...response];
101
- }
102
- onChange(event) {
103
- event.stopPropagation();
104
- this.value = event.detail.value;
105
- this._inputDistinctSearch.selectValue(event.detail.value, event.detail.isNewItem);
106
- this.changeValue.emit(event.detail);
107
- }
108
- onPopupClose() {
109
- this._inputDistinctSearch.setFocus();
110
- }
111
- getMessage(key) {
112
- return this._application.messagesBuilder.getMessage(key, null);
113
- }
114
- renderEmptyMessage() {
115
- return (index.h("span", { innerHTML: this.getMessage("snkDistinctSearch.emptyResult") }));
116
- }
117
- render() {
118
- return (index.h(index.Host, null, index.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 }), index.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) })));
119
- }
120
- };
121
- SnkDistinctSearch.style = snkDistinctSearchCss;
122
-
123
- exports.snk_distinct_search = SnkDistinctSearch;
@@ -1,4 +0,0 @@
1
- :host {
2
- display: block;
3
- width: 100%;
4
- }