cx 26.7.6 → 26.9.0
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/charts/Legend.d.ts +8 -1
- package/build/charts/Legend.d.ts.map +1 -1
- package/build/charts/Legend.js +8 -4
- package/build/charts/LineGraph.d.ts +8 -16
- package/build/charts/LineGraph.d.ts.map +1 -1
- package/build/charts/LineGraph.js +76 -69
- package/build/charts/axis/NumericAxis.d.ts.map +1 -1
- package/build/charts/axis/NumericAxis.js +1 -254
- package/build/charts/axis/NumericScale.d.ts +59 -0
- package/build/charts/axis/NumericScale.d.ts.map +1 -0
- package/build/charts/axis/NumericScale.js +254 -0
- package/build/jsx-dev-runtime.d.ts +2 -1
- package/build/jsx-dev-runtime.d.ts.map +1 -1
- package/build/svg/Svg.d.ts +9 -0
- package/build/svg/Svg.d.ts.map +1 -1
- package/build/svg/Svg.js +9 -1
- package/build/ui/index.d.ts +3 -2
- package/build/ui/index.d.ts.map +1 -1
- package/build/ui/index.js +1 -1
- package/build/util/DOM.d.ts.map +1 -1
- package/build/util/DOM.js +16 -4
- package/build/util/getActiveElement.d.ts +1 -1
- package/build/util/getActiveElement.d.ts.map +1 -1
- package/build/util/getActiveElement.js +14 -2
- package/build/widgets/form/TextArea.d.ts +4 -0
- package/build/widgets/form/TextArea.d.ts.map +1 -1
- package/build/widgets/form/TextArea.js +7 -1
- package/build/widgets/grid/Grid.d.ts +12 -2
- package/build/widgets/grid/Grid.d.ts.map +1 -1
- package/build/widgets/grid/Grid.js +17 -4
- package/build/widgets/nav/MenuItem.js +2 -2
- package/build/widgets/overlay/Dropdown.d.ts +4 -4
- package/build/widgets/overlay/Dropdown.d.ts.map +1 -1
- package/build/widgets/overlay/Dropdown.js +82 -38
- package/build/widgets/overlay/Overlay.d.ts.map +1 -1
- package/build/widgets/overlay/Overlay.js +7 -3
- package/build/widgets/overlay/Window.d.ts.map +1 -1
- package/build/widgets/overlay/Window.js +2 -1
- package/dist/charts.js +166 -168
- package/dist/manifest.js +805 -802
- package/dist/svg.js +13 -0
- package/dist/util.js +31 -9
- package/dist/widgets.js +153 -50
- package/package.json +1 -1
- package/src/charts/Legend.tsx +22 -2
- package/src/charts/LineGraph.tsx +80 -98
- package/src/charts/axis/NumericAxis.spec.ts +40 -0
- package/src/charts/axis/NumericAxis.tsx +1 -290
- package/src/charts/axis/NumericScale.ts +290 -0
- package/src/jsx-dev-runtime.ts +2 -1
- package/src/svg/Svg.tsx +24 -1
- package/src/ui/Cx.tsx +505 -505
- package/src/ui/DataProxy.ts +55 -55
- package/src/ui/Rescope.ts +50 -50
- package/src/ui/exprHelpers.ts +96 -96
- package/src/ui/index.ts +3 -6
- package/src/util/DOM.ts +15 -4
- package/src/util/getActiveElement.ts +16 -2
- package/src/widgets/Sandbox.ts +104 -104
- 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/MonthField.scss +113 -113
- package/src/widgets/form/Select.scss +104 -104
- package/src/widgets/form/TextArea.tsx +10 -1
- package/src/widgets/form/TextField.scss +66 -66
- package/src/widgets/grid/Grid.sorting.spec.tsx +188 -0
- package/src/widgets/grid/Grid.tsx +31 -7
- package/src/widgets/index.ts +41 -41
- package/src/widgets/nav/MenuItem.tsx +2 -2
- package/src/widgets/overlay/Dropdown.tsx +87 -27
- package/src/widgets/overlay/Overlay.tsx +5 -3
- package/src/widgets/overlay/Window.tsx +2 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Stack } from "./Stack";
|
|
2
|
+
export declare class NumericScale {
|
|
3
|
+
min: number;
|
|
4
|
+
max: number;
|
|
5
|
+
snapToTicks: number;
|
|
6
|
+
tickDivisions: number[][];
|
|
7
|
+
minLabelDistance: number;
|
|
8
|
+
minLabelTickSize: number;
|
|
9
|
+
minTickDistance: number;
|
|
10
|
+
minTickStep: number;
|
|
11
|
+
tickSizes: number[];
|
|
12
|
+
normalized: boolean;
|
|
13
|
+
inverted: boolean;
|
|
14
|
+
minValue?: number;
|
|
15
|
+
maxValue?: number;
|
|
16
|
+
minValuePadded: number;
|
|
17
|
+
maxValuePadded: number;
|
|
18
|
+
stacks: Record<string, Stack>;
|
|
19
|
+
lowerDeadZone: number;
|
|
20
|
+
upperDeadZone: number;
|
|
21
|
+
origin: number;
|
|
22
|
+
scale: {
|
|
23
|
+
factor: number;
|
|
24
|
+
min: number;
|
|
25
|
+
max: number;
|
|
26
|
+
minPadding: number;
|
|
27
|
+
maxPadding: number;
|
|
28
|
+
};
|
|
29
|
+
a: number;
|
|
30
|
+
b: number;
|
|
31
|
+
shouldUpdate: boolean;
|
|
32
|
+
reset(min: number, max: number, snapToTicks: number, tickDivisions: number[][], minTickDistance: number, minTickStep: number, minLabelDistance: number, minLabelTickSize: number, normalized: boolean, inverted: boolean, lowerDeadZone: number, upperDeadZone: number): void;
|
|
33
|
+
map(v: number, offset?: number): number;
|
|
34
|
+
decodeValue(n: number): number;
|
|
35
|
+
encodeValue(v: number): number;
|
|
36
|
+
constrainValue(v: number): number;
|
|
37
|
+
trackValue(v: number, offset?: number, constrain?: boolean): number;
|
|
38
|
+
hash(): any;
|
|
39
|
+
isSame(x: any): boolean;
|
|
40
|
+
measure(a: number, b: number): void;
|
|
41
|
+
getScale(tickSizes?: number[]): {
|
|
42
|
+
factor: number;
|
|
43
|
+
min: number;
|
|
44
|
+
max: number;
|
|
45
|
+
minPadding: number;
|
|
46
|
+
maxPadding: number;
|
|
47
|
+
};
|
|
48
|
+
acknowledge(value: number, width?: number, offset?: number): void;
|
|
49
|
+
getStack(name: string): Stack;
|
|
50
|
+
stacknowledge(name: string, ordinal: any, value: any): any;
|
|
51
|
+
stack(name: string, ordinal: any, value: any): number | null;
|
|
52
|
+
findTickSize(minPxDist: number): number | undefined;
|
|
53
|
+
getTickSizes(): number[];
|
|
54
|
+
calculateTicks(): void;
|
|
55
|
+
getTicks(tickSizes: number[]): number[][];
|
|
56
|
+
mapGridlines(): number[];
|
|
57
|
+
book(): void;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=NumericScale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumericScale.d.ts","sourceRoot":"","sources":["../../../src/charts/axis/NumericScale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAIhC,qBAAa,YAAY;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,EAAE,EAAE,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5F,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,YAAY,EAAE,OAAO,CAAC;IAEtB,KAAK,CACF,GAAG,EAAE,MAAM,E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AC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,GAAG,MAAM,GAAG,IAAI;IAK5D,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAInD,YAAY,IAAI,MAAM,EAAE;IAIxB,cAAc,IAAI,IAAI;IAsCtB,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE;IAUzC,YAAY,IAAI,MAAM,EAAE;IASxB,IAAI,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { Stack } from "./Stack";
|
|
2
|
+
import { isNumber } from "../../util/isNumber";
|
|
3
|
+
import { Console } from "../../util/Console";
|
|
4
|
+
export class NumericScale {
|
|
5
|
+
min;
|
|
6
|
+
max;
|
|
7
|
+
snapToTicks;
|
|
8
|
+
tickDivisions;
|
|
9
|
+
minLabelDistance;
|
|
10
|
+
minLabelTickSize;
|
|
11
|
+
minTickDistance;
|
|
12
|
+
minTickStep;
|
|
13
|
+
tickSizes;
|
|
14
|
+
normalized;
|
|
15
|
+
inverted;
|
|
16
|
+
minValue;
|
|
17
|
+
maxValue;
|
|
18
|
+
minValuePadded;
|
|
19
|
+
maxValuePadded;
|
|
20
|
+
stacks;
|
|
21
|
+
lowerDeadZone;
|
|
22
|
+
upperDeadZone;
|
|
23
|
+
origin;
|
|
24
|
+
scale;
|
|
25
|
+
a;
|
|
26
|
+
b;
|
|
27
|
+
shouldUpdate;
|
|
28
|
+
reset(min, max, snapToTicks, tickDivisions, minTickDistance, minTickStep, minLabelDistance, minLabelTickSize, normalized, inverted, lowerDeadZone, upperDeadZone) {
|
|
29
|
+
this.min = min;
|
|
30
|
+
this.max = max;
|
|
31
|
+
this.snapToTicks = snapToTicks;
|
|
32
|
+
this.tickDivisions = tickDivisions;
|
|
33
|
+
this.minLabelDistance = minLabelDistance;
|
|
34
|
+
this.minLabelTickSize = minLabelTickSize;
|
|
35
|
+
this.minTickDistance = minTickDistance;
|
|
36
|
+
this.minTickStep = minTickStep;
|
|
37
|
+
this.tickSizes = [];
|
|
38
|
+
this.normalized = normalized;
|
|
39
|
+
this.inverted = inverted;
|
|
40
|
+
delete this.minValue;
|
|
41
|
+
delete this.maxValue;
|
|
42
|
+
this.stacks = {};
|
|
43
|
+
this.lowerDeadZone = lowerDeadZone || 0;
|
|
44
|
+
this.upperDeadZone = upperDeadZone || 0;
|
|
45
|
+
}
|
|
46
|
+
map(v, offset = 0) {
|
|
47
|
+
return this.origin + (v + offset - this.scale.min + this.scale.minPadding) * this.scale.factor;
|
|
48
|
+
}
|
|
49
|
+
decodeValue(n) {
|
|
50
|
+
return n;
|
|
51
|
+
}
|
|
52
|
+
encodeValue(v) {
|
|
53
|
+
return v;
|
|
54
|
+
}
|
|
55
|
+
constrainValue(v) {
|
|
56
|
+
return Math.max(this.scale.min, Math.min(this.scale.max, v));
|
|
57
|
+
}
|
|
58
|
+
trackValue(v, offset = 0, constrain = false) {
|
|
59
|
+
let value = (v - this.origin) / this.scale.factor - offset + this.scale.min - this.scale.minPadding;
|
|
60
|
+
if (constrain)
|
|
61
|
+
value = this.constrainValue(value);
|
|
62
|
+
return value;
|
|
63
|
+
}
|
|
64
|
+
hash() {
|
|
65
|
+
let r = {
|
|
66
|
+
origin: this.origin,
|
|
67
|
+
factor: this.scale.factor,
|
|
68
|
+
min: this.scale.min,
|
|
69
|
+
max: this.scale.max,
|
|
70
|
+
minPadding: this.scale.minPadding,
|
|
71
|
+
maxPadding: this.scale.maxPadding,
|
|
72
|
+
};
|
|
73
|
+
r.stacks = Object.keys(this.stacks)
|
|
74
|
+
.map((s) => this.stacks[s].info?.join(","))
|
|
75
|
+
.join(":");
|
|
76
|
+
return r;
|
|
77
|
+
}
|
|
78
|
+
isSame(x) {
|
|
79
|
+
let hash = this.hash();
|
|
80
|
+
let same = x && !Object.keys(hash).some((k) => x[k] !== hash[k]);
|
|
81
|
+
this.shouldUpdate = !same;
|
|
82
|
+
return same;
|
|
83
|
+
}
|
|
84
|
+
measure(a, b) {
|
|
85
|
+
this.a = a;
|
|
86
|
+
this.b = b;
|
|
87
|
+
if (this.minValue != null && this.min == null)
|
|
88
|
+
this.min = this.minValue;
|
|
89
|
+
if (this.maxValue != null && this.max == null)
|
|
90
|
+
this.max = this.maxValue;
|
|
91
|
+
for (let s in this.stacks) {
|
|
92
|
+
let info = this.stacks[s].measure(this.normalized);
|
|
93
|
+
let [min, max] = info;
|
|
94
|
+
if (this.min == null || min < this.min)
|
|
95
|
+
this.min = min;
|
|
96
|
+
if (this.max == null || max > this.max)
|
|
97
|
+
this.max = max;
|
|
98
|
+
this.stacks[s].info = info;
|
|
99
|
+
}
|
|
100
|
+
if (this.min == null)
|
|
101
|
+
this.min = 0;
|
|
102
|
+
if (this.max == null)
|
|
103
|
+
this.max = this.normalized ? 1 : 100;
|
|
104
|
+
if (this.min == this.max) {
|
|
105
|
+
if (this.min == 0) {
|
|
106
|
+
this.min = -1;
|
|
107
|
+
this.max = 1;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
let delta = Math.abs(this.min) * 0.1;
|
|
111
|
+
this.min -= delta;
|
|
112
|
+
this.max += delta;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
this.origin = this.inverted ? this.b : this.a;
|
|
116
|
+
this.scale = this.getScale();
|
|
117
|
+
this.calculateTicks();
|
|
118
|
+
}
|
|
119
|
+
getScale(tickSizes) {
|
|
120
|
+
let { min, max } = this;
|
|
121
|
+
let smin = min;
|
|
122
|
+
let smax = max;
|
|
123
|
+
let tickSize;
|
|
124
|
+
if (tickSizes && isNumber(this.snapToTicks) && tickSizes.length > 0) {
|
|
125
|
+
tickSize = tickSizes[Math.min(tickSizes.length - 1, this.snapToTicks)];
|
|
126
|
+
smin = Math.floor(smin / tickSize) * tickSize;
|
|
127
|
+
smax = Math.ceil(smax / tickSize) * tickSize;
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
if (this.minValue === min)
|
|
131
|
+
smin = this.minValuePadded;
|
|
132
|
+
if (this.maxValue === max)
|
|
133
|
+
smax = this.maxValuePadded;
|
|
134
|
+
}
|
|
135
|
+
let minPadding = this.minValue === min ? Math.max(0, smin - this.minValuePadded) : 0;
|
|
136
|
+
let maxPadding = this.maxValue === max ? Math.max(0, this.maxValuePadded - smax) : 0;
|
|
137
|
+
let sign = this.b > this.a ? 1 : -1;
|
|
138
|
+
let factor = smin < smax
|
|
139
|
+
? (Math.abs(this.b - this.a) - this.lowerDeadZone - this.upperDeadZone) /
|
|
140
|
+
(smax - smin + minPadding + maxPadding)
|
|
141
|
+
: 0;
|
|
142
|
+
if (factor < 0)
|
|
143
|
+
factor = 0;
|
|
144
|
+
if (factor > 0 && (this.lowerDeadZone > 0 || this.upperDeadZone > 0)) {
|
|
145
|
+
while (factor * (min - smin) < this.lowerDeadZone)
|
|
146
|
+
smin -= this.lowerDeadZone / factor;
|
|
147
|
+
while (factor * (smax - max) < this.upperDeadZone)
|
|
148
|
+
smax += this.upperDeadZone / factor;
|
|
149
|
+
if (tickSize > 0 && isNumber(this.snapToTicks)) {
|
|
150
|
+
smin = Math.floor(smin / tickSize) * tickSize;
|
|
151
|
+
smax = Math.ceil(smax / tickSize) * tickSize;
|
|
152
|
+
minPadding = this.minValue === min ? Math.max(0, smin - this.minValuePadded) : 0;
|
|
153
|
+
maxPadding = this.maxValue === max ? Math.max(0, this.maxValuePadded - smax) : 0;
|
|
154
|
+
}
|
|
155
|
+
factor = smin < smax ? Math.abs(this.b - this.a) / (smax - smin + minPadding + maxPadding) : 0;
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
factor: sign * (this.inverted ? -factor : factor),
|
|
159
|
+
min: smin,
|
|
160
|
+
max: smax,
|
|
161
|
+
minPadding,
|
|
162
|
+
maxPadding,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
acknowledge(value, width = 0, offset = 0) {
|
|
166
|
+
if (value == null)
|
|
167
|
+
return;
|
|
168
|
+
if (this.minValue == null || value < this.minValue) {
|
|
169
|
+
this.minValue = value;
|
|
170
|
+
this.minValuePadded = value + offset - width / 2;
|
|
171
|
+
}
|
|
172
|
+
if (this.maxValue == null || value > this.maxValue) {
|
|
173
|
+
this.maxValue = value;
|
|
174
|
+
this.maxValuePadded = value + offset + width / 2;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
getStack(name) {
|
|
178
|
+
let s = this.stacks[name];
|
|
179
|
+
if (!s)
|
|
180
|
+
s = this.stacks[name] = new Stack();
|
|
181
|
+
return s;
|
|
182
|
+
}
|
|
183
|
+
stacknowledge(name, ordinal, value) {
|
|
184
|
+
return this.getStack(name).acknowledge(ordinal, value);
|
|
185
|
+
}
|
|
186
|
+
stack(name, ordinal, value) {
|
|
187
|
+
let v = this.getStack(name).stack(ordinal, value);
|
|
188
|
+
return v != null ? this.map(v) : null;
|
|
189
|
+
}
|
|
190
|
+
findTickSize(minPxDist) {
|
|
191
|
+
return this.tickSizes.find((a) => a >= this.minLabelTickSize && a * Math.abs(this.scale.factor) >= minPxDist);
|
|
192
|
+
}
|
|
193
|
+
getTickSizes() {
|
|
194
|
+
return this.tickSizes;
|
|
195
|
+
}
|
|
196
|
+
calculateTicks() {
|
|
197
|
+
let dist = this.minLabelDistance / Math.abs(this.scale.factor);
|
|
198
|
+
let unit = Math.pow(10, Math.floor(Math.log10(dist)));
|
|
199
|
+
let bestLabelDistance = Infinity;
|
|
200
|
+
let bestTicks = [];
|
|
201
|
+
let bestScale = this.scale;
|
|
202
|
+
for (let i = 0; i < this.tickDivisions.length; i++) {
|
|
203
|
+
let divs = this.tickDivisions[i];
|
|
204
|
+
let tickSizes = divs.filter((ts) => ts >= this.minTickStep).map((ts) => ts * unit);
|
|
205
|
+
let scale = this.getScale(tickSizes);
|
|
206
|
+
tickSizes.forEach((size, level) => {
|
|
207
|
+
let labelDistance = size * Math.abs(scale.factor);
|
|
208
|
+
if (labelDistance >= this.minLabelDistance && labelDistance < bestLabelDistance) {
|
|
209
|
+
bestScale = scale;
|
|
210
|
+
bestTicks = tickSizes;
|
|
211
|
+
bestLabelDistance = labelDistance;
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
this.scale = bestScale;
|
|
216
|
+
this.tickSizes = bestTicks.filter((ts) => ts >= this.minTickStep && ts * Math.abs(bestScale.factor) >= this.minTickDistance);
|
|
217
|
+
if (this.tickSizes.length > 0) {
|
|
218
|
+
let max = this.tickSizes[this.tickSizes.length - 1];
|
|
219
|
+
this.tickSizes.push(2 * max);
|
|
220
|
+
this.tickSizes.push(5 * max);
|
|
221
|
+
this.tickSizes.push(10 * max);
|
|
222
|
+
let min = this.tickSizes[0];
|
|
223
|
+
let minDist = min * Math.abs(bestScale.factor);
|
|
224
|
+
if (min / 10 >= this.minTickStep && minDist / 10 >= this.minTickDistance)
|
|
225
|
+
this.tickSizes.splice(0, 0, min / 10);
|
|
226
|
+
else if (min / 5 >= this.minTickStep && minDist / 5 >= this.minTickDistance)
|
|
227
|
+
this.tickSizes.splice(0, 0, min / 5);
|
|
228
|
+
else if (min / 2 >= this.minTickStep && minDist / 2 >= this.minTickDistance)
|
|
229
|
+
this.tickSizes.splice(0, 0, min / 2);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
getTicks(tickSizes) {
|
|
233
|
+
return tickSizes.map((size) => {
|
|
234
|
+
let start = Math.ceil((this.scale.min - this.scale.minPadding) / size);
|
|
235
|
+
let end = Math.floor((this.scale.max + this.scale.maxPadding) / size);
|
|
236
|
+
let result = [];
|
|
237
|
+
for (let i = start; i <= end; i++)
|
|
238
|
+
result.push(i * size + 0);
|
|
239
|
+
return result;
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
mapGridlines() {
|
|
243
|
+
let size = this.tickSizes[0];
|
|
244
|
+
let start = Math.ceil((this.scale.min - this.scale.minPadding) / size);
|
|
245
|
+
let end = Math.floor((this.scale.max + this.scale.maxPadding) / size);
|
|
246
|
+
let result = [];
|
|
247
|
+
for (let i = start; i <= end; i++)
|
|
248
|
+
result.push(this.map(i * size));
|
|
249
|
+
return result;
|
|
250
|
+
}
|
|
251
|
+
book() {
|
|
252
|
+
Console.warn("NumericAxis does not support the autoSize flag for column and bar graphs.");
|
|
253
|
+
}
|
|
254
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx } from "./jsx-runtime";
|
|
2
2
|
export declare const jsxDEV: typeof jsx;
|
|
3
3
|
export declare const jsxsDEV: typeof jsx;
|
|
4
|
-
export { Fragment
|
|
4
|
+
export { Fragment } from "./jsx-runtime";
|
|
5
|
+
export type { JSX } from "./jsx-runtime";
|
|
5
6
|
//# sourceMappingURL=jsx-dev-runtime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-dev-runtime.d.ts","sourceRoot":"","sources":["../src/jsx-dev-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAQ,MAAM,eAAe,CAAC;AAE1C,eAAO,MAAM,MAAM,YAAM,CAAC;AAC1B,eAAO,MAAM,OAAO,YAAO,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"jsx-dev-runtime.d.ts","sourceRoot":"","sources":["../src/jsx-dev-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAQ,MAAM,eAAe,CAAC;AAE1C,eAAO,MAAM,MAAM,YAAM,CAAC;AAC1B,eAAO,MAAM,OAAO,YAAO,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC"}
|
package/build/svg/Svg.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** @jsxImportSource react */
|
|
2
|
+
import { StringProp } from "../ui/Prop";
|
|
2
3
|
import { RenderingContext } from "../ui/RenderingContext";
|
|
3
4
|
import { BoundedObject, BoundedObjectConfig, BoundedObjectInstance, SvgRenderingContext } from "./BoundedObject";
|
|
4
5
|
import { Rect } from "./util/Rect";
|
|
@@ -13,6 +14,13 @@ interface SvgInstance extends BoundedObjectInstance {
|
|
|
13
14
|
clipRectId?: number;
|
|
14
15
|
}
|
|
15
16
|
export interface SvgConfig extends BoundedObjectConfig {
|
|
17
|
+
/** ARIA role for the `svg` element. Defaults to `img` when `ariaLabel` is set. */
|
|
18
|
+
role?: StringProp;
|
|
19
|
+
/**
|
|
20
|
+
* Accessible name for the `svg` element. Setting it announces the drawing as a single graphic
|
|
21
|
+
* instead of as its individual shapes, which is also how a tagged PDF export tags it.
|
|
22
|
+
*/
|
|
23
|
+
ariaLabel?: StringProp;
|
|
16
24
|
/** Set to `true` to automatically calculate width based on the measured height and `aspectRatio`. */
|
|
17
25
|
autoWidth?: boolean;
|
|
18
26
|
/** Set to `true` to automatically calculate height based on the measured width and `aspectRatio`. */
|
|
@@ -39,6 +47,7 @@ export declare class Svg extends BoundedObject<SvgConfig, SvgInstance> {
|
|
|
39
47
|
aspectRatio?: number;
|
|
40
48
|
onWheelActive?: (e: WheelEvent, instance: SvgInstance) => void;
|
|
41
49
|
constructor(config?: SvgConfig);
|
|
50
|
+
declareData(...args: any[]): void;
|
|
42
51
|
initState(context: RenderingContext, instance: SvgInstance): void;
|
|
43
52
|
explore(context: SvgRenderingContext, instance: SvgInstance): void;
|
|
44
53
|
exploreCleanup(context: SvgRenderingContext, instance: SvgInstance): void;
|
package/build/svg/Svg.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Svg.d.ts","sourceRoot":"","sources":["../../src/svg/Svg.tsx"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAI1D,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,qBAAqB,EAA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C;IACnD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,KAAK,IAAI,CAAC;gBAE3D,MAAM,CAAC,EAAE,SAAS;IAI9B,WAAW,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IAU1B,SAAS,CAAC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,WAAW;IAQ1D,OAAO,CAAC,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,WAAW;IAK3D,cAAc,CAAC,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,WAAW;IAIlE,OAAO,CAAC,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,WAAW;IAqB3D,cAAc,CAAC,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,WAAW;IAMlE,MAAM,CAAC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM;CAkBtE"}
|
package/build/svg/Svg.js
CHANGED
|
@@ -8,6 +8,12 @@ export class Svg extends BoundedObject {
|
|
|
8
8
|
constructor(config) {
|
|
9
9
|
super(config);
|
|
10
10
|
}
|
|
11
|
+
declareData(...args) {
|
|
12
|
+
return super.declareData({
|
|
13
|
+
role: undefined,
|
|
14
|
+
ariaLabel: undefined,
|
|
15
|
+
}, ...args);
|
|
16
|
+
}
|
|
11
17
|
initState(context, instance) {
|
|
12
18
|
const size = {
|
|
13
19
|
width: 0,
|
|
@@ -70,6 +76,8 @@ class SvgComponent extends VDOM.Component {
|
|
|
70
76
|
render() {
|
|
71
77
|
const { instance, data, size, children, eventHandlers } = this.props;
|
|
72
78
|
const { widget } = instance;
|
|
79
|
+
// An unnamed drawing is left alone: `role="img"` would hide its text and put nothing in its place.
|
|
80
|
+
const role = data.role ?? (data.ariaLabel ? "img" : undefined);
|
|
73
81
|
const defs = [];
|
|
74
82
|
for (const k in instance.clipRects) {
|
|
75
83
|
let cr = instance.clipRects[k];
|
|
@@ -89,7 +97,7 @@ class SvgComponent extends VDOM.Component {
|
|
|
89
97
|
//parent div is needed because clientWidth doesn't work on the svg element in FF
|
|
90
98
|
return (_jsx("div", { ref: (el) => {
|
|
91
99
|
this.el = el;
|
|
92
|
-
}, className: data.classNames, style: style, ...eventHandlers, children: size.width > 0 && size.height > 0 && (_jsxs("svg", { children: [_jsx("defs", { children: defs }), children] })) }));
|
|
100
|
+
}, className: data.classNames, style: style, ...eventHandlers, children: size.width > 0 && size.height > 0 && (_jsxs("svg", { role: role, "aria-label": data.ariaLabel, children: [_jsx("defs", { children: defs }), children] })) }));
|
|
93
101
|
}
|
|
94
102
|
onResize() {
|
|
95
103
|
const { instance } = this.props;
|
package/build/ui/index.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ export * from "./tpl";
|
|
|
38
38
|
export * from "./expr";
|
|
39
39
|
export * from "./exprHelpers";
|
|
40
40
|
import { computable } from "../data/computable";
|
|
41
|
-
import { createAccessorModelProxy, createModel
|
|
42
|
-
export { computable, createAccessorModelProxy, createModel
|
|
41
|
+
import { createAccessorModelProxy, createModel } from "../data/createAccessorModelProxy";
|
|
42
|
+
export { computable, createAccessorModelProxy, createModel };
|
|
43
|
+
export type { AccessorChain } from "../data/createAccessorModelProxy";
|
|
43
44
|
//# sourceMappingURL=index.d.ts.map
|
package/build/ui/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAA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CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,MAAM,CAAC;AACrB,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,kCAAkC,CAAC;AACjD,cAAc,aAAa,CAAC;AAE5B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gBAAgB,CAAC;AAE/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAEhC,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAG9B,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,wBAAwB,EAAE,WAAW,EAAE,CAAC;AAC7D,YAAY,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC"}
|
package/build/ui/index.js
CHANGED
|
@@ -39,5 +39,5 @@ export * from "./expr";
|
|
|
39
39
|
export * from "./exprHelpers";
|
|
40
40
|
//re-export computable here
|
|
41
41
|
import { computable } from "../data/computable";
|
|
42
|
-
import { createAccessorModelProxy, createModel
|
|
42
|
+
import { createAccessorModelProxy, createModel } from "../data/createAccessorModelProxy";
|
|
43
43
|
export { computable, createAccessorModelProxy, createModel };
|
package/build/util/DOM.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DOM.d.ts","sourceRoot":"","sources":["../../src/util/DOM.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DOM.d.ts","sourceRoot":"","sources":["../../src/util/DOM.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,OAAO,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;AACzG,wBAAgB,SAAS,CAAC,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,OAAO,KAAK,OAAO,GAAG,OAAO,GAAG,IAAI,CAAC;AAa5F,wBAAgB,cAAc,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,OAAO,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;AAC9G,wBAAgB,cAAc,CAAC,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,OAAO,KAAK,OAAO,GAAG,OAAO,GAAG,IAAI,CAAC;AAWjG,wBAAgB,OAAO,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,OAAO,GAAG,WAAW,GAAG,IAAI,CAAC;AAC7G,wBAAgB,OAAO,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,OAAO,KAAK,OAAO,GAAG,OAAO,GAAG,IAAI,CAAC;AASjG,wBAAgB,aAAa,CAAC,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,OAAO,GAAG,WAAW,GAAG,IAAI,CAAC;AAC5G,wBAAgB,aAAa,CAAC,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,OAAO,GAAG,WAAW,GAAG,IAAI,CAAC;AAKxG,wBAAgB,SAAS,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO,CAE9C;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO,CAElD;AAID,wBAAgB,WAAW,CAAC,EAAE,EAAE,OAAO,GAAG,EAAE,IAAI,WAAW,CAS1D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,GAAG,IAAI,CAElD;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAElE;AAMD,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAQxE"}
|
package/build/util/DOM.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isNumber } from "../util/isNumber";
|
|
2
|
+
import { getActiveElement } from "./getActiveElement";
|
|
2
3
|
export function findFirst(el, condition) {
|
|
3
4
|
if (condition(el))
|
|
4
5
|
return el;
|
|
@@ -33,10 +34,10 @@ export function closestParent(el, condition) {
|
|
|
33
34
|
return el && closest(el.parentElement, condition);
|
|
34
35
|
}
|
|
35
36
|
export function isFocused(el) {
|
|
36
|
-
return
|
|
37
|
+
return getActiveElement() == el;
|
|
37
38
|
}
|
|
38
39
|
export function isFocusedDeep(el) {
|
|
39
|
-
return
|
|
40
|
+
return isSelfOrDescendant(el, getActiveElement());
|
|
40
41
|
}
|
|
41
42
|
const focusableWithoutTabIndex = ["INPUT", "SELECT", "TEXTAREA", "A", "BUTTON"];
|
|
42
43
|
export function isFocusable(el) {
|
|
@@ -54,11 +55,22 @@ export function isFocusable(el) {
|
|
|
54
55
|
* @returns {Element}
|
|
55
56
|
*/
|
|
56
57
|
export function getFocusedElement() {
|
|
57
|
-
return
|
|
58
|
+
return getActiveElement();
|
|
58
59
|
}
|
|
59
60
|
export function isDescendant(el, descEl) {
|
|
60
61
|
return el.contains(descEl);
|
|
61
62
|
}
|
|
63
|
+
//`descEl` may live in a different document than `el` (e.g. focus is inside a same-origin
|
|
64
|
+
//iframe) - Node.contains never crosses document boundaries, so walk out through each
|
|
65
|
+
//frame's <iframe> element in its parent document until we either cross into el's document
|
|
66
|
+
//or run out of ancestor frames.
|
|
62
67
|
export function isSelfOrDescendant(el, descEl) {
|
|
63
|
-
|
|
68
|
+
let node = descEl;
|
|
69
|
+
while (node) {
|
|
70
|
+
if (el == node || el.contains(node))
|
|
71
|
+
return true;
|
|
72
|
+
let win = node.ownerDocument?.defaultView;
|
|
73
|
+
node = win?.frameElement;
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
64
76
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function getActiveElement(): Element;
|
|
1
|
+
export declare function getActiveElement(doc?: Document): Element;
|
|
2
2
|
//# sourceMappingURL=getActiveElement.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getActiveElement.d.ts","sourceRoot":"","sources":["../../src/util/getActiveElement.ts"],"names":[],"mappings":"AACA,wBAAgB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"getActiveElement.d.ts","sourceRoot":"","sources":["../../src/util/getActiveElement.ts"],"names":[],"mappings":"AACA,wBAAgB,gBAAgB,CAAC,GAAG,GAAE,QAAmB,GAAG,OAAO,CAgBlE"}
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
//IE sometimes returns null while other browsers always return document.body.
|
|
2
|
-
export function getActiveElement() {
|
|
3
|
-
|
|
2
|
+
export function getActiveElement(doc = document) {
|
|
3
|
+
let active = doc.activeElement ?? doc.body;
|
|
4
|
+
//when focus is inside a same-origin iframe, `doc.activeElement` only reports the
|
|
5
|
+
//<iframe> element itself - drill into its own document to find the element that's
|
|
6
|
+
//actually focused there (recursively, in case of nested iframes)
|
|
7
|
+
if (active && active.tagName === "IFRAME") {
|
|
8
|
+
const iframe = active;
|
|
9
|
+
let frameDoc = iframe.contentDocument;
|
|
10
|
+
if (frameDoc) {
|
|
11
|
+
const inner = getActiveElement(frameDoc);
|
|
12
|
+
return inner ?? active;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return active;
|
|
4
16
|
}
|
|
@@ -3,6 +3,10 @@ import { TextField, TextFieldConfig } from "./TextField";
|
|
|
3
3
|
import { FieldInstance } from "./Field";
|
|
4
4
|
import type { RenderingContext } from "../../ui/RenderingContext";
|
|
5
5
|
import { NumberProp } from "../../ui/Prop";
|
|
6
|
+
/**
|
|
7
|
+
* `trim` applies to the commit that ends the edit, not to intermediate `input` commits. Whitespace
|
|
8
|
+
* inside the text is never touched.
|
|
9
|
+
*/
|
|
6
10
|
export interface TextAreaConfig extends TextFieldConfig {
|
|
7
11
|
/** Specifies the number of visible lines. */
|
|
8
12
|
rows?: NumberProp;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextArea.d.ts","sourceRoot":"","sources":["../../../src/widgets/form/TextArea.tsx"],"names":[],"mappings":"AAAA,6BAA6B;AAG7B,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAmB,aAAa,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"TextArea.d.ts","sourceRoot":"","sources":["../../../src/widgets/form/TextArea.tsx"],"names":[],"mappings":"AAAA,6BAA6B;AAG7B,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAmB,aAAa,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAclE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;;GAGG;AACH,MAAM,WAAW,cAAe,SAAQ,eAAe;IACpD,6CAA6C;IAC7C,IAAI,CAAC,EAAE,UAAU,CAAC;IAElB,iGAAiG;IACjG,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,2EAA2E;IAC3E,SAAS,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,QAAS,SAAQ,SAAS,CAAC,cAAc,CAAC;gBACxC,MAAM,CAAC,EAAE,cAAc;IAInC,WAAW,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,IAAI;IAMrD,WAAW,CAAC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,aAAa,CAAC,QAAQ,CAAC,GAAG,IAAI;IAM/E,WAAW,CAAC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,aAAa,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,SAAS;IAYvG,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,aAAa,CAAC,QAAQ,CAAC,GAAG,MAAM,GAAG,SAAS;CAGpG"}
|
|
@@ -8,6 +8,7 @@ import { stopPropagation } from "../../util/eventCallbacks";
|
|
|
8
8
|
import { KeyCode } from "../../util/KeyCode";
|
|
9
9
|
import { autoFocus } from "../autoFocus";
|
|
10
10
|
import { getActiveElement } from "../../util/getActiveElement";
|
|
11
|
+
import { isString } from "../../util/isString";
|
|
11
12
|
export class TextArea extends TextField {
|
|
12
13
|
constructor(config) {
|
|
13
14
|
super(config);
|
|
@@ -103,8 +104,13 @@ class Input extends VDOM.Component {
|
|
|
103
104
|
});
|
|
104
105
|
}
|
|
105
106
|
if (instance.widget.reactOn.indexOf(change) != -1) {
|
|
106
|
-
|
|
107
|
+
// Trimming on `input` would strip whitespace the user is still typing, so a trailing
|
|
108
|
+
// newline could never be entered.
|
|
109
|
+
let text = change != "input" && data.trim && isString(inputValue) ? inputValue.trim() : inputValue;
|
|
110
|
+
let value = text || widget.emptyValue;
|
|
107
111
|
instance.set("value", value);
|
|
112
|
+
if (this.input && text != inputValue)
|
|
113
|
+
this.input.value = text;
|
|
108
114
|
}
|
|
109
115
|
}
|
|
110
116
|
onFocus() {
|
|
@@ -13,10 +13,11 @@ import type { KeySelection } from "../../ui/selection/KeySelection";
|
|
|
13
13
|
import type { PropertySelection } from "../../ui/selection/PropertySelection";
|
|
14
14
|
import { WidgetConfig } from "../../ui/Widget";
|
|
15
15
|
import { DragEvent, DragEndEvent } from "../drag-drop/ops";
|
|
16
|
-
import { GridRow,
|
|
16
|
+
import { GridRow, GridRowInstance } from "./GridRow";
|
|
17
|
+
import type { GridRowConfig } from "./GridRow";
|
|
17
18
|
import { CreateConfig } from "../../util";
|
|
18
19
|
import type { TreeAdapter } from "../../ui/adapter/TreeAdapter";
|
|
19
|
-
export { GridRowConfig };
|
|
20
|
+
export type { GridRowConfig };
|
|
20
21
|
export type GridFetchRecordsResult<T> = T[] | {
|
|
21
22
|
records: T[];
|
|
22
23
|
lastPage?: boolean;
|
|
@@ -151,7 +152,16 @@ export interface GridColumnConfig {
|
|
|
151
152
|
children?: ChildNode | ChildNode[];
|
|
152
153
|
key?: string;
|
|
153
154
|
pad?: boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Record field used for sorting instead of `field` or the displayed `value`.
|
|
157
|
+
* Use it when the column displays a computed value but should sort by raw data.
|
|
158
|
+
* Sort key precedence: `sortValue` > `sortField` > `value` > `field`.
|
|
159
|
+
*/
|
|
154
160
|
sortField?: string;
|
|
161
|
+
/**
|
|
162
|
+
* Selector (binding, template, expression or computable) used for sorting instead
|
|
163
|
+
* of `field`, `sortField` or the displayed `value`. Takes the highest precedence.
|
|
164
|
+
*/
|
|
155
165
|
sortValue?: Prop<any>;
|
|
156
166
|
style?: StyleProp;
|
|
157
167
|
trimWhitespace?: boolean;
|