cx 24.2.0 → 24.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/charts.js +61 -63
- package/dist/data.js +43 -52
- package/dist/manifest.js +781 -775
- package/dist/svg.js +70 -71
- package/dist/ui.js +103 -111
- package/dist/util.js +94 -13
- package/dist/widgets.js +209 -217
- package/package.json +1 -1
- package/src/charts/axis/TimeAxis.js +7 -6
- package/src/ui/Format.js +4 -3
- package/src/util/Format.js +73 -86
- package/src/util/date/index.d.ts +10 -9
- package/src/util/date/index.js +10 -9
- package/src/util/date/parseDateInvariant.d.ts +3 -0
- package/src/util/date/parseDateInvariant.js +20 -0
- package/src/widgets/form/Calendar.js +27 -26
- package/src/widgets/form/DateTimeField.js +8 -5
- package/src/widgets/form/DateTimePicker.js +9 -8
- package/src/widgets/form/MonthField.js +7 -7
- package/src/widgets/form/MonthPicker.js +17 -16
package/package.json
CHANGED
|
@@ -4,12 +4,13 @@ import { Stack } from "./Stack";
|
|
|
4
4
|
import { Format } from "../../ui/Format";
|
|
5
5
|
import { isNumber } from "../../util/isNumber";
|
|
6
6
|
import { zeroTime } from "../../util/date/zeroTime";
|
|
7
|
+
import { parseDateInvariant } from "../../util";
|
|
7
8
|
|
|
8
9
|
Format.registerFactory("yearOrMonth", (format) => {
|
|
9
10
|
let year = Format.parse("datetime;yyyy");
|
|
10
11
|
let month = Format.parse("datetime;MMM");
|
|
11
12
|
return function (date) {
|
|
12
|
-
let d =
|
|
13
|
+
let d = parseDateInvariant(date);
|
|
13
14
|
if (d.getMonth() == 0) return year(d);
|
|
14
15
|
else return month(d);
|
|
15
16
|
};
|
|
@@ -19,7 +20,7 @@ Format.registerFactory("monthOrDay", (format) => {
|
|
|
19
20
|
let month = Format.parse("datetime;MMM");
|
|
20
21
|
let day = Format.parse("datetime;dd");
|
|
21
22
|
return function (date) {
|
|
22
|
-
let d =
|
|
23
|
+
let d = parseDateInvariant(date);
|
|
23
24
|
if (d.getDate() == 1) return month(d);
|
|
24
25
|
else return day(d);
|
|
25
26
|
};
|
|
@@ -69,7 +70,7 @@ export class TimeAxis extends Axis {
|
|
|
69
70
|
this.minTickUnit,
|
|
70
71
|
lowerDeadZone,
|
|
71
72
|
upperDeadZone,
|
|
72
|
-
this.decode
|
|
73
|
+
this.decode,
|
|
73
74
|
);
|
|
74
75
|
}
|
|
75
76
|
|
|
@@ -149,7 +150,7 @@ class TimeScale {
|
|
|
149
150
|
minTickUnit,
|
|
150
151
|
lowerDeadZone,
|
|
151
152
|
upperDeadZone,
|
|
152
|
-
decode
|
|
153
|
+
decode,
|
|
153
154
|
) {
|
|
154
155
|
this.dateCache = {};
|
|
155
156
|
this.min = min != null ? this.decodeValue(min) : null;
|
|
@@ -180,12 +181,12 @@ class TimeScale {
|
|
|
180
181
|
let v = this.dateCache[date];
|
|
181
182
|
if (!v) {
|
|
182
183
|
if (this.decode) date = this.decode(date);
|
|
183
|
-
v = this.dateCache[date] =
|
|
184
|
+
v = this.dateCache[date] = parseDateInvariant(date).getTime();
|
|
184
185
|
}
|
|
185
186
|
return v;
|
|
186
187
|
|
|
187
188
|
case "number":
|
|
188
|
-
return date;
|
|
189
|
+
return parseDateInvariant(date).getTime();
|
|
189
190
|
}
|
|
190
191
|
}
|
|
191
192
|
|
package/src/ui/Format.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Culture } from "./Culture";
|
|
2
2
|
import { Format as Fmt, resolveMinMaxFractionDigits } from "../util/Format";
|
|
3
|
+
import { parseDateInvariant } from "../util";
|
|
3
4
|
import { GlobalCacheIdentifier } from "../util/GlobalCacheIdentifier";
|
|
4
5
|
|
|
5
6
|
export const Format = Fmt;
|
|
@@ -68,19 +69,19 @@ export function enableCultureSensitiveFormatting() {
|
|
|
68
69
|
Fmt.registerFactory(["date", "d"], (fmt, format = "yyyyMMdd") => {
|
|
69
70
|
let culture = Culture.getDateTimeCulture();
|
|
70
71
|
let formatter = culture.getFormatter(format);
|
|
71
|
-
return (value) => formatter.format(
|
|
72
|
+
return (value) => formatter.format(parseDateInvariant(value));
|
|
72
73
|
});
|
|
73
74
|
|
|
74
75
|
Fmt.registerFactory(["time", "t"], (fmt, format = "hhmmss") => {
|
|
75
76
|
let culture = Culture.getDateTimeCulture();
|
|
76
77
|
let formatter = culture.getFormatter(format);
|
|
77
|
-
return (value) => formatter.format(
|
|
78
|
+
return (value) => formatter.format(parseDateInvariant(value));
|
|
78
79
|
});
|
|
79
80
|
|
|
80
81
|
Fmt.registerFactory(["datetime", "dt"], (fmt, format = "yyyyMd hhmm") => {
|
|
81
82
|
let culture = Culture.getDateTimeCulture();
|
|
82
83
|
let formatter = culture.getFormatter(format);
|
|
83
|
-
return (value) => formatter.format(
|
|
84
|
+
return (value) => formatter.format(parseDateInvariant(value));
|
|
84
85
|
});
|
|
85
86
|
|
|
86
87
|
GlobalCacheIdentifier.change();
|
package/src/util/Format.js
CHANGED
|
@@ -1,121 +1,116 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { isArray } from "../util/isArray";
|
|
2
|
+
import { isNumber } from "../util/isNumber";
|
|
3
|
+
import { isUndefined } from "../util/isUndefined";
|
|
4
|
+
import { parseDateInvariant } from "./date";
|
|
5
|
+
import { debug } from "./Debug";
|
|
6
|
+
import { GlobalCacheIdentifier } from "./GlobalCacheIdentifier";
|
|
6
7
|
|
|
7
8
|
//Culture dependent formatters are defined in the ui package.
|
|
8
9
|
|
|
9
|
-
const defaultFormatter = v => v.toString();
|
|
10
|
+
const defaultFormatter = (v) => v.toString();
|
|
10
11
|
|
|
11
12
|
let formatFactory = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return defaultFormatter
|
|
13
|
+
string: function () {
|
|
14
|
+
return defaultFormatter;
|
|
15
15
|
},
|
|
16
16
|
|
|
17
|
-
wrap: function(part0, prefix, suffix) {
|
|
18
|
-
if (!prefix)
|
|
19
|
-
prefix = '';
|
|
17
|
+
wrap: function (part0, prefix, suffix) {
|
|
18
|
+
if (!prefix) prefix = "";
|
|
20
19
|
|
|
21
|
-
if (!suffix)
|
|
22
|
-
suffix = '';
|
|
20
|
+
if (!suffix) suffix = "";
|
|
23
21
|
|
|
24
|
-
return value => prefix + value.toString() + suffix;
|
|
22
|
+
return (value) => prefix + value.toString() + suffix;
|
|
25
23
|
},
|
|
26
24
|
|
|
27
|
-
fixed: function(part0, digits) {
|
|
28
|
-
return value => value.toFixed(digits)
|
|
25
|
+
fixed: function (part0, digits) {
|
|
26
|
+
return (value) => value.toFixed(digits);
|
|
29
27
|
},
|
|
30
28
|
|
|
31
|
-
prefix: function(part0, prefix) {
|
|
32
|
-
if (!prefix)
|
|
33
|
-
prefix = '';
|
|
29
|
+
prefix: function (part0, prefix) {
|
|
30
|
+
if (!prefix) prefix = "";
|
|
34
31
|
|
|
35
|
-
return value => prefix + value.toString();
|
|
32
|
+
return (value) => prefix + value.toString();
|
|
36
33
|
},
|
|
37
34
|
|
|
38
|
-
suffix: function(part0, suffix) {
|
|
39
|
-
if (!suffix)
|
|
40
|
-
suffix = '';
|
|
35
|
+
suffix: function (part0, suffix) {
|
|
36
|
+
if (!suffix) suffix = "";
|
|
41
37
|
|
|
42
|
-
return value => value.toString() + suffix;
|
|
38
|
+
return (value) => value.toString() + suffix;
|
|
43
39
|
},
|
|
44
40
|
|
|
45
|
-
uppercase: function() {
|
|
46
|
-
return value => value.toString().toUpperCase();
|
|
41
|
+
uppercase: function () {
|
|
42
|
+
return (value) => value.toString().toUpperCase();
|
|
47
43
|
},
|
|
48
44
|
|
|
49
|
-
lowercase: function() {
|
|
50
|
-
return value => value.toString().toLowerCase();
|
|
45
|
+
lowercase: function () {
|
|
46
|
+
return (value) => value.toString().toLowerCase();
|
|
51
47
|
},
|
|
52
48
|
|
|
53
|
-
urlencode: function() {
|
|
54
|
-
return value => encodeURIComponent(value);
|
|
49
|
+
urlencode: function () {
|
|
50
|
+
return (value) => encodeURIComponent(value);
|
|
55
51
|
},
|
|
56
|
-
|
|
52
|
+
|
|
57
53
|
number: function (part0, minFractionDigits, maxFractionDigits) {
|
|
58
|
-
let {minimumFractionDigits, maximumFractionDigits} = resolveMinMaxFractionDigits(
|
|
54
|
+
let { minimumFractionDigits, maximumFractionDigits } = resolveMinMaxFractionDigits(
|
|
55
|
+
minFractionDigits,
|
|
56
|
+
maxFractionDigits,
|
|
57
|
+
);
|
|
59
58
|
let trimmable = maximumFractionDigits - minimumFractionDigits;
|
|
60
59
|
if (trimmable > 0) {
|
|
61
|
-
if (minimumFractionDigits == 0)
|
|
62
|
-
|
|
63
|
-
return value => trimFractionZeros(value.toFixed(maximumFractionDigits), trimmable);
|
|
60
|
+
if (minimumFractionDigits == 0) ++trimmable;
|
|
61
|
+
return (value) => trimFractionZeros(value.toFixed(maximumFractionDigits), trimmable);
|
|
64
62
|
}
|
|
65
|
-
return value => value.toFixed(maximumFractionDigits);
|
|
63
|
+
return (value) => value.toFixed(maximumFractionDigits);
|
|
66
64
|
},
|
|
67
65
|
|
|
68
66
|
percentage: function (part0, minFractionDigits, maxFractionDigits) {
|
|
69
67
|
let numberFormatter = formatFactory.number(part0, minFractionDigits, maxFractionDigits);
|
|
70
|
-
return value => numberFormatter(value * 100) +
|
|
68
|
+
return (value) => numberFormatter(value * 100) + "%";
|
|
71
69
|
},
|
|
72
70
|
|
|
73
71
|
percentageSign: function (part0, minFractionDigits, maxFractionDigits) {
|
|
74
72
|
let numberFormatter = formatFactory.number(part0, minFractionDigits, maxFractionDigits);
|
|
75
|
-
return value => numberFormatter(value) +
|
|
73
|
+
return (value) => numberFormatter(value) + "%";
|
|
76
74
|
},
|
|
77
75
|
|
|
78
76
|
date: function () {
|
|
79
|
-
return value => {
|
|
80
|
-
let date =
|
|
77
|
+
return (value) => {
|
|
78
|
+
let date = parseDateInvariant(value);
|
|
81
79
|
return `${date.getMonth() + 1}/${date.getDate()}/${date.getFullYear()}`;
|
|
82
|
-
}
|
|
80
|
+
};
|
|
83
81
|
},
|
|
84
82
|
|
|
85
83
|
time: function () {
|
|
86
|
-
return value => {
|
|
87
|
-
let date =
|
|
88
|
-
let h = date.getHours() >= 10 ? date.getHours() :
|
|
89
|
-
let m = date.getMinutes() >= 10 ? date.getMinutes() :
|
|
84
|
+
return (value) => {
|
|
85
|
+
let date = parseDateInvariant(value);
|
|
86
|
+
let h = date.getHours() >= 10 ? date.getHours() : "0" + date.getHours();
|
|
87
|
+
let m = date.getMinutes() >= 10 ? date.getMinutes() : "0" + date.getMinutes();
|
|
90
88
|
return `${h}:${m}`;
|
|
91
|
-
}
|
|
89
|
+
};
|
|
92
90
|
},
|
|
93
91
|
|
|
94
92
|
datetime: function () {
|
|
95
93
|
let date = formatFactory.date();
|
|
96
94
|
let time = formatFactory.time();
|
|
97
|
-
return value => date(value) +
|
|
95
|
+
return (value) => date(value) + " " + time(value);
|
|
98
96
|
},
|
|
99
97
|
|
|
100
98
|
ellipsis: function (part0, length, where) {
|
|
101
99
|
length = Number(length);
|
|
102
|
-
if (!(length > 3))
|
|
103
|
-
length = 10;
|
|
100
|
+
if (!(length > 3)) length = 10;
|
|
104
101
|
switch (where) {
|
|
105
102
|
default:
|
|
106
103
|
case "end":
|
|
107
104
|
return (value) => {
|
|
108
105
|
let s = String(value);
|
|
109
|
-
if (s.length > length)
|
|
110
|
-
return s.substring(0, length - 3) + "...";
|
|
106
|
+
if (s.length > length) return s.substring(0, length - 3) + "...";
|
|
111
107
|
return s;
|
|
112
108
|
};
|
|
113
109
|
|
|
114
110
|
case "start":
|
|
115
111
|
return (value) => {
|
|
116
112
|
let s = String(value);
|
|
117
|
-
if (s.length > length)
|
|
118
|
-
return "..." + s.substring(s.length - length + 3);
|
|
113
|
+
if (s.length > length) return "..." + s.substring(s.length - length + 3);
|
|
119
114
|
return s;
|
|
120
115
|
};
|
|
121
116
|
|
|
@@ -129,7 +124,7 @@ let formatFactory = {
|
|
|
129
124
|
return s;
|
|
130
125
|
};
|
|
131
126
|
}
|
|
132
|
-
}
|
|
127
|
+
},
|
|
133
128
|
};
|
|
134
129
|
|
|
135
130
|
formatFactory.s = formatFactory.str = formatFactory.string;
|
|
@@ -142,26 +137,25 @@ formatFactory.t = formatFactory.time;
|
|
|
142
137
|
formatFactory.dt = formatFactory.datetime;
|
|
143
138
|
|
|
144
139
|
function buildFormatter(format) {
|
|
145
|
-
let formatter = defaultFormatter,
|
|
140
|
+
let formatter = defaultFormatter,
|
|
141
|
+
nullText = "";
|
|
146
142
|
if (format) {
|
|
147
|
-
let pipeParts = format.split(
|
|
148
|
-
nullText = pipeParts[1] ||
|
|
149
|
-
let colonSepParts = pipeParts[0].split(
|
|
143
|
+
let pipeParts = format.split("|");
|
|
144
|
+
nullText = pipeParts[1] || "";
|
|
145
|
+
let colonSepParts = pipeParts[0].split(":");
|
|
150
146
|
for (let i = 0; i < colonSepParts.length; i++) {
|
|
151
|
-
let parts = colonSepParts[i].split(
|
|
147
|
+
let parts = colonSepParts[i].split(";");
|
|
152
148
|
let factory = formatFactory[parts[0]];
|
|
153
|
-
if (!factory)
|
|
154
|
-
|
|
155
|
-
else if (i == 0)
|
|
156
|
-
formatter = factory(...parts);
|
|
149
|
+
if (!factory) debug("Unknown string format: " + format);
|
|
150
|
+
else if (i == 0) formatter = factory(...parts);
|
|
157
151
|
else {
|
|
158
152
|
let outerFmt = factory(...parts);
|
|
159
153
|
let innerFmt = formatter;
|
|
160
|
-
formatter = v => outerFmt(innerFmt(v));
|
|
154
|
+
formatter = (v) => outerFmt(innerFmt(v));
|
|
161
155
|
}
|
|
162
156
|
}
|
|
163
157
|
}
|
|
164
|
-
return v => (v == null || v ===
|
|
158
|
+
return (v) => (v == null || v === "" ? nullText : formatter(v));
|
|
165
159
|
}
|
|
166
160
|
|
|
167
161
|
let format = {
|
|
@@ -172,25 +166,22 @@ function getFormatCache() {
|
|
|
172
166
|
if (format.cacheIdentifier != GlobalCacheIdentifier.get()) {
|
|
173
167
|
format = {
|
|
174
168
|
cache: {},
|
|
175
|
-
cacheIdentifier: GlobalCacheIdentifier.get()
|
|
169
|
+
cacheIdentifier: GlobalCacheIdentifier.get(),
|
|
176
170
|
};
|
|
177
171
|
}
|
|
178
172
|
return format.cache;
|
|
179
173
|
}
|
|
180
174
|
|
|
181
175
|
function getFormatter(format) {
|
|
182
|
-
if (!format)
|
|
183
|
-
format = '';
|
|
176
|
+
if (!format) format = "";
|
|
184
177
|
let formatCache = getFormatCache();
|
|
185
178
|
let formatter = formatCache[format];
|
|
186
|
-
if (!formatter)
|
|
187
|
-
formatter = formatCache[format] = buildFormatter(format);
|
|
179
|
+
if (!formatter) formatter = formatCache[format] = buildFormatter(format);
|
|
188
180
|
|
|
189
181
|
return formatter;
|
|
190
182
|
}
|
|
191
183
|
|
|
192
184
|
export class Format {
|
|
193
|
-
|
|
194
185
|
static value(v, format) {
|
|
195
186
|
let formatter = getFormatter(format);
|
|
196
187
|
return formatter(v);
|
|
@@ -205,10 +196,8 @@ export class Format {
|
|
|
205
196
|
}
|
|
206
197
|
|
|
207
198
|
static registerFactory(format, factory) {
|
|
208
|
-
if (isArray(format))
|
|
209
|
-
|
|
210
|
-
else
|
|
211
|
-
formatFactory[format] = factory;
|
|
199
|
+
if (isArray(format)) format.forEach((f) => this.registerFactory(f, factory));
|
|
200
|
+
else formatFactory[format] = factory;
|
|
212
201
|
}
|
|
213
202
|
}
|
|
214
203
|
|
|
@@ -217,26 +206,24 @@ export function resolveMinMaxFractionDigits(minimumFractionDigits, maximumFracti
|
|
|
217
206
|
maximumFractionDigits = maximumFractionDigits != null ? Number(maximumFractionDigits) : maximumFractionDigits;
|
|
218
207
|
|
|
219
208
|
if (isNumber(minimumFractionDigits)) {
|
|
220
|
-
if (isUndefined(maximumFractionDigits))
|
|
221
|
-
maximumFractionDigits = minimumFractionDigits;
|
|
209
|
+
if (isUndefined(maximumFractionDigits)) maximumFractionDigits = minimumFractionDigits;
|
|
222
210
|
else if (isNumber(maximumFractionDigits) && maximumFractionDigits < minimumFractionDigits)
|
|
223
211
|
maximumFractionDigits = minimumFractionDigits;
|
|
224
|
-
}
|
|
225
|
-
else if (minimumFractionDigits == null && maximumFractionDigits == null) {
|
|
212
|
+
} else if (minimumFractionDigits == null && maximumFractionDigits == null) {
|
|
226
213
|
minimumFractionDigits = 0;
|
|
227
214
|
maximumFractionDigits = 18;
|
|
228
215
|
}
|
|
229
216
|
|
|
230
217
|
return {
|
|
231
218
|
minimumFractionDigits,
|
|
232
|
-
maximumFractionDigits
|
|
233
|
-
}
|
|
219
|
+
maximumFractionDigits,
|
|
220
|
+
};
|
|
234
221
|
}
|
|
235
222
|
|
|
236
223
|
export function trimFractionZeros(str, max) {
|
|
237
|
-
let cnt = 0,
|
|
238
|
-
|
|
239
|
-
|
|
224
|
+
let cnt = 0,
|
|
225
|
+
l = str.length;
|
|
226
|
+
while (cnt < max && (str[l - 1 - cnt] === "0" || str[l - 1 - cnt] === ".")) cnt++;
|
|
240
227
|
|
|
241
228
|
return cnt > 0 ? str.substring(0, l - cnt) : str;
|
|
242
|
-
}
|
|
229
|
+
}
|
package/src/util/date/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
1
|
+
export * from "./dateDiff";
|
|
2
|
+
export * from "./zeroTime";
|
|
3
|
+
export * from "./monthStart";
|
|
4
|
+
export * from "./lowerBoundCheck";
|
|
5
|
+
export * from "./upperBoundCheck";
|
|
6
|
+
export * from "./maxDate";
|
|
7
|
+
export * from "./minDate";
|
|
8
|
+
export * from "./sameDate";
|
|
9
|
+
export * from "./encodeDateWithTimezoneOffset";
|
|
10
|
+
export * from "./parseDateInvariant";
|
package/src/util/date/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
1
|
+
export * from "./dateDiff";
|
|
2
|
+
export * from "./zeroTime";
|
|
3
|
+
export * from "./monthStart";
|
|
4
|
+
export * from "./lowerBoundCheck";
|
|
5
|
+
export * from "./upperBoundCheck";
|
|
6
|
+
export * from "./maxDate";
|
|
7
|
+
export * from "./minDate";
|
|
8
|
+
export * from "./sameDate";
|
|
9
|
+
export * from "./encodeDateWithTimezoneOffset";
|
|
10
|
+
export * from "./parseDateInvariant";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// This module addresses a common issue when handling date strings in the format "yyyy-MM-dd" usually returned by backends.
|
|
2
|
+
// In time zones earlier than UTC, creating a Date object from such a string can result in the date being shifted one day earlier.
|
|
3
|
+
// This happens because "yyyy-MM-dd" is interpreted as a UTC date at 00:00, and when the browser displays it in local time, it adjusts backward.
|
|
4
|
+
// To resolve this, the default implementation (`defaultInvariantParseDate`) appends " 00:00" to the date string,
|
|
5
|
+
// explicitly indicating local time. Custom parsing logic can also be registered dynamically using `registerInvariantParseDateImpl`
|
|
6
|
+
// to accommodate other formats or requirements.
|
|
7
|
+
function defaultParseDateInvariant(input) {
|
|
8
|
+
if (typeof input == "string" && input.length == 10 && input[4] == "-" && input[7] == "-")
|
|
9
|
+
return new Date(`${input} 00:00`);
|
|
10
|
+
return new Date(input);
|
|
11
|
+
}
|
|
12
|
+
let impl = defaultParseDateInvariant;
|
|
13
|
+
|
|
14
|
+
export function parseDateInvariant(input) {
|
|
15
|
+
return impl(input);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function overrideParseDateInvariant(newImpl) {
|
|
19
|
+
impl = newImpl;
|
|
20
|
+
}
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import { Widget, VDOM } from "../../ui/Widget";
|
|
2
|
-
import { Field, getFieldTooltip } from "./Field";
|
|
3
|
-
import { Culture } from "../../ui/Culture";
|
|
4
|
-
import { FocusManager, oneFocusOut, offFocusOut } from "../../ui/FocusManager";
|
|
5
1
|
import { StringTemplate } from "../../data/StringTemplate";
|
|
6
|
-
import {
|
|
2
|
+
import { Culture } from "../../ui/Culture";
|
|
3
|
+
import { FocusManager, offFocusOut, oneFocusOut } from "../../ui/FocusManager";
|
|
4
|
+
import "../../ui/Format";
|
|
5
|
+
import { Localization } from "../../ui/Localization";
|
|
6
|
+
import { VDOM, Widget } from "../../ui/Widget";
|
|
7
|
+
import { parseDateInvariant } from "../../util";
|
|
8
|
+
import { KeyCode } from "../../util/KeyCode";
|
|
7
9
|
import { dateDiff } from "../../util/date/dateDiff";
|
|
8
10
|
import { lowerBoundCheck } from "../../util/date/lowerBoundCheck";
|
|
9
|
-
import {
|
|
11
|
+
import { monthStart } from "../../util/date/monthStart";
|
|
10
12
|
import { sameDate } from "../../util/date/sameDate";
|
|
13
|
+
import { upperBoundCheck } from "../../util/date/upperBoundCheck";
|
|
14
|
+
import { zeroTime } from "../../util/date/zeroTime";
|
|
15
|
+
import DropdownIcon from "../icons/drop-down";
|
|
16
|
+
import ForwardIcon from "../icons/forward";
|
|
11
17
|
import {
|
|
12
|
-
tooltipParentWillReceiveProps,
|
|
13
|
-
tooltipParentWillUnmount,
|
|
14
|
-
tooltipMouseMove,
|
|
15
18
|
tooltipMouseLeave,
|
|
19
|
+
tooltipMouseMove,
|
|
16
20
|
tooltipParentDidMount,
|
|
21
|
+
tooltipParentWillReceiveProps,
|
|
22
|
+
tooltipParentWillUnmount,
|
|
17
23
|
} from "../overlay/tooltip-ops";
|
|
18
|
-
import {
|
|
19
|
-
import { Localization } from "../../ui/Localization";
|
|
20
|
-
import ForwardIcon from "../icons/forward";
|
|
21
|
-
import DropdownIcon from "../icons/drop-down";
|
|
22
|
-
import "../../ui/Format";
|
|
23
|
-
import { monthStart } from "../../util/date/monthStart";
|
|
24
|
+
import { Field, getFieldTooltip } from "./Field";
|
|
24
25
|
|
|
25
26
|
export class Calendar extends Field {
|
|
26
27
|
declareData() {
|
|
@@ -37,7 +38,7 @@ export class Calendar extends Field {
|
|
|
37
38
|
focusable: undefined,
|
|
38
39
|
dayData: undefined,
|
|
39
40
|
},
|
|
40
|
-
...arguments
|
|
41
|
+
...arguments,
|
|
41
42
|
);
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -53,17 +54,17 @@ export class Calendar extends Field {
|
|
|
53
54
|
};
|
|
54
55
|
|
|
55
56
|
if (data.value) {
|
|
56
|
-
let d =
|
|
57
|
+
let d = parseDateInvariant(data.value);
|
|
57
58
|
if (!isNaN(d.getTime())) {
|
|
58
59
|
data.date = zeroTime(d);
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
if (data.refDate) data.refDate = zeroTime(
|
|
63
|
+
if (data.refDate) data.refDate = zeroTime(parseDateInvariant(data.refDate));
|
|
63
64
|
|
|
64
|
-
if (data.maxValue) data.maxValue = zeroTime(
|
|
65
|
+
if (data.maxValue) data.maxValue = zeroTime(parseDateInvariant(data.maxValue));
|
|
65
66
|
|
|
66
|
-
if (data.minValue) data.minValue = zeroTime(
|
|
67
|
+
if (data.minValue) data.minValue = zeroTime(parseDateInvariant(data.minValue));
|
|
67
68
|
|
|
68
69
|
super.prepareData(...arguments);
|
|
69
70
|
}
|
|
@@ -92,7 +93,7 @@ export class Calendar extends Field {
|
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
if (data.dayData) {
|
|
95
|
-
let date =
|
|
96
|
+
let date = parseDateInvariant(data.value);
|
|
96
97
|
let info = data.dayData[date.toDateString()];
|
|
97
98
|
if (info && info.disabled) data.error = this.disabledDaysOfWeekErrorText;
|
|
98
99
|
}
|
|
@@ -117,7 +118,7 @@ export class Calendar extends Field {
|
|
|
117
118
|
if (this.onBeforeSelect && instance.invoke("onBeforeSelect", e, instance, date) === false) return;
|
|
118
119
|
|
|
119
120
|
if (widget.partial) {
|
|
120
|
-
let mixed =
|
|
121
|
+
let mixed = parseDateInvariant(data.value);
|
|
121
122
|
if (data.value && !isNaN(mixed)) {
|
|
122
123
|
mixed.setFullYear(date.getFullYear());
|
|
123
124
|
mixed.setMonth(date.getMonth());
|
|
@@ -176,7 +177,7 @@ export class CalendarCmp extends VDOM.Component {
|
|
|
176
177
|
focus: false,
|
|
177
178
|
cursor: zeroTime(data.date || refDate),
|
|
178
179
|
},
|
|
179
|
-
this.getPage(refDate)
|
|
180
|
+
this.getPage(refDate),
|
|
180
181
|
);
|
|
181
182
|
|
|
182
183
|
this.handleMouseMove = this.handleMouseMove.bind(this);
|
|
@@ -414,7 +415,7 @@ export class CalendarCmp extends VDOM.Component {
|
|
|
414
415
|
today: widget.highlightToday && sameDate(date, today),
|
|
415
416
|
}),
|
|
416
417
|
dayInfo.className,
|
|
417
|
-
CSS.mod(dayInfo.mod)
|
|
418
|
+
CSS.mod(dayInfo.mod),
|
|
418
419
|
);
|
|
419
420
|
let dateInst = new Date(date);
|
|
420
421
|
days.push(
|
|
@@ -429,7 +430,7 @@ export class CalendarCmp extends VDOM.Component {
|
|
|
429
430
|
onMouseDown={unselectable ? null : this.handleMouseDown}
|
|
430
431
|
>
|
|
431
432
|
{date.getDate()}
|
|
432
|
-
</td
|
|
433
|
+
</td>,
|
|
433
434
|
);
|
|
434
435
|
date.setDate(date.getDate() + 1);
|
|
435
436
|
}
|
|
@@ -438,7 +439,7 @@ export class CalendarCmp extends VDOM.Component {
|
|
|
438
439
|
<td />
|
|
439
440
|
{days}
|
|
440
441
|
<td />
|
|
441
|
-
</tr
|
|
442
|
+
</tr>,
|
|
442
443
|
);
|
|
443
444
|
}
|
|
444
445
|
|
|
@@ -27,6 +27,7 @@ import { Format } from "../../util/Format";
|
|
|
27
27
|
import { TimeList } from "./TimeList";
|
|
28
28
|
import { autoFocus } from "../autoFocus";
|
|
29
29
|
import { getActiveElement } from "../../util";
|
|
30
|
+
import { parseDateInvariant } from "../../util";
|
|
30
31
|
|
|
31
32
|
export class DateTimeField extends Field {
|
|
32
33
|
declareData() {
|
|
@@ -77,7 +78,9 @@ export class DateTimeField extends Field {
|
|
|
77
78
|
let { data } = instance;
|
|
78
79
|
|
|
79
80
|
if (data.value) {
|
|
80
|
-
let date =
|
|
81
|
+
let date = parseDateInvariant(data.value);
|
|
82
|
+
// let date = new Date(data.value);
|
|
83
|
+
|
|
81
84
|
if (isNaN(date.getTime())) data.formatted = String(data.value);
|
|
82
85
|
else {
|
|
83
86
|
// handle utc edge cases
|
|
@@ -87,11 +90,11 @@ export class DateTimeField extends Field {
|
|
|
87
90
|
data.date = date;
|
|
88
91
|
} else data.formatted = "";
|
|
89
92
|
|
|
90
|
-
if (data.refDate) data.refDate = zeroTime(
|
|
93
|
+
if (data.refDate) data.refDate = zeroTime(parseDateInvariant(data.refDate));
|
|
91
94
|
|
|
92
|
-
if (data.maxValue) data.maxValue =
|
|
95
|
+
if (data.maxValue) data.maxValue = parseDateInvariant(data.maxValue);
|
|
93
96
|
|
|
94
|
-
if (data.minValue) data.minValue =
|
|
97
|
+
if (data.minValue) data.minValue = parseDateInvariant(data.minValue);
|
|
95
98
|
|
|
96
99
|
if (this.segment == "date") {
|
|
97
100
|
if (data.minValue) data.minValue = zeroTime(data.minValue);
|
|
@@ -540,7 +543,7 @@ class DateTimeInput extends VDOM.Component {
|
|
|
540
543
|
});
|
|
541
544
|
|
|
542
545
|
if (!isNaN(date)) {
|
|
543
|
-
let mixed =
|
|
546
|
+
let mixed = parseDateInvariant(baseValue);
|
|
544
547
|
if (date && baseValue && !isNaN(mixed) && widget.partial) {
|
|
545
548
|
switch (widget.segment) {
|
|
546
549
|
case "date":
|