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
|
@@ -5,6 +5,7 @@ import { WheelComponent } from "./Wheel";
|
|
|
5
5
|
import { oneFocusOut, offFocusOut } from "../../ui/FocusManager";
|
|
6
6
|
|
|
7
7
|
import { enableCultureSensitiveFormatting } from "../../ui/Format";
|
|
8
|
+
import { parseDateInvariant } from "../../util";
|
|
8
9
|
enableCultureSensitiveFormatting();
|
|
9
10
|
|
|
10
11
|
export class DateTimePicker extends Widget {
|
|
@@ -37,7 +38,7 @@ DateTimePicker.prototype.showSeconds = false;
|
|
|
37
38
|
class DateTimePickerComponent extends VDOM.Component {
|
|
38
39
|
constructor(props) {
|
|
39
40
|
super(props);
|
|
40
|
-
let date = props.data.value ?
|
|
41
|
+
let date = props.data.value ? parseDateInvariant(props.data.value) : new Date();
|
|
41
42
|
if (isNaN(date.getTime())) date = new Date();
|
|
42
43
|
this.state = {
|
|
43
44
|
date: date,
|
|
@@ -67,7 +68,7 @@ class DateTimePickerComponent extends VDOM.Component {
|
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
UNSAFE_componentWillReceiveProps(props) {
|
|
70
|
-
let date = props.data.value ?
|
|
71
|
+
let date = props.data.value ? parseDateInvariant(props.data.value) : new Date();
|
|
71
72
|
if (isNaN(date.getTime())) date = new Date();
|
|
72
73
|
this.setState({ date });
|
|
73
74
|
}
|
|
@@ -160,7 +161,7 @@ class DateTimePickerComponent extends VDOM.Component {
|
|
|
160
161
|
(state) => ({
|
|
161
162
|
date: this.setDateComponent(this.state.date, "year", newIndex + 1970),
|
|
162
163
|
}),
|
|
163
|
-
this.handleChange
|
|
164
|
+
this.handleChange,
|
|
164
165
|
);
|
|
165
166
|
}}
|
|
166
167
|
onPipeKeyDown={(kd) => {
|
|
@@ -186,7 +187,7 @@ class DateTimePickerComponent extends VDOM.Component {
|
|
|
186
187
|
(state) => ({
|
|
187
188
|
date: this.setDateComponent(this.state.date, "month", newIndex),
|
|
188
189
|
}),
|
|
189
|
-
this.handleChange
|
|
190
|
+
this.handleChange,
|
|
190
191
|
);
|
|
191
192
|
}}
|
|
192
193
|
onPipeKeyDown={(kd) => {
|
|
@@ -214,7 +215,7 @@ class DateTimePickerComponent extends VDOM.Component {
|
|
|
214
215
|
(state) => ({
|
|
215
216
|
date: this.setDateComponent(this.state.date, "date", newIndex + 1),
|
|
216
217
|
}),
|
|
217
|
-
this.handleChange
|
|
218
|
+
this.handleChange,
|
|
218
219
|
);
|
|
219
220
|
}}
|
|
220
221
|
onPipeKeyDown={(kd) => {
|
|
@@ -240,7 +241,7 @@ class DateTimePickerComponent extends VDOM.Component {
|
|
|
240
241
|
(state) => ({
|
|
241
242
|
date: this.setDateComponent(this.state.date, "hours", newIndex),
|
|
242
243
|
}),
|
|
243
|
-
this.handleChange
|
|
244
|
+
this.handleChange,
|
|
244
245
|
);
|
|
245
246
|
}}
|
|
246
247
|
onPipeKeyDown={(kd) => {
|
|
@@ -266,7 +267,7 @@ class DateTimePickerComponent extends VDOM.Component {
|
|
|
266
267
|
(state) => ({
|
|
267
268
|
date: this.setDateComponent(this.state.date, "minutes", newIndex),
|
|
268
269
|
}),
|
|
269
|
-
this.handleChange
|
|
270
|
+
this.handleChange,
|
|
270
271
|
);
|
|
271
272
|
}}
|
|
272
273
|
onPipeKeyDown={(kd) => {
|
|
@@ -292,7 +293,7 @@ class DateTimePickerComponent extends VDOM.Component {
|
|
|
292
293
|
(state) => ({
|
|
293
294
|
date: this.setDateComponent(this.state.date, "seconds", newIndex),
|
|
294
295
|
}),
|
|
295
|
-
this.handleChange
|
|
296
|
+
this.handleChange,
|
|
296
297
|
);
|
|
297
298
|
}}
|
|
298
299
|
onPipeKeyDown={(kd) => {
|
|
@@ -13,7 +13,6 @@ import { stopPropagation } from "../../util/eventCallbacks";
|
|
|
13
13
|
import { isDefined } from "../../util/isDefined";
|
|
14
14
|
import { isTouchDevice } from "../../util/isTouchDevice";
|
|
15
15
|
import { isTouchEvent } from "../../util/isTouchEvent";
|
|
16
|
-
import { Icon } from "../Icon";
|
|
17
16
|
import { autoFocus } from "../autoFocus";
|
|
18
17
|
import ClearIcon from "../icons/clear";
|
|
19
18
|
import DropdownIcon from "../icons/drop-down";
|
|
@@ -28,6 +27,7 @@ import {
|
|
|
28
27
|
import { Field, getFieldTooltip } from "./Field";
|
|
29
28
|
import { MonthPicker } from "./MonthPicker";
|
|
30
29
|
import { getActiveElement } from "../../util/getActiveElement";
|
|
30
|
+
import { parseDateInvariant } from "../../util";
|
|
31
31
|
|
|
32
32
|
export class MonthField extends Field {
|
|
33
33
|
declareData() {
|
|
@@ -93,11 +93,11 @@ export class MonthField extends Field {
|
|
|
93
93
|
};
|
|
94
94
|
|
|
95
95
|
if (!this.range && data.value) {
|
|
96
|
-
data.date =
|
|
96
|
+
data.date = parseDateInvariant(data.value);
|
|
97
97
|
data.formatted = this.culture.format(data.date, formatOptions);
|
|
98
98
|
} else if (this.range && data.from && data.to) {
|
|
99
|
-
data.from =
|
|
100
|
-
data.to =
|
|
99
|
+
data.from = parseDateInvariant(data.from);
|
|
100
|
+
data.to = parseDateInvariant(data.to);
|
|
101
101
|
data.to.setDate(data.to.getDate() - 1);
|
|
102
102
|
let fromStr = this.culture.format(data.from, formatOptions);
|
|
103
103
|
let toStr = this.culture.format(data.to, formatOptions);
|
|
@@ -105,11 +105,11 @@ export class MonthField extends Field {
|
|
|
105
105
|
else data.formatted = fromStr;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
if (data.refDate) data.refDate = monthStart(
|
|
108
|
+
if (data.refDate) data.refDate = monthStart(parseDateInvariant(data.refDate));
|
|
109
109
|
|
|
110
|
-
if (data.maxValue) data.maxValue = monthStart(
|
|
110
|
+
if (data.maxValue) data.maxValue = monthStart(parseDateInvariant(data.maxValue));
|
|
111
111
|
|
|
112
|
-
if (data.minValue) data.minValue = monthStart(
|
|
112
|
+
if (data.minValue) data.minValue = monthStart(parseDateInvariant(data.minValue));
|
|
113
113
|
|
|
114
114
|
instance.lastDropdown = context.lastDropdown;
|
|
115
115
|
}
|
|
@@ -26,6 +26,7 @@ import { isTouchEvent } from "../../util/isTouchEvent";
|
|
|
26
26
|
import { getCursorPos } from "../overlay/captureMouse";
|
|
27
27
|
|
|
28
28
|
import { enableCultureSensitiveFormatting } from "../../ui/Format";
|
|
29
|
+
import { parseDateInvariant } from "../../util";
|
|
29
30
|
enableCultureSensitiveFormatting();
|
|
30
31
|
|
|
31
32
|
export class MonthPicker extends Field {
|
|
@@ -59,7 +60,7 @@ export class MonthPicker extends Field {
|
|
|
59
60
|
maxValue: undefined,
|
|
60
61
|
maxExclusive: undefined,
|
|
61
62
|
},
|
|
62
|
-
...arguments
|
|
63
|
+
...arguments,
|
|
63
64
|
);
|
|
64
65
|
}
|
|
65
66
|
|
|
@@ -72,19 +73,19 @@ export class MonthPicker extends Field {
|
|
|
72
73
|
disabled: data.disabled,
|
|
73
74
|
};
|
|
74
75
|
|
|
75
|
-
if (!this.range && data.value) data.date = monthStart(
|
|
76
|
+
if (!this.range && data.value) data.date = monthStart(parseDateInvariant(data.value));
|
|
76
77
|
|
|
77
78
|
if (this.range) {
|
|
78
|
-
if (data.from) data.from = monthStart(
|
|
79
|
+
if (data.from) data.from = monthStart(parseDateInvariant(data.from));
|
|
79
80
|
|
|
80
|
-
if (data.to) data.to = monthStart(
|
|
81
|
+
if (data.to) data.to = monthStart(parseDateInvariant(data.to));
|
|
81
82
|
}
|
|
82
83
|
|
|
83
|
-
if (data.refDate) data.refDate = monthStart(
|
|
84
|
+
if (data.refDate) data.refDate = monthStart(parseDateInvariant(data.refDate));
|
|
84
85
|
|
|
85
|
-
if (data.maxValue) data.maxValue = monthStart(
|
|
86
|
+
if (data.maxValue) data.maxValue = monthStart(parseDateInvariant(data.maxValue));
|
|
86
87
|
|
|
87
|
-
if (data.minValue) data.minValue = monthStart(
|
|
88
|
+
if (data.minValue) data.minValue = monthStart(parseDateInvariant(data.minValue));
|
|
88
89
|
|
|
89
90
|
super.prepareData(...arguments);
|
|
90
91
|
}
|
|
@@ -272,7 +273,7 @@ export class MonthPickerComponent extends VDOM.Component {
|
|
|
272
273
|
cursorQuarter: (cursorQuarter + 3) % 4,
|
|
273
274
|
cursorYear: cursorQuarter == 0 ? cursorYear - 1 : cursorYear,
|
|
274
275
|
},
|
|
275
|
-
{ ensureVisible: true }
|
|
276
|
+
{ ensureVisible: true },
|
|
276
277
|
);
|
|
277
278
|
else if (column == "M")
|
|
278
279
|
if (cursorMonth > 3) this.moveCursor(e, { cursorMonth: cursorMonth - 3 }, { ensureVisible: true });
|
|
@@ -280,7 +281,7 @@ export class MonthPickerComponent extends VDOM.Component {
|
|
|
280
281
|
this.moveCursor(
|
|
281
282
|
e,
|
|
282
283
|
{ cursorMonth: cursorMonth + 9, cursorYear: cursorYear - 1 },
|
|
283
|
-
{ ensureVisible: true }
|
|
284
|
+
{ ensureVisible: true },
|
|
284
285
|
);
|
|
285
286
|
break;
|
|
286
287
|
|
|
@@ -293,7 +294,7 @@ export class MonthPickerComponent extends VDOM.Component {
|
|
|
293
294
|
cursorQuarter: (cursorQuarter + 1) % 4,
|
|
294
295
|
cursorYear: cursorQuarter == 3 ? cursorYear + 1 : cursorYear,
|
|
295
296
|
},
|
|
296
|
-
{ ensureVisible: true }
|
|
297
|
+
{ ensureVisible: true },
|
|
297
298
|
);
|
|
298
299
|
else if (column == "M")
|
|
299
300
|
if (cursorMonth < 10) this.moveCursor(e, { cursorMonth: cursorMonth + 3 }, { ensureVisible: true });
|
|
@@ -301,7 +302,7 @@ export class MonthPickerComponent extends VDOM.Component {
|
|
|
301
302
|
this.moveCursor(
|
|
302
303
|
e,
|
|
303
304
|
{ cursorMonth: cursorMonth - 9, cursorYear: cursorYear + 1 },
|
|
304
|
-
{ ensureVisible: true }
|
|
305
|
+
{ ensureVisible: true },
|
|
305
306
|
);
|
|
306
307
|
break;
|
|
307
308
|
|
|
@@ -470,7 +471,7 @@ export class MonthPickerComponent extends VDOM.Component {
|
|
|
470
471
|
onMouseUp={this.handleMouseUp}
|
|
471
472
|
>
|
|
472
473
|
{y}
|
|
473
|
-
</th
|
|
474
|
+
</th>,
|
|
474
475
|
);
|
|
475
476
|
|
|
476
477
|
for (let i = 0; i < 3; i++) {
|
|
@@ -500,7 +501,7 @@ export class MonthPickerComponent extends VDOM.Component {
|
|
|
500
501
|
onTouchEnd={this.handleMouseUp}
|
|
501
502
|
>
|
|
502
503
|
{monthNames[m - 1].substr(0, 3)}
|
|
503
|
-
</td
|
|
504
|
+
</td>,
|
|
504
505
|
);
|
|
505
506
|
}
|
|
506
507
|
row.push(
|
|
@@ -519,7 +520,7 @@ export class MonthPickerComponent extends VDOM.Component {
|
|
|
519
520
|
onMouseUp={this.handleMouseUp}
|
|
520
521
|
>
|
|
521
522
|
{`Q${q + 1}`}
|
|
522
|
-
</th
|
|
523
|
+
</th>,
|
|
523
524
|
);
|
|
524
525
|
rows.push(row);
|
|
525
526
|
}
|
|
@@ -568,7 +569,7 @@ export class MonthPickerComponent extends VDOM.Component {
|
|
|
568
569
|
let visibleItems = ceil5(Math.ceil(this.dom.el.offsetHeight / this.state.yearHeight));
|
|
569
570
|
let start = Math.max(
|
|
570
571
|
startYear,
|
|
571
|
-
startYear + floor5(Math.floor(this.dom.el.scrollTop / this.state.yearHeight)) - visibleItems
|
|
572
|
+
startYear + floor5(Math.floor(this.dom.el.scrollTop / this.state.yearHeight)) - visibleItems,
|
|
572
573
|
);
|
|
573
574
|
if (start != this.state.start && start + bufferSize <= endYear) {
|
|
574
575
|
this.setState({
|
|
@@ -606,7 +607,7 @@ export class MonthPickerComponent extends VDOM.Component {
|
|
|
606
607
|
this.dom.el.scrollTop =
|
|
607
608
|
(this.state.cursorYear - startYear + yearCount / 2) * this.state.yearHeight -
|
|
608
609
|
this.dom.el.offsetHeight / 2;
|
|
609
|
-
}
|
|
610
|
+
},
|
|
610
611
|
);
|
|
611
612
|
}
|
|
612
613
|
|