cx 24.10.8 → 24.10.10

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 (72) hide show
  1. package/dist/charts.js +11 -1
  2. package/dist/manifest.js +655 -655
  3. package/package.json +32 -32
  4. package/src/charts/PieChart.js +529 -529
  5. package/src/charts/PieLabel.js +71 -71
  6. package/src/charts/axis/Axis.js +280 -280
  7. package/src/charts/axis/CategoryAxis.js +235 -235
  8. package/src/charts/axis/NumericAxis.js +351 -347
  9. package/src/charts/axis/Stack.js +55 -55
  10. package/src/charts/axis/TimeAxis.d.ts +28 -28
  11. package/src/charts/axis/TimeAxis.js +610 -601
  12. package/src/charts/helpers/PointReducer.js +47 -47
  13. package/src/charts/helpers/SnapPointFinder.js +69 -69
  14. package/src/data/Binding.spec.js +69 -69
  15. package/src/data/Expression.js +221 -221
  16. package/src/data/Expression.spec.js +184 -184
  17. package/src/data/StringTemplate.spec.js +105 -105
  18. package/src/data/getAccessor.spec.js +11 -11
  19. package/src/index.scss +6 -6
  20. package/src/svg/Text.d.ts +40 -40
  21. package/src/ui/Culture.d.ts +55 -55
  22. package/src/ui/Culture.js +139 -139
  23. package/src/ui/FocusManager.js +171 -171
  24. package/src/ui/Instance.d.ts +72 -72
  25. package/src/ui/Instance.js +614 -614
  26. package/src/ui/VDOM.d.ts +12 -12
  27. package/src/ui/app/startAppLoop.js +58 -58
  28. package/src/ui/index.d.ts +42 -42
  29. package/src/ui/layout/ContentPlaceholder.d.ts +19 -19
  30. package/src/ui/layout/ContentPlaceholder.js +105 -105
  31. package/src/ui/layout/ContentPlaceholder.spec.js +579 -579
  32. package/src/ui/layout/LabelsTopLayout.js +134 -134
  33. package/src/util/Console.d.ts +4 -4
  34. package/src/util/index.d.ts +51 -51
  35. package/src/util/index.js +54 -54
  36. package/src/util/isValidIdentifierName.d.ts +1 -1
  37. package/src/util/isValidIdentifierName.js +5 -5
  38. package/src/util/isValidIdentifierName.spec.js +33 -33
  39. package/src/util/scss/add-rules.scss +38 -38
  40. package/src/widgets/CxCredit.scss +37 -37
  41. package/src/widgets/HighlightedSearchText.js +36 -36
  42. package/src/widgets/HighlightedSearchText.scss +18 -18
  43. package/src/widgets/List.scss +91 -91
  44. package/src/widgets/drag-drop/DropZone.js +214 -214
  45. package/src/widgets/form/Calendar.scss +196 -196
  46. package/src/widgets/form/ColorField.js +397 -397
  47. package/src/widgets/form/ColorPicker.scss +283 -283
  48. package/src/widgets/form/DateTimeField.js +573 -573
  49. package/src/widgets/form/LookupField.d.ts +179 -179
  50. package/src/widgets/form/MonthField.js +516 -516
  51. package/src/widgets/form/MonthPicker.scss +118 -118
  52. package/src/widgets/form/NumberField.js +459 -459
  53. package/src/widgets/form/NumberField.scss +61 -61
  54. package/src/widgets/form/Select.scss +99 -99
  55. package/src/widgets/form/Slider.scss +118 -118
  56. package/src/widgets/form/Switch.scss +140 -140
  57. package/src/widgets/form/TextArea.scss +43 -43
  58. package/src/widgets/form/TextField.js +290 -290
  59. package/src/widgets/form/TextField.scss +55 -55
  60. package/src/widgets/form/UploadButton.d.ts +34 -34
  61. package/src/widgets/form/variables.scss +353 -353
  62. package/src/widgets/grid/Grid.d.ts +5 -5
  63. package/src/widgets/grid/TreeNode.d.ts +16 -18
  64. package/src/widgets/grid/TreeNode.scss +88 -88
  65. package/src/widgets/nav/Menu.scss +74 -74
  66. package/src/widgets/overlay/Dropdown.js +612 -612
  67. package/src/widgets/overlay/FlyweightTooltipTracker.js +39 -39
  68. package/src/widgets/overlay/Tooltip.js +300 -300
  69. package/src/widgets/overlay/Window.js +196 -196
  70. package/src/widgets/overlay/captureMouse.js +124 -124
  71. package/src/widgets/overlay/variables.scss +83 -83
  72. package/src/widgets/variables.scss +144 -144
