@sankhyalabs/ezui 5.20.0-dev.2 → 5.20.0-dev.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +4 -5
  2. package/dist/cjs/ez-alert-list.cjs.entry.js +33 -28
  3. package/dist/cjs/ez-card-item.cjs.entry.js +52 -0
  4. package/dist/cjs/ez-combo-box.cjs.entry.js +155 -11
  5. package/dist/cjs/ez-filter-input_2.cjs.entry.js +137 -0
  6. package/dist/cjs/ez-form-view.cjs.entry.js +4 -2
  7. package/dist/cjs/ez-grid.cjs.entry.js +3 -3
  8. package/dist/cjs/ez-icon.cjs.entry.js +1 -1
  9. package/dist/cjs/ez-search.cjs.entry.js +31 -611
  10. package/dist/cjs/ez-split-panel.cjs.entry.js +3 -2
  11. package/dist/cjs/ezui.cjs.js +1 -1
  12. package/dist/cjs/index-a7b0c73d.js +6 -2
  13. package/dist/cjs/loader.cjs.js +1 -1
  14. package/dist/collection/collection-manifest.json +2 -2
  15. package/dist/collection/components/ez-alert-list/ez-alert-list.js +33 -28
  16. package/dist/collection/components/ez-card-item/ez-card-item.css +0 -16
  17. package/dist/collection/components/ez-combo-box/ez-combo-box.js +173 -12
  18. package/dist/collection/components/ez-form-view/fieldbuilder/templates/FileInput.tpl.js +4 -2
  19. package/dist/collection/components/ez-grid/ez-grid.css +1 -0
  20. package/dist/collection/components/ez-grid/ez-grid.js +2 -2
  21. package/dist/collection/components/ez-icon/ez-icon.css +1 -1
  22. package/dist/collection/components/ez-search/ez-search.css +0 -330
  23. package/dist/collection/components/ez-search/ez-search.js +55 -689
  24. package/dist/collection/components/ez-split-panel/ez-split-panel.css +7 -0
  25. package/dist/collection/components/ez-split-panel/ez-split-panel.js +19 -1
  26. package/dist/custom-elements/index.js +240 -665
  27. package/dist/esm/ez-alert-list.entry.js +33 -28
  28. package/dist/esm/ez-card-item.entry.js +48 -0
  29. package/dist/esm/ez-combo-box.entry.js +156 -12
  30. package/dist/esm/ez-filter-input_2.entry.js +132 -0
  31. package/dist/esm/ez-form-view.entry.js +4 -2
  32. package/dist/esm/ez-grid.entry.js +3 -3
  33. package/dist/esm/ez-icon.entry.js +1 -1
  34. package/dist/esm/ez-search.entry.js +33 -613
  35. package/dist/esm/ez-split-panel.entry.js +3 -2
  36. package/dist/esm/ezui.js +1 -1
  37. package/dist/esm/index-baa5e267.js +6 -2
  38. package/dist/esm/loader.js +1 -1
  39. package/dist/ezui/ezui.esm.js +1 -1
  40. package/dist/ezui/p-05f5a778.entry.js +1 -0
  41. package/dist/ezui/p-13dbad96.entry.js +1 -0
  42. package/dist/ezui/p-5613fe63.entry.js +1 -0
  43. package/dist/ezui/p-60848ef6.entry.js +1 -0
  44. package/dist/ezui/{p-6e2f8e6b.entry.js → p-844ee673.entry.js} +1 -1
  45. package/dist/ezui/{p-f56dd1da.entry.js → p-93c3df4f.entry.js} +1 -1
  46. package/dist/ezui/p-940ed30b.entry.js +1 -0
  47. package/dist/ezui/p-a32aaac6.entry.js +1 -0
  48. package/dist/ezui/p-a5ac7151.entry.js +1 -0
  49. package/dist/types/components/ez-alert-list/ez-alert-list.d.ts +1 -1
  50. package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +15 -0
  51. package/dist/types/components/ez-search/ez-search.d.ts +10 -100
  52. package/dist/types/components.d.ts +22 -23
  53. package/dist/types/utils/interfaces/AbstractFieldMetadata.d.ts +1 -2
  54. package/package.json +16 -8
  55. package/dist/cjs/ez-card-item_3.cjs.entry.js +0 -182
  56. package/dist/esm/ez-card-item_3.entry.js +0 -176
  57. package/dist/ezui/p-133fae4a.entry.js +0 -1
  58. package/dist/ezui/p-43b03119.entry.js +0 -1
  59. package/dist/ezui/p-4a7f113d.entry.js +0 -1
  60. package/dist/ezui/p-76ba9d67.entry.js +0 -1
  61. package/dist/ezui/p-796c1a88.entry.js +0 -1
  62. package/dist/ezui/p-ba875f37.entry.js +0 -1
