@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-74246.1 → 0.0.0-bugfix-dev-KB-76362.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{SnkFormConfigManager-bff848f1.js → SnkFormConfigManager-63369164.js} +3 -3
- package/dist/cjs/{SnkMessageBuilder-bae64d0d.js → SnkMessageBuilder-7691a2c1.js} +10 -0
- package/dist/cjs/index-f9e81701.js +8 -0
- package/dist/cjs/input-distinct-search_2.cjs.entry.js +471 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-application.cjs.entry.js +1 -1
- package/dist/cjs/snk-config-options_3.cjs.entry.js +1 -1
- package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
- package/dist/cjs/{snk-data-unit-3d4d0e2a.js → snk-data-unit-7dbdad0e.js} +1 -1
- package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
- package/dist/cjs/snk-detail-view.cjs.entry.js +3 -3
- package/dist/cjs/snk-distinct-search.cjs.entry.js +123 -0
- package/dist/cjs/{snk-guides-viewer-2b44c804.js → snk-guides-viewer-eee43c8b.js} +1 -1
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +2 -2
- package/dist/cjs/snk-simple-crud.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +3 -0
- package/dist/collection/components/snk-distinct-search/snk-distinct-search.css +4 -0
- package/dist/collection/components/snk-distinct-search/snk-distinct-search.js +372 -0
- package/dist/collection/components/snk-distinct-search/subcomponents/input-distinct-search/input-distinct-search.css +110 -0
- package/dist/collection/components/snk-distinct-search/subcomponents/input-distinct-search/input-distinct-search.js +544 -0
- package/dist/collection/components/snk-distinct-search/subcomponents/search-modal/search-modal.css +28 -0
- package/dist/collection/components/snk-distinct-search/subcomponents/search-modal/search-modal.js +593 -0
- package/dist/collection/components/snk-distinct-search/types/index.js +1 -0
- package/dist/collection/components/snk-distinct-search/utils/filter-distinct-search.js +15 -0
- package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +3 -3
- package/dist/collection/lib/http/data-fetcher/fetchers/distinct-search-fetcher.js +25 -0
- package/dist/collection/lib/message/SnkMessageBuilder.js +2 -0
- package/dist/collection/lib/message/resources/snk-distinct-search.msg.js +9 -0
- package/dist/components/SnkFormConfigManager.js +3 -3
- package/dist/components/SnkMessageBuilder.js +10 -0
- package/dist/components/filter-distinct-search.js +17 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.js +3 -0
- package/dist/components/input-distinct-search.d.ts +11 -0
- package/dist/components/input-distinct-search.js +6 -0
- package/dist/components/input-distinct-search2.js +264 -0
- package/dist/components/search-modal.d.ts +11 -0
- package/dist/components/search-modal.js +6 -0
- package/dist/components/search-modal2.js +264 -0
- package/dist/components/snk-distinct-search.d.ts +11 -0
- package/dist/components/snk-distinct-search.js +163 -0
- package/dist/esm/{SnkFormConfigManager-f0532f7d.js → SnkFormConfigManager-b409c745.js} +3 -3
- package/dist/esm/{SnkMessageBuilder-6fff4a4c.js → SnkMessageBuilder-7ace6803.js} +10 -0
- package/dist/esm/index-a7d3d3f1.js +8 -0
- package/dist/esm/input-distinct-search_2.entry.js +466 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-application.entry.js +1 -1
- package/dist/esm/snk-config-options_3.entry.js +1 -1
- package/dist/esm/snk-data-exporter.entry.js +2 -2
- package/dist/esm/{snk-data-unit-618e0b80.js → snk-data-unit-7a579dbd.js} +1 -1
- package/dist/esm/snk-data-unit.entry.js +2 -2
- package/dist/esm/snk-detail-view.entry.js +3 -3
- package/dist/esm/snk-distinct-search.entry.js +119 -0
- package/dist/esm/{snk-guides-viewer-15c916a3.js → snk-guides-viewer-e8ca764a.js} +1 -1
- package/dist/esm/snk-guides-viewer.entry.js +2 -2
- package/dist/esm/snk-simple-crud.entry.js +1 -1
- package/dist/sankhyablocks/{p-9c3138f5.entry.js → p-00f9fe5c.entry.js} +1 -1
- package/dist/sankhyablocks/p-0e206e62.js +1 -0
- package/dist/sankhyablocks/{p-c88ad28e.entry.js → p-0e250436.entry.js} +1 -1
- package/dist/sankhyablocks/{p-da87e42c.entry.js → p-154aa2a6.entry.js} +1 -1
- package/dist/sankhyablocks/p-18cb1acb.entry.js +1 -0
- package/dist/sankhyablocks/{p-bab79110.entry.js → p-30ebcbe0.entry.js} +1 -1
- package/dist/sankhyablocks/p-3755b46f.entry.js +1 -0
- package/dist/sankhyablocks/{p-d1da52e1.entry.js → p-42130213.entry.js} +1 -1
- package/dist/sankhyablocks/{p-e41bd8ee.entry.js → p-b389ed49.entry.js} +1 -1
- package/dist/sankhyablocks/{p-a75e9dcc.js → p-c75fae8e.js} +1 -1
- package/dist/sankhyablocks/p-d8665750.js +1 -0
- package/dist/sankhyablocks/{p-ae50d69f.js → p-e3a285a2.js} +1 -1
- package/dist/sankhyablocks/{p-c1adf0dd.entry.js → p-f4e221b2.entry.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-distinct-search/snk-distinct-search.d.ts +83 -0
- package/dist/types/components/snk-distinct-search/subcomponents/input-distinct-search/input-distinct-search.d.ts +105 -0
- package/dist/types/components/snk-distinct-search/subcomponents/search-modal/search-modal.d.ts +127 -0
- package/dist/types/components/snk-distinct-search/types/index.d.ts +12 -0
- package/dist/types/components/snk-distinct-search/utils/filter-distinct-search.d.ts +4 -0
- package/dist/types/components.d.ts +393 -1
- package/dist/types/lib/http/data-fetcher/fetchers/distinct-search-fetcher.d.ts +6 -0
- package/dist/types/lib/message/resources/snk-distinct-search.msg.d.ts +2 -0
- package/package.json +1 -1
- package/react/components.d.ts +3 -0
- package/react/components.js +3 -0
- package/react/components.js.map +1 -1
- package/dist/sankhyablocks/p-17425c72.js +0 -1
- package/dist/sankhyablocks/p-a0ebd886.js +0 -1
package/dist/collection/components/snk-distinct-search/subcomponents/search-modal/search-modal.js
ADDED
|
@@ -0,0 +1,593 @@
|
|
|
1
|
+
import { EzScrollDirection } from '@sankhyalabs/ezui/dist/collection/components/ez-scroller/EzScrollDirection';
|
|
2
|
+
import { Host, h } from '@stencil/core';
|
|
3
|
+
import { KeyboardManager } from '@sankhyalabs/core';
|
|
4
|
+
import { filterItems, getMatchOption, normalizeString } from '../../utils/filter-distinct-search';
|
|
5
|
+
export class SearchModal {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.debounceTimeout = null;
|
|
8
|
+
this.filteredItems = [];
|
|
9
|
+
this.searchFocus = false;
|
|
10
|
+
this.isLimited = false;
|
|
11
|
+
this.application = undefined;
|
|
12
|
+
this.listItens = [];
|
|
13
|
+
this.opened = false;
|
|
14
|
+
this.value = undefined;
|
|
15
|
+
this.canShowError = false;
|
|
16
|
+
this.emptyMessage = undefined;
|
|
17
|
+
this.debounceTime = 300;
|
|
18
|
+
this.maxItens = 100;
|
|
19
|
+
this.label = 'Pesquisar';
|
|
20
|
+
this.mode = 'regular';
|
|
21
|
+
this.restrict = undefined;
|
|
22
|
+
this.errorMessage = undefined;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Método para adicionar a nova palavra e chamar o método closeModal() para fechar o modal
|
|
26
|
+
*/
|
|
27
|
+
addNewItem() {
|
|
28
|
+
this.closeModal();
|
|
29
|
+
this.changeValue.emit({ isNewItem: true, value: this.value });
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Método para limpa o campo de entrada de pesquisa
|
|
33
|
+
*/
|
|
34
|
+
clearInput() {
|
|
35
|
+
this._refFilterInput.setValue("");
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Método para fechar o modal
|
|
39
|
+
*/
|
|
40
|
+
closeModal() {
|
|
41
|
+
this._popupElement.opened = false;
|
|
42
|
+
this.popupClose.emit(false);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Método para abrir o modal
|
|
46
|
+
*/
|
|
47
|
+
openModal() {
|
|
48
|
+
this._popupElement.opened = true;
|
|
49
|
+
setTimeout(() => this.setFocus(), 100);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Retorna se o conteúdo é inválido.
|
|
53
|
+
*/
|
|
54
|
+
isInvalid() {
|
|
55
|
+
this._refFilterInput.isInvalid();
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Remove o foco do campo
|
|
59
|
+
*/
|
|
60
|
+
setBlur() {
|
|
61
|
+
this._refFilterInput.setBlur();
|
|
62
|
+
this.searchFocus = false;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Aplica o foco do campo
|
|
66
|
+
*/
|
|
67
|
+
setFocus() {
|
|
68
|
+
this._refFilterInput.setFocus();
|
|
69
|
+
this.searchFocus = true;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Método para tratar a mensagem de erro
|
|
73
|
+
*/
|
|
74
|
+
watchPropErrorMessage() {
|
|
75
|
+
this._refFilterInput.errorMessage = this.errorMessage;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Método para tratar o value do input
|
|
79
|
+
*/
|
|
80
|
+
watchPropValue() {
|
|
81
|
+
this._refFilterInput.value = this.value;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Atualiza a lista de itens à medida que o usuário digita no campo de pesquisa.
|
|
85
|
+
*/
|
|
86
|
+
async handleInput(event) {
|
|
87
|
+
if (this.debounceTimeout) {
|
|
88
|
+
clearTimeout(this.debounceTimeout);
|
|
89
|
+
}
|
|
90
|
+
this.value = event.detail;
|
|
91
|
+
this.debounceTimeout = setTimeout(async () => {
|
|
92
|
+
var _a;
|
|
93
|
+
const { isLimited, items } = filterItems(event.detail, this.listItens, this.maxItens);
|
|
94
|
+
this.filteredItems = items;
|
|
95
|
+
this.isLimited = isLimited;
|
|
96
|
+
await ((_a = this._refList) === null || _a === void 0 ? void 0 : _a.removeSelection());
|
|
97
|
+
}, this.debounceTime);
|
|
98
|
+
}
|
|
99
|
+
initializeComponent() {
|
|
100
|
+
this.filteredItems = this.listItens;
|
|
101
|
+
}
|
|
102
|
+
getMessage(key) {
|
|
103
|
+
return this.application.messagesBuilder.getMessage(key, null);
|
|
104
|
+
}
|
|
105
|
+
componentWillLoad() {
|
|
106
|
+
this.initializeComponent();
|
|
107
|
+
}
|
|
108
|
+
componentDidLoad() {
|
|
109
|
+
this.bindKeyboardManager();
|
|
110
|
+
this._refFilterInput.value = this.value;
|
|
111
|
+
const { isLimited, items } = filterItems(this.value, this.listItens, this.maxItens);
|
|
112
|
+
this.filteredItems = items;
|
|
113
|
+
this.isLimited = isLimited;
|
|
114
|
+
}
|
|
115
|
+
disconnectedCallback() {
|
|
116
|
+
this.unbindKeyboardManager();
|
|
117
|
+
}
|
|
118
|
+
buildItems() {
|
|
119
|
+
var _a;
|
|
120
|
+
const items = (_a = this.filteredItems) === null || _a === void 0 ? void 0 : _a.map((item) => ({
|
|
121
|
+
label: item,
|
|
122
|
+
id: normalizeString(item),
|
|
123
|
+
}));
|
|
124
|
+
return items;
|
|
125
|
+
}
|
|
126
|
+
async tabSelect() {
|
|
127
|
+
var _a;
|
|
128
|
+
const selectedValue = await ((_a = this._refList) === null || _a === void 0 ? void 0 : _a.getSelection());
|
|
129
|
+
if (this.searchFocus && this._refList) {
|
|
130
|
+
this.searchFocus = false;
|
|
131
|
+
this._refList.focus();
|
|
132
|
+
await this.selectFirstItem();
|
|
133
|
+
}
|
|
134
|
+
else if (selectedValue) {
|
|
135
|
+
await this._refList.removeSelection();
|
|
136
|
+
await this._refButton.setFocus();
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
await this._refButton.setBlur();
|
|
140
|
+
this.setFocus();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
bindKeyboardManager() {
|
|
144
|
+
this._keyboardManager = new KeyboardManager({ propagate: false, element: this._element });
|
|
145
|
+
this._keyboardManager
|
|
146
|
+
.bind("ArrowDown", () => { this.selectNextItem(); })
|
|
147
|
+
.bind("ArrowUp", () => { this.selectPreviousItem(); })
|
|
148
|
+
.bind("Enter", () => { this.setSelectedValue(); })
|
|
149
|
+
.bind("Tab", () => { this.tabSelect(); });
|
|
150
|
+
}
|
|
151
|
+
unbindKeyboardManager() {
|
|
152
|
+
this._keyboardManager
|
|
153
|
+
.unbind("ArrowDown")
|
|
154
|
+
.unbind("ArrowUp")
|
|
155
|
+
.unbind("Enter")
|
|
156
|
+
.unbind("Tab");
|
|
157
|
+
}
|
|
158
|
+
async setSelectedValue() {
|
|
159
|
+
var _a;
|
|
160
|
+
const selectedValue = await ((_a = this._refList) === null || _a === void 0 ? void 0 : _a.getSelection());
|
|
161
|
+
if (selectedValue) {
|
|
162
|
+
this.changeValue.emit({ isNewItem: false, value: selectedValue.label });
|
|
163
|
+
this.closeModal();
|
|
164
|
+
}
|
|
165
|
+
else if (this.searchFocus && this.enabledButtonNewItem()) {
|
|
166
|
+
this.addNewItem();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
async selectNextItem() {
|
|
170
|
+
var _a;
|
|
171
|
+
const itemSelected = await ((_a = this._refList) === null || _a === void 0 ? void 0 : _a.getSelection());
|
|
172
|
+
if (this.searchFocus && !itemSelected) {
|
|
173
|
+
this.setBlur();
|
|
174
|
+
await this.selectFirstItem();
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
;
|
|
178
|
+
await this._refList.selectNextItem();
|
|
179
|
+
}
|
|
180
|
+
async selectPreviousItem() {
|
|
181
|
+
const itemSelected = await this._refList.getSelection();
|
|
182
|
+
if (itemSelected === undefined)
|
|
183
|
+
return;
|
|
184
|
+
await this._refList.selectPreviousItem();
|
|
185
|
+
}
|
|
186
|
+
async selectFirstItem() {
|
|
187
|
+
if (!this.filteredItems.length) {
|
|
188
|
+
await this._refList.removeSelection();
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
const firstItem = this.filteredItems[0];
|
|
192
|
+
await this._refList.setSelection({
|
|
193
|
+
id: normalizeString(firstItem),
|
|
194
|
+
label: firstItem,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
enabledButtonNewItem() {
|
|
198
|
+
if (this.value === undefined)
|
|
199
|
+
return false;
|
|
200
|
+
if (getMatchOption(this.value, this.listItens))
|
|
201
|
+
return false;
|
|
202
|
+
return this.value.trim().length === 0 ? false : true;
|
|
203
|
+
}
|
|
204
|
+
buildMessage() {
|
|
205
|
+
if (this.isLimited) {
|
|
206
|
+
return this.getMessage("snkDistinctSearch.limitResult");
|
|
207
|
+
}
|
|
208
|
+
return `${this.filteredItems.length} ${this.filteredItems.length > 1 ? this.getMessage("snkDistinctSearch.availableResults") : this.getMessage("snkDistinctSearch.availableResult")}`;
|
|
209
|
+
}
|
|
210
|
+
render() {
|
|
211
|
+
var _a;
|
|
212
|
+
return (h(Host, null, h("ez-popup", { ref: (ref) => this._popupElement = ref, size: "400px", "ez-title": this.label, onEzClosePopup: () => this.popupClose.emit(false), "height-mode": "full" }, h("div", null, h("ez-filter-input", { ref: (ref) => this._refFilterInput = ref, label: "Pesquisar", onEzChange: this.handleInput.bind(this), onBlur: () => this.searchFocus = false, onEzFocusIn: () => this.searchFocus = true, errorMessage: this.errorMessage, canShowError: this.canShowError, mode: this.mode, value: this.value, restrict: this.restrict }), this.filteredItems.length === 0 ? (h("div", { class: "ez-content" }, h("div", { class: "ez-text--center search-modal-text" }, this.emptyMessage))) : (h("div", null, h("div", { class: "search-modal-text ez-padding-vertical--medium" }, this.buildMessage()), h("ez-scroller", { class: "search-modal-scroller", direction: EzScrollDirection.VERTICAL }, h("ez-list", { ref: (ref) => this._refList = ref, dataSource: this.buildItems(), onEzClickItem: ({ label }) => this.setSelectedValue.bind(this)(label), ezSelectable: true, hoverFeedback: true, disableShortcuts: true })))), h("div", { class: "ez-flex ez-flex--justify-end" }, h("ez-button", { ref: (ref) => this._refButton = ref, class: "ez-button--tertiary", enabled: this.enabledButtonNewItem(), label: `${this.getMessage("snkDistinctSearch.titleAdd")} ${(_a = this.label) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase()}`, onClick: () => this.addNewItem() }))))));
|
|
213
|
+
}
|
|
214
|
+
static get is() { return "search-modal"; }
|
|
215
|
+
static get encapsulation() { return "scoped"; }
|
|
216
|
+
static get originalStyleUrls() {
|
|
217
|
+
return {
|
|
218
|
+
"$": ["search-modal.css"]
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
static get styleUrls() {
|
|
222
|
+
return {
|
|
223
|
+
"$": ["search-modal.css"]
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
static get properties() {
|
|
227
|
+
return {
|
|
228
|
+
"application": {
|
|
229
|
+
"type": "unknown",
|
|
230
|
+
"mutable": false,
|
|
231
|
+
"complexType": {
|
|
232
|
+
"original": "SnkApplication",
|
|
233
|
+
"resolved": "SnkApplication",
|
|
234
|
+
"references": {
|
|
235
|
+
"SnkApplication": {
|
|
236
|
+
"location": "import",
|
|
237
|
+
"path": "../../../snk-application/snk-application"
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
"required": false,
|
|
242
|
+
"optional": false,
|
|
243
|
+
"docs": {
|
|
244
|
+
"tags": [],
|
|
245
|
+
"text": "SnkApplication"
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
"listItens": {
|
|
249
|
+
"type": "unknown",
|
|
250
|
+
"mutable": true,
|
|
251
|
+
"complexType": {
|
|
252
|
+
"original": "string[]",
|
|
253
|
+
"resolved": "string[]",
|
|
254
|
+
"references": {}
|
|
255
|
+
},
|
|
256
|
+
"required": false,
|
|
257
|
+
"optional": false,
|
|
258
|
+
"docs": {
|
|
259
|
+
"tags": [],
|
|
260
|
+
"text": "Lista de itens exibidas conforme o usu\u00E1rio digita."
|
|
261
|
+
},
|
|
262
|
+
"defaultValue": "[]"
|
|
263
|
+
},
|
|
264
|
+
"opened": {
|
|
265
|
+
"type": "boolean",
|
|
266
|
+
"mutable": true,
|
|
267
|
+
"complexType": {
|
|
268
|
+
"original": "boolean",
|
|
269
|
+
"resolved": "boolean",
|
|
270
|
+
"references": {}
|
|
271
|
+
},
|
|
272
|
+
"required": false,
|
|
273
|
+
"optional": false,
|
|
274
|
+
"docs": {
|
|
275
|
+
"tags": [],
|
|
276
|
+
"text": "Define se o ez-popover est\u00E1 aberto."
|
|
277
|
+
},
|
|
278
|
+
"attribute": "opened",
|
|
279
|
+
"reflect": true,
|
|
280
|
+
"defaultValue": "false"
|
|
281
|
+
},
|
|
282
|
+
"value": {
|
|
283
|
+
"type": "string",
|
|
284
|
+
"mutable": false,
|
|
285
|
+
"complexType": {
|
|
286
|
+
"original": "string",
|
|
287
|
+
"resolved": "string",
|
|
288
|
+
"references": {}
|
|
289
|
+
},
|
|
290
|
+
"required": false,
|
|
291
|
+
"optional": false,
|
|
292
|
+
"docs": {
|
|
293
|
+
"tags": [],
|
|
294
|
+
"text": "Define o valor do campo."
|
|
295
|
+
},
|
|
296
|
+
"attribute": "value",
|
|
297
|
+
"reflect": false,
|
|
298
|
+
"defaultValue": "undefined"
|
|
299
|
+
},
|
|
300
|
+
"canShowError": {
|
|
301
|
+
"type": "boolean",
|
|
302
|
+
"mutable": false,
|
|
303
|
+
"complexType": {
|
|
304
|
+
"original": "boolean",
|
|
305
|
+
"resolved": "boolean",
|
|
306
|
+
"references": {}
|
|
307
|
+
},
|
|
308
|
+
"required": false,
|
|
309
|
+
"optional": false,
|
|
310
|
+
"docs": {
|
|
311
|
+
"tags": [],
|
|
312
|
+
"text": "Se false deixa de exibir a mensagem de erro dentro do campo."
|
|
313
|
+
},
|
|
314
|
+
"attribute": "can-show-error",
|
|
315
|
+
"reflect": false,
|
|
316
|
+
"defaultValue": "false"
|
|
317
|
+
},
|
|
318
|
+
"emptyMessage": {
|
|
319
|
+
"type": "string",
|
|
320
|
+
"mutable": false,
|
|
321
|
+
"complexType": {
|
|
322
|
+
"original": "HTMLElement | string",
|
|
323
|
+
"resolved": "HTMLElement | string",
|
|
324
|
+
"references": {
|
|
325
|
+
"HTMLElement": {
|
|
326
|
+
"location": "global"
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
"required": false,
|
|
331
|
+
"optional": false,
|
|
332
|
+
"docs": {
|
|
333
|
+
"tags": [],
|
|
334
|
+
"text": "Recebe a mensagem de vazio ou personalizada"
|
|
335
|
+
},
|
|
336
|
+
"attribute": "empty-message",
|
|
337
|
+
"reflect": false,
|
|
338
|
+
"defaultValue": "undefined"
|
|
339
|
+
},
|
|
340
|
+
"debounceTime": {
|
|
341
|
+
"type": "number",
|
|
342
|
+
"mutable": false,
|
|
343
|
+
"complexType": {
|
|
344
|
+
"original": "number",
|
|
345
|
+
"resolved": "number",
|
|
346
|
+
"references": {}
|
|
347
|
+
},
|
|
348
|
+
"required": false,
|
|
349
|
+
"optional": false,
|
|
350
|
+
"docs": {
|
|
351
|
+
"tags": [],
|
|
352
|
+
"text": "Tempo em milissegundos para debouncing das chamadas de busca de sugest\u00F5es."
|
|
353
|
+
},
|
|
354
|
+
"attribute": "debounce-time",
|
|
355
|
+
"reflect": false,
|
|
356
|
+
"defaultValue": "300"
|
|
357
|
+
},
|
|
358
|
+
"maxItens": {
|
|
359
|
+
"type": "number",
|
|
360
|
+
"mutable": false,
|
|
361
|
+
"complexType": {
|
|
362
|
+
"original": "number",
|
|
363
|
+
"resolved": "number",
|
|
364
|
+
"references": {}
|
|
365
|
+
},
|
|
366
|
+
"required": false,
|
|
367
|
+
"optional": false,
|
|
368
|
+
"docs": {
|
|
369
|
+
"tags": [],
|
|
370
|
+
"text": "Limita a quantidade de registros apresentados na tela"
|
|
371
|
+
},
|
|
372
|
+
"attribute": "max-itens",
|
|
373
|
+
"reflect": false,
|
|
374
|
+
"defaultValue": "100"
|
|
375
|
+
},
|
|
376
|
+
"label": {
|
|
377
|
+
"type": "string",
|
|
378
|
+
"mutable": false,
|
|
379
|
+
"complexType": {
|
|
380
|
+
"original": "string",
|
|
381
|
+
"resolved": "string",
|
|
382
|
+
"references": {}
|
|
383
|
+
},
|
|
384
|
+
"required": false,
|
|
385
|
+
"optional": false,
|
|
386
|
+
"docs": {
|
|
387
|
+
"tags": [],
|
|
388
|
+
"text": "Texto exibido como placeholder no campo de pesquisa."
|
|
389
|
+
},
|
|
390
|
+
"attribute": "label",
|
|
391
|
+
"reflect": false,
|
|
392
|
+
"defaultValue": "'Pesquisar'"
|
|
393
|
+
},
|
|
394
|
+
"mode": {
|
|
395
|
+
"type": "string",
|
|
396
|
+
"mutable": false,
|
|
397
|
+
"complexType": {
|
|
398
|
+
"original": "'slim' | 'regular'",
|
|
399
|
+
"resolved": "\"regular\" | \"slim\"",
|
|
400
|
+
"references": {}
|
|
401
|
+
},
|
|
402
|
+
"required": false,
|
|
403
|
+
"optional": false,
|
|
404
|
+
"docs": {
|
|
405
|
+
"tags": [],
|
|
406
|
+
"text": "Define o tamanho do campo."
|
|
407
|
+
},
|
|
408
|
+
"attribute": "mode",
|
|
409
|
+
"reflect": false,
|
|
410
|
+
"defaultValue": "'regular'"
|
|
411
|
+
},
|
|
412
|
+
"restrict": {
|
|
413
|
+
"type": "string",
|
|
414
|
+
"mutable": false,
|
|
415
|
+
"complexType": {
|
|
416
|
+
"original": "string",
|
|
417
|
+
"resolved": "string",
|
|
418
|
+
"references": {}
|
|
419
|
+
},
|
|
420
|
+
"required": false,
|
|
421
|
+
"optional": false,
|
|
422
|
+
"docs": {
|
|
423
|
+
"tags": [],
|
|
424
|
+
"text": "Express\u00E3o que define os caracteres permitidos na entrada."
|
|
425
|
+
},
|
|
426
|
+
"attribute": "restrict",
|
|
427
|
+
"reflect": false,
|
|
428
|
+
"defaultValue": "undefined"
|
|
429
|
+
},
|
|
430
|
+
"errorMessage": {
|
|
431
|
+
"type": "string",
|
|
432
|
+
"mutable": false,
|
|
433
|
+
"complexType": {
|
|
434
|
+
"original": "string",
|
|
435
|
+
"resolved": "string",
|
|
436
|
+
"references": {}
|
|
437
|
+
},
|
|
438
|
+
"required": false,
|
|
439
|
+
"optional": false,
|
|
440
|
+
"docs": {
|
|
441
|
+
"tags": [],
|
|
442
|
+
"text": "Define uma mensagem de orienta\u00E7\u00E3o ao usu\u00E1rio, colocando o campo em modo inv\u00E1lido."
|
|
443
|
+
},
|
|
444
|
+
"attribute": "error-message",
|
|
445
|
+
"reflect": false,
|
|
446
|
+
"defaultValue": "undefined"
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
static get states() {
|
|
451
|
+
return {
|
|
452
|
+
"filteredItems": {},
|
|
453
|
+
"searchFocus": {},
|
|
454
|
+
"isLimited": {}
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
static get events() {
|
|
458
|
+
return [{
|
|
459
|
+
"method": "popupClose",
|
|
460
|
+
"name": "popupClose",
|
|
461
|
+
"bubbles": true,
|
|
462
|
+
"cancelable": true,
|
|
463
|
+
"composed": true,
|
|
464
|
+
"docs": {
|
|
465
|
+
"tags": [],
|
|
466
|
+
"text": "Emitido ao fechar o popup"
|
|
467
|
+
},
|
|
468
|
+
"complexType": {
|
|
469
|
+
"original": "boolean",
|
|
470
|
+
"resolved": "boolean",
|
|
471
|
+
"references": {}
|
|
472
|
+
}
|
|
473
|
+
}, {
|
|
474
|
+
"method": "changeValue",
|
|
475
|
+
"name": "changeValue",
|
|
476
|
+
"bubbles": true,
|
|
477
|
+
"cancelable": true,
|
|
478
|
+
"composed": true,
|
|
479
|
+
"docs": {
|
|
480
|
+
"tags": [],
|
|
481
|
+
"text": "Emitido quando h\u00E1 uma altera\u00E7\u00E3o no valor do campo."
|
|
482
|
+
},
|
|
483
|
+
"complexType": {
|
|
484
|
+
"original": "IDistinctValue",
|
|
485
|
+
"resolved": "IDistinctValue",
|
|
486
|
+
"references": {
|
|
487
|
+
"IDistinctValue": {
|
|
488
|
+
"location": "import",
|
|
489
|
+
"path": "../../types"
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}];
|
|
494
|
+
}
|
|
495
|
+
static get methods() {
|
|
496
|
+
return {
|
|
497
|
+
"addNewItem": {
|
|
498
|
+
"complexType": {
|
|
499
|
+
"signature": "() => Promise<void>",
|
|
500
|
+
"parameters": [],
|
|
501
|
+
"references": {},
|
|
502
|
+
"return": "Promise<void>"
|
|
503
|
+
},
|
|
504
|
+
"docs": {
|
|
505
|
+
"text": "M\u00E9todo para adicionar a nova palavra e chamar o m\u00E9todo closeModal() para fechar o modal",
|
|
506
|
+
"tags": []
|
|
507
|
+
}
|
|
508
|
+
},
|
|
509
|
+
"clearInput": {
|
|
510
|
+
"complexType": {
|
|
511
|
+
"signature": "() => Promise<void>",
|
|
512
|
+
"parameters": [],
|
|
513
|
+
"references": {},
|
|
514
|
+
"return": "Promise<void>"
|
|
515
|
+
},
|
|
516
|
+
"docs": {
|
|
517
|
+
"text": "M\u00E9todo para limpa o campo de entrada de pesquisa",
|
|
518
|
+
"tags": []
|
|
519
|
+
}
|
|
520
|
+
},
|
|
521
|
+
"closeModal": {
|
|
522
|
+
"complexType": {
|
|
523
|
+
"signature": "() => Promise<void>",
|
|
524
|
+
"parameters": [],
|
|
525
|
+
"references": {},
|
|
526
|
+
"return": "Promise<void>"
|
|
527
|
+
},
|
|
528
|
+
"docs": {
|
|
529
|
+
"text": "M\u00E9todo para fechar o modal",
|
|
530
|
+
"tags": []
|
|
531
|
+
}
|
|
532
|
+
},
|
|
533
|
+
"openModal": {
|
|
534
|
+
"complexType": {
|
|
535
|
+
"signature": "() => Promise<void>",
|
|
536
|
+
"parameters": [],
|
|
537
|
+
"references": {},
|
|
538
|
+
"return": "Promise<void>"
|
|
539
|
+
},
|
|
540
|
+
"docs": {
|
|
541
|
+
"text": "M\u00E9todo para abrir o modal",
|
|
542
|
+
"tags": []
|
|
543
|
+
}
|
|
544
|
+
},
|
|
545
|
+
"isInvalid": {
|
|
546
|
+
"complexType": {
|
|
547
|
+
"signature": "() => Promise<void>",
|
|
548
|
+
"parameters": [],
|
|
549
|
+
"references": {},
|
|
550
|
+
"return": "Promise<void>"
|
|
551
|
+
},
|
|
552
|
+
"docs": {
|
|
553
|
+
"text": "Retorna se o conte\u00FAdo \u00E9 inv\u00E1lido.",
|
|
554
|
+
"tags": []
|
|
555
|
+
}
|
|
556
|
+
},
|
|
557
|
+
"setBlur": {
|
|
558
|
+
"complexType": {
|
|
559
|
+
"signature": "() => Promise<void>",
|
|
560
|
+
"parameters": [],
|
|
561
|
+
"references": {},
|
|
562
|
+
"return": "Promise<void>"
|
|
563
|
+
},
|
|
564
|
+
"docs": {
|
|
565
|
+
"text": "Remove o foco do campo",
|
|
566
|
+
"tags": []
|
|
567
|
+
}
|
|
568
|
+
},
|
|
569
|
+
"setFocus": {
|
|
570
|
+
"complexType": {
|
|
571
|
+
"signature": "() => Promise<void>",
|
|
572
|
+
"parameters": [],
|
|
573
|
+
"references": {},
|
|
574
|
+
"return": "Promise<void>"
|
|
575
|
+
},
|
|
576
|
+
"docs": {
|
|
577
|
+
"text": "Aplica o foco do campo",
|
|
578
|
+
"tags": []
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
static get elementRef() { return "_element"; }
|
|
584
|
+
static get watchers() {
|
|
585
|
+
return [{
|
|
586
|
+
"propName": "errorMessage",
|
|
587
|
+
"methodName": "watchPropErrorMessage"
|
|
588
|
+
}, {
|
|
589
|
+
"propName": "value",
|
|
590
|
+
"methodName": "watchPropValue"
|
|
591
|
+
}];
|
|
592
|
+
}
|
|
593
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function normalizeString(text = "") {
|
|
2
|
+
return text.normalize('NFD').replace(/[\u0300-\u036f/\s'"&.-]/g, "").toUpperCase();
|
|
3
|
+
}
|
|
4
|
+
export function filterItems(searchArgument, distinctItems, maxItems) {
|
|
5
|
+
const normalizedSearch = normalizeString(searchArgument);
|
|
6
|
+
const filteredDistincts = distinctItems.filter((item) => normalizeString(item).includes(normalizedSearch));
|
|
7
|
+
const isLimited = filteredDistincts.length > maxItems;
|
|
8
|
+
const items = filteredDistincts.slice(0, maxItems);
|
|
9
|
+
return { items, isLimited };
|
|
10
|
+
}
|
|
11
|
+
export function getMatchOption(value, distinctItems) {
|
|
12
|
+
const normalizedSearch = normalizeString(value);
|
|
13
|
+
const item = distinctItems.find((item) => normalizeString(item) === normalizedSearch);
|
|
14
|
+
return item;
|
|
15
|
+
}
|
|
@@ -87,13 +87,13 @@ export class SnkFormConfigManager {
|
|
|
87
87
|
const fields = (_a = this._config) === null || _a === void 0 ? void 0 : _a.fields;
|
|
88
88
|
const hasConfig = this.hasConfig();
|
|
89
89
|
if (hasConfig && !forceEmptyConfig) {
|
|
90
|
-
return fields.map(({ label, name, readOnly, visible, required, tab
|
|
90
|
+
return fields.map(({ label, name, readOnly, visible, required, tab }) => {
|
|
91
91
|
var _a;
|
|
92
92
|
if (label == undefined) {
|
|
93
93
|
const currentField = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.getField(name);
|
|
94
|
-
return Object.assign(Object.assign({}, currentField), { name: name !== null && name !== void 0 ? name : currentField.name, readOnly: readOnly !== null && readOnly !== void 0 ? readOnly : currentField.readOnly, visible: visible !== null && visible !== void 0 ? visible : currentField.visible, required: required !== null && required !== void 0 ? required : currentField.required, tab: tab
|
|
94
|
+
return Object.assign(Object.assign({}, currentField), { name: name !== null && name !== void 0 ? name : currentField.name, readOnly: readOnly !== null && readOnly !== void 0 ? readOnly : currentField.readOnly, visible: visible !== null && visible !== void 0 ? visible : currentField.visible, required: required !== null && required !== void 0 ? required : currentField.required, tab: tab });
|
|
95
95
|
}
|
|
96
|
-
return { name, label, readOnly, visible, required, tab
|
|
96
|
+
return { name, label, readOnly, visible, required, tab };
|
|
97
97
|
})
|
|
98
98
|
.filter(field => this.isFieldVisible(field, descriptionFilter));
|
|
99
99
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DataFetcher } from "../DataFetcher";
|
|
2
|
+
export default class DistinctSearchFetcher {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.SERVICE = 'mge@Pesquisa.getSelectDistinct';
|
|
5
|
+
}
|
|
6
|
+
buildRequestBody(coluna, instancia) {
|
|
7
|
+
return {
|
|
8
|
+
selectDistinct: {
|
|
9
|
+
instancia,
|
|
10
|
+
coluna,
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
parseResponseBody(response) {
|
|
15
|
+
var _a, _b, _c;
|
|
16
|
+
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 : [];
|
|
17
|
+
return ocorrencias;
|
|
18
|
+
}
|
|
19
|
+
async fetchItens(coluna, instancia) {
|
|
20
|
+
const requestBody = this.buildRequestBody(coluna, instancia);
|
|
21
|
+
const response = await DataFetcher.get().callServiceBroker(this.SERVICE, requestBody);
|
|
22
|
+
const parsedResponse = this.parseResponseBody(response);
|
|
23
|
+
return parsedResponse;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -7,6 +7,7 @@ import snkCrudMessages from "./resources/snk-crud.msg";
|
|
|
7
7
|
import snkSimpleCrudMessages from "./resources/snk-simple-crud.msg";
|
|
8
8
|
import fileViewerMessages from "./resources/file-viewer.msg";
|
|
9
9
|
import snkApplicationMessages from "./resources/snk-application.msg";
|
|
10
|
+
import snkDistinctSearchMessages from "./resources/snk-distinct-search.msg";
|
|
10
11
|
import { snkFormConfigMessages, snkConfigOptionsMessages, snkFieldConfigMessages, snkTabConfigMessages } from "./resources/snk-form.msg";
|
|
11
12
|
import { snkConfiguratorMessages } from "./resources/snk-configurator.msg";
|
|
12
13
|
import { snkGridMessages, snkGridConfigMessages } from "./resources/snk-grid.msg";
|
|
@@ -48,6 +49,7 @@ export class SnkMessageBuilder {
|
|
|
48
49
|
snkEntityList: snkEntityListMessages,
|
|
49
50
|
snkActionsButton: snkActionsButtonMessages,
|
|
50
51
|
snkPrintSelector: snkPrintSelectorMessages,
|
|
52
|
+
snkDistinctSearch: snkDistinctSearchMessages,
|
|
51
53
|
};
|
|
52
54
|
this._currentOperation = OperationMap.CLEAN;
|
|
53
55
|
this._domainName = domainName;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const snkDistinctSearchMessages = {
|
|
2
|
+
titleBadgeNew: "novo",
|
|
3
|
+
titleAdd: "Adicionar",
|
|
4
|
+
availableResults: "resultados disponíveis",
|
|
5
|
+
availableResult: "resultado disponível",
|
|
6
|
+
limitResult: "Esta pesquisa foi limitada, existem mais resultados",
|
|
7
|
+
emptyResult: "Nenhum resultado disponível. <br/>Você pode adicionar um novo termo",
|
|
8
|
+
};
|
|
9
|
+
export default snkDistinctSearchMessages;
|