@progress/kendo-react-dateinputs 9.0.0-develop.8 → 9.0.0
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/dateinput/DateInput.js +1 -1
- package/dateinput/DateInput.mjs +107 -93
- package/datepicker/DatePicker.js +1 -1
- package/datepicker/DatePicker.mjs +97 -83
- package/datetimepicker/DateTimePicker.js +1 -1
- package/datetimepicker/DateTimePicker.mjs +82 -68
- package/dist/cdn/js/kendo-react-dateinputs.js +1 -1
- package/index.d.mts +111 -10
- package/index.d.ts +111 -10
- package/package-metadata.mjs +1 -1
- package/package.json +9 -9
- package/timepicker/TimePicker.js +1 -1
- package/timepicker/TimePicker.mjs +78 -68
|
@@ -8,22 +8,22 @@
|
|
|
8
8
|
"use client";
|
|
9
9
|
import * as n from "react";
|
|
10
10
|
import e from "prop-types";
|
|
11
|
-
import { Popup as
|
|
12
|
-
import { getDate as
|
|
13
|
-
import { classNames as k, Keys as r, validatePackage as
|
|
14
|
-
import { calendarIcon as
|
|
15
|
-
import { packageMetadata as
|
|
16
|
-
import { DateInput as
|
|
17
|
-
import { Calendar as
|
|
18
|
-
import { MAX_DATE as
|
|
19
|
-
import { toggleCalendar as
|
|
20
|
-
import { provideLocalizationService as
|
|
21
|
-
import { ToggleButton as
|
|
22
|
-
import { PickerWrap as
|
|
23
|
-
import { PickerFloatingLabel as
|
|
24
|
-
import { ActionSheetContent as
|
|
25
|
-
import { AdaptiveMode as
|
|
26
|
-
import { MOBILE_MEDIUM_DEVISE as
|
|
11
|
+
import { Popup as Y } from "@progress/kendo-react-popup";
|
|
12
|
+
import { getDate as Z, cloneDate as O } from "@progress/kendo-date-math";
|
|
13
|
+
import { classNames as k, Keys as r, validatePackage as j, canUseDOM as P, AsyncFocusBlur as G, kendoThemeMaps as T, createPropsContext as J, withIdHOC as Q, withPropsContext as ee } from "@progress/kendo-react-common";
|
|
14
|
+
import { calendarIcon as te } from "@progress/kendo-svg-icons";
|
|
15
|
+
import { packageMetadata as ie } from "../package-metadata.mjs";
|
|
16
|
+
import { DateInput as se } from "../dateinput/DateInput.mjs";
|
|
17
|
+
import { Calendar as oe } from "../calendar/components/Calendar.mjs";
|
|
18
|
+
import { MAX_DATE as ae, MIN_DATE as ne, isInDateRange as re, setTime as le } from "../utils.mjs";
|
|
19
|
+
import { toggleCalendar as x, messages as de } from "../messages/index.mjs";
|
|
20
|
+
import { provideLocalizationService as ue, registerForLocalization as he } from "@progress/kendo-react-intl";
|
|
21
|
+
import { ToggleButton as pe } from "./ToggleButton.mjs";
|
|
22
|
+
import { PickerWrap as ce } from "../common/PickerWrap.mjs";
|
|
23
|
+
import { PickerFloatingLabel as me } from "../hooks/usePickerFloatingLabel.mjs";
|
|
24
|
+
import { ActionSheetContent as fe } from "@progress/kendo-react-layout";
|
|
25
|
+
import { AdaptiveMode as ge } from "../common/AdaptiveMode.mjs";
|
|
26
|
+
import { MOBILE_MEDIUM_DEVISE as ve } from "../common/constants.mjs";
|
|
27
27
|
const o = class o extends n.Component {
|
|
28
28
|
constructor(i) {
|
|
29
29
|
super(i), this._element = null, this._dateInput = n.createRef(), this._calendar = null, this.shouldFocusDateInput = !1, this.prevShow = !1, this.focus = () => {
|
|
@@ -31,7 +31,7 @@ const o = class o extends n.Component {
|
|
|
31
31
|
}, this.setCalendarRef = (t) => {
|
|
32
32
|
this._calendar = t;
|
|
33
33
|
}, this.nextValue = (t, s) => t.value !== void 0 ? t.value : s.value, this.nextShow = (t, s) => t.show !== void 0 ? t.show : s.show, this.renderPopup = () => {
|
|
34
|
-
const { disabled: t, min: s, max: a, weekNumber: c, focusedDate: m, popupSettings: l } = this.props, { popupClass: f, ...g } = l, v = this.show, d = this.value, w = d &&
|
|
34
|
+
const { disabled: t, min: s, max: a, weekNumber: c, focusedDate: m, popupSettings: l } = this.props, { popupClass: f, ...g } = l, v = this.show, d = this.value, w = d && Z(d), u = k(f), b = {
|
|
35
35
|
popupClass: "k-datepicker-popup",
|
|
36
36
|
show: v,
|
|
37
37
|
anchor: this._element,
|
|
@@ -66,7 +66,7 @@ const o = class o extends n.Component {
|
|
|
66
66
|
adaptiveTitle: this.props.adaptiveTitle,
|
|
67
67
|
windowWidth: t
|
|
68
68
|
};
|
|
69
|
-
return /* @__PURE__ */ n.createElement(
|
|
69
|
+
return /* @__PURE__ */ n.createElement(ge, { ...s }, /* @__PURE__ */ n.createElement(fe, { overflowHidden: !0 }, this.renderPopup()));
|
|
70
70
|
}, this.handleInputValueChange = (t) => {
|
|
71
71
|
this.handleValueChange(t.value, t);
|
|
72
72
|
}, this.handleCalendarValueChange = (t) => {
|
|
@@ -74,7 +74,7 @@ const o = class o extends n.Component {
|
|
|
74
74
|
this.handleValueChange(s, t);
|
|
75
75
|
}, this.handleValueChange = (t, s) => {
|
|
76
76
|
this.setState({
|
|
77
|
-
value:
|
|
77
|
+
value: O(t || void 0)
|
|
78
78
|
}), this.valueDuringOnChange = t, this.showDuringOnChange = !1, this.mobileMode || (this.shouldFocusDateInput = !0);
|
|
79
79
|
const { onChange: a } = this.props;
|
|
80
80
|
a && a.call(void 0, {
|
|
@@ -104,7 +104,7 @@ const o = class o extends n.Component {
|
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
106
|
s && (a === r.up || a === r.down) && (t.preventDefault(), t.stopPropagation(), this.shouldFocusDateInput = a === r.up, this.setShow(a === r.down));
|
|
107
|
-
},
|
|
107
|
+
}, j(ie), this.state = {
|
|
108
108
|
value: this.props.defaultValue || o.defaultProps.defaultValue,
|
|
109
109
|
show: this.props.defaultShow || o.defaultProps.defaultShow,
|
|
110
110
|
focused: !1
|
|
@@ -127,7 +127,7 @@ const o = class o extends n.Component {
|
|
|
127
127
|
* The mobile mode of the DatePicker.
|
|
128
128
|
*/
|
|
129
129
|
get mobileMode() {
|
|
130
|
-
return !!(this.state.windowWidth && this.state.windowWidth <=
|
|
130
|
+
return !!(this.state.windowWidth && this.state.windowWidth <= ve && this.props.adaptive);
|
|
131
131
|
}
|
|
132
132
|
/**
|
|
133
133
|
* Gets the DateInput component inside the DatePicker component.
|
|
@@ -146,7 +146,7 @@ const o = class o extends n.Component {
|
|
|
146
146
|
*/
|
|
147
147
|
get value() {
|
|
148
148
|
const i = this.valueDuringOnChange !== void 0 ? this.valueDuringOnChange : this.props.value !== void 0 ? this.props.value : this.state.value;
|
|
149
|
-
return i !== null ?
|
|
149
|
+
return i !== null ? O(i) : null;
|
|
150
150
|
}
|
|
151
151
|
/**
|
|
152
152
|
* Gets the popup state of the DatePickerWithoutContext.
|
|
@@ -185,7 +185,7 @@ const o = class o extends n.Component {
|
|
|
185
185
|
* Represents the validity state into which the DatePicker is set.
|
|
186
186
|
*/
|
|
187
187
|
get validity() {
|
|
188
|
-
const i =
|
|
188
|
+
const i = re(this.value, this.min, this.max), t = this.props.validationMessage !== void 0, s = (!this.required || this.value !== null) && i, a = this.props.valid !== void 0 ? this.props.valid : s;
|
|
189
189
|
return {
|
|
190
190
|
customError: t,
|
|
191
191
|
rangeOverflow: this.value && this.max.getTime() < this.value.getTime() || !1,
|
|
@@ -246,38 +246,45 @@ const o = class o extends n.Component {
|
|
|
246
246
|
width: u,
|
|
247
247
|
name: b,
|
|
248
248
|
validationMessage: h,
|
|
249
|
-
required:
|
|
249
|
+
required: E,
|
|
250
250
|
validityStyles: B,
|
|
251
251
|
ariaLabelledBy: F,
|
|
252
252
|
ariaDescribedBy: V,
|
|
253
253
|
ariaLabel: z,
|
|
254
254
|
placeholder: N,
|
|
255
255
|
label: y,
|
|
256
|
-
popupSettings:
|
|
257
|
-
defaultValue:
|
|
258
|
-
defaultShow:
|
|
259
|
-
value:
|
|
260
|
-
popup:
|
|
261
|
-
weekNumber:
|
|
262
|
-
dateInput:
|
|
263
|
-
calendar:
|
|
264
|
-
toggleButton:
|
|
265
|
-
onChange:
|
|
266
|
-
onBlur:
|
|
267
|
-
onFocus:
|
|
268
|
-
show:
|
|
269
|
-
onOpen:
|
|
270
|
-
pickerWrap:
|
|
271
|
-
adaptive:
|
|
272
|
-
adaptiveTitle:
|
|
273
|
-
valid:
|
|
256
|
+
popupSettings: ye,
|
|
257
|
+
defaultValue: Ce,
|
|
258
|
+
defaultShow: Ie,
|
|
259
|
+
value: De,
|
|
260
|
+
popup: Se,
|
|
261
|
+
weekNumber: Me,
|
|
262
|
+
dateInput: Oe,
|
|
263
|
+
calendar: ke,
|
|
264
|
+
toggleButton: Pe,
|
|
265
|
+
onChange: Te,
|
|
266
|
+
onBlur: xe,
|
|
267
|
+
onFocus: Ee,
|
|
268
|
+
show: Be,
|
|
269
|
+
onOpen: Fe,
|
|
270
|
+
pickerWrap: Ve,
|
|
271
|
+
adaptive: ze,
|
|
272
|
+
adaptiveTitle: Ne,
|
|
273
|
+
valid: Re,
|
|
274
274
|
autoFocus: R,
|
|
275
275
|
// Removed to support direct use in Form Field component
|
|
276
|
-
visited:
|
|
277
|
-
touched:
|
|
278
|
-
modified:
|
|
279
|
-
|
|
280
|
-
|
|
276
|
+
visited: Ae,
|
|
277
|
+
touched: Le,
|
|
278
|
+
modified: We,
|
|
279
|
+
autoFill: A,
|
|
280
|
+
twoDigitYearMax: L,
|
|
281
|
+
enableMouseWheel: W,
|
|
282
|
+
autoCorrectParts: q,
|
|
283
|
+
autoSwitchParts: _,
|
|
284
|
+
autoSwitchKeys: K,
|
|
285
|
+
allowCaretMode: U,
|
|
286
|
+
...C
|
|
287
|
+
} = this.props, $ = this.value, I = !this.validityStyles || this.validity.valid, H = {
|
|
281
288
|
disabled: a,
|
|
282
289
|
format: f,
|
|
283
290
|
formatPlaceholder: g,
|
|
@@ -289,36 +296,43 @@ const o = class o extends n.Component {
|
|
|
289
296
|
min: v,
|
|
290
297
|
name: b,
|
|
291
298
|
onChange: this.handleInputValueChange,
|
|
292
|
-
required:
|
|
299
|
+
required: E,
|
|
293
300
|
tabIndex: this.show ? -1 : c,
|
|
294
301
|
title: m,
|
|
295
302
|
valid: this.validity.valid,
|
|
296
303
|
validationMessage: h,
|
|
297
304
|
validityStyles: B,
|
|
298
|
-
value:
|
|
305
|
+
value: $,
|
|
299
306
|
label: void 0,
|
|
300
307
|
placeholder: this.state.focused ? null : N,
|
|
301
308
|
ariaExpanded: this.show,
|
|
302
309
|
size: null,
|
|
303
310
|
fillMode: null,
|
|
304
|
-
rounded: null
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
311
|
+
rounded: null,
|
|
312
|
+
autoFill: A,
|
|
313
|
+
twoDigitYearMax: L,
|
|
314
|
+
enableMouseWheel: W,
|
|
315
|
+
autoCorrectParts: q,
|
|
316
|
+
autoSwitchParts: _,
|
|
317
|
+
autoSwitchKeys: K,
|
|
318
|
+
allowCaretMode: U
|
|
319
|
+
}, D = ue(this).toLanguageString(
|
|
320
|
+
x,
|
|
321
|
+
de[x]
|
|
322
|
+
), S = /* @__PURE__ */ n.createElement(
|
|
323
|
+
G,
|
|
310
324
|
{
|
|
311
325
|
onFocus: this.handleFocus,
|
|
312
326
|
onBlur: this.mobileMode ? void 0 : this.handleBlur,
|
|
313
327
|
onSyncBlur: this.props.onBlur,
|
|
314
328
|
onSyncFocus: this.props.onFocus
|
|
315
329
|
},
|
|
316
|
-
(
|
|
330
|
+
(M) => /* @__PURE__ */ n.createElement(n.Fragment, null, /* @__PURE__ */ n.createElement(
|
|
317
331
|
"span",
|
|
318
332
|
{
|
|
319
|
-
...y ? {} :
|
|
320
|
-
ref: (
|
|
321
|
-
this._element =
|
|
333
|
+
...y ? {} : C,
|
|
334
|
+
ref: (X) => {
|
|
335
|
+
this._element = X;
|
|
322
336
|
},
|
|
323
337
|
className: k(
|
|
324
338
|
"k-input",
|
|
@@ -327,7 +341,7 @@ const o = class o extends n.Component {
|
|
|
327
341
|
[`k-input-${T.sizeMap[i] || i}`]: i,
|
|
328
342
|
[`k-rounded-${T.roundedMap[t] || t}`]: t,
|
|
329
343
|
[`k-input-${s}`]: s,
|
|
330
|
-
"k-invalid": !
|
|
344
|
+
"k-invalid": !I,
|
|
331
345
|
"k-required": this.required,
|
|
332
346
|
"k-disabled": a
|
|
333
347
|
},
|
|
@@ -335,8 +349,8 @@ const o = class o extends n.Component {
|
|
|
335
349
|
),
|
|
336
350
|
onKeyDown: this.handleKeyDown,
|
|
337
351
|
style: { width: u },
|
|
338
|
-
onFocus:
|
|
339
|
-
onBlur:
|
|
352
|
+
onFocus: M.onFocus,
|
|
353
|
+
onBlur: M.onBlur,
|
|
340
354
|
onClick: this.mobileMode ? this.handleIconClick : void 0
|
|
341
355
|
},
|
|
342
356
|
/* @__PURE__ */ n.createElement(
|
|
@@ -348,7 +362,7 @@ const o = class o extends n.Component {
|
|
|
348
362
|
ariaExpanded: this.show,
|
|
349
363
|
ariaControls: this._popupId,
|
|
350
364
|
autoFocus: R,
|
|
351
|
-
...
|
|
365
|
+
...H
|
|
352
366
|
}
|
|
353
367
|
),
|
|
354
368
|
/* @__PURE__ */ n.createElement(
|
|
@@ -356,7 +370,7 @@ const o = class o extends n.Component {
|
|
|
356
370
|
{
|
|
357
371
|
type: "button",
|
|
358
372
|
icon: "calendar",
|
|
359
|
-
svgIcon:
|
|
373
|
+
svgIcon: te,
|
|
360
374
|
title: D,
|
|
361
375
|
className: "k-input-button",
|
|
362
376
|
rounded: null,
|
|
@@ -370,18 +384,18 @@ const o = class o extends n.Component {
|
|
|
370
384
|
), this.mobileMode && this.renderAdaptivePopup())
|
|
371
385
|
);
|
|
372
386
|
return y ? /* @__PURE__ */ n.createElement(
|
|
373
|
-
|
|
387
|
+
me,
|
|
374
388
|
{
|
|
375
389
|
dateInput: this._dateInput,
|
|
376
390
|
label: y,
|
|
377
391
|
editorId: l,
|
|
378
|
-
editorValid:
|
|
392
|
+
editorValid: I,
|
|
379
393
|
editorDisabled: a,
|
|
380
|
-
children:
|
|
394
|
+
children: S,
|
|
381
395
|
style: { width: u },
|
|
382
|
-
...
|
|
396
|
+
...C
|
|
383
397
|
}
|
|
384
|
-
) :
|
|
398
|
+
) : S;
|
|
385
399
|
}
|
|
386
400
|
setShow(i) {
|
|
387
401
|
const { onOpen: t, onClose: s } = this.props;
|
|
@@ -392,7 +406,7 @@ const o = class o extends n.Component {
|
|
|
392
406
|
}));
|
|
393
407
|
}
|
|
394
408
|
mergeTime(i) {
|
|
395
|
-
return this.value && i ?
|
|
409
|
+
return this.value && i ? le(i, this.value) : i;
|
|
396
410
|
}
|
|
397
411
|
nextTick(i) {
|
|
398
412
|
clearTimeout(this.nextTickId), this.nextTickId = window.setTimeout(() => i());
|
|
@@ -475,15 +489,15 @@ o.displayName = "DatePicker", o.propTypes = {
|
|
|
475
489
|
}, o.defaultProps = {
|
|
476
490
|
defaultShow: !1,
|
|
477
491
|
defaultValue: null,
|
|
478
|
-
dateInput:
|
|
479
|
-
calendar:
|
|
480
|
-
toggleButton:
|
|
481
|
-
popup:
|
|
482
|
-
pickerWrap:
|
|
492
|
+
dateInput: se,
|
|
493
|
+
calendar: oe,
|
|
494
|
+
toggleButton: pe,
|
|
495
|
+
popup: Y,
|
|
496
|
+
pickerWrap: ce,
|
|
483
497
|
disabled: !1,
|
|
484
498
|
format: "d",
|
|
485
|
-
max:
|
|
486
|
-
min:
|
|
499
|
+
max: ae,
|
|
500
|
+
min: ne,
|
|
487
501
|
popupSettings: {},
|
|
488
502
|
tabIndex: 0,
|
|
489
503
|
weekNumber: !1,
|
|
@@ -494,13 +508,13 @@ o.displayName = "DatePicker", o.propTypes = {
|
|
|
494
508
|
autoFocus: !1
|
|
495
509
|
};
|
|
496
510
|
let p = o;
|
|
497
|
-
const
|
|
498
|
-
|
|
511
|
+
const we = J(), be = Q(
|
|
512
|
+
ee(we, p)
|
|
499
513
|
);
|
|
500
|
-
|
|
501
|
-
|
|
514
|
+
be.displayName = "KendoReactDatePicker";
|
|
515
|
+
he(p);
|
|
502
516
|
export {
|
|
503
|
-
|
|
504
|
-
|
|
517
|
+
be as DatePicker,
|
|
518
|
+
we as DatePickerPropsContext,
|
|
505
519
|
p as DatePickerWithoutContext
|
|
506
520
|
};
|
|
@@ -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 client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("react"),e=require("prop-types"),U=require("@progress/kendo-react-popup"),T=require("@progress/kendo-date-math"),o=require("@progress/kendo-react-common"),H=require("@progress/kendo-svg-icons"),W=require("../dateinput/DateInput.js"),X=require("@progress/kendo-react-buttons"),Z=require("../package-metadata.js"),p=require("../utils.js"),$=require("../common/constants.js"),l=require("../messages/index.js"),m=require("@progress/kendo-react-intl"),G=require("./DateTimeSelector.js"),J=require("../timepicker/utils.js"),Q=require("../hooks/usePickerFloatingLabel.js"),Y=require("../common/AdaptiveMode.js"),ee=require("@progress/kendo-react-layout");function te(c){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const i in c)if(i!=="default"){const s=Object.getOwnPropertyDescriptor(c,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:()=>c[i]})}}return t.default=c,Object.freeze(t)}const r=te(j),n=class n extends r.Component{constructor(t){super(t),this._element=null,this._dateInput=r.createRef(),this._dateTimeSelector=null,this.shouldFocusDateInput=!1,this.prevShow=!1,this.focus=()=>{const i=this.dateInputElement();i&&i.focus()},this.renderPicker=()=>{const{disabled:i,minTime:s,maxTime:a,format:h,calendar:d,cancelButton:u,weekNumber:f,focusedDate:v,unstyled:w}=this.props;return r.createElement(G.DateTimeSelector,{ref:b=>{this._dateTimeSelector=b},cancelButton:u,steps:this.props.steps,value:this.value,onChange:this.handleValueChange,onReject:this.handleReject,disabled:i,weekNumber:f,min:this.min,max:this.max,minTime:s,maxTime:a,focusedDate:v,format:h,calendar:d,mobileMode:this.mobileMode,footerActions:!this.mobileMode,unstyled:w})},this.renderAdaptivePopup=()=>{const{windowWidth:i=0}=this.state,s=m.provideLocalizationService(this).toLanguageString(l.dateTimePickerCancel,l.messages[l.dateTimePickerCancel]),a=m.provideLocalizationService(this).toLanguageString(l.dateTimePickerSet,l.messages[l.dateTimePickerSet]),h={expand:this.show,onClose:this.handleBlur,adaptiveTitle:this.props.adaptiveTitle,windowWidth:i,footer:{cancelText:s,onCancel:d=>{var u;return(u=this._dateTimeSelector)==null?void 0:u.handleReject(d)},applyText:a,onApply:d=>{var u;return(u=this._dateTimeSelector)==null?void 0:u.handleAccept(d)}}};return r.createElement(Y.AdaptiveMode,{...h},r.createElement(ee.ActionSheetContent,{overflowHidden:!0},this.renderPicker()))},this.handleReject=()=>{this.shouldFocusDateInput=!0,this.setShow(!1)},this.handleValueChange=i=>{this.setState({value:T.cloneDate(i.value||void 0)}),this.valueDuringOnChange=i.value,this.showDuringOnChange=!1,this.mobileMode||(this.shouldFocusDateInput=!0);const{onChange:s}=this.props;s&&s.call(void 0,{syntheticEvent:i.syntheticEvent,nativeEvent:i.nativeEvent,value:this.value,show:this.show,target:this}),this.valueDuringOnChange=void 0,this.showDuringOnChange=void 0,this.setShow(!1)},this.handleFocus=()=>{this.setState({focused:!0})},this.handleBlur=()=>{this.setState({focused:!1}),this.setShow(!1)},this.handleDateIconClick=()=>{this.props.disabled||(this.shouldFocusDateInput=!0,this.setShow(!this.show))},this.handleIconMouseDown=i=>{i.preventDefault()},this.handleKeyDown=i=>{const{altKey:s,keyCode:a}=i;if(a===o.Keys.esc){this.shouldFocusDateInput=!0,this.setShow(!1);return}s&&(a===o.Keys.up||a===o.Keys.down)&&(i.preventDefault(),i.stopPropagation(),this.shouldFocusDateInput=a===o.Keys.up,this.setShow(a===o.Keys.down))},this.dateInputElement=()=>this.dateInput&&this.dateInput.element||this.element&&this.element.querySelector(".k-dateinput > input.k-input-inner"),o.validatePackage(Z.packageMetadata),this.state={value:this.props.defaultValue||n.defaultProps.defaultValue,show:this.props.defaultShow||n.defaultProps.defaultShow,focused:!1}}get _popupId(){return this.props.id+"-popup-id"}get document(){if(o.canUseDOM)return this.element&&this.element.ownerDocument||document}get element(){return this._element}get dateInput(){return this._dateInput.current}get value(){const t=this.valueDuringOnChange!==void 0?this.valueDuringOnChange:this.props.value!==void 0?this.props.value:this.state.value;return t!==null?T.cloneDate(t):null}get show(){return this.showDuringOnChange!==void 0?this.showDuringOnChange:this.props.show!==void 0?this.props.show:this.state.show}get name(){return this.props.name}get mobileMode(){return!!(this.state.windowWidth&&this.state.windowWidth<=$.MOBILE_MEDIUM_DEVISE&&this.props.adaptive)}get min(){return this.props.min!==void 0?this.props.min:n.defaultProps.min}get max(){return this.props.max!==void 0?this.props.max:n.defaultProps.max}get validity(){const t=p.isInDateRange(this.value,this.min,this.max)&&J.isInTimeRange(this.value,this.props.minTime||p.MIN_TIME,this.props.maxTime||p.MAX_TIME),i=this.props.validationMessage!==void 0,s=(!this.required||this.value!==null)&&t,a=this.props.valid!==void 0?this.props.valid:s;return{customError:i,rangeOverflow:this.value&&this.max.getTime()<this.value.getTime()||!1,rangeUnderflow:this.value&&this.value.getTime()<this.min.getTime()||!1,valid:a,valueMissing:this.value===null}}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:n.defaultProps.validityStyles}get required(){return this.props.required!==void 0?this.props.required:!1}get dateInputComp(){return this.props.dateInput||n.defaultProps.dateInput}componentDidMount(){var t;this.observerResize=o.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.show&&this.forceUpdate(),(t=this.document)!=null&&t.body&&this.observerResize&&this.observerResize.observe(this.document.body)}componentDidUpdate(){const t=this.dateInputElement();this._dateTimeSelector&&this.show&&!this.prevShow&&this._dateTimeSelector.focus({preventScroll:!0}),t&&!this.show&&this.shouldFocusDateInput&&t.focus({preventScroll:!0}),this.prevShow=this.show,this.shouldFocusDateInput=!1}componentWillUnmount(){var t;clearTimeout(this.nextTickId),(t=this.document)!=null&&t.body&&this.observerResize&&this.observerResize.disconnect()}render(){const{size:t=n.defaultProps.size,rounded:i=n.defaultProps.rounded,fillMode:s=n.defaultProps.fillMode,autoFocus:a=n.defaultProps.autoFocus,disabled:h,tabIndex:d,title:u,id:f,format:v,formatPlaceholder:w,min:b,max:k,className:M,width:C,name:x,validationMessage:E,required:q,validityStyles:R,minTime:F,maxTime:z,ariaLabelledBy:B,ariaDescribedBy:A,popup:N=U.Popup,unstyled:y}=this.props,D=y&&y.uDateTimePicker,S=!this.validityStyles||this.validity.valid,L={id:f,ariaLabelledBy:B,ariaDescribedBy:A,format:v,formatPlaceholder:w,disabled:h,title:u,validityStyles:R,validationMessage:E,required:q,min:b,max:k,minTime:F,maxTime:z,name:x,tabIndex:this.show?-1:d,valid:this.validity.valid,value:this.value,onChange:this.handleValueChange,steps:this.props.steps,label:void 0,placeholder:this.state.focused?null:this.props.placeholder,ariaExpanded:this.show,size:null,fillMode:null,rounded:null,unstyled:y},I=r.createElement(o.AsyncFocusBlur,{onFocus:this.handleFocus,onBlur:this.handleBlur,onSyncFocus:this.props.onFocus,onSyncBlur:this.props.onBlur},({onFocus:_,onBlur:V})=>r.createElement(r.Fragment,null,r.createElement("div",{ref:K=>{this._element=K},className:o.classNames(o.uDateTimePicker.wrapper({c:D,size:t,fillMode:s,rounded:i,disabled:h,required:this.required,invalid:!S}),M),onKeyDown:this.handleKeyDown,style:{width:C},onFocus:this.mobileMode?void 0:_,onBlur:V,onClick:this.mobileMode?this.handleDateIconClick:void 0},r.createElement(this.dateInputComp,{_ref:this._dateInput,ariaRole:"combobox",ariaControls:this._popupId,ariaHasPopup:"dialog",readonly:this.mobileMode,autoFocus:a,...L}),r.createElement(X.Button,{tabIndex:-1,type:"button",icon:"calendar",svgIcon:H.calendarIcon,onMouseDown:this.handleIconMouseDown,onClick:this.mobileMode?void 0:this.handleDateIconClick,title:m.provideLocalizationService(this).toLanguageString(l.toggleDateTimeSelector,l.messages[l.toggleDateTimeSelector]),className:o.classNames(o.uDateTimePicker.inputButton({c:D})),rounded:null,fillMode:s,"aria-label":m.provideLocalizationService(this).toLanguageString(l.toggleDateTimeSelector,l.messages[l.toggleDateTimeSelector])}),r.createElement(N,{show:this.show,animate:this.element!==null,anchor:this.element,popupClass:o.classNames(o.uDateTimePicker.popup({c:D})),id:this._popupId,anchorAlign:{horizontal:"left",vertical:"bottom"},popupAlign:{horizontal:"left",vertical:"top"}},!this.mobileMode&&this.renderPicker())),this.mobileMode&&this.renderAdaptivePopup()));return this.props.label?r.createElement(Q.PickerFloatingLabel,{dateInput:this._dateInput,label:this.props.label,editorId:f,editorValid:S,editorDisabled:this.props.disabled,children:I,style:{width:this.props.width}}):I}setShow(t){const{onOpen:i,onClose:s}=this.props;this.show!==t&&(this.setState({show:t}),t&&i&&i.call(void 0,{target:this}),!t&&s&&s.call(void 0,{target:this}))}nextTick(t){clearTimeout(this.nextTickId),this.nextTickId=window.setTimeout(()=>t())}calculateMedia(t){for(const i of t)this.setState({windowWidth:i.target.clientWidth})}};n.displayName="DateTimePicker",n.propTypes={className:e.string,defaultShow:e.bool,defaultValue:e.instanceOf(Date),disabled:e.bool,focusedDate:e.instanceOf(Date),format:e.oneOfType([e.string,e.shape({skeleton:e.string,pattern:e.string,date:e.oneOf(["short","medium","long","full"]),time:e.oneOf(["short","medium","long","full"]),datetime:e.oneOf(["short","medium","long","full"]),era:e.oneOf(["narrow","short","long"]),year:e.oneOf(["numeric","2-digit"]),month:e.oneOf(["numeric","2-digit","narrow","short","long"]),day:e.oneOf(["numeric","2-digit"]),weekday:e.oneOf(["narrow","short","long"]),hour:e.oneOf(["numeric","2-digit"]),hour12:e.bool,minute:e.oneOf(["numeric","2-digit"]),second:e.oneOf(["numeric","2-digit"]),timeZoneName:e.oneOf(["short","long"])})]),formatPlaceholder:e.oneOfType([e.oneOf(["wide","narrow","short","formatPattern"]),e.shape({year:e.string,month:e.string,day:e.string,hour:e.string,minute:e.string,second:e.string})]),id:e.string,ariaLabelledBy:e.string,ariaDescribedBy:e.string,min:e.instanceOf(Date),max:e.instanceOf(Date),name:e.string,popupSettings:e.shape({animate:e.bool,appendTo:e.any,popupClass:e.string}),show:e.bool,tabIndex:e.number,title:e.string,value:e.instanceOf(Date),weekNumber:e.bool,width:e.oneOfType([e.number,e.string]),validationMessage:e.string,required:e.bool,validate:e.bool,valid:e.bool,cancelButton:e.bool,size:e.oneOf([null,"small","medium","large"]),rounded:e.oneOf([null,"small","medium","large","full"]),fillMode:e.oneOf([null,"solid","flat","outline"]),autoFocus:e.bool},n.defaultProps={defaultShow:!1,defaultValue:null,disabled:!1,format:"g",max:p.MAX_DATE,min:p.MIN_DATE,popupSettings:{},tabIndex:0,weekNumber:!1,validityStyles:!0,cancelButton:!0,dateInput:W.DateInput,size:"medium",rounded:"medium",fillMode:"solid",autoFocus:!1};let g=n;const P=o.createPropsContext(),O=o.withIdHOC(o.withPropsContext(P,o.withUnstyledHOC(g)));O.displayName="KendoReactDateTimePicker";m.registerForLocalization(g);exports.DateTimePicker=O;exports.DateTimePickerPropsContext=P;exports.DateTimePickerWithoutContext=g;
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("react"),e=require("prop-types"),G=require("@progress/kendo-react-popup"),T=require("@progress/kendo-date-math"),o=require("@progress/kendo-react-common"),J=require("@progress/kendo-svg-icons"),Q=require("../dateinput/DateInput.js"),ee=require("@progress/kendo-react-buttons"),te=require("../package-metadata.js"),p=require("../utils.js"),ie=require("../common/constants.js"),l=require("../messages/index.js"),m=require("@progress/kendo-react-intl"),se=require("./DateTimeSelector.js"),oe=require("../timepicker/utils.js"),ae=require("../hooks/usePickerFloatingLabel.js"),ne=require("../common/AdaptiveMode.js"),re=require("@progress/kendo-react-layout");function le(c){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const i in c)if(i!=="default"){const s=Object.getOwnPropertyDescriptor(c,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:()=>c[i]})}}return t.default=c,Object.freeze(t)}const r=le($),a=class a extends r.Component{constructor(t){super(t),this._element=null,this._dateInput=r.createRef(),this._dateTimeSelector=null,this.shouldFocusDateInput=!1,this.prevShow=!1,this.focus=()=>{const i=this.dateInputElement();i&&i.focus()},this.renderPicker=()=>{const{disabled:i,minTime:s,maxTime:n,format:h,calendar:d,cancelButton:u,weekNumber:f,focusedDate:v,unstyled:w}=this.props;return r.createElement(se.DateTimeSelector,{ref:b=>{this._dateTimeSelector=b},cancelButton:u,steps:this.props.steps,value:this.value,onChange:this.handleValueChange,onReject:this.handleReject,disabled:i,weekNumber:f,min:this.min,max:this.max,minTime:s,maxTime:n,focusedDate:v,format:h,calendar:d,mobileMode:this.mobileMode,footerActions:!this.mobileMode,unstyled:w})},this.renderAdaptivePopup=()=>{const{windowWidth:i=0}=this.state,s=m.provideLocalizationService(this).toLanguageString(l.dateTimePickerCancel,l.messages[l.dateTimePickerCancel]),n=m.provideLocalizationService(this).toLanguageString(l.dateTimePickerSet,l.messages[l.dateTimePickerSet]),h={expand:this.show,onClose:this.handleBlur,adaptiveTitle:this.props.adaptiveTitle,windowWidth:i,footer:{cancelText:s,onCancel:d=>{var u;return(u=this._dateTimeSelector)==null?void 0:u.handleReject(d)},applyText:n,onApply:d=>{var u;return(u=this._dateTimeSelector)==null?void 0:u.handleAccept(d)}}};return r.createElement(ne.AdaptiveMode,{...h},r.createElement(re.ActionSheetContent,{overflowHidden:!0},this.renderPicker()))},this.handleReject=()=>{this.shouldFocusDateInput=!0,this.setShow(!1)},this.handleValueChange=i=>{this.setState({value:T.cloneDate(i.value||void 0)}),this.valueDuringOnChange=i.value,this.showDuringOnChange=!1,this.mobileMode||(this.shouldFocusDateInput=!0);const{onChange:s}=this.props;s&&s.call(void 0,{syntheticEvent:i.syntheticEvent,nativeEvent:i.nativeEvent,value:this.value,show:this.show,target:this}),this.valueDuringOnChange=void 0,this.showDuringOnChange=void 0,this.setShow(!1)},this.handleFocus=()=>{this.setState({focused:!0})},this.handleBlur=()=>{this.setState({focused:!1}),this.setShow(!1)},this.handleDateIconClick=()=>{this.props.disabled||(this.shouldFocusDateInput=!0,this.setShow(!this.show))},this.handleIconMouseDown=i=>{i.preventDefault()},this.handleKeyDown=i=>{const{altKey:s,keyCode:n}=i;if(n===o.Keys.esc){this.shouldFocusDateInput=!0,this.setShow(!1);return}s&&(n===o.Keys.up||n===o.Keys.down)&&(i.preventDefault(),i.stopPropagation(),this.shouldFocusDateInput=n===o.Keys.up,this.setShow(n===o.Keys.down))},this.dateInputElement=()=>this.dateInput&&this.dateInput.element||this.element&&this.element.querySelector(".k-dateinput > input.k-input-inner"),o.validatePackage(te.packageMetadata),this.state={value:this.props.defaultValue||a.defaultProps.defaultValue,show:this.props.defaultShow||a.defaultProps.defaultShow,focused:!1}}get _popupId(){return this.props.id+"-popup-id"}get document(){if(o.canUseDOM)return this.element&&this.element.ownerDocument||document}get element(){return this._element}get dateInput(){return this._dateInput.current}get value(){const t=this.valueDuringOnChange!==void 0?this.valueDuringOnChange:this.props.value!==void 0?this.props.value:this.state.value;return t!==null?T.cloneDate(t):null}get show(){return this.showDuringOnChange!==void 0?this.showDuringOnChange:this.props.show!==void 0?this.props.show:this.state.show}get name(){return this.props.name}get mobileMode(){return!!(this.state.windowWidth&&this.state.windowWidth<=ie.MOBILE_MEDIUM_DEVISE&&this.props.adaptive)}get min(){return this.props.min!==void 0?this.props.min:a.defaultProps.min}get max(){return this.props.max!==void 0?this.props.max:a.defaultProps.max}get validity(){const t=p.isInDateRange(this.value,this.min,this.max)&&oe.isInTimeRange(this.value,this.props.minTime||p.MIN_TIME,this.props.maxTime||p.MAX_TIME),i=this.props.validationMessage!==void 0,s=(!this.required||this.value!==null)&&t,n=this.props.valid!==void 0?this.props.valid:s;return{customError:i,rangeOverflow:this.value&&this.max.getTime()<this.value.getTime()||!1,rangeUnderflow:this.value&&this.value.getTime()<this.min.getTime()||!1,valid:n,valueMissing:this.value===null}}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:a.defaultProps.validityStyles}get required(){return this.props.required!==void 0?this.props.required:!1}get dateInputComp(){return this.props.dateInput||a.defaultProps.dateInput}componentDidMount(){var t;this.observerResize=o.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.show&&this.forceUpdate(),(t=this.document)!=null&&t.body&&this.observerResize&&this.observerResize.observe(this.document.body)}componentDidUpdate(){const t=this.dateInputElement();this._dateTimeSelector&&this.show&&!this.prevShow&&this._dateTimeSelector.focus({preventScroll:!0}),t&&!this.show&&this.shouldFocusDateInput&&t.focus({preventScroll:!0}),this.prevShow=this.show,this.shouldFocusDateInput=!1}componentWillUnmount(){var t;clearTimeout(this.nextTickId),(t=this.document)!=null&&t.body&&this.observerResize&&this.observerResize.disconnect()}render(){const{size:t=a.defaultProps.size,rounded:i=a.defaultProps.rounded,fillMode:s=a.defaultProps.fillMode,autoFocus:n=a.defaultProps.autoFocus,disabled:h,tabIndex:d,title:u,id:f,format:v,formatPlaceholder:w,min:b,max:O,className:k,width:C,name:x,validationMessage:E,required:q,validityStyles:F,minTime:R,maxTime:z,ariaLabelledBy:B,ariaDescribedBy:A,popup:N=G.Popup,unstyled:y,autoFill:L,twoDigitYearMax:_,enableMouseWheel:K,autoCorrectParts:V,autoSwitchParts:j,autoSwitchKeys:U,allowCaretMode:H}=this.props,D=y&&y.uDateTimePicker,S=!this.validityStyles||this.validity.valid,W={id:f,ariaLabelledBy:B,ariaDescribedBy:A,format:v,formatPlaceholder:w,disabled:h,title:u,validityStyles:F,validationMessage:E,required:q,min:b,max:O,minTime:R,maxTime:z,name:x,tabIndex:this.show?-1:d,valid:this.validity.valid,value:this.value,onChange:this.handleValueChange,steps:this.props.steps,label:void 0,placeholder:this.state.focused?null:this.props.placeholder,ariaExpanded:this.show,size:null,fillMode:null,rounded:null,unstyled:y,autoFill:L,twoDigitYearMax:_,enableMouseWheel:K,autoCorrectParts:V,autoSwitchParts:j,autoSwitchKeys:U,allowCaretMode:H},I=r.createElement(o.AsyncFocusBlur,{onFocus:this.handleFocus,onBlur:this.handleBlur,onSyncFocus:this.props.onFocus,onSyncBlur:this.props.onBlur},({onFocus:X,onBlur:Y})=>r.createElement(r.Fragment,null,r.createElement("div",{ref:Z=>{this._element=Z},className:o.classNames(o.uDateTimePicker.wrapper({c:D,size:t,fillMode:s,rounded:i,disabled:h,required:this.required,invalid:!S}),k),onKeyDown:this.handleKeyDown,style:{width:C},onFocus:this.mobileMode?void 0:X,onBlur:Y,onClick:this.mobileMode?this.handleDateIconClick:void 0},r.createElement(this.dateInputComp,{_ref:this._dateInput,ariaRole:"combobox",ariaControls:this._popupId,ariaHasPopup:"dialog",readonly:this.mobileMode,autoFocus:n,...W}),r.createElement(ee.Button,{tabIndex:-1,type:"button",icon:"calendar",svgIcon:J.calendarIcon,onMouseDown:this.handleIconMouseDown,onClick:this.mobileMode?void 0:this.handleDateIconClick,title:m.provideLocalizationService(this).toLanguageString(l.toggleDateTimeSelector,l.messages[l.toggleDateTimeSelector]),className:o.classNames(o.uDateTimePicker.inputButton({c:D})),rounded:null,fillMode:s,"aria-label":m.provideLocalizationService(this).toLanguageString(l.toggleDateTimeSelector,l.messages[l.toggleDateTimeSelector])}),r.createElement(N,{show:this.show,animate:this.element!==null,anchor:this.element,popupClass:o.classNames(o.uDateTimePicker.popup({c:D})),id:this._popupId,anchorAlign:{horizontal:"left",vertical:"bottom"},popupAlign:{horizontal:"left",vertical:"top"}},!this.mobileMode&&this.renderPicker())),this.mobileMode&&this.renderAdaptivePopup()));return this.props.label?r.createElement(ae.PickerFloatingLabel,{dateInput:this._dateInput,label:this.props.label,editorId:f,editorValid:S,editorDisabled:this.props.disabled,children:I,style:{width:this.props.width}}):I}setShow(t){const{onOpen:i,onClose:s}=this.props;this.show!==t&&(this.setState({show:t}),t&&i&&i.call(void 0,{target:this}),!t&&s&&s.call(void 0,{target:this}))}nextTick(t){clearTimeout(this.nextTickId),this.nextTickId=window.setTimeout(()=>t())}calculateMedia(t){for(const i of t)this.setState({windowWidth:i.target.clientWidth})}};a.displayName="DateTimePicker",a.propTypes={className:e.string,defaultShow:e.bool,defaultValue:e.instanceOf(Date),disabled:e.bool,focusedDate:e.instanceOf(Date),format:e.oneOfType([e.string,e.shape({skeleton:e.string,pattern:e.string,date:e.oneOf(["short","medium","long","full"]),time:e.oneOf(["short","medium","long","full"]),datetime:e.oneOf(["short","medium","long","full"]),era:e.oneOf(["narrow","short","long"]),year:e.oneOf(["numeric","2-digit"]),month:e.oneOf(["numeric","2-digit","narrow","short","long"]),day:e.oneOf(["numeric","2-digit"]),weekday:e.oneOf(["narrow","short","long"]),hour:e.oneOf(["numeric","2-digit"]),hour12:e.bool,minute:e.oneOf(["numeric","2-digit"]),second:e.oneOf(["numeric","2-digit"]),timeZoneName:e.oneOf(["short","long"])})]),formatPlaceholder:e.oneOfType([e.oneOf(["wide","narrow","short","formatPattern"]),e.shape({year:e.string,month:e.string,day:e.string,hour:e.string,minute:e.string,second:e.string})]),id:e.string,ariaLabelledBy:e.string,ariaDescribedBy:e.string,min:e.instanceOf(Date),max:e.instanceOf(Date),name:e.string,popupSettings:e.shape({animate:e.bool,appendTo:e.any,popupClass:e.string}),show:e.bool,tabIndex:e.number,title:e.string,value:e.instanceOf(Date),weekNumber:e.bool,width:e.oneOfType([e.number,e.string]),validationMessage:e.string,required:e.bool,validate:e.bool,valid:e.bool,cancelButton:e.bool,size:e.oneOf([null,"small","medium","large"]),rounded:e.oneOf([null,"small","medium","large","full"]),fillMode:e.oneOf([null,"solid","flat","outline"]),autoFocus:e.bool},a.defaultProps={defaultShow:!1,defaultValue:null,disabled:!1,format:"g",max:p.MAX_DATE,min:p.MIN_DATE,popupSettings:{},tabIndex:0,weekNumber:!1,validityStyles:!0,cancelButton:!0,dateInput:Q.DateInput,size:"medium",rounded:"medium",fillMode:"solid",autoFocus:!1};let g=a;const P=o.createPropsContext(),M=o.withIdHOC(o.withPropsContext(P,o.withUnstyledHOC(g)));M.displayName="KendoReactDateTimePicker";m.registerForLocalization(g);exports.DateTimePicker=M;exports.DateTimePickerPropsContext=P;exports.DateTimePickerWithoutContext=g;
|