@sankhyalabs/sankhyablocks 8.15.3 → 8.16.0-dev.10
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-942ce74b.js → ConfigStorage-a343e418.js} +1 -0
- package/dist/cjs/{SnkMultiSelectionListDataSource-3c08d25c.js → IExporterProvider-597949f9.js} +94 -4
- package/dist/cjs/RecordIDUtils-3735135c.js +43 -0
- package/dist/cjs/{SnkFormConfigManager-f9dc0d28.js → SnkFormConfigManager-166cbd1f.js} +8 -7
- package/dist/cjs/{SnkMessageBuilder-66aa2557.js → SnkMessageBuilder-897ffd08.js} +9 -13
- package/dist/cjs/{pesquisa-fetcher-562d281f.js → dataunit-fetcher-688d3f05.js} +87 -180
- package/dist/cjs/{index-0922807b.js → index-1dfc7a6e.js} +5 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/pesquisa-fetcher-680e198f.js +166 -0
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button_4.cjs.entry.js +5 -3
- package/dist/cjs/snk-application.cjs.entry.js +35 -12
- package/dist/cjs/snk-attach.cjs.entry.js +71 -46
- package/dist/cjs/snk-crud.cjs.entry.js +101 -10
- package/dist/cjs/snk-data-exporter.cjs.entry.js +315 -85
- package/dist/cjs/snk-data-unit-8fa7917a.js +689 -0
- package/dist/cjs/snk-data-unit.cjs.entry.js +12 -2
- package/dist/cjs/snk-detail-view.cjs.entry.js +50 -10
- package/dist/cjs/snk-filter-bar.cjs.entry.js +6 -2
- package/dist/cjs/snk-filter-modal-item.cjs.entry.js +1 -1
- package/dist/cjs/snk-form-config.cjs.entry.js +1 -1
- package/dist/cjs/snk-form-view.cjs.entry.js +67 -0
- package/dist/cjs/snk-form.cjs.entry.js +52 -7
- package/dist/cjs/snk-grid.cjs.entry.js +165 -108
- package/dist/cjs/{snk-guides-viewer-bb6087cd.js → snk-guides-viewer-9c682034.js} +43 -10
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +9 -7
- package/dist/cjs/snk-personalized-filter.cjs.entry.js +1 -1
- package/dist/cjs/snk-simple-crud.cjs.entry.js +268 -40
- package/dist/cjs/snk-taskbar.cjs.entry.js +4 -3
- package/dist/cjs/{taskbar-elements-3ecd1278.js → taskbar-elements-9ad1f9c0.js} +3 -3
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/snk-application/snk-application.js +35 -11
- package/dist/collection/components/snk-attach/snk-attach.js +67 -44
- package/dist/collection/components/snk-crud/interfaces/PropsCustomEditor.js +1 -0
- package/dist/collection/components/snk-crud/interfaces/PropsCustomRender.js +1 -0
- package/dist/collection/components/snk-crud/snk-crud.js +305 -7
- package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +136 -2
- package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +161 -0
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +134 -7
- package/dist/collection/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.js +97 -0
- package/dist/collection/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.js +74 -0
- package/dist/collection/components/snk-data-exporter/interfaces/IExporterProvider.js +54 -1
- package/dist/collection/components/snk-data-exporter/interfaces/IExporterStrategy.js +1 -0
- package/dist/collection/components/snk-data-exporter/providers/ClientSideExporterProvider.js +58 -0
- package/dist/collection/components/snk-data-exporter/providers/ServerSideExporterProvider.js +55 -0
- package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +59 -52
- package/dist/collection/components/snk-data-exporter/structure/ItemBuilder.js +62 -0
- package/dist/collection/components/snk-data-exporter/test/resources/ClientSideExporterStrategyResources.js +88 -0
- package/dist/collection/components/snk-data-exporter/utils/ParserExport.js +20 -0
- package/dist/collection/components/snk-data-exporter/utils/RecordIDUtils.js +38 -0
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +538 -218
- package/dist/collection/components/snk-data-unit/test/resources/metadataMock.js +24 -0
- package/dist/collection/components/snk-data-unit/test/resources/parentMetadataMock.js +18 -0
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +22 -1
- package/dist/collection/components/snk-form/snk-form.js +102 -5
- package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +7 -6
- package/dist/collection/components/snk-form-config/snk-form-config.js +1 -1
- package/dist/collection/components/snk-grid/snk-grid.js +240 -101
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +406 -20
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +2 -2
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +2 -1
- package/dist/collection/lib/@types/index.js +5 -0
- package/dist/collection/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.js +35 -0
- package/dist/collection/lib/configs/ConfigStorage.js +1 -0
- package/dist/collection/lib/dataUnit/InMemoryLoader.js +7 -3
- package/dist/collection/lib/dataUnit/ValueFormatter.js +4 -0
- package/dist/collection/lib/dataUnit/interfaces/InMemoryLoaderConfig.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.js +3 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.js +4 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.js +11 -13
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/dataunit-fetcher.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/IBuildRequestBodyLoadRowMetadata.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/IRowMetadata.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +53 -4
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/test/resources/metadataMock.js +22 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +4 -4
- package/dist/collection/lib/message/SnkMessageBuilder.js +5 -12
- package/dist/collection/lib/message/resources/snk-data-exporter.msg.js +2 -0
- package/dist/collection/lib/message/resources/snk-data-unit.msg.js +2 -1
- package/dist/components/ConfigStorage.js +1 -0
- package/dist/components/{field-search.js → IExporterProvider.js} +93 -6
- package/dist/components/ISave.js +47 -0
- package/dist/components/SnkFormConfigManager.js +7 -6
- package/dist/components/SnkMessageBuilder.js +9 -13
- package/dist/components/dataunit-fetcher.js +84 -182
- package/dist/components/index2.js +198 -33
- package/dist/components/pesquisa-fetcher.js +164 -0
- package/dist/components/snk-actions-button2.js +4 -11
- package/dist/components/snk-application2.js +31 -9
- package/dist/components/snk-attach2.js +65 -41
- package/dist/components/snk-crud.js +110 -11
- package/dist/components/snk-data-exporter2.js +309 -85
- package/dist/components/snk-data-unit2.js +485 -216
- package/dist/components/snk-detail-view2.js +96 -14
- package/dist/components/snk-expression-item2.js +1 -1
- package/dist/components/snk-filter-bar2.js +6 -1
- package/dist/components/snk-form-config2.js +1 -1
- package/dist/components/snk-form-view2.js +72 -1
- package/dist/components/snk-form.js +53 -6
- package/dist/components/snk-grid2.js +168 -106
- package/dist/components/snk-personalized-filter2.js +1 -1
- package/dist/components/snk-simple-crud2.js +263 -25
- package/dist/components/snk-taskbar2.js +6 -5
- package/dist/esm/{ConfigStorage-86187da3.js → ConfigStorage-3806514e.js} +1 -0
- package/dist/esm/{SnkMultiSelectionListDataSource-6a879955.js → IExporterProvider-63a188b6.js} +93 -5
- package/dist/esm/RecordIDUtils-87d02110.js +41 -0
- package/dist/esm/{SnkFormConfigManager-f53f9f87.js → SnkFormConfigManager-31b24066.js} +8 -7
- package/dist/esm/{SnkMessageBuilder-0a4becdd.js → SnkMessageBuilder-571462fb.js} +9 -13
- package/dist/esm/{pesquisa-fetcher-c7ce8ee7.js → dataunit-fetcher-264191b2.js} +83 -181
- package/dist/esm/{index-0ece87a6.js → index-3aa4977a.js} +6 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/pesquisa-fetcher-03c8f919.js +164 -0
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button_4.entry.js +5 -3
- package/dist/esm/snk-application.entry.js +34 -11
- package/dist/esm/snk-attach.entry.js +66 -41
- package/dist/esm/snk-crud.entry.js +101 -10
- package/dist/esm/snk-data-exporter.entry.js +316 -86
- package/dist/esm/snk-data-unit-f5cbe64b.js +687 -0
- package/dist/esm/snk-data-unit.entry.js +12 -2
- package/dist/esm/snk-detail-view.entry.js +50 -10
- package/dist/esm/snk-filter-bar.entry.js +6 -2
- package/dist/esm/snk-filter-modal-item.entry.js +1 -1
- package/dist/esm/snk-form-config.entry.js +1 -1
- package/dist/esm/snk-form-view.entry.js +67 -0
- package/dist/esm/snk-form.entry.js +52 -7
- package/dist/esm/snk-grid.entry.js +163 -106
- package/dist/esm/{snk-guides-viewer-1d95ebf2.js → snk-guides-viewer-8f6960a2.js} +43 -10
- package/dist/esm/snk-guides-viewer.entry.js +9 -7
- package/dist/esm/snk-personalized-filter.entry.js +1 -1
- package/dist/esm/snk-simple-crud.entry.js +256 -28
- package/dist/esm/snk-taskbar.entry.js +4 -3
- package/dist/esm/{taskbar-elements-2473c8ac.js → taskbar-elements-d59867f1.js} +3 -3
- package/dist/sankhyablocks/p-17def7cd.js +1 -0
- package/dist/sankhyablocks/p-1db45d26.entry.js +1 -0
- package/dist/sankhyablocks/p-28ee0972.js +1 -0
- package/dist/sankhyablocks/p-2a408684.js +1 -0
- package/dist/sankhyablocks/{p-eae7a817.entry.js → p-2c68b3ae.entry.js} +1 -1
- package/dist/sankhyablocks/p-30cf616e.js +1 -0
- package/dist/sankhyablocks/p-3a212712.js +1 -0
- package/dist/sankhyablocks/p-450c60e4.entry.js +1 -0
- package/dist/sankhyablocks/{p-a1d72395.entry.js → p-47db7e88.entry.js} +1 -1
- package/dist/sankhyablocks/p-4e5e1313.entry.js +1 -0
- package/dist/sankhyablocks/{p-aff76a53.js → p-52920496.js} +1 -1
- package/dist/sankhyablocks/p-62ba211a.entry.js +1 -0
- package/dist/sankhyablocks/p-6bb2f3e9.entry.js +1 -0
- package/dist/sankhyablocks/p-7505da04.entry.js +1 -0
- package/dist/sankhyablocks/p-7619bdb1.entry.js +11 -0
- package/dist/sankhyablocks/p-7a85fd49.entry.js +1 -0
- package/dist/sankhyablocks/{p-ae4fc9a9.js → p-7e7a7473.js} +1 -1
- package/dist/sankhyablocks/p-7ef9c55c.js +1 -0
- package/dist/sankhyablocks/p-80042dc6.entry.js +1 -0
- package/dist/sankhyablocks/p-8c59edd7.entry.js +1 -0
- package/dist/sankhyablocks/p-9606509c.entry.js +1 -0
- package/dist/sankhyablocks/p-9863d682.js +1 -0
- package/dist/sankhyablocks/p-ae93d46a.entry.js +1 -0
- package/dist/sankhyablocks/p-af8efd95.js +6 -0
- package/dist/sankhyablocks/p-d6e26ea8.entry.js +1 -0
- package/dist/sankhyablocks/p-f2809746.entry.js +1 -0
- package/dist/sankhyablocks/p-f4450320.entry.js +1 -0
- package/dist/sankhyablocks/p-fe79f83a.js +60 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +7 -3
- package/dist/types/components/snk-attach/snk-attach.d.ts +11 -9
- package/dist/types/components/snk-crud/interfaces/PropsCustomEditor.d.ts +4 -0
- package/dist/types/components/snk-crud/interfaces/PropsCustomRender.d.ts +4 -0
- package/dist/types/components/snk-crud/snk-crud.d.ts +45 -1
- package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +23 -0
- package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +28 -3
- package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +24 -0
- package/dist/types/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.d.ts +14 -0
- package/dist/types/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.d.ts +12 -0
- package/dist/types/components/snk-data-exporter/interfaces/IExporterProvider.d.ts +24 -4
- package/dist/types/components/snk-data-exporter/interfaces/IExporterStrategy.d.ts +5 -0
- package/dist/types/components/snk-data-exporter/providers/ClientSideExporterProvider.d.ts +17 -0
- package/dist/types/components/snk-data-exporter/providers/ServerSideExporterProvider.d.ts +17 -0
- package/dist/types/components/snk-data-exporter/snk-data-exporter.d.ts +4 -1
- package/dist/types/components/snk-data-exporter/structure/ItemBuilder.d.ts +21 -0
- package/dist/types/components/snk-data-exporter/test/resources/ClientSideExporterStrategyResources.d.ts +77 -0
- package/dist/types/components/snk-data-exporter/utils/ParserExport.d.ts +4 -0
- package/dist/types/components/snk-data-exporter/utils/RecordIDUtils.d.ts +3 -0
- package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +66 -2
- package/dist/types/components/snk-data-unit/test/resources/metadataMock.d.ts +3 -0
- package/dist/types/components/snk-data-unit/test/resources/parentMetadataMock.d.ts +3 -0
- package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +4 -0
- package/dist/types/components/snk-form/snk-form.d.ts +14 -0
- package/dist/types/components/snk-form-config/SnkFormConfigManager.d.ts +2 -2
- package/dist/types/components/snk-grid/snk-grid.d.ts +46 -6
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +62 -4
- package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +1 -1
- package/dist/types/components.d.ts +261 -4
- package/dist/types/lib/@types/index.d.ts +5 -0
- package/dist/types/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.d.ts +11 -0
- package/dist/types/lib/dataUnit/InMemoryLoader.d.ts +2 -1
- package/dist/types/lib/dataUnit/ValueFormatter.d.ts +2 -0
- package/dist/types/lib/dataUnit/interfaces/InMemoryLoaderConfig.d.ts +3 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.d.ts +2 -1
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.d.ts +1 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.d.ts +1 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/IBuildRequestBodyLoadRowMetadata.d.ts +10 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/IRowMetadata.d.ts +7 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.d.ts +6 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/test/resources/metadataMock.d.ts +20 -0
- package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IExporterColumnMetadata.d.ts +3 -0
- package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IFetchDataExporterParams.d.ts +2 -1
- package/dist/types/lib/http/data-fetcher/fetchers/pesquisa-fetcher.d.ts +1 -0
- package/package.json +1 -1
- package/dist/cjs/snk-data-unit-41c29713.js +0 -462
- package/dist/collection/lib/http/data-fetcher/fetchers/fetchDataExporter/index.js +0 -34
- package/dist/components/index3.js +0 -199
- package/dist/esm/snk-data-unit-de1d140d.js +0 -460
- package/dist/sankhyablocks/p-032fe52e.js +0 -1
- package/dist/sankhyablocks/p-03dcc5ff.entry.js +0 -1
- package/dist/sankhyablocks/p-0594db5a.entry.js +0 -1
- package/dist/sankhyablocks/p-06e13db2.js +0 -1
- package/dist/sankhyablocks/p-07a61550.entry.js +0 -1
- package/dist/sankhyablocks/p-1403a4b6.entry.js +0 -1
- package/dist/sankhyablocks/p-14a08904.entry.js +0 -1
- package/dist/sankhyablocks/p-15802c59.entry.js +0 -1
- package/dist/sankhyablocks/p-235dc7b1.js +0 -65
- package/dist/sankhyablocks/p-32556aa6.js +0 -1
- package/dist/sankhyablocks/p-38289a55.js +0 -1
- package/dist/sankhyablocks/p-3c632d48.js +0 -1
- package/dist/sankhyablocks/p-3f833983.entry.js +0 -1
- package/dist/sankhyablocks/p-52c8e589.js +0 -1
- package/dist/sankhyablocks/p-5e1502b6.entry.js +0 -11
- package/dist/sankhyablocks/p-74d349c3.entry.js +0 -1
- package/dist/sankhyablocks/p-93167e28.entry.js +0 -1
- package/dist/sankhyablocks/p-add17f6a.entry.js +0 -1
- package/dist/sankhyablocks/p-bd47dd16.entry.js +0 -1
- package/dist/sankhyablocks/p-c1f88236.entry.js +0 -1
- package/dist/sankhyablocks/p-ccdd5332.entry.js +0 -1
- package/dist/sankhyablocks/p-ee9536bc.entry.js +0 -1
- package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/index.d.ts +0 -3
@@ -8,7 +8,7 @@ const snkDataUnitMessages = {
|
|
8
8
|
},
|
9
9
|
cancelInfo: {
|
10
10
|
clone: "Duplicação descartada!",
|
11
|
-
insert: "A inclusão descartada!",
|
11
|
+
insert: "A inclusão foi descartada!",
|
12
12
|
update: "A edição foi descartada!"
|
13
13
|
},
|
14
14
|
confirm: {
|
@@ -29,6 +29,7 @@ const snkDataUnitMessages = {
|
|
29
29
|
forbiddenRemove: "Não é possível remover. Verifique as permissões de acesso.",
|
30
30
|
removeAllConfirmation: "Os <strong>{{size}} registros selecionados</strong> serão excluídos.<br/><br/><strong>Você realmente gostaria de continuar?</strong>",
|
31
31
|
removeAllInfo: "Os {{size}} registros foram removidos com sucesso!",
|
32
|
+
fieldNameRequired: "É necessário informar o nome da coluna."
|
32
33
|
};
|
33
34
|
|
34
35
|
const snkFilterBarMessages = {
|
@@ -284,6 +285,7 @@ const snkDataExporterMessages = {
|
|
284
285
|
},
|
285
286
|
label: {
|
286
287
|
currentPage: "Somente a página atual",
|
288
|
+
allRecords: "Todos os registros",
|
287
289
|
spreadsheet: "Planilha",
|
288
290
|
cube: "Cubo",
|
289
291
|
sendByEmail: "Enviar por email",
|
@@ -296,6 +298,7 @@ const snkDataExporterMessages = {
|
|
296
298
|
},
|
297
299
|
title: {
|
298
300
|
error: "Erro",
|
301
|
+
permission: "Falha detectada",
|
299
302
|
},
|
300
303
|
limitExceeded: {
|
301
304
|
title: "Atenção",
|
@@ -552,7 +555,7 @@ class SnkMessageBuilder {
|
|
552
555
|
this.loadAppMessages().then((msgs) => {
|
553
556
|
this._appMessages = msgs;
|
554
557
|
}, error => {
|
555
|
-
console.info('O arquivo de mensagens personalizadas não foi encontrado no caminho /messages/appmessages
|
558
|
+
console.info('O arquivo de mensagens personalizadas não foi encontrado no caminho /messages/appmessages', error);
|
556
559
|
});
|
557
560
|
}
|
558
561
|
/**
|
@@ -644,17 +647,10 @@ class SnkMessageBuilder {
|
|
644
647
|
return message;
|
645
648
|
}
|
646
649
|
}
|
647
|
-
loadAppMessages() {
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
.then(module => {
|
652
|
-
accept(module.default);
|
653
|
-
})
|
654
|
-
.catch(reason => {
|
655
|
-
reject(reason);
|
656
|
-
});
|
657
|
-
});
|
650
|
+
async loadAppMessages() {
|
651
|
+
const messagesUrl = await this._application.getApplicationPath();
|
652
|
+
const module = await import(/* webpackIgnore: true */ `${messagesUrl}/messages/appmessages.js`);
|
653
|
+
return module.default;
|
658
654
|
}
|
659
655
|
}
|
660
656
|
var OperationMap;
|
@@ -1,170 +1,11 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
1
|
+
import { ObjectUtils, DataUnit, DataType, DateUtils, StringUtils, ChangeOperation, ApplicationContext, UserInterface, DataUnitStorage } from '@sankhyalabs/core';
|
2
|
+
import { D as DataFetcher, d as dist } from './DataFetcher.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';
|
6
|
+
import SortingUtils from '@sankhyalabs/core/dist/utils/SortingUtils';
|
6
7
|
import { R as ResourceIDUtils } from './ResourceIDUtils.js';
|
7
8
|
|
8
|
-
class PesquisaFetcher {
|
9
|
-
constructor() {
|
10
|
-
this._defaultPageSize = 100;
|
11
|
-
this._templateByQuery = new Map();
|
12
|
-
this._searchListenersByDataUnit = new Map();
|
13
|
-
this.buldTemplates();
|
14
|
-
}
|
15
|
-
buldTemplates() {
|
16
|
-
this._templateByQuery.set("search", dist.gql `query($entityName: String! $argument: String $criteria: InputSearchCriteria $options: InputSearchOptions) {
|
17
|
-
$queryAlias$: search(entityName: $entityName argument: $argument criteria: $criteria options: $options){
|
18
|
-
value
|
19
|
-
label
|
20
|
-
}
|
21
|
-
}`);
|
22
|
-
}
|
23
|
-
loadSearchOptions(entityName, argument, criteria, options) {
|
24
|
-
var _a;
|
25
|
-
const cleanText = (argument === null || argument === void 0 ? void 0 : argument.toString().trim()) || undefined;
|
26
|
-
argument = isNaN(Number(cleanText)) && cleanText ? `%${cleanText}` : cleanText;
|
27
|
-
criteria === null || criteria === void 0 ? void 0 : criteria.params.forEach(param => {
|
28
|
-
if (param.dataType === DataType.OBJECT) {
|
29
|
-
param.value = JSON.stringify(param.value);
|
30
|
-
}
|
31
|
-
});
|
32
|
-
const listenerResult = this.applySearchListener(SearchListenerType.beforeSearch, entityName, argument, criteria, options);
|
33
|
-
const values = {
|
34
|
-
argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
|
35
|
-
entityName,
|
36
|
-
criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
|
37
|
-
options: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || options,
|
38
|
-
};
|
39
|
-
if (values.options) {
|
40
|
-
(_a = values.options) === null || _a === void 0 ? true : delete _a.dataUnitId;
|
41
|
-
}
|
42
|
-
return new Promise((resolve, reject) => {
|
43
|
-
DataFetcher.get()
|
44
|
-
.callGraphQL({
|
45
|
-
values,
|
46
|
-
query: this._templateByQuery.get("search"),
|
47
|
-
})
|
48
|
-
.then((result) => {
|
49
|
-
resolve(result);
|
50
|
-
})
|
51
|
-
.catch((error) => {
|
52
|
-
reject(error);
|
53
|
-
});
|
54
|
-
});
|
55
|
-
}
|
56
|
-
loadAdvancedSearch(entityName, argument, criteria, searchOptions) {
|
57
|
-
var _a, _b, _c, _d;
|
58
|
-
const listenerResult = this.applySearchListener(SearchListenerType.beforeSearch, entityName, argument, criteria, searchOptions);
|
59
|
-
const values = {
|
60
|
-
argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
|
61
|
-
criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
|
62
|
-
searchOptions: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || searchOptions,
|
63
|
-
};
|
64
|
-
const serviceName = "PesquisaSP.getSuggestion";
|
65
|
-
const externalCriteria = {
|
66
|
-
query: {
|
67
|
-
$: (_a = values.criteria) === null || _a === void 0 ? void 0 : _a.expression
|
68
|
-
}
|
69
|
-
};
|
70
|
-
if (((_c = (_b = values.criteria) === null || _b === void 0 ? void 0 : _b.params) === null || _c === void 0 ? void 0 : _c.length) > 0) {
|
71
|
-
externalCriteria.params = {
|
72
|
-
param: values.criteria.params.map(param => {
|
73
|
-
let value = param.value;
|
74
|
-
if (typeof value === "string") {
|
75
|
-
const match = /CTX\{([^}]+)\}/.exec(value);
|
76
|
-
if (match) {
|
77
|
-
value = ApplicationContext.getContextValue(`__SNK__APPLICATION__FILTER__CONTEXT(${match[1]})__`);
|
78
|
-
}
|
79
|
-
}
|
80
|
-
let type = param.dataType;
|
81
|
-
if (type === DataType.OBJECT) {
|
82
|
-
value = value.value;
|
83
|
-
type = "S";
|
84
|
-
}
|
85
|
-
else {
|
86
|
-
type = convertParamType(param.dataType);
|
87
|
-
}
|
88
|
-
return { $: value, type };
|
89
|
-
})
|
90
|
-
};
|
91
|
-
}
|
92
|
-
const options = searchOptions != undefined
|
93
|
-
? Object.assign(Object.assign({}, searchOptions), { "pkFieldName": searchOptions.codeFieldName, "label": searchOptions.descriptionFieldName, "fieldName": searchOptions.codeFieldName, "useDescriptionOptions": false, "enableRowsCounter": true }) : undefined;
|
94
|
-
const reqBody = {
|
95
|
-
"serviceName": serviceName,
|
96
|
-
"requestBody": {
|
97
|
-
"criteria": Object.assign({ "entityName": entityName, "compacted": false, "ignoreEntityCriteria": false, "limit": this._defaultPageSize, "query": { "$": values.argument }, "orderByDesc": false, "externalCriteria": externalCriteria, "localEntityName": (_d = values.searchOptions) === null || _d === void 0 ? void 0 : _d.rootEntity }, { options }),
|
98
|
-
"clientEventList": {
|
99
|
-
"clientEvent": []
|
100
|
-
}
|
101
|
-
}
|
102
|
-
};
|
103
|
-
return new Promise((resolve, reject) => {
|
104
|
-
DataFetcher.get()
|
105
|
-
.callServiceBroker("PesquisaSP.getSuggestion", JSON.stringify(reqBody))
|
106
|
-
.then(result => resolve(result))
|
107
|
-
.catch(error => reject(error));
|
108
|
-
});
|
109
|
-
}
|
110
|
-
addSearchListener(entityName, dataUnitID, listener) {
|
111
|
-
var _a;
|
112
|
-
const dataUnitSearchListeners = this._searchListenersByDataUnit.get(dataUnitID) || [];
|
113
|
-
const entityListener = dataUnitSearchListeners.find(currentListener => currentListener.entity === entityName);
|
114
|
-
if (!entityListener) {
|
115
|
-
this._searchListenersByDataUnit.set(dataUnitID, [...dataUnitSearchListeners, { entity: entityName, listener }]);
|
116
|
-
}
|
117
|
-
else {
|
118
|
-
for (const type of Object.keys(listener)) {
|
119
|
-
if (type in entityListener.listener) {
|
120
|
-
const listenerFunctionIsEquals = ((_a = entityListener.listener[type]) === null || _a === void 0 ? void 0 : _a.toString()) === listener[type].toString();
|
121
|
-
if (listenerFunctionIsEquals)
|
122
|
-
continue;
|
123
|
-
entityListener.listener[type] = listener[type];
|
124
|
-
}
|
125
|
-
}
|
126
|
-
}
|
127
|
-
return () => {
|
128
|
-
const newListeners = dataUnitSearchListeners.filter(currentListener => currentListener.entity !== entityName);
|
129
|
-
if (!newListeners.length) {
|
130
|
-
this._searchListenersByDataUnit.delete(dataUnitID);
|
131
|
-
return;
|
132
|
-
}
|
133
|
-
this._searchListenersByDataUnit.set(dataUnitID, newListeners);
|
134
|
-
};
|
135
|
-
}
|
136
|
-
applySearchListener(listenerType, entityName, argument, criteria, searchOptions) {
|
137
|
-
var _a;
|
138
|
-
const dataUnitId = searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.dataUnitId;
|
139
|
-
if (!dataUnitId)
|
140
|
-
return;
|
141
|
-
const entityListener = (_a = this._searchListenersByDataUnit.get(dataUnitId)) === null || _a === void 0 ? void 0 : _a.find(({ entity }) => entity === entityName);
|
142
|
-
if (!entityListener)
|
143
|
-
return;
|
144
|
-
const { listener } = entityListener;
|
145
|
-
if (!(listenerType in listener))
|
146
|
-
return;
|
147
|
-
return listener[listenerType]({ argument, criteria, searchOptions });
|
148
|
-
}
|
149
|
-
}
|
150
|
-
function convertParamType(dataType) {
|
151
|
-
//Alerta: Cuidado pra não contaminar o DataType com a implementação
|
152
|
-
//atual da pesquisa... em geral, somente inteiros,
|
153
|
-
//data (com ou sem hora) e string são realmente relevantes
|
154
|
-
switch (dataType) {
|
155
|
-
case DataType.NUMBER:
|
156
|
-
return "I";
|
157
|
-
case DataType.DATE:
|
158
|
-
return "D";
|
159
|
-
default:
|
160
|
-
return "S";
|
161
|
-
}
|
162
|
-
}
|
163
|
-
var SearchListenerType;
|
164
|
-
(function (SearchListenerType) {
|
165
|
-
SearchListenerType["beforeSearch"] = "beforeSearch";
|
166
|
-
})(SearchListenerType || (SearchListenerType = {}));
|
167
|
-
|
168
9
|
class ArrayRepository {
|
169
10
|
constructor(equalsFunction) {
|
170
11
|
this._list = [];
|
@@ -244,6 +85,9 @@ class ArrayRepository {
|
|
244
85
|
async count() {
|
245
86
|
return Promise.resolve(this._list.length);
|
246
87
|
}
|
88
|
+
getFromCache() {
|
89
|
+
return ObjectUtils.copy(this._list);
|
90
|
+
}
|
247
91
|
}
|
248
92
|
|
249
93
|
class PreloadManager {
|
@@ -265,17 +109,7 @@ class PreloadManager {
|
|
265
109
|
}
|
266
110
|
}
|
267
111
|
static getSortingFunction(dataUnit, sorting) {
|
268
|
-
|
269
|
-
return undefined;
|
270
|
-
}
|
271
|
-
return (recordA, recordB) => {
|
272
|
-
for (const sort of sorting) {
|
273
|
-
const result = FieldComparator.compare(dataUnit.getField(sort.field), recordA, recordB, sort.mode === SortMode.ASC);
|
274
|
-
if (result != 0) {
|
275
|
-
return result;
|
276
|
-
}
|
277
|
-
}
|
278
|
-
};
|
112
|
+
return SortingUtils.getSortingFunction(dataUnit, sorting);
|
279
113
|
}
|
280
114
|
static async getDistinct(dataUnit, fieldName) {
|
281
115
|
if (!PreloadManager.isCacheEnabled(dataUnit)) {
|
@@ -312,7 +146,11 @@ class PreloadManager {
|
|
312
146
|
static async loadData(dataUnit, request, loadFromServer) {
|
313
147
|
try {
|
314
148
|
if (PreloadManager.isCacheEnabled(dataUnit)) {
|
315
|
-
|
149
|
+
const useCache = [
|
150
|
+
"EZ_GRID_LOADING_SOURCE",
|
151
|
+
DataUnit.CHANGING_PAGE_LOADING_SOURCE,
|
152
|
+
DataUnit.ALL_RECORDS_SELECTION_SOURCE
|
153
|
+
].includes(request.source);
|
316
154
|
if (useCache) {
|
317
155
|
const isCacheEmpty = await PreloadManager.getRepository(dataUnit).isEmpty();
|
318
156
|
if (!isCacheEmpty) {
|
@@ -379,6 +217,9 @@ class PreloadManager {
|
|
379
217
|
.catch(reason => reject(reason));
|
380
218
|
});
|
381
219
|
}
|
220
|
+
static getCachedRecords(dataUnit) {
|
221
|
+
return PreloadManager.getRepository(dataUnit).getFromCache();
|
222
|
+
}
|
382
223
|
}
|
383
224
|
PreloadManager._repositories = new Map();
|
384
225
|
PreloadManager._loadingStatus = new Map();
|
@@ -420,7 +261,7 @@ function buildPaginationInfo(records, offset = 0, limit = 0) {
|
|
420
261
|
}
|
421
262
|
|
422
263
|
class InMemoryLoader {
|
423
|
-
constructor(metadata, records) {
|
264
|
+
constructor(metadata, records, config) {
|
424
265
|
this.metadata = metadata;
|
425
266
|
this.records = records;
|
426
267
|
this._dataUnit = new DataUnit(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME);
|
@@ -429,7 +270,11 @@ class InMemoryLoader {
|
|
429
270
|
this._dataUnit.dataLoader = (dataUnit, request) => this.inMemoryLoader(dataUnit, request, this.getRecordsToLoad());
|
430
271
|
this._dataUnit.saveLoader = (_dataUnit, changes) => this.saveLoader(_dataUnit, changes);
|
431
272
|
this._dataUnit.removeLoader = (_dataUnit, recordIds) => this.removeLoader(_dataUnit, recordIds);
|
432
|
-
this.dataUnit.loadMetadata().then(() =>
|
273
|
+
this.dataUnit.loadMetadata().then(() => {
|
274
|
+
if ((config === null || config === void 0 ? void 0 : config.autoLoad) !== false) {
|
275
|
+
this.dataUnit.loadData();
|
276
|
+
}
|
277
|
+
});
|
433
278
|
}
|
434
279
|
getRecordsToLoad() {
|
435
280
|
if (this._initialRecords == undefined && this.dataUnit.records.length > 0) {
|
@@ -481,7 +326,7 @@ class InMemoryLoader {
|
|
481
326
|
this._initialRecords = newRecords;
|
482
327
|
if (this._dataUnit) {
|
483
328
|
//Isso força o refresh internamente no datunit
|
484
|
-
this._dataUnit.
|
329
|
+
this._dataUnit.loadData();
|
485
330
|
}
|
486
331
|
}
|
487
332
|
get metadata() {
|
@@ -533,11 +378,17 @@ class InMemoryLoader {
|
|
533
378
|
}
|
534
379
|
InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME = "InMemoryDataUnit";
|
535
380
|
|
381
|
+
function getRecordValue(record, fieldName) {
|
382
|
+
var _a, _b;
|
383
|
+
return ((_a = record[fieldName]) === null || _a === void 0 ? void 0 : _a.value) !== undefined ? (_b = record[fieldName]) === null || _b === void 0 ? void 0 : _b.value : record[fieldName];
|
384
|
+
}
|
385
|
+
|
536
386
|
class DatasetStrategy {
|
537
387
|
canSlice() {
|
538
388
|
return false;
|
539
389
|
}
|
540
390
|
processSortingSide(request, dataUnit, serverSideFilters) {
|
391
|
+
var _a;
|
541
392
|
const localSorting = [];
|
542
393
|
const serverSorting = [];
|
543
394
|
if (request.sort != undefined) {
|
@@ -546,9 +397,7 @@ class DatasetStrategy {
|
|
546
397
|
}
|
547
398
|
for (const sort of request.sort) {
|
548
399
|
const descriptor = dataUnit.getField(sort.field);
|
549
|
-
const local = descriptor
|
550
|
-
&& descriptor.properties != undefined
|
551
|
-
&& descriptor.properties.calculated === "true";
|
400
|
+
const local = ((_a = descriptor === null || descriptor === void 0 ? void 0 : descriptor.properties) === null || _a === void 0 ? void 0 : _a.calculated) === "true" || (descriptor === null || descriptor === void 0 ? void 0 : descriptor.userInterface) === UserInterface.LONGTEXT;
|
552
401
|
if (local) {
|
553
402
|
localSorting.push(sort);
|
554
403
|
}
|
@@ -588,6 +437,53 @@ class DatasetStrategy {
|
|
588
437
|
return Promise.reject(error);
|
589
438
|
}
|
590
439
|
}
|
440
|
+
async loadRowMetadata(snkDataUnit, fieldName, metadataName, updatedFields = {}) {
|
441
|
+
try {
|
442
|
+
const serviceName = "DatasetSP.loadRowMetadata";
|
443
|
+
const parsedRequestBody = await this.buildRequestBodyLoadRowMetadata({ snkDataUnit, fieldName, metadataName, serviceName, updatedFields });
|
444
|
+
const response = await DataFetcher.get().callServiceBroker(serviceName, parsedRequestBody);
|
445
|
+
return response;
|
446
|
+
}
|
447
|
+
catch (error) {
|
448
|
+
console.error(error);
|
449
|
+
return Promise.reject(error);
|
450
|
+
}
|
451
|
+
}
|
452
|
+
async buildRequestBodyLoadRowMetadata({ snkDataUnit, serviceName, fieldName, metadataName, updatedFields, }) {
|
453
|
+
const dataUnit = snkDataUnit.dataUnit;
|
454
|
+
const entityName = DataUnitFetcher.parseDataUnitName(dataUnit.name).entityName;
|
455
|
+
const recordIdInfo = await snkDataUnit.getSelectedRecordsIDsInfo();
|
456
|
+
const pk = recordIdInfo.reduce((accumulator, currentValue) => {
|
457
|
+
accumulator[currentValue.name] = currentValue.value;
|
458
|
+
return accumulator;
|
459
|
+
}, {});
|
460
|
+
const record = dataUnit.getSelectedRecord();
|
461
|
+
const fields = dataUnit.metadata.fields.filter(({ standAlone, name }) => !standAlone && !name.includes(".")).map(({ name }) => name);
|
462
|
+
const values = fields.reduce((accumulator, currentValue, currentIndex) => {
|
463
|
+
const recordValue = getRecordValue(record, currentValue);
|
464
|
+
const updatedFieldValue = getRecordValue(updatedFields, currentValue);
|
465
|
+
accumulator[currentIndex] = updatedFieldValue !== undefined ? updatedFieldValue : recordValue;
|
466
|
+
return accumulator;
|
467
|
+
}, {});
|
468
|
+
const requestBody = {
|
469
|
+
serviceName,
|
470
|
+
requestBody: {
|
471
|
+
dataSetID: dataUnit.dataUnitId,
|
472
|
+
entityName,
|
473
|
+
standAlone: false,
|
474
|
+
metadataName,
|
475
|
+
fieldName,
|
476
|
+
fields,
|
477
|
+
record: {
|
478
|
+
pk,
|
479
|
+
oldPk: pk,
|
480
|
+
values,
|
481
|
+
},
|
482
|
+
}
|
483
|
+
};
|
484
|
+
const parsedRequestBody = JSON.stringify(requestBody);
|
485
|
+
return parsedRequestBody;
|
486
|
+
}
|
591
487
|
getFieldsList(dataUnit) {
|
592
488
|
let fields = ["__record__id__", "__record__label__"];
|
593
489
|
dataUnit.metadata.fields.forEach((descriptor) => {
|
@@ -667,9 +563,11 @@ class DatasetStrategy {
|
|
667
563
|
}
|
668
564
|
processRecords(dataUnit, fields, responseRecords) {
|
669
565
|
return responseRecords.map((dataFrame) => {
|
566
|
+
const lastElement = dataFrame[dataFrame.length - 1];
|
670
567
|
const duRecord = {
|
671
568
|
__record__id__: dataFrame[0],
|
672
|
-
__record__label__: dataFrame[1]
|
569
|
+
__record__label__: dataFrame[1],
|
570
|
+
__record__metadata__: lastElement['_rmd'],
|
673
571
|
};
|
674
572
|
dataUnit.metadata.fields.forEach(fieldDescriptor => {
|
675
573
|
duRecord[fieldDescriptor.name] = this.buildFieldValue(fieldDescriptor, fields, dataFrame);
|
@@ -732,6 +630,9 @@ class DataUnitDataLoader {
|
|
732
630
|
});
|
733
631
|
});
|
734
632
|
}
|
633
|
+
static getCachedRecords(dataUnit) {
|
634
|
+
return PreloadManager.getCachedRecords(dataUnit);
|
635
|
+
}
|
735
636
|
static async loadFromServer(dataUnit, request, loadingInfo) {
|
736
637
|
try {
|
737
638
|
//Registramos a request com as informações de carga para determinarmos a última.
|
@@ -932,6 +833,7 @@ class DataUnitFetcher {
|
|
932
833
|
dataUnit.saveLoader = (_dataUnit, changes) => this.saveData(dataUnit, changes);
|
933
834
|
dataUnit.removeLoader = (dataUnit, recordIds) => this.removeRecords(dataUnit, recordIds);
|
934
835
|
dataUnit.recordLoader = (dataUnit, recordIds) => this.loadRecord(dataUnit, recordIds);
|
836
|
+
dataUnit.allRecordsLoader = (dataUnit) => DataUnitDataLoader.getCachedRecords(dataUnit);
|
935
837
|
return dataUnit;
|
936
838
|
}
|
937
839
|
loadMetadata(dataUnit) {
|
@@ -1150,4 +1052,4 @@ class DataUnitFetcher {
|
|
1150
1052
|
}
|
1151
1053
|
}
|
1152
1054
|
|
1153
|
-
export { DataUnitFetcher as D, InMemoryLoader as I,
|
1055
|
+
export { DataUnitFetcher as D, InMemoryLoader as I, PreloadManager as P, applyFilter as a, applySorting as b, buildPaginationInfo as c, DatasetStrategy as d, getRecordValue as g };
|
@@ -1,34 +1,199 @@
|
|
1
|
-
|
2
|
-
(function (PresentationMode) {
|
3
|
-
PresentationMode["PRIMARY"] = "primary";
|
4
|
-
PresentationMode["SECONDARY"] = "secondary";
|
5
|
-
PresentationMode["SINGLE_TASKBAR"] = "singleTaskbar";
|
6
|
-
})(PresentationMode || (PresentationMode = {}));
|
7
|
-
var DataExporterOption;
|
8
|
-
(function (DataExporterOption) {
|
9
|
-
DataExporterOption["EXPORT_TO_PDF"] = "exportToPDF";
|
10
|
-
DataExporterOption["EXPORT_TO_XLS"] = "exportToXLS";
|
11
|
-
DataExporterOption["EXPORT_CURRENT_PAGE"] = "exportCurrentPage";
|
12
|
-
DataExporterOption["EXPORT_PAGE_TO_PDF"] = "exportPageToPDF";
|
13
|
-
DataExporterOption["EXPORT_PAGE_TO_XLS"] = "exportPageToXLS";
|
14
|
-
DataExporterOption["EXPORT_BY_EMAIL"] = "exportToEmail";
|
15
|
-
DataExporterOption["EXPORT_PDF_TO_EMAIL"] = "exportPDFToEmail";
|
16
|
-
DataExporterOption["EXPORT_XLS_TO_EMAIL"] = "exportXLSToEmail";
|
17
|
-
})(DataExporterOption || (DataExporterOption = {}));
|
18
|
-
var DataExporterFormat;
|
19
|
-
(function (DataExporterFormat) {
|
20
|
-
DataExporterFormat["PDF"] = "exportPDFToEmail";
|
21
|
-
DataExporterFormat["XLS"] = "exportXLSToEmail";
|
22
|
-
DataExporterFormat["XLSX"] = "exportXLSToEmail";
|
23
|
-
})(DataExporterFormat || (DataExporterFormat = {}));
|
24
|
-
var DataExporterType;
|
25
|
-
(function (DataExporterType) {
|
26
|
-
DataExporterType["EXPORT_TO_PDF"] = "PDF";
|
27
|
-
DataExporterType["EXPORT_TO_XLS"] = "XLS";
|
28
|
-
DataExporterType["EXPORT_PAGE_TO_PDF"] = "PDF";
|
29
|
-
DataExporterType["EXPORT_PAGE_TO_XLS"] = "XLS";
|
30
|
-
DataExporterType["EXPORT_PDF_TO_EMAIL"] = "PDF";
|
31
|
-
DataExporterType["EXPORT_XLS_TO_EMAIL"] = "XLS";
|
32
|
-
})(DataExporterType || (DataExporterType = {}));
|
1
|
+
import { getRenderingRef, forceUpdate } from '@stencil/core/internal/client';
|
33
2
|
|
34
|
-
|
3
|
+
const appendToMap = (map, propName, value) => {
|
4
|
+
const items = map.get(propName);
|
5
|
+
if (!items) {
|
6
|
+
map.set(propName, [value]);
|
7
|
+
}
|
8
|
+
else if (!items.includes(value)) {
|
9
|
+
items.push(value);
|
10
|
+
}
|
11
|
+
};
|
12
|
+
const debounce = (fn, ms) => {
|
13
|
+
let timeoutId;
|
14
|
+
return (...args) => {
|
15
|
+
if (timeoutId) {
|
16
|
+
clearTimeout(timeoutId);
|
17
|
+
}
|
18
|
+
timeoutId = setTimeout(() => {
|
19
|
+
timeoutId = 0;
|
20
|
+
fn(...args);
|
21
|
+
}, ms);
|
22
|
+
};
|
23
|
+
};
|
24
|
+
|
25
|
+
/**
|
26
|
+
* Check if a possible element isConnected.
|
27
|
+
* The property might not be there, so we check for it.
|
28
|
+
*
|
29
|
+
* We want it to return true if isConnected is not a property,
|
30
|
+
* otherwise we would remove these elements and would not update.
|
31
|
+
*
|
32
|
+
* Better leak in Edge than to be useless.
|
33
|
+
*/
|
34
|
+
const isConnected = (maybeElement) => !('isConnected' in maybeElement) || maybeElement.isConnected;
|
35
|
+
const cleanupElements = debounce((map) => {
|
36
|
+
for (let key of map.keys()) {
|
37
|
+
map.set(key, map.get(key).filter(isConnected));
|
38
|
+
}
|
39
|
+
}, 2000);
|
40
|
+
const stencilSubscription = () => {
|
41
|
+
if (typeof getRenderingRef !== 'function') {
|
42
|
+
// If we are not in a stencil project, we do nothing.
|
43
|
+
// This function is not really exported by @stencil/core.
|
44
|
+
return {};
|
45
|
+
}
|
46
|
+
const elmsToUpdate = new Map();
|
47
|
+
return {
|
48
|
+
dispose: () => elmsToUpdate.clear(),
|
49
|
+
get: (propName) => {
|
50
|
+
const elm = getRenderingRef();
|
51
|
+
if (elm) {
|
52
|
+
appendToMap(elmsToUpdate, propName, elm);
|
53
|
+
}
|
54
|
+
},
|
55
|
+
set: (propName) => {
|
56
|
+
const elements = elmsToUpdate.get(propName);
|
57
|
+
if (elements) {
|
58
|
+
elmsToUpdate.set(propName, elements.filter(forceUpdate));
|
59
|
+
}
|
60
|
+
cleanupElements(elmsToUpdate);
|
61
|
+
},
|
62
|
+
reset: () => {
|
63
|
+
elmsToUpdate.forEach((elms) => elms.forEach(forceUpdate));
|
64
|
+
cleanupElements(elmsToUpdate);
|
65
|
+
},
|
66
|
+
};
|
67
|
+
};
|
68
|
+
|
69
|
+
const unwrap = (val) => (typeof val === 'function' ? val() : val);
|
70
|
+
const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) => {
|
71
|
+
const unwrappedState = unwrap(defaultState);
|
72
|
+
let states = new Map(Object.entries(unwrappedState !== null && unwrappedState !== void 0 ? unwrappedState : {}));
|
73
|
+
const handlers = {
|
74
|
+
dispose: [],
|
75
|
+
get: [],
|
76
|
+
set: [],
|
77
|
+
reset: [],
|
78
|
+
};
|
79
|
+
const reset = () => {
|
80
|
+
var _a;
|
81
|
+
// When resetting the state, the default state may be a function - unwrap it to invoke it.
|
82
|
+
// otherwise, the state won't be properly reset
|
83
|
+
states = new Map(Object.entries((_a = unwrap(defaultState)) !== null && _a !== void 0 ? _a : {}));
|
84
|
+
handlers.reset.forEach((cb) => cb());
|
85
|
+
};
|
86
|
+
const dispose = () => {
|
87
|
+
// Call first dispose as resetting the state would
|
88
|
+
// cause less updates ;)
|
89
|
+
handlers.dispose.forEach((cb) => cb());
|
90
|
+
reset();
|
91
|
+
};
|
92
|
+
const get = (propName) => {
|
93
|
+
handlers.get.forEach((cb) => cb(propName));
|
94
|
+
return states.get(propName);
|
95
|
+
};
|
96
|
+
const set = (propName, value) => {
|
97
|
+
const oldValue = states.get(propName);
|
98
|
+
if (shouldUpdate(value, oldValue, propName)) {
|
99
|
+
states.set(propName, value);
|
100
|
+
handlers.set.forEach((cb) => cb(propName, value, oldValue));
|
101
|
+
}
|
102
|
+
};
|
103
|
+
const state = (typeof Proxy === 'undefined'
|
104
|
+
? {}
|
105
|
+
: new Proxy(unwrappedState, {
|
106
|
+
get(_, propName) {
|
107
|
+
return get(propName);
|
108
|
+
},
|
109
|
+
ownKeys(_) {
|
110
|
+
return Array.from(states.keys());
|
111
|
+
},
|
112
|
+
getOwnPropertyDescriptor() {
|
113
|
+
return {
|
114
|
+
enumerable: true,
|
115
|
+
configurable: true,
|
116
|
+
};
|
117
|
+
},
|
118
|
+
has(_, propName) {
|
119
|
+
return states.has(propName);
|
120
|
+
},
|
121
|
+
set(_, propName, value) {
|
122
|
+
set(propName, value);
|
123
|
+
return true;
|
124
|
+
},
|
125
|
+
}));
|
126
|
+
const on = (eventName, callback) => {
|
127
|
+
handlers[eventName].push(callback);
|
128
|
+
return () => {
|
129
|
+
removeFromArray(handlers[eventName], callback);
|
130
|
+
};
|
131
|
+
};
|
132
|
+
const onChange = (propName, cb) => {
|
133
|
+
const unSet = on('set', (key, newValue) => {
|
134
|
+
if (key === propName) {
|
135
|
+
cb(newValue);
|
136
|
+
}
|
137
|
+
});
|
138
|
+
// We need to unwrap the defaultState because it might be a function.
|
139
|
+
// Otherwise we might not be sending the right reset value.
|
140
|
+
const unReset = on('reset', () => cb(unwrap(defaultState)[propName]));
|
141
|
+
return () => {
|
142
|
+
unSet();
|
143
|
+
unReset();
|
144
|
+
};
|
145
|
+
};
|
146
|
+
const use = (...subscriptions) => {
|
147
|
+
const unsubs = subscriptions.reduce((unsubs, subscription) => {
|
148
|
+
if (subscription.set) {
|
149
|
+
unsubs.push(on('set', subscription.set));
|
150
|
+
}
|
151
|
+
if (subscription.get) {
|
152
|
+
unsubs.push(on('get', subscription.get));
|
153
|
+
}
|
154
|
+
if (subscription.reset) {
|
155
|
+
unsubs.push(on('reset', subscription.reset));
|
156
|
+
}
|
157
|
+
if (subscription.dispose) {
|
158
|
+
unsubs.push(on('dispose', subscription.dispose));
|
159
|
+
}
|
160
|
+
return unsubs;
|
161
|
+
}, []);
|
162
|
+
return () => unsubs.forEach((unsub) => unsub());
|
163
|
+
};
|
164
|
+
const forceUpdate = (key) => {
|
165
|
+
const oldValue = states.get(key);
|
166
|
+
handlers.set.forEach((cb) => cb(key, oldValue, oldValue));
|
167
|
+
};
|
168
|
+
return {
|
169
|
+
state,
|
170
|
+
get,
|
171
|
+
set,
|
172
|
+
on,
|
173
|
+
onChange,
|
174
|
+
use,
|
175
|
+
dispose,
|
176
|
+
reset,
|
177
|
+
forceUpdate,
|
178
|
+
};
|
179
|
+
};
|
180
|
+
const removeFromArray = (array, item) => {
|
181
|
+
const index = array.indexOf(item);
|
182
|
+
if (index >= 0) {
|
183
|
+
array[index] = array[array.length - 1];
|
184
|
+
array.length--;
|
185
|
+
}
|
186
|
+
};
|
187
|
+
|
188
|
+
const createStore = (defaultState, shouldUpdate) => {
|
189
|
+
const map = createObservableMap(defaultState, shouldUpdate);
|
190
|
+
map.use(stencilSubscription());
|
191
|
+
return map;
|
192
|
+
};
|
193
|
+
|
194
|
+
const store = createStore({
|
195
|
+
exporterProviders: {},
|
196
|
+
filterFieldsDataSource: undefined
|
197
|
+
});
|
198
|
+
|
199
|
+
export { store as s };
|