@progress/kendo-react-dateinputs 14.4.1 → 14.5.0-develop.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.
- package/calendar/components/Calendar.d.ts +35 -110
- package/calendar/components/Calendar.js +5 -5
- package/calendar/components/Calendar.mjs +288 -313
- package/calendar/components/CalendarCell.d.ts +1 -10
- package/calendar/components/CalendarCell.js +1 -1
- package/calendar/components/CalendarCell.mjs +68 -78
- package/calendar/components/Header.d.ts +10 -23
- package/calendar/components/Header.js +1 -1
- package/calendar/components/Header.mjs +41 -55
- package/calendar/components/HorizontalViewList.d.ts +28 -26
- package/calendar/components/HorizontalViewList.js +1 -1
- package/calendar/components/HorizontalViewList.mjs +112 -102
- package/calendar/components/MultiViewCalendar.d.ts +39 -141
- package/calendar/components/MultiViewCalendar.js +1 -1
- package/calendar/components/MultiViewCalendar.mjs +331 -373
- package/calendar/components/Navigation.d.ts +19 -39
- package/calendar/components/Navigation.js +1 -1
- package/calendar/components/Navigation.mjs +95 -107
- package/calendar/components/TodayCommand.d.ts +8 -25
- package/calendar/components/TodayCommand.js +1 -1
- package/calendar/components/TodayCommand.mjs +44 -61
- package/calendar/components/View.d.ts +11 -42
- package/calendar/components/View.js +1 -1
- package/calendar/components/View.mjs +111 -137
- package/calendar/components/ViewList.d.ts +25 -65
- package/calendar/components/ViewList.js +1 -1
- package/calendar/components/ViewList.mjs +207 -225
- package/calendar/services/ScrollSyncService.d.ts +4 -4
- package/dateinput/DateInput.js +1 -1
- package/dateinput/DateInput.mjs +55 -55
- package/datetimepicker/DateTimeSelector.d.ts +2 -3
- package/datetimepicker/DateTimeSelector.js +1 -1
- package/datetimepicker/DateTimeSelector.mjs +92 -89
- package/dist/cdn/js/kendo-react-dateinputs.js +1 -1
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +14 -9
- package/timepicker/TimePicker.js +1 -1
- package/timepicker/TimePicker.mjs +2 -2
- package/virtualization/Virtualization.d.ts +25 -63
- package/virtualization/Virtualization.js +1 -1
- package/virtualization/Virtualization.mjs +163 -168
package/dateinput/DateInput.mjs
CHANGED
|
@@ -9,22 +9,22 @@ import * as r from "react";
|
|
|
9
9
|
import e from "prop-types";
|
|
10
10
|
import { cloneDate as M, isEqual as Fe } from "@progress/kendo-date-math";
|
|
11
11
|
import { Button as Q } from "@progress/kendo-react-buttons";
|
|
12
|
-
import {
|
|
12
|
+
import { chevronUpIcon as He, chevronDownIcon as Be } from "@progress/kendo-svg-icons";
|
|
13
13
|
import { useInternationalization as qe, useLocalization as ze } from "@progress/kendo-react-intl";
|
|
14
|
-
import { useId as je, useUnstyled as Ue, usePropsContext as ee, classNames as
|
|
14
|
+
import { useId as je, useUnstyled as Ue, usePropsContext as ee, classNames as b, uDateInput as O, createPropsContext as We, getActiveElement as te } from "@progress/kendo-react-common";
|
|
15
15
|
import { FloatingLabel as Ke } from "@progress/kendo-react-labels";
|
|
16
16
|
import { DateInput as Je } from "@progress/kendo-dateinputs-common";
|
|
17
17
|
import { DEFAULT_FORMAT_PLACEHOLDER as Ye, DEFAULT_FORMAT as Xe, isInRange as Ze } from "./utils.mjs";
|
|
18
|
-
import { MAX_TIME as Ge, MIN_TIME as $e, MIN_DATE as Qe, MAX_DATE as et, nullable as
|
|
18
|
+
import { MAX_TIME as Ge, MIN_TIME as $e, MIN_DATE as Qe, MAX_DATE as et, nullable as u } from "../utils.mjs";
|
|
19
19
|
import { increaseValue as S, messages as P, decreaseValue as R } from "../messages/index.mjs";
|
|
20
20
|
import { isInTimeRange as tt } from "../timepicker/utils.mjs";
|
|
21
21
|
import nt from "../common/ClearButton.mjs";
|
|
22
22
|
import { DateInputIntl as at } from "./dateInputIntl.mjs";
|
|
23
23
|
const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
24
24
|
var $;
|
|
25
|
-
const ie = je(t.id), le = qe(), E = ze(),
|
|
25
|
+
const ie = je(t.id), le = qe(), E = ze(), oe = Ue(), H = ee(ne, t).unstyled || oe, {
|
|
26
26
|
format: L = l.format,
|
|
27
|
-
defaultValue:
|
|
27
|
+
defaultValue: ue = l.defaultValue,
|
|
28
28
|
size: se = l.size,
|
|
29
29
|
rounded: ce = l.rounded,
|
|
30
30
|
fillMode: de = l.fillMode,
|
|
@@ -33,9 +33,9 @@ const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
|
33
33
|
disabled: I = l.disabled,
|
|
34
34
|
min: ge = l.min,
|
|
35
35
|
max: ve = l.max,
|
|
36
|
-
minTime:
|
|
37
|
-
maxTime:
|
|
38
|
-
validityStyles:
|
|
36
|
+
minTime: he = l.minTime,
|
|
37
|
+
maxTime: ye = l.maxTime,
|
|
38
|
+
validityStyles: be = l.validityStyles,
|
|
39
39
|
validationMessage: B = l.validationMessage,
|
|
40
40
|
placeholder: m = l.placeholder,
|
|
41
41
|
enableMouseWheel: Oe = l.enableMouseWheel,
|
|
@@ -47,20 +47,20 @@ const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
|
47
47
|
autoFocus: g = l.autoFocus
|
|
48
48
|
} = ee(ne, t), x = (n) => {
|
|
49
49
|
pe((a) => ({ ...a, ...n }));
|
|
50
|
-
}, d = () =>
|
|
50
|
+
}, d = () => A.value ? A.value : T.current !== void 0 ? T.current : i.current && i.current.value, q = () => {
|
|
51
51
|
const n = i.current && i.current.currentText || "", a = d();
|
|
52
|
-
return m != null && !
|
|
52
|
+
return m != null && !A.focused && !a ? m : n;
|
|
53
53
|
}, z = () => t.required !== void 0 ? t.required : !1, V = () => {
|
|
54
|
-
const n = d() || t.value, a = ge,
|
|
54
|
+
const n = d() || t.value, a = ge, y = ve, k = Ze(n, a, y) && tt(n, he, ye), _ = B !== void 0, F = (!z() || n != null) && k, _e = t.valid !== void 0 ? t.valid : F;
|
|
55
55
|
return {
|
|
56
56
|
customError: _,
|
|
57
|
-
rangeOverflow: n &&
|
|
57
|
+
rangeOverflow: n && y.getTime() < n.getTime() || !1,
|
|
58
58
|
rangeUnderflow: n && n.getTime() < a.getTime() || !1,
|
|
59
59
|
valid: _e,
|
|
60
60
|
valueMissing: n === null
|
|
61
61
|
};
|
|
62
62
|
}, De = () => {
|
|
63
|
-
|
|
63
|
+
o.current && o.current.focus();
|
|
64
64
|
}, j = () => new at(le), C = () => {
|
|
65
65
|
const n = d();
|
|
66
66
|
return {
|
|
@@ -91,8 +91,8 @@ const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
|
91
91
|
}, W = (n) => {
|
|
92
92
|
t.onChange && t.onChange(n);
|
|
93
93
|
}, K = (n) => {
|
|
94
|
-
te(document) ===
|
|
95
|
-
}, Re = () => new Je(
|
|
94
|
+
te(document) === o.current && n.preventDefault();
|
|
95
|
+
}, Re = () => new Je(o.current, {
|
|
96
96
|
...C(),
|
|
97
97
|
format: Pe(C().format),
|
|
98
98
|
events: {
|
|
@@ -102,24 +102,24 @@ const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
|
102
102
|
click: W
|
|
103
103
|
}
|
|
104
104
|
}), J = () => {
|
|
105
|
-
|
|
105
|
+
o.current && o.current.setCustomValidity && o.current.setCustomValidity(
|
|
106
106
|
V().valid ? "" : B || l.validationMessage
|
|
107
107
|
);
|
|
108
108
|
}, Y = r.useCallback(
|
|
109
109
|
(n) => {
|
|
110
110
|
var a;
|
|
111
|
-
if (
|
|
112
|
-
const
|
|
111
|
+
if (o.current && g && n) {
|
|
112
|
+
const y = (i == null ? void 0 : i.current).currentText, k = (i == null ? void 0 : i.current).currentText.search(/[^a-zA-Z]/), _ = y[k], F = y.split(_)[0].length;
|
|
113
113
|
s.current && s.current.classList.add("k-focus"), (a = i == null ? void 0 : i.current) == null || a.selectNearestSegment(F);
|
|
114
114
|
}
|
|
115
115
|
},
|
|
116
116
|
[g]
|
|
117
117
|
), Le = (n) => {
|
|
118
|
-
!
|
|
118
|
+
!o.current || !i.current || U(n);
|
|
119
119
|
}, Ve = (n) => {
|
|
120
120
|
n.preventDefault();
|
|
121
121
|
const a = te(document);
|
|
122
|
-
|
|
122
|
+
o.current && a !== o.current && o.current.focus({ preventScroll: !0 });
|
|
123
123
|
}, c = (n) => {
|
|
124
124
|
const a = d();
|
|
125
125
|
f.current && t.onChange && !Fe(f.current.oldValue, a) && t.onChange.call(void 0, {
|
|
@@ -128,13 +128,13 @@ const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
|
128
128
|
value: f.current.value,
|
|
129
129
|
target: w.current
|
|
130
130
|
}), f.current = null;
|
|
131
|
-
},
|
|
131
|
+
}, Ne = (n) => {
|
|
132
132
|
var a;
|
|
133
133
|
(a = i.current) == null || a.modifyDateSegmentValue(1), c(n);
|
|
134
|
-
},
|
|
134
|
+
}, Ae = (n) => {
|
|
135
135
|
var a;
|
|
136
136
|
(a = i.current) == null || a.modifyDateSegmentValue(-1), c(n);
|
|
137
|
-
}, w = r.useRef(null),
|
|
137
|
+
}, w = r.useRef(null), o = r.useRef(null), s = r.useRef(null);
|
|
138
138
|
r.useImperativeHandle(
|
|
139
139
|
w,
|
|
140
140
|
() => ({
|
|
@@ -146,7 +146,7 @@ const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
|
146
146
|
return q();
|
|
147
147
|
},
|
|
148
148
|
get element() {
|
|
149
|
-
return
|
|
149
|
+
return o.current;
|
|
150
150
|
},
|
|
151
151
|
get name() {
|
|
152
152
|
return t.name;
|
|
@@ -162,13 +162,13 @@ const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
|
162
162
|
updateOnPaste: Le
|
|
163
163
|
})
|
|
164
164
|
), r.useImperativeHandle(re, () => w.current);
|
|
165
|
-
const i = r.useRef(null), D = r.useRef(null),
|
|
166
|
-
value: t.value === void 0 ?
|
|
165
|
+
const i = r.useRef(null), D = r.useRef(null), N = r.useRef(!1), T = r.useRef(null), f = r.useRef(null), v = r.useRef(t), [A, pe] = r.useState({
|
|
166
|
+
value: t.value === void 0 ? ue : null,
|
|
167
167
|
focused: !1
|
|
168
168
|
}), [, ke] = r.useReducer((n) => n + 1, 0);
|
|
169
169
|
r.useLayoutEffect(() => {
|
|
170
|
-
|
|
171
|
-
}, []), r.useEffect(() => (J(),
|
|
170
|
+
N.current || (i.current = Re(), D.current = i.current.dateObject, N.current = !0);
|
|
171
|
+
}, []), r.useEffect(() => (J(), N.current || s.current && s.current.addEventListener("wheel", K, { passive: !1 }), g && (x({ focused: !0 }), Y(!0)), () => {
|
|
172
172
|
s.current && s.current.removeEventListener("wheel", K);
|
|
173
173
|
}), []), r.useEffect(() => {
|
|
174
174
|
J(), i.current && (D.current = i.current.dateObject, (Se(v.current.format, L) || v.current.readonly !== t.readonly || JSON.stringify(v.current.steps) !== JSON.stringify(t.steps) || j().locale !== i.current.options.intlService.locale) && i.current.setOptions(C(), !0), v.current.value !== t.value && (D.current.getValue() !== null || t.value !== null) && D.current.setValue(t.value), t.ariaExpanded !== void 0 && t.ariaExpanded && (i.current.options.placeholder = null), t.ariaExpanded !== void 0 && !t.ariaExpanded && (i.current.options.placeholder = m), i.current.refreshElementValue(), v.current = {
|
|
@@ -179,7 +179,7 @@ const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
|
179
179
|
value: t.value
|
|
180
180
|
});
|
|
181
181
|
});
|
|
182
|
-
const X = t.id || ie + "-accessibility-id",
|
|
182
|
+
const X = t.id || ie + "-accessibility-id", h = H && H.uDateInput, Z = q(), p = !be || V().valid;
|
|
183
183
|
r.useImperativeHandle(t._ref, () => w.current);
|
|
184
184
|
const G = /* @__PURE__ */ r.createElement(
|
|
185
185
|
"span",
|
|
@@ -189,9 +189,9 @@ const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
|
189
189
|
},
|
|
190
190
|
style: t.label ? void 0 : { width: t.width },
|
|
191
191
|
dir: t.dir,
|
|
192
|
-
className:
|
|
192
|
+
className: b(
|
|
193
193
|
O.wrapper({
|
|
194
|
-
c:
|
|
194
|
+
c: h,
|
|
195
195
|
size: se,
|
|
196
196
|
fillMode: de,
|
|
197
197
|
rounded: ce,
|
|
@@ -206,7 +206,7 @@ const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
|
206
206
|
"input",
|
|
207
207
|
{
|
|
208
208
|
ref: (n) => {
|
|
209
|
-
|
|
209
|
+
o.current = n;
|
|
210
210
|
},
|
|
211
211
|
role: t.ariaRole || "textbox",
|
|
212
212
|
readOnly: t.readonly,
|
|
@@ -218,7 +218,7 @@ const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
|
218
218
|
autoComplete: "off",
|
|
219
219
|
autoCorrect: "off",
|
|
220
220
|
autoFocus: g,
|
|
221
|
-
className:
|
|
221
|
+
className: b(O.inputInner({ c: h })),
|
|
222
222
|
id: X,
|
|
223
223
|
value: Z,
|
|
224
224
|
"aria-label": t.ariaLabel,
|
|
@@ -241,29 +241,29 @@ const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
|
241
241
|
),
|
|
242
242
|
t.children,
|
|
243
243
|
t.clearButton && t.value && /* @__PURE__ */ r.createElement(nt, { onClick: W, key: "clearbutton" }),
|
|
244
|
-
me && /* @__PURE__ */ r.createElement("span", { className:
|
|
244
|
+
me && /* @__PURE__ */ r.createElement("span", { className: b(O.inputSpinner({ c: h })), onMouseDown: Ve }, /* @__PURE__ */ r.createElement(
|
|
245
245
|
Q,
|
|
246
246
|
{
|
|
247
247
|
tabIndex: -1,
|
|
248
248
|
type: "button",
|
|
249
|
-
className:
|
|
250
|
-
icon: "
|
|
249
|
+
className: b(O.spinnerIncrease({ c: h })),
|
|
250
|
+
icon: "chevron-up",
|
|
251
251
|
svgIcon: He,
|
|
252
252
|
"aria-label": E.toLanguageString(S, P[S]),
|
|
253
253
|
title: E.toLanguageString(S, P[S]),
|
|
254
|
-
onClick:
|
|
254
|
+
onClick: Ne
|
|
255
255
|
}
|
|
256
256
|
), /* @__PURE__ */ r.createElement(
|
|
257
257
|
Q,
|
|
258
258
|
{
|
|
259
259
|
tabIndex: -1,
|
|
260
260
|
type: "button",
|
|
261
|
-
className:
|
|
262
|
-
icon: "
|
|
261
|
+
className: b(O.spinnerDecrease({ c: h })),
|
|
262
|
+
icon: "chevron-down",
|
|
263
263
|
svgIcon: Be,
|
|
264
264
|
"aria-label": E.toLanguageString(R, P[R]),
|
|
265
265
|
title: E.toLanguageString(R, P[R]),
|
|
266
|
-
onClick:
|
|
266
|
+
onClick: Ae
|
|
267
267
|
}
|
|
268
268
|
))
|
|
269
269
|
);
|
|
@@ -272,7 +272,7 @@ const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
|
272
272
|
{
|
|
273
273
|
label: t.label,
|
|
274
274
|
editorId: X,
|
|
275
|
-
editorValue: ($ =
|
|
275
|
+
editorValue: ($ = o.current) == null ? void 0 : $.value,
|
|
276
276
|
editorValid: p,
|
|
277
277
|
editorDisabled: I,
|
|
278
278
|
children: G,
|
|
@@ -283,7 +283,7 @@ const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
|
283
283
|
ae.propTypes = {
|
|
284
284
|
value: e.instanceOf(Date),
|
|
285
285
|
format: e.oneOfType([
|
|
286
|
-
|
|
286
|
+
u(e.string),
|
|
287
287
|
e.shape({
|
|
288
288
|
skeleton: e.string,
|
|
289
289
|
pattern: e.string,
|
|
@@ -303,28 +303,28 @@ ae.propTypes = {
|
|
|
303
303
|
})
|
|
304
304
|
]),
|
|
305
305
|
formatPlaceholder: e.oneOfType([
|
|
306
|
-
|
|
306
|
+
u(
|
|
307
307
|
e.oneOf(["wide", "narrow", "short", "formatPattern"])
|
|
308
308
|
),
|
|
309
309
|
e.shape({
|
|
310
|
-
year:
|
|
311
|
-
month:
|
|
312
|
-
day:
|
|
313
|
-
hour:
|
|
314
|
-
minute:
|
|
315
|
-
second:
|
|
310
|
+
year: u(e.string),
|
|
311
|
+
month: u(e.string),
|
|
312
|
+
day: u(e.string),
|
|
313
|
+
hour: u(e.string),
|
|
314
|
+
minute: u(e.string),
|
|
315
|
+
second: u(e.string)
|
|
316
316
|
})
|
|
317
317
|
]),
|
|
318
318
|
width: e.oneOfType([e.string, e.number]),
|
|
319
319
|
tabIndex: e.number,
|
|
320
320
|
title: e.string,
|
|
321
321
|
steps: e.shape({
|
|
322
|
-
year:
|
|
323
|
-
month:
|
|
324
|
-
day:
|
|
325
|
-
hour:
|
|
326
|
-
minute:
|
|
327
|
-
second:
|
|
322
|
+
year: u(e.number),
|
|
323
|
+
month: u(e.number),
|
|
324
|
+
day: u(e.number),
|
|
325
|
+
hour: u(e.number),
|
|
326
|
+
minute: u(e.number),
|
|
327
|
+
second: u(e.number)
|
|
328
328
|
}),
|
|
329
329
|
min: e.instanceOf(Date),
|
|
330
330
|
max: e.instanceOf(Date),
|
|
@@ -75,7 +75,7 @@ export declare class DateTimeSelector extends React.Component<DateTimeSelectorPr
|
|
|
75
75
|
private _timePart;
|
|
76
76
|
private _cancelButton;
|
|
77
77
|
private _acceptButton;
|
|
78
|
-
private
|
|
78
|
+
private _buttonGroupRef;
|
|
79
79
|
private _calendarWrap;
|
|
80
80
|
private shouldFocusPart;
|
|
81
81
|
get calendar(): Calendar | null;
|
|
@@ -100,8 +100,7 @@ export declare class DateTimeSelector extends React.Component<DateTimeSelectorPr
|
|
|
100
100
|
private handleNowClick;
|
|
101
101
|
private handleCalendarValueChange;
|
|
102
102
|
private handleTimeListContainerChange;
|
|
103
|
-
private
|
|
104
|
-
private handleTimeClick;
|
|
103
|
+
private readonly handleTabChange;
|
|
105
104
|
private handleKeyDown;
|
|
106
105
|
private handleCancelKeyDown;
|
|
107
106
|
private handleSetKeyDown;
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("react"),
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("react"),D=require("@progress/kendo-react-intl"),r=require("../messages/index.js"),f=require("@progress/kendo-react-buttons"),N=require("../calendar/components/Calendar.js"),S=require("../timepicker/TimePart.js"),c=require("../utils.js"),y=require("@progress/kendo-date-math"),a=require("@progress/kendo-react-common"),b=require("../timepicker/utils.js");function V(d){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(d){for(const e in d)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(d,e);Object.defineProperty(s,e,t.get?t:{enumerable:!0,get:()=>d[e]})}}return s.default=d,Object.freeze(s)}const o=V(E),v=class v extends o.Component{constructor(s){super(s),this._calendar=null,this._timePart=null,this._cancelButton=null,this._acceptButton=null,this._buttonGroupRef=null,this._calendarWrap=null,this.shouldFocusPart=!1,this.focus=e=>{Promise.resolve().then(()=>{this.state.tab==="time"&&this._timePart&&this._timePart.focus(e);const t=this.calendarElement();this.state.tab==="date"&&t&&t.focus(e)})},this.calendarElement=()=>this._calendar&&this._calendar.element||this._calendarWrap&&this._calendarWrap.querySelector(".k-calendar"),this.move=e=>{if(e==="right"&&this.state.tab==="time"||e==="left"&&this.state.tab==="date")return;const t=e==="left"?"date":"time";this.shouldFocusPart=!0,this.setState({tab:t})},this.dateTimeFooter=()=>{const{cancelButton:e,unstyled:t}=this.props,i=t&&t.uDateTimePicker,n=this.localizationService.toLanguageString(r.dateTimePickerCancel,r.messages[r.dateTimePickerCancel]),h=this.localizationService.toLanguageString(r.dateTimePickerSet,r.messages[r.dateTimePickerSet]);return o.createElement("div",{className:a.classNames(a.uDateTimePicker.timeFooter({c:i}))},o.createElement(f.Button,{type:"button",themeColor:"primary",ref:l=>{this._acceptButton=l},className:a.classNames(a.uTime.accept({c:i})),disabled:!this.hasDateValue,onClick:this.handleAccept,onKeyDown:this.handleSetKeyDown,title:h,"aria-label":h},h),e&&o.createElement(f.Button,{type:"button",ref:l=>{this._cancelButton=l},className:a.classNames(a.uTime.cancel({c:i})),onClick:this.handleReject,onKeyDown:this.handleCancelKeyDown,title:n,"aria-label":n},n))},this.handleReject=e=>{this.setState({dateValue:this.props.value,timeValue:this.props.value||c.MIDNIGHT_DATE});const t=this.mergeDate(this.props.value,this.props.value||c.MIDNIGHT_DATE);if(this.props.onReject){const i={nativeEvent:e.nativeEvent,syntheticEvent:e,target:this,value:t};this.props.onReject.call(void 0,i)}},this.handleAccept=(e,t)=>{if(!this.state.dateValue||!this.state.timeValue||!this.hasDateValue)return;const i=t||(this._timePart?this._timePart.value:this.state.timeValue),n=this.mergeDate(this.state.dateValue,i);this.props.onChange.call(void 0,{syntheticEvent:e,nativeEvent:e.nativeEvent,value:n,target:this})},this.handleNowClick=e=>{this.setState({timeValue:b.getNow()}),this.handleAccept(e,b.getNow())},this.handleCalendarValueChange=e=>{e.syntheticEvent.stopPropagation(),this.setState({dateValue:e.value,tab:"time"}),this.shouldFocusPart=!0},this.handleTimeListContainerChange=e=>{this.setState({timeValue:e})},this.handleTabChange=e=>{const t=e==="date"?"left":"right";this.move(t)},this.handleKeyDown=e=>{const{keyCode:t,altKey:i}=e;if(!this.props.disabled)switch(t){case a.Keys.enter:!this.hasActiveButton()&&this.hasDateValue&&this.handleAccept(e);return;case a.Keys.left:if(!i)return;this.move("left");return;case a.Keys.right:if(!i)return;this.move("right");return;default:return}},this.handleCancelKeyDown=e=>{var n;const{keyCode:t}=e,i=(n=this._buttonGroupRef)==null?void 0:n.querySelector(".k-segmented-control-button");t===a.Keys.tab&&i&&(e.preventDefault(),i.focus())},this.handleSetKeyDown=e=>{var n;const{keyCode:t}=e,i=(n=this._buttonGroupRef)==null?void 0:n.querySelector(".k-segmented-control-button");t===a.Keys.tab&&!this.props.cancelButton&&i&&(e.preventDefault(),i.focus())},this.handleDateKeyDown=e=>{var n,h,l;const{keyCode:t,shiftKey:i}=e;i&&t===a.Keys.tab&&(e.stopPropagation(),(n=this._cancelButton)!=null&&n.element?this._cancelButton.element.focus():(l=(h=this._acceptButton)==null?void 0:h.element)==null||l.focus()),t===a.Keys.enter&&e.stopPropagation()},this.handleTimeKeyDown=e=>{const{keyCode:t}=e;t===a.Keys.enter&&e.stopPropagation()},this.handleTimePartMount=e=>{this.setState({timeValue:e})},this.state={tab:"date",dateValue:this.props.value,timeValue:this.props.value||c.MIDNIGHT_DATE}}get calendar(){return this._calendar}get timePart(){return this._timePart}get hasDateValue(){return this.state.dateValue!==null}get localizationService(){return D.provideLocalizationService(this)}componentDidUpdate(s,e){var t,i;this.shouldFocusPart&&this.focus({preventScroll:!0}),(((t=s.value)==null?void 0:t.getTime())!==((i=this.props.value)==null?void 0:i.getTime())||this.state.tab!==e.tab&&this.props.value)&&this.setState(n=>({dateValue:s.value&&this.props.value&&y.isEqualDate(s.value,this.props.value)?n.dateValue:this.props.value,timeValue:this.props.value||c.MIDNIGHT_DATE})),this.shouldFocusPart=!1}render(){const{disabled:s,min:e,max:t,weekNumber:i,focusedDate:n,format:h,mobileMode:l,footerActions:_,unstyled:g}=this.props,m=g&&g.uDateTimePicker,P=a.classNames(a.uDateTimePicker.wrap({c:m,date:this.state.tab==="date",time:this.state.tab==="time",disabled:s})),C=this.localizationService.toLanguageString(r.date,r.messages[r.date]),k=this.localizationService.toLanguageString(r.time,r.messages[r.time]),T={min:e,max:t,weekNumber:i,focusedDate:n,disabled:s||this.state.tab!=="date",value:this.state.dateValue,onChange:this.handleCalendarValueChange,navigation:!1,tabIndex:s||this.state.tab!=="date"?-1:void 0,mobileMode:l};return o.createElement("div",{onKeyDown:this.handleKeyDown,className:P,tabIndex:-1},o.createElement("div",{className:a.classNames(a.uDateTimePicker.buttonGroup({c:m})),ref:u=>{this._buttonGroupRef=u}},o.createElement(f.SegmentedControl,{layoutMode:"stretch",size:l?"large":void 0,value:this.state.tab,onChange:this.handleTabChange,items:[{value:"date",text:C,onKeyDown:this.handleDateKeyDown},{value:"time",text:k,onKeyDown:this.handleTimeKeyDown}]})),o.createElement("div",{className:a.classNames(a.uDateTimePicker.selector({c:m}))},o.createElement("div",{className:a.classNames(a.uDateTimePicker.calendarWrap({c:m})),ref:u=>{this._calendarWrap=u}},this.props.calendar?o.createElement(this.props.calendar,{key:this.state.tab,...T}):o.createElement(N.Calendar,{key:this.state.tab,ref:u=>{this._calendar=u},...T})),o.createElement("div",{className:a.classNames(a.uDateTimePicker.timeWrap({c:m}))},o.createElement("div",{className:a.classNames(a.uDateTimePicker.timeSelector({c:m,mobileMode:l}))},o.createElement(S.TimePart,{key:1,onNowClick:this.handleNowClick,disabled:s||this.state.tab!=="time",ref:u=>{this._timePart=u},min:this.minTime||c.MIN_TIME,max:this.maxTime||c.MAX_TIME,steps:this.props.steps,value:this.state.timeValue,format:h,onChange:this.handleTimeListContainerChange,onMount:this.handleTimePartMount,mobileMode:l,unstyled:g})))),_&&this.dateTimeFooter())}get minTime(){return this.props.minTime!==void 0?this.props.minTime:this.normalizeRange(this.props.min,this.state.dateValue)}get maxTime(){return this.props.maxTime!==void 0?this.props.maxTime:this.normalizeRange(this.props.max,this.state.dateValue)}normalizeRange(s,e){return y.isEqualDate(s,e||c.getToday())?s:null}hasActiveButton(){if(!this._acceptButton)return!1;const s=a.getActiveElement(document);return this._acceptButton&&s===this._acceptButton.element||this._cancelButton&&s===this._cancelButton.element}mergeTime(s,e){return s&&e?c.setTime(e,s):e}mergeDate(s,e){return s?c.setTime(s||c.getToday(),e):e}};v.defaultProps={footerActions:!0};let p=v;D.registerForLocalization(p);exports.DateTimeSelector=p;
|