@sankhyalabs/sankhyablocks 8.15.1 → 8.16.0-dev.1
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/{SnkMultiSelectionListDataSource-303e85d1.js → IExporterProvider-c78cb1b8.js} +94 -4
- package/dist/cjs/RecordIDUtils-3735135c.js +43 -0
- package/dist/cjs/{SnkFormConfigManager-f9dc0d28.js → SnkFormConfigManager-1b13bacd.js} +6 -3
- package/dist/cjs/{SnkMessageBuilder-66aa2557.js → SnkMessageBuilder-722b104e.js} +8 -12
- package/dist/cjs/{pesquisa-fetcher-213797ec.js → dataunit-fetcher-620b29a1.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 +4 -2
- package/dist/cjs/snk-application.cjs.entry.js +34 -11
- package/dist/cjs/snk-attach.cjs.entry.js +71 -46
- package/dist/cjs/snk-crud.cjs.entry.js +96 -10
- package/dist/cjs/snk-data-exporter.cjs.entry.js +315 -85
- package/dist/cjs/snk-data-unit-82dea87e.js +679 -0
- package/dist/cjs/snk-data-unit.cjs.entry.js +12 -2
- package/dist/cjs/snk-detail-view.cjs.entry.js +48 -7
- package/dist/cjs/snk-filter-bar.cjs.entry.js +5 -1
- package/dist/cjs/snk-form-view.cjs.entry.js +67 -0
- package/dist/cjs/snk-form.cjs.entry.js +51 -6
- package/dist/cjs/snk-grid.cjs.entry.js +164 -107
- package/dist/cjs/{snk-guides-viewer-4b6ecda8.js → snk-guides-viewer-05a1ba27.js} +36 -8
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +8 -6
- package/dist/cjs/snk-simple-crud.cjs.entry.js +264 -37
- 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 +249 -7
- package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +135 -0
- package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +161 -0
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +112 -5
- 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 +507 -214
- 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 +6 -3
- package/dist/collection/components/snk-grid/snk-grid.js +240 -101
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +386 -18
- 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/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 +1 -0
- package/dist/components/{field-search.js → IExporterProvider.js} +93 -6
- package/dist/components/ISave.js +47 -0
- package/dist/components/SnkFormConfigManager.js +6 -3
- package/dist/components/SnkMessageBuilder.js +8 -12
- 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 +103 -11
- package/dist/components/snk-data-exporter2.js +309 -85
- package/dist/components/snk-data-unit2.js +470 -212
- package/dist/components/snk-detail-view2.js +87 -10
- package/dist/components/snk-expression-item2.js +1 -1
- package/dist/components/snk-filter-bar2.js +6 -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 +259 -23
- package/dist/components/snk-taskbar2.js +6 -5
- package/dist/esm/{SnkMultiSelectionListDataSource-36918dbf.js → IExporterProvider-343272b3.js} +93 -5
- package/dist/esm/RecordIDUtils-87d02110.js +41 -0
- package/dist/esm/{SnkFormConfigManager-f53f9f87.js → SnkFormConfigManager-d4554df9.js} +6 -3
- package/dist/esm/{SnkMessageBuilder-0a4becdd.js → SnkMessageBuilder-89925609.js} +8 -12
- package/dist/esm/{pesquisa-fetcher-fe6f3826.js → dataunit-fetcher-3fbf9d12.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 +4 -2
- package/dist/esm/snk-application.entry.js +33 -10
- package/dist/esm/snk-attach.entry.js +66 -41
- package/dist/esm/snk-crud.entry.js +96 -10
- package/dist/esm/snk-data-exporter.entry.js +316 -86
- package/dist/esm/snk-data-unit-8f98b45f.js +677 -0
- package/dist/esm/snk-data-unit.entry.js +12 -2
- package/dist/esm/snk-detail-view.entry.js +48 -7
- package/dist/esm/snk-filter-bar.entry.js +5 -1
- package/dist/esm/snk-form-view.entry.js +67 -0
- package/dist/esm/snk-form.entry.js +51 -6
- package/dist/esm/snk-grid.entry.js +162 -105
- package/dist/esm/{snk-guides-viewer-113be3fd.js → snk-guides-viewer-aee2cafe.js} +36 -8
- package/dist/esm/snk-guides-viewer.entry.js +8 -6
- package/dist/esm/snk-simple-crud.entry.js +252 -25
- 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-0d91b10f.entry.js +1 -0
- package/dist/sankhyablocks/p-1db45d26.entry.js +1 -0
- package/dist/sankhyablocks/p-26394a01.entry.js +1 -0
- package/dist/sankhyablocks/p-2d649237.entry.js +1 -0
- package/dist/sankhyablocks/p-30cf616e.js +1 -0
- package/dist/sankhyablocks/p-44767378.entry.js +1 -0
- package/dist/sankhyablocks/p-47b60deb.entry.js +1 -0
- package/dist/sankhyablocks/p-4f72727a.entry.js +1 -0
- package/dist/sankhyablocks/p-550fee49.entry.js +1 -0
- package/dist/sankhyablocks/p-5539ecb4.entry.js +1 -0
- package/dist/sankhyablocks/p-672302c3.js +60 -0
- package/dist/sankhyablocks/p-7a337364.js +1 -0
- package/dist/sankhyablocks/{p-ae4fc9a9.js → p-7e7a7473.js} +1 -1
- package/dist/sankhyablocks/p-829d4045.js +1 -0
- package/dist/sankhyablocks/p-8a5910a7.entry.js +1 -0
- package/dist/sankhyablocks/p-8cc64963.entry.js +1 -0
- package/dist/sankhyablocks/p-8fc470e5.entry.js +1 -0
- package/dist/sankhyablocks/p-9863d682.js +1 -0
- package/dist/sankhyablocks/p-9e99a92a.js +1 -0
- package/dist/sankhyablocks/p-af8efd95.js +6 -0
- package/dist/sankhyablocks/p-be603a24.js +1 -0
- package/dist/sankhyablocks/p-d09feef1.js +1 -0
- package/dist/sankhyablocks/p-e95b3b93.entry.js +11 -0
- package/dist/sankhyablocks/p-f2809746.entry.js +1 -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 +36 -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 +19 -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 +61 -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-grid/snk-grid.d.ts +46 -6
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +58 -4
- package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +1 -1
- package/dist/types/components.d.ts +220 -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-07a61550.entry.js +0 -1
- package/dist/sankhyablocks/p-0899e0b5.entry.js +0 -1
- package/dist/sankhyablocks/p-154a7f33.entry.js +0 -1
- package/dist/sankhyablocks/p-15802c59.entry.js +0 -1
- package/dist/sankhyablocks/p-164666b1.js +0 -65
- package/dist/sankhyablocks/p-32556aa6.js +0 -1
- package/dist/sankhyablocks/p-328585d0.entry.js +0 -1
- package/dist/sankhyablocks/p-38289a55.js +0 -1
- package/dist/sankhyablocks/p-52c8e589.js +0 -1
- package/dist/sankhyablocks/p-5cb07080.js +0 -1
- package/dist/sankhyablocks/p-74d349c3.entry.js +0 -1
- package/dist/sankhyablocks/p-7fe120b8.entry.js +0 -11
- package/dist/sankhyablocks/p-add17f6a.entry.js +0 -1
- package/dist/sankhyablocks/p-af1ac81f.entry.js +0 -1
- package/dist/sankhyablocks/p-b4525fc0.entry.js +0 -1
- package/dist/sankhyablocks/p-cce0865d.js +0 -1
- package/dist/sankhyablocks/p-dec65f6c.entry.js +0 -1
- package/dist/sankhyablocks/p-ee9536bc.entry.js +0 -1
- package/dist/sankhyablocks/p-f13f7616.entry.js +0 -1
- package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/index.d.ts +0 -3
@@ -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();
|
@@ -416,7 +257,7 @@ function buildPaginationInfo(records, offset = 0, limit = 0) {
|
|
416
257
|
}
|
417
258
|
|
418
259
|
class InMemoryLoader {
|
419
|
-
constructor(metadata, records) {
|
260
|
+
constructor(metadata, records, config) {
|
420
261
|
this.metadata = metadata;
|
421
262
|
this.records = records;
|
422
263
|
this._dataUnit = new DataUnit(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME);
|
@@ -424,7 +265,11 @@ class InMemoryLoader {
|
|
424
265
|
this._dataUnit.dataLoader = (dataUnit, request) => this.inMemoryLoader(dataUnit, request, this.getRecordsToLoad());
|
425
266
|
this._dataUnit.saveLoader = (_dataUnit, changes) => this.saveLoader(_dataUnit, changes);
|
426
267
|
this._dataUnit.removeLoader = (_dataUnit, recordIds) => this.removeLoader(_dataUnit, recordIds);
|
427
|
-
this.dataUnit.loadMetadata().then(() =>
|
268
|
+
this.dataUnit.loadMetadata().then(() => {
|
269
|
+
if ((config === null || config === void 0 ? void 0 : config.autoLoad) !== false) {
|
270
|
+
this.dataUnit.loadData();
|
271
|
+
}
|
272
|
+
});
|
428
273
|
}
|
429
274
|
getRecordsToLoad() {
|
430
275
|
if (this._initialRecords == undefined && this.dataUnit.records.length > 0) {
|
@@ -476,7 +321,7 @@ class InMemoryLoader {
|
|
476
321
|
this._initialRecords = newRecords;
|
477
322
|
if (this._dataUnit) {
|
478
323
|
//Isso força o refresh internamente no datunit
|
479
|
-
this._dataUnit.
|
324
|
+
this._dataUnit.loadData();
|
480
325
|
}
|
481
326
|
}
|
482
327
|
get metadata() {
|
@@ -528,11 +373,17 @@ class InMemoryLoader {
|
|
528
373
|
}
|
529
374
|
InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME = "InMemoryDataUnit";
|
530
375
|
|
376
|
+
function getRecordValue(record, fieldName) {
|
377
|
+
var _a, _b;
|
378
|
+
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];
|
379
|
+
}
|
380
|
+
|
531
381
|
class DatasetStrategy {
|
532
382
|
canSlice() {
|
533
383
|
return false;
|
534
384
|
}
|
535
385
|
processSortingSide(request, dataUnit, serverSideFilters) {
|
386
|
+
var _a;
|
536
387
|
const localSorting = [];
|
537
388
|
const serverSorting = [];
|
538
389
|
if (request.sort != undefined) {
|
@@ -541,9 +392,7 @@ class DatasetStrategy {
|
|
541
392
|
}
|
542
393
|
for (const sort of request.sort) {
|
543
394
|
const descriptor = dataUnit.getField(sort.field);
|
544
|
-
const local = descriptor
|
545
|
-
&& descriptor.properties != undefined
|
546
|
-
&& descriptor.properties.calculated === "true";
|
395
|
+
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;
|
547
396
|
if (local) {
|
548
397
|
localSorting.push(sort);
|
549
398
|
}
|
@@ -583,6 +432,53 @@ class DatasetStrategy {
|
|
583
432
|
return Promise.reject(error);
|
584
433
|
}
|
585
434
|
}
|
435
|
+
async loadRowMetadata(snkDataUnit, fieldName, metadataName, updatedFields = {}) {
|
436
|
+
try {
|
437
|
+
const serviceName = "DatasetSP.loadRowMetadata";
|
438
|
+
const parsedRequestBody = await this.buildRequestBodyLoadRowMetadata({ snkDataUnit, fieldName, metadataName, serviceName, updatedFields });
|
439
|
+
const response = await DataFetcher.get().callServiceBroker(serviceName, parsedRequestBody);
|
440
|
+
return response;
|
441
|
+
}
|
442
|
+
catch (error) {
|
443
|
+
console.error(error);
|
444
|
+
return Promise.reject(error);
|
445
|
+
}
|
446
|
+
}
|
447
|
+
async buildRequestBodyLoadRowMetadata({ snkDataUnit, serviceName, fieldName, metadataName, updatedFields, }) {
|
448
|
+
const dataUnit = snkDataUnit.dataUnit;
|
449
|
+
const entityName = DataUnitFetcher.parseDataUnitName(dataUnit.name).entityName;
|
450
|
+
const recordIdInfo = await snkDataUnit.getSelectedRecordsIDsInfo();
|
451
|
+
const pk = recordIdInfo.reduce((accumulator, currentValue) => {
|
452
|
+
accumulator[currentValue.name] = currentValue.value;
|
453
|
+
return accumulator;
|
454
|
+
}, {});
|
455
|
+
const record = dataUnit.getSelectedRecord();
|
456
|
+
const fields = dataUnit.metadata.fields.filter(({ standAlone, name }) => !standAlone && !name.includes(".")).map(({ name }) => name);
|
457
|
+
const values = fields.reduce((accumulator, currentValue, currentIndex) => {
|
458
|
+
const recordValue = getRecordValue(record, currentValue);
|
459
|
+
const updatedFieldValue = getRecordValue(updatedFields, currentValue);
|
460
|
+
accumulator[currentIndex] = updatedFieldValue !== undefined ? updatedFieldValue : recordValue;
|
461
|
+
return accumulator;
|
462
|
+
}, {});
|
463
|
+
const requestBody = {
|
464
|
+
serviceName,
|
465
|
+
requestBody: {
|
466
|
+
dataSetID: dataUnit.dataUnitId,
|
467
|
+
entityName,
|
468
|
+
standAlone: false,
|
469
|
+
metadataName,
|
470
|
+
fieldName,
|
471
|
+
fields,
|
472
|
+
record: {
|
473
|
+
pk,
|
474
|
+
oldPk: pk,
|
475
|
+
values,
|
476
|
+
},
|
477
|
+
}
|
478
|
+
};
|
479
|
+
const parsedRequestBody = JSON.stringify(requestBody);
|
480
|
+
return parsedRequestBody;
|
481
|
+
}
|
586
482
|
getFieldsList(dataUnit) {
|
587
483
|
let fields = ["__record__id__", "__record__label__"];
|
588
484
|
dataUnit.metadata.fields.forEach((descriptor) => {
|
@@ -662,9 +558,11 @@ class DatasetStrategy {
|
|
662
558
|
}
|
663
559
|
processRecords(dataUnit, fields, responseRecords) {
|
664
560
|
return responseRecords.map((dataFrame) => {
|
561
|
+
const lastElement = dataFrame[dataFrame.length - 1];
|
665
562
|
const duRecord = {
|
666
563
|
__record__id__: dataFrame[0],
|
667
|
-
__record__label__: dataFrame[1]
|
564
|
+
__record__label__: dataFrame[1],
|
565
|
+
__record__metadata__: lastElement['_rmd'],
|
668
566
|
};
|
669
567
|
dataUnit.metadata.fields.forEach(fieldDescriptor => {
|
670
568
|
duRecord[fieldDescriptor.name] = this.buildFieldValue(fieldDescriptor, fields, dataFrame);
|
@@ -727,6 +625,9 @@ class DataUnitDataLoader {
|
|
727
625
|
});
|
728
626
|
});
|
729
627
|
}
|
628
|
+
static getCachedRecords(dataUnit) {
|
629
|
+
return PreloadManager.getCachedRecords(dataUnit);
|
630
|
+
}
|
730
631
|
static async loadFromServer(dataUnit, request, loadingInfo) {
|
731
632
|
try {
|
732
633
|
//Registramos a request com as informações de carga para determinarmos a última.
|
@@ -927,6 +828,7 @@ class DataUnitFetcher {
|
|
927
828
|
dataUnit.saveLoader = (_dataUnit, changes) => this.saveData(dataUnit, changes);
|
928
829
|
dataUnit.removeLoader = (dataUnit, recordIds) => this.removeRecords(dataUnit, recordIds);
|
929
830
|
dataUnit.recordLoader = (dataUnit, recordIds) => this.loadRecord(dataUnit, recordIds);
|
831
|
+
dataUnit.allRecordsLoader = (dataUnit) => DataUnitDataLoader.getCachedRecords(dataUnit);
|
930
832
|
return dataUnit;
|
931
833
|
}
|
932
834
|
loadMetadata(dataUnit) {
|
@@ -1145,4 +1047,4 @@ class DataUnitFetcher {
|
|
1145
1047
|
}
|
1146
1048
|
}
|
1147
1049
|
|
1148
|
-
export { DataUnitFetcher as D, InMemoryLoader as I,
|
1050
|
+
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 };
|