cx 24.6.4 → 24.6.6
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 +27 -29
- package/dist/data.js +26 -29
- package/dist/manifest.js +808 -802
- package/dist/svg.js +59 -56
- package/dist/ui.js +51 -52
- package/dist/util.js +56 -10
- package/dist/widgets.js +74 -74
- package/package.json +1 -1
- package/src/charts/Legend.js +151 -151
- package/src/charts/Marker.d.ts +96 -96
- package/src/charts/Marker.js +299 -299
- package/src/charts/axis/Axis.d.ts +96 -96
- package/src/charts/axis/NumericAxis.js +347 -347
- package/src/charts/axis/Stack.js +55 -55
- package/src/charts/axis/TimeAxis.js +7 -6
- package/src/data/Binding.spec.js +69 -69
- package/src/data/StringTemplate.spec.js +105 -105
- package/src/data/getAccessor.spec.js +11 -11
- package/src/ui/Controller.d.ts +182 -182
- package/src/ui/FocusManager.js +171 -171
- package/src/ui/Format.js +3 -3
- package/src/ui/Instance.d.ts +72 -72
- package/src/ui/index.d.ts +42 -42
- package/src/util/Format.js +6 -5
- 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/drag-drop/DropZone.js +214 -214
- package/src/widgets/form/Calendar.js +7 -6
- package/src/widgets/form/ColorField.js +3 -3
- package/src/widgets/form/DateTimeField.js +9 -6
- package/src/widgets/form/DateTimePicker.js +9 -8
- package/src/widgets/form/MonthField.js +9 -9
- package/src/widgets/form/MonthPicker.js +17 -16
- package/src/widgets/form/NumberField.js +1 -1
- package/src/widgets/form/TextField.js +290 -289
- package/src/widgets/form/UploadButton.d.ts +34 -34
- package/src/widgets/grid/variables.scss +88 -88
- package/src/widgets/overlay/Dropdown.js +612 -612
|
@@ -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,214 +1,214 @@
|
|
|
1
|
-
import { Widget, VDOM } from "../../ui/Widget";
|
|
2
|
-
import { Container } from "../../ui/Container";
|
|
3
|
-
import { parseStyle } from "../../util/parseStyle";
|
|
4
|
-
import { registerDropZone, DragDropContext } from "./ops";
|
|
5
|
-
import { findScrollableParent } from "../../util/findScrollableParent";
|
|
6
|
-
import { isNumber } from "../../util/isNumber";
|
|
7
|
-
import { getTopLevelBoundingClientRect } from "../../util/getTopLevelBoundingClientRect";
|
|
8
|
-
|
|
9
|
-
export class DropZone extends Container {
|
|
10
|
-
init() {
|
|
11
|
-
this.overStyle = parseStyle(this.overStyle);
|
|
12
|
-
this.nearStyle = parseStyle(this.nearStyle);
|
|
13
|
-
this.farStyle = parseStyle(this.farStyle);
|
|
14
|
-
|
|
15
|
-
if (isNumber(this.inflate)) {
|
|
16
|
-
this.hinflate = this.inflate;
|
|
17
|
-
this.vinflate = this.inflate;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
super.init();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
declareData() {
|
|
24
|
-
return super.declareData(...arguments, {
|
|
25
|
-
overClass: { structured: true },
|
|
26
|
-
nearClass: { structured: true },
|
|
27
|
-
farClass: { structured: true },
|
|
28
|
-
overStyle: { structured: true },
|
|
29
|
-
nearStyle: { structured: true },
|
|
30
|
-
farStyle: { structured: true },
|
|
31
|
-
data: { structured: true },
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
render(context, instance, key) {
|
|
36
|
-
return (
|
|
37
|
-
<DropZoneComponent key={key} instance={instance}>
|
|
38
|
-
{this.renderChildren(context, instance)}
|
|
39
|
-
</DropZoneComponent>
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
DropZone.prototype.styled = true;
|
|
45
|
-
DropZone.prototype.nearDistance = 0;
|
|
46
|
-
DropZone.prototype.hinflate = 0;
|
|
47
|
-
DropZone.prototype.vinflate = 0;
|
|
48
|
-
DropZone.prototype.baseClass = "dropzone";
|
|
49
|
-
|
|
50
|
-
Widget.alias("dropzone", DropZone);
|
|
51
|
-
|
|
52
|
-
class DropZoneComponent extends VDOM.Component {
|
|
53
|
-
constructor(props) {
|
|
54
|
-
super(props);
|
|
55
|
-
this.state = {
|
|
56
|
-
state: false,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
render() {
|
|
61
|
-
let { instance, children } = this.props;
|
|
62
|
-
let { data, widget } = instance;
|
|
63
|
-
let { CSS } = widget;
|
|
64
|
-
|
|
65
|
-
let classes = [data.classNames, CSS.state(this.state.state)];
|
|
66
|
-
|
|
67
|
-
let stateStyle;
|
|
68
|
-
|
|
69
|
-
switch (this.state.state) {
|
|
70
|
-
case "over":
|
|
71
|
-
classes.push(data.overClass);
|
|
72
|
-
stateStyle = parseStyle(data.overStyle);
|
|
73
|
-
break;
|
|
74
|
-
case "near":
|
|
75
|
-
classes.push(data.nearClass);
|
|
76
|
-
stateStyle = parseStyle(data.nearStyle);
|
|
77
|
-
break;
|
|
78
|
-
case "far":
|
|
79
|
-
classes.push(data.farClass);
|
|
80
|
-
stateStyle = parseStyle(data.farStyle);
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return (
|
|
85
|
-
<div
|
|
86
|
-
className={CSS.expand(classes)}
|
|
87
|
-
style={{ ...data.style, ...this.state.style, ...stateStyle }}
|
|
88
|
-
ref={(el) => {
|
|
89
|
-
this.el = el;
|
|
90
|
-
}}
|
|
91
|
-
>
|
|
92
|
-
{children}
|
|
93
|
-
</div>
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
componentDidMount() {
|
|
98
|
-
let dragDropOptions = this.context;
|
|
99
|
-
let disabled = dragDropOptions && dragDropOptions.disabled;
|
|
100
|
-
if (!disabled) this.unregister = registerDropZone(this);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
componentWillUnmount() {
|
|
104
|
-
this.unregister && this.unregister();
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
onDropTest(e) {
|
|
108
|
-
let { instance } = this.props;
|
|
109
|
-
let { widget } = instance;
|
|
110
|
-
return !widget.onDropTest || instance.invoke("onDropTest", e, instance);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
onDragStart(e) {
|
|
114
|
-
this.setState({
|
|
115
|
-
state: "far",
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
onDragNear(e) {
|
|
120
|
-
this.setState({
|
|
121
|
-
state: "near",
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
onDragAway(e) {
|
|
126
|
-
this.setState({
|
|
127
|
-
state: "far",
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
onDragLeave(e) {
|
|
132
|
-
let { nearDistance } = this.props.instance.widget;
|
|
133
|
-
this.setState({
|
|
134
|
-
state: nearDistance ? "near" : "far",
|
|
135
|
-
style: null,
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
onDragMeasure(e) {
|
|
140
|
-
let rect = getTopLevelBoundingClientRect(this.el);
|
|
141
|
-
|
|
142
|
-
let { instance } = this.props;
|
|
143
|
-
let { widget } = instance;
|
|
144
|
-
|
|
145
|
-
let { clientX, clientY } = e.cursor;
|
|
146
|
-
let distance =
|
|
147
|
-
Math.max(0, rect.left - clientX, clientX - rect.right) +
|
|
148
|
-
Math.max(0, rect.top - clientY, clientY - rect.bottom);
|
|
149
|
-
|
|
150
|
-
if (widget.hinflate > 0) {
|
|
151
|
-
rect.left -= widget.hinflate;
|
|
152
|
-
rect.right += widget.hinflate;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (widget.vinflate > 0) {
|
|
156
|
-
rect.top -= widget.vinflate;
|
|
157
|
-
rect.bottom += widget.vinflate;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
let { nearDistance } = widget;
|
|
161
|
-
|
|
162
|
-
let over = rect.left <= clientX && clientX < rect.right && rect.top <= clientY && clientY < rect.bottom;
|
|
163
|
-
|
|
164
|
-
return {
|
|
165
|
-
over:
|
|
166
|
-
over && Math.abs(clientX - (rect.left + rect.right) / 2) + Math.abs(clientY - (rect.top + rect.bottom) / 2),
|
|
167
|
-
near: nearDistance && (over || distance < nearDistance),
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
onDragEnter(e) {
|
|
172
|
-
let { instance } = this.props;
|
|
173
|
-
let { widget } = instance;
|
|
174
|
-
let style = {};
|
|
175
|
-
|
|
176
|
-
if (widget.matchWidth) style.width = `${e.source.width}px`;
|
|
177
|
-
|
|
178
|
-
if (widget.matchHeight) style.height = `${e.source.height}px`;
|
|
179
|
-
|
|
180
|
-
if (widget.matchMargin) style.margin = e.source.margin.join(" ");
|
|
181
|
-
|
|
182
|
-
if (this.state != "over")
|
|
183
|
-
this.setState({
|
|
184
|
-
state: "over",
|
|
185
|
-
style,
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
onDragOver(e) {}
|
|
190
|
-
|
|
191
|
-
onGetHScrollParent() {
|
|
192
|
-
return findScrollableParent(this.el, true);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
onGetVScrollParent() {
|
|
196
|
-
return findScrollableParent(this.el);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
onDrop(e) {
|
|
200
|
-
let { instance } = this.props;
|
|
201
|
-
let { widget } = instance;
|
|
202
|
-
|
|
203
|
-
if (this.state.state == "over" && widget.onDrop) instance.invoke("onDrop", e, instance);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
onDragEnd(e) {
|
|
207
|
-
this.setState({
|
|
208
|
-
state: false,
|
|
209
|
-
style: null,
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
DropZoneComponent.contextType = DragDropContext;
|
|
1
|
+
import { Widget, VDOM } from "../../ui/Widget";
|
|
2
|
+
import { Container } from "../../ui/Container";
|
|
3
|
+
import { parseStyle } from "../../util/parseStyle";
|
|
4
|
+
import { registerDropZone, DragDropContext } from "./ops";
|
|
5
|
+
import { findScrollableParent } from "../../util/findScrollableParent";
|
|
6
|
+
import { isNumber } from "../../util/isNumber";
|
|
7
|
+
import { getTopLevelBoundingClientRect } from "../../util/getTopLevelBoundingClientRect";
|
|
8
|
+
|
|
9
|
+
export class DropZone extends Container {
|
|
10
|
+
init() {
|
|
11
|
+
this.overStyle = parseStyle(this.overStyle);
|
|
12
|
+
this.nearStyle = parseStyle(this.nearStyle);
|
|
13
|
+
this.farStyle = parseStyle(this.farStyle);
|
|
14
|
+
|
|
15
|
+
if (isNumber(this.inflate)) {
|
|
16
|
+
this.hinflate = this.inflate;
|
|
17
|
+
this.vinflate = this.inflate;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
super.init();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
declareData() {
|
|
24
|
+
return super.declareData(...arguments, {
|
|
25
|
+
overClass: { structured: true },
|
|
26
|
+
nearClass: { structured: true },
|
|
27
|
+
farClass: { structured: true },
|
|
28
|
+
overStyle: { structured: true },
|
|
29
|
+
nearStyle: { structured: true },
|
|
30
|
+
farStyle: { structured: true },
|
|
31
|
+
data: { structured: true },
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
render(context, instance, key) {
|
|
36
|
+
return (
|
|
37
|
+
<DropZoneComponent key={key} instance={instance}>
|
|
38
|
+
{this.renderChildren(context, instance)}
|
|
39
|
+
</DropZoneComponent>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
DropZone.prototype.styled = true;
|
|
45
|
+
DropZone.prototype.nearDistance = 0;
|
|
46
|
+
DropZone.prototype.hinflate = 0;
|
|
47
|
+
DropZone.prototype.vinflate = 0;
|
|
48
|
+
DropZone.prototype.baseClass = "dropzone";
|
|
49
|
+
|
|
50
|
+
Widget.alias("dropzone", DropZone);
|
|
51
|
+
|
|
52
|
+
class DropZoneComponent extends VDOM.Component {
|
|
53
|
+
constructor(props) {
|
|
54
|
+
super(props);
|
|
55
|
+
this.state = {
|
|
56
|
+
state: false,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
render() {
|
|
61
|
+
let { instance, children } = this.props;
|
|
62
|
+
let { data, widget } = instance;
|
|
63
|
+
let { CSS } = widget;
|
|
64
|
+
|
|
65
|
+
let classes = [data.classNames, CSS.state(this.state.state)];
|
|
66
|
+
|
|
67
|
+
let stateStyle;
|
|
68
|
+
|
|
69
|
+
switch (this.state.state) {
|
|
70
|
+
case "over":
|
|
71
|
+
classes.push(data.overClass);
|
|
72
|
+
stateStyle = parseStyle(data.overStyle);
|
|
73
|
+
break;
|
|
74
|
+
case "near":
|
|
75
|
+
classes.push(data.nearClass);
|
|
76
|
+
stateStyle = parseStyle(data.nearStyle);
|
|
77
|
+
break;
|
|
78
|
+
case "far":
|
|
79
|
+
classes.push(data.farClass);
|
|
80
|
+
stateStyle = parseStyle(data.farStyle);
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<div
|
|
86
|
+
className={CSS.expand(classes)}
|
|
87
|
+
style={{ ...data.style, ...this.state.style, ...stateStyle }}
|
|
88
|
+
ref={(el) => {
|
|
89
|
+
this.el = el;
|
|
90
|
+
}}
|
|
91
|
+
>
|
|
92
|
+
{children}
|
|
93
|
+
</div>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
componentDidMount() {
|
|
98
|
+
let dragDropOptions = this.context;
|
|
99
|
+
let disabled = dragDropOptions && dragDropOptions.disabled;
|
|
100
|
+
if (!disabled) this.unregister = registerDropZone(this);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
componentWillUnmount() {
|
|
104
|
+
this.unregister && this.unregister();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
onDropTest(e) {
|
|
108
|
+
let { instance } = this.props;
|
|
109
|
+
let { widget } = instance;
|
|
110
|
+
return !widget.onDropTest || instance.invoke("onDropTest", e, instance);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
onDragStart(e) {
|
|
114
|
+
this.setState({
|
|
115
|
+
state: "far",
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
onDragNear(e) {
|
|
120
|
+
this.setState({
|
|
121
|
+
state: "near",
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
onDragAway(e) {
|
|
126
|
+
this.setState({
|
|
127
|
+
state: "far",
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
onDragLeave(e) {
|
|
132
|
+
let { nearDistance } = this.props.instance.widget;
|
|
133
|
+
this.setState({
|
|
134
|
+
state: nearDistance ? "near" : "far",
|
|
135
|
+
style: null,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
onDragMeasure(e) {
|
|
140
|
+
let rect = getTopLevelBoundingClientRect(this.el);
|
|
141
|
+
|
|
142
|
+
let { instance } = this.props;
|
|
143
|
+
let { widget } = instance;
|
|
144
|
+
|
|
145
|
+
let { clientX, clientY } = e.cursor;
|
|
146
|
+
let distance =
|
|
147
|
+
Math.max(0, rect.left - clientX, clientX - rect.right) +
|
|
148
|
+
Math.max(0, rect.top - clientY, clientY - rect.bottom);
|
|
149
|
+
|
|
150
|
+
if (widget.hinflate > 0) {
|
|
151
|
+
rect.left -= widget.hinflate;
|
|
152
|
+
rect.right += widget.hinflate;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (widget.vinflate > 0) {
|
|
156
|
+
rect.top -= widget.vinflate;
|
|
157
|
+
rect.bottom += widget.vinflate;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
let { nearDistance } = widget;
|
|
161
|
+
|
|
162
|
+
let over = rect.left <= clientX && clientX < rect.right && rect.top <= clientY && clientY < rect.bottom;
|
|
163
|
+
|
|
164
|
+
return {
|
|
165
|
+
over:
|
|
166
|
+
over && Math.abs(clientX - (rect.left + rect.right) / 2) + Math.abs(clientY - (rect.top + rect.bottom) / 2),
|
|
167
|
+
near: nearDistance && (over || distance < nearDistance),
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
onDragEnter(e) {
|
|
172
|
+
let { instance } = this.props;
|
|
173
|
+
let { widget } = instance;
|
|
174
|
+
let style = {};
|
|
175
|
+
|
|
176
|
+
if (widget.matchWidth) style.width = `${e.source.width}px`;
|
|
177
|
+
|
|
178
|
+
if (widget.matchHeight) style.height = `${e.source.height}px`;
|
|
179
|
+
|
|
180
|
+
if (widget.matchMargin) style.margin = e.source.margin.join(" ");
|
|
181
|
+
|
|
182
|
+
if (this.state != "over")
|
|
183
|
+
this.setState({
|
|
184
|
+
state: "over",
|
|
185
|
+
style,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
onDragOver(e) {}
|
|
190
|
+
|
|
191
|
+
onGetHScrollParent() {
|
|
192
|
+
return findScrollableParent(this.el, true);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
onGetVScrollParent() {
|
|
196
|
+
return findScrollableParent(this.el);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
onDrop(e) {
|
|
200
|
+
let { instance } = this.props;
|
|
201
|
+
let { widget } = instance;
|
|
202
|
+
|
|
203
|
+
if (this.state.state == "over" && widget.onDrop) instance.invoke("onDrop", e, instance);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
onDragEnd(e) {
|
|
207
|
+
this.setState({
|
|
208
|
+
state: false,
|
|
209
|
+
style: null,
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
DropZoneComponent.contextType = DragDropContext;
|
|
@@ -4,6 +4,7 @@ import { FocusManager, offFocusOut, oneFocusOut } from "../../ui/FocusManager";
|
|
|
4
4
|
import "../../ui/Format";
|
|
5
5
|
import { Localization } from "../../ui/Localization";
|
|
6
6
|
import { VDOM, Widget } from "../../ui/Widget";
|
|
7
|
+
import { parseDateInvariant } from "../../util";
|
|
7
8
|
import { KeyCode } from "../../util/KeyCode";
|
|
8
9
|
import { dateDiff } from "../../util/date/dateDiff";
|
|
9
10
|
import { lowerBoundCheck } from "../../util/date/lowerBoundCheck";
|
|
@@ -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());
|
|
@@ -35,7 +35,7 @@ export class ColorField extends Field {
|
|
|
35
35
|
required: undefined,
|
|
36
36
|
format: undefined,
|
|
37
37
|
},
|
|
38
|
-
...arguments
|
|
38
|
+
...arguments,
|
|
39
39
|
);
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -199,7 +199,7 @@ class ColorInput extends VDOM.Component {
|
|
|
199
199
|
icon: true,
|
|
200
200
|
empty: empty && !data.placeholder,
|
|
201
201
|
error: data.error && (state.visited || !suppressErrorsUntilVisited || !empty),
|
|
202
|
-
})
|
|
202
|
+
}),
|
|
203
203
|
)}
|
|
204
204
|
style={data.style}
|
|
205
205
|
onMouseDown={this.onMouseDown.bind(this)}
|
|
@@ -353,7 +353,7 @@ class ColorInput extends VDOM.Component {
|
|
|
353
353
|
}
|
|
354
354
|
|
|
355
355
|
componentWillUnmount() {
|
|
356
|
-
if (this.input == getActiveElement()) {
|
|
356
|
+
if (this.input == getActiveElement() && this.input.value != this.props.data.value) {
|
|
357
357
|
this.onChange(this.input.value, "blur");
|
|
358
358
|
}
|
|
359
359
|
tooltipParentWillUnmount(this.props.instance);
|
|
@@ -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);
|
|
@@ -510,7 +513,7 @@ class DateTimeInput extends VDOM.Component {
|
|
|
510
513
|
}
|
|
511
514
|
|
|
512
515
|
componentWillUnmount() {
|
|
513
|
-
if (this.input == getActiveElement()) {
|
|
516
|
+
if (this.input == getActiveElement() && this.input.value != this.props.data.formatted) {
|
|
514
517
|
this.onChange(this.input.value, "blur");
|
|
515
518
|
}
|
|
516
519
|
tooltipParentWillUnmount(this.props.instance);
|
|
@@ -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":
|
|
@@ -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) => {
|