@progress/kendo-react-dateinputs 11.0.0-develop.3 → 11.0.0-develop.4
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/common/AdaptiveMode.js +1 -1
- package/common/AdaptiveMode.mjs +14 -13
- package/datepicker/DatePicker.js +1 -1
- package/datepicker/DatePicker.mjs +155 -150
- package/daterangepicker/DateRangePicker.js +1 -1
- package/daterangepicker/DateRangePicker.mjs +59 -65
- package/datetimepicker/DateTimePicker.js +1 -1
- package/datetimepicker/DateTimePicker.mjs +49 -46
- package/datetimepicker/DateTimeSelector.js +1 -1
- package/datetimepicker/DateTimeSelector.mjs +23 -21
- package/dist/cdn/js/kendo-react-dateinputs.js +1 -1
- package/index.d.mts +42 -6
- package/index.d.ts +42 -6
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +8 -8
- package/timepicker/TimePicker.js +1 -1
- package/timepicker/TimePicker.mjs +39 -36
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import * as
|
|
8
|
+
import * as n from "react";
|
|
9
9
|
import e from "prop-types";
|
|
10
10
|
import { Popup as $ } from "@progress/kendo-react-popup";
|
|
11
11
|
import { cloneDate as M } from "@progress/kendo-date-math";
|
|
12
|
-
import { Keys as d, canUseDOM as O, AsyncFocusBlur as ee, classNames as
|
|
13
|
-
import { calendarIcon as
|
|
12
|
+
import { Keys as d, canUseDOM as O, AsyncFocusBlur as ee, classNames as S, uDateTimePicker as I, createPropsContext as te, withIdHOC as ie, withPropsContext as se, withUnstyledHOC as oe, withAdaptiveModeContext as ae } from "@progress/kendo-react-common";
|
|
13
|
+
import { calendarIcon as ne } from "@progress/kendo-svg-icons";
|
|
14
14
|
import { DateInput as re } from "../dateinput/DateInput.mjs";
|
|
15
15
|
import { Button as le } from "@progress/kendo-react-buttons";
|
|
16
16
|
import { MAX_DATE as he, MIN_DATE as de, isInDateRange as ue, MAX_TIME as pe, MIN_TIME as ce } from "../utils.mjs";
|
|
@@ -21,14 +21,14 @@ import { isInTimeRange as ge } from "../timepicker/utils.mjs";
|
|
|
21
21
|
import { PickerFloatingLabel as ve } from "../hooks/usePickerFloatingLabel.mjs";
|
|
22
22
|
import { AdaptiveMode as we } from "../common/AdaptiveMode.mjs";
|
|
23
23
|
import { ActionSheetContent as be } from "@progress/kendo-react-layout";
|
|
24
|
-
const o = class o extends
|
|
24
|
+
const o = class o extends n.Component {
|
|
25
25
|
constructor(i) {
|
|
26
|
-
super(i), this._element = null, this._dateInput =
|
|
26
|
+
super(i), this._element = null, this._dateInput = n.createRef(), this._dateTimeSelector = null, this.shouldFocusDateInput = !1, this.prevShow = !1, this.focus = () => {
|
|
27
27
|
const t = this.dateInputElement();
|
|
28
28
|
t && t.focus();
|
|
29
29
|
}, this.renderPicker = () => {
|
|
30
|
-
const { disabled: t, minTime: s, maxTime:
|
|
31
|
-
return /* @__PURE__ */
|
|
30
|
+
const { disabled: t, minTime: s, maxTime: a, format: h, calendar: l, cancelButton: r, weekNumber: g, focusedDate: u, unstyled: v } = this.props;
|
|
31
|
+
return /* @__PURE__ */ n.createElement(
|
|
32
32
|
fe,
|
|
33
33
|
{
|
|
34
34
|
ref: (w) => {
|
|
@@ -44,7 +44,7 @@ const o = class o extends a.Component {
|
|
|
44
44
|
min: this.min,
|
|
45
45
|
max: this.max,
|
|
46
46
|
minTime: s,
|
|
47
|
-
maxTime:
|
|
47
|
+
maxTime: a,
|
|
48
48
|
focusedDate: u,
|
|
49
49
|
format: h,
|
|
50
50
|
calendar: l,
|
|
@@ -57,13 +57,14 @@ const o = class o extends a.Component {
|
|
|
57
57
|
const { windowWidth: t = 0 } = this.state, s = m(this).toLanguageString(
|
|
58
58
|
C,
|
|
59
59
|
p[C]
|
|
60
|
-
),
|
|
60
|
+
), a = m(this).toLanguageString(
|
|
61
61
|
P,
|
|
62
62
|
p[P]
|
|
63
63
|
), h = {
|
|
64
64
|
expand: this.show,
|
|
65
65
|
onClose: this.handleBlur,
|
|
66
|
-
title: this.props.adaptiveTitle,
|
|
66
|
+
title: this.props.adaptiveTitle || this.props.label,
|
|
67
|
+
subTitle: this.props.adaptiveSubtitle,
|
|
67
68
|
windowWidth: t,
|
|
68
69
|
footer: {
|
|
69
70
|
cancelText: s,
|
|
@@ -71,14 +72,14 @@ const o = class o extends a.Component {
|
|
|
71
72
|
var r;
|
|
72
73
|
return (r = this._dateTimeSelector) == null ? void 0 : r.handleReject(l);
|
|
73
74
|
},
|
|
74
|
-
applyText:
|
|
75
|
+
applyText: a,
|
|
75
76
|
onApply: (l) => {
|
|
76
77
|
var r;
|
|
77
78
|
return (r = this._dateTimeSelector) == null ? void 0 : r.handleAccept(l);
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
};
|
|
81
|
-
return /* @__PURE__ */
|
|
82
|
+
return /* @__PURE__ */ n.createElement(we, { ...h }, /* @__PURE__ */ n.createElement(be, null, this.renderPicker()));
|
|
82
83
|
}, this.handleReject = () => {
|
|
83
84
|
this.shouldFocusDateInput = !0, this.setShow(!1);
|
|
84
85
|
}, this.handleValueChange = (t) => {
|
|
@@ -97,17 +98,17 @@ const o = class o extends a.Component {
|
|
|
97
98
|
this.setState({ focused: !0 });
|
|
98
99
|
}, this.handleBlur = () => {
|
|
99
100
|
this.setState({ focused: !1 }), this.setShow(!1);
|
|
100
|
-
}, this.
|
|
101
|
+
}, this.handleClick = () => {
|
|
101
102
|
this.props.disabled || (this.shouldFocusDateInput = !0, this.setShow(!this.show));
|
|
102
103
|
}, this.handleIconMouseDown = (t) => {
|
|
103
104
|
t.preventDefault();
|
|
104
105
|
}, this.handleKeyDown = (t) => {
|
|
105
|
-
const { altKey: s, keyCode:
|
|
106
|
-
if (
|
|
106
|
+
const { altKey: s, keyCode: a } = t;
|
|
107
|
+
if (a === d.esc) {
|
|
107
108
|
this.shouldFocusDateInput = !0, this.setShow(!1);
|
|
108
109
|
return;
|
|
109
110
|
}
|
|
110
|
-
s && (
|
|
111
|
+
s && (a === d.up || a === d.down) && (t.preventDefault(), t.stopPropagation(), this.shouldFocusDateInput = a === d.up, this.setShow(a === d.down));
|
|
111
112
|
}, this.dateInputElement = () => this.dateInput && this.dateInput.element || this.element && this.element.querySelector(".k-dateinput > input.k-input-inner"), this.state = {
|
|
112
113
|
value: this.props.defaultValue || o.defaultProps.defaultValue,
|
|
113
114
|
show: this.props.defaultShow || o.defaultProps.defaultShow,
|
|
@@ -169,12 +170,12 @@ const o = class o extends a.Component {
|
|
|
169
170
|
* Represents the validity state into which the DateTimePicker is set.
|
|
170
171
|
*/
|
|
171
172
|
get validity() {
|
|
172
|
-
const i = ue(this.value, this.min, this.max) && ge(this.value, this.props.minTime || ce, this.props.maxTime || pe), t = this.props.validationMessage !== void 0, s = (!this.required || this.value !== null) && i,
|
|
173
|
+
const i = ue(this.value, this.min, this.max) && ge(this.value, this.props.minTime || ce, this.props.maxTime || pe), t = this.props.validationMessage !== void 0, s = (!this.required || this.value !== null) && i, a = this.props.valid !== void 0 ? this.props.valid : s;
|
|
173
174
|
return {
|
|
174
175
|
customError: t,
|
|
175
176
|
rangeOverflow: this.value && this.max.getTime() < this.value.getTime() || !1,
|
|
176
177
|
rangeUnderflow: this.value && this.value.getTime() < this.min.getTime() || !1,
|
|
177
|
-
valid:
|
|
178
|
+
valid: a,
|
|
178
179
|
valueMissing: this.value === null
|
|
179
180
|
};
|
|
180
181
|
}
|
|
@@ -208,7 +209,9 @@ const o = class o extends a.Component {
|
|
|
208
209
|
*/
|
|
209
210
|
componentDidUpdate() {
|
|
210
211
|
const i = this.dateInputElement();
|
|
211
|
-
this._dateTimeSelector && this.show && !this.prevShow && this._dateTimeSelector.focus({ preventScroll: !0 }),
|
|
212
|
+
this._dateTimeSelector && this.show && !this.prevShow && this._dateTimeSelector.focus({ preventScroll: !0 }), this.mobileMode && this.show && !this.prevShow && setTimeout(() => {
|
|
213
|
+
this._dateTimeSelector && this._dateTimeSelector.focus({ preventScroll: !0 });
|
|
214
|
+
}, 300), i && !this.show && this.shouldFocusDateInput && i.focus({ preventScroll: !0 }), this.prevShow = this.show, this.shouldFocusDateInput = !1;
|
|
212
215
|
}
|
|
213
216
|
/**
|
|
214
217
|
* @hidden
|
|
@@ -225,7 +228,7 @@ const o = class o extends a.Component {
|
|
|
225
228
|
size: i = o.defaultProps.size,
|
|
226
229
|
rounded: t = o.defaultProps.rounded,
|
|
227
230
|
fillMode: s = o.defaultProps.fillMode,
|
|
228
|
-
autoFocus:
|
|
231
|
+
autoFocus: a = o.defaultProps.autoFocus,
|
|
229
232
|
inputAttributes: h,
|
|
230
233
|
disabled: l,
|
|
231
234
|
tabIndex: r,
|
|
@@ -242,8 +245,8 @@ const o = class o extends a.Component {
|
|
|
242
245
|
required: z,
|
|
243
246
|
validityStyles: B,
|
|
244
247
|
minTime: N,
|
|
245
|
-
maxTime:
|
|
246
|
-
ariaLabelledBy:
|
|
248
|
+
maxTime: _,
|
|
249
|
+
ariaLabelledBy: V,
|
|
247
250
|
ariaDescribedBy: q,
|
|
248
251
|
popup: L = $,
|
|
249
252
|
unstyled: b,
|
|
@@ -254,9 +257,9 @@ const o = class o extends a.Component {
|
|
|
254
257
|
autoSwitchParts: W,
|
|
255
258
|
autoSwitchKeys: X,
|
|
256
259
|
allowCaretMode: Y
|
|
257
|
-
} = this.props, y = b && b.uDateTimePicker,
|
|
260
|
+
} = this.props, y = b && b.uDateTimePicker, D = !this.validityStyles || this.validity.valid, Z = {
|
|
258
261
|
id: u,
|
|
259
|
-
ariaLabelledBy:
|
|
262
|
+
ariaLabelledBy: V,
|
|
260
263
|
ariaDescribedBy: q,
|
|
261
264
|
format: v,
|
|
262
265
|
formatPlaceholder: w,
|
|
@@ -268,7 +271,7 @@ const o = class o extends a.Component {
|
|
|
268
271
|
min: x,
|
|
269
272
|
max: k,
|
|
270
273
|
minTime: N,
|
|
271
|
-
maxTime:
|
|
274
|
+
maxTime: _,
|
|
272
275
|
name: A,
|
|
273
276
|
tabIndex: this.show ? -1 : r,
|
|
274
277
|
valid: this.validity.valid,
|
|
@@ -289,7 +292,7 @@ const o = class o extends a.Component {
|
|
|
289
292
|
autoSwitchParts: W,
|
|
290
293
|
autoSwitchKeys: X,
|
|
291
294
|
allowCaretMode: Y
|
|
292
|
-
}, T = /* @__PURE__ */
|
|
295
|
+
}, T = /* @__PURE__ */ n.createElement(
|
|
293
296
|
ee,
|
|
294
297
|
{
|
|
295
298
|
onFocus: this.handleFocus,
|
|
@@ -297,56 +300,56 @@ const o = class o extends a.Component {
|
|
|
297
300
|
onSyncFocus: this.props.onFocus,
|
|
298
301
|
onSyncBlur: this.props.onBlur
|
|
299
302
|
},
|
|
300
|
-
({ onFocus: G, onBlur: J }) => /* @__PURE__ */
|
|
303
|
+
({ onFocus: G, onBlur: J }) => /* @__PURE__ */ n.createElement(n.Fragment, null, /* @__PURE__ */ n.createElement(
|
|
301
304
|
"div",
|
|
302
305
|
{
|
|
303
306
|
ref: (Q) => {
|
|
304
307
|
this._element = Q;
|
|
305
308
|
},
|
|
306
|
-
className:
|
|
307
|
-
|
|
309
|
+
className: S(
|
|
310
|
+
I.wrapper({
|
|
308
311
|
c: y,
|
|
309
312
|
size: i,
|
|
310
313
|
fillMode: s,
|
|
311
314
|
rounded: t,
|
|
312
315
|
disabled: l,
|
|
313
316
|
required: this.required,
|
|
314
|
-
invalid: !
|
|
317
|
+
invalid: !D
|
|
315
318
|
}),
|
|
316
319
|
E
|
|
317
320
|
),
|
|
318
321
|
onKeyDown: this.handleKeyDown,
|
|
319
322
|
style: { width: F },
|
|
320
|
-
onFocus: this.mobileMode ?
|
|
323
|
+
onFocus: this.mobileMode ? this.handleClick : G,
|
|
321
324
|
onBlur: J,
|
|
322
|
-
onClick: this.mobileMode ? this.
|
|
325
|
+
onClick: this.mobileMode ? this.handleClick : void 0
|
|
323
326
|
},
|
|
324
|
-
/* @__PURE__ */
|
|
327
|
+
/* @__PURE__ */ n.createElement(
|
|
325
328
|
this.dateInputComp,
|
|
326
329
|
{
|
|
327
330
|
_ref: this._dateInput,
|
|
328
331
|
ariaRole: "combobox",
|
|
329
332
|
ariaControls: this._popupId,
|
|
330
333
|
ariaHasPopup: "dialog",
|
|
331
|
-
autoFocus:
|
|
334
|
+
autoFocus: a,
|
|
332
335
|
inputAttributes: h,
|
|
333
336
|
...Z
|
|
334
337
|
}
|
|
335
338
|
),
|
|
336
|
-
/* @__PURE__ */
|
|
339
|
+
/* @__PURE__ */ n.createElement(
|
|
337
340
|
le,
|
|
338
341
|
{
|
|
339
342
|
tabIndex: -1,
|
|
340
343
|
type: "button",
|
|
341
344
|
icon: "calendar",
|
|
342
|
-
svgIcon:
|
|
345
|
+
svgIcon: ne,
|
|
343
346
|
onMouseDown: this.handleIconMouseDown,
|
|
344
|
-
onClick: this.mobileMode ? void 0 : this.
|
|
347
|
+
onClick: this.mobileMode ? void 0 : this.handleClick,
|
|
345
348
|
title: m(this).toLanguageString(
|
|
346
349
|
c,
|
|
347
350
|
p[c]
|
|
348
351
|
),
|
|
349
|
-
className: I
|
|
352
|
+
className: S(I.inputButton({ c: y })),
|
|
350
353
|
rounded: null,
|
|
351
354
|
fillMode: s,
|
|
352
355
|
"aria-label": m(this).toLanguageString(
|
|
@@ -355,13 +358,13 @@ const o = class o extends a.Component {
|
|
|
355
358
|
)
|
|
356
359
|
}
|
|
357
360
|
),
|
|
358
|
-
/* @__PURE__ */
|
|
361
|
+
/* @__PURE__ */ n.createElement(
|
|
359
362
|
L,
|
|
360
363
|
{
|
|
361
364
|
show: this.show,
|
|
362
365
|
animate: this.element !== null,
|
|
363
366
|
anchor: this.element,
|
|
364
|
-
popupClass: I
|
|
367
|
+
popupClass: S(I.popup({ c: y })),
|
|
365
368
|
id: this._popupId,
|
|
366
369
|
anchorAlign: {
|
|
367
370
|
horizontal: "left",
|
|
@@ -376,13 +379,13 @@ const o = class o extends a.Component {
|
|
|
376
379
|
)
|
|
377
380
|
), this.mobileMode && this.renderAdaptivePopup())
|
|
378
381
|
);
|
|
379
|
-
return this.props.label ? /* @__PURE__ */
|
|
382
|
+
return this.props.label ? /* @__PURE__ */ n.createElement(
|
|
380
383
|
ve,
|
|
381
384
|
{
|
|
382
385
|
dateInput: this._dateInput,
|
|
383
386
|
label: this.props.label,
|
|
384
387
|
editorId: u,
|
|
385
|
-
editorValid:
|
|
388
|
+
editorValid: D,
|
|
386
389
|
editorDisabled: this.props.disabled,
|
|
387
390
|
children: T,
|
|
388
391
|
style: { width: this.props.width }
|
|
@@ -494,18 +497,18 @@ o.displayName = "DateTimePicker", o.propTypes = {
|
|
|
494
497
|
autoFocus: !1
|
|
495
498
|
};
|
|
496
499
|
let f = o;
|
|
497
|
-
const ye = te(),
|
|
500
|
+
const ye = te(), Se = ie(
|
|
498
501
|
se(
|
|
499
502
|
ye,
|
|
500
503
|
oe(
|
|
501
|
-
|
|
504
|
+
ae(f)
|
|
502
505
|
)
|
|
503
506
|
)
|
|
504
507
|
);
|
|
505
|
-
|
|
508
|
+
Se.displayName = "KendoReactDateTimePicker";
|
|
506
509
|
me(f);
|
|
507
510
|
export {
|
|
508
|
-
|
|
511
|
+
Se as DateTimePicker,
|
|
509
512
|
ye as DateTimePickerPropsContext,
|
|
510
513
|
f as DateTimePickerWithoutContext
|
|
511
514
|
};
|
|
@@ -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"),_=require("@progress/kendo-react-intl"),
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("react"),_=require("@progress/kendo-react-intl"),o=require("../messages/index.js"),p=require("@progress/kendo-react-buttons"),N=require("../calendar/components/Calendar.js"),B=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 n=V(E),D=class D extends n.Component{constructor(s){super(s),this._calendar=null,this._timePart=null,this._cancelButton=null,this._acceptButton=null,this._dateButtonRef=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,r=this.localizationService.toLanguageString(o.dateTimePickerCancel,o.messages[o.dateTimePickerCancel]),h=this.localizationService.toLanguageString(o.dateTimePickerSet,o.messages[o.dateTimePickerSet]);return n.createElement("div",{className:a.classNames(a.uDateTimePicker.timeFooter({c:i}))},e&&n.createElement(p.Button,{type:"button",ref:l=>{this._cancelButton=l},className:a.classNames(a.uTime.cancel({c:i})),onClick:this.handleReject,onKeyDown:this.handleCancelKeyDown,title:r,"aria-label":r},r),n.createElement(p.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))},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=this.mergeDate(this.state.dateValue,t||this.state.timeValue);this.props.onChange.call(void 0,{syntheticEvent:e,nativeEvent:e.nativeEvent,value:i,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.handleDateClick=e=>{e.stopPropagation(),this.move("left")},this.handleTimeClick=e=>{e.stopPropagation(),this.move("right")},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=>{const{keyCode:t}=e;t===a.Keys.tab&&this._dateButtonRef&&this._dateButtonRef.element&&!this.hasDateValue&&(e.preventDefault(),this._dateButtonRef.element.focus())},this.handleSetKeyDown=e=>{const{keyCode:t}=e;t===a.Keys.tab&&this._dateButtonRef&&this._dateButtonRef.element&&(e.preventDefault(),this._dateButtonRef.element.focus())},this.handleDateKeyDown=e=>{var r,h,l,g;const{keyCode:t,shiftKey:i}=e;i&&t===a.Keys.tab&&(e.stopPropagation(),this.hasDateValue?(g=(l=this._acceptButton)==null?void 0:l.element)==null||g.focus():(h=(r=this._cancelButton)==null?void 0:r.element)==null||h.focus()),t===a.Keys.enter&&(e.stopPropagation(),this.move("left"))},this.handleTimeKeyDown=e=>{const{keyCode:t}=e;t===a.Keys.enter&&(e.stopPropagation(),this.move("right"))},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 _.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(r=>({dateValue:s.value&&this.props.value&&y.isEqualDate(s.value,this.props.value)?r.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:r,format:h,mobileMode:l,footerActions:g,unstyled:f}=this.props,m=f&&f.uDateTimePicker,k=a.classNames(a.uDateTimePicker.wrap({c:m,date:this.state.tab==="date",time:this.state.tab==="time",disabled:s})),C=this.localizationService.toLanguageString(o.date,o.messages[o.date]),P=this.localizationService.toLanguageString(o.time,o.messages[o.time]),T={min:e,max:t,weekNumber:i,focusedDate:r,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 n.createElement("div",{onKeyDown:this.handleKeyDown,className:k,tabIndex:-1},n.createElement("div",{className:a.classNames(a.uDateTimePicker.buttonGroup({c:m}))},n.createElement(p.ButtonGroup,{width:"100%",unstyled:f},n.createElement(p.Button,{ref:u=>{this._dateButtonRef=u},type:"button",selected:this.state.tab==="date",togglable:!0,size:l?"large":void 0,onClick:this.handleDateClick,onKeyDown:this.handleDateKeyDown},C),n.createElement(p.Button,{type:"button",selected:this.state.tab==="time",togglable:!0,size:l?"large":void 0,onClick:this.handleTimeClick,onKeyDown:this.handleTimeKeyDown},P))),n.createElement("div",{className:a.classNames(a.uDateTimePicker.selector({c:m}))},n.createElement("div",{className:a.classNames(a.uDateTimePicker.calendarWrap({c:m})),ref:u=>{this._calendarWrap=u}},this.props.calendar?n.createElement(this.props.calendar,{key:this.state.tab,...T}):n.createElement(N.Calendar,{key:this.state.tab,ref:u=>{this._calendar=u},...T})),n.createElement("div",{className:a.classNames(a.uDateTimePicker.timeWrap({c:m}))},n.createElement("div",{className:a.classNames(a.uDateTimePicker.timeSelector({c:m,mobileMode:l}))},n.createElement(B.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:f})))),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}};D.defaultProps={footerActions:!0};let v=D;_.registerForLocalization(v);exports.DateTimeSelector=v;
|
|
@@ -9,8 +9,8 @@ import * as i from "react";
|
|
|
9
9
|
import { provideLocalizationService as R, registerForLocalization as M } from "@progress/kendo-react-intl";
|
|
10
10
|
import { dateTimePickerCancel as D, messages as f, dateTimePickerSet as _, date as T, time as E } from "../messages/index.mjs";
|
|
11
11
|
import { Button as g, ButtonGroup as x } from "@progress/kendo-react-buttons";
|
|
12
|
-
import { Calendar as
|
|
13
|
-
import { TimePart as
|
|
12
|
+
import { Calendar as z } from "../calendar/components/Calendar.mjs";
|
|
13
|
+
import { TimePart as A } from "../timepicker/TimePart.mjs";
|
|
14
14
|
import { MIDNIGHT_DATE as v, MIN_TIME as F, MAX_TIME as L, getToday as V, setTime as P } from "../utils.mjs";
|
|
15
15
|
import { isEqualDate as k } from "@progress/kendo-date-math";
|
|
16
16
|
import { classNames as l, uDateTimePicker as u, uTime as B, Keys as h, getActiveElement as I } from "@progress/kendo-react-common";
|
|
@@ -29,28 +29,28 @@ const y = class y extends i.Component {
|
|
|
29
29
|
const e = t === "left" ? "date" : "time";
|
|
30
30
|
this.shouldFocusPart = !0, this.setState({ tab: e });
|
|
31
31
|
}, this.dateTimeFooter = () => {
|
|
32
|
-
const { cancelButton: t, unstyled: e } = this.props, s = e && e.uDateTimePicker,
|
|
32
|
+
const { cancelButton: t, unstyled: e } = this.props, s = e && e.uDateTimePicker, o = this.localizationService.toLanguageString(D, f[D]), r = this.localizationService.toLanguageString(_, f[_]);
|
|
33
33
|
return /* @__PURE__ */ i.createElement("div", { className: l(u.timeFooter({ c: s })) }, t && /* @__PURE__ */ i.createElement(
|
|
34
34
|
g,
|
|
35
35
|
{
|
|
36
36
|
type: "button",
|
|
37
|
-
ref: (
|
|
38
|
-
this._cancelButton =
|
|
37
|
+
ref: (n) => {
|
|
38
|
+
this._cancelButton = n;
|
|
39
39
|
},
|
|
40
40
|
className: l(B.cancel({ c: s })),
|
|
41
41
|
onClick: this.handleReject,
|
|
42
42
|
onKeyDown: this.handleCancelKeyDown,
|
|
43
|
-
title:
|
|
44
|
-
"aria-label":
|
|
43
|
+
title: o,
|
|
44
|
+
"aria-label": o
|
|
45
45
|
},
|
|
46
|
-
|
|
46
|
+
o
|
|
47
47
|
), /* @__PURE__ */ i.createElement(
|
|
48
48
|
g,
|
|
49
49
|
{
|
|
50
50
|
type: "button",
|
|
51
51
|
themeColor: "primary",
|
|
52
|
-
ref: (
|
|
53
|
-
this._acceptButton =
|
|
52
|
+
ref: (n) => {
|
|
53
|
+
this._acceptButton = n;
|
|
54
54
|
},
|
|
55
55
|
className: l(B.accept({ c: s })),
|
|
56
56
|
disabled: !this.hasDateValue,
|
|
@@ -120,9 +120,9 @@ const y = class y extends i.Component {
|
|
|
120
120
|
const { keyCode: e } = t;
|
|
121
121
|
e === h.tab && this._dateButtonRef && this._dateButtonRef.element && (t.preventDefault(), this._dateButtonRef.element.focus());
|
|
122
122
|
}, this.handleDateKeyDown = (t) => {
|
|
123
|
-
var
|
|
123
|
+
var o, r, n, d;
|
|
124
124
|
const { keyCode: e, shiftKey: s } = t;
|
|
125
|
-
s && e === h.tab && (t.stopPropagation(), this.hasDateValue ? (d = (
|
|
125
|
+
s && e === h.tab && (t.stopPropagation(), this.hasDateValue ? (d = (n = this._acceptButton) == null ? void 0 : n.element) == null || d.focus() : (r = (o = this._cancelButton) == null ? void 0 : o.element) == null || r.focus()), e === h.enter && (t.stopPropagation(), this.move("left"));
|
|
126
126
|
}, this.handleTimeKeyDown = (t) => {
|
|
127
127
|
const { keyCode: e } = t;
|
|
128
128
|
e === h.enter && (t.stopPropagation(), this.move("right"));
|
|
@@ -148,13 +148,13 @@ const y = class y extends i.Component {
|
|
|
148
148
|
}
|
|
149
149
|
componentDidUpdate(a, t) {
|
|
150
150
|
var e, s;
|
|
151
|
-
this.shouldFocusPart && this.focus({ preventScroll: !0 }), (((e = a.value) == null ? void 0 : e.getTime()) !== ((s = this.props.value) == null ? void 0 : s.getTime()) || this.state.tab !== t.tab && this.props.value) && this.setState((
|
|
152
|
-
dateValue: a.value && this.props.value && k(a.value, this.props.value) ?
|
|
151
|
+
this.shouldFocusPart && this.focus({ preventScroll: !0 }), (((e = a.value) == null ? void 0 : e.getTime()) !== ((s = this.props.value) == null ? void 0 : s.getTime()) || this.state.tab !== t.tab && this.props.value) && this.setState((o) => ({
|
|
152
|
+
dateValue: a.value && this.props.value && k(a.value, this.props.value) ? o.dateValue : this.props.value,
|
|
153
153
|
timeValue: this.props.value || v
|
|
154
154
|
})), this.shouldFocusPart = !1;
|
|
155
155
|
}
|
|
156
156
|
render() {
|
|
157
|
-
const { disabled: a, min: t, max: e, weekNumber: s, focusedDate:
|
|
157
|
+
const { disabled: a, min: t, max: e, weekNumber: s, focusedDate: o, format: r, mobileMode: n, footerActions: d, unstyled: p } = this.props, m = p && p.uDateTimePicker, S = l(
|
|
158
158
|
u.wrap({
|
|
159
159
|
c: m,
|
|
160
160
|
date: this.state.tab === "date",
|
|
@@ -165,13 +165,13 @@ const y = class y extends i.Component {
|
|
|
165
165
|
min: t,
|
|
166
166
|
max: e,
|
|
167
167
|
weekNumber: s,
|
|
168
|
-
focusedDate:
|
|
168
|
+
focusedDate: o,
|
|
169
169
|
disabled: a || this.state.tab !== "date",
|
|
170
170
|
value: this.state.dateValue,
|
|
171
171
|
onChange: this.handleCalendarValueChange,
|
|
172
172
|
navigation: !1,
|
|
173
173
|
tabIndex: a || this.state.tab !== "date" ? -1 : void 0,
|
|
174
|
-
mobileMode:
|
|
174
|
+
mobileMode: n
|
|
175
175
|
};
|
|
176
176
|
return /* @__PURE__ */ i.createElement("div", { onKeyDown: this.handleKeyDown, className: S, tabIndex: -1 }, /* @__PURE__ */ i.createElement("div", { className: l(u.buttonGroup({ c: m })) }, /* @__PURE__ */ i.createElement(x, { width: "100%", unstyled: p }, /* @__PURE__ */ i.createElement(
|
|
177
177
|
g,
|
|
@@ -182,6 +182,7 @@ const y = class y extends i.Component {
|
|
|
182
182
|
type: "button",
|
|
183
183
|
selected: this.state.tab === "date",
|
|
184
184
|
togglable: !0,
|
|
185
|
+
size: n ? "large" : void 0,
|
|
185
186
|
onClick: this.handleDateClick,
|
|
186
187
|
onKeyDown: this.handleDateKeyDown
|
|
187
188
|
},
|
|
@@ -192,6 +193,7 @@ const y = class y extends i.Component {
|
|
|
192
193
|
type: "button",
|
|
193
194
|
selected: this.state.tab === "time",
|
|
194
195
|
togglable: !0,
|
|
196
|
+
size: n ? "large" : void 0,
|
|
195
197
|
onClick: this.handleTimeClick,
|
|
196
198
|
onKeyDown: this.handleTimeKeyDown
|
|
197
199
|
},
|
|
@@ -205,7 +207,7 @@ const y = class y extends i.Component {
|
|
|
205
207
|
}
|
|
206
208
|
},
|
|
207
209
|
this.props.calendar ? /* @__PURE__ */ i.createElement(this.props.calendar, { key: this.state.tab, ...C }) : /* @__PURE__ */ i.createElement(
|
|
208
|
-
|
|
210
|
+
z,
|
|
209
211
|
{
|
|
210
212
|
key: this.state.tab,
|
|
211
213
|
ref: (c) => {
|
|
@@ -214,8 +216,8 @@ const y = class y extends i.Component {
|
|
|
214
216
|
...C
|
|
215
217
|
}
|
|
216
218
|
)
|
|
217
|
-
), /* @__PURE__ */ i.createElement("div", { className: l(u.timeWrap({ c: m })) }, /* @__PURE__ */ i.createElement("div", { className: l(u.timeSelector({ c: m, mobileMode:
|
|
218
|
-
|
|
219
|
+
), /* @__PURE__ */ i.createElement("div", { className: l(u.timeWrap({ c: m })) }, /* @__PURE__ */ i.createElement("div", { className: l(u.timeSelector({ c: m, mobileMode: n })) }, /* @__PURE__ */ i.createElement(
|
|
220
|
+
A,
|
|
219
221
|
{
|
|
220
222
|
key: 1,
|
|
221
223
|
onNowClick: this.handleNowClick,
|
|
@@ -230,7 +232,7 @@ const y = class y extends i.Component {
|
|
|
230
232
|
format: r,
|
|
231
233
|
onChange: this.handleTimeListContainerChange,
|
|
232
234
|
onMount: this.handleTimePartMount,
|
|
233
|
-
mobileMode:
|
|
235
|
+
mobileMode: n,
|
|
234
236
|
unstyled: p
|
|
235
237
|
}
|
|
236
238
|
)))), d && this.dateTimeFooter());
|