@@ -1,25 +1,8 @@
1
- import { h, Host } from "@stencil/core";
1
+ import { h } from "@stencil/core";
2
2
  import CSSVarsUtils from "../../utils/CSSVarsUtils";
3
- import { ElementIDUtils, FloatingManager, ObjectUtils, StringUtils } from "@sankhyalabs/core";
4
- import { ApplicationUtils } from "../../utils";
5
- import { REQUIRED_INFO } from "../../utils/constants";
3
+ import { ElementIDUtils } from "@sankhyalabs/core";
6
4
  export class EzSearch {
7
5
  constructor() {
8
- this._changeDeboucingTimeout = null;
9
- this._limitCharsToSearch = 3;
10
- this._deboucingTime = 300;
11
- this._maxWidthValue = 0;
12
- this._tabPressed = false;
13
- this._textEmptyList = "Nenhum resultado encontrado";
14
- this._textEmptySearch = "Nenhum resultado de {0} encontrado";
15
- this._lookupMode = false;
16
- this._startHighlightTag = "<span class='card-item__highlight'>";
17
- this._endHighlightTag = "</span>";
18
- this._preSelection = undefined;
19
- this._visibleOptions = undefined;
20
- this._startLoading = false;
21
- this._showLoading = true;
22
- this._criteria = undefined;
23
6
  this.value = undefined;
24
7
  this.label = undefined;
25
8
  this.enabled = true;
@@ -34,82 +17,28 @@ export class EzSearch {
34
17
  this.listOptionsPosition = undefined;
35
18
  this.isTextSearch = false;
36
19
  this.ignoreLimitCharsToSearch = false;
37
- this.options = undefined;
38
- this.suppressSearch = false;
39
20
  }
40
21
  observeErrorMessage() {
41
- var _a;
42
- if (this._textInput) {
43
- this._textInput.errorMessage = this.errorMessage;
44
- if (!((_a = this.errorMessage) === null || _a === void 0 ? void 0 : _a.trim())) {
45
- this.setInputValue();
46
- }
22
+ if (this._comboElement) {
23
+ this._comboElement.errorMessage = this.errorMessage;
47
24
  }
48
25
  }
49
- observeValue(newValue, oldValue) {
50
- if (this._textInput && newValue != oldValue) {
51
- try {
52
- if (newValue === "string") {
53
- this.setInputValue();
54
- return;
55
- }
56
- const newValueSelected = this.getSelectedOption(newValue);
57
- const oldValueSelected = this.getSelectedOption(oldValue);
58
- const currentValue = this.getSelectedOption(this.value);
59
- if (this.isDifferentValues(currentValue, newValueSelected)) {
60
- this.value = newValueSelected;
61
- }
62
- if (this.isDifferentValues(newValueSelected, oldValueSelected)) {
63
- this.setInputValue();
64
- const valueEmitted = newValueSelected === null ? undefined : newValueSelected;
65
- if (!this._lookupMode) {
66
- this.ezChange.emit(valueEmitted);
67
- }
68
- }
69
- this.resetOptions();
70
- }
71
- finally {
72
- this._lookupMode = false;
73
- }
26
+ observeValue() {
27
+ if (this._comboElement) {
28
+ this._comboElement.value = this.value;
74
29
  }
75
30
  }
76
- observeOptions(newOptions, oldOptions) {
77
- if ((newOptions === null || newOptions === void 0 ? void 0 : newOptions.join('')) === (oldOptions === null || oldOptions === void 0 ? void 0 : oldOptions.join('')))
78
- return;
79
- this.loadOptions(SearchMode.PRELOAD);
80
- }
81
- /*
82
- * Retorna uma promise com o valor da opção selecionada,
83
- * que será resolvida quando o backend devolver este dado.
84
- */
85
- async getValueAsync() {
86
- if (!this._showLoading) {
87
- return new Promise(resolve => resolve(this.value));
88
- }
89
- return new Promise(resolve => {
90
- let id = setInterval(() => {
91
- if (!this._showLoading) {
92
- clearInterval(id);
93
- resolve(this.value);
94
- }
95
- }, 100);
96
- });
97
- }
98
31
  /**
99
- * Aplica o foco no campo.
100
- */
32
+ * Aplica o foco no campo.
33
+ */
101
34
  async setFocus() {
102
- if (this._textInput) {
103
- this._textInput.setFocus();
104
- }
35
+ this._comboElement.setFocus();
105
36
  }
106
37
  /**
107
- * Remove o foco do campo.
108
- */
38
+ * Remove o foco do campo.
39
+ */
109
40
  async setBlur() {
110
- if (this._textInput) {
111
- this._textInput.setBlur();
112
- }
41
+ this._comboElement.setBlur();
113
42
  }
114
43
  /**
115
44
  * Retorna se o conteúdo é inválido.
@@ -121,533 +50,33 @@ export class EzSearch {
121
50
  * Limpa o valor do campo de pesquisa
122
51
  */
123
52
  async clearValue() {
124
- this.clearSearch();
125
- }
126
- scrollListener() {
127
- var _a;
128
- if (this._floatingID == undefined) {
129
- return;
130
- }
131
- if ((_a = this.listOptionsPosition) === null || _a === void 0 ? void 0 : _a.hardPosition) {
132
- this.hideOptions();
133
- }
134
- else {
135
- window.requestAnimationFrame(() => {
136
- this.updateListPosition();
137
- });
138
- }
139
- }
140
- updateListPosition() {
141
- let { verticalPosition, horizontalPosition, fromBottom, fromRight, bottomLimit, hardPosition } = this.getListPosition();
142
- const elementRect = this._listWrapper.getBoundingClientRect();
143
- const containerRect = this._listContainer.getBoundingClientRect();
144
- const textInputRect = this._textInput.getBoundingClientRect();
145
- const limitHeight = bottomLimit || window.innerHeight;
146
- const neededHeight = containerRect.bottom + elementRect.height;
147
- if (!fromBottom && (elementRect.top < 0 || neededHeight > limitHeight)) {
148
- fromBottom = true;
149
- }
150
- if (!hardPosition) {
151
- verticalPosition = verticalPosition || 0;
152
- horizontalPosition = horizontalPosition || 0;
153
- if (fromBottom) {
154
- verticalPosition = window.innerHeight - textInputRect.top + verticalPosition;
155
- }
156
- else {
157
- verticalPosition += containerRect.top;
158
- }
159
- if (fromRight) {
160
- horizontalPosition = window.innerWidth - textInputRect.right + horizontalPosition;
161
- }
162
- else {
163
- horizontalPosition += containerRect.left;
164
- }
165
- }
166
- if (verticalPosition != undefined) {
167
- this._listWrapper.style[fromBottom ? "bottom" : "top"] = `${verticalPosition}px`;
168
- this._listWrapper.style[fromBottom ? "top" : "bottom"] = "";
169
- }
170
- if (horizontalPosition != undefined) {
171
- this._listWrapper.style[fromRight ? "right" : "left"] = `${horizontalPosition}px`;
172
- this._listWrapper.style[fromRight ? "left" : "right"] = "";
173
- }
174
- }
175
- getListPosition() {
176
- if (this.listOptionsPosition) {
177
- return this.listOptionsPosition;
178
- }
179
- return {
180
- verticalPosition: (this.errorMessage || !this.canShowError || this.mode === "slim") ? 6 : -13
181
- };
182
- }
183
- isDifferentValues(firstValue, secondValue) {
184
- return ObjectUtils.objectToString(firstValue || {}) !== ObjectUtils.objectToString(secondValue || {});
185
- }
186
- getFormattedText(currentValue) {
187
- if (currentValue == undefined) {
188
- return;
189
- }
190
- if (!this.showSelectedValue || currentValue.value == undefined) {
191
- return currentValue.label;
192
- }
193
- return currentValue.label ? `${currentValue.value} - ${currentValue.label}` : currentValue.value;
194
- }
195
- getText() {
196
- const currentValue = this.getSelectedOption(this.value);
197
- const text = this.getFormattedText(currentValue);
198
- if (text == undefined) {
199
- return;
200
- }
201
- return String(text)
202
- .replace(/&amp;/g, '&')
203
- .replace(/&lt;/g, '<')
204
- .replace(/&gt;/g, '>')
205
- .replace(/&quot;/g, '"');
206
- }
207
- getSelectedOption(value) {
208
- if (typeof value === "string" || value instanceof String) {
209
- return this._visibleOptions.find(o => o.value === value);
210
- }
211
- return value;
212
- }
213
- updateVisibleOptions() {
214
- let opts = this._source || [];
215
- if (this.suppressEmptyOption) {
216
- this._visibleOptions = opts;
217
- }
218
- else {
219
- this._visibleOptions = [{ value: undefined, label: "" }].concat(opts);
220
- }
221
- this._maxWidthValue = this.getMaxWidthValue();
222
- }
223
- getMaxWidthValue() {
224
- var _a;
225
- const arrValues = [];
226
- (_a = this._visibleOptions) === null || _a === void 0 ? void 0 : _a.forEach(opt => {
227
- const widthValue = this.getWidthValue(opt.value);
228
- if (!arrValues.includes(widthValue)) {
229
- arrValues.push(widthValue);
230
- }
231
- });
232
- return arrValues.length > 1 ? Math.max(...arrValues) : 0;
233
- }
234
- getWidthValue(value) {
235
- if (this._itemValueBasis != undefined) {
236
- const span = this._itemValueBasis;
237
- if (value != undefined) {
238
- span.innerHTML = value;
239
- return span.clientWidth > 0 ? (span.clientWidth + 2) : 0;
240
- }
241
- else {
242
- span.innerHTML = "";
243
- }
244
- }
245
- return 0;
246
- }
247
- createOption(detail) {
248
- let { key, title } = detail;
249
- const startHighlight = new RegExp(this._startHighlightTag, 'g');
250
- const endHighlight = new RegExp(this._endHighlightTag, 'g');
251
- title = StringUtils.decodeHtmlEntities(title);
252
- const option = {
253
- value: key === null || key === void 0 ? void 0 : key.replace(startHighlight, '').replace(endHighlight, ''),
254
- label: title === null || title === void 0 ? void 0 : title.replace(startHighlight, '').replace(endHighlight, '')
255
- };
256
- this.selectOption(option);
257
- }
258
- buildItem(opt, index) {
259
- opt.label = opt.label || opt.value;
260
- const card = {
261
- key: opt.value,
262
- title: opt.label,
263
- details: opt.details
264
- };
265
- return h("div", { style: { "height": "100%" }, onMouseDown: () => this.createOption(card), onMouseOver: () => this._preSelection = index }, h("ez-card-item", { item: card }));
266
- }
267
- showOptions() {
268
- if (!this.enabled)
269
- return;
270
- if (this.isOptionsVisible()) {
271
- return;
272
- }
273
- if (!!this._resizeObserver)
274
- this._resizeObserver.observe(this._textInput);
275
- this._floatingID = FloatingManager.float(this._listWrapper, this._listContainer, { autoClose: false, isFixed: true, backClickListener: () => this.hideOptions() });
276
- this.setFocus();
277
- window.requestAnimationFrame(() => {
278
- this.updateListPosition();
279
- if (!this.listOptionsPosition) {
280
- this._listWrapper.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "nearest" });
281
- }
282
- });
283
- }
284
- hideOptions() {
285
- if (this._floatingID !== undefined) {
286
- FloatingManager.close(this._floatingID);
287
- }
288
- this._floatingID = undefined;
289
- if (!!this._resizeObserver)
290
- this._resizeObserver.unobserve(this._textInput);
291
- }
292
- isOptionsVisible() {
293
- return this._floatingID !== undefined && FloatingManager.isFloating(this._floatingID);
294
- }
295
- nextOption() {
296
- if (!this.isOptionsVisible()) {
297
- return;
298
- }
299
- this.showOptions();
300
- this._preSelection = this._preSelection === undefined ? 0 : Math.min(this._preSelection + 1, this._visibleOptions.length - 1);
301
- this.scrollToOption(this._visibleOptions[this._preSelection]);
302
- }
303
- previousOption() {
304
- this._preSelection = this._preSelection === undefined ? 0 : Math.max(this._preSelection - 1, 0);
305
- this.scrollToOption(this._visibleOptions[this._preSelection]);
306
- }
307
- scrollToOption(opt) {
308
- window.requestAnimationFrame(() => {
309
- const liElem = (opt === null || opt === void 0 ? void 0 : opt.value) ? this._optionsList.querySelector(`li#item_${opt.value.replace(/[<>\[\]#=]/g, '\\$&').replace(/:/g, '\\:')}`) : undefined;
310
- if (liElem)
311
- liElem.scrollIntoView({ behavior: "smooth", block: "nearest" });
312
- });
313
- }
314
- selectCurrentOption() {
315
- if (this._preSelection !== undefined) {
316
- this.selectOption(this._visibleOptions[this._preSelection]);
317
- this._preSelection = undefined;
318
- }
319
- else {
320
- this.controlListWithOnlyOne();
321
- }
322
- }
323
- updateSource(source) {
324
- this._startLoading = false;
325
- if (source instanceof Promise) {
326
- this._showLoading = true;
327
- source.then(result => {
328
- this._showLoading = false;
329
- this.updateSource(result);
330
- }).catch(() => this._showLoading = false);
331
- this.updateVisibleOptions();
332
- }
333
- else {
334
- this._showLoading = false;
335
- if (Array.isArray(source)) {
336
- this._source = source;
337
- this.updateVisibleOptions();
338
- if (this._tabPressed) {
339
- this._tabPressed = false;
340
- this.controlEmptySearch();
341
- }
342
- }
343
- else {
344
- this.selectOption(source);
345
- }
346
- }
347
- }
348
- clearSource() {
349
- this._source = [];
350
- this.updateVisibleOptions();
351
- }
352
- selectOption(newOption) {
353
- var _a, _b;
354
- const currentValue = this.getSelectedOption(this.value);
355
- if ((((_a = currentValue === null || currentValue === void 0 ? void 0 : currentValue.value) === null || _a === void 0 ? void 0 : _a.toString()) !== ((_b = newOption === null || newOption === void 0 ? void 0 : newOption.value) === null || _b === void 0 ? void 0 : _b.toString()))
356
- || (currentValue == undefined && newOption != undefined && "value" in newOption)) {
357
- const adjustedOpt = !(newOption === null || newOption === void 0 ? void 0 : newOption.value) ? undefined : newOption;
358
- this.value = adjustedOpt;
359
- }
360
- else {
361
- this.resetOptions();
362
- }
363
- this._visibleOptions = [];
364
- this.clearSource();
365
- }
366
- loadOptions(mode, argument = "") {
367
- this._criteria = argument;
368
- this._startLoading = true;
369
- if (this.optionLoader) {
370
- const searchArgument = { mode, argument };
371
- this.updateSource(this.optionLoader(searchArgument));
372
- }
373
- else {
374
- this.updateSource(this.options);
375
- }
376
- }
377
- cancelPreselection() {
378
- if (!this._textInput.value && this.value) {
379
- this.selectOption(undefined);
380
- }
381
- else {
382
- window.setTimeout(() => {
383
- this.setInputValue();
384
- }, this._deboucingTime);
385
- }
386
- this.resetOptions();
387
- }
388
- setInputValue(clearError = true) {
389
- const textValue = this.getText();
390
- if ((this._textInput.value || '') !== textValue) {
391
- this._textInput.value = textValue;
392
- if (clearError) {
393
- this.errorMessage = null;
394
- }
395
- }
396
- }
397
- clearSearch() {
398
- this.value = null;
399
- }
400
- controlListWithOnlyOne() {
401
53
  var _a, _b;
402
- const source = (_a = this._visibleOptions) === null || _a === void 0 ? void 0 : _a.filter((opt) => opt.label !== "" && opt.value != undefined);
403
- if ((source === null || source === void 0 ? void 0 : source.length) > 0) {
404
- const startHighlight = new RegExp(this._startHighlightTag, 'g');
405
- const endHighlight = new RegExp(this._endHighlightTag, 'g');
406
- let title = StringUtils.decodeHtmlEntities(source[0].label);
407
- const option = {
408
- value: (_b = source[0].value) === null || _b === void 0 ? void 0 : _b.replace(startHighlight, '').replace(endHighlight, ''),
409
- label: title === null || title === void 0 ? void 0 : title.replace(startHighlight, '').replace(endHighlight, '')
410
- };
411
- this.selectOption(option);
412
- }
54
+ (_b = (_a = this._comboElement) === null || _a === void 0 ? void 0 : _a['clearValue']) === null || _b === void 0 ? void 0 : _b.call(_a);
413
55
  }
414
- controlEmptySearch() {
415
- var _a;
416
- if (!((_a = this._visibleOptions) === null || _a === void 0 ? void 0 : _a.length)) {
417
- this.clearSearch();
418
- ApplicationUtils.info(this._textEmptyList);
419
- }
420
- else {
421
- this.controlListWithOnlyOne();
422
- }
423
- }
424
- validateDescriptionValue() {
425
- if (StringUtils.isEmpty(this.value)) {
426
- return;
427
- }
428
- let value = this.value;
429
- if (typeof value === "object") {
430
- return;
431
- }
432
- if (StringUtils.isEmpty(value)) {
433
- return;
434
- }
435
- this.loadDescriptionValue(value);
436
- }
437
- async loadDescriptionValue(argument) {
438
- var _a, _b;
439
- if (argument == undefined) {
440
- return;
441
- }
442
- if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.length) > 0) {
443
- this.loadOptionValue(argument);
444
- return;
445
- }
446
- const searchArgument = {
447
- mode: SearchMode.PREDICTIVE,
448
- argument
449
- };
450
- const source = await ((_b = this.optionLoader) === null || _b === void 0 ? void 0 : _b.call(this, searchArgument));
451
- if (source == undefined) {
452
- return;
453
- }
454
- if (source instanceof Promise) {
455
- source.then((result) => {
456
- this.setDescriptionValue(result);
457
- });
458
- }
459
- else {
460
- this.setDescriptionValue(source);
461
- }
462
- }
463
- setDescriptionValue(source) {
464
- const value = (source === null || source === void 0 ? void 0 : source[0]) || source;
465
- if (value == undefined || !Object.keys(value).length) {
466
- this.showNoResultMessage();
467
- return;
468
- }
469
- this._lookupMode = true;
470
- this.value = value;
471
- }
472
- loadOptionValue(argument) {
473
- var _a;
474
- const source = (_a = this.options) === null || _a === void 0 ? void 0 : _a.find((opt) => opt.value === argument);
475
- if (source != undefined) {
476
- this.selectOption(source);
477
- }
478
- else {
479
- this.showNoResultMessage();
480
- }
481
- }
482
- async showNoResultMessage() {
483
- this.clearSearch();
484
- ApplicationUtils.info(this._textEmptySearch.replace("{0}", this.getFieldLabel()));
485
- }
486
- getFieldLabel() {
56
+ /*
57
+ * Retorna uma promise com o valor da opção selecionada,
58
+ * que será resolvida quando o backend devolver este dado.
59
+ */
60
+ async getValueAsync() {
487
61
  var _a;
488
- return (_a = this.label) === null || _a === void 0 ? void 0 : _a.replace(REQUIRED_INFO, "").toUpperCase();
489
- }
490
- resetOptions() {
491
- this.hideOptions();
492
- this._criteria = undefined;
493
- this._preSelection = undefined;
494
- this.updateVisibleOptions();
62
+ return (_a = this._comboElement) === null || _a === void 0 ? void 0 : _a.getValueAsync();
495
63
  }
496
- //---------------------------------------------
497
- // Lifecycle web component
498
- //---------------------------------------------
499
- componentWillLoad() {
500
- if (this.options === undefined) {
501
- this.options = [];
502
- const optionsTags = this.el.querySelectorAll("option");
503
- if (optionsTags) {
504
- optionsTags.forEach(e => {
505
- let label = e.innerText;
506
- let value = e.getAttribute("value");
507
- let details = e.getAttribute("details");
508
- if (!value) {
509
- value = label;
510
- }
511
- this.options.push({ label, value, details });
512
- e.hidden = true;
513
- });
514
- }
515
- }
516
- this.updateSource([]);
517
- }
518
- componentDidRender() {
519
- var _a;
520
- if (this._floatingID === undefined) {
521
- this._listWrapper.remove();
64
+ onComboChange(event) {
65
+ event.stopPropagation();
66
+ this.value = event.detail;
67
+ this.ezChange.emit(event.detail);
68
+ if (this.errorMessage !== this._comboElement.errorMessage) {
69
+ this.errorMessage = this._comboElement.errorMessage;
522
70
  }
523
- (_a = this._optionsList) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".item").forEach((elem) => {
524
- ElementIDUtils.addIDInfoIfNotExists(elem, "itemSearch");
525
- });
526
- this.validateDescriptionValue();
527
71
  }
528
72
  componentDidLoad() {
529
- CSSVarsUtils.applyVarsTextInput(this.el, this._textInput);
530
- this.setInputValue(false);
531
- this._resizeObserver = new ResizeObserver((entries) => {
532
- window.requestAnimationFrame(() => {
533
- if (!Array.isArray(entries) || !entries.length)
534
- return;
535
- const { clientWidth } = this._listContainer;
536
- if (clientWidth > 0 && !!this._listWrapper) {
537
- this._listWrapper.style.width = `${clientWidth}px`;
538
- }
539
- });
540
- });
541
- }
542
- //---------------------------------------------
543
- // Event handlers
544
- //---------------------------------------------
545
- handlerIconClick() {
546
- this.loadOptions(SearchMode.ADVANCED);
547
- }
548
- buildNumberArgument(argument) {
549
- if (this.isTextSearch) {
550
- return NaN;
551
- }
552
- return Number(argument || undefined);
553
- }
554
- onTextInputChangeHandler(event) {
555
- var _a;
556
- this.clearDeboucingTimeout();
557
- if (this._startLoading) {
558
- this._changeDeboucingTimeout = window.setTimeout(() => {
559
- this.onTextInputChangeHandler(event);
560
- }, this._deboucingTime);
561
- return;
562
- }
563
- const argument = (_a = event.target.value) === null || _a === void 0 ? void 0 : _a.trim();
564
- const argumentNumber = this.buildNumberArgument(argument);
565
- if (!this._criteria) {
566
- this._textInput.value = event.data || argument;
567
- }
568
- this._criteria = argument;
569
- if (argument) {
570
- this._showLoading = false;
571
- this.clearSource();
572
- if (!isNaN(argumentNumber) || argument.length >= this._limitCharsToSearch) {
573
- this._showLoading = true;
574
- this._changeDeboucingTimeout = window.setTimeout(() => {
575
- this.loadOptions(SearchMode.PREDICTIVE, isNaN(argumentNumber) ? argument : argumentNumber.toString());
576
- }, this._deboucingTime);
577
- this.showOptions();
578
- }
579
- else {
580
- this.hideOptions();
581
- }
582
- }
583
- else {
584
- this.hideOptions();
585
- this._showLoading = false;
586
- this.clearSource();
587
- }
588
- }
589
- clearDeboucingTimeout() {
590
- if (this._changeDeboucingTimeout) {
591
- window.clearTimeout(this._changeDeboucingTimeout);
592
- this._changeDeboucingTimeout = null;
593
- }
594
- }
595
- keyDownHandler(event) {
596
- this._tabPressed = false;
597
- if (event.ctrlKey) {
598
- if (event.key === "f" || event.key === "F") {
599
- this.loadOptions(SearchMode.ADVANCED);
600
- //ATENÇÃO: Ctrl + F tem ação específica nos browsers
601
- //nesse caso, como vamos abrir o popup de busca avançada,
602
- //não é interessante deixar o evento propagar;
603
- event.stopPropagation();
604
- event.stopImmediatePropagation();
605
- event.preventDefault();
606
- }
607
- }
608
- switch (event.key) {
609
- case "ArrowDown":
610
- this.nextOption();
611
- event.stopPropagation();
612
- break;
613
- case "ArrowUp":
614
- this.previousOption();
615
- event.stopPropagation();
616
- break;
617
- case "Enter":
618
- this.selectCurrentOption();
619
- break;
620
- case "Escape":
621
- this.cancelPreselection();
622
- break;
623
- case "Tab":
624
- this._tabPressed = true;
625
- this.controlListWithOnlyOne();
626
- break;
627
- }
628
- //ATENÇÃO: Existe a necessidade de propagar o evento de teclado.
629
- //Por exemplo, quando o usuário dá um Enter, além de selecionar
630
- //um valor, também significa que a ateração finalizou,
631
- //e o contexto pode reagir (fechar um popup por exemplo).
632
- //event.stopPropagation();
633
- }
634
- onTextInputFocusOutHandler() {
635
- if (this.hideErrorOnFocusOut)
636
- this.cancelPreselection();
637
- }
638
- canShowListOptions() {
639
- return !this._showLoading && this._visibleOptions.length > 0;
73
+ CSSVarsUtils.applyVarsTextInput(this._elem, this._comboElement);
640
74
  }
641
75
  render() {
642
- var _a;
643
- ElementIDUtils.addIDInfoIfNotExists(this.el, 'input');
644
- return (h(Host, null, h("ez-text-input", { "data-element-id": ElementIDUtils.getInternalIDInfo("textInput"), class: this.suppressSearch ? "suppressed-search-input" : "", ref: elem => this._textInput = elem, "data-slave-mode": "true", enabled: this.enabled && !this.suppressSearch, onInput: event => this.onTextInputChangeHandler(event), onFocusout: () => this.onTextInputFocusOutHandler(), onKeyDown: event => this.keyDownHandler(event), label: this.label, canShowError: this.canShowError, errorMessage: this.errorMessage, mode: this.mode }, h("button", { class: "btn", slot: "leftIcon", disabled: !this.enabled, tabindex: -1, onClick: () => this.handlerIconClick() }, h("ez-icon", { iconName: "search" })), ((_a = this._textInput) === null || _a === void 0 ? void 0 : _a.value) && (this._criteria || this.value)
645
- ? h("button", { class: "btn btn__close", slot: "rightIcon", disabled: !this.enabled, tabindex: -1, onClick: () => this.clearSearch() }, h("ez-icon", { iconName: "close" }))
646
- : undefined), h("section", { class: "list-container", ref: elem => this._listContainer = elem }, h("div", { class: "list-wrapper", ref: elem => this._listWrapper = elem }, h("ul", { class: "list-options", ref: elem => this._optionsList = elem }, !this._showLoading
647
- && this._visibleOptions.length === 0
648
- && h("div", { class: "message" }, h("span", { class: "message__no-result" }, this._textEmptyList)), this._showLoading
649
- && h("div", { class: "message" }, h("div", { class: "message__loading" })), h("span", { class: "item__value item__value--hidden", ref: elem => this._itemValueBasis = elem }), this.canShowListOptions() && this._visibleOptions.map((opt, index) => this.buildItem(opt, index)))))));
76
+ ElementIDUtils.addIDInfoIfNotExists(this._elem, 'input');
77
+ return (h("ez-combo-box", { "data-element-id": ElementIDUtils.getInternalIDInfo("combo"), ref: elem => this._comboElement = elem, value: this.value, label: this.label, enabled: this.enabled, errorMessage: this.errorMessage, hideErrorOnFocusOut: this.hideErrorOnFocusOut, optionLoader: this.optionLoader, searchMode: true, onEzChange: event => this.onComboChange(event), showSelectedValue: this.showSelectedValue, showOptionValue: this.showOptionValue, suppressEmptyOption: this.suppressEmptyOption, mode: this.mode, canShowError: this.canShowError, listOptionsPosition: this.listOptionsPosition, isTextSearch: this.isTextSearch, limitCharsToSearch: this.ignoreLimitCharsToSearch ? 0 : 3 }));
650
78
  }
79
+ ;
651
80
  static get is() { return "ez-search"; }
652
81
  static get encapsulation() { return "shadow"; }
653
82
  static get originalStyleUrls() {
@@ -670,7 +99,8 @@ export class EzSearch {
670
99
  "resolved": "IOption | string",
671
100
  "references": {
672
101
  "IOption": {
673
- "location": "local"
102
+ "location": "import",
103
+ "path": "../ez-combo-box/ez-combo-box"
674
104
  }
675
105
  }
676
106
  },
@@ -743,7 +173,8 @@ export class EzSearch {
743
173
  "resolved": "(argument: ISearchArgument) => IOption | IOption[] | Promise<IOption[]>",
744
174
  "references": {
745
175
  "ISearchArgument": {
746
- "location": "local"
176
+ "location": "import",
177
+ "path": "../ez-combo-box/ez-combo-box"
747
178
  },
748
179
  "Promise": {
749
180
  "location": "global"
@@ -752,7 +183,8 @@ export class EzSearch {
752
183
  "location": "global"
753
184
  },
754
185
  "IOption": {
755
- "location": "local"
186
+ "location": "import",
187
+ "path": "../ez-combo-box/ez-combo-box"
756
188
  }
757
189
  }
758
190
  },
@@ -926,58 +358,9 @@ export class EzSearch {
926
358
  "attribute": "ignore-limit-chars-to-search",
927
359
  "reflect": false,
928
360
  "defaultValue": "false"
929
- },
930
- "options": {
931
- "type": "unknown",
932
- "mutable": true,
933
- "complexType": {
934
- "original": "Array<IOption>",
935
- "resolved": "IOption[]",
936
- "references": {
937
- "Array": {
938
- "location": "global"
939
- },
940
- "IOption": {
941
- "location": "local"
942
- }
943
- }
944
- },
945
- "required": false,
946
- "optional": false,
947
- "docs": {
948
- "tags": [],
949
- "text": "Array com as op\u00E7\u00F5es do ez-combo-box. Os elementos devem obedecer\no formato: `{value: string, label: string}`."
950
- }
951
- },
952
- "suppressSearch": {
953
- "type": "boolean",
954
- "mutable": false,
955
- "complexType": {
956
- "original": "boolean",
957
- "resolved": "boolean",
958
- "references": {}
959
- },
960
- "required": false,
961
- "optional": false,
962
- "docs": {
963
- "tags": [],
964
- "text": "Se true desabilita a digita\u00E7\u00E3o dentro do componente."
965
- },
966
- "attribute": "suppress-search",
967
- "reflect": false,
968
- "defaultValue": "false"
969
361
  }
970
362
  };
971
363
  }
972
- static get states() {
973
- return {
974
- "_preSelection": {},
975
- "_visibleOptions": {},
976
- "_startLoading": {},
977
- "_showLoading": {},
978
- "_criteria": {}
979
- };
980
- }
981
364
  static get events() {
982
365
  return [{
983
366
  "method": "ezChange",
@@ -994,7 +377,8 @@ export class EzSearch {
994
377
  "resolved": "IOption",
995
378
  "references": {
996
379
  "IOption": {
997
- "location": "local"
380
+ "location": "import",
381
+ "path": "../ez-combo-box/ez-combo-box"
998
382
  }
999
383
  }
1000
384
  }
@@ -1002,22 +386,6 @@ export class EzSearch {
1002
386
  }
1003
387
  static get methods() {
1004
388
  return {
1005
- "getValueAsync": {
1006
- "complexType": {
1007
- "signature": "() => Promise<unknown>",
1008
- "parameters": [],
1009
- "references": {
1010
- "Promise": {
1011
- "location": "global"
1012
- }
1013
- },
1014
- "return": "Promise<unknown>"
1015
- },
1016
- "docs": {
1017
- "text": "",
1018
- "tags": []
1019
- }
1020
- },
1021
389
  "setFocus": {
1022
390
  "complexType": {
1023
391
  "signature": "() => Promise<void>",
@@ -1081,10 +449,26 @@ export class EzSearch {
1081
449
  "text": "Limpa o valor do campo de pesquisa",
1082
450
  "tags": []
1083
451
  }
452
+ },
453
+ "getValueAsync": {
454
+ "complexType": {
455
+ "signature": "() => Promise<unknown>",
456
+ "parameters": [],
457
+ "references": {
458
+ "Promise": {
459
+ "location": "global"
460
+ }
461
+ },
462
+ "return": "Promise<unknown>"
463
+ },
464
+ "docs": {
465
+ "text": "",
466
+ "tags": []
467
+ }
1084
468
  }
1085
469
  };
1086
470
  }
1087
- static get elementRef() { return "el"; }
471
+ static get elementRef() { return "_elem"; }
1088
472
  static get watchers() {
1089
473
  return [{
1090
474
  "propName": "errorMessage",
@@ -1092,24 +476,6 @@ export class EzSearch {
1092
476
  }, {
1093
477
  "propName": "value",
1094
478
  "methodName": "observeValue"
1095
- }, {
1096
- "propName": "options",
1097
- "methodName": "observeOptions"
1098
- }];
1099
- }
1100
- static get listeners() {
1101
- return [{
1102
- "name": "scroll",
1103
- "method": "scrollListener",
1104
- "target": "window",
1105
- "capture": true,
1106
- "passive": true
1107
479
  }];
1108
480
  }
1109
481
  }
1110
- var SearchMode;
1111
- (function (SearchMode) {
1112
- SearchMode["ADVANCED"] = "ADVANCED";
1113
- SearchMode["PRELOAD"] = "PRELOAD";
1114
- SearchMode["PREDICTIVE"] = "PREDICTIVE";
1115
- })(SearchMode || (SearchMode = {}));