cx 24.10.3 → 24.10.4

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 (68) hide show
  1. package/dist/charts.js +24 -27
  2. package/dist/data.js +26 -29
  3. package/dist/manifest.js +721 -721
  4. package/dist/svg.js +59 -56
  5. package/dist/ui.js +51 -52
  6. package/dist/widgets.js +40 -44
  7. package/package.json +32 -32
  8. package/src/charts/PieChart.js +2 -2
  9. package/src/charts/PieLabel.js +71 -71
  10. package/src/charts/axis/Axis.js +260 -260
  11. package/src/charts/axis/NumericAxis.js +347 -347
  12. package/src/charts/axis/Stack.js +55 -55
  13. package/src/charts/axis/TimeAxis.js +510 -510
  14. package/src/charts/helpers/PointReducer.js +43 -43
  15. package/src/charts/helpers/SnapPointFinder.js +69 -69
  16. package/src/data/Binding.spec.js +69 -69
  17. package/src/data/Expression.js +221 -221
  18. package/src/data/Expression.spec.js +184 -184
  19. package/src/data/StringTemplate.spec.js +105 -105
  20. package/src/data/getAccessor.spec.js +11 -11
  21. package/src/index.scss +6 -6
  22. package/src/svg/Text.d.ts +40 -40
  23. package/src/ui/Culture.d.ts +55 -55
  24. package/src/ui/Culture.js +139 -139
  25. package/src/ui/FocusManager.js +171 -171
  26. package/src/ui/Instance.d.ts +72 -72
  27. package/src/ui/VDOM.d.ts +12 -12
  28. package/src/ui/app/startAppLoop.js +58 -58
  29. package/src/ui/index.d.ts +42 -42
  30. package/src/ui/layout/LabelsTopLayout.js +134 -134
  31. package/src/util/Console.d.ts +4 -4
  32. package/src/util/index.d.ts +51 -51
  33. package/src/util/index.js +54 -54
  34. package/src/util/isValidIdentifierName.d.ts +1 -1
  35. package/src/util/isValidIdentifierName.js +5 -5
  36. package/src/util/isValidIdentifierName.spec.js +33 -33
  37. package/src/util/scss/add-rules.scss +38 -38
  38. package/src/widgets/CxCredit.scss +37 -37
  39. package/src/widgets/HighlightedSearchText.js +36 -36
  40. package/src/widgets/HighlightedSearchText.scss +18 -18
  41. package/src/widgets/List.scss +91 -91
  42. package/src/widgets/drag-drop/DropZone.js +214 -214
  43. package/src/widgets/form/Calendar.scss +196 -196
  44. package/src/widgets/form/ColorField.js +397 -397
  45. package/src/widgets/form/ColorPicker.scss +283 -283
  46. package/src/widgets/form/DateTimeField.js +573 -573
  47. package/src/widgets/form/LookupField.d.ts +179 -179
  48. package/src/widgets/form/MonthField.js +516 -516
  49. package/src/widgets/form/MonthPicker.scss +118 -118
  50. package/src/widgets/form/NumberField.js +459 -459
  51. package/src/widgets/form/NumberField.scss +61 -61
  52. package/src/widgets/form/Select.scss +99 -99
  53. package/src/widgets/form/Slider.scss +118 -118
  54. package/src/widgets/form/Switch.scss +140 -140
  55. package/src/widgets/form/TextArea.scss +43 -43
  56. package/src/widgets/form/TextField.js +290 -290
  57. package/src/widgets/form/TextField.scss +55 -55
  58. package/src/widgets/form/UploadButton.d.ts +34 -34
  59. package/src/widgets/form/variables.scss +353 -353
  60. package/src/widgets/grid/TreeNode.scss +88 -88
  61. package/src/widgets/nav/Menu.scss +74 -74
  62. package/src/widgets/overlay/Dropdown.js +612 -612
  63. package/src/widgets/overlay/FlyweightTooltipTracker.js +39 -39
  64. package/src/widgets/overlay/Tooltip.js +300 -300
  65. package/src/widgets/overlay/Window.js +196 -196
  66. package/src/widgets/overlay/captureMouse.js +124 -124
  67. package/src/widgets/overlay/variables.scss +83 -83
  68. package/src/widgets/variables.scss +144 -144
