cx 26.3.10 → 26.4.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/util/innerTextTrim.js +1 -1
- package/build/widgets/nav/Menu.d.ts +1 -0
- package/build/widgets/nav/Menu.d.ts.map +1 -1
- package/build/widgets/nav/Menu.js +3 -0
- package/dist/charts.css +10 -0
- package/dist/manifest.js +768 -768
- package/dist/util.js +1 -1
- package/dist/widgets.css +14 -6
- package/dist/widgets.js +3 -0
- package/package.json +4 -3
- package/src/charts/BarGraph.scss +31 -31
- package/src/charts/Legend.scss +57 -57
- package/src/charts/LegendEntry.scss +35 -35
- package/src/charts/LineGraph.scss +28 -28
- package/src/charts/Swimlane.scss +3 -0
- package/src/charts/Swimlanes.scss +3 -0
- package/src/charts/helpers/SnapPointFinder.ts +136 -136
- package/src/charts/helpers/ValueAtFinder.ts +72 -72
- package/src/charts/index.scss +2 -0
- package/src/data/createAccessorModelProxy.ts +66 -66
- package/src/ui/DataProxy.ts +55 -55
- package/src/ui/Repeater.spec.tsx +38 -0
- package/src/ui/Rescope.ts +50 -50
- package/src/ui/adapter/ArrayAdapter.ts +229 -229
- package/src/ui/exprHelpers.ts +96 -96
- package/src/ui/layout/LabelsTopLayout.scss +10 -0
- package/src/util/innerTextTrim.ts +1 -1
- package/src/util/scss/include.scss +69 -69
- package/src/widgets/Button.maps.scss +103 -103
- package/src/widgets/Sandbox.ts +104 -104
- package/src/widgets/form/Calendar.tsx +772 -772
- package/src/widgets/form/ColorField.scss +112 -112
- package/src/widgets/form/DateTimeField.scss +111 -111
- package/src/widgets/form/LookupField.maps.scss +26 -26
- package/src/widgets/form/LookupField.scss +227 -227
- package/src/widgets/form/MonthField.scss +113 -113
- package/src/widgets/form/NumberField.scss +72 -72
- package/src/widgets/form/Select.scss +104 -104
- package/src/widgets/form/TextField.scss +66 -66
- package/src/widgets/form/variables.scss +114 -111
- package/src/widgets/grid/Grid.scss +657 -657
- package/src/widgets/grid/variables.scss +47 -47
- package/src/widgets/index.ts +63 -63
- package/src/widgets/nav/Menu.tsx +5 -0
- package/src/widgets/nav/MenuItem.scss +2 -2
- package/src/widgets/nav/MenuItem.tsx +525 -525
- package/src/widgets/nav/Tab.ts +122 -122
- package/src/widgets/overlay/Overlay.tsx +1028 -1028
- package/src/widgets/overlay/Window.tsx +320 -320
- package/src/widgets/variables.scss +61 -61
|
@@ -1,136 +1,136 @@
|
|
|
1
|
-
import { PointReducer, PointReducerConfig, PointReducerInstance, PointReducerAccumulator } from "./PointReducer";
|
|
2
|
-
import { RenderingContext } from "../../ui/RenderingContext";
|
|
3
|
-
import { NumberProp, Bind, Prop, DataRecord } from "../../ui/Prop";
|
|
4
|
-
import { AccessorChain } from "../../data/createAccessorModelProxy";
|
|
5
|
-
|
|
6
|
-
export interface SnapAccumulator extends PointReducerAccumulator {
|
|
7
|
-
cursor: {
|
|
8
|
-
x: number | null;
|
|
9
|
-
y: number | null;
|
|
10
|
-
mapped: boolean;
|
|
11
|
-
mappedX?: number | null;
|
|
12
|
-
mappedY?: number | null;
|
|
13
|
-
};
|
|
14
|
-
dist: number;
|
|
15
|
-
snapX: any;
|
|
16
|
-
snapY: any;
|
|
17
|
-
snapRecord?: any;
|
|
18
|
-
xAxis: any;
|
|
19
|
-
yAxis: any;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface SnapPointFinderInstance extends PointReducerInstance<SnapAccumulator> {
|
|
23
|
-
xAxis?: any;
|
|
24
|
-
yAxis?: any;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface SnapPointFinderConfig extends PointReducerConfig {
|
|
28
|
-
/** Cursor X value. */
|
|
29
|
-
cursorX?: NumberProp;
|
|
30
|
-
|
|
31
|
-
/** Cursor Y value */
|
|
32
|
-
cursorY?: NumberProp;
|
|
33
|
-
|
|
34
|
-
/** A binding used to receive the x value of the nearest point.*/
|
|
35
|
-
snapX?: Bind | AccessorChain<number | null | undefined> | AccessorChain<string | null | undefined>;
|
|
36
|
-
|
|
37
|
-
/** A binding used to receive the y value of the nearest point. */
|
|
38
|
-
snapY?: Bind | AccessorChain<number | null | undefined> | AccessorChain<string | null | undefined>;
|
|
39
|
-
|
|
40
|
-
/** A binding used to receive the record prop */
|
|
41
|
-
snapRecord?: Prop<DataRecord>;
|
|
42
|
-
|
|
43
|
-
/** Maximum distance between cursor and the snap point. Default value is 50. Adjust accordingly for large distances, e.g. set to Infinity when using TimeAxis */
|
|
44
|
-
maxDistance?: number;
|
|
45
|
-
|
|
46
|
-
/** A function used to convert x values into numeric format. Commonly used with dates. */
|
|
47
|
-
convertX?: (value: number | string) => number;
|
|
48
|
-
|
|
49
|
-
/** A function used to convert y values into numeric format. Commonly used with dates. */
|
|
50
|
-
convertY?: (value: number | string) => number;
|
|
51
|
-
|
|
52
|
-
/** Name of the x-axis. Default is 'x'. */
|
|
53
|
-
xAxis?: string;
|
|
54
|
-
|
|
55
|
-
/** Name of the y-axis. Default is 'y'. */
|
|
56
|
-
yAxis?: string;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export class SnapPointFinder extends PointReducer<SnapAccumulator> {
|
|
60
|
-
declare maxDistance: number;
|
|
61
|
-
declare convertX: (value: any) => number;
|
|
62
|
-
declare convertY: (value: any) => number;
|
|
63
|
-
declare xAxis: string;
|
|
64
|
-
declare yAxis: string;
|
|
65
|
-
|
|
66
|
-
constructor(config?: SnapPointFinderConfig) {
|
|
67
|
-
super(config);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
declareData(...args: any[]) {
|
|
71
|
-
super.declareData(...args, {
|
|
72
|
-
cursorX: undefined,
|
|
73
|
-
cursorY: undefined,
|
|
74
|
-
snapX: undefined,
|
|
75
|
-
snapY: undefined,
|
|
76
|
-
snapRecord: undefined,
|
|
77
|
-
maxDistance: undefined,
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
explore(context: RenderingContext, instance: SnapPointFinderInstance) {
|
|
82
|
-
instance.xAxis = (context.axes as any)?.[this.xAxis];
|
|
83
|
-
instance.yAxis = (context.axes as any)?.[this.yAxis];
|
|
84
|
-
super.explore(context, instance);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
onInitAccumulator = (acc: SnapAccumulator, { data, xAxis, yAxis }: SnapPointFinderInstance) => {
|
|
88
|
-
const d = data as any;
|
|
89
|
-
acc.cursor = {
|
|
90
|
-
x: d.cursorX,
|
|
91
|
-
y: d.cursorY,
|
|
92
|
-
mapped: false,
|
|
93
|
-
};
|
|
94
|
-
acc.dist = d.maxDistance > 0 ? Math.pow(d.maxDistance, 2) : Number.POSITIVE_INFINITY;
|
|
95
|
-
acc.snapX = null;
|
|
96
|
-
acc.snapY = null;
|
|
97
|
-
acc.xAxis = xAxis;
|
|
98
|
-
acc.yAxis = yAxis;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
onMap = (acc: SnapAccumulator, x: any, y: any, name: string, p: any) => {
|
|
102
|
-
let { xAxis, yAxis, cursor } = acc;
|
|
103
|
-
|
|
104
|
-
if (!cursor.mapped) {
|
|
105
|
-
cursor.mappedX = cursor.x != null ? xAxis?.map(this.convertX(cursor.x)) : null;
|
|
106
|
-
cursor.mappedY = cursor.y != null ? yAxis?.map(this.convertY(cursor.y)) : null;
|
|
107
|
-
cursor.mapped = true;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
let d: number | null = null;
|
|
111
|
-
let cx = x != null ? xAxis?.map(this.convertX(x)) : null;
|
|
112
|
-
let cy = y != null ? yAxis?.map(this.convertY(y)) : null;
|
|
113
|
-
|
|
114
|
-
if (cursor.mappedX != null && cx != null) d = (d || 0) + Math.pow(Math.abs(cx - cursor.mappedX), 2);
|
|
115
|
-
if (cursor.mappedY != null && cy != null) d = (d || 0) + Math.pow(Math.abs(cy - cursor.mappedY), 2);
|
|
116
|
-
|
|
117
|
-
if (d != null && d < acc.dist) {
|
|
118
|
-
acc.dist = d;
|
|
119
|
-
acc.snapX = x;
|
|
120
|
-
acc.snapY = y;
|
|
121
|
-
acc.snapRecord = p;
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
onReduce = (acc: SnapAccumulator, instance: PointReducerInstance<SnapAccumulator>) => {
|
|
126
|
-
instance.set("snapX", acc.snapX);
|
|
127
|
-
instance.set("snapY", acc.snapY);
|
|
128
|
-
instance.set("snapRecord", acc.snapRecord);
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
SnapPointFinder.prototype.maxDistance = 50;
|
|
133
|
-
SnapPointFinder.prototype.convertX = (x) => x;
|
|
134
|
-
SnapPointFinder.prototype.convertY = (y) => y;
|
|
135
|
-
SnapPointFinder.prototype.xAxis = "x";
|
|
136
|
-
SnapPointFinder.prototype.yAxis = "y";
|
|
1
|
+
import { PointReducer, PointReducerConfig, PointReducerInstance, PointReducerAccumulator } from "./PointReducer";
|
|
2
|
+
import { RenderingContext } from "../../ui/RenderingContext";
|
|
3
|
+
import { NumberProp, Bind, Prop, DataRecord } from "../../ui/Prop";
|
|
4
|
+
import { AccessorChain } from "../../data/createAccessorModelProxy";
|
|
5
|
+
|
|
6
|
+
export interface SnapAccumulator extends PointReducerAccumulator {
|
|
7
|
+
cursor: {
|
|
8
|
+
x: number | null;
|
|
9
|
+
y: number | null;
|
|
10
|
+
mapped: boolean;
|
|
11
|
+
mappedX?: number | null;
|
|
12
|
+
mappedY?: number | null;
|
|
13
|
+
};
|
|
14
|
+
dist: number;
|
|
15
|
+
snapX: any;
|
|
16
|
+
snapY: any;
|
|
17
|
+
snapRecord?: any;
|
|
18
|
+
xAxis: any;
|
|
19
|
+
yAxis: any;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface SnapPointFinderInstance extends PointReducerInstance<SnapAccumulator> {
|
|
23
|
+
xAxis?: any;
|
|
24
|
+
yAxis?: any;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface SnapPointFinderConfig extends PointReducerConfig {
|
|
28
|
+
/** Cursor X value. */
|
|
29
|
+
cursorX?: NumberProp;
|
|
30
|
+
|
|
31
|
+
/** Cursor Y value */
|
|
32
|
+
cursorY?: NumberProp;
|
|
33
|
+
|
|
34
|
+
/** A binding used to receive the x value of the nearest point.*/
|
|
35
|
+
snapX?: Bind | AccessorChain<number | null | undefined> | AccessorChain<string | null | undefined>;
|
|
36
|
+
|
|
37
|
+
/** A binding used to receive the y value of the nearest point. */
|
|
38
|
+
snapY?: Bind | AccessorChain<number | null | undefined> | AccessorChain<string | null | undefined>;
|
|
39
|
+
|
|
40
|
+
/** A binding used to receive the record prop */
|
|
41
|
+
snapRecord?: Prop<DataRecord>;
|
|
42
|
+
|
|
43
|
+
/** Maximum distance between cursor and the snap point. Default value is 50. Adjust accordingly for large distances, e.g. set to Infinity when using TimeAxis */
|
|
44
|
+
maxDistance?: number;
|
|
45
|
+
|
|
46
|
+
/** A function used to convert x values into numeric format. Commonly used with dates. */
|
|
47
|
+
convertX?: (value: number | string) => number;
|
|
48
|
+
|
|
49
|
+
/** A function used to convert y values into numeric format. Commonly used with dates. */
|
|
50
|
+
convertY?: (value: number | string) => number;
|
|
51
|
+
|
|
52
|
+
/** Name of the x-axis. Default is 'x'. */
|
|
53
|
+
xAxis?: string;
|
|
54
|
+
|
|
55
|
+
/** Name of the y-axis. Default is 'y'. */
|
|
56
|
+
yAxis?: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export class SnapPointFinder extends PointReducer<SnapAccumulator> {
|
|
60
|
+
declare maxDistance: number;
|
|
61
|
+
declare convertX: (value: any) => number;
|
|
62
|
+
declare convertY: (value: any) => number;
|
|
63
|
+
declare xAxis: string;
|
|
64
|
+
declare yAxis: string;
|
|
65
|
+
|
|
66
|
+
constructor(config?: SnapPointFinderConfig) {
|
|
67
|
+
super(config);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
declareData(...args: any[]) {
|
|
71
|
+
super.declareData(...args, {
|
|
72
|
+
cursorX: undefined,
|
|
73
|
+
cursorY: undefined,
|
|
74
|
+
snapX: undefined,
|
|
75
|
+
snapY: undefined,
|
|
76
|
+
snapRecord: undefined,
|
|
77
|
+
maxDistance: undefined,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
explore(context: RenderingContext, instance: SnapPointFinderInstance) {
|
|
82
|
+
instance.xAxis = (context.axes as any)?.[this.xAxis];
|
|
83
|
+
instance.yAxis = (context.axes as any)?.[this.yAxis];
|
|
84
|
+
super.explore(context, instance);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
onInitAccumulator = (acc: SnapAccumulator, { data, xAxis, yAxis }: SnapPointFinderInstance) => {
|
|
88
|
+
const d = data as any;
|
|
89
|
+
acc.cursor = {
|
|
90
|
+
x: d.cursorX,
|
|
91
|
+
y: d.cursorY,
|
|
92
|
+
mapped: false,
|
|
93
|
+
};
|
|
94
|
+
acc.dist = d.maxDistance > 0 ? Math.pow(d.maxDistance, 2) : Number.POSITIVE_INFINITY;
|
|
95
|
+
acc.snapX = null;
|
|
96
|
+
acc.snapY = null;
|
|
97
|
+
acc.xAxis = xAxis;
|
|
98
|
+
acc.yAxis = yAxis;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
onMap = (acc: SnapAccumulator, x: any, y: any, name: string, p: any) => {
|
|
102
|
+
let { xAxis, yAxis, cursor } = acc;
|
|
103
|
+
|
|
104
|
+
if (!cursor.mapped) {
|
|
105
|
+
cursor.mappedX = cursor.x != null ? xAxis?.map(this.convertX(cursor.x)) : null;
|
|
106
|
+
cursor.mappedY = cursor.y != null ? yAxis?.map(this.convertY(cursor.y)) : null;
|
|
107
|
+
cursor.mapped = true;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
let d: number | null = null;
|
|
111
|
+
let cx = x != null ? xAxis?.map(this.convertX(x)) : null;
|
|
112
|
+
let cy = y != null ? yAxis?.map(this.convertY(y)) : null;
|
|
113
|
+
|
|
114
|
+
if (cursor.mappedX != null && cx != null) d = (d || 0) + Math.pow(Math.abs(cx - cursor.mappedX), 2);
|
|
115
|
+
if (cursor.mappedY != null && cy != null) d = (d || 0) + Math.pow(Math.abs(cy - cursor.mappedY), 2);
|
|
116
|
+
|
|
117
|
+
if (d != null && d < acc.dist) {
|
|
118
|
+
acc.dist = d;
|
|
119
|
+
acc.snapX = x;
|
|
120
|
+
acc.snapY = y;
|
|
121
|
+
acc.snapRecord = p;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
onReduce = (acc: SnapAccumulator, instance: PointReducerInstance<SnapAccumulator>) => {
|
|
126
|
+
instance.set("snapX", acc.snapX);
|
|
127
|
+
instance.set("snapY", acc.snapY);
|
|
128
|
+
instance.set("snapRecord", acc.snapRecord);
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
SnapPointFinder.prototype.maxDistance = 50;
|
|
133
|
+
SnapPointFinder.prototype.convertX = (x) => x;
|
|
134
|
+
SnapPointFinder.prototype.convertY = (y) => y;
|
|
135
|
+
SnapPointFinder.prototype.xAxis = "x";
|
|
136
|
+
SnapPointFinder.prototype.yAxis = "y";
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import { AccessorChain } from "../../data/createAccessorModelProxy";
|
|
2
|
-
import { Bind, Prop } from "../../ui/Prop";
|
|
3
|
-
import { PointReducer, PointReducerAccumulator, PointReducerConfig, PointReducerInstance } from "./PointReducer";
|
|
4
|
-
|
|
5
|
-
export interface ValueAtAccumulator extends PointReducerAccumulator {
|
|
6
|
-
at: number;
|
|
7
|
-
left?: { x: number; y: number; d: number };
|
|
8
|
-
right?: { x: number; y: number; d: number };
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface ValueAtFinderConfig extends PointReducerConfig {
|
|
12
|
-
/** X axis probe value. */
|
|
13
|
-
at?: Prop<string | number | null | undefined>;
|
|
14
|
-
|
|
15
|
-
/** A binding used to receive the measured y axis value */
|
|
16
|
-
value?: Bind | AccessorChain<number | null | undefined>;
|
|
17
|
-
|
|
18
|
-
/** A function used to convert x values into numeric format. Commonly used with dates. */
|
|
19
|
-
convert?: (value: number | string) => number;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/** Calculate value at a given point on the graph */
|
|
23
|
-
export class ValueAtFinder extends PointReducer<ValueAtAccumulator> {
|
|
24
|
-
declare convert: (value: any) => number;
|
|
25
|
-
|
|
26
|
-
constructor(config?: ValueAtFinderConfig) {
|
|
27
|
-
super(config);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
declareData(...args: any[]) {
|
|
31
|
-
super.declareData(...args, {
|
|
32
|
-
at: undefined,
|
|
33
|
-
value: undefined,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
onInitAccumulator = (acc: ValueAtAccumulator, { data }: PointReducerInstance<ValueAtAccumulator>) => {
|
|
38
|
-
acc.at = this.convert((data as any).at);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
onMap = (acc: ValueAtAccumulator, x: any, y: any, name: string) => {
|
|
42
|
-
let cx = this.convert(x);
|
|
43
|
-
let d = cx - acc.at;
|
|
44
|
-
if (d <= 0 && (!acc.left || acc.left.d < d)) {
|
|
45
|
-
acc.left = {
|
|
46
|
-
x: cx,
|
|
47
|
-
y,
|
|
48
|
-
d,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
if (d >= 0 && (!acc.right || acc.right.d > d)) {
|
|
52
|
-
acc.right = {
|
|
53
|
-
x: cx,
|
|
54
|
-
y,
|
|
55
|
-
d,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
onReduce = (acc: ValueAtAccumulator, instance: PointReducerInstance<ValueAtAccumulator>) => {
|
|
61
|
-
let y: number | null = null;
|
|
62
|
-
if (acc.left && acc.right) {
|
|
63
|
-
if (acc.left.x == acc.right.x) y = acc.left.y;
|
|
64
|
-
else if (acc.left.y != null && acc.right.y != null) {
|
|
65
|
-
y = acc.left.y + ((acc.right.y - acc.left.y) * (acc.at - acc.left.x)) / (acc.right.x - acc.left.x);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
instance.set("value", y);
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
ValueAtFinder.prototype.convert = (x) => x;
|
|
1
|
+
import { AccessorChain } from "../../data/createAccessorModelProxy";
|
|
2
|
+
import { Bind, Prop } from "../../ui/Prop";
|
|
3
|
+
import { PointReducer, PointReducerAccumulator, PointReducerConfig, PointReducerInstance } from "./PointReducer";
|
|
4
|
+
|
|
5
|
+
export interface ValueAtAccumulator extends PointReducerAccumulator {
|
|
6
|
+
at: number;
|
|
7
|
+
left?: { x: number; y: number; d: number };
|
|
8
|
+
right?: { x: number; y: number; d: number };
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ValueAtFinderConfig extends PointReducerConfig {
|
|
12
|
+
/** X axis probe value. */
|
|
13
|
+
at?: Prop<string | number | null | undefined>;
|
|
14
|
+
|
|
15
|
+
/** A binding used to receive the measured y axis value */
|
|
16
|
+
value?: Bind | AccessorChain<number | null | undefined>;
|
|
17
|
+
|
|
18
|
+
/** A function used to convert x values into numeric format. Commonly used with dates. */
|
|
19
|
+
convert?: (value: number | string) => number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Calculate value at a given point on the graph */
|
|
23
|
+
export class ValueAtFinder extends PointReducer<ValueAtAccumulator> {
|
|
24
|
+
declare convert: (value: any) => number;
|
|
25
|
+
|
|
26
|
+
constructor(config?: ValueAtFinderConfig) {
|
|
27
|
+
super(config);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
declareData(...args: any[]) {
|
|
31
|
+
super.declareData(...args, {
|
|
32
|
+
at: undefined,
|
|
33
|
+
value: undefined,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
onInitAccumulator = (acc: ValueAtAccumulator, { data }: PointReducerInstance<ValueAtAccumulator>) => {
|
|
38
|
+
acc.at = this.convert((data as any).at);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
onMap = (acc: ValueAtAccumulator, x: any, y: any, name: string) => {
|
|
42
|
+
let cx = this.convert(x);
|
|
43
|
+
let d = cx - acc.at;
|
|
44
|
+
if (d <= 0 && (!acc.left || acc.left.d < d)) {
|
|
45
|
+
acc.left = {
|
|
46
|
+
x: cx,
|
|
47
|
+
y,
|
|
48
|
+
d,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
if (d >= 0 && (!acc.right || acc.right.d > d)) {
|
|
52
|
+
acc.right = {
|
|
53
|
+
x: cx,
|
|
54
|
+
y,
|
|
55
|
+
d,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
onReduce = (acc: ValueAtAccumulator, instance: PointReducerInstance<ValueAtAccumulator>) => {
|
|
61
|
+
let y: number | null = null;
|
|
62
|
+
if (acc.left && acc.right) {
|
|
63
|
+
if (acc.left.x == acc.right.x) y = acc.left.y;
|
|
64
|
+
else if (acc.left.y != null && acc.right.y != null) {
|
|
65
|
+
y = acc.left.y + ((acc.right.y - acc.left.y) * (acc.at - acc.left.x)) / (acc.right.x - acc.left.x);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
instance.set("value", y);
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
ValueAtFinder.prototype.convert = (x) => x;
|
package/src/charts/index.scss
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
// Homomorphic mapped type preserves Go-to-Definition in IDEs
|
|
2
|
-
// -? strips optionality, as clause filters conflicting method names
|
|
3
|
-
type AccessorChainMap<M> = {
|
|
4
|
-
[K in keyof M as Exclude<K, "toString" | "valueOf" | "nameOf">]-?: AccessorChain<M[K]>;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
// Check if a type is `any` using the intersection trick
|
|
8
|
-
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
9
|
-
|
|
10
|
-
export type AccessorChain<M> = (IsAny<M> extends true
|
|
11
|
-
? { [key: string]: any } // Allow any property access for `any` type
|
|
12
|
-
: [M] extends [object]
|
|
13
|
-
? AccessorChainMap<M> // Direct mapping preserves IDE navigation
|
|
14
|
-
: [NonNullable<M>] extends [object]
|
|
15
|
-
? AccessorChainMap<NonNullable<M>> // Fallback for nullable types (e.g. optional properties)
|
|
16
|
-
: {}) & {
|
|
17
|
-
toString(): string;
|
|
18
|
-
valueOf(): M | undefined;
|
|
19
|
-
nameOf(): string;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const emptyFn = () => {};
|
|
23
|
-
|
|
24
|
-
export function createAccessorModelProxy<M>(chain: string = ""): AccessorChain<M> {
|
|
25
|
-
let lastOp: string | null = null;
|
|
26
|
-
|
|
27
|
-
const proxy = new Proxy(emptyFn, {
|
|
28
|
-
get: (_, name: string | symbol) => {
|
|
29
|
-
if (typeof name !== "string") return proxy;
|
|
30
|
-
|
|
31
|
-
switch (name) {
|
|
32
|
-
case "isAccessorChain":
|
|
33
|
-
return true;
|
|
34
|
-
|
|
35
|
-
case "toString":
|
|
36
|
-
case "valueOf":
|
|
37
|
-
case "nameOf":
|
|
38
|
-
lastOp = name;
|
|
39
|
-
return proxy;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
let newChain = chain;
|
|
43
|
-
if (newChain.length > 0) newChain += ".";
|
|
44
|
-
newChain += name;
|
|
45
|
-
return createAccessorModelProxy(newChain);
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
apply(): string {
|
|
49
|
-
switch (lastOp) {
|
|
50
|
-
case "nameOf":
|
|
51
|
-
const lastDotIndex = chain.lastIndexOf(".");
|
|
52
|
-
return lastDotIndex > 0 ? chain.substring(lastDotIndex + 1) : chain;
|
|
53
|
-
|
|
54
|
-
default:
|
|
55
|
-
return chain;
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
return proxy as unknown as AccessorChain<M>;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export const createModel = createAccessorModelProxy;
|
|
63
|
-
|
|
64
|
-
export function isAccessorChain<M>(value: unknown): value is AccessorChain<M> {
|
|
65
|
-
return value != null && !!(value as any).isAccessorChain;
|
|
66
|
-
}
|
|
1
|
+
// Homomorphic mapped type preserves Go-to-Definition in IDEs
|
|
2
|
+
// -? strips optionality, as clause filters conflicting method names
|
|
3
|
+
type AccessorChainMap<M> = {
|
|
4
|
+
[K in keyof M as Exclude<K, "toString" | "valueOf" | "nameOf">]-?: AccessorChain<M[K]>;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// Check if a type is `any` using the intersection trick
|
|
8
|
+
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
9
|
+
|
|
10
|
+
export type AccessorChain<M> = (IsAny<M> extends true
|
|
11
|
+
? { [key: string]: any } // Allow any property access for `any` type
|
|
12
|
+
: [M] extends [object]
|
|
13
|
+
? AccessorChainMap<M> // Direct mapping preserves IDE navigation
|
|
14
|
+
: [NonNullable<M>] extends [object]
|
|
15
|
+
? AccessorChainMap<NonNullable<M>> // Fallback for nullable types (e.g. optional properties)
|
|
16
|
+
: {}) & {
|
|
17
|
+
toString(): string;
|
|
18
|
+
valueOf(): M | undefined;
|
|
19
|
+
nameOf(): string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const emptyFn = () => {};
|
|
23
|
+
|
|
24
|
+
export function createAccessorModelProxy<M>(chain: string = ""): AccessorChain<M> {
|
|
25
|
+
let lastOp: string | null = null;
|
|
26
|
+
|
|
27
|
+
const proxy = new Proxy(emptyFn, {
|
|
28
|
+
get: (_, name: string | symbol) => {
|
|
29
|
+
if (typeof name !== "string") return proxy;
|
|
30
|
+
|
|
31
|
+
switch (name) {
|
|
32
|
+
case "isAccessorChain":
|
|
33
|
+
return true;
|
|
34
|
+
|
|
35
|
+
case "toString":
|
|
36
|
+
case "valueOf":
|
|
37
|
+
case "nameOf":
|
|
38
|
+
lastOp = name;
|
|
39
|
+
return proxy;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
let newChain = chain;
|
|
43
|
+
if (newChain.length > 0) newChain += ".";
|
|
44
|
+
newChain += name;
|
|
45
|
+
return createAccessorModelProxy(newChain);
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
apply(): string {
|
|
49
|
+
switch (lastOp) {
|
|
50
|
+
case "nameOf":
|
|
51
|
+
const lastDotIndex = chain.lastIndexOf(".");
|
|
52
|
+
return lastDotIndex > 0 ? chain.substring(lastDotIndex + 1) : chain;
|
|
53
|
+
|
|
54
|
+
default:
|
|
55
|
+
return chain;
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
return proxy as unknown as AccessorChain<M>;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const createModel = createAccessorModelProxy;
|
|
63
|
+
|
|
64
|
+
export function isAccessorChain<M>(value: unknown): value is AccessorChain<M> {
|
|
65
|
+
return value != null && !!(value as any).isAccessorChain;
|
|
66
|
+
}
|
package/src/ui/DataProxy.ts
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import { AccessorChain } from "../data";
|
|
2
|
-
import { NestedDataView } from "../data/NestedDataView";
|
|
3
|
-
import { StructuredProp, WritableProp } from "./Prop";
|
|
4
|
-
import { PureContainerBase, PureContainerConfig } from "./PureContainer";
|
|
5
|
-
import { StructuredInstanceDataAccessor } from "./StructuredInstanceDataAccessor";
|
|
6
|
-
|
|
7
|
-
export interface DataProxyConfig extends PureContainerConfig {
|
|
8
|
-
/** Data object with computed values to be exposed in the local store. */
|
|
9
|
-
data?: StructuredProp;
|
|
10
|
-
|
|
11
|
-
/** Binding to a value to be exposed under the `alias` name. */
|
|
12
|
-
value?: WritableProp<any>;
|
|
13
|
-
|
|
14
|
-
/** Alias name under which `value` is exposed in the local store. */
|
|
15
|
-
alias?: string | AccessorChain<any>;
|
|
16
|
-
|
|
17
|
-
/** Indicate that parent store data should not be mutated. */
|
|
18
|
-
immutable?: boolean;
|
|
19
|
-
|
|
20
|
-
/** Indicate that local store data should not be mutated. */
|
|
21
|
-
sealed?: boolean;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export class DataProxy extends PureContainerBase<DataProxyConfig> {
|
|
25
|
-
declare data?: any;
|
|
26
|
-
declare alias?: string;
|
|
27
|
-
declare value?: any;
|
|
28
|
-
declare immutable: boolean;
|
|
29
|
-
declare sealed: boolean;
|
|
30
|
-
|
|
31
|
-
init() {
|
|
32
|
-
if (!this.data) this.data = {};
|
|
33
|
-
|
|
34
|
-
if (this.alias) this.data[this.alias] = this.value;
|
|
35
|
-
|
|
36
|
-
super.init();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
initInstance(context: any, instance: any) {
|
|
40
|
-
instance.store = new NestedDataView({
|
|
41
|
-
store: instance.parentStore,
|
|
42
|
-
nestedData: new StructuredInstanceDataAccessor({ instance, data: this.data, useParentStore: true }),
|
|
43
|
-
immutable: this.immutable,
|
|
44
|
-
sealed: this.sealed,
|
|
45
|
-
});
|
|
46
|
-
super.initInstance(context, instance);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
applyParentStore(instance: any) {
|
|
50
|
-
instance.store.setStore(instance.parentStore);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
DataProxy.prototype.immutable = false;
|
|
55
|
-
DataProxy.prototype.sealed = false;
|
|
1
|
+
import { AccessorChain } from "../data";
|
|
2
|
+
import { NestedDataView } from "../data/NestedDataView";
|
|
3
|
+
import { StructuredProp, WritableProp } from "./Prop";
|
|
4
|
+
import { PureContainerBase, PureContainerConfig } from "./PureContainer";
|
|
5
|
+
import { StructuredInstanceDataAccessor } from "./StructuredInstanceDataAccessor";
|
|
6
|
+
|
|
7
|
+
export interface DataProxyConfig extends PureContainerConfig {
|
|
8
|
+
/** Data object with computed values to be exposed in the local store. */
|
|
9
|
+
data?: StructuredProp;
|
|
10
|
+
|
|
11
|
+
/** Binding to a value to be exposed under the `alias` name. */
|
|
12
|
+
value?: WritableProp<any>;
|
|
13
|
+
|
|
14
|
+
/** Alias name under which `value` is exposed in the local store. */
|
|
15
|
+
alias?: string | AccessorChain<any>;
|
|
16
|
+
|
|
17
|
+
/** Indicate that parent store data should not be mutated. */
|
|
18
|
+
immutable?: boolean;
|
|
19
|
+
|
|
20
|
+
/** Indicate that local store data should not be mutated. */
|
|
21
|
+
sealed?: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class DataProxy extends PureContainerBase<DataProxyConfig> {
|
|
25
|
+
declare data?: any;
|
|
26
|
+
declare alias?: string;
|
|
27
|
+
declare value?: any;
|
|
28
|
+
declare immutable: boolean;
|
|
29
|
+
declare sealed: boolean;
|
|
30
|
+
|
|
31
|
+
init() {
|
|
32
|
+
if (!this.data) this.data = {};
|
|
33
|
+
|
|
34
|
+
if (this.alias) this.data[this.alias] = this.value;
|
|
35
|
+
|
|
36
|
+
super.init();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
initInstance(context: any, instance: any) {
|
|
40
|
+
instance.store = new NestedDataView({
|
|
41
|
+
store: instance.parentStore,
|
|
42
|
+
nestedData: new StructuredInstanceDataAccessor({ instance, data: this.data, useParentStore: true }),
|
|
43
|
+
immutable: this.immutable,
|
|
44
|
+
sealed: this.sealed,
|
|
45
|
+
});
|
|
46
|
+
super.initInstance(context, instance);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
applyParentStore(instance: any) {
|
|
50
|
+
instance.store.setStore(instance.parentStore);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
DataProxy.prototype.immutable = false;
|
|
55
|
+
DataProxy.prototype.sealed = false;
|