@sankhyalabs/core 1.0.21 → 1.0.24
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/dataunit/DataUnit.d.ts +70 -0
- package/dist/dataunit/DataUnit.js +198 -0
- package/dist/dataunit/DataUnit.js.map +1 -0
- package/dist/dataunit/metadata/DataType.d.ts +9 -0
- package/dist/dataunit/metadata/DataType.js +37 -0
- package/dist/dataunit/metadata/DataType.js.map +1 -0
- package/dist/dataunit/metadata/UnitMetadata.d.ts +70 -0
- package/dist/dataunit/metadata/UnitMetadata.js +31 -0
- package/dist/dataunit/metadata/UnitMetadata.js.map +1 -0
- package/dist/dataunit/state/HistReducer.d.ts +10 -0
- package/dist/dataunit/state/HistReducer.js +28 -0
- package/dist/dataunit/state/HistReducer.js.map +1 -0
- package/dist/dataunit/state/StateManager.d.ts +57 -0
- package/dist/dataunit/state/StateManager.js +109 -0
- package/dist/dataunit/state/StateManager.js.map +1 -0
- package/dist/dataunit/state/action/DataUnitAction.d.ts +26 -0
- package/dist/dataunit/state/action/DataUnitAction.js +32 -0
- package/dist/dataunit/state/action/DataUnitAction.js.map +1 -0
- package/dist/dataunit/state/slice/AddedRecordsSlice.d.ts +10 -0
- package/dist/dataunit/state/slice/AddedRecordsSlice.js +25 -0
- package/dist/dataunit/state/slice/AddedRecordsSlice.js.map +1 -0
- package/dist/dataunit/state/slice/ChangesSlice.d.ts +12 -0
- package/dist/dataunit/state/slice/ChangesSlice.js +73 -0
- package/dist/dataunit/state/slice/ChangesSlice.js.map +1 -0
- package/dist/dataunit/state/slice/CurrentRecordsSlice.d.ts +11 -0
- package/dist/dataunit/state/slice/CurrentRecordsSlice.js +46 -0
- package/dist/dataunit/state/slice/CurrentRecordsSlice.js.map +1 -0
- package/dist/dataunit/state/slice/RecordsSlice.d.ts +10 -0
- package/dist/dataunit/state/slice/RecordsSlice.js +38 -0
- package/dist/dataunit/state/slice/RecordsSlice.js.map +1 -0
- package/dist/dataunit/state/slice/RemovedRecordsSlice.d.ts +9 -0
- package/dist/dataunit/state/slice/RemovedRecordsSlice.js +21 -0
- package/dist/dataunit/state/slice/RemovedRecordsSlice.js.map +1 -0
- package/dist/dataunit/state/slice/SelectionSlice.d.ts +11 -0
- package/dist/dataunit/state/slice/SelectionSlice.js +109 -0
- package/dist/dataunit/state/slice/SelectionSlice.js.map +1 -0
- package/dist/dataunit/state/slice/UnitMetadataSlice.d.ts +11 -0
- package/dist/dataunit/state/slice/UnitMetadataSlice.js +21 -0
- package/dist/dataunit/state/slice/UnitMetadataSlice.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/ui/FloatingManager.js +23 -7
- package/dist/ui/FloatingManager.js.map +1 -1
- package/package.json +1 -1
- package/src/dataunit/DataUnit.ts +283 -0
- package/src/dataunit/metadata/DataType.ts +38 -0
- package/src/dataunit/metadata/UnitMetadata.ts +81 -0
- package/src/dataunit/state/HistReducer.ts +34 -0
- package/src/dataunit/state/StateManager.ts +153 -0
- package/src/dataunit/state/action/DataUnitAction.ts +48 -0
- package/src/dataunit/state/slice/AddedRecordsSlice.ts +31 -0
- package/src/dataunit/state/slice/ChangesSlice.ts +91 -0
- package/src/dataunit/state/slice/CurrentRecordsSlice.ts +54 -0
- package/src/dataunit/state/slice/RecordsSlice.ts +50 -0
- package/src/dataunit/state/slice/RemovedRecordsSlice.ts +26 -0
- package/src/dataunit/state/slice/SelectionSlice.ts +128 -0
- package/src/dataunit/state/slice/UnitMetadataSlice.ts +30 -0
- package/src/index.ts +13 -1
- package/src/ui/FloatingManager.ts +28 -9
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { StateAction } from "../StateManager";
|
|
2
|
+
export declare class DataUnitAction implements StateAction {
|
|
3
|
+
private _type;
|
|
4
|
+
private _payload;
|
|
5
|
+
constructor(type: Action, payload?: any);
|
|
6
|
+
get type(): Action;
|
|
7
|
+
get payload(): any;
|
|
8
|
+
}
|
|
9
|
+
export declare enum Action {
|
|
10
|
+
LOADING_METADATA = "loadingMetadata",
|
|
11
|
+
METADATA_LOADED = "metadataLoaded",
|
|
12
|
+
LOADING_DATA = "loadingData",
|
|
13
|
+
DATA_LOADED = "dataLoaded",
|
|
14
|
+
SAVING_DATA = "savingData",
|
|
15
|
+
DATA_SAVED = "dataSaved",
|
|
16
|
+
RECORDS_REMOVED = "recordsRemoved",
|
|
17
|
+
RECORDS_ADDED = "recordsAdded",
|
|
18
|
+
DATA_CHANGED = "dataChanged",
|
|
19
|
+
EDITION_CANCELED = "editionCanceled",
|
|
20
|
+
CHANGE_UNDONE = "changeUndone",
|
|
21
|
+
CHANGE_REDONE = "changeRedone",
|
|
22
|
+
SELECTION_CHANGED = "selectionChanged",
|
|
23
|
+
NEXT_SELECTED = "nextSelected",
|
|
24
|
+
PREVIOUS_SELECTED = "previousSelected",
|
|
25
|
+
STATE_CHANGED = "stateChanged"
|
|
26
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export class DataUnitAction {
|
|
2
|
+
constructor(type, payload) {
|
|
3
|
+
this._type = type;
|
|
4
|
+
this._payload = payload;
|
|
5
|
+
}
|
|
6
|
+
get type() {
|
|
7
|
+
return this._type;
|
|
8
|
+
}
|
|
9
|
+
get payload() {
|
|
10
|
+
return this._payload;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export var Action;
|
|
14
|
+
(function (Action) {
|
|
15
|
+
Action["LOADING_METADATA"] = "loadingMetadata";
|
|
16
|
+
Action["METADATA_LOADED"] = "metadataLoaded";
|
|
17
|
+
Action["LOADING_DATA"] = "loadingData";
|
|
18
|
+
Action["DATA_LOADED"] = "dataLoaded";
|
|
19
|
+
Action["SAVING_DATA"] = "savingData";
|
|
20
|
+
Action["DATA_SAVED"] = "dataSaved";
|
|
21
|
+
Action["RECORDS_REMOVED"] = "recordsRemoved";
|
|
22
|
+
Action["RECORDS_ADDED"] = "recordsAdded";
|
|
23
|
+
Action["DATA_CHANGED"] = "dataChanged";
|
|
24
|
+
Action["EDITION_CANCELED"] = "editionCanceled";
|
|
25
|
+
Action["CHANGE_UNDONE"] = "changeUndone";
|
|
26
|
+
Action["CHANGE_REDONE"] = "changeRedone";
|
|
27
|
+
Action["SELECTION_CHANGED"] = "selectionChanged";
|
|
28
|
+
Action["NEXT_SELECTED"] = "nextSelected";
|
|
29
|
+
Action["PREVIOUS_SELECTED"] = "previousSelected";
|
|
30
|
+
Action["STATE_CHANGED"] = "stateChanged";
|
|
31
|
+
})(Action || (Action = {}));
|
|
32
|
+
//# sourceMappingURL=DataUnitAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataUnitAction.js","sourceRoot":"","sources":["../../../../src/dataunit/state/action/DataUnitAction.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,cAAc;IAKvB,YAAY,IAAY,EAAE,OAAY;QAClC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC5B,CAAC;IAED,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;CACJ;AAED,MAAM,CAAN,IAAY,MAyBX;AAzBD,WAAY,MAAM;IAEd,8CAAoC,CAAA;IACpC,4CAAkC,CAAA;IAElC,sCAA4B,CAAA;IAC5B,oCAA0B,CAAA;IAE1B,oCAA0B,CAAA;IAC1B,kCAAwB,CAAA;IAExB,4CAAkC,CAAA;IAClC,wCAA8B,CAAA;IAC9B,sCAA4B,CAAA;IAE5B,8CAAoC,CAAA;IACpC,wCAA8B,CAAA;IAC9B,wCAA8B,CAAA;IAE9B,gDAAsC,CAAA;IACtC,wCAA8B,CAAA;IAC9B,gDAAsC,CAAA;IAEtC,wCAA8B,CAAA;AAElC,CAAC,EAzBW,MAAM,KAAN,MAAM,QAyBjB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ActionReducer, StateAction } from "../StateManager";
|
|
2
|
+
import StateManager from "../StateManager";
|
|
3
|
+
import { Record } from "../../DataUnit";
|
|
4
|
+
declare class AddedRecordsReducerImpl implements ActionReducer {
|
|
5
|
+
sliceName: string;
|
|
6
|
+
reduce(_stateManager: StateManager, currentState: Array<Record>, action: StateAction): Array<Record> | undefined;
|
|
7
|
+
}
|
|
8
|
+
export declare const AddedRecordsReducer: AddedRecordsReducerImpl;
|
|
9
|
+
export declare const getAddedRecords: (stateManager: StateManager) => Array<Record>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Action } from "../action/DataUnitAction";
|
|
2
|
+
class AddedRecordsReducerImpl {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.sliceName = "hist::addedRecords";
|
|
5
|
+
}
|
|
6
|
+
reduce(_stateManager, currentState, action) {
|
|
7
|
+
switch (action.type) {
|
|
8
|
+
case Action.RECORDS_ADDED:
|
|
9
|
+
const newState = currentState ? currentState.slice() : [];
|
|
10
|
+
action.payload.forEach((r) => {
|
|
11
|
+
newState.push(Object.assign({ __record__id__: "NEW_" + (newState.length + 1) }, r));
|
|
12
|
+
});
|
|
13
|
+
return newState;
|
|
14
|
+
case Action.DATA_SAVED:
|
|
15
|
+
case Action.EDITION_CANCELED:
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
return currentState;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export const AddedRecordsReducer = new AddedRecordsReducerImpl();
|
|
22
|
+
export const getAddedRecords = (stateManager) => {
|
|
23
|
+
return stateManager.select(AddedRecordsReducer.sliceName, (state) => state);
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=AddedRecordsSlice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AddedRecordsSlice.js","sourceRoot":"","sources":["../../../../src/dataunit/state/slice/AddedRecordsSlice.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAIlD,MAAM,uBAAuB;IAA7B;QAEW,cAAS,GAAW,oBAAoB,CAAC;IAgBpD,CAAC;IAdU,MAAM,CAAC,aAA0B,EAAE,YAA2B,EAAE,MAAmB;QACtF,QAAO,MAAM,CAAC,IAAI,EAAC;YACf,KAAK,MAAM,CAAC,aAAa;gBACrB,MAAM,QAAQ,GAAkB,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACzE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAM,EAAE,EAAE;oBAC9B,QAAQ,CAAC,IAAI,iBAAE,cAAc,EAAE,MAAM,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,IAAK,CAAC,EAAE,CAAC;gBAC1E,CAAC,CAAC,CAAC;gBACH,OAAO,QAAQ,CAAC;YACpB,KAAK,MAAM,CAAC,UAAU,CAAC;YACvB,KAAK,MAAM,CAAC,gBAAgB;gBACxB,OAAO,SAAS,CAAC;SACxB;QACD,OAAO,YAAY,CAAC;IACxB,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,uBAAuB,EAAE,CAAC;AAEjE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,YAA0B,EAAiB,EAAE;IACzE,OAAO,YAAY,CAAC,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,CAAC,KAAoB,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;AAC/F,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ActionReducer, StateAction } from "../StateManager";
|
|
2
|
+
import StateManager from "../StateManager";
|
|
3
|
+
import { Change } from "../../DataUnit";
|
|
4
|
+
declare class ChangesReducerImpl implements ActionReducer {
|
|
5
|
+
sliceName: string;
|
|
6
|
+
reduce(stateManager: StateManager, currentState: Map<string, any>, action: StateAction): Map<string, any> | undefined;
|
|
7
|
+
}
|
|
8
|
+
export declare const ChangesReducer: ChangesReducerImpl;
|
|
9
|
+
export declare const getChanges: (stateManager: StateManager) => Map<string, any>;
|
|
10
|
+
export declare const isDirty: (stateManager: StateManager) => boolean;
|
|
11
|
+
export declare const getChangesToSave: (dataUnit: string, stateManager: StateManager) => Array<Change>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Action } from "../action/DataUnitAction";
|
|
2
|
+
import { getSelection } from "./SelectionSlice";
|
|
3
|
+
import { getRecords } from "./RecordsSlice";
|
|
4
|
+
import { getRemovedRecords } from "./RemovedRecordsSlice";
|
|
5
|
+
import { getAddedRecords } from "./AddedRecordsSlice";
|
|
6
|
+
import { Change, ChangeOperation } from "../../DataUnit";
|
|
7
|
+
class ChangesReducerImpl {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.sliceName = "hist::changes";
|
|
10
|
+
}
|
|
11
|
+
reduce(stateManager, currentState, action) {
|
|
12
|
+
switch (action.type) {
|
|
13
|
+
case Action.DATA_CHANGED:
|
|
14
|
+
const selection = action.payload.records || getSelection(stateManager);
|
|
15
|
+
if (selection) {
|
|
16
|
+
const newState = new Map(currentState);
|
|
17
|
+
selection.forEach(recordId => {
|
|
18
|
+
newState.set(recordId, Object.assign(Object.assign({}, newState.get(recordId)), action.payload));
|
|
19
|
+
});
|
|
20
|
+
return newState;
|
|
21
|
+
}
|
|
22
|
+
return currentState;
|
|
23
|
+
case Action.DATA_SAVED:
|
|
24
|
+
case Action.EDITION_CANCELED:
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
return currentState;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export const ChangesReducer = new ChangesReducerImpl();
|
|
31
|
+
export const getChanges = (stateManager) => {
|
|
32
|
+
return stateManager.select(ChangesReducer.sliceName, (state) => state);
|
|
33
|
+
};
|
|
34
|
+
export const isDirty = (stateManager) => {
|
|
35
|
+
if (getAddedRecords(stateManager) !== undefined) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
if (getRemovedRecords(stateManager) !== undefined) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
return getChanges(stateManager) !== undefined;
|
|
42
|
+
};
|
|
43
|
+
export const getChangesToSave = (dataUnit, stateManager) => {
|
|
44
|
+
const result = [];
|
|
45
|
+
const changes = getChanges(stateManager);
|
|
46
|
+
const records = getRecords(stateManager);
|
|
47
|
+
if (records) {
|
|
48
|
+
records.forEach(r => {
|
|
49
|
+
if (changes) {
|
|
50
|
+
const c = changes.get(r.__record__id__);
|
|
51
|
+
if (c) {
|
|
52
|
+
result.push(new Change(dataUnit, r, c, ChangeOperation.UPDATE));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
const addedRecords = getAddedRecords(stateManager);
|
|
58
|
+
if (addedRecords) {
|
|
59
|
+
addedRecords.forEach(r => {
|
|
60
|
+
result.push(new Change(dataUnit, r, changes === null || changes === void 0 ? void 0 : changes.get(r.__record__id__), ChangeOperation.INSERT));
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
const removedRecords = getRemovedRecords(stateManager);
|
|
64
|
+
const recordsById = {};
|
|
65
|
+
records.forEach(r => recordsById[r.__record__id__] = r);
|
|
66
|
+
if (removedRecords) {
|
|
67
|
+
removedRecords.forEach(id => {
|
|
68
|
+
result.push(new Change(dataUnit, recordsById[id], undefined, ChangeOperation.DELETE));
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return result;
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=ChangesSlice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChangesSlice.js","sourceRoot":"","sources":["../../../../src/dataunit/state/slice/ChangesSlice.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM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C,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;QACjG,CAAC,CAAC,CAAC;KACN;IAED,MAAM,cAAc,GAAG,iBAAiB,CAAC,YAAY,CAAC,CAAC;IACvD,MAAM,WAAW,GAAQ,EAAE,CAAC;IAC5B,OAAO,CAAC,OAAO,CAAC,CAAC,CAAA,EAAE,CAAA,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;IACtD,IAAI,cAAc,EAAE;QAChB,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;YACxB,MAAM,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;QAC1F,CAAC,CAAC,CAAC;KACN;IAED,OAAO,MAAM,CAAC;AAClB,CAAC,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ActionReducer, StateAction } from "../StateManager";
|
|
2
|
+
import StateManager from "../StateManager";
|
|
3
|
+
import { Record } from "../../DataUnit";
|
|
4
|
+
declare class CurrentRecordsReducerImpl implements ActionReducer {
|
|
5
|
+
sliceName: string;
|
|
6
|
+
reduce(stateManager: StateManager, _currentState: Map<string, Record>, _action: StateAction): Map<string, Record> | undefined;
|
|
7
|
+
}
|
|
8
|
+
export declare const CurrentRecordsReducer: CurrentRecordsReducerImpl;
|
|
9
|
+
export declare const getCurrentRecords: (stateManager: StateManager) => Map<string, Record>;
|
|
10
|
+
export declare const getFieldValue: (stateManager: StateManager, fieldName: string) => any;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { getRecords } from "./RecordsSlice";
|
|
2
|
+
import { getSelection } from "./SelectionSlice";
|
|
3
|
+
import { getChanges } from "./ChangesSlice";
|
|
4
|
+
import { getRemovedRecords } from "./RemovedRecordsSlice";
|
|
5
|
+
import { getAddedRecords } from "./AddedRecordsSlice";
|
|
6
|
+
class CurrentRecordsReducerImpl {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.sliceName = "currentRecords";
|
|
9
|
+
}
|
|
10
|
+
reduce(stateManager, _currentState, _action) {
|
|
11
|
+
let records = getRecords(stateManager);
|
|
12
|
+
const added = getAddedRecords(stateManager);
|
|
13
|
+
if (!records && !added) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
if (added) {
|
|
17
|
+
records = (records || []).concat(added);
|
|
18
|
+
}
|
|
19
|
+
const removedRecords = getRemovedRecords(stateManager);
|
|
20
|
+
if (removedRecords) {
|
|
21
|
+
records = records.filter(r => !removedRecords.includes(r.__record__id__));
|
|
22
|
+
}
|
|
23
|
+
const changes = getChanges(stateManager);
|
|
24
|
+
return new Map(records.map(r => {
|
|
25
|
+
const recordId = r.__record__id__;
|
|
26
|
+
const record = Object.assign(Object.assign({}, r), changes === null || changes === void 0 ? void 0 : changes.get(recordId));
|
|
27
|
+
return [recordId, record];
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export const CurrentRecordsReducer = new CurrentRecordsReducerImpl();
|
|
32
|
+
export const getCurrentRecords = (stateManager) => {
|
|
33
|
+
return stateManager.select(CurrentRecordsReducer.sliceName, (state) => state);
|
|
34
|
+
};
|
|
35
|
+
export const getFieldValue = (stateManager, fieldName) => {
|
|
36
|
+
const selection = getSelection(stateManager);
|
|
37
|
+
if (selection && selection.length > 0) {
|
|
38
|
+
const currentRecords = getCurrentRecords(stateManager);
|
|
39
|
+
if (currentRecords) {
|
|
40
|
+
const record = currentRecords.get(selection[0]);
|
|
41
|
+
return record ? record[fieldName] : undefined;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=CurrentRecordsSlice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CurrentRecordsSlice.js","sourceRoot":"","sources":["../../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AAC,CAAC;YACjD,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC9B,CAAC,CAAC,CAAC,CAAC;IACR,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,yBAAyB,EAAE,CAAC;AAErE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,YAA0B,EAAuB,EAAE;IACjF,OAAO,YAAY,CAAC,MAAM,CAAC,qBAAqB,CAAC,SAAS,EAAE,CAAC,KAA0B,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;AACvG,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,YAA0B,EAAE,SAAiB,EAAO,EAAE;IAChF,MAAM,SAAS,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;IAC7C,IAAG,SAAS,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAC;QACjC,MAAM,cAAc,GAAG,iBAAiB,CAAC,YAAY,CAAC,CAAC;QACvD,IAAG,cAAc,EAAC;YACd,MAAM,MAAM,GAAG,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;YAChD,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;SACjD;KACJ;IACD,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ActionReducer, StateAction } from "../StateManager";
|
|
2
|
+
import StateManager from "../StateManager";
|
|
3
|
+
import { Record } from "../../DataUnit";
|
|
4
|
+
declare class RecordsReducerImpl implements ActionReducer {
|
|
5
|
+
sliceName: string;
|
|
6
|
+
reduce(stateManager: StateManager, currentState: Array<Record>, action: StateAction): Array<Record>;
|
|
7
|
+
}
|
|
8
|
+
export declare const RecordsReducer: RecordsReducerImpl;
|
|
9
|
+
export declare const getRecords: (stateManager: StateManager) => Array<Record>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Action } from "../action/DataUnitAction";
|
|
2
|
+
import { getRemovedRecords } from "./RemovedRecordsSlice";
|
|
3
|
+
class RecordsReducerImpl {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.sliceName = "records";
|
|
6
|
+
}
|
|
7
|
+
reduce(stateManager, currentState, action) {
|
|
8
|
+
switch (action.type) {
|
|
9
|
+
case Action.DATA_LOADED:
|
|
10
|
+
return action.payload;
|
|
11
|
+
case Action.DATA_SAVED:
|
|
12
|
+
const recordsMap = new Map();
|
|
13
|
+
const currentRecords = getRecords(stateManager);
|
|
14
|
+
if (currentRecords) {
|
|
15
|
+
const removed = getRemovedRecords(stateManager) || [];
|
|
16
|
+
currentRecords.forEach(r => {
|
|
17
|
+
if (!removed.includes(r.__record__id__)) {
|
|
18
|
+
recordsMap.set(r.__record__id__, r);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
const savedRecords = action.payload.records;
|
|
23
|
+
savedRecords.forEach(sr => {
|
|
24
|
+
const recordId = sr.__old__id__ || sr.__record__id__;
|
|
25
|
+
const newRecord = Object.assign({}, sr);
|
|
26
|
+
delete newRecord["__old__id__"];
|
|
27
|
+
recordsMap.set(recordId, newRecord);
|
|
28
|
+
});
|
|
29
|
+
return Array.from(recordsMap.values());
|
|
30
|
+
}
|
|
31
|
+
return currentState;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export const RecordsReducer = new RecordsReducerImpl();
|
|
35
|
+
export const getRecords = (stateManager) => {
|
|
36
|
+
return stateManager.select(RecordsReducer.sliceName, (state) => state);
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=RecordsSlice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RecordsSlice.js","sourceRoot":"","sources":["../../../../src/dataunit/state/slice/RecordsSlice.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,0B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IACxB,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,kBAAkB,EAAE,CAAC;AAEvD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,YAA0B,EAAiB,EAAE;IACpE,OAAO,YAAY,CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC,KAAoB,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;AAC1F,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ActionReducer, StateAction } from "../StateManager";
|
|
2
|
+
import StateManager from "../StateManager";
|
|
3
|
+
declare class RemovedRecordsReducerImpl implements ActionReducer {
|
|
4
|
+
sliceName: string;
|
|
5
|
+
reduce(_stateManager: StateManager, currentState: Array<string>, action: StateAction): Array<string> | undefined;
|
|
6
|
+
}
|
|
7
|
+
export declare const RemovedRecordsReducer: RemovedRecordsReducerImpl;
|
|
8
|
+
export declare const getRemovedRecords: (stateManager: StateManager) => Array<string>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Action } from "../action/DataUnitAction";
|
|
2
|
+
class RemovedRecordsReducerImpl {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.sliceName = "hist::removedRecords";
|
|
5
|
+
}
|
|
6
|
+
reduce(_stateManager, currentState, action) {
|
|
7
|
+
switch (action.type) {
|
|
8
|
+
case Action.RECORDS_REMOVED:
|
|
9
|
+
return (currentState || []).concat(action.payload);
|
|
10
|
+
case Action.EDITION_CANCELED:
|
|
11
|
+
case Action.DATA_SAVED:
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
return currentState;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export const RemovedRecordsReducer = new RemovedRecordsReducerImpl();
|
|
18
|
+
export const getRemovedRecords = (stateManager) => {
|
|
19
|
+
return stateManager.select(RemovedRecordsReducer.sliceName, (state) => state);
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=RemovedRecordsSlice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RemovedRecordsSlice.js","sourceRoot":"","sources":["../../../../src/dataunit/state/slice/RemovedRecordsSlice.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAGlD,MAAM,yBAAyB;IAA/B;QAEW,cAAS,GAAW,sBAAsB,CAAC;IAYtD,CAAC;IAVU,MAAM,CAAC,aAA0B,EAAE,YAA2B,EAAE,MAAmB;QACtF,QAAO,MAAM,CAAC,IAAI,EAAC;YACf,KAAK,MAAM,CAAC,eAAe;gBACvB,OAAO,CAAC,YAAY,IAAE,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACrD,KAAK,MAAM,CAAC,gBAAgB,CAAC;YAC7B,KAAK,MAAM,CAAC,UAAU;gBAClB,OAAO,SAAS,CAAC;SACxB;QACD,OAAO,YAAY,CAAC;IACxB,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,yBAAyB,EAAE,CAAC;AAErE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,YAA0B,EAAiB,EAAE;IAC3E,OAAO,YAAY,CAAC,MAAM,CAAC,qBAAqB,CAAC,SAAS,EAAE,CAAC,KAAoB,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;AACjG,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ActionReducer, StateAction } from "../StateManager";
|
|
2
|
+
import StateManager from "../StateManager";
|
|
3
|
+
declare class SelectionReducerImpl implements ActionReducer {
|
|
4
|
+
sliceName: string;
|
|
5
|
+
reduce(stateManager: StateManager, currentState: Array<string>, action: StateAction): Array<string> | undefined;
|
|
6
|
+
}
|
|
7
|
+
export declare const SelectionReducer: SelectionReducerImpl;
|
|
8
|
+
export declare const getSelection: (stateManager: StateManager) => Array<string>;
|
|
9
|
+
export declare const hasNext: (stateManager: StateManager) => boolean;
|
|
10
|
+
export declare const hasPrevious: (stateManager: StateManager) => boolean;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Action } from "../action/DataUnitAction";
|
|
2
|
+
import { getCurrentRecords } from "./CurrentRecordsSlice";
|
|
3
|
+
class SelectionReducerImpl {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.sliceName = "hist::selection";
|
|
6
|
+
}
|
|
7
|
+
reduce(stateManager, currentState, action) {
|
|
8
|
+
switch (action.type) {
|
|
9
|
+
case Action.DATA_SAVED:
|
|
10
|
+
return updateSavedIds(stateManager, action.payload.records);
|
|
11
|
+
case Action.RECORDS_REMOVED:
|
|
12
|
+
const removed = action.payload;
|
|
13
|
+
if (currentState && removed) {
|
|
14
|
+
return currentState.filter(recordId => !removed.includes(recordId));
|
|
15
|
+
}
|
|
16
|
+
return currentState;
|
|
17
|
+
case Action.NEXT_SELECTED:
|
|
18
|
+
case Action.PREVIOUS_SELECTED:
|
|
19
|
+
const currentRecords = getCurrentRecords(stateManager);
|
|
20
|
+
if (currentRecords && currentRecords.size > 0) {
|
|
21
|
+
let index;
|
|
22
|
+
if (!currentState || currentState.length === 0) {
|
|
23
|
+
index = action.type === Action.PREVIOUS_SELECTED ? 0 : Math.min(1, currentRecords.size);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
index = getItemIndex(currentState[0], currentRecords) + (action.type === Action.PREVIOUS_SELECTED ? -1 : 1);
|
|
27
|
+
}
|
|
28
|
+
if (index < currentRecords.size && index >= 0) {
|
|
29
|
+
return [Array.from(currentRecords.values())[index].__record__id__];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return undefined;
|
|
33
|
+
case Action.SELECTION_CHANGED:
|
|
34
|
+
const { type, selection: selectionSource } = action.payload;
|
|
35
|
+
if (selectionSource && type === "index") {
|
|
36
|
+
const currentRecords = getCurrentRecords(stateManager);
|
|
37
|
+
if (currentRecords) {
|
|
38
|
+
const records = Array.from(currentRecords.values());
|
|
39
|
+
const selectionById = [];
|
|
40
|
+
selectionSource.forEach((i) => {
|
|
41
|
+
if (i > 0 && i < currentRecords.size) {
|
|
42
|
+
selectionById.push(records[i].__record__id__);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
return selectionById;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return selectionSource;
|
|
49
|
+
}
|
|
50
|
+
return currentState;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export const SelectionReducer = new SelectionReducerImpl();
|
|
54
|
+
export const getSelection = (stateManager) => {
|
|
55
|
+
let selection = stateManager.select(SelectionReducer.sliceName, (state) => state);
|
|
56
|
+
const currentRecords = Array.from((getCurrentRecords(stateManager) || new Map()).keys());
|
|
57
|
+
if (selection) {
|
|
58
|
+
selection = selection.filter(id => currentRecords.includes(id));
|
|
59
|
+
}
|
|
60
|
+
if (!selection || selection.length === 0) {
|
|
61
|
+
if (currentRecords && currentRecords.length > 0) {
|
|
62
|
+
return [currentRecords[0]];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return selection;
|
|
66
|
+
};
|
|
67
|
+
export const hasNext = (stateManager) => {
|
|
68
|
+
const records = getCurrentRecords(stateManager);
|
|
69
|
+
if (records) {
|
|
70
|
+
const selection = stateManager.select(SelectionReducer.sliceName, (state) => state);
|
|
71
|
+
if (!selection || selection.length === 0) {
|
|
72
|
+
return records.size > 0;
|
|
73
|
+
}
|
|
74
|
+
return records.size > (getItemIndex(selection[0], records) + 1);
|
|
75
|
+
}
|
|
76
|
+
return false;
|
|
77
|
+
};
|
|
78
|
+
export const hasPrevious = (stateManager) => {
|
|
79
|
+
const records = getCurrentRecords(stateManager);
|
|
80
|
+
if (records) {
|
|
81
|
+
const selection = stateManager.select(SelectionReducer.sliceName, (state) => state);
|
|
82
|
+
if (!selection || selection.length === 0) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
return getItemIndex(selection[0], records) > 0;
|
|
86
|
+
}
|
|
87
|
+
return false;
|
|
88
|
+
};
|
|
89
|
+
function getItemIndex(key, map) {
|
|
90
|
+
return Array.from(map.keys()).indexOf(key);
|
|
91
|
+
}
|
|
92
|
+
function updateSavedIds(stateManager, savedRecords) {
|
|
93
|
+
const currentSelection = getSelection(stateManager);
|
|
94
|
+
if (currentSelection) {
|
|
95
|
+
const newSelection = [];
|
|
96
|
+
currentSelection.forEach(id => {
|
|
97
|
+
const record = savedRecords.find(r => r.__old__id__ === id);
|
|
98
|
+
if (record) {
|
|
99
|
+
newSelection.push(record.__record__id__);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
newSelection.push(id);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
return newSelection;
|
|
106
|
+
}
|
|
107
|
+
return currentSelection;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=SelectionSlice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectionSlice.js","sourceRoot":"","sources":["../../../../src/dataunit/state/slice/SelectionSlice.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG1D,MAAM,oBAAoB;IAA1B;QAEW,cAAS,GAAW,iBAAiB,CAAC;IAuDjD,CAAC;IArDU,MAAM,CAAC,YAA0B,EAAE,YAA2B,EAAE,MAAmB;QAEtF,QAAQ,MAAM,CAAC,IAAI,EAAE;YAEjB,KAAK,MAAM,CAAC,UAAU;gBAClB,OAAO,cAAc,CAAC,YAAY,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAChE,KAAK,MAAM,CAAC,eAAe;gBACvB,MAAM,OAAO,GAAkB,MAAM,CAAC,OAAO,CAAC;gBAC9C,IAAI,YAAY,IAAI,OAAO,EAAE;oBACzB,OAAO,YAAY,CAAC,MAAM,CAAC,QAAQ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CAAC;AAC/C,CAAC;AAED,SAAS,cAAc,CAAC,YAAyB,EAAE,YAA+B;IAC9E,MAAM,gBAAgB,GAAkB,YAAY,CAAC,YAAY,CAAC,CAAC;IACnE,IAAG,gBAAgB,EAAC;QAChB,MAAM,YAAY,GAAkB,EAAE,CAAC;QACvC,gBAAgB,CAAC,OAAO,CAAE,EAAE,CAAC,EAAE;YAC3B,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,KAAK,EAAE,CAAC,CAAC;YAC5D,IAAG,MAAM,EAAC;gBACN,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;aAC5C;iBAAM;gBACH,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;aACzB;QACL,CAAC,CAAC,CAAC;QACH,OAAO,YAAY,CAAC;KACvB;IACD,OAAO,gBAAgB,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ActionReducer, StateAction } from "../StateManager";
|
|
2
|
+
import { UnitMetadata, FieldDescriptor } from "../../metadata/UnitMetadata";
|
|
3
|
+
import StateManager from "../StateManager";
|
|
4
|
+
declare class UnitMetadataReducerImpl implements ActionReducer {
|
|
5
|
+
sliceName: string;
|
|
6
|
+
reduce(_stateManager: StateManager, currentState: UnitMetadata, action: StateAction): UnitMetadata;
|
|
7
|
+
}
|
|
8
|
+
export declare const UnitMetadataReducer: UnitMetadataReducerImpl;
|
|
9
|
+
export declare const getMetadata: (stateManager: StateManager) => UnitMetadata;
|
|
10
|
+
export declare const getField: (stateManager: StateManager, fieldName: string) => FieldDescriptor | undefined;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Action } from "../action/DataUnitAction";
|
|
2
|
+
class UnitMetadataReducerImpl {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.sliceName = "unitMetadata";
|
|
5
|
+
}
|
|
6
|
+
reduce(_stateManager, currentState, action) {
|
|
7
|
+
if (action.type === Action.METADATA_LOADED) {
|
|
8
|
+
return action.payload;
|
|
9
|
+
}
|
|
10
|
+
return currentState;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export const UnitMetadataReducer = new UnitMetadataReducerImpl();
|
|
14
|
+
export const getMetadata = (stateManager) => {
|
|
15
|
+
return stateManager.select(UnitMetadataReducer.sliceName, (state) => state);
|
|
16
|
+
};
|
|
17
|
+
export const getField = (stateManager, fieldName) => {
|
|
18
|
+
const md = getMetadata(stateManager);
|
|
19
|
+
return md ? md.fields.find(fmd => fmd.name === fieldName) : undefined;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=UnitMetadataSlice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UnitMetadataSlice.js","sourceRoot":"","sources":["../../../../src/dataunit/state/slice/UnitMetadataSlice.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAIlD,MAAM,uBAAuB;IAA7B;QAEW,cAAS,GAAW,cAAc,CAAC;IAS9C,CAAC;IAPU,MAAM,CAAC,aAA0B,EAAE,YAA0B,EAAE,MAAmB;QACrF,IAAG,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,eAAe,EAAC;YACtC,OAAO,MAAM,CAAC,OAAO,CAAC;SACzB;QACD,OAAO,YAAY,CAAC;IACxB,CAAC;CAEJ;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,uBAAuB,EAAE,CAAC;AAEjE,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,YAA0B,EAAgB,EAAE;IACpE,OAAO,YAAY,CAAC,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,CAAC,KAAmB,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;AAC9F,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,YAA0B,EAAE,SAAiB,EAA6B,EAAE;IACjG,MAAM,EAAE,GAAiB,WAAW,CAAC,YAAY,CAAC,CAAC;IACnD,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC1E,CAAC,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,4 +8,8 @@ import { HttpProvider } from "./http/HttpProvider";
|
|
|
8
8
|
import { SkwHttpProvider } from "./http/SkwHttpProvider";
|
|
9
9
|
import { RequestMetadata } from "./http/RequestMetadata";
|
|
10
10
|
import { AuthorizedServiceCaller } from "./http/AuthorizedServiceCaller";
|
|
11
|
-
|
|
11
|
+
import DataUnit, { Record } from "./dataunit/DataUnit";
|
|
12
|
+
import { DataType } from "./dataunit/metadata/DataType";
|
|
13
|
+
import { UnitMetadata, FieldDescriptor, UserInterface } from "./dataunit/metadata/UnitMetadata";
|
|
14
|
+
import { DataUnitAction, Action } from "./dataunit/state/action/DataUnitAction";
|
|
15
|
+
export { StringUtils, MaskFormatter, NumberUtils, FloatingManager, DateUtils, TimeFormatter, SkwHttpProvider, HttpProvider, RequestMetadata, AuthorizedServiceCaller, DataUnit, Record, DataType, UnitMetadata, FieldDescriptor, UserInterface, DataUnitAction, Action };
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,10 @@ import { HttpProvider } from "./http/HttpProvider";
|
|
|
8
8
|
import { SkwHttpProvider } from "./http/SkwHttpProvider";
|
|
9
9
|
import { RequestMetadata } from "./http/RequestMetadata";
|
|
10
10
|
import { AuthorizedServiceCaller } from "./http/AuthorizedServiceCaller";
|
|
11
|
+
import DataUnit from "./dataunit/DataUnit";
|
|
12
|
+
import { DataType } from "./dataunit/metadata/DataType";
|
|
13
|
+
import { UserInterface } from "./dataunit/metadata/UnitMetadata";
|
|
14
|
+
import { DataUnitAction, Action } from "./dataunit/state/action/DataUnitAction";
|
|
11
15
|
/*Classes públicas no pacote*/
|
|
12
|
-
export { StringUtils, MaskFormatter, NumberUtils, FloatingManager, DateUtils, TimeFormatter, SkwHttpProvider, HttpProvider, RequestMetadata, AuthorizedServiceCaller };
|
|
16
|
+
export { StringUtils, MaskFormatter, NumberUtils, FloatingManager, DateUtils, TimeFormatter, SkwHttpProvider, HttpProvider, RequestMetadata, AuthorizedServiceCaller, DataUnit, DataType, UserInterface, DataUnitAction, Action };
|
|
13
17
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,eAAe,MAAM,sBAAsB,CAAC;AACnD,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,eAAe,MAAM,sBAAsB,CAAC;AACnD,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,QAAkB,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAiC,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAChG,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,wCAAwC,CAAC;AAEhF,8BAA8B;AAC9B,OAAO,EACH,WAAW,EACX,aAAa,EACb,WAAW,EACX,eAAe,EACf,SAAS,EACT,aAAa,EACb,eAAe,EACf,YAAY,EACZ,eAAe,EACf,uBAAuB,EACvB,QAAQ,EAER,QAAQ,EAGR,aAAa,EACb,cAAc,EACd,MAAM,EACT,CAAC"}
|
|
@@ -1,9 +1,27 @@
|
|
|
1
1
|
class FloatingEntry {
|
|
2
2
|
constructor(parent, content, opts) {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
try {
|
|
4
|
+
this.weakRefParent = new WeakRef(parent);
|
|
5
|
+
this.weakRefContent = new WeakRef(content);
|
|
6
|
+
}
|
|
7
|
+
catch (error) {
|
|
8
|
+
this.strongRefParent = parent;
|
|
9
|
+
this.strongRefContent = content;
|
|
10
|
+
}
|
|
5
11
|
this.options = opts;
|
|
6
12
|
}
|
|
13
|
+
get parent() {
|
|
14
|
+
if (this.weakRefParent) {
|
|
15
|
+
return this.weakRefParent.deref();
|
|
16
|
+
}
|
|
17
|
+
return this.strongRefParent;
|
|
18
|
+
}
|
|
19
|
+
get content() {
|
|
20
|
+
if (this.weakRefContent) {
|
|
21
|
+
return this.weakRefContent.deref();
|
|
22
|
+
}
|
|
23
|
+
return this.strongRefContent;
|
|
24
|
+
}
|
|
7
25
|
}
|
|
8
26
|
export default class FloatingManager {
|
|
9
27
|
static init() {
|
|
@@ -23,8 +41,8 @@ export default class FloatingManager {
|
|
|
23
41
|
}
|
|
24
42
|
static doClose(id, entry, target) {
|
|
25
43
|
if (!target || entry.options.autoClose) {
|
|
26
|
-
const parent =
|
|
27
|
-
const content =
|
|
44
|
+
const parent = entry.parent;
|
|
45
|
+
const content = entry.content;
|
|
28
46
|
if (parent && content) {
|
|
29
47
|
const innerClickFunction = entry.options.innerClickTest ? entry.options.innerClickTest : FloatingManager.innerClick;
|
|
30
48
|
if (!target || !innerClickFunction(content, target)) {
|
|
@@ -61,9 +79,7 @@ export default class FloatingManager {
|
|
|
61
79
|
static getFloatIndex(content, parent) {
|
|
62
80
|
for (let index = 0; index < FloatingManager.entries.length; index++) {
|
|
63
81
|
const entry = FloatingManager.entries[index];
|
|
64
|
-
|
|
65
|
-
const entryContent = (WeakRef === undefined ? entry.content : entry.content.deref());
|
|
66
|
-
if (entry && content === entryContent && parent === entryParent) {
|
|
82
|
+
if (entry && content === entry.content && parent === entry.parent) {
|
|
67
83
|
return index;
|
|
68
84
|
}
|
|
69
85
|
}
|