cx 24.10.7 → 24.10.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/charts.js +11 -1
- package/dist/manifest.js +573 -573
- package/dist/ui.js +20 -3
- package/package.json +1 -1
- package/src/charts/axis/NumericAxis.js +4 -0
- package/src/charts/axis/TimeAxis.js +10 -1
- package/src/ui/Instance.js +614 -610
- package/src/ui/layout/ContentPlaceholder.js +17 -3
- package/src/ui/layout/ContentPlaceholder.spec.js +121 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Widget } from "../Widget";
|
|
2
2
|
import { PureContainer } from "../PureContainer";
|
|
3
3
|
import { isString } from "../../util/isString";
|
|
4
|
+
import { isNonEmptyArray } from "../../util/isNonEmptyArray";
|
|
4
5
|
|
|
5
6
|
export class ContentPlaceholder extends PureContainer {
|
|
6
7
|
declareData() {
|
|
@@ -13,12 +14,23 @@ export class ContentPlaceholder extends PureContainer {
|
|
|
13
14
|
instance.content = null;
|
|
14
15
|
let { data } = instance;
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
if (this.allowMultiple) {
|
|
18
|
+
const contentList = context.contentList && context.contentList[data.name];
|
|
19
|
+
if (isNonEmptyArray(contentList) && !this.scoped)
|
|
20
|
+
for (let i = 0; i < contentList.length; i++) this.setContent(context, instance, contentList[i]);
|
|
21
|
+
|
|
22
|
+
// in multi mode register a callback to allow for more entries to be added
|
|
19
23
|
context.pushNamedValue("contentPlaceholder", data.name, (content) => {
|
|
20
24
|
this.setContent(context, instance, content);
|
|
21
25
|
});
|
|
26
|
+
} else {
|
|
27
|
+
const content = context.content && context.content[data.name];
|
|
28
|
+
if (content && !this.scoped) this.setContent(context, instance, content);
|
|
29
|
+
else
|
|
30
|
+
context.pushNamedValue("contentPlaceholder", data.name, (content) => {
|
|
31
|
+
this.setContent(context, instance, content);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
22
34
|
|
|
23
35
|
if (this.scoped)
|
|
24
36
|
instance.unregisterContentPlaceholder = () => {
|
|
@@ -78,6 +90,7 @@ export class ContentPlaceholderScope extends PureContainer {
|
|
|
78
90
|
this.name.forEach((name) => {
|
|
79
91
|
context.pushNamedValue("contentPlaceholder", name, null);
|
|
80
92
|
context.pushNamedValue("content", name, null);
|
|
93
|
+
context.pushNamedValue("contentList", name, []);
|
|
81
94
|
});
|
|
82
95
|
super.explore(context, instance);
|
|
83
96
|
}
|
|
@@ -86,6 +99,7 @@ export class ContentPlaceholderScope extends PureContainer {
|
|
|
86
99
|
this.name.forEach((name) => {
|
|
87
100
|
context.popNamedValue("contentPlaceholder", name);
|
|
88
101
|
context.popNamedValue("content", name);
|
|
102
|
+
context.popNamedValue("contentList", name);
|
|
89
103
|
});
|
|
90
104
|
}
|
|
91
105
|
}
|
|
@@ -3,7 +3,7 @@ import { VDOM } from "../Widget";
|
|
|
3
3
|
import { HtmlElement } from "../../widgets/HtmlElement";
|
|
4
4
|
import { Store } from "../../data/Store";
|
|
5
5
|
import { Controller } from "../Controller";
|
|
6
|
-
import { ContentPlaceholder } from "./ContentPlaceholder";
|
|
6
|
+
import { ContentPlaceholder, ContentPlaceholderScope } from "./ContentPlaceholder";
|
|
7
7
|
|
|
8
8
|
import renderer from "react-test-renderer";
|
|
9
9
|
import assert from "assert";
|
|
@@ -128,6 +128,126 @@ describe("ContentPlaceholder", () => {
|
|
|
128
128
|
});
|
|
129
129
|
});
|
|
130
130
|
|
|
131
|
+
it("allows putting multiple entries inside when content is defined before and after the placeholder", () => {
|
|
132
|
+
let store = new Store();
|
|
133
|
+
const component = renderer.create(
|
|
134
|
+
<Cx store={store} subscribe immediate>
|
|
135
|
+
<div>
|
|
136
|
+
<PureContainer>
|
|
137
|
+
<h2 putInto="headers">Header1</h2>
|
|
138
|
+
<h2 putInto="headers">Header2</h2>
|
|
139
|
+
</PureContainer>
|
|
140
|
+
<header>
|
|
141
|
+
<ContentPlaceholder name="headers" allowMultiple />
|
|
142
|
+
</header>
|
|
143
|
+
<PureContainer>
|
|
144
|
+
<h2 putInto="headers">Header3</h2>
|
|
145
|
+
<h2 putInto="headers">Header4</h2>
|
|
146
|
+
</PureContainer>
|
|
147
|
+
</div>
|
|
148
|
+
</Cx>,
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
let tree = component.toJSON();
|
|
152
|
+
assert.deepEqual(tree, {
|
|
153
|
+
type: "div",
|
|
154
|
+
props: {},
|
|
155
|
+
children: [
|
|
156
|
+
{
|
|
157
|
+
type: "header",
|
|
158
|
+
props: {},
|
|
159
|
+
children: [
|
|
160
|
+
{
|
|
161
|
+
type: "h2",
|
|
162
|
+
props: {},
|
|
163
|
+
children: ["Header1"],
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
type: "h2",
|
|
167
|
+
props: {},
|
|
168
|
+
children: ["Header2"],
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
type: "h2",
|
|
172
|
+
props: {},
|
|
173
|
+
children: ["Header3"],
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
type: "h2",
|
|
177
|
+
props: {},
|
|
178
|
+
children: ["Header4"],
|
|
179
|
+
},
|
|
180
|
+
],
|
|
181
|
+
},
|
|
182
|
+
],
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it("allows putting multiple entries into separate placeholders using content placeholder scopes", () => {
|
|
187
|
+
let store = new Store();
|
|
188
|
+
const component = renderer.create(
|
|
189
|
+
<Cx store={store} subscribe immediate>
|
|
190
|
+
<div>
|
|
191
|
+
<ContentPlaceholderScope name="headers">
|
|
192
|
+
<h2 putInto="headers">Header1</h2>
|
|
193
|
+
<h2 putInto="headers">Header2</h2>
|
|
194
|
+
<header>
|
|
195
|
+
<ContentPlaceholder name="headers" allowMultiple />
|
|
196
|
+
</header>
|
|
197
|
+
</ContentPlaceholderScope>
|
|
198
|
+
|
|
199
|
+
<ContentPlaceholderScope name="headers">
|
|
200
|
+
<header>
|
|
201
|
+
<ContentPlaceholder name="headers" allowMultiple />
|
|
202
|
+
</header>
|
|
203
|
+
<h2 putInto="headers">Header3</h2>
|
|
204
|
+
<h2 putInto="headers">Header4</h2>
|
|
205
|
+
</ContentPlaceholderScope>
|
|
206
|
+
</div>
|
|
207
|
+
</Cx>,
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
let tree = component.toJSON();
|
|
211
|
+
assert.deepEqual(tree, {
|
|
212
|
+
type: "div",
|
|
213
|
+
props: {},
|
|
214
|
+
children: [
|
|
215
|
+
{
|
|
216
|
+
type: "header",
|
|
217
|
+
props: {},
|
|
218
|
+
children: [
|
|
219
|
+
{
|
|
220
|
+
type: "h2",
|
|
221
|
+
props: {},
|
|
222
|
+
children: ["Header1"],
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
type: "h2",
|
|
226
|
+
props: {},
|
|
227
|
+
children: ["Header2"],
|
|
228
|
+
},
|
|
229
|
+
],
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
type: "header",
|
|
233
|
+
props: {},
|
|
234
|
+
children: [
|
|
235
|
+
{
|
|
236
|
+
type: "h2",
|
|
237
|
+
props: {},
|
|
238
|
+
children: ["Header3"],
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
type: "h2",
|
|
242
|
+
props: {},
|
|
243
|
+
children: ["Header4"],
|
|
244
|
+
},
|
|
245
|
+
],
|
|
246
|
+
},
|
|
247
|
+
],
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
|
|
131
251
|
it("is used for defining body position in outer layouts", () => {
|
|
132
252
|
let store = new Store();
|
|
133
253
|
|