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