@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-kb-74339.1 → 0.0.0-bugfix-dev-KB-76362.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{ConfigStorage-ecc0ed20.js → ConfigStorage-f079f5fd.js} +2 -2
- package/dist/cjs/{ContinuousInsertUtils-29b65619.js → ContinuousInsertUtils-64e47516.js} +29 -20
- package/dist/cjs/{DataFetcher-cadeef8e.js → DataFetcher-e059eb72.js} +7 -5
- package/dist/cjs/{SnkFormConfigManager-f1c92f79.js → SnkFormConfigManager-63369164.js} +2 -2
- package/dist/cjs/{SnkMessageBuilder-bae64d0d.js → SnkMessageBuilder-7691a2c1.js} +10 -0
- package/dist/cjs/{auth-fetcher-d68841bc.js → auth-fetcher-4f853233.js} +1 -1
- package/dist/cjs/{dataunit-fetcher-f89461c1.js → dataunit-fetcher-228016f4.js} +3 -3
- package/dist/cjs/{form-config-fetcher-ed497282.js → form-config-fetcher-39397ac5.js} +1 -1
- 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/{pesquisa-fetcher-ca89181c.js → pesquisa-fetcher-a9bfeb22.js} +7 -2
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button_4.cjs.entry.js +5 -5
- package/dist/cjs/snk-application.cjs.entry.js +102 -60
- package/dist/cjs/snk-attach.cjs.entry.js +5 -5
- package/dist/cjs/snk-config-options_3.cjs.entry.js +4 -4
- package/dist/cjs/snk-crud.cjs.entry.js +5 -5
- package/dist/cjs/snk-data-exporter.cjs.entry.js +6 -6
- package/dist/cjs/{snk-data-unit-668dc5e8.js → snk-data-unit-7dbdad0e.js} +2 -2
- package/dist/cjs/snk-data-unit.cjs.entry.js +4 -4
- package/dist/cjs/snk-detail-view.cjs.entry.js +8 -8
- package/dist/cjs/snk-distinct-search.cjs.entry.js +123 -0
- package/dist/cjs/snk-filter-bar_4.cjs.entry.js +3 -3
- package/dist/cjs/snk-filter-modal-item.cjs.entry.js +3 -3
- package/dist/cjs/snk-grid.cjs.entry.js +6 -6
- package/dist/cjs/{snk-guides-viewer-4236cb9d.js → snk-guides-viewer-eee43c8b.js} +8 -5
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +7 -7
- package/dist/cjs/snk-personalized-filter.cjs.entry.js +3 -3
- package/dist/cjs/snk-simple-crud.cjs.entry.js +10 -8
- package/dist/collection/collection-manifest.json +3 -0
- package/dist/collection/components/snk-application/request-listener/DebouncedRequestListener.js +28 -0
- package/dist/collection/components/snk-application/request-listener/RequestListenerFactory.js +16 -0
- package/dist/collection/components/snk-application/request-listener/RequestListenerLoadingBar.js +52 -0
- package/dist/collection/components/snk-application/snk-application.js +3 -53
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +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-simple-crud/snk-simple-crud.js +3 -1
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +8 -6
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.js +2 -2
- package/dist/collection/lib/http/data-fetcher/fetchers/distinct-search-fetcher.js +25 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +6 -1
- package/dist/collection/lib/message/SnkMessageBuilder.js +2 -0
- package/dist/collection/lib/message/resources/snk-distinct-search.msg.js +9 -0
- package/dist/collection/lib/utils/CrudUtils.js +25 -16
- package/dist/components/ContinuousInsertUtils.js +25 -16
- package/dist/components/DataFetcher.js +7 -5
- package/dist/components/SnkMessageBuilder.js +10 -0
- package/dist/components/dataunit-fetcher.js +2 -2
- 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/pesquisa-fetcher.js +6 -1
- 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-application2.js +95 -53
- package/dist/components/snk-detail-view2.js +3 -0
- package/dist/components/snk-distinct-search.d.ts +11 -0
- package/dist/components/snk-distinct-search.js +163 -0
- package/dist/components/snk-simple-crud2.js +3 -1
- package/dist/esm/{ConfigStorage-7b36d041.js → ConfigStorage-6514d66e.js} +2 -2
- package/dist/esm/{ContinuousInsertUtils-30caa626.js → ContinuousInsertUtils-b62906f9.js} +29 -20
- package/dist/esm/{DataFetcher-a9c598f2.js → DataFetcher-5034df59.js} +7 -5
- package/dist/esm/{SnkFormConfigManager-f1a0fc92.js → SnkFormConfigManager-b409c745.js} +2 -2
- package/dist/esm/{SnkMessageBuilder-6fff4a4c.js → SnkMessageBuilder-7ace6803.js} +10 -0
- package/dist/esm/{auth-fetcher-749d880f.js → auth-fetcher-ca5d3a49.js} +1 -1
- package/dist/esm/{dataunit-fetcher-c24c76c6.js → dataunit-fetcher-56cb648b.js} +3 -3
- package/dist/esm/{form-config-fetcher-adbe5d34.js → form-config-fetcher-a7d3e277.js} +1 -1
- 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/{pesquisa-fetcher-8edaa8cd.js → pesquisa-fetcher-6bc2e41a.js} +7 -2
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button_4.entry.js +5 -5
- package/dist/esm/snk-application.entry.js +102 -60
- package/dist/esm/snk-attach.entry.js +5 -5
- package/dist/esm/snk-config-options_3.entry.js +4 -4
- package/dist/esm/snk-crud.entry.js +5 -5
- package/dist/esm/snk-data-exporter.entry.js +6 -6
- package/dist/esm/{snk-data-unit-0fdfb6c2.js → snk-data-unit-7a579dbd.js} +2 -2
- package/dist/esm/snk-data-unit.entry.js +4 -4
- package/dist/esm/snk-detail-view.entry.js +8 -8
- package/dist/esm/snk-distinct-search.entry.js +119 -0
- package/dist/esm/snk-filter-bar_4.entry.js +3 -3
- package/dist/esm/snk-filter-modal-item.entry.js +3 -3
- package/dist/esm/snk-grid.entry.js +6 -6
- package/dist/esm/{snk-guides-viewer-8fa1321a.js → snk-guides-viewer-e8ca764a.js} +8 -5
- package/dist/esm/snk-guides-viewer.entry.js +7 -7
- package/dist/esm/snk-personalized-filter.entry.js +3 -3
- package/dist/esm/snk-simple-crud.entry.js +10 -8
- package/dist/sankhyablocks/{p-f3434fc4.js → p-00278e07.js} +1 -1
- package/dist/sankhyablocks/{p-49b01ec2.entry.js → p-00f9fe5c.entry.js} +1 -1
- package/dist/sankhyablocks/{p-fadc8339.js → p-0e206e62.js} +1 -1
- package/dist/sankhyablocks/{p-ab05d5f2.entry.js → p-0e250436.entry.js} +1 -1
- package/dist/sankhyablocks/{p-06421fdb.js → p-126c58ea.js} +1 -1
- package/dist/sankhyablocks/p-154aa2a6.entry.js +11 -0
- package/dist/sankhyablocks/p-18cb1acb.entry.js +1 -0
- package/dist/sankhyablocks/{p-a75d242d.entry.js → p-1dbd5c18.entry.js} +1 -1
- package/dist/sankhyablocks/{p-fa6c5826.entry.js → p-30ebcbe0.entry.js} +1 -1
- package/dist/sankhyablocks/{p-1bf06cd3.js → p-341465ce.js} +2 -2
- package/dist/sankhyablocks/p-3755b46f.entry.js +1 -0
- package/dist/sankhyablocks/{p-052213ba.entry.js → p-3858a2e4.entry.js} +1 -1
- package/dist/sankhyablocks/p-42130213.entry.js +1 -0
- package/dist/sankhyablocks/{p-7ac7932c.js → p-47d24ac8.js} +2 -2
- package/dist/sankhyablocks/{p-8dfc2ba9.entry.js → p-563b7c28.entry.js} +1 -1
- package/dist/sankhyablocks/{p-4d9549cf.js → p-9ffd9fc7.js} +1 -1
- package/dist/sankhyablocks/{p-c2e4ac99.entry.js → p-a2c790ac.entry.js} +1 -1
- package/dist/sankhyablocks/{p-212213d9.entry.js → p-aa003d4e.entry.js} +1 -1
- package/dist/sankhyablocks/p-aaf94476.js +1 -0
- package/dist/sankhyablocks/{p-2ef45894.entry.js → p-b389ed49.entry.js} +1 -1
- package/dist/sankhyablocks/{p-5dd8cf4f.js → p-c75fae8e.js} +1 -1
- package/dist/sankhyablocks/p-d8665750.js +1 -0
- package/dist/sankhyablocks/{p-ee7023c4.js → p-e3a285a2.js} +1 -1
- package/dist/sankhyablocks/p-e4391e16.js +1 -0
- package/dist/sankhyablocks/{p-42288374.entry.js → p-f0aaad2b.entry.js} +1 -1
- package/dist/sankhyablocks/{p-b9c67e45.entry.js → p-f4e221b2.entry.js} +1 -1
- package/dist/sankhyablocks/{p-fb34e0cf.entry.js → p-fca0e5cc.entry.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/request-listener/DebouncedRequestListener.d.ts +11 -0
- package/dist/types/components/snk-application/request-listener/RequestListenerFactory.d.ts +12 -0
- package/dist/types/components/snk-application/request-listener/RequestListenerLoadingBar.d.ts +13 -0
- package/dist/types/components/snk-application/snk-application.d.ts +3 -12
- 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/DataFetcher.d.ts +1 -0
- 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/dist/types/lib/utils/CrudUtils.d.ts +1 -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-2923c1b5.js +0 -1
- package/dist/sankhyablocks/p-7281cdab.entry.js +0 -1
- package/dist/sankhyablocks/p-a42e7a1e.entry.js +0 -11
- package/dist/sankhyablocks/p-ca5ec380.js +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { D as DataFetcher } from './DataFetcher-
|
|
2
|
-
import './pesquisa-fetcher-
|
|
1
|
+
import { D as DataFetcher } from './DataFetcher-5034df59.js';
|
|
2
|
+
import './pesquisa-fetcher-6bc2e41a.js';
|
|
3
3
|
import { SortMode, ApplicationContext, UserInterface, DateUtils, ObjectUtils, StringUtils, NumberUtils, DataType } from '@sankhyalabs/core';
|
|
4
4
|
import './index-3aa4977a.js';
|
|
5
5
|
import './ISave-d8c8bc59.js';
|
|
6
6
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
|
7
7
|
import { UserInterface as UserInterface$1 } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
|
8
|
-
import { P as PreloadManager } from './dataunit-fetcher-
|
|
8
|
+
import { P as PreloadManager } from './dataunit-fetcher-56cb648b.js';
|
|
9
9
|
import './filter-item-type.enum-d45e026f.js';
|
|
10
|
-
import './form-config-fetcher-
|
|
10
|
+
import './form-config-fetcher-a7d3e277.js';
|
|
11
11
|
import InMemoryFilterColumnDataSource from '@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource';
|
|
12
12
|
import { h } from './index-a7d3d3f1.js';
|
|
13
13
|
|
|
@@ -24,6 +24,28 @@ class CrudUtils {
|
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
+
static parseCrudResults(entities, onlyFirst) {
|
|
28
|
+
if (!Array.isArray(entities)) {
|
|
29
|
+
entities = [entities];
|
|
30
|
+
}
|
|
31
|
+
const crudFindResults = [];
|
|
32
|
+
for (const entity of entities) {
|
|
33
|
+
let crudFindResult = {
|
|
34
|
+
fields: new Map()
|
|
35
|
+
};
|
|
36
|
+
for (let key in entity) {
|
|
37
|
+
let fieldValue = entity[key];
|
|
38
|
+
if (fieldValue.hasOwnProperty('$')) {
|
|
39
|
+
crudFindResult.fields.set(key, fieldValue.$);
|
|
40
|
+
}
|
|
41
|
+
if (onlyFirst) {
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
crudFindResults.push(crudFindResult);
|
|
46
|
+
}
|
|
47
|
+
return crudFindResults.length > 1 ? crudFindResults : crudFindResults[0];
|
|
48
|
+
}
|
|
27
49
|
static find(entityName, fields, criteria, onlyFirst = true, criteriaExpression, orderBy) {
|
|
28
50
|
const SERVICE_CRUD_FIND = "mge@crud.find";
|
|
29
51
|
let parsedFields = [];
|
|
@@ -71,24 +93,11 @@ class CrudUtils {
|
|
|
71
93
|
DataFetcher.get().callServiceBroker(SERVICE_CRUD_FIND, JSON.stringify(request)).then((result) => {
|
|
72
94
|
var _a;
|
|
73
95
|
let entities = (_a = result.entidades) === null || _a === void 0 ? void 0 : _a.entidade;
|
|
74
|
-
if (entities
|
|
75
|
-
let crudFindResult = {
|
|
76
|
-
fields: new Map()
|
|
77
|
-
};
|
|
78
|
-
for (let key in entities) {
|
|
79
|
-
let fieldValue = entities[key];
|
|
80
|
-
if (fieldValue.hasOwnProperty('$')) {
|
|
81
|
-
crudFindResult.fields.set(key, fieldValue.$);
|
|
82
|
-
}
|
|
83
|
-
if (onlyFirst) {
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
resolve(crudFindResult);
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
96
|
+
if (!entities) {
|
|
90
97
|
resolve(null);
|
|
91
98
|
}
|
|
99
|
+
const crudFindResults = this.parseCrudResults(entities, onlyFirst);
|
|
100
|
+
resolve(crudFindResults);
|
|
92
101
|
});
|
|
93
102
|
});
|
|
94
103
|
}
|
|
@@ -6777,7 +6777,8 @@ class DataFetcher {
|
|
|
6777
6777
|
}
|
|
6778
6778
|
payloadJson['requestBody']['clientEventList'].clientEvent.push({ $: key });
|
|
6779
6779
|
}
|
|
6780
|
-
|
|
6780
|
+
const requestId = StringUtils.generateUUID();
|
|
6781
|
+
DataFetcher.requestListener.forEach(listener => listener.onRequestStart({ url: url, requestBody: payload, requestId }));
|
|
6781
6782
|
http.open("POST", url, true);
|
|
6782
6783
|
http.withCredentials = true;
|
|
6783
6784
|
http.send(ObjectUtils.objectToString(payloadJson));
|
|
@@ -6817,7 +6818,7 @@ class DataFetcher {
|
|
|
6817
6818
|
else if (http.readyState == 4 && http.status != 200) {
|
|
6818
6819
|
reject(new ErrorException(`Erro ao executar serviço: ${serviceName}`, http.responseText));
|
|
6819
6820
|
}
|
|
6820
|
-
DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url: url, requestBody: payload }));
|
|
6821
|
+
DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url: url, requestBody: payload, requestId }));
|
|
6821
6822
|
};
|
|
6822
6823
|
});
|
|
6823
6824
|
}
|
|
@@ -6922,7 +6923,8 @@ class DataFetcher {
|
|
|
6922
6923
|
const errorsResponse = [];
|
|
6923
6924
|
const responseExtensions = [];
|
|
6924
6925
|
const url = this.buildGraphQlURL(quietMode);
|
|
6925
|
-
|
|
6926
|
+
const requestId = StringUtils.generateUUID();
|
|
6927
|
+
DataFetcher.requestListener.forEach(listener => listener.onRequestStart({ url, requestBody: request, requestId }));
|
|
6926
6928
|
try {
|
|
6927
6929
|
const response = await dist.batchRequests(url, request, { 'Content-Type': `application/json; charset=${window['SERVER_ENCODING'] || 'UTF-8'}` });
|
|
6928
6930
|
response.forEach((resItem, index) => {
|
|
@@ -6956,11 +6958,11 @@ class DataFetcher {
|
|
|
6956
6958
|
});
|
|
6957
6959
|
}
|
|
6958
6960
|
else {
|
|
6959
|
-
DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url, requestBody: request }));
|
|
6961
|
+
DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url, requestBody: request, requestId }));
|
|
6960
6962
|
throw new ErrorException("Falha de comunicação", err.message);
|
|
6961
6963
|
}
|
|
6962
6964
|
}
|
|
6963
|
-
DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url, requestBody: request }));
|
|
6965
|
+
DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url, requestBody: request, requestId }));
|
|
6964
6966
|
return { data: dataResponse, errors: errorsResponse, extensions: responseExtensions };
|
|
6965
6967
|
}
|
|
6966
6968
|
isHttpError(err) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { C as ConfigStorage } from './ConfigStorage-
|
|
1
|
+
import { C as ConfigStorage } from './ConfigStorage-6514d66e.js';
|
|
2
2
|
import { ObjectUtils, StringUtils } from '@sankhyalabs/core';
|
|
3
|
-
import { F as FormConfigFetcher } from './form-config-fetcher-
|
|
3
|
+
import { F as FormConfigFetcher } from './form-config-fetcher-a7d3e277.js';
|
|
4
4
|
import { b as TAB_NAMES } from './constants-7302ee87.js';
|
|
5
5
|
|
|
6
6
|
class SnkFormConfigManager {
|
|
@@ -172,6 +172,15 @@ const snkAttachMessages$1 = {
|
|
|
172
172
|
}
|
|
173
173
|
};
|
|
174
174
|
|
|
175
|
+
const snkDistinctSearchMessages = {
|
|
176
|
+
titleBadgeNew: "novo",
|
|
177
|
+
titleAdd: "Adicionar",
|
|
178
|
+
availableResults: "resultados disponíveis",
|
|
179
|
+
availableResult: "resultado disponível",
|
|
180
|
+
limitResult: "Esta pesquisa foi limitada, existem mais resultados",
|
|
181
|
+
emptyResult: "Nenhum resultado disponível. <br/>Você pode adicionar um novo termo",
|
|
182
|
+
};
|
|
183
|
+
|
|
175
184
|
const snkConfigOptionsMessages = {
|
|
176
185
|
label: {
|
|
177
186
|
nameField: "Nome do Campo *",
|
|
@@ -552,6 +561,7 @@ class SnkMessageBuilder {
|
|
|
552
561
|
snkEntityList: snkEntityListMessages,
|
|
553
562
|
snkActionsButton: snkActionsButtonMessages,
|
|
554
563
|
snkPrintSelector: snkPrintSelectorMessages,
|
|
564
|
+
snkDistinctSearch: snkDistinctSearchMessages,
|
|
555
565
|
};
|
|
556
566
|
this._currentOperation = OperationMap.CLEAN;
|
|
557
567
|
this._domainName = domainName;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ObjectUtils } from '@sankhyalabs/core';
|
|
2
|
-
import { R as ResourceFetcher } from './form-config-fetcher-
|
|
2
|
+
import { R as ResourceFetcher } from './form-config-fetcher-a7d3e277.js';
|
|
3
3
|
|
|
4
4
|
class AuthFetcher extends ResourceFetcher {
|
|
5
5
|
getData(resourceID) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ObjectUtils, DataUnit, DataType, DateUtils, StringUtils, ChangeOperation, ApplicationContext, UserInterface, DataUnitStorage } from '@sankhyalabs/core';
|
|
2
|
-
import { D as DataFetcher, d as dist } from './DataFetcher-
|
|
2
|
+
import { D as DataFetcher, d as dist } from './DataFetcher-5034df59.js';
|
|
3
3
|
import { DISTINCT_FILTER_NAME_PREFIX } from '@sankhyalabs/ezui/dist/collection/utils/constants';
|
|
4
4
|
import { DataUnitTransient } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
|
5
5
|
import { ColumnFilterManager } from '@sankhyalabs/ezui/dist/collection/components/ez-grid/utils';
|
|
@@ -712,7 +712,7 @@ class DataUnitDataLoader {
|
|
|
712
712
|
}
|
|
713
713
|
const count = loadingInfo.count;
|
|
714
714
|
if (loadingInfo.loadingInProgress) {
|
|
715
|
-
dataUnit.updatePagination(Object.assign(Object.assign({}, dataUnitPagination), { count }));
|
|
715
|
+
dataUnit.updatePagination(Object.assign(Object.assign({}, dataUnitPagination), { count, loadingInProgress: true }));
|
|
716
716
|
return;
|
|
717
717
|
}
|
|
718
718
|
if (loadingInfo.needReload) {
|
|
@@ -720,7 +720,7 @@ class DataUnitDataLoader {
|
|
|
720
720
|
dataUnit.gotoPage(0);
|
|
721
721
|
return;
|
|
722
722
|
}
|
|
723
|
-
dataUnit.updatePagination(Object.assign(Object.assign({}, dataUnitPagination), { total: count, count }));
|
|
723
|
+
dataUnit.updatePagination(Object.assign(Object.assign({}, dataUnitPagination), { total: count, count, loadingInProgress: false }));
|
|
724
724
|
}
|
|
725
725
|
static registryLoading(dataUnit, loadingInfo) {
|
|
726
726
|
if (loadingInfo == undefined) {
|
|
@@ -2110,6 +2110,10 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
2110
2110
|
return import(
|
|
2111
2111
|
/* webpackMode: "lazy" */
|
|
2112
2112
|
'./snk-custom-slot-elements.entry.js').then(processMod, consoleError);
|
|
2113
|
+
case 'snk-distinct-search':
|
|
2114
|
+
return import(
|
|
2115
|
+
/* webpackMode: "lazy" */
|
|
2116
|
+
'./snk-distinct-search.entry.js').then(processMod, consoleError);
|
|
2113
2117
|
case 'snk-entity-list':
|
|
2114
2118
|
return import(
|
|
2115
2119
|
/* webpackMode: "lazy" */
|
|
@@ -2154,6 +2158,10 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
2154
2158
|
return import(
|
|
2155
2159
|
/* webpackMode: "lazy" */
|
|
2156
2160
|
'./teste-pesquisa.entry.js').then(processMod, consoleError);
|
|
2161
|
+
case 'input-distinct-search_2':
|
|
2162
|
+
return import(
|
|
2163
|
+
/* webpackMode: "lazy" */
|
|
2164
|
+
'./input-distinct-search_2.entry.js').then(processMod, consoleError);
|
|
2157
2165
|
case 'snk-filter-modal-item':
|
|
2158
2166
|
return import(
|
|
2159
2167
|
/* webpackMode: "lazy" */
|
|
@@ -0,0 +1,466 @@
|
|
|
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).includes(normalizedSearch));
|
|
11
|
+
const isLimited = filteredDistincts.length > maxItems;
|
|
12
|
+
const items = filteredDistincts.slice(0, maxItems);
|
|
13
|
+
return { items, isLimited };
|
|
14
|
+
}
|
|
15
|
+
function getMatchOption(value, distinctItems) {
|
|
16
|
+
const normalizedSearch = normalizeString(value);
|
|
17
|
+
const item = distinctItems.find((item) => normalizeString(item) === normalizedSearch);
|
|
18
|
+
return item;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
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--small, 6px);max-height:calc(var(--max-height-popover) - (2 * var(--space--small, 6px)));display:flex;flex-direction:column}.list-container{overflow:auto;scrollbar-width:thin;scrollbar-color:var(--scrollbar--color-clicked) var(--scrollbar--color-background);padding-right:var(--space--small, 6px)}.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)}";
|
|
22
|
+
|
|
23
|
+
const InputDistinctSearch = class {
|
|
24
|
+
constructor(hostRef) {
|
|
25
|
+
registerInstance(this, hostRef);
|
|
26
|
+
this.changeValue = createEvent(this, "changeValue", 7);
|
|
27
|
+
this.iconClick = createEvent(this, "iconClick", 7);
|
|
28
|
+
this.textValue = "";
|
|
29
|
+
this.isNewItem = false;
|
|
30
|
+
this.filteredItems = [];
|
|
31
|
+
this.isNewItemSelected = false;
|
|
32
|
+
this.application = undefined;
|
|
33
|
+
this.distinctItems = [];
|
|
34
|
+
this.label = "";
|
|
35
|
+
this.value = "";
|
|
36
|
+
this.maxItems = 100;
|
|
37
|
+
this.debounceTime = 300;
|
|
38
|
+
this.canShowError = false;
|
|
39
|
+
this.mode = 'regular';
|
|
40
|
+
this.restrict = undefined;
|
|
41
|
+
this.errorMessage = undefined;
|
|
42
|
+
}
|
|
43
|
+
async observerValue(newValue) {
|
|
44
|
+
await this.selectedNewItem(newValue, true);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Seleciona um item
|
|
48
|
+
*/
|
|
49
|
+
async selectValue(value, isNewItem = false) {
|
|
50
|
+
this.isNewItem = isNewItem;
|
|
51
|
+
this.textValue = value;
|
|
52
|
+
await this._refFilterInput.setValue(value);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Método para limpa o campo de entrada de pesquisa
|
|
56
|
+
*/
|
|
57
|
+
clearInput() {
|
|
58
|
+
this._refFilterInput.setValue("");
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Retorna se o conteúdo é inválido.
|
|
62
|
+
*/
|
|
63
|
+
isInvalid() {
|
|
64
|
+
return this._refFilterInput.isInvalid();
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Remove o foco do campo
|
|
68
|
+
*/
|
|
69
|
+
setBlur() {
|
|
70
|
+
this._refFilterInput.setBlur();
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Aplica o foco do campo
|
|
74
|
+
*/
|
|
75
|
+
setFocus() {
|
|
76
|
+
this._refFilterInput.setFocus();
|
|
77
|
+
}
|
|
78
|
+
getMessage(key) {
|
|
79
|
+
return this.application.messagesBuilder.getMessage(key, null);
|
|
80
|
+
}
|
|
81
|
+
async optionLoader(searchArgument) {
|
|
82
|
+
return new Promise((resolve) => {
|
|
83
|
+
if (this._debounceTimeout) {
|
|
84
|
+
clearTimeout(this._debounceTimeout);
|
|
85
|
+
}
|
|
86
|
+
this._debounceTimeout = setTimeout(() => {
|
|
87
|
+
const { items } = filterItems(searchArgument, this.distinctItems, this.maxItems);
|
|
88
|
+
this.filteredItems = items;
|
|
89
|
+
resolve();
|
|
90
|
+
}, this.debounceTime);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
async openPopOver() {
|
|
94
|
+
var _a;
|
|
95
|
+
await ((_a = this._refPopOver) === null || _a === void 0 ? void 0 : _a.showUnder(this._refFilterInput));
|
|
96
|
+
}
|
|
97
|
+
async closePopOver() {
|
|
98
|
+
var _a;
|
|
99
|
+
this.isNewItemSelected = false;
|
|
100
|
+
await ((_a = this._refPopOver) === null || _a === void 0 ? void 0 : _a.hide());
|
|
101
|
+
await this._refList.removeSelection();
|
|
102
|
+
}
|
|
103
|
+
async onTextChange(event) {
|
|
104
|
+
this.textValue = event.detail;
|
|
105
|
+
await this.optionLoader(event.detail);
|
|
106
|
+
await this.selectFirstItem();
|
|
107
|
+
}
|
|
108
|
+
onIconClick() {
|
|
109
|
+
this.iconClick.emit();
|
|
110
|
+
}
|
|
111
|
+
buidItems() {
|
|
112
|
+
var _a;
|
|
113
|
+
const items = (_a = this.filteredItems) === null || _a === void 0 ? void 0 : _a.map((item) => ({
|
|
114
|
+
label: item,
|
|
115
|
+
id: normalizeString(item),
|
|
116
|
+
}));
|
|
117
|
+
return items;
|
|
118
|
+
}
|
|
119
|
+
async setValue(value, isNewItem = false, preventEventEmit = false) {
|
|
120
|
+
this.isNewItem = isNewItem;
|
|
121
|
+
this.textValue = value;
|
|
122
|
+
await this._refFilterInput.setValue(value);
|
|
123
|
+
await this.closePopOver();
|
|
124
|
+
if (!preventEventEmit) {
|
|
125
|
+
this.changeValue.emit({
|
|
126
|
+
value,
|
|
127
|
+
isNewItem,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
async selectedNewItem(value, preventEventEmit = false) {
|
|
132
|
+
if (!this.textValue && !value) {
|
|
133
|
+
await this.setValue("", false, preventEventEmit);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const item = getMatchOption(value !== null && value !== void 0 ? value : this.textValue, this.distinctItems);
|
|
137
|
+
if (item) {
|
|
138
|
+
await this.setValue(item, false, preventEventEmit);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
await this.setValue(this.textValue || value, true, preventEventEmit);
|
|
142
|
+
}
|
|
143
|
+
async setSelectedValue() {
|
|
144
|
+
const selectedValue = await this._refList.getSelection();
|
|
145
|
+
await this.selectedNewItem((selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.label) || this.textValue, true);
|
|
146
|
+
await this._refFilterInput.setBlur();
|
|
147
|
+
this._element.focus();
|
|
148
|
+
}
|
|
149
|
+
async selectNextItem() {
|
|
150
|
+
if (this.isNewItemSelected) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const itemSelected = await this._refList.getSelection();
|
|
154
|
+
const itemsAmount = this.filteredItems.length;
|
|
155
|
+
const indexSelected = this.filteredItems.findIndex((item) => item === (itemSelected === null || itemSelected === void 0 ? void 0 : itemSelected.label));
|
|
156
|
+
const isLastItemSelected = indexSelected === (itemsAmount - 1);
|
|
157
|
+
const optionNewItemIsAvailable = !!this.textValue;
|
|
158
|
+
if (!isLastItemSelected || !optionNewItemIsAvailable) {
|
|
159
|
+
this.isNewItemSelected = false;
|
|
160
|
+
await this._refList.selectNextItem();
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
this.isNewItemSelected = true;
|
|
164
|
+
await this._refList.removeSelection();
|
|
165
|
+
}
|
|
166
|
+
async selectPreviousItem() {
|
|
167
|
+
const itemsAmount = this.filteredItems.length;
|
|
168
|
+
const lastItem = this.filteredItems[itemsAmount - 1];
|
|
169
|
+
if (this.isNewItemSelected && lastItem) {
|
|
170
|
+
this.isNewItemSelected = false;
|
|
171
|
+
await this._refList.setSelection({
|
|
172
|
+
id: normalizeString(lastItem),
|
|
173
|
+
label: lastItem
|
|
174
|
+
});
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
await this._refList.selectPreviousItem();
|
|
178
|
+
}
|
|
179
|
+
bindKeyboardManager() {
|
|
180
|
+
this._keyboardManager = new KeyboardManager({ propagate: false, element: this._element });
|
|
181
|
+
this._keyboardManager
|
|
182
|
+
.bind("ArrowDown", () => { this.selectNextItem(); })
|
|
183
|
+
.bind("ArrowUp", () => { this.selectPreviousItem(); })
|
|
184
|
+
.bind("Enter", () => { this.setSelectedValue(); })
|
|
185
|
+
.bind("Tab", () => { this.setSelectedValue(); });
|
|
186
|
+
}
|
|
187
|
+
unbindKeyboardManager() {
|
|
188
|
+
this._keyboardManager
|
|
189
|
+
.unbind("ArrowDown")
|
|
190
|
+
.unbind("ArrowUp")
|
|
191
|
+
.unbind("Enter")
|
|
192
|
+
.unbind("Tab");
|
|
193
|
+
}
|
|
194
|
+
async selectFirstItem() {
|
|
195
|
+
if (!this.filteredItems.length) {
|
|
196
|
+
await this._refList.removeSelection();
|
|
197
|
+
this.isNewItemSelected = true;
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const firstItem = this.filteredItems[0];
|
|
201
|
+
this.isNewItemSelected = false;
|
|
202
|
+
await this._refList.setSelection({
|
|
203
|
+
id: normalizeString(firstItem),
|
|
204
|
+
label: firstItem,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
initializeComponent() {
|
|
208
|
+
const { items } = filterItems("", this.distinctItems, this.maxItems);
|
|
209
|
+
this.filteredItems = items;
|
|
210
|
+
}
|
|
211
|
+
componentWillLoad() {
|
|
212
|
+
this.initializeComponent();
|
|
213
|
+
}
|
|
214
|
+
async componentDidLoad() {
|
|
215
|
+
this.bindKeyboardManager();
|
|
216
|
+
this.selectFirstItem();
|
|
217
|
+
await this.selectedNewItem(this.value, true);
|
|
218
|
+
}
|
|
219
|
+
disconnectedCallback() {
|
|
220
|
+
this.unbindKeyboardManager();
|
|
221
|
+
}
|
|
222
|
+
buildNewItemOption() {
|
|
223
|
+
if (!this.textValue) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
return (h(Fragment, null, !!this.filteredItems.length &&
|
|
227
|
+
h("hr", { class: "divider" }), h("button", { slot: "bottomSlot", class: {
|
|
228
|
+
"new-value": true,
|
|
229
|
+
"new-value-selected": this.isNewItemSelected,
|
|
230
|
+
}, title: `${this.getMessage("snkDistinctSearch.titleAdd")} '${this.textValue}'`, onClick: () => this.selectedNewItem.bind(this)(undefined, true) }, this.getMessage("snkDistinctSearch.titleAdd"), " '", this.textValue, "'")));
|
|
231
|
+
}
|
|
232
|
+
render() {
|
|
233
|
+
return (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 &&
|
|
234
|
+
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: {
|
|
235
|
+
'space-error': this.canShowError,
|
|
236
|
+
} }, 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()))));
|
|
237
|
+
}
|
|
238
|
+
get _element() { return getElement(this); }
|
|
239
|
+
static get watchers() { return {
|
|
240
|
+
"value": ["observerValue"]
|
|
241
|
+
}; }
|
|
242
|
+
};
|
|
243
|
+
InputDistinctSearch.style = inputDistinctSearchCss;
|
|
244
|
+
|
|
245
|
+
const searchModalCss = ".sc-search-modal-h{display:block}ez-popup.sc-search-modal{--ez-popup__title--font-size:var(--title--large, 20px);--ez-popup__container--height:380px}.search-modal-scroller.sc-search-modal{height:174px}.search-modal-text.sc-search-modal{font-family:var(--font-pattern);color:var(--text--primary);font-size:var(--text--medium)}ez-filter-input.sc-search-modal>input.sc-search-modal{text-overflow:ellipsis}.ez-content.sc-search-modal{height:190px;display:flex;align-items:center;justify-content:center}";
|
|
246
|
+
|
|
247
|
+
const SearchModal = class {
|
|
248
|
+
constructor(hostRef) {
|
|
249
|
+
registerInstance(this, hostRef);
|
|
250
|
+
this.popupClose = createEvent(this, "popupClose", 7);
|
|
251
|
+
this.changeValue = createEvent(this, "changeValue", 7);
|
|
252
|
+
this.debounceTimeout = null;
|
|
253
|
+
this.filteredItems = [];
|
|
254
|
+
this.searchFocus = false;
|
|
255
|
+
this.isLimited = false;
|
|
256
|
+
this.application = undefined;
|
|
257
|
+
this.listItens = [];
|
|
258
|
+
this.opened = false;
|
|
259
|
+
this.value = undefined;
|
|
260
|
+
this.canShowError = false;
|
|
261
|
+
this.emptyMessage = undefined;
|
|
262
|
+
this.debounceTime = 300;
|
|
263
|
+
this.maxItens = 100;
|
|
264
|
+
this.label = 'Pesquisar';
|
|
265
|
+
this.mode = 'regular';
|
|
266
|
+
this.restrict = undefined;
|
|
267
|
+
this.errorMessage = undefined;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Método para adicionar a nova palavra e chamar o método closeModal() para fechar o modal
|
|
271
|
+
*/
|
|
272
|
+
addNewItem() {
|
|
273
|
+
this.closeModal();
|
|
274
|
+
this.changeValue.emit({ isNewItem: true, value: this.value });
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Método para limpa o campo de entrada de pesquisa
|
|
278
|
+
*/
|
|
279
|
+
clearInput() {
|
|
280
|
+
this._refFilterInput.setValue("");
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Método para fechar o modal
|
|
284
|
+
*/
|
|
285
|
+
closeModal() {
|
|
286
|
+
this._popupElement.opened = false;
|
|
287
|
+
this.popupClose.emit(false);
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Método para abrir o modal
|
|
291
|
+
*/
|
|
292
|
+
openModal() {
|
|
293
|
+
this._popupElement.opened = true;
|
|
294
|
+
setTimeout(() => this.setFocus(), 100);
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Retorna se o conteúdo é inválido.
|
|
298
|
+
*/
|
|
299
|
+
isInvalid() {
|
|
300
|
+
this._refFilterInput.isInvalid();
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Remove o foco do campo
|
|
304
|
+
*/
|
|
305
|
+
setBlur() {
|
|
306
|
+
this._refFilterInput.setBlur();
|
|
307
|
+
this.searchFocus = false;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Aplica o foco do campo
|
|
311
|
+
*/
|
|
312
|
+
setFocus() {
|
|
313
|
+
this._refFilterInput.setFocus();
|
|
314
|
+
this.searchFocus = true;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Método para tratar a mensagem de erro
|
|
318
|
+
*/
|
|
319
|
+
watchPropErrorMessage() {
|
|
320
|
+
this._refFilterInput.errorMessage = this.errorMessage;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Método para tratar o value do input
|
|
324
|
+
*/
|
|
325
|
+
watchPropValue() {
|
|
326
|
+
this._refFilterInput.value = this.value;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Atualiza a lista de itens à medida que o usuário digita no campo de pesquisa.
|
|
330
|
+
*/
|
|
331
|
+
async handleInput(event) {
|
|
332
|
+
if (this.debounceTimeout) {
|
|
333
|
+
clearTimeout(this.debounceTimeout);
|
|
334
|
+
}
|
|
335
|
+
this.value = event.detail;
|
|
336
|
+
this.debounceTimeout = setTimeout(async () => {
|
|
337
|
+
var _a;
|
|
338
|
+
const { isLimited, items } = filterItems(event.detail, this.listItens, this.maxItens);
|
|
339
|
+
this.filteredItems = items;
|
|
340
|
+
this.isLimited = isLimited;
|
|
341
|
+
await ((_a = this._refList) === null || _a === void 0 ? void 0 : _a.removeSelection());
|
|
342
|
+
}, this.debounceTime);
|
|
343
|
+
}
|
|
344
|
+
initializeComponent() {
|
|
345
|
+
this.filteredItems = this.listItens;
|
|
346
|
+
}
|
|
347
|
+
getMessage(key) {
|
|
348
|
+
return this.application.messagesBuilder.getMessage(key, null);
|
|
349
|
+
}
|
|
350
|
+
componentWillLoad() {
|
|
351
|
+
this.initializeComponent();
|
|
352
|
+
}
|
|
353
|
+
componentDidLoad() {
|
|
354
|
+
this.bindKeyboardManager();
|
|
355
|
+
this._refFilterInput.value = this.value;
|
|
356
|
+
const { isLimited, items } = filterItems(this.value, this.listItens, this.maxItens);
|
|
357
|
+
this.filteredItems = items;
|
|
358
|
+
this.isLimited = isLimited;
|
|
359
|
+
}
|
|
360
|
+
disconnectedCallback() {
|
|
361
|
+
this.unbindKeyboardManager();
|
|
362
|
+
}
|
|
363
|
+
buildItems() {
|
|
364
|
+
var _a;
|
|
365
|
+
const items = (_a = this.filteredItems) === null || _a === void 0 ? void 0 : _a.map((item) => ({
|
|
366
|
+
label: item,
|
|
367
|
+
id: normalizeString(item),
|
|
368
|
+
}));
|
|
369
|
+
return items;
|
|
370
|
+
}
|
|
371
|
+
async tabSelect() {
|
|
372
|
+
var _a;
|
|
373
|
+
const selectedValue = await ((_a = this._refList) === null || _a === void 0 ? void 0 : _a.getSelection());
|
|
374
|
+
if (this.searchFocus && this._refList) {
|
|
375
|
+
this.searchFocus = false;
|
|
376
|
+
this._refList.focus();
|
|
377
|
+
await this.selectFirstItem();
|
|
378
|
+
}
|
|
379
|
+
else if (selectedValue) {
|
|
380
|
+
await this._refList.removeSelection();
|
|
381
|
+
await this._refButton.setFocus();
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
await this._refButton.setBlur();
|
|
385
|
+
this.setFocus();
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
bindKeyboardManager() {
|
|
389
|
+
this._keyboardManager = new KeyboardManager({ propagate: false, element: this._element });
|
|
390
|
+
this._keyboardManager
|
|
391
|
+
.bind("ArrowDown", () => { this.selectNextItem(); })
|
|
392
|
+
.bind("ArrowUp", () => { this.selectPreviousItem(); })
|
|
393
|
+
.bind("Enter", () => { this.setSelectedValue(); })
|
|
394
|
+
.bind("Tab", () => { this.tabSelect(); });
|
|
395
|
+
}
|
|
396
|
+
unbindKeyboardManager() {
|
|
397
|
+
this._keyboardManager
|
|
398
|
+
.unbind("ArrowDown")
|
|
399
|
+
.unbind("ArrowUp")
|
|
400
|
+
.unbind("Enter")
|
|
401
|
+
.unbind("Tab");
|
|
402
|
+
}
|
|
403
|
+
async setSelectedValue() {
|
|
404
|
+
var _a;
|
|
405
|
+
const selectedValue = await ((_a = this._refList) === null || _a === void 0 ? void 0 : _a.getSelection());
|
|
406
|
+
if (selectedValue) {
|
|
407
|
+
this.changeValue.emit({ isNewItem: false, value: selectedValue.label });
|
|
408
|
+
this.closeModal();
|
|
409
|
+
}
|
|
410
|
+
else if (this.searchFocus && this.enabledButtonNewItem()) {
|
|
411
|
+
this.addNewItem();
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
async selectNextItem() {
|
|
415
|
+
var _a;
|
|
416
|
+
const itemSelected = await ((_a = this._refList) === null || _a === void 0 ? void 0 : _a.getSelection());
|
|
417
|
+
if (this.searchFocus && !itemSelected) {
|
|
418
|
+
this.setBlur();
|
|
419
|
+
await this.selectFirstItem();
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
await this._refList.selectNextItem();
|
|
423
|
+
}
|
|
424
|
+
async selectPreviousItem() {
|
|
425
|
+
const itemSelected = await this._refList.getSelection();
|
|
426
|
+
if (itemSelected === undefined)
|
|
427
|
+
return;
|
|
428
|
+
await this._refList.selectPreviousItem();
|
|
429
|
+
}
|
|
430
|
+
async selectFirstItem() {
|
|
431
|
+
if (!this.filteredItems.length) {
|
|
432
|
+
await this._refList.removeSelection();
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
const firstItem = this.filteredItems[0];
|
|
436
|
+
await this._refList.setSelection({
|
|
437
|
+
id: normalizeString(firstItem),
|
|
438
|
+
label: firstItem,
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
enabledButtonNewItem() {
|
|
442
|
+
if (this.value === undefined)
|
|
443
|
+
return false;
|
|
444
|
+
if (getMatchOption(this.value, this.listItens))
|
|
445
|
+
return false;
|
|
446
|
+
return this.value.trim().length === 0 ? false : true;
|
|
447
|
+
}
|
|
448
|
+
buildMessage() {
|
|
449
|
+
if (this.isLimited) {
|
|
450
|
+
return this.getMessage("snkDistinctSearch.limitResult");
|
|
451
|
+
}
|
|
452
|
+
return `${this.filteredItems.length} ${this.filteredItems.length > 1 ? this.getMessage("snkDistinctSearch.availableResults") : this.getMessage("snkDistinctSearch.availableResult")}`;
|
|
453
|
+
}
|
|
454
|
+
render() {
|
|
455
|
+
var _a;
|
|
456
|
+
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() }))))));
|
|
457
|
+
}
|
|
458
|
+
get _element() { return getElement(this); }
|
|
459
|
+
static get watchers() { return {
|
|
460
|
+
"errorMessage": ["watchPropErrorMessage"],
|
|
461
|
+
"value": ["watchPropValue"]
|
|
462
|
+
}; }
|
|
463
|
+
};
|
|
464
|
+
SearchModal.style = searchModalCss;
|
|
465
|
+
|
|
466
|
+
export { InputDistinctSearch as input_distinct_search, SearchModal as search_modal };
|