@@ -1,260 +1,260 @@
1
- import { BoundedObject } from "../../svg/BoundedObject";
2
- import { VDOM } from "../../ui/Widget";
3
- import { isUndefined } from "../../util/isUndefined";
4
- import { parseStyle } from "../../util/parseStyle";
5
-
6
- export class Axis extends BoundedObject {
7
- init() {
8
- if (this.labelAnchor == "auto") this.labelAnchor = this.vertical ? (this.secondary ? "start" : "end") : "middle";
9
-
10
- if (this.labelDx == "auto") this.labelDx = 0;
11
-
12
- if (this.labelDy == "auto") this.labelDy = this.vertical ? "0.4em" : this.secondary ? 0 : "0.8em";
13
-
14
- if (isUndefined(this.minLabelDistance))
15
- this.minLabelDistance = this.vertical ? this.minLabelDistanceVertical : this.minLabelDistanceHorizontal;
16
-
17
- if (this.labelLineCountDyFactor == "auto")
18
- this.labelLineCountDyFactor = this.vertical ? -this.labelLineHeight / 2 : this.secondary ? -1 : 0;
19
-
20
- this.lineStyle = parseStyle(this.lineStyle);
21
- this.tickStyle = parseStyle(this.tickStyle);
22
- this.labelStyle = parseStyle(this.labelStyle);
23
-
24
- super.init();
25
- }
26
-
27
- declareData() {
28
- super.declareData(
29
- {
30
- anchors: undefined,
31
- hideLabels: undefined,
32
- hideLine: undefined,
33
- hideTicks: undefined,
34
- labelRotation: undefined,
35
- labelAnchor: undefined,
36
- lineStyle: undefined,
37
- lineClass: undefined,
38
- labelStyle: undefined,
39
- labelClass: undefined,
40
- tickStyle: undefined,
41
- tickClass: undefined,
42
- },
43
- ...arguments,
44
- );
45
- }
46
-
47
- prepareData(context, instance) {
48
- super.prepareData(context, instance);
49
- if (this.onCreateLabelFormatter)
50
- instance.labelFormatter = instance.invoke("onCreateLabelFormatter", context, instance);
51
- }
52
-
53
- report(context, instance) {
54
- return instance.calculator;
55
- }
56
-
57
- reportData(context, instance) {}
58
-
59
- renderTicksAndLabels(context, instance, valueFormatter) {
60
- if (this.hidden) return false;
61
-
62
- var { data, calculator, labelFormatter } = instance;
63
- var { bounds } = data;
64
- let { CSS, baseClass } = this;
65
- var size = calculator.findTickSize(this.minLabelDistance);
66
-
67
- var labelClass = CSS.expand(CSS.element(baseClass, "label"), data.labelClass);
68
- var offsetClass = CSS.element(baseClass, "label-offset");
69
-
70
- var x1,
71
- y1,
72
- x2,
73
- y2,
74
- tickSize = this.tickSize;
75
-
76
- if (this.vertical) {
77
- x1 = x2 = this.secondary ? bounds.r : bounds.l;
78
- y1 = bounds.b;
79
- y2 = bounds.t;
80
- } else {
81
- x1 = bounds.l;
82
- x2 = bounds.r;
83
- y1 = y2 = this.secondary ? bounds.t : bounds.b;
84
- }
85
-
86
- var res = [null, null];
87
-
88
- if (!data.hideLine) {
89
- res[0] = (
90
- <line
91
- key="line"
92
- className={CSS.expand(CSS.element(baseClass, "line"), data.lineClass)}
93
- style={data.lineStyle}
94
- x1={x1}
95
- y1={y1}
96
- x2={x2}
97
- y2={y2}
98
- />
99
- );
100
- }
101
-
102
- var t = [];
103
- if (size > 0 && !data.hideLabels) {
104
- var ticks = calculator.getTicks([size]);
105
- ticks.forEach((serie, si) => {
106
- serie.forEach((v, i) => {
107
- var s = calculator.map(v);
108
-
109
- if (this.secondary) {
110
- x1 = this.vertical ? bounds.r : s;
111
- y1 = this.vertical ? s : bounds.t;
112
- x2 = this.vertical ? bounds.r + tickSize : s;
113
- y2 = this.vertical ? s : bounds.t - tickSize;
114
- } else {
115
- x1 = this.vertical ? bounds.l : s;
116
- y1 = this.vertical ? s : bounds.b;
117
- x2 = this.vertical ? bounds.l - tickSize : s;
118
- y2 = this.vertical ? s : bounds.b + tickSize;
119
- }
120
-
121
- t.push(`M ${x1} ${y1} L ${x2} ${y2}`);
122
-
123
- var x, y;
124
- let labelOffset =
125
- this.alternateLabelOffset != null && i % 2 == 1 ? this.alternateLabelOffset : this.labelOffset;
126
-
127
- if (this.secondary) {
128
- x = this.vertical ? bounds.r + labelOffset : s;
129
- y = this.vertical ? s : bounds.t - labelOffset;
130
- } else {
131
- x = this.vertical ? bounds.l - labelOffset : s;
132
- y = this.vertical ? s : bounds.b + labelOffset;
133
- }
134
-
135
- var transform = data.labelRotation ? `rotate(${data.labelRotation} ${x} ${y})` : null;
136
- var formattedValue = valueFormatter(v);
137
- var lines = labelFormatter
138
- ? labelFormatter(formattedValue, v, { tickIndex: si, serieIndex: i })
139
- : this.wrapLines(formattedValue);
140
- res.push(
141
- <text
142
- key={`label-${si}-${i}`}
143
- className={labelClass}
144
- style={data.labelStyle}
145
- x={x}
146
- y={y}
147
- textAnchor={data.labelAnchor}
148
- transform={transform}
149
- >
150
- {this.renderLabels(lines, x, this.labelDy, this.labelDx, offsetClass)}
151
- </text>,
152
- );
153
- });
154
- });
155
- }
156
-
157
- if (!data.hideTicks) {
158
- res[1] = (
159
- <path
160
- key="ticks"
161
- className={CSS.expand(CSS.element(baseClass, "ticks"), data.tickClass)}
162
- style={data.tickStyle}
163
- d={t.join(" ")}
164
- />
165
- );
166
- }
167
-
168
- return res;
169
- }
170
-
171
- wrapLines(str) {
172
- if (!this.labelWrap || typeof str != "string") return [{ text: str }];
173
-
174
- let parts = str.split(" ");
175
- if (parts.length == 0) return null;
176
-
177
- let lines = [];
178
- let line = null;
179
- for (let i = 0; i < parts.length; i++) {
180
- if (!line) line = parts[i];
181
- else if (parts[i].length + line.length < this.labelMaxLineLength) line += " " + parts[i];
182
- else {
183
- lines.push({ text: line });
184
- line = parts[i];
185
- }
186
- }
187
- lines.push({ text: line });
188
- return lines;
189
- }
190
-
191
- renderLabels(lines, x, dy, dx, offsetClass) {
192
- let offset = this.labelLineCountDyFactor * (lines.length - 1);
193
- let result = [];
194
-
195
- if (lines.length > 1 && dy != null) {
196
- result.push(
197
- <tspan key={-2} className={offsetClass} dy={dy}>
198
- _
199
- </tspan>,
200
- );
201
- }
202
-
203
- lines.forEach((p, i) => {
204
- result.push(
205
- <tspan
206
- key={i}
207
- dy={lines.length > 1 ? `${i == 0 ? offset : this.labelLineHeight}em` : dy}
208
- x={x}
209
- style={p.style}
210
- className={p.className}
211
- dx={dx}
212
- >
213
- {p.text}
214
- </tspan>,
215
- );
216
- });
217
- return result;
218
- }
219
-
220
- prepare(context, instance) {
221
- super.prepare(context, instance);
222
- var { bounds } = instance.data;
223
- var [a, b] = !this.vertical ? [bounds.l, bounds.r] : [bounds.b, bounds.t];
224
- instance.calculator.measure(a, b);
225
- if (this.onMeasured) instance.invoke("onMeasured", instance.calculator.hash(), instance);
226
- if (!instance.calculator.isSame(instance.cached.axis)) instance.markShouldUpdate(context);
227
- }
228
-
229
- cleanup(context, instance) {
230
- var { cached, calculator } = instance;
231
- cached.axis = calculator.hash();
232
- }
233
- }
234
-
235
- Axis.prototype.anchors = "0 1 1 0";
236
- Axis.prototype.styled = true;
237
- Axis.prototype.vertical = false;
238
- Axis.prototype.secondary = false;
239
- Axis.prototype.inverted = false;
240
- Axis.prototype.hidden = false;
241
- Axis.prototype.hideLabels = false;
242
- Axis.prototype.hideTicks = false;
243
- Axis.prototype.hideLine = false;
244
-
245
- Axis.prototype.tickSize = 3;
246
- Axis.prototype.minTickDistance = 25;
247
- Axis.prototype.minLabelDistanceVertical = 40;
248
- Axis.prototype.minLabelDistanceHorizontal = 50;
249
- Axis.prototype.labelOffset = 10;
250
- Axis.prototype.alternateLabelOffset = null;
251
- Axis.prototype.labelRotation = 0;
252
- Axis.prototype.labelAnchor = "auto";
253
- Axis.prototype.labelDx = "auto";
254
- Axis.prototype.labelDy = "auto";
255
- Axis.prototype.labelWrap = false;
256
- Axis.prototype.labelLineCountDyFactor = "auto";
257
- Axis.prototype.labelLineHeight = 1;
258
- Axis.prototype.labelMaxLineLength = 10;
259
-
260
- Axis.namespace = "ui.svg.chart.axis";
1
+ import { BoundedObject } from "../../svg/BoundedObject";
2
+ import { VDOM } from "../../ui/Widget";
3
+ import { isUndefined } from "../../util/isUndefined";
4
+ import { parseStyle } from "../../util/parseStyle";
5
+
6
+ export class Axis extends BoundedObject {
7
+ init() {
8
+ if (this.labelAnchor == "auto") this.labelAnchor = this.vertical ? (this.secondary ? "start" : "end") : "middle";
9
+
10
+ if (this.labelDx == "auto") this.labelDx = 0;
11
+
12
+ if (this.labelDy == "auto") this.labelDy = this.vertical ? "0.4em" : this.secondary ? 0 : "0.8em";
13
+
14
+ if (isUndefined(this.minLabelDistance))
15
+ this.minLabelDistance = this.vertical ? this.minLabelDistanceVertical : this.minLabelDistanceHorizontal;
16
+
17
+ if (this.labelLineCountDyFactor == "auto")
18
+ this.labelLineCountDyFactor = this.vertical ? -this.labelLineHeight / 2 : this.secondary ? -1 : 0;
19
+
20
+ this.lineStyle = parseStyle(this.lineStyle);
21
+ this.tickStyle = parseStyle(this.tickStyle);
22
+ this.labelStyle = parseStyle(this.labelStyle);
23
+
24
+ super.init();
25
+ }
26
+
27
+ declareData() {
28
+ super.declareData(
29
+ {
30
+ anchors: undefined,
31
+ hideLabels: undefined,
32
+ hideLine: undefined,
33
+ hideTicks: undefined,
34
+ labelRotation: undefined,
35
+ labelAnchor: undefined,
36
+ lineStyle: undefined,
37
+ lineClass: undefined,
38
+ labelStyle: undefined,
39
+ labelClass: undefined,
40
+ tickStyle: undefined,
41
+ tickClass: undefined,
42
+ },
43
+ ...arguments,
44
+ );
45
+ }
46
+
47
+ prepareData(context, instance) {
48
+ super.prepareData(context, instance);
49
+ if (this.onCreateLabelFormatter)
50
+ instance.labelFormatter = instance.invoke("onCreateLabelFormatter", context, instance);
51
+ }
52
+
53
+ report(context, instance) {
54
+ return instance.calculator;
55
+ }
56
+
57
+ reportData(context, instance) {}
58
+
59
+ renderTicksAndLabels(context, instance, valueFormatter) {
60
+ if (this.hidden) return false;
61
+
62
+ var { data, calculator, labelFormatter } = instance;
63
+ var { bounds } = data;
64
+ let { CSS, baseClass } = this;
65
+ var size = calculator.findTickSize(this.minLabelDistance);
66
+
67
+ var labelClass = CSS.expand(CSS.element(baseClass, "label"), data.labelClass);
68
+ var offsetClass = CSS.element(baseClass, "label-offset");
69
+
70
+ var x1,
71
+ y1,
72
+ x2,
73
+ y2,
74
+ tickSize = this.tickSize;
75
+
76
+ if (this.vertical) {
77
+ x1 = x2 = this.secondary ? bounds.r : bounds.l;
78
+ y1 = bounds.b;
79
+ y2 = bounds.t;
80
+ } else {
81
+ x1 = bounds.l;
82
+ x2 = bounds.r;
83
+ y1 = y2 = this.secondary ? bounds.t : bounds.b;
84
+ }
85
+
86
+ var res = [null, null];
87
+
88
+ if (!data.hideLine) {
89
+ res[0] = (
90
+ <line
91
+ key="line"
92
+ className={CSS.expand(CSS.element(baseClass, "line"), data.lineClass)}
93
+ style={data.lineStyle}
94
+ x1={x1}
95
+ y1={y1}
96
+ x2={x2}
97
+ y2={y2}
98
+ />
99
+ );
100
+ }
101
+
102
+ var t = [];
103
+ if (size > 0 && !data.hideLabels) {
104
+ var ticks = calculator.getTicks([size]);
105
+ ticks.forEach((serie, si) => {
106
+ serie.forEach((v, i) => {
107
+ var s = calculator.map(v);
108
+
109
+ if (this.secondary) {
110
+ x1 = this.vertical ? bounds.r : s;
111
+ y1 = this.vertical ? s : bounds.t;
112
+ x2 = this.vertical ? bounds.r + tickSize : s;
113
+ y2 = this.vertical ? s : bounds.t - tickSize;
114
+ } else {
115
+ x1 = this.vertical ? bounds.l : s;
116
+ y1 = this.vertical ? s : bounds.b;
117
+ x2 = this.vertical ? bounds.l - tickSize : s;
118
+ y2 = this.vertical ? s : bounds.b + tickSize;
119
+ }
120
+
121
+ t.push(`M ${x1} ${y1} L ${x2} ${y2}`);
122
+
123
+ var x, y;
124
+ let labelOffset =
125
+ this.alternateLabelOffset != null && i % 2 == 1 ? this.alternateLabelOffset : this.labelOffset;
126
+
127
+ if (this.secondary) {
128
+ x = this.vertical ? bounds.r + labelOffset : s;
129
+ y = this.vertical ? s : bounds.t - labelOffset;
130
+ } else {
131
+ x = this.vertical ? bounds.l - labelOffset : s;
132
+ y = this.vertical ? s : bounds.b + labelOffset;
133
+ }
134
+
135
+ var transform = data.labelRotation ? `rotate(${data.labelRotation} ${x} ${y})` : null;
136
+ var formattedValue = valueFormatter(v);
137
+ var lines = labelFormatter
138
+ ? labelFormatter(formattedValue, v, { tickIndex: si, serieIndex: i })
139
+ : this.wrapLines(formattedValue);
140
+ res.push(
141
+ <text
142
+ key={`label-${si}-${i}`}
143
+ className={labelClass}
144
+ style={data.labelStyle}
145
+ x={x}
146
+ y={y}
147
+ textAnchor={data.labelAnchor}
148
+ transform={transform}
149
+ >
150
+ {this.renderLabels(lines, x, this.labelDy, this.labelDx, offsetClass)}
151
+ </text>,
152
+ );
153
+ });
154
+ });
155
+ }
156
+
157
+ if (!data.hideTicks) {
158
+ res[1] = (
159
+ <path
160
+ key="ticks"
161
+ className={CSS.expand(CSS.element(baseClass, "ticks"), data.tickClass)}
162
+ style={data.tickStyle}
163
+ d={t.join(" ")}
164
+ />
165
+ );
166
+ }
167
+
168
+ return res;
169
+ }
170
+
171
+ wrapLines(str) {
172
+ if (!this.labelWrap || typeof str != "string") return [{ text: str }];
173
+
174
+ let parts = str.split(" ");
175
+ if (parts.length == 0) return null;
176
+
177
+ let lines = [];
178
+ let line = null;
179
+ for (let i = 0; i < parts.length; i++) {
180
+ if (!line) line = parts[i];
181
+ else if (parts[i].length + line.length < this.labelMaxLineLength) line += " " + parts[i];
182
+ else {
183
+ lines.push({ text: line });
184
+ line = parts[i];
185
+ }
186
+ }
187
+ lines.push({ text: line });
188
+ return lines;
189
+ }
190
+
191
+ renderLabels(lines, x, dy, dx, offsetClass) {
192
+ let offset = this.labelLineCountDyFactor * (lines.length - 1);
193
+ let result = [];
194
+
195
+ if (lines.length > 1 && dy != null) {
196
+ result.push(
197
+ <tspan key={-2} className={offsetClass} dy={dy}>
198
+ _
199
+ </tspan>,
200
+ );
201
+ }
202
+
203
+ lines.forEach((p, i) => {
204
+ result.push(
205
+ <tspan
206
+ key={i}
207
+ dy={lines.length > 1 ? `${i == 0 ? offset : this.labelLineHeight}em` : dy}
208
+ x={x}
209
+ style={p.style}
210
+ className={p.className}
211
+ dx={dx}
212
+ >
213
+ {p.text}
214
+ </tspan>,
215
+ );
216
+ });
217
+ return result;
218
+ }
219
+
220
+ prepare(context, instance) {
221
+ super.prepare(context, instance);
222
+ var { bounds } = instance.data;
223
+ var [a, b] = !this.vertical ? [bounds.l, bounds.r] : [bounds.b, bounds.t];
224
+ instance.calculator.measure(a, b);
225
+ if (this.onMeasured) instance.invoke("onMeasured", instance.calculator.hash(), instance);
226
+ if (!instance.calculator.isSame(instance.cached.axis)) instance.markShouldUpdate(context);
227
+ }
228
+
229
+ cleanup(context, instance) {
230
+ var { cached, calculator } = instance;
231
+ cached.axis = calculator.hash();
232
+ }
233
+ }
234
+
235
+ Axis.prototype.anchors = "0 1 1 0";
236
+ Axis.prototype.styled = true;
237
+ Axis.prototype.vertical = false;
238
+ Axis.prototype.secondary = false;
239
+ Axis.prototype.inverted = false;
240
+ Axis.prototype.hidden = false;
241
+ Axis.prototype.hideLabels = false;
242
+ Axis.prototype.hideTicks = false;
243
+ Axis.prototype.hideLine = false;
244
+
245
+ Axis.prototype.tickSize = 3;
246
+ Axis.prototype.minTickDistance = 25;
247
+ Axis.prototype.minLabelDistanceVertical = 40;
248
+ Axis.prototype.minLabelDistanceHorizontal = 50;
249
+ Axis.prototype.labelOffset = 10;
250
+ Axis.prototype.alternateLabelOffset = null;
251
+ Axis.prototype.labelRotation = 0;
252
+ Axis.prototype.labelAnchor = "auto";
253
+ Axis.prototype.labelDx = "auto";
254
+ Axis.prototype.labelDy = "auto";
255
+ Axis.prototype.labelWrap = false;
256
+ Axis.prototype.labelLineCountDyFactor = "auto";
257
+ Axis.prototype.labelLineHeight = 1;
258
+ Axis.prototype.labelMaxLineLength = 10;
259
+
260
+ Axis.namespace = "ui.svg.chart.axis";