cx 26.4.2 → 26.4.3

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.
Files changed (38) hide show
  1. package/build/jsx-dev-runtime.d.ts +1 -0
  2. package/build/jsx-dev-runtime.d.ts.map +1 -1
  3. package/build/jsx-dev-runtime.js +1 -0
  4. package/dist/manifest.js +889 -889
  5. package/package.json +1 -1
  6. package/src/charts/BarGraph.scss +31 -31
  7. package/src/charts/Legend.scss +57 -57
  8. package/src/charts/LegendEntry.scss +35 -35
  9. package/src/charts/LineGraph.scss +28 -28
  10. package/src/charts/helpers/SnapPointFinder.ts +136 -136
  11. package/src/charts/helpers/ValueAtFinder.ts +72 -72
  12. package/src/data/createAccessorModelProxy.ts +66 -66
  13. package/src/jsx-dev-runtime.ts +1 -0
  14. package/src/ui/DataProxy.ts +55 -55
  15. package/src/ui/Repeater.spec.tsx +181 -181
  16. package/src/ui/Rescope.ts +50 -50
  17. package/src/ui/adapter/ArrayAdapter.ts +229 -229
  18. package/src/ui/exprHelpers.ts +96 -96
  19. package/src/util/scss/include.scss +69 -69
  20. package/src/widgets/Button.maps.scss +103 -103
  21. package/src/widgets/Sandbox.ts +104 -104
  22. package/src/widgets/form/Calendar.tsx +772 -772
  23. package/src/widgets/form/ColorField.scss +112 -112
  24. package/src/widgets/form/DateTimeField.scss +111 -111
  25. package/src/widgets/form/LookupField.maps.scss +26 -26
  26. package/src/widgets/form/LookupField.scss +227 -227
  27. package/src/widgets/form/MonthField.scss +113 -113
  28. package/src/widgets/form/NumberField.scss +72 -72
  29. package/src/widgets/form/Select.scss +104 -104
  30. package/src/widgets/form/TextField.scss +66 -66
  31. package/src/widgets/grid/Grid.scss +657 -657
  32. package/src/widgets/grid/variables.scss +47 -47
  33. package/src/widgets/index.ts +63 -63
  34. package/src/widgets/nav/MenuItem.scss +150 -150
  35. package/src/widgets/nav/MenuItem.tsx +525 -525
  36. package/src/widgets/nav/Tab.ts +122 -122
  37. package/src/widgets/overlay/Overlay.tsx +1029 -1029
  38. package/src/widgets/variables.scss +61 -61