@@ -1,221 +1,221 @@
1
- import { computable } from "./computable";
2
- import { Format } from "../util/Format";
3
- import { Binding } from "./Binding";
4
-
5
- import { quoteStr } from "../util/quote";
6
- import { isFunction } from "../util/isFunction";
7
- import { isValidIdentifierName } from "../util/isValidIdentifierName";
8
-
9
- /*
10
- Helper usage example
11
-
12
- Expression.registerHelper('_', _);
13
- let e = Expression.compile('_.min({data})');
14
- */
15
-
16
- let helpers = {},
17
- helperNames = [],
18
- helperValues = [],
19
- expFatArrows = null;
20
-
21
- function getExpr(expr) {
22
- if (expr.memoize) return expr;
23
-
24
- function memoize() {
25
- let lastValue,
26
- lastRunBindings = {},
27
- lastRunResults = {},
28
- getters = {},
29
- currentData,
30
- len = -1;
31
-
32
- let get = function (bindingWithFormat) {
33
- let getter = getters[bindingWithFormat];
34
- if (!getter) {
35
- let binding = bindingWithFormat,
36
- format;
37
- let colonIndex = bindingWithFormat.indexOf(":");
38
- if (colonIndex != -1) {
39
- format = Format.parse(bindingWithFormat.substring(colonIndex + 1));
40
- binding = bindingWithFormat.substring(0, colonIndex);
41
- } else {
42
- let nullSeparatorIndex = bindingWithFormat.indexOf(":");
43
- if (nullSeparatorIndex != -1) {
44
- format = Format.parse(bindingWithFormat.substring(nullSeparatorIndex));
45
- binding = bindingWithFormat.substring(0, nullSeparatorIndex - 1);
46
- }
47
- }
48
- let b = Binding.get(binding);
49
- getter = (data) => {
50
- let value = b.value(data);
51
- lastRunBindings[len] = b.value;
52
- lastRunResults[len] = value;
53
- len++;
54
- return value;
55
- };
56
-
57
- if (format) {
58
- let valueGetter = getter;
59
- getter = (data) => format(valueGetter(data));
60
- }
61
-
62
- getters[bindingWithFormat] = getter;
63
- }
64
- return getter(currentData);
65
- };
66
-
67
- return function (data) {
68
- let i = 0;
69
- for (; i < len; i++) if (lastRunBindings[i](data) !== lastRunResults[i]) break;
70
- if (i !== len) {
71
- len = 0;
72
- currentData = data;
73
- lastValue = expr(get);
74
- }
75
- return lastValue;
76
- };
77
- }
78
-
79
- let result = memoize();
80
- result.memoize = memoize;
81
- return result;
82
- }
83
-
84
- export function expression(str) {
85
- if (isFunction(str)) return getExpr(str);
86
-
87
- let cache = getExpressionCache();
88
- let r = cache[str];
89
- if (r) return r;
90
-
91
- let quote = false;
92
-
93
- let termStart = -1,
94
- curlyBrackets = 0,
95
- percentExpression;
96
-
97
- let fb = ["return ("];
98
-
99
- let args = {};
100
- let formats = [];
101
- let subExprCount = 0;
102
- let invalidNameCount = 0;
103
-
104
- for (let i = 0; i < str.length; i++) {
105
- let c = str[i];
106
- switch (c) {
107
- case "{":
108
- if (curlyBrackets > 0) curlyBrackets++;
109
- else {
110
- if (!quote && termStart < 0 && (str[i + 1] != "{" || str[i - 1] == "%")) {
111
- termStart = i + 1;
112
- curlyBrackets = 1;
113
- percentExpression = str[i - 1] == "%";
114
- if (percentExpression) fb.pop(); //%
115
- } else if (str[i - 1] != "{") fb.push(c);
116
- }
117
- break;
118
-
119
- case "}":
120
- if (termStart >= 0) {
121
- if (--curlyBrackets == 0) {
122
- let term = str.substring(termStart, i);
123
- let formatStart = 0;
124
- if (term[0] == "[") formatStart = term.indexOf("]");
125
- let colon = term.indexOf(":", formatStart > 0 ? formatStart : 0);
126
- let binding = colon == -1 ? term : term.substring(0, colon);
127
- let format = colon == -1 ? null : term.substring(colon + 1);
128
- if (colon == -1) {
129
- let nullSepIndex = binding.indexOf("|", formatStart);
130
- if (nullSepIndex != -1) {
131
- format = binding.substring(nullSepIndex);
132
- binding = binding.substring(0, nullSepIndex);
133
- }
134
- }
135
- let argName = binding.replace(/\./g, "_");
136
- if (!isValidIdentifierName(argName)) argName = "inv" + ++invalidNameCount;
137
- if (percentExpression || (binding[0] == "[" && binding[binding.length - 1] == "]")) {
138
- argName = `expr${++subExprCount}`;
139
- args[argName] = expression(percentExpression ? binding : binding.substring(1, binding.length - 1));
140
- } else args[argName] = binding;
141
- if (format) {
142
- let formatter = "fmt" + formats.length;
143
- fb.push(formatter, "(", argName, ", ", quoteStr(format), ")");
144
- formats.push(Format.parse(format));
145
- } else fb.push(argName);
146
- termStart = -1;
147
- }
148
- } else fb.push(c);
149
-
150
- break;
151
-
152
- case '"':
153
- case "'":
154
- if (curlyBrackets == 0) {
155
- if (!quote) quote = c;
156
- else if (str[i - 1] != "\\" && quote == c) quote = false;
157
- fb.push(c);
158
- }
159
- break;
160
-
161
- default:
162
- if (termStart < 0) fb.push(c);
163
- break;
164
- }
165
- }
166
-
167
- fb.push(")");
168
-
169
- let body = fb.join("");
170
-
171
- if (expFatArrows) body = expFatArrows(body);
172
-
173
- //console.log(body);
174
- let keys = Object.keys(args);
175
-
176
- try {
177
- let compute = new Function("fmt", ...formats.map((f, i) => "fmt" + i), ...keys, ...helperNames, body).bind(
178
- Format,
179
- Format.value,
180
- ...formats,
181
- ...helperValues,
182
- );
183
- let selector = computable(...keys.map((k) => args[k]), compute);
184
- cache[str] = selector;
185
- return selector;
186
- } catch (err) {
187
- throw new Error(`Failed to parse expression: '${str}'. Error: ${err.message}`);
188
- }
189
- }
190
-
191
- export const Expression = {
192
- get: function (str) {
193
- return expression(str);
194
- },
195
-
196
- compile: function (str) {
197
- return this.get(str).memoize();
198
- },
199
-
200
- registerHelper: function (name, helper) {
201
- helpers[name] = helper;
202
- helperNames = Object.keys(helpers);
203
- helperValues = helperNames.map((n) => helpers[n]);
204
- },
205
- };
206
-
207
- export function plugFatArrowExpansion(impl) {
208
- expFatArrows = impl;
209
- }
210
-
211
- export function invalidateExpressionCache() {
212
- expCache = {};
213
- }
214
-
215
- let expCache = {};
216
-
217
- let getExpressionCache = () => expCache;
218
-
219
- export function setGetExpressionCacheCallback(callback) {
220
- getExpressionCache = callback;
221
- }
1
+ import { computable } from "./computable";
2
+ import { Format } from "../util/Format";
3
+ import { Binding } from "./Binding";
4
+
5
+ import { quoteStr } from "../util/quote";
6
+ import { isFunction } from "../util/isFunction";
7
+ import { isValidIdentifierName } from "../util/isValidIdentifierName";
8
+
9
+ /*
10
+ Helper usage example
11
+
12
+ Expression.registerHelper('_', _);
13
+ let e = Expression.compile('_.min({data})');
14
+ */
15
+
16
+ let helpers = {},
17
+ helperNames = [],
18
+ helperValues = [],
19
+ expFatArrows = null;
20
+
21
+ function getExpr(expr) {
22
+ if (expr.memoize) return expr;
23
+
24
+ function memoize() {
25
+ let lastValue,
26
+ lastRunBindings = {},
27
+ lastRunResults = {},
28
+ getters = {},
29
+ currentData,
30
+ len = -1;
31
+
32
+ let get = function (bindingWithFormat) {
33
+ let getter = getters[bindingWithFormat];
34
+ if (!getter) {
35
+ let binding = bindingWithFormat,
36
+ format;
37
+ let colonIndex = bindingWithFormat.indexOf(":");
38
+ if (colonIndex != -1) {
39
+ format = Format.parse(bindingWithFormat.substring(colonIndex + 1));
40
+ binding = bindingWithFormat.substring(0, colonIndex);
41
+ } else {
42
+ let nullSeparatorIndex = bindingWithFormat.indexOf(":");
43
+ if (nullSeparatorIndex != -1) {
44
+ format = Format.parse(bindingWithFormat.substring(nullSeparatorIndex));
45
+ binding = bindingWithFormat.substring(0, nullSeparatorIndex - 1);
46
+ }
47
+ }
48
+ let b = Binding.get(binding);
49
+ getter = (data) => {
50
+ let value = b.value(data);
51
+ lastRunBindings[len] = b.value;
52
+ lastRunResults[len] = value;
53
+ len++;
54
+ return value;
55
+ };
56
+
57
+ if (format) {
58
+ let valueGetter = getter;
59
+ getter = (data) => format(valueGetter(data));
60
+ }
61
+
62
+ getters[bindingWithFormat] = getter;
63
+ }
64
+ return getter(currentData);
65
+ };
66
+
67
+ return function (data) {
68
+ let i = 0;
69
+ for (; i < len; i++) if (lastRunBindings[i](data) !== lastRunResults[i]) break;
70
+ if (i !== len) {
71
+ len = 0;
72
+ currentData = data;
73
+ lastValue = expr(get);
74
+ }
75
+ return lastValue;
76
+ };
77
+ }
78
+
79
+ let result = memoize();
80
+ result.memoize = memoize;
81
+ return result;
82
+ }
83
+
84
+ export function expression(str) {
85
+ if (isFunction(str)) return getExpr(str);
86
+
87
+ let cache = getExpressionCache();
88
+ let r = cache[str];
89
+ if (r) return r;
90
+
91
+ let quote = false;
92
+
93
+ let termStart = -1,
94
+ curlyBrackets = 0,
95
+ percentExpression;
96
+
97
+ let fb = ["return ("];
98
+
99
+ let args = {};
100
+ let formats = [];
101
+ let subExprCount = 0;
102
+ let invalidNameCount = 0;
103
+
104
+ for (let i = 0; i < str.length; i++) {
105
+ let c = str[i];
106
+ switch (c) {
107
+ case "{":
108
+ if (curlyBrackets > 0) curlyBrackets++;
109
+ else {
110
+ if (!quote && termStart < 0 && (str[i + 1] != "{" || str[i - 1] == "%")) {
111
+ termStart = i + 1;
112
+ curlyBrackets = 1;
113
+ percentExpression = str[i - 1] == "%";
114
+ if (percentExpression) fb.pop(); //%
115
+ } else if (str[i - 1] != "{") fb.push(c);
116
+ }
117
+ break;
118
+
119
+ case "}":
120
+ if (termStart >= 0) {
121
+ if (--curlyBrackets == 0) {
122
+ let term = str.substring(termStart, i);
123
+ let formatStart = 0;
124
+ if (term[0] == "[") formatStart = term.indexOf("]");
125
+ let colon = term.indexOf(":", formatStart > 0 ? formatStart : 0);
126
+ let binding = colon == -1 ? term : term.substring(0, colon);
127
+ let format = colon == -1 ? null : term.substring(colon + 1);
128
+ if (colon == -1) {
129
+ let nullSepIndex = binding.indexOf("|", formatStart);
130
+ if (nullSepIndex != -1) {
131
+ format = binding.substring(nullSepIndex);
132
+ binding = binding.substring(0, nullSepIndex);
133
+ }
134
+ }
135
+ let argName = binding.replace(/\./g, "_");
136
+ if (!isValidIdentifierName(argName)) argName = "inv" + ++invalidNameCount;
137
+ if (percentExpression || (binding[0] == "[" && binding[binding.length - 1] == "]")) {
138
+ argName = `expr${++subExprCount}`;
139
+ args[argName] = expression(percentExpression ? binding : binding.substring(1, binding.length - 1));
140
+ } else args[argName] = binding;
141
+ if (format) {
142
+ let formatter = "fmt" + formats.length;
143
+ fb.push(formatter, "(", argName, ", ", quoteStr(format), ")");
144
+ formats.push(Format.parse(format));
145
+ } else fb.push(argName);
146
+ termStart = -1;
147
+ }
148
+ } else fb.push(c);
149
+
150
+ break;
151
+
152
+ case '"':
153
+ case "'":
154
+ if (curlyBrackets == 0) {
155
+ if (!quote) quote = c;
156
+ else if (str[i - 1] != "\\" && quote == c) quote = false;
157
+ fb.push(c);
158
+ }
159
+ break;
160
+
161
+ default:
162
+ if (termStart < 0) fb.push(c);
163
+ break;
164
+ }
165
+ }
166
+
167
+ fb.push(")");
168
+
169
+ let body = fb.join("");
170
+
171
+ if (expFatArrows) body = expFatArrows(body);
172
+
173
+ //console.log(body);
174
+ let keys = Object.keys(args);
175
+
176
+ try {
177
+ let compute = new Function("fmt", ...formats.map((f, i) => "fmt" + i), ...keys, ...helperNames, body).bind(
178
+ Format,
179
+ Format.value,
180
+ ...formats,
181
+ ...helperValues,
182
+ );
183
+ let selector = computable(...keys.map((k) => args[k]), compute);
184
+ cache[str] = selector;
185
+ return selector;
186
+ } catch (err) {
187
+ throw new Error(`Failed to parse expression: '${str}'. Error: ${err.message}`);
188
+ }
189
+ }
190
+
191
+ export const Expression = {
192
+ get: function (str) {
193
+ return expression(str);
194
+ },
195
+
196
+ compile: function (str) {
197
+ return this.get(str).memoize();
198
+ },
199
+
200
+ registerHelper: function (name, helper) {
201
+ helpers[name] = helper;
202
+ helperNames = Object.keys(helpers);
203
+ helperValues = helperNames.map((n) => helpers[n]);
204
+ },
205
+ };
206
+
207
+ export function plugFatArrowExpansion(impl) {
208
+ expFatArrows = impl;
209
+ }
210
+
211
+ export function invalidateExpressionCache() {
212
+ expCache = {};
213
+ }
214
+
215
+ let expCache = {};
216
+
217
+ let getExpressionCache = () => expCache;
218
+
219
+ export function setGetExpressionCacheCallback(callback) {
220
+ getExpressionCache = callback;
221
+ }