@claspo/common 7.3.1-dev.4 → 7.4.0-nonlinear
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/{out/document → document}/Document.interface.d.ts +2 -0
- package/document/ViewNavigationGraph.d.ts +42 -0
- package/document/ViewNavigationGraph.js +1 -0
- package/package.json +2 -2
- package/velocity/SysVelocityRenderer.js +1 -0
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sorter.js +0 -196
- package/jest.config.ts +0 -204
- package/out/package.json +0 -50
- package/out/velocity/SysVelocityRenderer.js +0 -1
- package/src/DefaultEventEmitter.test.ts +0 -84
- package/src/DefaultEventEmitter.ts +0 -96
- package/src/HttpAbortableLoader.ts +0 -35
- package/src/InAppLayoutType.ts +0 -6
- package/src/LayoutType.ts +0 -18
- package/src/PrizePool.interface.ts +0 -32
- package/src/RenderMode.ts +0 -10
- package/src/UuidGenerator.ts +0 -16
- package/src/WidgetInitConfig.interface.ts +0 -163
- package/src/WidgetType.ts +0 -18
- package/src/action/type.ts +0 -7
- package/src/async/createAsyncIterator.ts +0 -33
- package/src/async/debounce.ts +0 -28
- package/src/async/timeout.ts +0 -3
- package/src/component-manifest/ComponentManifest.interface.ts +0 -160
- package/src/component-manifest/ContextMenuManifest.interface.ts +0 -52
- package/src/component-manifest/DisplayCondition.interface.ts +0 -65
- package/src/component-manifest/FloatingControlManifest.interface.ts +0 -89
- package/src/component-manifest/PropPathCondition.interface.ts +0 -4
- package/src/component-manifest/PropertyPaneManifest.interface.ts +0 -614
- package/src/converter/time/TimeConverter.spec.ts +0 -11
- package/src/converter/time/TimeUnit.spec.ts +0 -12
- package/src/converter/time/TimeUnit.ts +0 -34
- package/src/converter/time/TimerConverter.ts +0 -29
- package/src/document/ComponentInsertType.ts +0 -6
- package/src/document/Document.interface.ts +0 -625
- package/src/document/DocumentCssVarsReplace.test.ts +0 -2947
- package/src/document/DocumentCssVarsReplace.ts +0 -31
- package/src/document/DocumentUtils.test.ts +0 -595
- package/src/document/DocumentUtils.ts +0 -194
- package/src/document/hidden-fields.interface.ts +0 -54
- package/src/dom/ViewportSize.ts +0 -61
- package/src/dom/copyToClipboard.ts +0 -17
- package/src/dom/getMostNestedNode.ts +0 -9
- package/src/dom/insertHtmlIntoElement.ts +0 -36
- package/src/dom/sanitizeHTML.test.ts +0 -59
- package/src/dom/sanitizeHTML.ts +0 -78
- package/src/element/BaseElementInViewportHandler.ts +0 -41
- package/src/element/CssVarsOperations.ts +0 -37
- package/src/element/ThemeCssVars.ts +0 -28
- package/src/element/recursiveFindParentNodeByAttribute.test.ts +0 -63
- package/src/element/recursiveFindParentNodeByAttribute.ts +0 -25
- package/src/flat.ts +0 -16
- package/src/handler/HandlerTypes.ts +0 -4
- package/src/math/RandomDistributor.test.ts +0 -35
- package/src/math/RandomDistributor.ts +0 -58
- package/src/math/sum.ts +0 -3
- package/src/network/HttpClient.ts +0 -28
- package/src/network/HttpStatus.ts +0 -4
- package/src/object/isDictionary.test.ts +0 -24
- package/src/object/isDictionary.ts +0 -13
- package/src/object/omitKeys.test.ts +0 -19
- package/src/object/omitKeys.ts +0 -20
- package/src/storage/BaseCachingStorage.test.ts +0 -70
- package/src/storage/BaseCachingStorage.ts +0 -37
- package/src/storage/CachingCookieStorage.test.ts +0 -75
- package/src/storage/CachingCookieStorage.ts +0 -36
- package/src/storage/CachingLocalStorage.test.ts +0 -59
- package/src/storage/CachingLocalStorage.ts +0 -34
- package/src/storage/getCookie.test.ts +0 -53
- package/src/storage/getCookie.ts +0 -10
- package/src/storage/setCookie.test.ts +0 -97
- package/src/storage/setCookie.ts +0 -49
- package/src/theme/theme.utils.ts +0 -50
- package/src/url/sanitizeUrl.test.ts +0 -62
- package/src/url/sanitizeUrl.ts +0 -51
- package/src/utils/CaseTransformer.test.ts +0 -16
- package/src/utils/CaseTransformer.ts +0 -10
- package/src/utils/NullishCoalescingOperator.ts +0 -3
- package/src/utils/NumericDecline.ts +0 -25
- package/src/utils/addEventListener.ts +0 -23
- package/src/utils/allSettled.ts +0 -6
- package/src/utils/checkTimeZone.spec.ts +0 -18
- package/src/utils/checkTimeZone.ts +0 -6
- package/src/utils/deviceUtils.ts +0 -12
- package/src/utils/flatMap.test.ts +0 -21
- package/src/utils/flatMap.ts +0 -3
- package/src/utils/fromEntries.ts +0 -6
- package/src/utils/generateRandomNumber.test.ts +0 -23
- package/src/utils/generateRandomNumber.ts +0 -3
- package/src/utils/objectSort.ts +0 -41
- package/src/utils/orientationUtils.ts +0 -18
- package/src/velocity/SysVelocityContext.spec.ts +0 -88
- package/src/velocity/SysVelocityContext.ts +0 -129
- package/src/velocity/SysVelocityRenderer.spec.ts +0 -36
- package/src/velocity/SysVelocityRenderer.ts +0 -11
- package/test/__mocks/jestGlobalMocks.js +0 -1887
- /package/{out/DefaultEventEmitter.d.ts → DefaultEventEmitter.d.ts} +0 -0
- /package/{out/DefaultEventEmitter.js → DefaultEventEmitter.js} +0 -0
- /package/{out/HttpAbortableLoader.d.ts → HttpAbortableLoader.d.ts} +0 -0
- /package/{out/HttpAbortableLoader.js → HttpAbortableLoader.js} +0 -0
- /package/{out/InAppLayoutType.d.ts → InAppLayoutType.d.ts} +0 -0
- /package/{out/InAppLayoutType.js → InAppLayoutType.js} +0 -0
- /package/{out/LayoutType.d.ts → LayoutType.d.ts} +0 -0
- /package/{out/LayoutType.js → LayoutType.js} +0 -0
- /package/{out/PrizePool.interface.d.ts → PrizePool.interface.d.ts} +0 -0
- /package/{out/PrizePool.interface.js → PrizePool.interface.js} +0 -0
- /package/{out/RenderMode.d.ts → RenderMode.d.ts} +0 -0
- /package/{out/RenderMode.js → RenderMode.js} +0 -0
- /package/{out/UuidGenerator.d.ts → UuidGenerator.d.ts} +0 -0
- /package/{out/UuidGenerator.js → UuidGenerator.js} +0 -0
- /package/{out/WidgetInitConfig.interface.d.ts → WidgetInitConfig.interface.d.ts} +0 -0
- /package/{out/WidgetInitConfig.interface.js → WidgetInitConfig.interface.js} +0 -0
- /package/{out/WidgetType.d.ts → WidgetType.d.ts} +0 -0
- /package/{out/WidgetType.js → WidgetType.js} +0 -0
- /package/{out/action → action}/type.d.ts +0 -0
- /package/{out/action → action}/type.js +0 -0
- /package/{out/async → async}/createAsyncIterator.d.ts +0 -0
- /package/{out/async → async}/createAsyncIterator.js +0 -0
- /package/{out/async → async}/debounce.d.ts +0 -0
- /package/{out/async → async}/debounce.js +0 -0
- /package/{out/async → async}/timeout.d.ts +0 -0
- /package/{out/async → async}/timeout.js +0 -0
- /package/{out/component-manifest → component-manifest}/ComponentManifest.interface.d.ts +0 -0
- /package/{out/component-manifest → component-manifest}/ComponentManifest.interface.js +0 -0
- /package/{out/component-manifest → component-manifest}/ContextMenuManifest.interface.d.ts +0 -0
- /package/{out/component-manifest → component-manifest}/ContextMenuManifest.interface.js +0 -0
- /package/{out/component-manifest → component-manifest}/DisplayCondition.interface.d.ts +0 -0
- /package/{out/component-manifest → component-manifest}/DisplayCondition.interface.js +0 -0
- /package/{out/component-manifest → component-manifest}/FloatingControlManifest.interface.d.ts +0 -0
- /package/{out/component-manifest → component-manifest}/FloatingControlManifest.interface.js +0 -0
- /package/{out/component-manifest → component-manifest}/PropPathCondition.interface.d.ts +0 -0
- /package/{out/component-manifest → component-manifest}/PropPathCondition.interface.js +0 -0
- /package/{out/component-manifest → component-manifest}/PropertyPaneManifest.interface.d.ts +0 -0
- /package/{out/component-manifest → component-manifest}/PropertyPaneManifest.interface.js +0 -0
- /package/{out/converter → converter}/time/TimeUnit.d.ts +0 -0
- /package/{out/converter → converter}/time/TimeUnit.js +0 -0
- /package/{out/converter → converter}/time/TimerConverter.d.ts +0 -0
- /package/{out/converter → converter}/time/TimerConverter.js +0 -0
- /package/{out/document → document}/ComponentInsertType.d.ts +0 -0
- /package/{out/document → document}/ComponentInsertType.js +0 -0
- /package/{out/document → document}/Document.interface.js +0 -0
- /package/{out/document → document}/DocumentCssVarsReplace.d.ts +0 -0
- /package/{out/document → document}/DocumentCssVarsReplace.js +0 -0
- /package/{out/document → document}/DocumentUtils.d.ts +0 -0
- /package/{out/document → document}/DocumentUtils.js +0 -0
- /package/{out/document → document}/hidden-fields.interface.d.ts +0 -0
- /package/{out/document → document}/hidden-fields.interface.js +0 -0
- /package/{out/dom → dom}/ViewportSize.d.ts +0 -0
- /package/{out/dom → dom}/ViewportSize.js +0 -0
- /package/{out/dom → dom}/copyToClipboard.d.ts +0 -0
- /package/{out/dom → dom}/copyToClipboard.js +0 -0
- /package/{out/dom → dom}/getMostNestedNode.d.ts +0 -0
- /package/{out/dom → dom}/getMostNestedNode.js +0 -0
- /package/{out/dom → dom}/insertHtmlIntoElement.d.ts +0 -0
- /package/{out/dom → dom}/insertHtmlIntoElement.js +0 -0
- /package/{out/dom → dom}/sanitizeHTML.d.ts +0 -0
- /package/{out/dom → dom}/sanitizeHTML.js +0 -0
- /package/{out/element → element}/BaseElementInViewportHandler.d.ts +0 -0
- /package/{out/element → element}/BaseElementInViewportHandler.js +0 -0
- /package/{out/element → element}/CssVarsOperations.d.ts +0 -0
- /package/{out/element → element}/CssVarsOperations.js +0 -0
- /package/{out/element → element}/ThemeCssVars.d.ts +0 -0
- /package/{out/element → element}/ThemeCssVars.js +0 -0
- /package/{out/element → element}/recursiveFindParentNodeByAttribute.d.ts +0 -0
- /package/{out/element → element}/recursiveFindParentNodeByAttribute.js +0 -0
- /package/{out/flat.d.ts → flat.d.ts} +0 -0
- /package/{out/flat.js → flat.js} +0 -0
- /package/{out/handler → handler}/HandlerTypes.d.ts +0 -0
- /package/{out/handler → handler}/HandlerTypes.js +0 -0
- /package/{out/math → math}/RandomDistributor.d.ts +0 -0
- /package/{out/math → math}/RandomDistributor.js +0 -0
- /package/{out/math → math}/sum.d.ts +0 -0
- /package/{out/math → math}/sum.js +0 -0
- /package/{out/network → network}/HttpClient.d.ts +0 -0
- /package/{out/network → network}/HttpClient.js +0 -0
- /package/{out/network → network}/HttpStatus.d.ts +0 -0
- /package/{out/network → network}/HttpStatus.js +0 -0
- /package/{out/object → object}/isDictionary.d.ts +0 -0
- /package/{out/object → object}/isDictionary.js +0 -0
- /package/{out/object → object}/omitKeys.d.ts +0 -0
- /package/{out/object → object}/omitKeys.js +0 -0
- /package/{out/storage → storage}/BaseCachingStorage.d.ts +0 -0
- /package/{out/storage → storage}/BaseCachingStorage.js +0 -0
- /package/{out/storage → storage}/CachingCookieStorage.d.ts +0 -0
- /package/{out/storage → storage}/CachingCookieStorage.js +0 -0
- /package/{out/storage → storage}/CachingLocalStorage.d.ts +0 -0
- /package/{out/storage → storage}/CachingLocalStorage.js +0 -0
- /package/{out/storage → storage}/getCookie.d.ts +0 -0
- /package/{out/storage → storage}/getCookie.js +0 -0
- /package/{out/storage → storage}/setCookie.d.ts +0 -0
- /package/{out/storage → storage}/setCookie.js +0 -0
- /package/{out/theme → theme}/theme.utils.d.ts +0 -0
- /package/{out/theme → theme}/theme.utils.js +0 -0
- /package/{out/url → url}/sanitizeUrl.d.ts +0 -0
- /package/{out/url → url}/sanitizeUrl.js +0 -0
- /package/{out/utils → utils}/CaseTransformer.d.ts +0 -0
- /package/{out/utils → utils}/CaseTransformer.js +0 -0
- /package/{out/utils → utils}/NullishCoalescingOperator.d.ts +0 -0
- /package/{out/utils → utils}/NullishCoalescingOperator.js +0 -0
- /package/{out/utils → utils}/NumericDecline.d.ts +0 -0
- /package/{out/utils → utils}/NumericDecline.js +0 -0
- /package/{out/utils → utils}/addEventListener.d.ts +0 -0
- /package/{out/utils → utils}/addEventListener.js +0 -0
- /package/{out/utils → utils}/allSettled.d.ts +0 -0
- /package/{out/utils → utils}/allSettled.js +0 -0
- /package/{out/utils → utils}/checkTimeZone.d.ts +0 -0
- /package/{out/utils → utils}/checkTimeZone.js +0 -0
- /package/{out/utils → utils}/deviceUtils.d.ts +0 -0
- /package/{out/utils → utils}/deviceUtils.js +0 -0
- /package/{out/utils → utils}/flatMap.d.ts +0 -0
- /package/{out/utils → utils}/flatMap.js +0 -0
- /package/{out/utils → utils}/fromEntries.d.ts +0 -0
- /package/{out/utils → utils}/fromEntries.js +0 -0
- /package/{out/utils → utils}/generateRandomNumber.d.ts +0 -0
- /package/{out/utils → utils}/generateRandomNumber.js +0 -0
- /package/{out/utils → utils}/objectSort.d.ts +0 -0
- /package/{out/utils → utils}/objectSort.js +0 -0
- /package/{out/utils → utils}/orientationUtils.d.ts +0 -0
- /package/{out/utils → utils}/orientationUtils.js +0 -0
- /package/{out/velocity → velocity}/SysVelocityContext.d.ts +0 -0
- /package/{out/velocity → velocity}/SysVelocityContext.js +0 -0
- /package/{out/velocity → velocity}/SysVelocityRenderer.d.ts +0 -0
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import {ClDocumentCssVarsI, ClDocumentI} from './Document.interface';
|
|
2
|
-
|
|
3
|
-
export default class DocumentCssVarsReplace {
|
|
4
|
-
static replaceVars(document: ClDocumentI, colorsMap: ClDocumentCssVarsI): ClDocumentI {
|
|
5
|
-
const cssVarsMap = {...document.shared.cssVars, ...colorsMap};
|
|
6
|
-
let documentString = JSON.stringify(document);
|
|
7
|
-
|
|
8
|
-
Object.keys(cssVarsMap)
|
|
9
|
-
.forEach((varName) => {
|
|
10
|
-
let search = `var(--${varName})`;
|
|
11
|
-
let replacement = cssVarsMap[varName];
|
|
12
|
-
documentString = documentString.split(search).join(replacement);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
return JSON.parse(documentString);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
static replaceValues(document: ClDocumentI, cssVarsMap: ClDocumentCssVarsI): ClDocumentI {
|
|
19
|
-
let documentString = JSON.stringify(document);
|
|
20
|
-
Object.keys(cssVarsMap)
|
|
21
|
-
.forEach((varName) => {
|
|
22
|
-
let search = cssVarsMap[varName];
|
|
23
|
-
let replacement = `var(--${varName})`;
|
|
24
|
-
documentString = documentString.split(search).join(replacement);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
return JSON.parse(documentString);
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
}
|
|
@@ -1,595 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
import DocumentUtils from "./DocumentUtils";
|
|
3
|
-
import {ComponentInsertType} from "./ComponentInsertType";
|
|
4
|
-
|
|
5
|
-
function getDocument(): any {
|
|
6
|
-
return {
|
|
7
|
-
views: [
|
|
8
|
-
{
|
|
9
|
-
id: 'id1',
|
|
10
|
-
path: [0],
|
|
11
|
-
children: [
|
|
12
|
-
{
|
|
13
|
-
id: 'id2',
|
|
14
|
-
path: [0, 0],
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
id: 'id3',
|
|
18
|
-
path: [0, 1],
|
|
19
|
-
children: [
|
|
20
|
-
{
|
|
21
|
-
id: 'id4',
|
|
22
|
-
path: [0, 1, 0],
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
]
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
id: 'id5',
|
|
29
|
-
path: [0, 2]
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
]
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
id: 'id12',
|
|
36
|
-
path: [1],
|
|
37
|
-
children: [
|
|
38
|
-
{
|
|
39
|
-
id: 'id22',
|
|
40
|
-
path: [1, 0],
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
id: 'id32',
|
|
44
|
-
path: [1, 1],
|
|
45
|
-
children: [
|
|
46
|
-
{
|
|
47
|
-
id: 'id42',
|
|
48
|
-
path: [1, 1, 0],
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
]
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
id: 'id52',
|
|
55
|
-
path: [1, 2]
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
]
|
|
59
|
-
},
|
|
60
|
-
]
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
describe('DocumentUtils', () => {
|
|
65
|
-
|
|
66
|
-
it('removeNode', function () {
|
|
67
|
-
const document = getDocument();
|
|
68
|
-
const expectedModel = {
|
|
69
|
-
views: [
|
|
70
|
-
{
|
|
71
|
-
id: 'id1',
|
|
72
|
-
path: [0],
|
|
73
|
-
children: [
|
|
74
|
-
{
|
|
75
|
-
id: 'id3',
|
|
76
|
-
path: [0, 0],
|
|
77
|
-
children: [
|
|
78
|
-
{
|
|
79
|
-
id: 'id4',
|
|
80
|
-
path: [0, 0, 0],
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
]
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
id: 'id5',
|
|
87
|
-
path: [0, 1]
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
]
|
|
92
|
-
},
|
|
93
|
-
...document.views.slice(1),
|
|
94
|
-
]
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const removedNode = DocumentUtils.removeNode(document.views, [0, 0]);
|
|
98
|
-
|
|
99
|
-
expect(removedNode.id).toEqual('id2');
|
|
100
|
-
expect(document).toEqual(expectedModel);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it('removeNode VIEW', function () {
|
|
104
|
-
const document = getDocument();
|
|
105
|
-
const expectedModel = {
|
|
106
|
-
views: [
|
|
107
|
-
{
|
|
108
|
-
id: 'id12',
|
|
109
|
-
path: [0],
|
|
110
|
-
children: [
|
|
111
|
-
{
|
|
112
|
-
id: 'id22',
|
|
113
|
-
path: [0, 0],
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
id: 'id32',
|
|
117
|
-
path: [0, 1],
|
|
118
|
-
children: [
|
|
119
|
-
{
|
|
120
|
-
id: 'id42',
|
|
121
|
-
path: [0, 1, 0],
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
]
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
id: 'id52',
|
|
128
|
-
path: [0, 2]
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
]
|
|
132
|
-
}]
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
const removedNode = DocumentUtils.removeNode(document.views, [0]);
|
|
136
|
-
|
|
137
|
-
expect(removedNode.id).toEqual('id1');
|
|
138
|
-
expect(document).toEqual(expectedModel);
|
|
139
|
-
})
|
|
140
|
-
|
|
141
|
-
it('insertNode before first', function () {
|
|
142
|
-
|
|
143
|
-
const document = getDocument();
|
|
144
|
-
const expectedModel = {
|
|
145
|
-
views: [
|
|
146
|
-
{
|
|
147
|
-
id: 'id1',
|
|
148
|
-
path: [0],
|
|
149
|
-
children: [
|
|
150
|
-
{
|
|
151
|
-
id: 'Inserted',
|
|
152
|
-
path: [0, 0],
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
id: 'id2',
|
|
156
|
-
path: [0, 1],
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
id: 'id3',
|
|
160
|
-
path: [0, 2],
|
|
161
|
-
children: [
|
|
162
|
-
{
|
|
163
|
-
id: 'id4',
|
|
164
|
-
path: [0, 2, 0],
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
]
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
id: 'id5',
|
|
171
|
-
path: [0, 3]
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
]
|
|
175
|
-
},
|
|
176
|
-
...document.views.slice(1),
|
|
177
|
-
]
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
const node = {
|
|
181
|
-
id: 'Inserted'
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
DocumentUtils.insertNode(node, [0, 0], document.views, ComponentInsertType.BEFORE);
|
|
185
|
-
|
|
186
|
-
expect(document).toEqual(expectedModel);
|
|
187
|
-
});
|
|
188
|
-
it('insertNode in the middle', function () {
|
|
189
|
-
|
|
190
|
-
const document = getDocument();
|
|
191
|
-
const expectedModel = {
|
|
192
|
-
views: [
|
|
193
|
-
{
|
|
194
|
-
id: 'id1',
|
|
195
|
-
path: [0],
|
|
196
|
-
children: [
|
|
197
|
-
{
|
|
198
|
-
id: 'id2',
|
|
199
|
-
path: [0, 0],
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
id: 'Inserted',
|
|
203
|
-
path: [0, 1],
|
|
204
|
-
},
|
|
205
|
-
{
|
|
206
|
-
id: 'id3',
|
|
207
|
-
path: [0, 2],
|
|
208
|
-
children: [
|
|
209
|
-
{
|
|
210
|
-
id: 'id4',
|
|
211
|
-
path: [0, 2, 0],
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
]
|
|
215
|
-
},
|
|
216
|
-
{
|
|
217
|
-
id: 'id5',
|
|
218
|
-
path: [0, 3]
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
]
|
|
222
|
-
},
|
|
223
|
-
...document.views.slice(1),
|
|
224
|
-
]
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
const node = {
|
|
228
|
-
id: 'Inserted'
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
DocumentUtils.insertNode(node, [0, 1], document.views, ComponentInsertType.BEFORE);
|
|
232
|
-
|
|
233
|
-
expect(document).toEqual(expectedModel);
|
|
234
|
-
});
|
|
235
|
-
it('insertNode after last', function () {
|
|
236
|
-
|
|
237
|
-
const document = getDocument();
|
|
238
|
-
const expectedModel = {
|
|
239
|
-
views: [
|
|
240
|
-
{
|
|
241
|
-
id: 'id1',
|
|
242
|
-
path: [0],
|
|
243
|
-
children: [
|
|
244
|
-
{
|
|
245
|
-
id: 'id2',
|
|
246
|
-
path: [0, 0],
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
id: 'id3',
|
|
250
|
-
path: [0, 1],
|
|
251
|
-
children: [
|
|
252
|
-
{
|
|
253
|
-
id: 'id4',
|
|
254
|
-
path: [0, 1, 0],
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
]
|
|
258
|
-
},
|
|
259
|
-
{
|
|
260
|
-
id: 'id5',
|
|
261
|
-
path: [0, 2]
|
|
262
|
-
},
|
|
263
|
-
{
|
|
264
|
-
id: 'Inserted',
|
|
265
|
-
path: [0, 3]
|
|
266
|
-
}
|
|
267
|
-
]
|
|
268
|
-
},
|
|
269
|
-
...document.views.slice(1),
|
|
270
|
-
]
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
const node = {
|
|
274
|
-
id: 'Inserted'
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
DocumentUtils.insertNode(node, [0, 2], document.views, ComponentInsertType.AFTER);
|
|
278
|
-
|
|
279
|
-
expect(document).toEqual(expectedModel);
|
|
280
|
-
});
|
|
281
|
-
it('insertNode VIEW', function () {
|
|
282
|
-
|
|
283
|
-
const document = getDocument();
|
|
284
|
-
const expectedModel = {
|
|
285
|
-
views: [
|
|
286
|
-
{
|
|
287
|
-
id: 'id1',
|
|
288
|
-
path: [0],
|
|
289
|
-
children: [
|
|
290
|
-
{
|
|
291
|
-
id: 'id2',
|
|
292
|
-
path: [0, 0],
|
|
293
|
-
},
|
|
294
|
-
{
|
|
295
|
-
id: 'id3',
|
|
296
|
-
path: [0, 1],
|
|
297
|
-
children: [
|
|
298
|
-
{
|
|
299
|
-
id: 'id4',
|
|
300
|
-
path: [0, 1, 0],
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
]
|
|
304
|
-
},
|
|
305
|
-
{
|
|
306
|
-
id: 'id5',
|
|
307
|
-
path: [0, 2]
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
]
|
|
311
|
-
},
|
|
312
|
-
{
|
|
313
|
-
id: 'inserted',
|
|
314
|
-
path: [1],
|
|
315
|
-
children: [
|
|
316
|
-
{
|
|
317
|
-
id: 'inserted',
|
|
318
|
-
path: [1, 0],
|
|
319
|
-
},
|
|
320
|
-
{
|
|
321
|
-
id: 'inserted',
|
|
322
|
-
path: [1, 1],
|
|
323
|
-
children: [
|
|
324
|
-
{
|
|
325
|
-
id: 'inserted',
|
|
326
|
-
path: [1, 1, 0],
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
]
|
|
330
|
-
},
|
|
331
|
-
{
|
|
332
|
-
id: 'inserted',
|
|
333
|
-
path: [1, 2]
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
]
|
|
337
|
-
},
|
|
338
|
-
{
|
|
339
|
-
id: 'id12',
|
|
340
|
-
path: [2],
|
|
341
|
-
children: [
|
|
342
|
-
{
|
|
343
|
-
id: 'id22',
|
|
344
|
-
path: [2, 0],
|
|
345
|
-
},
|
|
346
|
-
{
|
|
347
|
-
id: 'id32',
|
|
348
|
-
path: [2, 1],
|
|
349
|
-
children: [
|
|
350
|
-
{
|
|
351
|
-
id: 'id42',
|
|
352
|
-
path: [2, 1, 0],
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
]
|
|
356
|
-
},
|
|
357
|
-
{
|
|
358
|
-
id: 'id52',
|
|
359
|
-
path: [2, 2]
|
|
360
|
-
}
|
|
361
|
-
]
|
|
362
|
-
}
|
|
363
|
-
]
|
|
364
|
-
};
|
|
365
|
-
|
|
366
|
-
const node = {
|
|
367
|
-
id: 'inserted',
|
|
368
|
-
path: [22],
|
|
369
|
-
children: [
|
|
370
|
-
{
|
|
371
|
-
id: 'inserted',
|
|
372
|
-
path: [1, 0],
|
|
373
|
-
},
|
|
374
|
-
{
|
|
375
|
-
id: 'inserted',
|
|
376
|
-
path: [1, 1],
|
|
377
|
-
children: [
|
|
378
|
-
{
|
|
379
|
-
id: 'inserted',
|
|
380
|
-
path: [1, 1, 0],
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
]
|
|
384
|
-
},
|
|
385
|
-
{
|
|
386
|
-
id: 'inserted',
|
|
387
|
-
path: [1, 2]
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
]
|
|
391
|
-
};
|
|
392
|
-
|
|
393
|
-
DocumentUtils.insertNode(node, [1], document.views, ComponentInsertType.BEFORE);
|
|
394
|
-
|
|
395
|
-
expect(document).toEqual(expectedModel);
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
it('move node from first to last position', () => {
|
|
399
|
-
const views = [{
|
|
400
|
-
id: 'view1',
|
|
401
|
-
path: [0],
|
|
402
|
-
children: [
|
|
403
|
-
{
|
|
404
|
-
id: 'child1',
|
|
405
|
-
path: [0, 0],
|
|
406
|
-
},
|
|
407
|
-
{
|
|
408
|
-
id: 'child2',
|
|
409
|
-
path: [0, 1],
|
|
410
|
-
},
|
|
411
|
-
{
|
|
412
|
-
id: 'child3',
|
|
413
|
-
path: [0, 2],
|
|
414
|
-
},
|
|
415
|
-
]
|
|
416
|
-
}];
|
|
417
|
-
|
|
418
|
-
DocumentUtils.moveNode(
|
|
419
|
-
views,
|
|
420
|
-
[0, 0],
|
|
421
|
-
[0, 2],
|
|
422
|
-
ComponentInsertType.AFTER,
|
|
423
|
-
);
|
|
424
|
-
|
|
425
|
-
expect(views[0].children[0].id).toEqual('child2');
|
|
426
|
-
expect(views[0].children[1].id).toEqual('child3');
|
|
427
|
-
expect(views[0].children[2].id).toEqual('child1');
|
|
428
|
-
});
|
|
429
|
-
|
|
430
|
-
it('move node from last to first position', () => {
|
|
431
|
-
const views = [{
|
|
432
|
-
id: 'view1',
|
|
433
|
-
path: [0],
|
|
434
|
-
children: [
|
|
435
|
-
{
|
|
436
|
-
id: 'child1',
|
|
437
|
-
path: [0, 0],
|
|
438
|
-
},
|
|
439
|
-
{
|
|
440
|
-
id: 'child2',
|
|
441
|
-
path: [0, 1],
|
|
442
|
-
},
|
|
443
|
-
{
|
|
444
|
-
id: 'child3',
|
|
445
|
-
path: [0, 2],
|
|
446
|
-
},
|
|
447
|
-
]
|
|
448
|
-
}];
|
|
449
|
-
|
|
450
|
-
DocumentUtils.moveNode(
|
|
451
|
-
views,
|
|
452
|
-
[0, 2],
|
|
453
|
-
[0, 0],
|
|
454
|
-
ComponentInsertType.BEFORE,
|
|
455
|
-
);
|
|
456
|
-
|
|
457
|
-
expect(views[0].children[0].id).toEqual('child3');
|
|
458
|
-
expect(views[0].children[1].id).toEqual('child1');
|
|
459
|
-
expect(views[0].children[2].id).toEqual('child2');
|
|
460
|
-
});
|
|
461
|
-
|
|
462
|
-
it('move node from first view to second one', () => {
|
|
463
|
-
const views = [
|
|
464
|
-
{
|
|
465
|
-
id: 'view1',
|
|
466
|
-
path: [0],
|
|
467
|
-
children: [
|
|
468
|
-
{
|
|
469
|
-
id: 'child1',
|
|
470
|
-
path: [0, 0],
|
|
471
|
-
},
|
|
472
|
-
{
|
|
473
|
-
id: 'child2',
|
|
474
|
-
path: [0, 1],
|
|
475
|
-
},
|
|
476
|
-
]
|
|
477
|
-
},
|
|
478
|
-
{
|
|
479
|
-
id: 'view2',
|
|
480
|
-
path: [1],
|
|
481
|
-
children: [
|
|
482
|
-
{
|
|
483
|
-
id: 'child3',
|
|
484
|
-
path: [1, 0],
|
|
485
|
-
},
|
|
486
|
-
]
|
|
487
|
-
}
|
|
488
|
-
];
|
|
489
|
-
|
|
490
|
-
DocumentUtils.moveNode(
|
|
491
|
-
views,
|
|
492
|
-
[0, 0],
|
|
493
|
-
[1, 0],
|
|
494
|
-
ComponentInsertType.BEFORE,
|
|
495
|
-
);
|
|
496
|
-
|
|
497
|
-
expect(views[0].children[0].id).toEqual('child2');
|
|
498
|
-
expect(views[1].children[0].id).toEqual('child1');
|
|
499
|
-
expect(views[1].children[1].id).toEqual('child3');
|
|
500
|
-
});
|
|
501
|
-
|
|
502
|
-
it('iterateDepthFirst', function () {
|
|
503
|
-
const node = {
|
|
504
|
-
children: [
|
|
505
|
-
{},
|
|
506
|
-
{},
|
|
507
|
-
{}
|
|
508
|
-
]
|
|
509
|
-
};
|
|
510
|
-
const expected = {
|
|
511
|
-
upd: true,
|
|
512
|
-
children: [
|
|
513
|
-
{upd: true,},
|
|
514
|
-
{upd: true,},
|
|
515
|
-
{upd: true,}
|
|
516
|
-
]
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
DocumentUtils.iterateDepthFirst(node, (node) => node.upd = true);
|
|
520
|
-
expect(node).toEqual(expected);
|
|
521
|
-
|
|
522
|
-
});
|
|
523
|
-
|
|
524
|
-
it('reIndex', function () {
|
|
525
|
-
const expectedModel = getDocument();
|
|
526
|
-
const document = {
|
|
527
|
-
views: [
|
|
528
|
-
{
|
|
529
|
-
id: 'id1',
|
|
530
|
-
|
|
531
|
-
children: [
|
|
532
|
-
{
|
|
533
|
-
id: 'id2',
|
|
534
|
-
path: [23],
|
|
535
|
-
},
|
|
536
|
-
{
|
|
537
|
-
id: 'id3',
|
|
538
|
-
children: [
|
|
539
|
-
{
|
|
540
|
-
id: 'id4',
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
]
|
|
544
|
-
},
|
|
545
|
-
{
|
|
546
|
-
id: 'id5',
|
|
547
|
-
}
|
|
548
|
-
]
|
|
549
|
-
},
|
|
550
|
-
...expectedModel.views.slice(1),
|
|
551
|
-
]
|
|
552
|
-
};
|
|
553
|
-
|
|
554
|
-
DocumentUtils.reIndex(document.views[0], [0]);
|
|
555
|
-
|
|
556
|
-
expect(document).toEqual(expectedModel);
|
|
557
|
-
});
|
|
558
|
-
|
|
559
|
-
it('getRelativePath', function () {
|
|
560
|
-
expect(DocumentUtils.getRelativePath([0, 1])).toEqual([1]);
|
|
561
|
-
});
|
|
562
|
-
|
|
563
|
-
it('getParentPath', function () {
|
|
564
|
-
expect(DocumentUtils.getParentPath([0, 1])).toEqual([0]);
|
|
565
|
-
});
|
|
566
|
-
|
|
567
|
-
it('getNodeByPath', function () {
|
|
568
|
-
|
|
569
|
-
const node1 = DocumentUtils.getNodeByPath(getDocument().views, [0, 1, 0]);
|
|
570
|
-
expect(node1.id).toEqual('id4');
|
|
571
|
-
|
|
572
|
-
const node2 = DocumentUtils.getNodeByPath(getDocument().views, [1, 1, 0]);
|
|
573
|
-
expect(node2.id).toEqual('id42');
|
|
574
|
-
});
|
|
575
|
-
|
|
576
|
-
it('getNodeById', function () {
|
|
577
|
-
|
|
578
|
-
const node = DocumentUtils.getNodeById(getDocument().views, 'id4');
|
|
579
|
-
expect(node.path).toEqual([0, 1, 0]);
|
|
580
|
-
});
|
|
581
|
-
|
|
582
|
-
it('getPathToInsert', function () {
|
|
583
|
-
const pathToInsert = DocumentUtils.getPathToInsert([0, 0], ComponentInsertType.BEFORE, getDocument().views);
|
|
584
|
-
expect(pathToInsert).toEqual([0, 0]);
|
|
585
|
-
|
|
586
|
-
const pathToInsert1 = DocumentUtils.getPathToInsert([0, 2], ComponentInsertType.AFTER, getDocument().views);
|
|
587
|
-
expect(pathToInsert1).toEqual([0, 3]);
|
|
588
|
-
|
|
589
|
-
const pathToInsert2 = DocumentUtils.getPathToInsert([0, 1], ComponentInsertType.AFTER, getDocument().views);
|
|
590
|
-
expect(pathToInsert2).toEqual([0, 2]);
|
|
591
|
-
|
|
592
|
-
const pathToInsert3 = DocumentUtils.getPathToInsert([0], ComponentInsertType.INSIDE, getDocument().views);
|
|
593
|
-
expect(pathToInsert3).toEqual([0, 3]);
|
|
594
|
-
});
|
|
595
|
-
})
|