cx 24.3.10 → 24.4.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/dist/charts.css +6 -0
- package/dist/charts.js +307 -62
- package/dist/manifest.js +748 -741
- package/dist/ui.js +58 -119
- package/package.json +1 -1
- package/src/charts/BarGraph.d.ts +7 -9
- package/src/charts/ColumnGraph.d.ts +10 -12
- package/src/charts/LineGraph.d.ts +1 -1
- package/src/charts/PieChart.d.ts +6 -0
- package/src/charts/PieChart.js +162 -82
- package/src/charts/RangeMarker.d.ts +35 -0
- package/src/charts/RangeMarker.js +155 -0
- package/src/charts/RangeMarker.scss +15 -0
- package/src/charts/ScatterGraph.d.ts +30 -32
- package/src/charts/index.d.ts +1 -0
- package/src/charts/index.js +1 -0
- package/src/charts/index.scss +1 -0
- package/src/charts/variables.scss +21 -20
- package/src/data/Expression.d.ts +17 -17
- package/src/data/Expression.js +220 -220
- package/src/data/StringTemplate.d.ts +15 -15
- package/src/data/StringTemplate.js +92 -92
- package/src/ui/Culture.d.ts +51 -47
- package/src/ui/Culture.js +129 -132
- package/src/ui/Cx.js +313 -311
- package/src/ui/Format.js +107 -107
- package/src/ui/Restate.d.ts +3 -0
- package/src/ui/Restate.js +163 -163
- package/src/ui/index.d.ts +0 -1
- package/src/ui/index.js +44 -45
- package/src/util/Console.d.ts +2 -7
- package/src/util/Format.d.ts +18 -18
- package/src/util/Format.js +234 -234
- package/src/widgets/drag-drop/DropZone.d.ts +9 -9
- package/src/widgets/grid/Grid.d.ts +12 -12
- package/src/ui/CultureScope.d.ts +0 -10
- package/src/ui/CultureScope.js +0 -55
package/src/util/Console.d.ts
CHANGED
package/src/util/Format.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
declare type Formatter = (any) => string;
|
|
2
|
-
|
|
3
|
-
export class Format {
|
|
4
|
-
static value(v: any, format: string): string;
|
|
5
|
-
|
|
6
|
-
static parse(format: string): Formatter;
|
|
7
|
-
|
|
8
|
-
static register(format: string | string[], formatter: Formatter): void;
|
|
9
|
-
|
|
10
|
-
static registerFactory(format: string | string[], factory: (...args) => Formatter): void;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function resolveMinMaxFractionDigits(
|
|
14
|
-
minimumFractionDigits: number,
|
|
15
|
-
maximumFractionDigits: number,
|
|
16
|
-
): { minimumFractionDigits: number; maximumFractionDigits: number };
|
|
17
|
-
|
|
18
|
-
export function setGetFormatCacheCallback(callback: () => {}): void;
|
|
1
|
+
declare type Formatter = (any) => string;
|
|
2
|
+
|
|
3
|
+
export class Format {
|
|
4
|
+
static value(v: any, format: string): string;
|
|
5
|
+
|
|
6
|
+
static parse(format: string): Formatter;
|
|
7
|
+
|
|
8
|
+
static register(format: string | string[], formatter: Formatter): void;
|
|
9
|
+
|
|
10
|
+
static registerFactory(format: string | string[], factory: (...args) => Formatter): void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function resolveMinMaxFractionDigits(
|
|
14
|
+
minimumFractionDigits: number,
|
|
15
|
+
maximumFractionDigits: number,
|
|
16
|
+
): { minimumFractionDigits: number; maximumFractionDigits: number };
|
|
17
|
+
|
|
18
|
+
export function setGetFormatCacheCallback(callback: () => {}): void;
|
package/src/util/Format.js
CHANGED
|
@@ -1,234 +1,234 @@
|
|
|
1
|
-
import { debug } from "./Debug";
|
|
2
|
-
import { GlobalCacheIdentifier } from "./GlobalCacheIdentifier";
|
|
3
|
-
import { isNumber } from "../util/isNumber";
|
|
4
|
-
import { isUndefined } from "../util/isUndefined";
|
|
5
|
-
import { isArray } from "../util/isArray";
|
|
6
|
-
|
|
7
|
-
//Culture dependent formatters are defined in the ui package.
|
|
8
|
-
|
|
9
|
-
const defaultFormatter = (v) => v.toString();
|
|
10
|
-
|
|
11
|
-
let formatFactory = {
|
|
12
|
-
string: function () {
|
|
13
|
-
return defaultFormatter;
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
wrap: function (part0, prefix, suffix) {
|
|
17
|
-
if (!prefix) prefix = "";
|
|
18
|
-
|
|
19
|
-
if (!suffix) suffix = "";
|
|
20
|
-
|
|
21
|
-
return (value) => prefix + value.toString() + suffix;
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
fixed: function (part0, digits) {
|
|
25
|
-
return (value) => value.toFixed(digits);
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
prefix: function (part0, prefix) {
|
|
29
|
-
if (!prefix) prefix = "";
|
|
30
|
-
|
|
31
|
-
return (value) => prefix + value.toString();
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
suffix: function (part0, suffix) {
|
|
35
|
-
if (!suffix) suffix = "";
|
|
36
|
-
|
|
37
|
-
return (value) => value.toString() + suffix;
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
uppercase: function () {
|
|
41
|
-
return (value) => value.toString().toUpperCase();
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
lowercase: function () {
|
|
45
|
-
return (value) => value.toString().toLowerCase();
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
urlencode: function () {
|
|
49
|
-
return (value) => encodeURIComponent(value);
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
number: function (part0, minFractionDigits, maxFractionDigits) {
|
|
53
|
-
let { minimumFractionDigits, maximumFractionDigits } = resolveMinMaxFractionDigits(
|
|
54
|
-
minFractionDigits,
|
|
55
|
-
maxFractionDigits,
|
|
56
|
-
);
|
|
57
|
-
let trimmable = maximumFractionDigits - minimumFractionDigits;
|
|
58
|
-
if (trimmable > 0) {
|
|
59
|
-
if (minimumFractionDigits == 0) ++trimmable;
|
|
60
|
-
return (value) => trimFractionZeros(value.toFixed(maximumFractionDigits), trimmable);
|
|
61
|
-
}
|
|
62
|
-
return (value) => value.toFixed(maximumFractionDigits);
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
percentage: function (part0, minFractionDigits, maxFractionDigits) {
|
|
66
|
-
let numberFormatter = formatFactory.number(part0, minFractionDigits, maxFractionDigits);
|
|
67
|
-
return (value) => numberFormatter(value * 100) + "%";
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
percentageSign: function (part0, minFractionDigits, maxFractionDigits) {
|
|
71
|
-
let numberFormatter = formatFactory.number(part0, minFractionDigits, maxFractionDigits);
|
|
72
|
-
return (value) => numberFormatter(value) + "%";
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
date: function () {
|
|
76
|
-
return (value) => {
|
|
77
|
-
let date = new Date(value);
|
|
78
|
-
return `${date.getMonth() + 1}/${date.getDate()}/${date.getFullYear()}`;
|
|
79
|
-
};
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
time: function () {
|
|
83
|
-
return (value) => {
|
|
84
|
-
let date = new Date(value);
|
|
85
|
-
let h = date.getHours() >= 10 ? date.getHours() : "0" + date.getHours();
|
|
86
|
-
let m = date.getMinutes() >= 10 ? date.getMinutes() : "0" + date.getMinutes();
|
|
87
|
-
return `${h}:${m}`;
|
|
88
|
-
};
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
datetime: function () {
|
|
92
|
-
let date = formatFactory.date();
|
|
93
|
-
let time = formatFactory.time();
|
|
94
|
-
return (value) => date(value) + " " + time(value);
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
ellipsis: function (part0, length, where) {
|
|
98
|
-
length = Number(length);
|
|
99
|
-
if (!(length > 3)) length = 10;
|
|
100
|
-
switch (where) {
|
|
101
|
-
default:
|
|
102
|
-
case "end":
|
|
103
|
-
return (value) => {
|
|
104
|
-
let s = String(value);
|
|
105
|
-
if (s.length > length) return s.substring(0, length - 3) + "...";
|
|
106
|
-
return s;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
case "start":
|
|
110
|
-
return (value) => {
|
|
111
|
-
let s = String(value);
|
|
112
|
-
if (s.length > length) return "..." + s.substring(s.length - length + 3);
|
|
113
|
-
return s;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
case "middle":
|
|
117
|
-
return (value) => {
|
|
118
|
-
let s = String(value);
|
|
119
|
-
if (s.length > length) {
|
|
120
|
-
let x = Math.floor(length - 2) / 2;
|
|
121
|
-
return s.substring(0, x) + "..." + s.substring(s.length - (length - 3 - x));
|
|
122
|
-
}
|
|
123
|
-
return s;
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
formatFactory.s = formatFactory.str = formatFactory.string;
|
|
130
|
-
formatFactory.f = formatFactory.fixed;
|
|
131
|
-
formatFactory.n = formatFactory.number;
|
|
132
|
-
formatFactory.p = formatFactory.percentage;
|
|
133
|
-
formatFactory.ps = formatFactory.percentageSign;
|
|
134
|
-
formatFactory.d = formatFactory.date;
|
|
135
|
-
formatFactory.t = formatFactory.time;
|
|
136
|
-
formatFactory.dt = formatFactory.datetime;
|
|
137
|
-
|
|
138
|
-
function buildFormatter(format) {
|
|
139
|
-
let formatter = defaultFormatter,
|
|
140
|
-
nullText = "";
|
|
141
|
-
if (format) {
|
|
142
|
-
let pipeParts = format.split("|");
|
|
143
|
-
nullText = pipeParts[1] || "";
|
|
144
|
-
let colonSepParts = pipeParts[0].split(":");
|
|
145
|
-
for (let i = 0; i < colonSepParts.length; i++) {
|
|
146
|
-
let parts = colonSepParts[i].split(";");
|
|
147
|
-
let factory = formatFactory[parts[0]];
|
|
148
|
-
if (!factory) debug("Unknown string format: " + format);
|
|
149
|
-
else if (i == 0) formatter = factory(...parts);
|
|
150
|
-
else {
|
|
151
|
-
let outerFmt = factory(...parts);
|
|
152
|
-
let innerFmt = formatter;
|
|
153
|
-
formatter = (v) => outerFmt(innerFmt(v));
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return (v) => (v == null || v === "" ? nullText : formatter(v));
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
let format = {
|
|
161
|
-
cache: {},
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
function getDefaultFormatCache() {
|
|
165
|
-
if (format.cacheIdentifier != GlobalCacheIdentifier.get()) {
|
|
166
|
-
format = {
|
|
167
|
-
cache: {},
|
|
168
|
-
cacheIdentifier: GlobalCacheIdentifier.get(),
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
return format.cache;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
let getFormatCache = getDefaultFormatCache;
|
|
175
|
-
|
|
176
|
-
export function setGetFormatCacheCallback(callback) {
|
|
177
|
-
getFormatCache = callback;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
function getFormatter(format) {
|
|
181
|
-
if (!format) format = "";
|
|
182
|
-
let formatCache = getFormatCache();
|
|
183
|
-
let formatter = formatCache[format];
|
|
184
|
-
if (!formatter) formatter = formatCache[format] = buildFormatter(format);
|
|
185
|
-
|
|
186
|
-
return formatter;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export class Format {
|
|
190
|
-
static value(v, format) {
|
|
191
|
-
let formatter = getFormatter(format);
|
|
192
|
-
return formatter(v);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
static parse(format) {
|
|
196
|
-
return getFormatter(format);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
static register(format, formatter) {
|
|
200
|
-
this.registerFactory(format, () => formatter);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
static registerFactory(format, factory) {
|
|
204
|
-
if (isArray(format)) format.forEach((f) => this.registerFactory(f, factory));
|
|
205
|
-
else formatFactory[format] = factory;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
export function resolveMinMaxFractionDigits(minimumFractionDigits, maximumFractionDigits) {
|
|
210
|
-
minimumFractionDigits = minimumFractionDigits != null ? Number(minimumFractionDigits) : minimumFractionDigits;
|
|
211
|
-
maximumFractionDigits = maximumFractionDigits != null ? Number(maximumFractionDigits) : maximumFractionDigits;
|
|
212
|
-
|
|
213
|
-
if (isNumber(minimumFractionDigits)) {
|
|
214
|
-
if (isUndefined(maximumFractionDigits)) maximumFractionDigits = minimumFractionDigits;
|
|
215
|
-
else if (isNumber(maximumFractionDigits) && maximumFractionDigits < minimumFractionDigits)
|
|
216
|
-
maximumFractionDigits = minimumFractionDigits;
|
|
217
|
-
} else if (minimumFractionDigits == null && maximumFractionDigits == null) {
|
|
218
|
-
minimumFractionDigits = 0;
|
|
219
|
-
maximumFractionDigits = 18;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
return {
|
|
223
|
-
minimumFractionDigits,
|
|
224
|
-
maximumFractionDigits,
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
export function trimFractionZeros(str, max) {
|
|
229
|
-
let cnt = 0,
|
|
230
|
-
l = str.length;
|
|
231
|
-
while (cnt < max && (str[l - 1 - cnt] === "0" || str[l - 1 - cnt] === ".")) cnt++;
|
|
232
|
-
|
|
233
|
-
return cnt > 0 ? str.substring(0, l - cnt) : str;
|
|
234
|
-
}
|
|
1
|
+
import { debug } from "./Debug";
|
|
2
|
+
import { GlobalCacheIdentifier } from "./GlobalCacheIdentifier";
|
|
3
|
+
import { isNumber } from "../util/isNumber";
|
|
4
|
+
import { isUndefined } from "../util/isUndefined";
|
|
5
|
+
import { isArray } from "../util/isArray";
|
|
6
|
+
|
|
7
|
+
//Culture dependent formatters are defined in the ui package.
|
|
8
|
+
|
|
9
|
+
const defaultFormatter = (v) => v.toString();
|
|
10
|
+
|
|
11
|
+
let formatFactory = {
|
|
12
|
+
string: function () {
|
|
13
|
+
return defaultFormatter;
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
wrap: function (part0, prefix, suffix) {
|
|
17
|
+
if (!prefix) prefix = "";
|
|
18
|
+
|
|
19
|
+
if (!suffix) suffix = "";
|
|
20
|
+
|
|
21
|
+
return (value) => prefix + value.toString() + suffix;
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
fixed: function (part0, digits) {
|
|
25
|
+
return (value) => value.toFixed(digits);
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
prefix: function (part0, prefix) {
|
|
29
|
+
if (!prefix) prefix = "";
|
|
30
|
+
|
|
31
|
+
return (value) => prefix + value.toString();
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
suffix: function (part0, suffix) {
|
|
35
|
+
if (!suffix) suffix = "";
|
|
36
|
+
|
|
37
|
+
return (value) => value.toString() + suffix;
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
uppercase: function () {
|
|
41
|
+
return (value) => value.toString().toUpperCase();
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
lowercase: function () {
|
|
45
|
+
return (value) => value.toString().toLowerCase();
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
urlencode: function () {
|
|
49
|
+
return (value) => encodeURIComponent(value);
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
number: function (part0, minFractionDigits, maxFractionDigits) {
|
|
53
|
+
let { minimumFractionDigits, maximumFractionDigits } = resolveMinMaxFractionDigits(
|
|
54
|
+
minFractionDigits,
|
|
55
|
+
maxFractionDigits,
|
|
56
|
+
);
|
|
57
|
+
let trimmable = maximumFractionDigits - minimumFractionDigits;
|
|
58
|
+
if (trimmable > 0) {
|
|
59
|
+
if (minimumFractionDigits == 0) ++trimmable;
|
|
60
|
+
return (value) => trimFractionZeros(value.toFixed(maximumFractionDigits), trimmable);
|
|
61
|
+
}
|
|
62
|
+
return (value) => value.toFixed(maximumFractionDigits);
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
percentage: function (part0, minFractionDigits, maxFractionDigits) {
|
|
66
|
+
let numberFormatter = formatFactory.number(part0, minFractionDigits, maxFractionDigits);
|
|
67
|
+
return (value) => numberFormatter(value * 100) + "%";
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
percentageSign: function (part0, minFractionDigits, maxFractionDigits) {
|
|
71
|
+
let numberFormatter = formatFactory.number(part0, minFractionDigits, maxFractionDigits);
|
|
72
|
+
return (value) => numberFormatter(value) + "%";
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
date: function () {
|
|
76
|
+
return (value) => {
|
|
77
|
+
let date = new Date(value);
|
|
78
|
+
return `${date.getMonth() + 1}/${date.getDate()}/${date.getFullYear()}`;
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
time: function () {
|
|
83
|
+
return (value) => {
|
|
84
|
+
let date = new Date(value);
|
|
85
|
+
let h = date.getHours() >= 10 ? date.getHours() : "0" + date.getHours();
|
|
86
|
+
let m = date.getMinutes() >= 10 ? date.getMinutes() : "0" + date.getMinutes();
|
|
87
|
+
return `${h}:${m}`;
|
|
88
|
+
};
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
datetime: function () {
|
|
92
|
+
let date = formatFactory.date();
|
|
93
|
+
let time = formatFactory.time();
|
|
94
|
+
return (value) => date(value) + " " + time(value);
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
ellipsis: function (part0, length, where) {
|
|
98
|
+
length = Number(length);
|
|
99
|
+
if (!(length > 3)) length = 10;
|
|
100
|
+
switch (where) {
|
|
101
|
+
default:
|
|
102
|
+
case "end":
|
|
103
|
+
return (value) => {
|
|
104
|
+
let s = String(value);
|
|
105
|
+
if (s.length > length) return s.substring(0, length - 3) + "...";
|
|
106
|
+
return s;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
case "start":
|
|
110
|
+
return (value) => {
|
|
111
|
+
let s = String(value);
|
|
112
|
+
if (s.length > length) return "..." + s.substring(s.length - length + 3);
|
|
113
|
+
return s;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
case "middle":
|
|
117
|
+
return (value) => {
|
|
118
|
+
let s = String(value);
|
|
119
|
+
if (s.length > length) {
|
|
120
|
+
let x = Math.floor(length - 2) / 2;
|
|
121
|
+
return s.substring(0, x) + "..." + s.substring(s.length - (length - 3 - x));
|
|
122
|
+
}
|
|
123
|
+
return s;
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
formatFactory.s = formatFactory.str = formatFactory.string;
|
|
130
|
+
formatFactory.f = formatFactory.fixed;
|
|
131
|
+
formatFactory.n = formatFactory.number;
|
|
132
|
+
formatFactory.p = formatFactory.percentage;
|
|
133
|
+
formatFactory.ps = formatFactory.percentageSign;
|
|
134
|
+
formatFactory.d = formatFactory.date;
|
|
135
|
+
formatFactory.t = formatFactory.time;
|
|
136
|
+
formatFactory.dt = formatFactory.datetime;
|
|
137
|
+
|
|
138
|
+
function buildFormatter(format) {
|
|
139
|
+
let formatter = defaultFormatter,
|
|
140
|
+
nullText = "";
|
|
141
|
+
if (format) {
|
|
142
|
+
let pipeParts = format.split("|");
|
|
143
|
+
nullText = pipeParts[1] || "";
|
|
144
|
+
let colonSepParts = pipeParts[0].split(":");
|
|
145
|
+
for (let i = 0; i < colonSepParts.length; i++) {
|
|
146
|
+
let parts = colonSepParts[i].split(";");
|
|
147
|
+
let factory = formatFactory[parts[0]];
|
|
148
|
+
if (!factory) debug("Unknown string format: " + format);
|
|
149
|
+
else if (i == 0) formatter = factory(...parts);
|
|
150
|
+
else {
|
|
151
|
+
let outerFmt = factory(...parts);
|
|
152
|
+
let innerFmt = formatter;
|
|
153
|
+
formatter = (v) => outerFmt(innerFmt(v));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return (v) => (v == null || v === "" ? nullText : formatter(v));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
let format = {
|
|
161
|
+
cache: {},
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
function getDefaultFormatCache() {
|
|
165
|
+
if (format.cacheIdentifier != GlobalCacheIdentifier.get()) {
|
|
166
|
+
format = {
|
|
167
|
+
cache: {},
|
|
168
|
+
cacheIdentifier: GlobalCacheIdentifier.get(),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
return format.cache;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
let getFormatCache = getDefaultFormatCache;
|
|
175
|
+
|
|
176
|
+
export function setGetFormatCacheCallback(callback) {
|
|
177
|
+
getFormatCache = callback;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function getFormatter(format) {
|
|
181
|
+
if (!format) format = "";
|
|
182
|
+
let formatCache = getFormatCache();
|
|
183
|
+
let formatter = formatCache[format];
|
|
184
|
+
if (!formatter) formatter = formatCache[format] = buildFormatter(format);
|
|
185
|
+
|
|
186
|
+
return formatter;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export class Format {
|
|
190
|
+
static value(v, format) {
|
|
191
|
+
let formatter = getFormatter(format);
|
|
192
|
+
return formatter(v);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
static parse(format) {
|
|
196
|
+
return getFormatter(format);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
static register(format, formatter) {
|
|
200
|
+
this.registerFactory(format, () => formatter);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
static registerFactory(format, factory) {
|
|
204
|
+
if (isArray(format)) format.forEach((f) => this.registerFactory(f, factory));
|
|
205
|
+
else formatFactory[format] = factory;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export function resolveMinMaxFractionDigits(minimumFractionDigits, maximumFractionDigits) {
|
|
210
|
+
minimumFractionDigits = minimumFractionDigits != null ? Number(minimumFractionDigits) : minimumFractionDigits;
|
|
211
|
+
maximumFractionDigits = maximumFractionDigits != null ? Number(maximumFractionDigits) : maximumFractionDigits;
|
|
212
|
+
|
|
213
|
+
if (isNumber(minimumFractionDigits)) {
|
|
214
|
+
if (isUndefined(maximumFractionDigits)) maximumFractionDigits = minimumFractionDigits;
|
|
215
|
+
else if (isNumber(maximumFractionDigits) && maximumFractionDigits < minimumFractionDigits)
|
|
216
|
+
maximumFractionDigits = minimumFractionDigits;
|
|
217
|
+
} else if (minimumFractionDigits == null && maximumFractionDigits == null) {
|
|
218
|
+
minimumFractionDigits = 0;
|
|
219
|
+
maximumFractionDigits = 18;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return {
|
|
223
|
+
minimumFractionDigits,
|
|
224
|
+
maximumFractionDigits,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export function trimFractionZeros(str, max) {
|
|
229
|
+
let cnt = 0,
|
|
230
|
+
l = str.length;
|
|
231
|
+
while (cnt < max && (str[l - 1 - cnt] === "0" || str[l - 1 - cnt] === ".")) cnt++;
|
|
232
|
+
|
|
233
|
+
return cnt > 0 ? str.substring(0, l - cnt) : str;
|
|
234
|
+
}
|
|
@@ -55,35 +55,35 @@ interface DropZoneProps extends Cx.StyledContainerProps {
|
|
|
55
55
|
* instance
|
|
56
56
|
Return value is written into dragDropEvent.result and can be passed
|
|
57
57
|
to the source's onDragEnd callback. */
|
|
58
|
-
onDrop?: (event?: DragEvent, instance?: Instance) => any;
|
|
58
|
+
onDrop?: string | ((event?: DragEvent, instance?: Instance) => any);
|
|
59
59
|
|
|
60
60
|
/** A callback method used to test if dragged item (source) is compatible
|
|
61
61
|
with the drop zone. */
|
|
62
|
-
onDropTest?: (event?: DragEvent, instance?: Instance) => boolean;
|
|
62
|
+
onDropTest?: string | ((event?: DragEvent, instance?: Instance) => boolean);
|
|
63
63
|
|
|
64
64
|
/** A callback method invoked when the dragged item gets close to the drop zone.
|
|
65
65
|
See also `nearDistance`. */
|
|
66
|
-
onDragNear?: (event?: DragEvent, instance?: Instance) => void;
|
|
66
|
+
onDragNear?: string | ((event?: DragEvent, instance?: Instance) => void);
|
|
67
67
|
|
|
68
68
|
/** A callback method invoked when the dragged item is dragged away. */
|
|
69
|
-
onDragAway?: (event?: DragEvent, instance?: Instance) => void;
|
|
69
|
+
onDragAway?: string | ((event?: DragEvent, instance?: Instance) => void);
|
|
70
70
|
|
|
71
71
|
/** A callback method invoked when the dragged item is dragged over the drop zone.
|
|
72
72
|
The callback is called for each `mousemove` or `touchmove` event. */
|
|
73
|
-
onDragOver?: (event?: DragEvent, instance?: Instance) => void;
|
|
73
|
+
onDragOver?: string | ((event?: DragEvent, instance?: Instance) => void);
|
|
74
74
|
|
|
75
75
|
/** A callback method invoked when the dragged item is dragged over the drop zone
|
|
76
76
|
for the first time. */
|
|
77
|
-
onDragEnter?: (event?: DragEvent, instance?: Instance) => void;
|
|
77
|
+
onDragEnter?: string | ((event?: DragEvent, instance?: Instance) => void);
|
|
78
78
|
|
|
79
79
|
/** A callback method invoked when the dragged item leaves the drop zone area. */
|
|
80
|
-
onDragLeave?: (event?: DragEvent, instance?: Instance) => void;
|
|
80
|
+
onDragLeave?: string | ((event?: DragEvent, instance?: Instance) => void);
|
|
81
81
|
|
|
82
82
|
/** A callback method invoked when at the beginning of the drag & drop operation. */
|
|
83
|
-
onDragStart?: (event?: DragEvent, instance?: Instance) => void;
|
|
83
|
+
onDragStart?: string | ((event?: DragEvent, instance?: Instance) => void);
|
|
84
84
|
|
|
85
85
|
/** A callback method invoked when at the end of the drag & drop operation. */
|
|
86
|
-
onDragEnd?: (event?: DragEvent, instance?: Instance) => void;
|
|
86
|
+
onDragEnd?: string | ((event?: DragEvent, instance?: Instance) => void);
|
|
87
87
|
|
|
88
88
|
/** Match height of the item being dragged */
|
|
89
89
|
matchHeight?: boolean;
|
|
@@ -284,18 +284,18 @@ interface GridProps<T = unknown> extends StyledContainerProps {
|
|
|
284
284
|
rowStyle?: StyleProp;
|
|
285
285
|
|
|
286
286
|
// drag-drop handlers
|
|
287
|
-
onDrop?: (e: GridDragEvent, instance: Instance) => void;
|
|
288
|
-
onDropTest?: (e: DragEvent, instance: Instance) => boolean;
|
|
289
|
-
onDragStart?: (e: DragEvent, instance: Instance) => void;
|
|
290
|
-
onDragEnd?: (e: DragEvent, instance: Instance) => void;
|
|
291
|
-
onDragOver?: (e: GridDragEvent, instance: Instance) => void | boolean;
|
|
292
|
-
|
|
293
|
-
onRowDropTest?: (e: DragEvent, instance: Instance) => boolean;
|
|
294
|
-
onRowDragOver?: (e: GridRowDragEvent, instance: Instance) => void | boolean;
|
|
295
|
-
onRowDrop?: (e: GridRowDragEvent, instance: Instance) => void | boolean;
|
|
296
|
-
|
|
297
|
-
onColumnDrop?: (e: GridColumnDropEvent, instance: Instance) => void;
|
|
298
|
-
onColumnDropTest?: (e: DragEvent, instance: Instance) => boolean;
|
|
287
|
+
onDrop?: string | ((e: GridDragEvent, instance: Instance) => void);
|
|
288
|
+
onDropTest?: string | ((e: DragEvent, instance: Instance) => boolean);
|
|
289
|
+
onDragStart?: string | ((e: DragEvent, instance: Instance) => void);
|
|
290
|
+
onDragEnd?: string | ((e: DragEvent, instance: Instance) => void);
|
|
291
|
+
onDragOver?: string | ((e: GridDragEvent, instance: Instance) => void | boolean);
|
|
292
|
+
|
|
293
|
+
onRowDropTest?: string | ((e: DragEvent, instance: Instance) => boolean);
|
|
294
|
+
onRowDragOver?: string | ((e: GridRowDragEvent, instance: Instance) => void | boolean);
|
|
295
|
+
onRowDrop?: string | ((e: GridRowDragEvent, instance: Instance) => void | boolean);
|
|
296
|
+
|
|
297
|
+
onColumnDrop?: string | ((e: GridColumnDropEvent, instance: Instance) => void);
|
|
298
|
+
onColumnDropTest?: string | ((e: DragEvent, instance: Instance) => boolean);
|
|
299
299
|
|
|
300
300
|
/** Parameters that affect filtering. */
|
|
301
301
|
filterParams?: StructuredProp;
|
package/src/ui/CultureScope.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as Cx from "../core";
|
|
2
|
-
|
|
3
|
-
interface CultureScopeProps extends Cx.PureContainerProps {
|
|
4
|
-
culture: Cx.StringProp;
|
|
5
|
-
numberCulture: Cx.StringProp;
|
|
6
|
-
dateTimeCulture: Cx.StringProp;
|
|
7
|
-
defaultCurrency: Cx.StringProp;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export class CultureScope extends Cx.Widget<CultureScopeProps> {}
|
package/src/ui/CultureScope.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { createCulture, popCulture, pushCulture } from "./Culture";
|
|
2
|
-
import { PureContainer } from "./PureContainer";
|
|
3
|
-
|
|
4
|
-
export class CultureScope extends PureContainer {
|
|
5
|
-
init() {
|
|
6
|
-
this.initialItems = this.items ?? this.children;
|
|
7
|
-
delete this.items;
|
|
8
|
-
delete this.children;
|
|
9
|
-
super.init();
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
declareData(...args) {
|
|
13
|
-
super.declareData(...args, {
|
|
14
|
-
culture: undefined,
|
|
15
|
-
numberCulture: undefined,
|
|
16
|
-
dateTimeCulture: undefined,
|
|
17
|
-
defaultCurrency: undefined,
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
prepareData(context, instance) {
|
|
22
|
-
super.prepareData(context, instance);
|
|
23
|
-
this.clear();
|
|
24
|
-
let { data } = instance;
|
|
25
|
-
|
|
26
|
-
if (this.onCreateCulture) instance.culture = instance.invoke("onCreateCulture", data, instance);
|
|
27
|
-
else
|
|
28
|
-
instance.culture = createCulture({
|
|
29
|
-
culture: data.culture,
|
|
30
|
-
numberCulture: data.numberCulture,
|
|
31
|
-
dateTimeCulture: data.dateTimeCulture,
|
|
32
|
-
defaultCurrency: data.defaultCurrency,
|
|
33
|
-
dateEncoding: this.dateEncoding,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
explore(context, instance) {
|
|
38
|
-
let { culture } = instance;
|
|
39
|
-
pushCulture(culture);
|
|
40
|
-
if (this.items.length == 0 && this.initialItems) this.add(this.initialItems);
|
|
41
|
-
context.push("cultureInfo", culture);
|
|
42
|
-
super.explore(context, instance);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
exploreCleanup(context, instance) {
|
|
46
|
-
context.pop("cultureInfo");
|
|
47
|
-
popCulture();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
CultureScope.prototype.culture = null;
|
|
52
|
-
CultureScope.prototype.numberCulture = null;
|
|
53
|
-
CultureScope.prototype.dateTimeCulture = null;
|
|
54
|
-
CultureScope.prototype.defaultCurrency = null;
|
|
55
|
-
CultureScope.prototype.dateEncoding = null;
|