cx 26.0.3 → 26.0.5
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/data/ArrayElementView.spec.js +1 -1
- package/build/hooks/store.spec.js +1 -1
- package/build/hooks/useTrigger.spec.js +1 -1
- package/build/ui/Controller.spec.js +2 -6
- package/build/ui/PureContainer.spec.d.ts +1 -0
- package/build/ui/PureContainer.spec.js +149 -0
- package/build/ui/layout/ContentPlaceholder.spec.js +12 -12
- package/build.js +129 -129
- package/dist/manifest.d.ts +1443 -0
- package/dist/manifest.js +826 -826
- package/package.json +4 -3
- package/src/charts/Chart.ts +108 -108
- package/src/data/ArrayElementView.ts +90 -90
- package/src/data/AugmentedViewBase.ts +88 -88
- package/src/data/Binding.ts +104 -104
- package/src/data/ExposedRecordView.ts +95 -95
- package/src/data/ExposedValueView.ts +89 -89
- package/src/data/Expression.spec.ts +229 -229
- package/src/data/Expression.ts +233 -233
- package/src/data/Grouper.spec.ts +57 -57
- package/src/data/Grouper.ts +158 -158
- package/src/data/NestedDataView.ts +43 -43
- package/src/data/ReadOnlyDataView.ts +39 -39
- package/src/data/Ref.ts +104 -104
- package/src/data/Selector.ts +10 -10
- package/src/data/Store.ts +52 -52
- package/src/data/StoreProxy.ts +19 -19
- package/src/data/StoreRef.ts +66 -66
- package/src/data/StringTemplate.spec.ts +132 -132
- package/src/data/StringTemplate.ts +93 -93
- package/src/data/StructuredSelector.spec.ts +113 -113
- package/src/data/StructuredSelector.ts +146 -146
- package/src/data/SubscribableView.ts +63 -63
- package/src/data/ZoomIntoPropertyView.spec.ts +64 -64
- package/src/data/ZoomIntoPropertyView.ts +45 -45
- package/src/data/computable.spec.ts +62 -62
- package/src/data/createAccessorModelProxy.ts +60 -60
- 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/removeTreeNodes.ts +15 -15
- package/src/data/ops/updateArray.spec.ts +69 -69
- package/src/data/ops/updateArray.ts +31 -31
- package/src/data/ops/updateTree.ts +23 -23
- package/src/data/test-types.ts +7 -7
- package/src/hooks/useTrigger.ts +26 -26
- package/src/index.scss +6 -6
- package/src/jsx-runtime.ts +72 -72
- package/src/svg/BoundedObject.ts +101 -101
- package/src/ui/CSSHelper.ts +17 -17
- package/src/ui/ContentResolver.ts +124 -124
- package/src/ui/Controller.ts +189 -189
- package/src/ui/Culture.ts +159 -159
- package/src/ui/DataProxy.ts +55 -55
- package/src/ui/FocusManager.ts +171 -171
- package/src/ui/Instance.ts +868 -868
- package/src/ui/RenderingContext.ts +99 -99
- package/src/ui/Rescope.ts +49 -49
- package/src/ui/StructuredInstanceDataAccessor.ts +32 -32
- package/src/ui/VDOM.ts +34 -34
- package/src/ui/adapter/ArrayAdapter.spec.ts +55 -55
- package/src/ui/adapter/ArrayAdapter.ts +226 -226
- 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/startHotAppLoop.ts +40 -40
- package/src/ui/createFunctionalComponent.ts +65 -65
- package/src/ui/index.ts +45 -45
- package/src/ui/layout/Content.ts +30 -30
- package/src/ui/layout/FirstVisibleChildLayout.ts +60 -60
- package/src/ui/selection/KeySelection.ts +165 -165
- package/src/ui/selection/PropertySelection.ts +87 -87
- package/src/ui/selection/Selection.ts +118 -118
- package/src/util/Format.ts +267 -267
- package/src/util/browserSupportsPassiveEventHandlers.ts +20 -20
- package/src/util/color/rgbToHsl.ts +35 -35
- package/src/util/getActiveElement.ts +4 -4
- package/src/util/hasKey.ts +18 -18
- package/src/util/index.ts +55 -55
- package/src/util/innerTextTrim.ts +10 -10
- package/src/util/isArray.ts +3 -3
- package/src/util/isDataRecord.ts +5 -5
- package/src/util/isDefined.ts +3 -3
- package/src/util/isString.ts +3 -3
- package/src/widgets/Sandbox.ts +103 -103
- package/src/widgets/autoFocus.ts +9 -9
- package/src/widgets/cx.ts +63 -63
- package/src/widgets/grid/GridCell.ts +143 -143
- package/src/widgets/icons/calendar.tsx +17 -17
- package/src/widgets/icons/check.tsx +13 -13
- package/src/widgets/icons/clear.tsx +15 -15
- package/src/widgets/icons/close.tsx +20 -20
- package/src/widgets/icons/cx.tsx +38 -38
- package/src/widgets/icons/drop-down.tsx +15 -15
- package/src/widgets/icons/file.tsx +13 -13
- package/src/widgets/icons/folder-open.tsx +15 -15
- package/src/widgets/icons/folder.tsx +13 -13
- package/src/widgets/icons/forward.tsx +22 -22
- package/src/widgets/icons/loading.tsx +24 -24
- package/src/widgets/icons/menu.tsx +17 -17
- package/src/widgets/icons/pixel-picker.tsx +18 -18
- package/src/widgets/icons/search.tsx +13 -13
- package/src/widgets/icons/sort-asc.tsx +14 -14
- package/src/widgets/icons/square.tsx +18 -18
- package/src/widgets/nav/Route.ts +142 -142
- package/src/widgets/overlay/ContextMenu.ts +42 -42
- package/src/widgets/overlay/Dropdown.tsx +762 -762
- package/src/widgets/overlay/MsgBox.tsx +141 -141
- package/src/widgets/overlay/Toast.ts +111 -111
- package/src/widgets/overlay/Window.tsx +299 -299
- package/src/widgets/overlay/alerts.ts +46 -46
- package/src/widgets/overlay/captureMouse.ts +195 -195
- package/src/widgets/overlay/createHotPromiseWindowFactory.ts +72 -72
- package/src/widgets/overlay/index.d.ts +11 -11
- package/src/widgets/overlay/index.ts +11 -11
- package/src/widgets/overlay/tooltip-ops.ts +173 -173
|
@@ -23,7 +23,7 @@ describe("ArrayElementView", function () {
|
|
|
23
23
|
let store = new Store({ data: { letters } });
|
|
24
24
|
let elementView = new ArrayElementView({ store, itemIndex: 1, arrayAccessor: getAccessor({ bind: "letters" }) });
|
|
25
25
|
elementView.delete("$record");
|
|
26
|
-
assert.deepEqual(store.get("letters"), [
|
|
26
|
+
assert.deepEqual(store.get("letters"), [letters[0]]);
|
|
27
27
|
});
|
|
28
28
|
it("exposes the element as under the given alias", function () {
|
|
29
29
|
let letters = [{ letter: "A" }, { letter: "B" }];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "cx/jsx-runtime";
|
|
2
2
|
import assert from "assert";
|
|
3
|
-
import { createTestRenderer } from "
|
|
3
|
+
import { createTestRenderer } from "../util/test/createTestRenderer";
|
|
4
4
|
import { computable } from "../data";
|
|
5
5
|
import { Store } from "../data/Store";
|
|
6
6
|
import { createFunctionalComponent } from "../ui/createFunctionalComponent";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "cx/jsx-runtime";
|
|
2
2
|
import assert from "assert";
|
|
3
|
-
import { createTestRenderer } from "
|
|
3
|
+
import { createTestRenderer } from "../util/test/createTestRenderer";
|
|
4
4
|
import { Store } from "../data/Store";
|
|
5
5
|
import { createFunctionalComponent } from "../ui/createFunctionalComponent";
|
|
6
6
|
import { useTrigger } from "./useTrigger";
|
|
@@ -39,10 +39,8 @@ describe("Controller", () => {
|
|
|
39
39
|
}
|
|
40
40
|
class Cmp extends Widget {
|
|
41
41
|
render(context, instance, key) {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
onInit(context, instance) {
|
|
45
42
|
instance.invoke("onTest");
|
|
43
|
+
return null;
|
|
46
44
|
}
|
|
47
45
|
}
|
|
48
46
|
let store = new Store();
|
|
@@ -65,10 +63,8 @@ describe("Controller", () => {
|
|
|
65
63
|
}
|
|
66
64
|
class Cmp extends Widget {
|
|
67
65
|
render(context, instance, key) {
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
onInit(context, instance) {
|
|
71
66
|
instance.invoke("onTest");
|
|
67
|
+
return null;
|
|
72
68
|
}
|
|
73
69
|
}
|
|
74
70
|
let store = new Store();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "cx/jsx-runtime";
|
|
2
|
+
import { Store } from "../data/Store";
|
|
3
|
+
import assert from "assert";
|
|
4
|
+
import { createTestRenderer } from "../util/test/createTestRenderer";
|
|
5
|
+
import { bind } from "./bind";
|
|
6
|
+
import { PureContainer } from "./PureContainer";
|
|
7
|
+
describe("PureContainer", () => {
|
|
8
|
+
it("renders static text children", () => {
|
|
9
|
+
let widget = (_jsx("cx", { children: _jsx(PureContainer, { children: _jsx("div", { children: "Test" }) }) }));
|
|
10
|
+
let store = new Store();
|
|
11
|
+
const component = createTestRenderer(store, widget);
|
|
12
|
+
let tree = component.toJSON();
|
|
13
|
+
assert(tree && !Array.isArray(tree), "Expected single element");
|
|
14
|
+
assert.deepEqual(tree, {
|
|
15
|
+
type: "div",
|
|
16
|
+
props: {},
|
|
17
|
+
children: ["Test"],
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
it("renders multiple children", () => {
|
|
21
|
+
let widget = (_jsx("cx", { children: _jsxs(PureContainer, { children: [_jsx("div", { children: "First" }), _jsx("div", { children: "Second" }), _jsx("div", { children: "Third" })] }) }));
|
|
22
|
+
let store = new Store();
|
|
23
|
+
const component = createTestRenderer(store, widget);
|
|
24
|
+
let tree = component.toJSON();
|
|
25
|
+
assert(Array.isArray(tree), "Expected array of elements");
|
|
26
|
+
assert.equal(tree.length, 3);
|
|
27
|
+
assert.deepEqual(tree, [
|
|
28
|
+
{
|
|
29
|
+
type: "div",
|
|
30
|
+
props: {},
|
|
31
|
+
children: ["First"],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
type: "div",
|
|
35
|
+
props: {},
|
|
36
|
+
children: ["Second"],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
type: "div",
|
|
40
|
+
props: {},
|
|
41
|
+
children: ["Third"],
|
|
42
|
+
},
|
|
43
|
+
]);
|
|
44
|
+
});
|
|
45
|
+
it("renders children with data bindings", () => {
|
|
46
|
+
let widget = (_jsx("cx", { children: _jsx(PureContainer, { children: _jsx("div", { text: bind("message") }) }) }));
|
|
47
|
+
let store = new Store({
|
|
48
|
+
data: {
|
|
49
|
+
message: "Hello World",
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
const component = createTestRenderer(store, widget);
|
|
53
|
+
let tree = component.toJSON();
|
|
54
|
+
assert(tree && !Array.isArray(tree), "Expected single element");
|
|
55
|
+
assert.deepEqual(tree, {
|
|
56
|
+
type: "div",
|
|
57
|
+
props: {},
|
|
58
|
+
children: ["Hello World"],
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
it("renders nested containers", () => {
|
|
62
|
+
let widget = (_jsx("cx", { children: _jsx(PureContainer, { children: _jsx("div", { children: _jsx(PureContainer, { children: _jsx("span", { children: "Nested" }) }) }) }) }));
|
|
63
|
+
let store = new Store();
|
|
64
|
+
const component = createTestRenderer(store, widget);
|
|
65
|
+
let tree = component.toJSON();
|
|
66
|
+
assert(tree && !Array.isArray(tree), "Expected single element");
|
|
67
|
+
assert.deepEqual(tree, {
|
|
68
|
+
type: "div",
|
|
69
|
+
props: {},
|
|
70
|
+
children: [
|
|
71
|
+
{
|
|
72
|
+
type: "span",
|
|
73
|
+
props: {},
|
|
74
|
+
children: ["Nested"],
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
it("conditionally renders children based on visible binding", () => {
|
|
80
|
+
let widget = (_jsx("cx", { children: _jsxs(PureContainer, { children: [_jsx("div", { visible: bind("show"), text: "Visible" }), _jsx("div", { visible: false, text: "Hidden" })] }) }));
|
|
81
|
+
let store = new Store({
|
|
82
|
+
data: {
|
|
83
|
+
show: true,
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
const component = createTestRenderer(store, widget);
|
|
87
|
+
let tree = component.toJSON();
|
|
88
|
+
assert(tree && !Array.isArray(tree), "Expected single element");
|
|
89
|
+
assert.deepEqual(tree, {
|
|
90
|
+
type: "div",
|
|
91
|
+
props: {},
|
|
92
|
+
children: ["Visible"],
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
it("handles empty children", () => {
|
|
96
|
+
let widget = (_jsx("cx", { children: _jsx(PureContainer, { children: _jsx("div", {}) }) }));
|
|
97
|
+
let store = new Store();
|
|
98
|
+
const component = createTestRenderer(store, widget);
|
|
99
|
+
let tree = component.toJSON();
|
|
100
|
+
assert(tree && !Array.isArray(tree), "Expected single element");
|
|
101
|
+
assert.deepEqual(tree, {
|
|
102
|
+
type: "div",
|
|
103
|
+
props: {},
|
|
104
|
+
children: null,
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
it("renders children from items property", () => {
|
|
108
|
+
let widget = (_jsx("cx", { children: _jsx(PureContainer, { items: [_jsx("div", { children: "Item 1" }, "1"), _jsx("div", { children: "Item 2" }, "2")] }) }));
|
|
109
|
+
let store = new Store();
|
|
110
|
+
const component = createTestRenderer(store, widget);
|
|
111
|
+
let tree = component.toJSON();
|
|
112
|
+
assert(Array.isArray(tree), "Expected array of elements");
|
|
113
|
+
assert.equal(tree.length, 2);
|
|
114
|
+
assert.deepEqual(tree[0], {
|
|
115
|
+
type: "div",
|
|
116
|
+
props: {},
|
|
117
|
+
children: ["Item 1"],
|
|
118
|
+
});
|
|
119
|
+
assert.deepEqual(tree[1], {
|
|
120
|
+
type: "div",
|
|
121
|
+
props: {},
|
|
122
|
+
children: ["Item 2"],
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
it("updates children when store data changes", () => {
|
|
126
|
+
let widget = (_jsx("cx", { children: _jsx(PureContainer, { children: _jsx("div", { text: bind("count") }) }) }));
|
|
127
|
+
let store = new Store({
|
|
128
|
+
data: {
|
|
129
|
+
count: 0,
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
const component = createTestRenderer(store, widget);
|
|
133
|
+
let tree = component.toJSON();
|
|
134
|
+
assert.deepEqual(tree, {
|
|
135
|
+
type: "div",
|
|
136
|
+
props: {},
|
|
137
|
+
children: ["0"],
|
|
138
|
+
});
|
|
139
|
+
// Update the store
|
|
140
|
+
store.set("count", 5);
|
|
141
|
+
// Re-render
|
|
142
|
+
tree = component.toJSON();
|
|
143
|
+
assert.deepEqual(tree, {
|
|
144
|
+
type: "div",
|
|
145
|
+
props: {},
|
|
146
|
+
children: ["5"],
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
});
|
|
@@ -8,7 +8,7 @@ import { bind } from "../bind";
|
|
|
8
8
|
describe("ContentPlaceholder", () => {
|
|
9
9
|
it("allows putting content inside", () => {
|
|
10
10
|
let store = new Store();
|
|
11
|
-
const component = createTestRenderer(store,
|
|
11
|
+
const component = createTestRenderer(store, _jsx("cx", { children: _jsxs("div", { children: [_jsx("header", { children: _jsx(ContentPlaceholder, { name: "header" }) }), _jsx("main", { children: _jsx("h2", { putInto: "header", children: "Header" }) })] }) }));
|
|
12
12
|
let tree = component.toJSON();
|
|
13
13
|
assert.deepEqual(tree, {
|
|
14
14
|
type: "div",
|
|
@@ -39,7 +39,7 @@ describe("ContentPlaceholder", () => {
|
|
|
39
39
|
headerText: "Header",
|
|
40
40
|
},
|
|
41
41
|
});
|
|
42
|
-
const component = createTestRenderer(store,
|
|
42
|
+
const component = createTestRenderer(store, _jsx("cx", { children: _jsxs("div", { children: [_jsx(ContentPlaceholder, { name: "header" }), _jsx("h2", { putInto: "header", text: bind("headerText") })] }) }));
|
|
43
43
|
let getTree = (headerText) => ({
|
|
44
44
|
type: "div",
|
|
45
45
|
props: {},
|
|
@@ -57,7 +57,7 @@ describe("ContentPlaceholder", () => {
|
|
|
57
57
|
});
|
|
58
58
|
it("allows putting multiple entries inside", () => {
|
|
59
59
|
let store = new Store();
|
|
60
|
-
const component = createTestRenderer(store,
|
|
60
|
+
const component = createTestRenderer(store, _jsx("cx", { children: _jsxs("div", { children: [_jsx("header", { children: _jsx(ContentPlaceholder, { name: "headers", allowMultiple: true }) }), _jsxs("main", { children: [_jsx("h2", { putInto: "headers", children: "Header1" }), _jsx("h2", { putInto: "headers", children: "Header2" })] })] }) }));
|
|
61
61
|
let tree = component.toJSON();
|
|
62
62
|
assert.deepEqual(tree, {
|
|
63
63
|
type: "div",
|
|
@@ -89,7 +89,7 @@ describe("ContentPlaceholder", () => {
|
|
|
89
89
|
});
|
|
90
90
|
it("allows putting multiple entries inside when content is defined before and after the placeholder", () => {
|
|
91
91
|
let store = new Store();
|
|
92
|
-
const component = createTestRenderer(store,
|
|
92
|
+
const component = createTestRenderer(store, _jsx("cx", { children: _jsxs("div", { children: [_jsxs(PureContainer, { children: [_jsx("h2", { putInto: "headers", children: "Header1" }), _jsx("h2", { putInto: "headers", children: "Header2" })] }), _jsx("header", { children: _jsx(ContentPlaceholder, { name: "headers", allowMultiple: true }) }), _jsxs(PureContainer, { children: [_jsx("h2", { putInto: "headers", children: "Header3" }), _jsx("h2", { putInto: "headers", children: "Header4" })] })] }) }));
|
|
93
93
|
let tree = component.toJSON();
|
|
94
94
|
assert.deepEqual(tree, {
|
|
95
95
|
type: "div",
|
|
@@ -126,7 +126,7 @@ describe("ContentPlaceholder", () => {
|
|
|
126
126
|
});
|
|
127
127
|
it("allows putting multiple entries into separate placeholders using content placeholder scopes", () => {
|
|
128
128
|
let store = new Store();
|
|
129
|
-
const component = createTestRenderer(store,
|
|
129
|
+
const component = createTestRenderer(store, _jsx("cx", { children: _jsxs("div", { children: [_jsxs(ContentPlaceholderScope, { name: "headers", children: [_jsx("h2", { putInto: "headers", children: "Header1" }), _jsx("h2", { putInto: "headers", children: "Header2" }), _jsx("header", { children: _jsx(ContentPlaceholder, { name: "headers", allowMultiple: true }) })] }), _jsxs(ContentPlaceholderScope, { name: "headers", children: [_jsx("header", { children: _jsx(ContentPlaceholder, { name: "headers", allowMultiple: true }) }), _jsx("h2", { putInto: "headers", children: "Header3" }), _jsx("h2", { putInto: "headers", children: "Header4" })] })] }) }));
|
|
130
130
|
let tree = component.toJSON();
|
|
131
131
|
assert.deepEqual(tree, {
|
|
132
132
|
type: "div",
|
|
@@ -170,7 +170,7 @@ describe("ContentPlaceholder", () => {
|
|
|
170
170
|
it("is used for defining body position in outer layouts", () => {
|
|
171
171
|
let store = new Store();
|
|
172
172
|
let layout = (_jsx("cx", { children: _jsxs("div", { children: [_jsx("header", { children: "Header" }), _jsx(ContentPlaceholder, {}), _jsx("footer", { children: "Footer" })] }) }));
|
|
173
|
-
const component = createTestRenderer(store,
|
|
173
|
+
const component = createTestRenderer(store, _jsx("cx", { children: _jsx("main", { outerLayout: layout }) }));
|
|
174
174
|
assert.deepEqual(component.toJSON(), {
|
|
175
175
|
type: "div",
|
|
176
176
|
props: {},
|
|
@@ -202,7 +202,7 @@ describe("ContentPlaceholder", () => {
|
|
|
202
202
|
},
|
|
203
203
|
});
|
|
204
204
|
let layout = (_jsx("cx", { children: _jsxs("div", { children: [_jsx("header", { children: _jsx(ContentPlaceholder, { name: "header" }) }), _jsx(ContentPlaceholder, {}), _jsx("footer", { children: _jsx(ContentPlaceholder, { name: "footer" }) })] }) }));
|
|
205
|
-
const component = createTestRenderer(store,
|
|
205
|
+
const component = createTestRenderer(store, _jsx("cx", { children: _jsxs("main", { outerLayout: layout, children: [_jsx("div", { putInto: "header", children: _jsx("span", { text: bind("header") }) }), _jsx("div", { putInto: "footer", children: _jsx("span", { text: bind("footer") }) }), _jsx("span", { text: bind("body") })] }) }));
|
|
206
206
|
let getTree = (h, b, f) => ({
|
|
207
207
|
type: "div",
|
|
208
208
|
props: {},
|
|
@@ -236,7 +236,7 @@ describe("ContentPlaceholder", () => {
|
|
|
236
236
|
let store = new Store();
|
|
237
237
|
let outerLayout = (_jsx("cx", { children: _jsx("div", { children: _jsx(ContentPlaceholder, {}) }) }));
|
|
238
238
|
let innerLayout = (_jsx("cx", { children: _jsx("main", { outerLayout: outerLayout, children: _jsx(ContentPlaceholder, {}) }) }));
|
|
239
|
-
const component = createTestRenderer(store,
|
|
239
|
+
const component = createTestRenderer(store, _jsx("cx", { children: _jsx("section", { outerLayout: innerLayout }) }));
|
|
240
240
|
let tree = component.toJSON();
|
|
241
241
|
//console.log(tree);
|
|
242
242
|
assert.deepEqual(tree, {
|
|
@@ -259,7 +259,7 @@ describe("ContentPlaceholder", () => {
|
|
|
259
259
|
});
|
|
260
260
|
it("works in strange order", () => {
|
|
261
261
|
let store = new Store();
|
|
262
|
-
const component = createTestRenderer(store,
|
|
262
|
+
const component = createTestRenderer(store, _jsx("cx", { children: _jsxs("div", { children: [_jsx(ContentPlaceholder, { name: "footer" }), _jsx(PureContainer, { putInto: "footer-content", children: "works" }), _jsxs(PureContainer, { putInto: "footer", children: ["It", _jsx(ContentPlaceholder, { name: "footer-content", children: "doesn't work" })] })] }) }));
|
|
263
263
|
let tree = component.toJSON();
|
|
264
264
|
//console.log(tree);
|
|
265
265
|
assert.deepEqual(tree, {
|
|
@@ -272,7 +272,7 @@ describe("ContentPlaceholder", () => {
|
|
|
272
272
|
let store = new Store();
|
|
273
273
|
let outerLayout = (_jsx("cx", { children: _jsx("div", { children: _jsx(ContentPlaceholder, {}) }) }));
|
|
274
274
|
let innerLayout = (_jsx("cx", { children: _jsx(PureContainer, { children: _jsx("main", { outerLayout: outerLayout, children: _jsx(ContentPlaceholder, {}) }) }) }));
|
|
275
|
-
const component = createTestRenderer(store,
|
|
275
|
+
const component = createTestRenderer(store, _jsx("cx", { children: _jsx("section", { outerLayout: innerLayout }) }));
|
|
276
276
|
assert.deepEqual(component.toJSON(), {
|
|
277
277
|
type: "div",
|
|
278
278
|
props: {},
|
|
@@ -283,7 +283,7 @@ describe("ContentPlaceholder", () => {
|
|
|
283
283
|
let store = new Store();
|
|
284
284
|
let outerLayout1 = (_jsx("cx", { children: _jsx("div", { children: _jsx(ContentPlaceholder, {}) }) }));
|
|
285
285
|
let outerLayout2 = (_jsx("cx", { children: _jsx("main", { children: _jsx(ContentPlaceholder, {}) }) }));
|
|
286
|
-
const component = createTestRenderer(store,
|
|
286
|
+
const component = createTestRenderer(store, _jsx("cx", { children: _jsx(PureContainer, { outerLayout: outerLayout1, children: _jsx(PureContainer, { outerLayout: outerLayout2, children: "Content" }) }) }));
|
|
287
287
|
assert.deepEqual(component.toJSON(), {
|
|
288
288
|
type: "div",
|
|
289
289
|
props: {},
|
|
@@ -300,7 +300,7 @@ describe("ContentPlaceholder", () => {
|
|
|
300
300
|
});
|
|
301
301
|
let outerLayout = (_jsx("cx", { children: _jsxs("div", { children: [_jsx(ContentPlaceholder, {}), _jsx("footer", { children: _jsx(ContentPlaceholder, { name: "footer" }) })] }) }));
|
|
302
302
|
let innerLayout = (_jsx("cx", { children: _jsx(PureContainer, { children: _jsxs(PureContainer, { outerLayout: outerLayout, children: [_jsx("header", { children: _jsx(ContentPlaceholder, { name: "header" }) }), _jsx(ContentPlaceholder, {})] }) }) }));
|
|
303
|
-
const component = createTestRenderer(store,
|
|
303
|
+
const component = createTestRenderer(store, _jsx("cx", { children: _jsxs("main", { outerLayout: innerLayout, children: [_jsx("div", { putInto: "header", children: _jsx("span", { text: bind("header") }) }), _jsx("div", { putInto: "footer", children: _jsx("span", { text: bind("footer") }) }), _jsx("span", { text: bind("body") })] }) }));
|
|
304
304
|
let getTree = (h, b, f) => ({
|
|
305
305
|
type: "div",
|
|
306
306
|
props: {},
|
package/build.js
CHANGED
|
@@ -1,129 +1,129 @@
|
|
|
1
|
-
const buildJS = require("cx-build-tools/buildJS"),
|
|
2
|
-
buildSCSS = require("cx-build-tools/buildSCSS"),
|
|
3
|
-
getPathResolver = require("cx-build-tools/getPathResolver"),
|
|
4
|
-
fs = require("fs"),
|
|
5
|
-
resolvePath = getPathResolver(__dirname),
|
|
6
|
-
cxSrc = getPathResolver(resolvePath("./src")),
|
|
7
|
-
cxBuild = getPathResolver(resolvePath("./build"));
|
|
8
|
-
|
|
9
|
-
const entries = [
|
|
10
|
-
{
|
|
11
|
-
name: "util",
|
|
12
|
-
options: {
|
|
13
|
-
input: cxBuild("util/index.js"),
|
|
14
|
-
},
|
|
15
|
-
output: {},
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
name: "data",
|
|
19
|
-
|
|
20
|
-
options: {
|
|
21
|
-
input: cxBuild("data/index.js"),
|
|
22
|
-
},
|
|
23
|
-
output: {},
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
name: "ui",
|
|
27
|
-
options: {
|
|
28
|
-
input: cxBuild("ui/index.js"),
|
|
29
|
-
},
|
|
30
|
-
output: {},
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
name: "widgets",
|
|
34
|
-
options: {
|
|
35
|
-
input: cxBuild("widgets/index.js"),
|
|
36
|
-
},
|
|
37
|
-
output: {},
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
name: "svg",
|
|
41
|
-
options: {
|
|
42
|
-
input: cxBuild("svg/index.js"),
|
|
43
|
-
},
|
|
44
|
-
output: {},
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
name: "charts",
|
|
48
|
-
options: {
|
|
49
|
-
input: cxBuild("charts/index.js"),
|
|
50
|
-
},
|
|
51
|
-
output: {},
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
name: "hooks",
|
|
55
|
-
options: {
|
|
56
|
-
input: cxBuild("hooks/index.js"),
|
|
57
|
-
},
|
|
58
|
-
output: {},
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
name: "jsx-runtime",
|
|
62
|
-
options: {
|
|
63
|
-
input: cxBuild("jsx-runtime.js"),
|
|
64
|
-
},
|
|
65
|
-
output: {},
|
|
66
|
-
},
|
|
67
|
-
];
|
|
68
|
-
|
|
69
|
-
const externalPaths = {
|
|
70
|
-
[cxBuild("./util/")]: "cx/util",
|
|
71
|
-
[cxBuild("./data/")]: "cx/data",
|
|
72
|
-
[cxBuild("./ui/")]: "cx/ui",
|
|
73
|
-
[cxBuild("./widgets")]: "cx/widgets",
|
|
74
|
-
[cxBuild("./charts")]: "cx/charts",
|
|
75
|
-
[cxBuild("./svg/")]: "cx/svg",
|
|
76
|
-
[cxBuild("./hooks/")]: "cx/hooks",
|
|
77
|
-
[cxBuild("./jsx-runtime")]: "cx/jsx-runtime",
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
(async function buildAll() {
|
|
81
|
-
console.log("Building cx...");
|
|
82
|
-
try {
|
|
83
|
-
let distPath = resolvePath("./dist");
|
|
84
|
-
if (!fs.existsSync(distPath)) {
|
|
85
|
-
fs.mkdirSync(distPath);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
await Promise.all([
|
|
89
|
-
buildJS(resolvePath("./src"), resolvePath("./dist"), entries, externalPaths),
|
|
90
|
-
buildSCSS([resolvePath("../cx-build-tools/reset.scss")], resolvePath("./dist/reset.css")),
|
|
91
|
-
buildSCSS(
|
|
92
|
-
[
|
|
93
|
-
cxSrc("variables.scss"),
|
|
94
|
-
resolvePath("../cx-build-tools/divide.scss"),
|
|
95
|
-
cxSrc("widgets/index.scss"),
|
|
96
|
-
cxSrc("ui/index.scss"),
|
|
97
|
-
],
|
|
98
|
-
resolvePath("./dist/widgets.css"),
|
|
99
|
-
),
|
|
100
|
-
buildSCSS(
|
|
101
|
-
[cxSrc("variables.scss"), resolvePath("../cx-build-tools/divide.scss"), cxSrc("charts/index.scss")],
|
|
102
|
-
resolvePath("./dist/charts.css"),
|
|
103
|
-
),
|
|
104
|
-
buildSCSS(
|
|
105
|
-
[cxSrc("variables.scss"), resolvePath("../cx-build-tools/divide.scss"), cxSrc("svg/index.scss")],
|
|
106
|
-
resolvePath("./dist/svg.css"),
|
|
107
|
-
),
|
|
108
|
-
]);
|
|
109
|
-
} catch (err) {
|
|
110
|
-
console.log("Build error.", err);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// console.log("Building cx-redux...");
|
|
114
|
-
// await build(
|
|
115
|
-
// resolvePath("../../cx-redux/src"),
|
|
116
|
-
// resolvePath("../../cx-redux/dist"),
|
|
117
|
-
// [
|
|
118
|
-
// {
|
|
119
|
-
// name: "index",
|
|
120
|
-
// options: {
|
|
121
|
-
// input: [resolvePath("../../cx-redux/src/index.js")]
|
|
122
|
-
// },
|
|
123
|
-
// output: {}
|
|
124
|
-
// }
|
|
125
|
-
// ],
|
|
126
|
-
// null,
|
|
127
|
-
// ["redux", "cx/data"]
|
|
128
|
-
// );
|
|
129
|
-
})();
|
|
1
|
+
const buildJS = require("cx-build-tools/buildJS"),
|
|
2
|
+
buildSCSS = require("cx-build-tools/buildSCSS"),
|
|
3
|
+
getPathResolver = require("cx-build-tools/getPathResolver"),
|
|
4
|
+
fs = require("fs"),
|
|
5
|
+
resolvePath = getPathResolver(__dirname),
|
|
6
|
+
cxSrc = getPathResolver(resolvePath("./src")),
|
|
7
|
+
cxBuild = getPathResolver(resolvePath("./build"));
|
|
8
|
+
|
|
9
|
+
const entries = [
|
|
10
|
+
{
|
|
11
|
+
name: "util",
|
|
12
|
+
options: {
|
|
13
|
+
input: cxBuild("util/index.js"),
|
|
14
|
+
},
|
|
15
|
+
output: {},
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: "data",
|
|
19
|
+
|
|
20
|
+
options: {
|
|
21
|
+
input: cxBuild("data/index.js"),
|
|
22
|
+
},
|
|
23
|
+
output: {},
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "ui",
|
|
27
|
+
options: {
|
|
28
|
+
input: cxBuild("ui/index.js"),
|
|
29
|
+
},
|
|
30
|
+
output: {},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "widgets",
|
|
34
|
+
options: {
|
|
35
|
+
input: cxBuild("widgets/index.js"),
|
|
36
|
+
},
|
|
37
|
+
output: {},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "svg",
|
|
41
|
+
options: {
|
|
42
|
+
input: cxBuild("svg/index.js"),
|
|
43
|
+
},
|
|
44
|
+
output: {},
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "charts",
|
|
48
|
+
options: {
|
|
49
|
+
input: cxBuild("charts/index.js"),
|
|
50
|
+
},
|
|
51
|
+
output: {},
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "hooks",
|
|
55
|
+
options: {
|
|
56
|
+
input: cxBuild("hooks/index.js"),
|
|
57
|
+
},
|
|
58
|
+
output: {},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "jsx-runtime",
|
|
62
|
+
options: {
|
|
63
|
+
input: cxBuild("jsx-runtime.js"),
|
|
64
|
+
},
|
|
65
|
+
output: {},
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
const externalPaths = {
|
|
70
|
+
[cxBuild("./util/")]: "cx/util",
|
|
71
|
+
[cxBuild("./data/")]: "cx/data",
|
|
72
|
+
[cxBuild("./ui/")]: "cx/ui",
|
|
73
|
+
[cxBuild("./widgets")]: "cx/widgets",
|
|
74
|
+
[cxBuild("./charts")]: "cx/charts",
|
|
75
|
+
[cxBuild("./svg/")]: "cx/svg",
|
|
76
|
+
[cxBuild("./hooks/")]: "cx/hooks",
|
|
77
|
+
[cxBuild("./jsx-runtime")]: "cx/jsx-runtime",
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
(async function buildAll() {
|
|
81
|
+
console.log("Building cx...");
|
|
82
|
+
try {
|
|
83
|
+
let distPath = resolvePath("./dist");
|
|
84
|
+
if (!fs.existsSync(distPath)) {
|
|
85
|
+
fs.mkdirSync(distPath);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
await Promise.all([
|
|
89
|
+
buildJS(resolvePath("./src"), resolvePath("./dist"), entries, externalPaths),
|
|
90
|
+
buildSCSS([resolvePath("../cx-build-tools/reset.scss")], resolvePath("./dist/reset.css")),
|
|
91
|
+
buildSCSS(
|
|
92
|
+
[
|
|
93
|
+
cxSrc("variables.scss"),
|
|
94
|
+
resolvePath("../cx-build-tools/divide.scss"),
|
|
95
|
+
cxSrc("widgets/index.scss"),
|
|
96
|
+
cxSrc("ui/index.scss"),
|
|
97
|
+
],
|
|
98
|
+
resolvePath("./dist/widgets.css"),
|
|
99
|
+
),
|
|
100
|
+
buildSCSS(
|
|
101
|
+
[cxSrc("variables.scss"), resolvePath("../cx-build-tools/divide.scss"), cxSrc("charts/index.scss")],
|
|
102
|
+
resolvePath("./dist/charts.css"),
|
|
103
|
+
),
|
|
104
|
+
buildSCSS(
|
|
105
|
+
[cxSrc("variables.scss"), resolvePath("../cx-build-tools/divide.scss"), cxSrc("svg/index.scss")],
|
|
106
|
+
resolvePath("./dist/svg.css"),
|
|
107
|
+
),
|
|
108
|
+
]);
|
|
109
|
+
} catch (err) {
|
|
110
|
+
console.log("Build error.", err);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// console.log("Building cx-redux...");
|
|
114
|
+
// await build(
|
|
115
|
+
// resolvePath("../../cx-redux/src"),
|
|
116
|
+
// resolvePath("../../cx-redux/dist"),
|
|
117
|
+
// [
|
|
118
|
+
// {
|
|
119
|
+
// name: "index",
|
|
120
|
+
// options: {
|
|
121
|
+
// input: [resolvePath("../../cx-redux/src/index.js")]
|
|
122
|
+
// },
|
|
123
|
+
// output: {}
|
|
124
|
+
// }
|
|
125
|
+
// ],
|
|
126
|
+
// null,
|
|
127
|
+
// ["redux", "cx/data"]
|
|
128
|
+
// );
|
|
129
|
+
})();
|