@@ -1,181 +1,181 @@
1
- import { Store } from "../data/Store";
2
- import { Repeater } from "./Repeater";
3
- import { bind } from "./bind";
4
- import { createTestRenderer, act } from "../util/test/createTestRenderer";
5
- import { createAccessorModelProxy } from "../data/createAccessorModelProxy";
6
-
7
- import assert from "assert";
8
-
9
- describe("Repeater", () => {
10
- it("allows sorting", async () => {
11
- let data = [
12
- {
13
- value: "C",
14
- },
15
- {
16
- value: "B",
17
- },
18
- {
19
- value: "A",
20
- },
21
- ];
22
-
23
- let widget = (
24
- <cx>
25
- <div>
26
- <Repeater records={data} sorters={[{ field: "value", direction: "ASC" }]} recordAlias="$item">
27
- <div text={bind("$item.value")} />
28
- </Repeater>
29
- </div>
30
- </cx>
31
- );
32
-
33
- let store = new Store();
34
-
35
- const component = await createTestRenderer(store, widget);
36
-
37
- let tree = component.toJSON();
38
- assert.deepEqual(tree, {
39
- type: "div",
40
- props: {},
41
- children: [
42
- {
43
- type: "div",
44
- props: {},
45
- children: ["A"],
46
- },
47
- {
48
- type: "div",
49
- props: {},
50
- children: ["B"],
51
- },
52
- {
53
- type: "div",
54
- props: {},
55
- children: ["C"],
56
- },
57
- ],
58
- });
59
- });
60
-
61
- it("changes are properly updated", async () => {
62
- let divInstances: any[] = [];
63
- let widget = (
64
- <cx>
65
- <div>
66
- <Repeater records={bind("data")} sorters={[{ field: "value", direction: "ASC" }]} recordAlias="$item">
67
- <div
68
- text={bind("$item.value")}
69
- onExplore={(context, instance) => {
70
- divInstances.push(instance);
71
- }}
72
- />
73
- </Repeater>
74
- </div>
75
- </cx>
76
- );
77
-
78
- let store = new Store({
79
- data: {
80
- data: [
81
- {
82
- value: "C",
83
- },
84
- {
85
- value: "B",
86
- },
87
- ],
88
- },
89
- });
90
-
91
- const component = await createTestRenderer(store, widget);
92
-
93
- let tree = component.toJSON();
94
- assert.deepEqual(tree, {
95
- type: "div",
96
- props: {},
97
- children: [
98
- {
99
- type: "div",
100
- props: {},
101
- children: ["B"],
102
- },
103
- {
104
- type: "div",
105
- props: {},
106
- children: ["C"],
107
- },
108
- ],
109
- });
110
-
111
- divInstances = [];
112
-
113
- await act(async () => {
114
- store.update("data", (data) => [{ value: "A" }, ...data]);
115
- });
116
-
117
- assert.deepEqual(component.toJSON(), {
118
- type: "div",
119
- props: {},
120
- children: [
121
- {
122
- type: "div",
123
- props: {},
124
- children: ["A"],
125
- },
126
- {
127
- type: "div",
128
- props: {},
129
- children: ["B"],
130
- },
131
- {
132
- type: "div",
133
- props: {},
134
- children: ["C"],
135
- },
136
- ],
137
- });
138
-
139
- assert.equal(divInstances.length, 3);
140
- assert.equal(divInstances[0].store.get("$item.value"), "A");
141
- assert.equal(divInstances[1].store.get("$item.value"), "B");
142
- assert.equal(divInstances[2].store.get("$item.value"), "C");
143
- });
144
-
145
- it("infers T from AccessorChain<T[]> for onCreateFilter callback", () => {
146
- interface Item {
147
- name: string;
148
- active: boolean;
149
- }
150
-
151
- interface AppModel {
152
- items: Item[];
153
- $item: Item;
154
- }
155
-
156
- const m = createAccessorModelProxy<AppModel>();
157
-
158
- // onCreateFilter should receive (record: Item) => boolean when T is inferred from AccessorChain<Item[]>
159
- const widget = (
160
- <cx>
161
- <div>
162
- <Repeater
163
- records={m.items}
164
- recordAlias={m.$item}
165
- onCreateFilter={() => (record) => {
166
- // If T is correctly inferred as Item, record.name should be string
167
- const name: string = record.name;
168
- // @ts-expect-error - record.name should be string, not number
169
- const wrong: number = record.name;
170
- return record.active;
171
- }}
172
- >
173
- <div text={m.$item.name} />
174
- </Repeater>
175
- </div>
176
- </cx>
177
- );
178
-
179
- assert.ok(widget);
180
- });
181
- });
1
+ import { Store } from "../data/Store";
2
+ import { Repeater } from "./Repeater";
3
+ import { bind } from "./bind";
4
+ import { createTestRenderer, act } from "../util/test/createTestRenderer";
5
+ import { createAccessorModelProxy } from "../data/createAccessorModelProxy";
6
+
7
+ import assert from "assert";
8
+
9
+ describe("Repeater", () => {
10
+ it("allows sorting", async () => {
11
+ let data = [
12
+ {
13
+ value: "C",
14
+ },
15
+ {
16
+ value: "B",
17
+ },
18
+ {
19
+ value: "A",
20
+ },
21
+ ];
22
+
23
+ let widget = (
24
+ <cx>
25
+ <div>
26
+ <Repeater records={data} sorters={[{ field: "value", direction: "ASC" }]} recordAlias="$item">
27
+ <div text={bind("$item.value")} />
28
+ </Repeater>
29
+ </div>
30
+ </cx>
31
+ );
32
+
33
+ let store = new Store();
34
+
35
+ const component = await createTestRenderer(store, widget);
36
+
37
+ let tree = component.toJSON();
38
+ assert.deepEqual(tree, {
39
+ type: "div",
40
+ props: {},
41
+ children: [
42
+ {
43
+ type: "div",
44
+ props: {},
45
+ children: ["A"],
46
+ },
47
+ {
48
+ type: "div",
49
+ props: {},
50
+ children: ["B"],
51
+ },
52
+ {
53
+ type: "div",
54
+ props: {},
55
+ children: ["C"],
56
+ },
57
+ ],
58
+ });
59
+ });
60
+
61
+ it("changes are properly updated", async () => {
62
+ let divInstances: any[] = [];
63
+ let widget = (
64
+ <cx>
65
+ <div>
66
+ <Repeater records={bind("data")} sorters={[{ field: "value", direction: "ASC" }]} recordAlias="$item">
67
+ <div
68
+ text={bind("$item.value")}
69
+ onExplore={(context, instance) => {
70
+ divInstances.push(instance);
71
+ }}
72
+ />
73
+ </Repeater>
74
+ </div>
75
+ </cx>
76
+ );
77
+
78
+ let store = new Store({
79
+ data: {
80
+ data: [
81
+ {
82
+ value: "C",
83
+ },
84
+ {
85
+ value: "B",
86
+ },
87
+ ],
88
+ },
89
+ });
90
+
91
+ const component = await createTestRenderer(store, widget);
92
+
93
+ let tree = component.toJSON();
94
+ assert.deepEqual(tree, {
95
+ type: "div",
96
+ props: {},
97
+ children: [
98
+ {
99
+ type: "div",
100
+ props: {},
101
+ children: ["B"],
102
+ },
103
+ {
104
+ type: "div",
105
+ props: {},
106
+ children: ["C"],
107
+ },
108
+ ],
109
+ });
110
+
111
+ divInstances = [];
112
+
113
+ await act(async () => {
114
+ store.update("data", (data) => [{ value: "A" }, ...data]);
115
+ });
116
+
117
+ assert.deepEqual(component.toJSON(), {
118
+ type: "div",
119
+ props: {},
120
+ children: [
121
+ {
122
+ type: "div",
123
+ props: {},
124
+ children: ["A"],
125
+ },
126
+ {
127
+ type: "div",
128
+ props: {},
129
+ children: ["B"],
130
+ },
131
+ {
132
+ type: "div",
133
+ props: {},
134
+ children: ["C"],
135
+ },
136
+ ],
137
+ });
138
+
139
+ assert.equal(divInstances.length, 3);
140
+ assert.equal(divInstances[0].store.get("$item.value"), "A");
141
+ assert.equal(divInstances[1].store.get("$item.value"), "B");
142
+ assert.equal(divInstances[2].store.get("$item.value"), "C");
143
+ });
144
+
145
+ it("infers T from AccessorChain<T[]> for onCreateFilter callback", () => {
146
+ interface Item {
147
+ name: string;
148
+ active: boolean;
149
+ }
150
+
151
+ interface AppModel {
152
+ items: Item[];
153
+ $item: Item;
154
+ }
155
+
156
+ const m = createAccessorModelProxy<AppModel>();
157
+
158
+ // onCreateFilter should receive (record: Item) => boolean when T is inferred from AccessorChain<Item[]>
159
+ const widget = (
160
+ <cx>
161
+ <div>
162
+ <Repeater
163
+ records={m.items}
164
+ recordAlias={m.$item}
165
+ onCreateFilter={() => (record) => {
166
+ // If T is correctly inferred as Item, record.name should be string
167
+ const name: string = record.name;
168
+ // @ts-expect-error - record.name should be string, not number
169
+ const wrong: number = record.name;
170
+ return record.active;
171
+ }}
172
+ >
173
+ <div text={m.$item.name} />
174
+ </Repeater>
175
+ </div>
176
+ </cx>
177
+ );
178
+
179
+ assert.ok(widget);
180
+ });
181
+ });
package/src/ui/Rescope.ts CHANGED
@@ -1,50 +1,50 @@
1
- import { Widget } from "./Widget";
2
- import { PureContainerBase, PureContainerConfig } from "./PureContainer";
3
- import { Binding } from "../data/Binding";
4
- import { ZoomIntoPropertyView } from "../data/ZoomIntoPropertyView";
5
- import { StructuredInstanceDataAccessor } from "./StructuredInstanceDataAccessor";
6
- import { isObject } from "../util/isObject";
7
- import { StructuredProp } from "./Prop";
8
- import { AccessorChain } from "../data/createAccessorModelProxy";
9
-
10
- export interface RescopeConfig extends PureContainerConfig {
11
- bind: string | AccessorChain<any>;
12
- rootName?: string | AccessorChain<any>;
13
- rootAlias?: string | AccessorChain<any>;
14
- data?: StructuredProp;
15
- }
16
-
17
- export class Rescope extends PureContainerBase<RescopeConfig> {
18
- declare bind: string;
19
- declare binding: any;
20
- declare rootAlias?: string;
21
- declare rootName: string;
22
- declare data?: any;
23
-
24
- init() {
25
- this.binding = Binding.get(this.bind);
26
- if (this.rootAlias) this.rootName = this.rootAlias;
27
- super.init();
28
- }
29
-
30
- initInstance(context: any, instance: any) {
31
- instance.store = new ZoomIntoPropertyView({
32
- store: instance.parentStore,
33
- binding: this.binding,
34
- rootName: this.rootName,
35
- nestedData: isObject(this.data)
36
- ? new StructuredInstanceDataAccessor({ instance, data: this.data, useParentStore: true })
37
- : undefined,
38
- });
39
- super.initInstance(context, instance);
40
- }
41
-
42
- applyParentStore(instance: any) {
43
- instance.store.setStore(instance.parentStore);
44
- }
45
- }
46
-
47
- Rescope.prototype.bind = "$page";
48
- Rescope.prototype.rootName = "$root";
49
-
50
- Widget.alias("rescope", Rescope);
1
+ import { Widget } from "./Widget";
2
+ import { PureContainerBase, PureContainerConfig } from "./PureContainer";
3
+ import { Binding } from "../data/Binding";
4
+ import { ZoomIntoPropertyView } from "../data/ZoomIntoPropertyView";
5
+ import { StructuredInstanceDataAccessor } from "./StructuredInstanceDataAccessor";
6
+ import { isObject } from "../util/isObject";
7
+ import { StructuredProp } from "./Prop";
8
+ import { AccessorChain } from "../data/createAccessorModelProxy";
9
+
10
+ export interface RescopeConfig extends PureContainerConfig {
11
+ bind: string | AccessorChain<any>;
12
+ rootName?: string | AccessorChain<any>;
13
+ rootAlias?: string | AccessorChain<any>;
14
+ data?: StructuredProp;
15
+ }
16
+
17
+ export class Rescope extends PureContainerBase<RescopeConfig> {
18
+ declare bind: string;
19
+ declare binding: any;
20
+ declare rootAlias?: string;
21
+ declare rootName: string;
22
+ declare data?: any;
23
+
24
+ init() {
25
+ this.binding = Binding.get(this.bind);
26
+ if (this.rootAlias) this.rootName = this.rootAlias;
27
+ super.init();
28
+ }
29
+
30
+ initInstance(context: any, instance: any) {
31
+ instance.store = new ZoomIntoPropertyView({
32
+ store: instance.parentStore,
33
+ binding: this.binding,
34
+ rootName: this.rootName,
35
+ nestedData: isObject(this.data)
36
+ ? new StructuredInstanceDataAccessor({ instance, data: this.data, useParentStore: true })
37
+ : undefined,
38
+ });
39
+ super.initInstance(context, instance);
40
+ }
41
+
42
+ applyParentStore(instance: any) {
43
+ instance.store.setStore(instance.parentStore);
44
+ }
45
+ }
46
+
47
+ Rescope.prototype.bind = "$page";
48
+ Rescope.prototype.rootName = "$root";
49
+
50
+ Widget.alias("rescope", Rescope);