cx 26.0.14 → 26.1.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/build/ui/VDOM.d.ts +1 -20
- package/build/ui/VDOM.js +1 -3
- package/build/ui/Widget.d.ts +1 -1
- package/build/ui/Widget.js +0 -5
- package/build/ui/app/startAppLoop.js +2 -10
- package/build/util/Component.js +5 -0
- package/build/util/test/createTestRenderer.d.ts +3 -1
- package/build/util/test/createTestRenderer.js +8 -2
- package/build/widgets/form/Checkbox.d.ts +0 -1
- package/build/widgets/form/Checkbox.js +1 -0
- package/build/widgets/form/ColorField.d.ts +0 -1
- package/build/widgets/form/ColorField.js +2 -2
- package/build/widgets/form/DateTimeField.d.ts +0 -2
- package/build/widgets/form/DateTimeField.js +1 -0
- package/build/widgets/form/DateTimePicker.d.ts +0 -2
- package/build/widgets/form/DateTimePicker.js +1 -0
- package/build/widgets/form/Radio.d.ts +0 -1
- package/build/widgets/form/Slider.js +9 -1
- package/build/widgets/form/Switch.d.ts +0 -1
- package/build/widgets/form/Switch.js +1 -1
- package/build/widgets/form/Wheel.d.ts +0 -1
- package/build/widgets/grid/Grid.d.ts +0 -2
- package/build/widgets/grid/GridCellEditor.js +3 -1
- package/build/widgets/icons/calendar.js +4 -3
- package/build/widgets/icons/check.js +2 -2
- package/build/widgets/icons/clear.js +2 -2
- package/build/widgets/icons/close.js +2 -2
- package/build/widgets/icons/cx.js +2 -2
- package/build/widgets/icons/drop-down.js +2 -2
- package/build/widgets/icons/file.js +2 -2
- package/build/widgets/icons/folder-open.js +2 -2
- package/build/widgets/icons/folder.js +2 -2
- package/build/widgets/icons/forward.js +2 -2
- package/build/widgets/icons/loading.js +2 -2
- package/build/widgets/icons/menu.js +2 -2
- package/build/widgets/icons/pixel-picker.js +2 -2
- package/build/widgets/icons/search.js +2 -2
- package/build/widgets/icons/sort-asc.js +2 -2
- package/build/widgets/icons/square.js +2 -2
- package/build/widgets/overlay/Overlay.d.ts +3 -0
- package/build/widgets/overlay/Overlay.js +3 -2
- package/dist/manifest.js +867 -867
- package/dist/ui.js +4 -18
- package/dist/util.js +4 -0
- package/dist/widgets.js +395 -319
- package/package.json +11 -8
- package/src/charts/Chart.ts +108 -108
- package/src/core.d.ts +182 -182
- package/src/data/Expression.spec.ts +229 -229
- package/src/data/Expression.ts +233 -233
- package/src/data/Grouper.ts +158 -158
- package/src/data/Selector.ts +10 -10
- package/src/data/StringTemplate.spec.ts +132 -132
- package/src/data/StructuredSelector.ts +146 -146
- package/src/data/ZoomIntoPropertyView.spec.ts +64 -64
- package/src/data/comparer.ts +78 -78
- package/src/data/computable.spec.ts +87 -87
- package/src/data/createStructuredSelector.ts +62 -62
- package/src/data/getAccessor.spec.ts +11 -11
- package/src/data/getAccessor.ts +74 -74
- package/src/data/getSelector.spec.ts +43 -43
- package/src/data/getSelector.ts +66 -66
- package/src/data/ops/filter.spec.ts +35 -35
- package/src/data/ops/filter.ts +9 -9
- package/src/data/ops/merge.ts +13 -13
- package/src/data/ops/removeTreeNodes.spec.ts +37 -37
- package/src/data/ops/updateArray.spec.ts +69 -69
- package/src/data/ops/updateArray.ts +31 -31
- package/src/data/test-types.ts +7 -7
- package/src/hooks/invokeCallback.spec.tsx +4 -4
- package/src/hooks/resolveCallback.spec.tsx +4 -4
- package/src/hooks/store.spec.tsx +15 -15
- package/src/hooks/useTrigger.spec.tsx +16 -10
- package/src/hooks/useTrigger.ts +26 -26
- package/src/index.scss +6 -6
- package/src/jsx-runtime.ts +79 -79
- package/src/svg/BoundedObject.ts +101 -101
- package/src/svg/util/Rect.ts +105 -105
- package/src/ui/CSS.ts +87 -87
- package/src/ui/CSSHelper.ts +17 -17
- package/src/ui/ContentResolver.spec.tsx +31 -29
- package/src/ui/Controller.spec.tsx +47 -39
- package/src/ui/Culture.ts +159 -159
- package/src/ui/Cx.spec.tsx +10 -8
- package/src/ui/DataProxy.spec.tsx +18 -18
- package/src/ui/Instance.ts +866 -866
- package/src/ui/IsolatedScope.spec.tsx +16 -9
- package/src/ui/Prop.ts +140 -140
- package/src/ui/PureContainer.spec.tsx +20 -18
- package/src/ui/RenderingContext.ts +99 -99
- package/src/ui/Repeater.spec.tsx +8 -6
- package/src/ui/Rescope.spec.tsx +13 -13
- package/src/ui/Restate.spec.tsx +31 -27
- package/src/ui/StructuredInstanceDataAccessor.ts +32 -32
- package/src/ui/VDOM.ts +1 -34
- package/src/ui/Widget.tsx +0 -7
- package/src/ui/adapter/TreeAdapter.spec.ts +76 -76
- package/src/ui/adapter/TreeAdapter.ts +185 -185
- package/src/ui/app/History.ts +133 -133
- package/src/ui/app/Url.spec.ts +50 -50
- package/src/ui/app/startAppLoop.tsx +5 -9
- package/src/ui/app/startHotAppLoop.ts +41 -41
- package/src/ui/createFunctionalComponent.spec.tsx +20 -18
- package/src/ui/layout/ContentPlaceholder.spec.tsx +46 -34
- package/src/ui/layout/FirstVisibleChildLayout.spec.tsx +31 -19
- package/src/ui/layout/FirstVisibleChildLayout.ts +60 -60
- package/src/ui/selection/PropertySelection.ts +87 -87
- package/src/util/Component.spec.ts +30 -0
- package/src/util/Component.ts +301 -296
- package/src/util/Console.ts +13 -13
- package/src/util/DOM.ts +88 -88
- package/src/util/hasKey.ts +18 -18
- package/src/util/index.ts +55 -55
- package/src/util/isArray.ts +3 -3
- package/src/util/isDefined.ts +3 -3
- package/src/util/isString.ts +3 -3
- package/src/util/test/createTestRenderer.tsx +9 -2
- package/src/widgets/AccessorBindings.spec.tsx +4 -4
- package/src/widgets/DocumentTitle.ts +95 -95
- package/src/widgets/HtmlElement.spec.tsx +6 -6
- package/src/widgets/ReactElementWrapper.spec.tsx +37 -37
- package/src/widgets/autoFocus.ts +9 -9
- package/src/widgets/cx.ts +63 -63
- package/src/widgets/form/Checkbox.tsx +0 -1
- package/src/widgets/form/ColorField.tsx +15 -12
- package/src/widgets/form/DateTimeField.tsx +0 -2
- package/src/widgets/form/DateTimePicker.tsx +0 -2
- package/src/widgets/form/Radio.tsx +0 -1
- package/src/widgets/form/Slider.tsx +12 -4
- package/src/widgets/form/Switch.tsx +2 -3
- package/src/widgets/form/ValidationGroup.spec.tsx +12 -12
- package/src/widgets/form/Wheel.tsx +0 -1
- package/src/widgets/grid/Grid.tsx +0 -1
- package/src/widgets/grid/GridCellEditor.tsx +7 -1
- package/src/widgets/icons/calendar.tsx +20 -15
- package/src/widgets/icons/check.tsx +2 -1
- package/src/widgets/icons/clear.tsx +2 -1
- package/src/widgets/icons/close.tsx +2 -2
- package/src/widgets/icons/cx.tsx +2 -1
- package/src/widgets/icons/drop-down.tsx +2 -1
- package/src/widgets/icons/file.tsx +2 -1
- package/src/widgets/icons/folder-open.tsx +2 -1
- package/src/widgets/icons/folder.tsx +2 -1
- package/src/widgets/icons/forward.tsx +2 -1
- package/src/widgets/icons/loading.tsx +2 -1
- package/src/widgets/icons/menu.tsx +2 -1
- package/src/widgets/icons/pixel-picker.tsx +2 -2
- package/src/widgets/icons/search.tsx +2 -1
- package/src/widgets/icons/sort-asc.tsx +2 -1
- package/src/widgets/icons/square.tsx +2 -1
- package/src/widgets/nav/Route.spec.tsx +2 -2
- package/src/widgets/overlay/Overlay.tsx +5 -1
- package/src/widgets/overlay/captureMouse.ts +195 -195
- package/src/widgets/overlay/createHotPromiseWindowFactory.ts +71 -71
- package/src/widgets/overlay/index.d.ts +11 -11
- package/src/widgets/overlay/tooltip-ops.ts +173 -173
- package/build/data/ArrayElementView.spec.d.ts +0 -1
- package/build/data/ArrayElementView.spec.js +0 -81
- package/build/data/Binding.spec.d.ts +0 -1
- package/build/data/Binding.spec.js +0 -61
- package/build/data/Expression.spec.d.ts +0 -1
- package/build/data/Expression.spec.js +0 -196
- package/build/data/Grouper.spec.d.ts +0 -1
- package/build/data/Grouper.spec.js +0 -48
- package/build/data/Ref.spec.d.ts +0 -1
- package/build/data/Ref.spec.js +0 -72
- package/build/data/Store.spec.d.ts +0 -1
- package/build/data/Store.spec.js +0 -19
- package/build/data/StoreRef.spec.d.ts +0 -1
- package/build/data/StoreRef.spec.js +0 -22
- package/build/data/StringTemplate.spec.d.ts +0 -1
- package/build/data/StringTemplate.spec.js +0 -112
- package/build/data/StructuredSelector.spec.d.ts +0 -1
- package/build/data/StructuredSelector.spec.js +0 -102
- package/build/data/View.spec.d.ts +0 -1
- package/build/data/View.spec.js +0 -44
- package/build/data/ZoomIntoPropertyView.spec.d.ts +0 -1
- package/build/data/ZoomIntoPropertyView.spec.js +0 -54
- package/build/data/comparer.spec.d.ts +0 -1
- package/build/data/comparer.spec.js +0 -50
- package/build/data/computable.spec.d.ts +0 -1
- package/build/data/computable.spec.js +0 -56
- package/build/data/createAccessorModelProxy.spec.d.ts +0 -1
- package/build/data/createAccessorModelProxy.spec.js +0 -30
- package/build/data/createStructuredSelector.spec.d.ts +0 -1
- package/build/data/createStructuredSelector.spec.js +0 -42
- package/build/data/diff/diffs.spec.d.ts +0 -1
- package/build/data/diff/diffs.spec.js +0 -45
- package/build/data/getAccessor.spec.d.ts +0 -1
- package/build/data/getAccessor.spec.js +0 -10
- package/build/data/getSelector.spec.d.ts +0 -1
- package/build/data/getSelector.spec.js +0 -36
- package/build/data/ops/append.spec.d.ts +0 -1
- package/build/data/ops/append.spec.js +0 -24
- package/build/data/ops/filter.spec.d.ts +0 -1
- package/build/data/ops/filter.spec.js +0 -25
- package/build/data/ops/findTreeNode.spec.d.ts +0 -1
- package/build/data/ops/findTreeNode.spec.js +0 -20
- package/build/data/ops/merge.spec.d.ts +0 -1
- package/build/data/ops/merge.spec.js +0 -23
- package/build/data/ops/removeTreeNodes.spec.d.ts +0 -1
- package/build/data/ops/removeTreeNodes.spec.js +0 -35
- package/build/data/ops/updateArray.spec.d.ts +0 -1
- package/build/data/ops/updateArray.spec.js +0 -33
- package/build/data/ops/updateTree.spec.d.ts +0 -1
- package/build/data/ops/updateTree.spec.js +0 -44
- package/build/hooks/invokeCallback.spec.d.ts +0 -1
- package/build/hooks/invokeCallback.spec.js +0 -44
- package/build/hooks/resolveCallback.spec.d.ts +0 -1
- package/build/hooks/resolveCallback.spec.js +0 -35
- package/build/hooks/store.spec.d.ts +0 -1
- package/build/hooks/store.spec.js +0 -48
- package/build/hooks/useTrigger.spec.d.ts +0 -1
- package/build/hooks/useTrigger.spec.js +0 -59
- package/build/ui/Controller.spec.d.ts +0 -1
- package/build/ui/Controller.spec.js +0 -247
- package/build/ui/Cx.spec.d.ts +0 -1
- package/build/ui/Cx.spec.js +0 -153
- package/build/ui/DataProxy.spec.d.ts +0 -1
- package/build/ui/DataProxy.spec.js +0 -208
- package/build/ui/IsolatedScope.spec.d.ts +0 -1
- package/build/ui/IsolatedScope.spec.js +0 -42
- package/build/ui/PureContainer.spec.d.ts +0 -1
- package/build/ui/PureContainer.spec.js +0 -149
- package/build/ui/Repeater.spec.d.ts +0 -1
- package/build/ui/Repeater.spec.js +0 -109
- package/build/ui/Rescope.spec.d.ts +0 -1
- package/build/ui/Rescope.spec.js +0 -134
- package/build/ui/Restate.spec.d.ts +0 -1
- package/build/ui/Restate.spec.js +0 -257
- package/build/ui/adapter/ArrayAdapter.spec.d.ts +0 -1
- package/build/ui/adapter/ArrayAdapter.spec.js +0 -44
- package/build/ui/adapter/TreeAdapter.spec.d.ts +0 -1
- package/build/ui/adapter/TreeAdapter.spec.js +0 -71
- package/build/ui/app/Url.spec.d.ts +0 -1
- package/build/ui/app/Url.spec.js +0 -43
- package/build/ui/createFunctionalComponent.spec.d.ts +0 -1
- package/build/ui/createFunctionalComponent.spec.js +0 -272
- package/build/ui/layout/ContentPlaceholder.spec.d.ts +0 -1
- package/build/ui/layout/ContentPlaceholder.spec.js +0 -333
- package/build/ui/layout/FirstVisibleChildLayout.spec.d.ts +0 -1
- package/build/ui/layout/FirstVisibleChildLayout.spec.js +0 -101
- package/build/util/Format.spec.d.ts +0 -1
- package/build/util/Format.spec.js +0 -58
- package/build/util/TraversalStack.spec.d.ts +0 -1
- package/build/util/TraversalStack.spec.js +0 -43
- package/build/util/date/upperBoundCheck.spec.d.ts +0 -1
- package/build/util/date/upperBoundCheck.spec.js +0 -22
- package/build/util/getSearchQueryPredicate.spec.d.ts +0 -1
- package/build/util/getSearchQueryPredicate.spec.js +0 -33
- package/build/util/isValidIdentifierName.spec.d.ts +0 -1
- package/build/util/isValidIdentifierName.spec.js +0 -28
- package/build/util/routeAppend.spec.d.ts +0 -1
- package/build/util/routeAppend.spec.js +0 -14
- package/build/widgets/AccessorBindings.spec.d.ts +0 -1
- package/build/widgets/AccessorBindings.spec.js +0 -40
- package/build/widgets/HtmlElement.spec.d.ts +0 -1
- package/build/widgets/HtmlElement.spec.js +0 -38
- package/build/widgets/form/ValidationGroup.spec.d.ts +0 -1
- package/build/widgets/form/ValidationGroup.spec.js +0 -62
- package/build/widgets/nav/Route.spec.d.ts +0 -1
- package/build/widgets/nav/Route.spec.js +0 -15
- package/dist/manifest.d.ts +0 -1443
|
@@ -2,13 +2,13 @@ import { Store } from "../../data/Store";
|
|
|
2
2
|
import { ContentPlaceholder, ContentPlaceholderScope } from "./ContentPlaceholder";
|
|
3
3
|
import assert from "assert";
|
|
4
4
|
import { PureContainer } from "../PureContainer";
|
|
5
|
-
import { createTestRenderer } from "../../util/test/createTestRenderer";
|
|
5
|
+
import { createTestRenderer, act } from "../../util/test/createTestRenderer";
|
|
6
6
|
import { bind } from "../bind";
|
|
7
7
|
|
|
8
8
|
describe("ContentPlaceholder", () => {
|
|
9
|
-
it("allows putting content inside", () => {
|
|
9
|
+
it("allows putting content inside", async () => {
|
|
10
10
|
let store = new Store();
|
|
11
|
-
const component = createTestRenderer(
|
|
11
|
+
const component = await createTestRenderer(
|
|
12
12
|
store,
|
|
13
13
|
<cx>
|
|
14
14
|
<div>
|
|
@@ -47,13 +47,13 @@ describe("ContentPlaceholder", () => {
|
|
|
47
47
|
});
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
it("updates content on change", () => {
|
|
50
|
+
it("updates content on change", async () => {
|
|
51
51
|
let store = new Store({
|
|
52
52
|
data: {
|
|
53
53
|
headerText: "Header",
|
|
54
54
|
},
|
|
55
55
|
});
|
|
56
|
-
const component = createTestRenderer(
|
|
56
|
+
const component = await createTestRenderer(
|
|
57
57
|
store,
|
|
58
58
|
<cx>
|
|
59
59
|
<div>
|
|
@@ -76,13 +76,15 @@ describe("ContentPlaceholder", () => {
|
|
|
76
76
|
});
|
|
77
77
|
|
|
78
78
|
assert.deepEqual(component.toJSON(), getTree("Header"));
|
|
79
|
-
|
|
79
|
+
await act(async () => {
|
|
80
|
+
store.set("headerText", "Footer");
|
|
81
|
+
});
|
|
80
82
|
assert.deepEqual(component.toJSON(), getTree("Footer"));
|
|
81
83
|
});
|
|
82
84
|
|
|
83
|
-
it("allows putting multiple entries inside", () => {
|
|
85
|
+
it("allows putting multiple entries inside", async () => {
|
|
84
86
|
let store = new Store();
|
|
85
|
-
const component = createTestRenderer(
|
|
87
|
+
const component = await createTestRenderer(
|
|
86
88
|
store,
|
|
87
89
|
<cx>
|
|
88
90
|
<div>
|
|
@@ -127,9 +129,9 @@ describe("ContentPlaceholder", () => {
|
|
|
127
129
|
});
|
|
128
130
|
});
|
|
129
131
|
|
|
130
|
-
it("allows putting multiple entries inside when content is defined before and after the placeholder", () => {
|
|
132
|
+
it("allows putting multiple entries inside when content is defined before and after the placeholder", async () => {
|
|
131
133
|
let store = new Store();
|
|
132
|
-
const component = createTestRenderer(
|
|
134
|
+
const component = await createTestRenderer(
|
|
133
135
|
store,
|
|
134
136
|
<cx>
|
|
135
137
|
<div>
|
|
@@ -183,9 +185,9 @@ describe("ContentPlaceholder", () => {
|
|
|
183
185
|
});
|
|
184
186
|
});
|
|
185
187
|
|
|
186
|
-
it("allows putting multiple entries into separate placeholders using content placeholder scopes", () => {
|
|
188
|
+
it("allows putting multiple entries into separate placeholders using content placeholder scopes", async () => {
|
|
187
189
|
let store = new Store();
|
|
188
|
-
const component = createTestRenderer(
|
|
190
|
+
const component = await createTestRenderer(
|
|
189
191
|
store,
|
|
190
192
|
<cx>
|
|
191
193
|
<div>
|
|
@@ -249,7 +251,7 @@ describe("ContentPlaceholder", () => {
|
|
|
249
251
|
});
|
|
250
252
|
});
|
|
251
253
|
|
|
252
|
-
it("is used for defining body position in outer layouts", () => {
|
|
254
|
+
it("is used for defining body position in outer layouts", async () => {
|
|
253
255
|
let store = new Store();
|
|
254
256
|
|
|
255
257
|
let layout = (
|
|
@@ -262,7 +264,7 @@ describe("ContentPlaceholder", () => {
|
|
|
262
264
|
</cx>
|
|
263
265
|
);
|
|
264
266
|
|
|
265
|
-
const component = createTestRenderer(
|
|
267
|
+
const component = await createTestRenderer(
|
|
266
268
|
store,
|
|
267
269
|
<cx>
|
|
268
270
|
<main outerLayout={layout} />
|
|
@@ -292,7 +294,7 @@ describe("ContentPlaceholder", () => {
|
|
|
292
294
|
});
|
|
293
295
|
});
|
|
294
296
|
|
|
295
|
-
it("data in deeply nested placeholders is correctly updated", () => {
|
|
297
|
+
it("data in deeply nested placeholders is correctly updated", async () => {
|
|
296
298
|
let store = new Store({
|
|
297
299
|
data: {
|
|
298
300
|
header: "H",
|
|
@@ -315,7 +317,7 @@ describe("ContentPlaceholder", () => {
|
|
|
315
317
|
</cx>
|
|
316
318
|
);
|
|
317
319
|
|
|
318
|
-
const component = createTestRenderer(
|
|
320
|
+
const component = await createTestRenderer(
|
|
319
321
|
store,
|
|
320
322
|
<cx>
|
|
321
323
|
<main outerLayout={layout}>
|
|
@@ -353,15 +355,21 @@ describe("ContentPlaceholder", () => {
|
|
|
353
355
|
});
|
|
354
356
|
|
|
355
357
|
assert.deepEqual(component.toJSON(), getTree("H", "B", "F"));
|
|
356
|
-
|
|
358
|
+
await act(async () => {
|
|
359
|
+
store.set("header", "H2");
|
|
360
|
+
});
|
|
357
361
|
assert.deepEqual(component.toJSON(), getTree("H2", "B", "F"));
|
|
358
|
-
|
|
362
|
+
await act(async () => {
|
|
363
|
+
store.set("footer", "F2");
|
|
364
|
+
});
|
|
359
365
|
assert.deepEqual(component.toJSON(), getTree("H2", "B", "F2"));
|
|
360
|
-
|
|
366
|
+
await act(async () => {
|
|
367
|
+
store.set("body", "B2");
|
|
368
|
+
});
|
|
361
369
|
assert.deepEqual(component.toJSON(), getTree("H2", "B2", "F2"));
|
|
362
370
|
});
|
|
363
371
|
|
|
364
|
-
it("inside a two-level deep outer-layout works", () => {
|
|
372
|
+
it("inside a two-level deep outer-layout works", async () => {
|
|
365
373
|
let store = new Store();
|
|
366
374
|
|
|
367
375
|
let outerLayout = (
|
|
@@ -380,7 +388,7 @@ describe("ContentPlaceholder", () => {
|
|
|
380
388
|
</cx>
|
|
381
389
|
);
|
|
382
390
|
|
|
383
|
-
const component = createTestRenderer(
|
|
391
|
+
const component = await createTestRenderer(
|
|
384
392
|
store,
|
|
385
393
|
<cx>
|
|
386
394
|
<section outerLayout={innerLayout} />
|
|
@@ -388,7 +396,6 @@ describe("ContentPlaceholder", () => {
|
|
|
388
396
|
);
|
|
389
397
|
|
|
390
398
|
let tree = component.toJSON();
|
|
391
|
-
//console.log(tree);
|
|
392
399
|
|
|
393
400
|
assert.deepEqual(tree, {
|
|
394
401
|
type: "div",
|
|
@@ -409,10 +416,10 @@ describe("ContentPlaceholder", () => {
|
|
|
409
416
|
});
|
|
410
417
|
});
|
|
411
418
|
|
|
412
|
-
it("works in strange order", () => {
|
|
419
|
+
it("works in strange order", async () => {
|
|
413
420
|
let store = new Store();
|
|
414
421
|
|
|
415
|
-
const component = createTestRenderer(
|
|
422
|
+
const component = await createTestRenderer(
|
|
416
423
|
store,
|
|
417
424
|
<cx>
|
|
418
425
|
<div>
|
|
@@ -427,7 +434,6 @@ describe("ContentPlaceholder", () => {
|
|
|
427
434
|
);
|
|
428
435
|
|
|
429
436
|
let tree = component.toJSON();
|
|
430
|
-
//console.log(tree);
|
|
431
437
|
|
|
432
438
|
assert.deepEqual(tree, {
|
|
433
439
|
type: "div",
|
|
@@ -436,7 +442,7 @@ describe("ContentPlaceholder", () => {
|
|
|
436
442
|
});
|
|
437
443
|
});
|
|
438
444
|
|
|
439
|
-
it("inside a complex two-level-deep outer-layout works", () => {
|
|
445
|
+
it("inside a complex two-level-deep outer-layout works", async () => {
|
|
440
446
|
let store = new Store();
|
|
441
447
|
|
|
442
448
|
let outerLayout = (
|
|
@@ -457,7 +463,7 @@ describe("ContentPlaceholder", () => {
|
|
|
457
463
|
</cx>
|
|
458
464
|
);
|
|
459
465
|
|
|
460
|
-
const component = createTestRenderer(
|
|
466
|
+
const component = await createTestRenderer(
|
|
461
467
|
store,
|
|
462
468
|
<cx>
|
|
463
469
|
<section outerLayout={innerLayout} />
|
|
@@ -471,7 +477,7 @@ describe("ContentPlaceholder", () => {
|
|
|
471
477
|
});
|
|
472
478
|
});
|
|
473
479
|
|
|
474
|
-
it("each level use an outer-layout", () => {
|
|
480
|
+
it("each level use an outer-layout", async () => {
|
|
475
481
|
let store = new Store();
|
|
476
482
|
|
|
477
483
|
let outerLayout1 = (
|
|
@@ -490,7 +496,7 @@ describe("ContentPlaceholder", () => {
|
|
|
490
496
|
</cx>
|
|
491
497
|
);
|
|
492
498
|
|
|
493
|
-
const component = createTestRenderer(
|
|
499
|
+
const component = await createTestRenderer(
|
|
494
500
|
store,
|
|
495
501
|
<cx>
|
|
496
502
|
<PureContainer outerLayout={outerLayout1}>
|
|
@@ -506,7 +512,7 @@ describe("ContentPlaceholder", () => {
|
|
|
506
512
|
});
|
|
507
513
|
});
|
|
508
514
|
|
|
509
|
-
it("data in a two-level deep outer-layout is correctly updated", () => {
|
|
515
|
+
it("data in a two-level deep outer-layout is correctly updated", async () => {
|
|
510
516
|
let store = new Store({
|
|
511
517
|
data: {
|
|
512
518
|
header: "H",
|
|
@@ -539,7 +545,7 @@ describe("ContentPlaceholder", () => {
|
|
|
539
545
|
</cx>
|
|
540
546
|
);
|
|
541
547
|
|
|
542
|
-
const component = createTestRenderer(
|
|
548
|
+
const component = await createTestRenderer(
|
|
543
549
|
store,
|
|
544
550
|
<cx>
|
|
545
551
|
<main outerLayout={innerLayout}>
|
|
@@ -577,11 +583,17 @@ describe("ContentPlaceholder", () => {
|
|
|
577
583
|
});
|
|
578
584
|
|
|
579
585
|
assert.deepEqual(component.toJSON(), getTree("H", "B", "F"));
|
|
580
|
-
|
|
586
|
+
await act(async () => {
|
|
587
|
+
store.set("header", "H2");
|
|
588
|
+
});
|
|
581
589
|
assert.deepEqual(component.toJSON(), getTree("H2", "B", "F"));
|
|
582
|
-
|
|
590
|
+
await act(async () => {
|
|
591
|
+
store.set("footer", "F2");
|
|
592
|
+
});
|
|
583
593
|
assert.deepEqual(component.toJSON(), getTree("H2", "B", "F2"));
|
|
584
|
-
|
|
594
|
+
await act(async () => {
|
|
595
|
+
store.set("body", "B2");
|
|
596
|
+
});
|
|
585
597
|
assert.deepEqual(component.toJSON(), getTree("H2", "B2", "F2"));
|
|
586
598
|
});
|
|
587
599
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Store } from "../../data/Store";
|
|
2
2
|
import { expr } from "../expr";
|
|
3
|
-
import { createTestRenderer } from "../../util/test/createTestRenderer";
|
|
3
|
+
import { createTestRenderer, act } from "../../util/test/createTestRenderer";
|
|
4
4
|
|
|
5
5
|
import assert from "assert";
|
|
6
6
|
import { FirstVisibleChildLayout } from "./FirstVisibleChildLayout";
|
|
@@ -9,7 +9,7 @@ import { PureContainer } from "../PureContainer";
|
|
|
9
9
|
import { createFunctionalComponent } from "../createFunctionalComponent";
|
|
10
10
|
|
|
11
11
|
describe("FirstVisibleChildLayout", () => {
|
|
12
|
-
it("renders only the first child", () => {
|
|
12
|
+
it("renders only the first child", async () => {
|
|
13
13
|
let widget = (
|
|
14
14
|
<cx>
|
|
15
15
|
<div layout={FirstVisibleChildLayout}>
|
|
@@ -22,7 +22,7 @@ describe("FirstVisibleChildLayout", () => {
|
|
|
22
22
|
|
|
23
23
|
let store = new Store();
|
|
24
24
|
|
|
25
|
-
const component = createTestRenderer(store, widget);
|
|
25
|
+
const component = await createTestRenderer(store, widget);
|
|
26
26
|
|
|
27
27
|
let tree = component.toJSON();
|
|
28
28
|
assert.deepEqual(tree, {
|
|
@@ -32,7 +32,7 @@ describe("FirstVisibleChildLayout", () => {
|
|
|
32
32
|
});
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
it("does not process other widgets", () => {
|
|
35
|
+
it("does not process other widgets", async () => {
|
|
36
36
|
let h = false,
|
|
37
37
|
m = false,
|
|
38
38
|
f = false;
|
|
@@ -61,7 +61,7 @@ describe("FirstVisibleChildLayout", () => {
|
|
|
61
61
|
|
|
62
62
|
let store = new Store();
|
|
63
63
|
|
|
64
|
-
const component = createTestRenderer(store, widget);
|
|
64
|
+
const component = await createTestRenderer(store, widget);
|
|
65
65
|
|
|
66
66
|
let tree = component.toJSON();
|
|
67
67
|
assert.deepEqual(tree, {
|
|
@@ -75,7 +75,7 @@ describe("FirstVisibleChildLayout", () => {
|
|
|
75
75
|
assert.equal(f, false);
|
|
76
76
|
});
|
|
77
77
|
|
|
78
|
-
it("skips the first child if not visible", () => {
|
|
78
|
+
it("skips the first child if not visible", async () => {
|
|
79
79
|
let widget = (
|
|
80
80
|
<cx>
|
|
81
81
|
<div layout={FirstVisibleChildLayout}>
|
|
@@ -88,7 +88,7 @@ describe("FirstVisibleChildLayout", () => {
|
|
|
88
88
|
|
|
89
89
|
let store = new Store();
|
|
90
90
|
|
|
91
|
-
const component = createTestRenderer(store, widget);
|
|
91
|
+
const component = await createTestRenderer(store, widget);
|
|
92
92
|
|
|
93
93
|
let tree = component.toJSON();
|
|
94
94
|
assert.deepEqual(tree, {
|
|
@@ -98,7 +98,7 @@ describe("FirstVisibleChildLayout", () => {
|
|
|
98
98
|
});
|
|
99
99
|
});
|
|
100
100
|
|
|
101
|
-
it("skips pure containers which use parent layouts", () => {
|
|
101
|
+
it("skips pure containers which use parent layouts", async () => {
|
|
102
102
|
let widget = (
|
|
103
103
|
<cx>
|
|
104
104
|
<div layout={FirstVisibleChildLayout}>
|
|
@@ -113,7 +113,7 @@ describe("FirstVisibleChildLayout", () => {
|
|
|
113
113
|
|
|
114
114
|
let store = new Store();
|
|
115
115
|
|
|
116
|
-
const component = createTestRenderer(store, widget);
|
|
116
|
+
const component = await createTestRenderer(store, widget);
|
|
117
117
|
|
|
118
118
|
let tree = component.toJSON();
|
|
119
119
|
assert.deepEqual(tree, {
|
|
@@ -123,7 +123,7 @@ describe("FirstVisibleChildLayout", () => {
|
|
|
123
123
|
});
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
-
it("works with functional components", () => {
|
|
126
|
+
it("works with functional components", async () => {
|
|
127
127
|
let FC = createFunctionalComponent(({ children }: { children?: any }) => <cx>{children}</cx>);
|
|
128
128
|
|
|
129
129
|
let widget = (
|
|
@@ -140,7 +140,7 @@ describe("FirstVisibleChildLayout", () => {
|
|
|
140
140
|
|
|
141
141
|
let store = new Store();
|
|
142
142
|
|
|
143
|
-
const component = createTestRenderer(store, widget);
|
|
143
|
+
const component = await createTestRenderer(store, widget);
|
|
144
144
|
|
|
145
145
|
let tree = component.toJSON();
|
|
146
146
|
assert.deepEqual(tree, {
|
|
@@ -150,7 +150,7 @@ describe("FirstVisibleChildLayout", () => {
|
|
|
150
150
|
});
|
|
151
151
|
});
|
|
152
152
|
|
|
153
|
-
it("properly destroys invisible items", () => {
|
|
153
|
+
it("properly destroys invisible items", async () => {
|
|
154
154
|
let destroyList: number[] = [];
|
|
155
155
|
let widget = (
|
|
156
156
|
<cx>
|
|
@@ -166,29 +166,41 @@ describe("FirstVisibleChildLayout", () => {
|
|
|
166
166
|
|
|
167
167
|
let store = new Store();
|
|
168
168
|
|
|
169
|
-
const component = createTestRenderer(store, widget);
|
|
169
|
+
const component = await createTestRenderer(store, widget);
|
|
170
170
|
|
|
171
|
-
|
|
171
|
+
await act(async () => {
|
|
172
|
+
store.set("index", 0);
|
|
173
|
+
});
|
|
172
174
|
component.toJSON();
|
|
173
175
|
assert.deepEqual(destroyList, []);
|
|
174
176
|
|
|
175
|
-
|
|
177
|
+
await act(async () => {
|
|
178
|
+
store.set("index", 3);
|
|
179
|
+
});
|
|
176
180
|
component.toJSON();
|
|
177
181
|
assert.deepEqual(destroyList, [0]);
|
|
178
182
|
|
|
179
|
-
|
|
183
|
+
await act(async () => {
|
|
184
|
+
store.set("index", 1);
|
|
185
|
+
});
|
|
180
186
|
component.toJSON();
|
|
181
187
|
assert.deepEqual(destroyList, [0, 3]);
|
|
182
188
|
|
|
183
|
-
|
|
189
|
+
await act(async () => {
|
|
190
|
+
store.set("index", 4);
|
|
191
|
+
});
|
|
184
192
|
component.toJSON();
|
|
185
193
|
assert.deepEqual(destroyList, [0, 3, 1]);
|
|
186
194
|
|
|
187
|
-
|
|
195
|
+
await act(async () => {
|
|
196
|
+
store.set("index", 0);
|
|
197
|
+
});
|
|
188
198
|
component.toJSON();
|
|
189
199
|
assert.deepEqual(destroyList, [0, 3, 1, 4]);
|
|
190
200
|
|
|
191
|
-
|
|
201
|
+
await act(async () => {
|
|
202
|
+
store.set("index", -1);
|
|
203
|
+
});
|
|
192
204
|
component.toJSON();
|
|
193
205
|
assert.deepEqual(destroyList, [0, 3, 1, 4, 0]);
|
|
194
206
|
});
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
import { PureContainerConfig } from "./../PureContainer";
|
|
2
|
-
import { Instance } from "../Instance";
|
|
3
|
-
import { PureContainer } from "../PureContainer";
|
|
4
|
-
import { RenderingContext } from "../RenderingContext";
|
|
5
|
-
|
|
6
|
-
function isVisibleDeep(instance: Instance): boolean {
|
|
7
|
-
if (instance.visible && (!instance.widget.isPureContainer || !instance.widget.useParentLayout)) return true;
|
|
8
|
-
if (instance.children) {
|
|
9
|
-
for (let i = 0; i < instance.children.length; i++) if (isVisibleDeep(instance.children[i])) return true;
|
|
10
|
-
}
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
class FirstVisibleChildItem extends PureContainer {
|
|
15
|
-
constructor(config: PureContainerConfig) {
|
|
16
|
-
super(config);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
checkVisible(context: RenderingContext, instance: any, data: any): boolean {
|
|
20
|
-
if (instance.parent.firstVisibleChild) return false;
|
|
21
|
-
return super.checkVisible(context, instance, data);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
explore(context: RenderingContext, instance: any): void {
|
|
25
|
-
if (instance.parent.firstVisibleChild) return;
|
|
26
|
-
super.explore(context, instance);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
exploreCleanup(context: RenderingContext, instance: any): void {
|
|
30
|
-
if (instance.parent.firstVisibleChild) return;
|
|
31
|
-
if (isVisibleDeep(instance)) instance.parent.firstVisibleChild = instance;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
render(context: RenderingContext, instance: any, key: any): any {
|
|
35
|
-
if (instance.parent.firstVisibleChild != instance) return null;
|
|
36
|
-
return super.render(context, instance, key);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
FirstVisibleChildItem.prototype.useParentLayout = true;
|
|
41
|
-
|
|
42
|
-
export class FirstVisibleChildLayout extends PureContainer {
|
|
43
|
-
explore(context: RenderingContext, instance: any): void {
|
|
44
|
-
instance.firstVisibleChild = null;
|
|
45
|
-
super.explore(context, instance);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
exploreCleanup(context: RenderingContext, instance: any): void {
|
|
49
|
-
let { children, firstVisibleChild } = instance;
|
|
50
|
-
if (children) {
|
|
51
|
-
for (let i = 0; i < children.length; i++) if (children[i] != firstVisibleChild) children[i].destroy();
|
|
52
|
-
}
|
|
53
|
-
instance.children = [];
|
|
54
|
-
if (firstVisibleChild) instance.children.push(firstVisibleChild);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
wrapItem(item: any): any {
|
|
58
|
-
return item instanceof FirstVisibleChildItem ? item : FirstVisibleChildItem.create({ items: item });
|
|
59
|
-
}
|
|
60
|
-
}
|
|
1
|
+
import { PureContainerConfig } from "./../PureContainer";
|
|
2
|
+
import { Instance } from "../Instance";
|
|
3
|
+
import { PureContainer } from "../PureContainer";
|
|
4
|
+
import { RenderingContext } from "../RenderingContext";
|
|
5
|
+
|
|
6
|
+
function isVisibleDeep(instance: Instance): boolean {
|
|
7
|
+
if (instance.visible && (!instance.widget.isPureContainer || !instance.widget.useParentLayout)) return true;
|
|
8
|
+
if (instance.children) {
|
|
9
|
+
for (let i = 0; i < instance.children.length; i++) if (isVisibleDeep(instance.children[i])) return true;
|
|
10
|
+
}
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
class FirstVisibleChildItem extends PureContainer {
|
|
15
|
+
constructor(config: PureContainerConfig) {
|
|
16
|
+
super(config);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
checkVisible(context: RenderingContext, instance: any, data: any): boolean {
|
|
20
|
+
if (instance.parent.firstVisibleChild) return false;
|
|
21
|
+
return super.checkVisible(context, instance, data);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
explore(context: RenderingContext, instance: any): void {
|
|
25
|
+
if (instance.parent.firstVisibleChild) return;
|
|
26
|
+
super.explore(context, instance);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
exploreCleanup(context: RenderingContext, instance: any): void {
|
|
30
|
+
if (instance.parent.firstVisibleChild) return;
|
|
31
|
+
if (isVisibleDeep(instance)) instance.parent.firstVisibleChild = instance;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
render(context: RenderingContext, instance: any, key: any): any {
|
|
35
|
+
if (instance.parent.firstVisibleChild != instance) return null;
|
|
36
|
+
return super.render(context, instance, key);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
FirstVisibleChildItem.prototype.useParentLayout = true;
|
|
41
|
+
|
|
42
|
+
export class FirstVisibleChildLayout extends PureContainer {
|
|
43
|
+
explore(context: RenderingContext, instance: any): void {
|
|
44
|
+
instance.firstVisibleChild = null;
|
|
45
|
+
super.explore(context, instance);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
exploreCleanup(context: RenderingContext, instance: any): void {
|
|
49
|
+
let { children, firstVisibleChild } = instance;
|
|
50
|
+
if (children) {
|
|
51
|
+
for (let i = 0; i < children.length; i++) if (children[i] != firstVisibleChild) children[i].destroy();
|
|
52
|
+
}
|
|
53
|
+
instance.children = [];
|
|
54
|
+
if (firstVisibleChild) instance.children.push(firstVisibleChild);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
wrapItem(item: any): any {
|
|
58
|
+
return item instanceof FirstVisibleChildItem ? item : FirstVisibleChildItem.create({ items: item });
|
|
59
|
+
}
|
|
60
|
+
}
|