@progress/kendo-react-dateinputs 9.1.1-develop.3 → 9.2.0-develop.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dateinput/DateInput.js +1 -1
- package/dateinput/DateInput.mjs +87 -84
- package/datepicker/DatePicker.js +1 -1
- package/datepicker/DatePicker.mjs +78 -75
- package/daterangepicker/DateRangePicker.js +1 -1
- package/daterangepicker/DateRangePicker.mjs +58 -55
- package/datetimepicker/DateTimePicker.js +1 -1
- package/datetimepicker/DateTimePicker.mjs +93 -90
- package/dist/cdn/js/kendo-react-dateinputs.js +1 -1
- package/index.d.mts +31 -0
- package/index.d.ts +31 -0
- package/package-metadata.mjs +1 -1
- package/package.json +7 -7
- package/timepicker/TimePicker.js +1 -1
- package/timepicker/TimePicker.mjs +59 -56
|
@@ -10,20 +10,20 @@ import * as n from "react";
|
|
|
10
10
|
import e from "prop-types";
|
|
11
11
|
import { Popup as Y } from "@progress/kendo-react-popup";
|
|
12
12
|
import { getDate as Z, cloneDate as M } from "@progress/kendo-date-math";
|
|
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 x, messages 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
|
|
13
|
+
import { classNames as k, Keys as r, validatePackage as G, canUseDOM as P, AsyncFocusBlur as J, kendoThemeMaps as T, createPropsContext as Q, withIdHOC as ee, withPropsContext as te } from "@progress/kendo-react-common";
|
|
14
|
+
import { calendarIcon as ie } from "@progress/kendo-svg-icons";
|
|
15
|
+
import { packageMetadata as se } from "../package-metadata.mjs";
|
|
16
|
+
import { DateInput as oe } from "../dateinput/DateInput.mjs";
|
|
17
|
+
import { Calendar as ae } from "../calendar/components/Calendar.mjs";
|
|
18
|
+
import { MAX_DATE as ne, MIN_DATE as re, isInDateRange as le, setTime as ue } from "../utils.mjs";
|
|
19
|
+
import { toggleCalendar as x, messages as de } from "../messages/index.mjs";
|
|
20
|
+
import { provideLocalizationService as he, registerForLocalization as pe } from "@progress/kendo-react-intl";
|
|
21
|
+
import { ToggleButton as ce } from "./ToggleButton.mjs";
|
|
22
|
+
import { PickerWrap as me } from "../common/PickerWrap.mjs";
|
|
23
|
+
import { PickerFloatingLabel as fe } from "../hooks/usePickerFloatingLabel.mjs";
|
|
24
|
+
import { ActionSheetContent as ge } from "@progress/kendo-react-layout";
|
|
25
|
+
import { AdaptiveMode as ve } from "../common/AdaptiveMode.mjs";
|
|
26
|
+
import { MOBILE_MEDIUM_DEVISE as we } 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 = () => {
|
|
@@ -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(ve, { ...s }, /* @__PURE__ */ n.createElement(ge, { overflowHidden: !0 }, this.renderPopup()));
|
|
70
70
|
}, this.handleInputValueChange = (t) => {
|
|
71
71
|
this.handleValueChange(t.value, t);
|
|
72
72
|
}, this.handleCalendarValueChange = (t) => {
|
|
@@ -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
|
+
}, G(se), 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 <= we && this.props.adaptive);
|
|
131
131
|
}
|
|
132
132
|
/**
|
|
133
133
|
* Gets the DateInput component inside the DatePicker component.
|
|
@@ -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 = le(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,
|
|
@@ -253,38 +253,39 @@ const o = class o extends n.Component {
|
|
|
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: Ce,
|
|
257
|
+
defaultValue: Ie,
|
|
258
|
+
defaultShow: De,
|
|
259
|
+
value: Se,
|
|
260
|
+
popup: Oe,
|
|
261
|
+
weekNumber: Me,
|
|
262
|
+
dateInput: ke,
|
|
263
|
+
calendar: Pe,
|
|
264
|
+
toggleButton: Te,
|
|
265
|
+
onChange: xe,
|
|
266
|
+
onBlur: Ee,
|
|
267
|
+
onFocus: Be,
|
|
268
|
+
show: Fe,
|
|
269
|
+
onOpen: Ve,
|
|
270
|
+
pickerWrap: ze,
|
|
271
|
+
adaptive: Ne,
|
|
272
|
+
adaptiveTitle: Re,
|
|
273
|
+
valid: Ae,
|
|
274
274
|
autoFocus: R,
|
|
275
|
+
inputAttributes: A,
|
|
275
276
|
// Removed to support direct use in Form Field component
|
|
276
|
-
visited:
|
|
277
|
-
touched:
|
|
278
|
-
modified:
|
|
279
|
-
autoFill:
|
|
280
|
-
twoDigitYearMax:
|
|
281
|
-
enableMouseWheel:
|
|
282
|
-
autoCorrectParts:
|
|
283
|
-
autoSwitchParts:
|
|
284
|
-
autoSwitchKeys:
|
|
285
|
-
allowCaretMode:
|
|
277
|
+
visited: Le,
|
|
278
|
+
touched: We,
|
|
279
|
+
modified: qe,
|
|
280
|
+
autoFill: L,
|
|
281
|
+
twoDigitYearMax: W,
|
|
282
|
+
enableMouseWheel: q,
|
|
283
|
+
autoCorrectParts: _,
|
|
284
|
+
autoSwitchParts: K,
|
|
285
|
+
autoSwitchKeys: U,
|
|
286
|
+
allowCaretMode: $,
|
|
286
287
|
...C
|
|
287
|
-
} = this.props,
|
|
288
|
+
} = this.props, H = this.value, I = !this.validityStyles || this.validity.valid, j = {
|
|
288
289
|
disabled: a,
|
|
289
290
|
format: f,
|
|
290
291
|
formatPlaceholder: g,
|
|
@@ -302,25 +303,26 @@ const o = class o extends n.Component {
|
|
|
302
303
|
valid: this.validity.valid,
|
|
303
304
|
validationMessage: h,
|
|
304
305
|
validityStyles: B,
|
|
305
|
-
value:
|
|
306
|
+
value: H,
|
|
306
307
|
label: void 0,
|
|
307
308
|
placeholder: this.state.focused ? null : N,
|
|
308
309
|
ariaExpanded: this.show,
|
|
309
310
|
size: null,
|
|
310
311
|
fillMode: null,
|
|
311
312
|
rounded: null,
|
|
312
|
-
autoFill:
|
|
313
|
-
twoDigitYearMax:
|
|
314
|
-
enableMouseWheel:
|
|
315
|
-
autoCorrectParts:
|
|
316
|
-
autoSwitchParts:
|
|
317
|
-
autoSwitchKeys:
|
|
318
|
-
allowCaretMode:
|
|
319
|
-
|
|
313
|
+
autoFill: L,
|
|
314
|
+
twoDigitYearMax: W,
|
|
315
|
+
enableMouseWheel: q,
|
|
316
|
+
autoCorrectParts: _,
|
|
317
|
+
autoSwitchParts: K,
|
|
318
|
+
autoSwitchKeys: U,
|
|
319
|
+
allowCaretMode: $,
|
|
320
|
+
inputAttributes: A
|
|
321
|
+
}, D = he(this).toLanguageString(
|
|
320
322
|
x,
|
|
321
|
-
|
|
323
|
+
de[x]
|
|
322
324
|
), S = /* @__PURE__ */ n.createElement(
|
|
323
|
-
|
|
325
|
+
J,
|
|
324
326
|
{
|
|
325
327
|
onFocus: this.handleFocus,
|
|
326
328
|
onBlur: this.mobileMode ? void 0 : this.handleBlur,
|
|
@@ -361,7 +363,7 @@ const o = class o extends n.Component {
|
|
|
361
363
|
ariaExpanded: this.show,
|
|
362
364
|
ariaControls: this._popupId,
|
|
363
365
|
autoFocus: R,
|
|
364
|
-
...
|
|
366
|
+
...j
|
|
365
367
|
}
|
|
366
368
|
),
|
|
367
369
|
/* @__PURE__ */ n.createElement(
|
|
@@ -369,7 +371,7 @@ const o = class o extends n.Component {
|
|
|
369
371
|
{
|
|
370
372
|
type: "button",
|
|
371
373
|
icon: "calendar",
|
|
372
|
-
svgIcon:
|
|
374
|
+
svgIcon: ie,
|
|
373
375
|
title: D,
|
|
374
376
|
className: "k-input-button",
|
|
375
377
|
rounded: null,
|
|
@@ -383,7 +385,7 @@ const o = class o extends n.Component {
|
|
|
383
385
|
), this.mobileMode && this.renderAdaptivePopup())
|
|
384
386
|
);
|
|
385
387
|
return y ? /* @__PURE__ */ n.createElement(
|
|
386
|
-
|
|
388
|
+
fe,
|
|
387
389
|
{
|
|
388
390
|
dateInput: this._dateInput,
|
|
389
391
|
label: y,
|
|
@@ -405,7 +407,7 @@ const o = class o extends n.Component {
|
|
|
405
407
|
}));
|
|
406
408
|
}
|
|
407
409
|
mergeTime(i) {
|
|
408
|
-
return this.value && i ?
|
|
410
|
+
return this.value && i ? ue(i, this.value) : i;
|
|
409
411
|
}
|
|
410
412
|
nextTick(i) {
|
|
411
413
|
clearTimeout(this.nextTickId), this.nextTickId = window.setTimeout(() => i());
|
|
@@ -484,19 +486,20 @@ o.displayName = "DatePicker", o.propTypes = {
|
|
|
484
486
|
fillMode: e.oneOf([null, "solid", "flat", "outline"]),
|
|
485
487
|
adaptive: e.bool,
|
|
486
488
|
adaptiveTitle: e.string,
|
|
487
|
-
autoFocus: e.bool
|
|
489
|
+
autoFocus: e.bool,
|
|
490
|
+
inputAttributes: e.object
|
|
488
491
|
}, o.defaultProps = {
|
|
489
492
|
defaultShow: !1,
|
|
490
493
|
defaultValue: null,
|
|
491
|
-
dateInput:
|
|
492
|
-
calendar:
|
|
493
|
-
toggleButton:
|
|
494
|
+
dateInput: oe,
|
|
495
|
+
calendar: ae,
|
|
496
|
+
toggleButton: ce,
|
|
494
497
|
popup: Y,
|
|
495
|
-
pickerWrap:
|
|
498
|
+
pickerWrap: me,
|
|
496
499
|
disabled: !1,
|
|
497
500
|
format: "d",
|
|
498
|
-
max:
|
|
499
|
-
min:
|
|
501
|
+
max: ne,
|
|
502
|
+
min: re,
|
|
500
503
|
popupSettings: {},
|
|
501
504
|
tabIndex: 0,
|
|
502
505
|
weekNumber: !1,
|
|
@@ -507,13 +510,13 @@ o.displayName = "DatePicker", o.propTypes = {
|
|
|
507
510
|
autoFocus: !1
|
|
508
511
|
};
|
|
509
512
|
let p = o;
|
|
510
|
-
const
|
|
511
|
-
|
|
513
|
+
const be = Q(), ye = ee(
|
|
514
|
+
te(be, p)
|
|
512
515
|
);
|
|
513
|
-
|
|
514
|
-
|
|
516
|
+
ye.displayName = "KendoReactDatePicker";
|
|
517
|
+
pe(p);
|
|
515
518
|
export {
|
|
516
|
-
|
|
517
|
-
|
|
519
|
+
ye as DatePicker,
|
|
520
|
+
be as DatePickerPropsContext,
|
|
518
521
|
p as DatePickerWithoutContext
|
|
519
522
|
};
|
|
@@ -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 y=require("react"),t=require("prop-types"),O=require("@progress/kendo-react-popup"),D=require("@progress/kendo-date-math"),o=require("@progress/kendo-react-common"),c=require("@progress/kendo-react-intl"),k=require("@progress/kendo-svg-icons"),M=require("../package-metadata.js"),g=require("../dateinput/DateInput.js"),T=require("../calendar/components/MultiViewCalendar.js"),h=require("../calendar/models/SelectionRange.js"),u=require("../utils.js"),x=require("../common/constants.js"),n=require("../messages/index.js"),P=require("@progress/kendo-react-buttons"),_=require("../common/AdaptiveMode.js"),N=require("@progress/kendo-react-layout");function A(d){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(d){for(const e in d)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(d,e);Object.defineProperty(a,e,s.get?s:{enumerable:!0,get:()=>d[e]})}}return a.default=d,Object.freeze(a)}const i=A(y),l=class l extends i.Component{constructor(a){super(a),this._element=null,this._calendar=null,this._startDateInput=i.createRef(),this._endDateInput=i.createRef(),this.shouldFocusDateInput=!1,this.shouldFocusCalendar=!1,this.focus=()=>{this.startDateInput&&this.startDateInput.focus()},this.setCalendarRef=e=>{this._calendar=e},this.focusCalendarElement=()=>{this._calendar&&this._calendar.element&&this._calendar.element.focus({preventScroll:!0})},this.calculateValue=(e,s)=>(e.value!==void 0?e.value:s.value)||h.EMPTY_SELECTIONRANGE,this.calculateShow=(e,s)=>e.show!==void 0?e.show:s.show,this.renderCalendar=()=>{const e=this.value||h.EMPTY_SELECTIONRANGE,s={min:this.min,max:this.max,allowReverse:this.props.allowReverse,mode:"range",focusedDate:this.props.focusedDate,disabled:this.props.disabled,className:this.mobileMode?"k-calendar-lg":"",mobileMode:this.mobileMode,...this.props.calendarSettings,value:e,dir:this.props.dir,onChange:this.handleCalendarChange};return this.props.calendar?i.createElement(this.props.calendar,{...s}):i.createElement(T.MultiViewCalendar,{...s,ref:this.setCalendarRef})},this.renderPopup=()=>{const e={popupClass:o.classNames("k-calendar-container","k-daterangepicker-popup"),animate:this._element!==null,anchor:this._element,id:this._popupId,anchorAlign:{horizontal:"left",vertical:"bottom"},popupAlign:{horizontal:"left",vertical:"top"},...this.props.popupSettings,show:this.show};return this.props.popup?i.createElement(this.props.popup,{...e},this.renderCalendar()):i.createElement(O.Popup,{...e},this.renderCalendar())},this.renderAdaptivePopup=()=>{const{windowWidth:e=0}=this.state,s={expand:this.show,onClose:r=>this.handleCancel(r),adaptiveTitle:this.props.adaptiveTitle,windowWidth:e,footer:{cancelText:this.localizationService.toLanguageString(n.dateRangePickerCancel,n.messages[n.dateRangePickerCancel]),onCancel:this.handleCancel,applyText:this.localizationService.toLanguageString(n.dateRangePickerSet,n.messages[n.dateRangePickerSet]),onApply:this.handleBlur}};return i.createElement(_.AdaptiveMode,{...s},i.createElement(N.ActionSheetContent,{overflowHidden:!0},i.createElement("div",{className:"k-scrollable-wrap"},this.renderCalendar())))},this.handleReverseClick=e=>{const s={start:this.value.end,end:this.value.start},r={syntheticEvent:e,nativeEvent:e.nativeEvent};this.handleChange(s,r)},this.handleReverseMouseDown=e=>{e.preventDefault()},this.handleFocus=e=>{clearTimeout(this.nextTickId),this.shouldFocusDateInput||this.mobileMode&&this.setState({currentValue:this.value});const{onFocus:s}=this.props;s&&s.call(void 0,e)},this.handleClick=()=>{this.shouldFocusDateInput||this.setShow(!0)},this.handleBlur=e=>{this.nextTick(()=>{this.setShow(!1)});const{onBlur:s}=this.props;s&&s.call(void 0,e)},this.handleCancel=e=>{this.nextTick(()=>{this.setShow(!1),this.setState({currentValue:h.EMPTY_SELECTIONRANGE})});const{onCancel:s}=this.props;s&&s.call(void 0,e)},this.handleEndChange=e=>{const s={start:this.value.start,end:D.cloneDate(e.value||void 0)};this.handleChange(s,e)},this.handleStartChange=e=>{const s={start:D.cloneDate(e.value||void 0),end:this.value.end};this.handleChange(s,e)},this.extractRangeFromValue=e=>{if(!Array.isArray(e.value)&&!(e.value instanceof Date))return e.value||h.EMPTY_SELECTIONRANGE;const s=Array.isArray(e.value)?e.value[0]:e.value;return{start:this.value.end!==null?s:this.value.start,end:this.value.start!==null?s:this.value.end}},this.handleCalendarChange=e=>{const s=this.extractRangeFromValue(e);this.handleChange(s,e)},this.handleKeyDown=e=>{const{keyCode:s,altKey:r}=e;s===o.Keys.esc?(e.preventDefault(),this.shouldFocusDateInput=!0,this.setShow(!1)):r&&s===o.Keys.down?(e.preventDefault(),this.shouldFocusCalendar=!0,this.setShow(!0),this.focusCalendarElement()):r&&s===o.Keys.up&&(e.preventDefault(),this.shouldFocusDateInput=!0,this.setShow(!1))},this.handleChange=(e,s)=>{this.setState({value:e}),this.valueDuringOnChange=e;const{onChange:r}=this.props;if(r){const m={syntheticEvent:s.syntheticEvent,nativeEvent:s.nativeEvent,value:this.value,show:this.show,target:this};r.call(void 0,m)}this.valueDuringOnChange=void 0},o.validatePackage(M.packageMetadata),this.state={show:this.props.show||this.props.defaultShow||l.defaultProps.defaultShow,value:this.props.value||this.props.defaultValue||l.defaultProps.defaultValue,currentValue:h.EMPTY_SELECTIONRANGE},this.nextTick=this.nextTick.bind(this),this.setShow=this.setShow.bind(this),this.focusCalendarElement=this.focusCalendarElement.bind(this),this.focusDateInputElement=this.focusDateInputElement.bind(this)}get _popupId(){return this.props.id+"-popup-id"}get _startInputId(){return this.props.id+"-start-input-id"}get _endInputId(){return this.props.id+"-end-input-id"}get element(){return this._element}get startDateInput(){return this._startDateInput.current}get endDateInput(){return this._endDateInput.current}get calendar(){return this._calendar}get value(){return(this.valueDuringOnChange!==void 0?this.valueDuringOnChange:this.props.value!==void 0?this.props.value:this.state.value)||h.EMPTY_SELECTIONRANGE}get show(){return this.showDuringOnChange!==void 0?this.showDuringOnChange:this.props.show!==void 0?this.props.show:this.state.show}get min(){return this.props.min!==void 0?this.props.min:l.defaultProps.min}get max(){return this.props.max!==void 0?this.props.max:l.defaultProps.max}get document(){if(o.canUseDOM)return this.element&&this.element.ownerDocument||document}get localizationService(){return c.provideLocalizationService(this)}get mobileMode(){return!!(this.state.windowWidth&&this.state.windowWidth<=x.MOBILE_MEDIUM_DEVISE&&this.props.adaptive)}componentDidMount(){var a;this.observerResize=o.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.show&&this.forceUpdate(),(a=this.document)!=null&&a.body&&this.observerResize&&this.observerResize.observe(this.document.body)}componentDidUpdate(){this.shouldFocusCalendar&&this.focusCalendarElement(),this.shouldFocusDateInput&&this.focusDateInputElement(),this.shouldFocusCalendar=!1,this.shouldFocusDateInput=!1}componentWillUnmount(){var a;clearTimeout(this.nextTickId),(a=this.document)!=null&&a.body&&this.observerResize&&this.observerResize.disconnect()}render(){const a=this.value||h.EMPTY_SELECTIONRANGE,e=this.mobileMode&&this.show?this.state.currentValue:a,s=(this.props.startDateInputSettings||{}).id||this._startInputId,r=(this.props.endDateInputSettings||{}).id||this._endInputId,m=o.classNames("k-daterangepicker",{"k-disabled":this.props.disabled},this.props.className),b=this.localizationService.toLanguageString(n.start,n.messages[n.start]),E=this.localizationService.toLanguageString(n.end,n.messages[n.end]),S=this.localizationService.toLanguageString(n.separator,n.messages[n.separator]),f={disableSelection:this.mobileMode&&!0,label:b,format:this.props.format,min:this.min,max:this.max,id:this._startInputId,disabled:this.props.disabled,valid:this.props.valid,tabIndex:this.props.tabIndex,ariaExpanded:this.show,clearButton:this.props.clearButton,...this.props.startDateInputSettings,value:e.start,onChange:this.handleStartChange},v={disableSelection:this.mobileMode&&!0,label:E,format:this.props.format,min:this.min,max:this.max,id:this._endInputId,disabled:this.props.disabled,valid:this.props.valid,tabIndex:this.props.tabIndex,ariaExpanded:this.show,clearButton:this.props.clearButton,...this.props.endDateInputSettings,value:e.end,onChange:this.handleEndChange},C=i.createElement(P.Button,{type:"button",className:"k-select",fillMode:"flat",title:c.provideLocalizationService(this).toLanguageString(n.swapStartEnd,n.messages[n.swapStartEnd]),onMouseDown:this.handleReverseMouseDown,onClick:this.handleReverseClick,"aria-controls":s+" "+r,"aria-label":c.provideLocalizationService(this).toLanguageString(n.swapStartEnd,n.messages[n.swapStartEnd])},i.createElement(o.IconWrap,{style:{transform:"rotate(90deg)"},name:"arrows-swap",icon:k.arrowsSwapIcon}));return i.createElement(i.Fragment,null,i.createElement("span",{ref:R=>{this._element=R},className:m,style:this.props.style,id:this.props.id,"aria-labelledby":this.props.ariaLabelledBy,"aria-describedby":this.props.ariaDescribedBy,tabIndex:this.props.tabIndex,onFocus:this.handleFocus,onClick:this.handleClick,onKeyDown:this.handleKeyDown,onBlur:this.mobileMode?void 0:this.handleBlur,dir:this.props.dir},this.props.startDateInput?i.createElement(this.props.startDateInput,{...f}):i.createElement(g.DateInput,{...f,autoFocus:this.props.autoFocus,ref:this._startDateInput,ariaRole:"combobox",ariaControls:this._popupId}),(this.props.allowReverse||this.props.calendarSettings&&this.props.calendarSettings.allowReverse)&&this.props.swapButton?C:S,this.props.endDateInput?i.createElement(this.props.endDateInput,{...v}):i.createElement(g.DateInput,{...v,ref:this._endDateInput,ariaRole:"combobox",ariaControls:this._popupId}),!this.mobileMode&&this.renderPopup()),this.mobileMode&&this.renderAdaptivePopup())}focusDateInputElement(){if(!document||!this.startDateInput||!this.startDateInput.element||!this.endDateInput||!this.endDateInput.element)return;const a=o.getActiveElement(document);(this.value.start===null||this.value.end!==null)&&a!==this.endDateInput.element?this.startDateInput.element.focus({preventScroll:!0}):a!==this.startDateInput.element&&this.endDateInput.element.focus({preventScroll:!0})}nextTick(a){clearTimeout(this.nextTickId),this.nextTickId=window.setTimeout(()=>a())}setShow(a){const{onOpen:e,onClose:s}=this.props;this.show!==a&&(this.setState({show:a}),a&&e&&e.call(void 0,{target:this}),!a&&s&&s.call(void 0,{target:this}))}calculateMedia(a){for(const e of a)this.setState({windowWidth:e.target.clientWidth})}};l.displayName="DateRangePicker",l.propTypes={allowReverse:t.bool,calendarSettings:t.any,className:t.string,defaultShow:t.bool,defaultValue:t.shape({start:u.nullable(t.instanceOf(Date).isRequired),end:u.nullable(t.instanceOf(Date).isRequired)}),disabled:t.bool,endDateInputSettings:t.shape(g.DateInputWithoutContext.propTypes),focusedDate:t.instanceOf(Date),format:t.oneOfType([t.string,t.shape({skeleton:t.string,pattern:t.string,date:t.oneOf(["short","medium","long","full"]),time:t.oneOf(["short","medium","long","full"]),datetime:t.oneOf(["short","medium","long","full"]),era:t.oneOf(["narrow","short","long"]),year:t.oneOf(["numeric","2-digit"]),month:t.oneOf(["numeric","2-digit","narrow","short","long"]),day:t.oneOf(["numeric","2-digit"]),weekday:t.oneOf(["narrow","short","long"]),hour:t.oneOf(["numeric","2-digit"]),hour12:t.bool,minute:t.oneOf(["numeric","2-digit"]),second:t.oneOf(["numeric","2-digit"]),timeZoneName:t.oneOf(["short","long"])})]),id:t.string,ariaLabelledBy:t.string,ariaDescribedBy:t.string,max:t.instanceOf(Date),min:t.instanceOf(Date),onBlur:t.func,onChange:t.func,onFocus:t.func,popupSettings:t.any,show:t.bool,startDateInputSettings:t.any,style:t.any,swapButton:t.any,tabIndex:t.number,dir:t.string,value:t.shape({start:u.nullable(t.instanceOf(Date).isRequired),end:u.nullable(t.instanceOf(Date).isRequired)}),autoFocus:t.bool},l.defaultProps={allowReverse:!1,defaultShow:!1,defaultValue:h.EMPTY_SELECTIONRANGE,disabled:!1,format:"d",max:u.MAX_DATE,min:u.MIN_DATE,swapButton:!1,autoFocus:!1};let p=l;const I=o.createPropsContext(),w=o.withIdHOC(o.withPropsContext(I,p));w.displayName="KendoReactDateRangePicker";c.registerForLocalization(p);exports.DateRangePicker=w;exports.DateRangePickerPropsContext=I;exports.DateRangePickerWithoutContext=p;
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react"),t=require("prop-types"),M=require("@progress/kendo-react-popup"),D=require("@progress/kendo-date-math"),r=require("@progress/kendo-react-common"),c=require("@progress/kendo-react-intl"),T=require("@progress/kendo-svg-icons"),x=require("../package-metadata.js"),g=require("../dateinput/DateInput.js"),P=require("../calendar/components/MultiViewCalendar.js"),h=require("../calendar/models/SelectionRange.js"),u=require("../utils.js"),_=require("../common/constants.js"),n=require("../messages/index.js"),A=require("@progress/kendo-react-buttons"),N=require("../common/AdaptiveMode.js"),F=require("@progress/kendo-react-layout");function L(d){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(d){for(const e in d)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(d,e);Object.defineProperty(a,e,s.get?s:{enumerable:!0,get:()=>d[e]})}}return a.default=d,Object.freeze(a)}const i=L(k),l=class l extends i.Component{constructor(a){super(a),this._element=null,this._calendar=null,this._startDateInput=i.createRef(),this._endDateInput=i.createRef(),this.shouldFocusDateInput=!1,this.shouldFocusCalendar=!1,this.focus=()=>{this.startDateInput&&this.startDateInput.focus()},this.setCalendarRef=e=>{this._calendar=e},this.focusCalendarElement=()=>{this._calendar&&this._calendar.element&&this._calendar.element.focus({preventScroll:!0})},this.calculateValue=(e,s)=>(e.value!==void 0?e.value:s.value)||h.EMPTY_SELECTIONRANGE,this.calculateShow=(e,s)=>e.show!==void 0?e.show:s.show,this.renderCalendar=()=>{const e=this.value||h.EMPTY_SELECTIONRANGE,s={min:this.min,max:this.max,allowReverse:this.props.allowReverse,mode:"range",focusedDate:this.props.focusedDate,disabled:this.props.disabled,className:this.mobileMode?"k-calendar-lg":"",mobileMode:this.mobileMode,...this.props.calendarSettings,value:e,dir:this.props.dir,onChange:this.handleCalendarChange};return this.props.calendar?i.createElement(this.props.calendar,{...s}):i.createElement(P.MultiViewCalendar,{...s,ref:this.setCalendarRef})},this.renderPopup=()=>{const e={popupClass:r.classNames("k-calendar-container","k-daterangepicker-popup"),animate:this._element!==null,anchor:this._element,id:this._popupId,anchorAlign:{horizontal:"left",vertical:"bottom"},popupAlign:{horizontal:"left",vertical:"top"},...this.props.popupSettings,show:this.show};return this.props.popup?i.createElement(this.props.popup,{...e},this.renderCalendar()):i.createElement(M.Popup,{...e},this.renderCalendar())},this.renderAdaptivePopup=()=>{const{windowWidth:e=0}=this.state,s={expand:this.show,onClose:o=>this.handleCancel(o),adaptiveTitle:this.props.adaptiveTitle,windowWidth:e,footer:{cancelText:this.localizationService.toLanguageString(n.dateRangePickerCancel,n.messages[n.dateRangePickerCancel]),onCancel:this.handleCancel,applyText:this.localizationService.toLanguageString(n.dateRangePickerSet,n.messages[n.dateRangePickerSet]),onApply:this.handleBlur}};return i.createElement(N.AdaptiveMode,{...s},i.createElement(F.ActionSheetContent,{overflowHidden:!0},i.createElement("div",{className:"k-scrollable-wrap"},this.renderCalendar())))},this.handleReverseClick=e=>{const s={start:this.value.end,end:this.value.start},o={syntheticEvent:e,nativeEvent:e.nativeEvent};this.handleChange(s,o)},this.handleReverseMouseDown=e=>{e.preventDefault()},this.handleFocus=e=>{clearTimeout(this.nextTickId),this.shouldFocusDateInput||this.mobileMode&&this.setState({currentValue:this.value});const{onFocus:s}=this.props;s&&s.call(void 0,e)},this.handleClick=()=>{this.shouldFocusDateInput||this.setShow(!0)},this.handleBlur=e=>{this.nextTick(()=>{this.setShow(!1)});const{onBlur:s}=this.props;s&&s.call(void 0,e)},this.handleCancel=e=>{this.nextTick(()=>{this.setShow(!1),this.setState({currentValue:h.EMPTY_SELECTIONRANGE})});const{onCancel:s}=this.props;s&&s.call(void 0,e)},this.handleEndChange=e=>{const s={start:this.value.start,end:D.cloneDate(e.value||void 0)};this.handleChange(s,e)},this.handleStartChange=e=>{const s={start:D.cloneDate(e.value||void 0),end:this.value.end};this.handleChange(s,e)},this.extractRangeFromValue=e=>{if(!Array.isArray(e.value)&&!(e.value instanceof Date))return e.value||h.EMPTY_SELECTIONRANGE;const s=Array.isArray(e.value)?e.value[0]:e.value;return{start:this.value.end!==null?s:this.value.start,end:this.value.start!==null?s:this.value.end}},this.handleCalendarChange=e=>{const s=this.extractRangeFromValue(e);this.handleChange(s,e)},this.handleKeyDown=e=>{const{keyCode:s,altKey:o}=e;s===r.Keys.esc?(e.preventDefault(),this.shouldFocusDateInput=!0,this.setShow(!1)):o&&s===r.Keys.down?(e.preventDefault(),this.shouldFocusCalendar=!0,this.setShow(!0),this.focusCalendarElement()):o&&s===r.Keys.up&&(e.preventDefault(),this.shouldFocusDateInput=!0,this.setShow(!1))},this.handleChange=(e,s)=>{this.setState({value:e}),this.valueDuringOnChange=e;const{onChange:o}=this.props;if(o){const m={syntheticEvent:s.syntheticEvent,nativeEvent:s.nativeEvent,value:this.value,show:this.show,target:this};o.call(void 0,m)}this.valueDuringOnChange=void 0},r.validatePackage(x.packageMetadata),this.state={show:this.props.show||this.props.defaultShow||l.defaultProps.defaultShow,value:this.props.value||this.props.defaultValue||l.defaultProps.defaultValue,currentValue:h.EMPTY_SELECTIONRANGE},this.nextTick=this.nextTick.bind(this),this.setShow=this.setShow.bind(this),this.focusCalendarElement=this.focusCalendarElement.bind(this),this.focusDateInputElement=this.focusDateInputElement.bind(this)}get _popupId(){return this.props.id+"-popup-id"}get _startInputId(){return this.props.id+"-start-input-id"}get _endInputId(){return this.props.id+"-end-input-id"}get element(){return this._element}get startDateInput(){return this._startDateInput.current}get endDateInput(){return this._endDateInput.current}get calendar(){return this._calendar}get value(){return(this.valueDuringOnChange!==void 0?this.valueDuringOnChange:this.props.value!==void 0?this.props.value:this.state.value)||h.EMPTY_SELECTIONRANGE}get show(){return this.showDuringOnChange!==void 0?this.showDuringOnChange:this.props.show!==void 0?this.props.show:this.state.show}get min(){return this.props.min!==void 0?this.props.min:l.defaultProps.min}get max(){return this.props.max!==void 0?this.props.max:l.defaultProps.max}get document(){if(r.canUseDOM)return this.element&&this.element.ownerDocument||document}get localizationService(){return c.provideLocalizationService(this)}get mobileMode(){return!!(this.state.windowWidth&&this.state.windowWidth<=_.MOBILE_MEDIUM_DEVISE&&this.props.adaptive)}componentDidMount(){var a;this.observerResize=r.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.show&&this.forceUpdate(),(a=this.document)!=null&&a.body&&this.observerResize&&this.observerResize.observe(this.document.body)}componentDidUpdate(){this.shouldFocusCalendar&&this.focusCalendarElement(),this.shouldFocusDateInput&&this.focusDateInputElement(),this.shouldFocusCalendar=!1,this.shouldFocusDateInput=!1}componentWillUnmount(){var a;clearTimeout(this.nextTickId),(a=this.document)!=null&&a.body&&this.observerResize&&this.observerResize.disconnect()}render(){const{autoFocus:a,inputAttributes:e}=this.props,s=this.value||h.EMPTY_SELECTIONRANGE,o=this.mobileMode&&this.show?this.state.currentValue:s,m=(this.props.startDateInputSettings||{}).id||this._startInputId,w=(this.props.endDateInputSettings||{}).id||this._endInputId,E=r.classNames("k-daterangepicker",{"k-disabled":this.props.disabled},this.props.className),S=this.localizationService.toLanguageString(n.start,n.messages[n.start]),C=this.localizationService.toLanguageString(n.end,n.messages[n.end]),R=this.localizationService.toLanguageString(n.separator,n.messages[n.separator]),f={disableSelection:this.mobileMode&&!0,label:S,format:this.props.format,min:this.min,max:this.max,id:this._startInputId,disabled:this.props.disabled,valid:this.props.valid,tabIndex:this.props.tabIndex,ariaExpanded:this.show,clearButton:this.props.clearButton,...this.props.startDateInputSettings,value:o.start,onChange:this.handleStartChange,inputAttributes:this.props.inputAttributes},v={disableSelection:this.mobileMode&&!0,label:C,format:this.props.format,min:this.min,max:this.max,id:this._endInputId,disabled:this.props.disabled,valid:this.props.valid,tabIndex:this.props.tabIndex,ariaExpanded:this.show,clearButton:this.props.clearButton,...this.props.endDateInputSettings,value:o.end,onChange:this.handleEndChange,inputAttributes:this.props.inputAttributes},y=i.createElement(A.Button,{type:"button",className:"k-select",fillMode:"flat",title:c.provideLocalizationService(this).toLanguageString(n.swapStartEnd,n.messages[n.swapStartEnd]),onMouseDown:this.handleReverseMouseDown,onClick:this.handleReverseClick,"aria-controls":m+" "+w,"aria-label":c.provideLocalizationService(this).toLanguageString(n.swapStartEnd,n.messages[n.swapStartEnd])},i.createElement(r.IconWrap,{style:{transform:"rotate(90deg)"},name:"arrows-swap",icon:T.arrowsSwapIcon}));return i.createElement(i.Fragment,null,i.createElement("span",{ref:O=>{this._element=O},className:E,style:this.props.style,id:this.props.id,"aria-labelledby":this.props.ariaLabelledBy,"aria-describedby":this.props.ariaDescribedBy,tabIndex:this.props.tabIndex,onFocus:this.handleFocus,onClick:this.handleClick,onKeyDown:this.handleKeyDown,onBlur:this.mobileMode?void 0:this.handleBlur,dir:this.props.dir},this.props.startDateInput?i.createElement(this.props.startDateInput,{...f}):i.createElement(g.DateInput,{...f,autoFocus:a,ref:this._startDateInput,ariaRole:"combobox",ariaControls:this._popupId}),(this.props.allowReverse||this.props.calendarSettings&&this.props.calendarSettings.allowReverse)&&this.props.swapButton?y:R,this.props.endDateInput?i.createElement(this.props.endDateInput,{...v}):i.createElement(g.DateInput,{...v,ref:this._endDateInput,ariaRole:"combobox",ariaControls:this._popupId}),!this.mobileMode&&this.renderPopup()),this.mobileMode&&this.renderAdaptivePopup())}focusDateInputElement(){if(!document||!this.startDateInput||!this.startDateInput.element||!this.endDateInput||!this.endDateInput.element)return;const a=r.getActiveElement(document);(this.value.start===null||this.value.end!==null)&&a!==this.endDateInput.element?this.startDateInput.element.focus({preventScroll:!0}):a!==this.startDateInput.element&&this.endDateInput.element.focus({preventScroll:!0})}nextTick(a){clearTimeout(this.nextTickId),this.nextTickId=window.setTimeout(()=>a())}setShow(a){const{onOpen:e,onClose:s}=this.props;this.show!==a&&(this.setState({show:a}),a&&e&&e.call(void 0,{target:this}),!a&&s&&s.call(void 0,{target:this}))}calculateMedia(a){for(const e of a)this.setState({windowWidth:e.target.clientWidth})}};l.displayName="DateRangePicker",l.propTypes={allowReverse:t.bool,calendarSettings:t.any,className:t.string,defaultShow:t.bool,defaultValue:t.shape({start:u.nullable(t.instanceOf(Date).isRequired),end:u.nullable(t.instanceOf(Date).isRequired)}),disabled:t.bool,endDateInputSettings:t.shape(g.DateInputWithoutContext.propTypes),focusedDate:t.instanceOf(Date),format:t.oneOfType([t.string,t.shape({skeleton:t.string,pattern:t.string,date:t.oneOf(["short","medium","long","full"]),time:t.oneOf(["short","medium","long","full"]),datetime:t.oneOf(["short","medium","long","full"]),era:t.oneOf(["narrow","short","long"]),year:t.oneOf(["numeric","2-digit"]),month:t.oneOf(["numeric","2-digit","narrow","short","long"]),day:t.oneOf(["numeric","2-digit"]),weekday:t.oneOf(["narrow","short","long"]),hour:t.oneOf(["numeric","2-digit"]),hour12:t.bool,minute:t.oneOf(["numeric","2-digit"]),second:t.oneOf(["numeric","2-digit"]),timeZoneName:t.oneOf(["short","long"])})]),id:t.string,ariaLabelledBy:t.string,ariaDescribedBy:t.string,max:t.instanceOf(Date),min:t.instanceOf(Date),onBlur:t.func,onChange:t.func,onFocus:t.func,popupSettings:t.any,show:t.bool,startDateInputSettings:t.any,style:t.any,swapButton:t.any,tabIndex:t.number,dir:t.string,value:t.shape({start:u.nullable(t.instanceOf(Date).isRequired),end:u.nullable(t.instanceOf(Date).isRequired)}),autoFocus:t.bool,inputAttributes:t.object},l.defaultProps={allowReverse:!1,defaultShow:!1,defaultValue:h.EMPTY_SELECTIONRANGE,disabled:!1,format:"d",max:u.MAX_DATE,min:u.MIN_DATE,swapButton:!1,autoFocus:!1};let p=l;const I=r.createPropsContext(),b=r.withIdHOC(r.withPropsContext(I,p));b.displayName="KendoReactDateRangePicker";c.registerForLocalization(p);exports.DateRangePicker=b;exports.DateRangePickerPropsContext=I;exports.DateRangePickerWithoutContext=p;
|
|
@@ -8,21 +8,21 @@
|
|
|
8
8
|
"use client";
|
|
9
9
|
import * as i from "react";
|
|
10
10
|
import e from "prop-types";
|
|
11
|
-
import { Popup as
|
|
11
|
+
import { Popup as A } from "@progress/kendo-react-popup";
|
|
12
12
|
import { cloneDate as v } from "@progress/kendo-date-math";
|
|
13
|
-
import { classNames as D, Keys as c, validatePackage as
|
|
14
|
-
import { provideLocalizationService as m, registerForLocalization as
|
|
15
|
-
import { arrowsSwapIcon as
|
|
16
|
-
import { packageMetadata as
|
|
17
|
-
import { DateInputWithoutContext as
|
|
18
|
-
import { MultiViewCalendar as
|
|
13
|
+
import { classNames as D, Keys as c, validatePackage as F, canUseDOM as I, IconWrap as P, getActiveElement as B, createPropsContext as z, withIdHOC as N, withPropsContext as L } from "@progress/kendo-react-common";
|
|
14
|
+
import { provideLocalizationService as m, registerForLocalization as V } from "@progress/kendo-react-intl";
|
|
15
|
+
import { arrowsSwapIcon as K } from "@progress/kendo-svg-icons";
|
|
16
|
+
import { packageMetadata as U } from "../package-metadata.mjs";
|
|
17
|
+
import { DateInputWithoutContext as q, DateInput as w } from "../dateinput/DateInput.mjs";
|
|
18
|
+
import { MultiViewCalendar as W } from "../calendar/components/MultiViewCalendar.mjs";
|
|
19
19
|
import { EMPTY_SELECTIONRANGE as r } from "../calendar/models/SelectionRange.mjs";
|
|
20
|
-
import { nullable as h, MAX_DATE as
|
|
21
|
-
import { MOBILE_MEDIUM_DEVISE as
|
|
22
|
-
import { dateRangePickerCancel as b, messages as l, dateRangePickerSet as C, start as S, end as E, separator as y, swapStartEnd as
|
|
23
|
-
import { Button as
|
|
24
|
-
import { AdaptiveMode as
|
|
25
|
-
import { ActionSheetContent as
|
|
20
|
+
import { nullable as h, MAX_DATE as H, MIN_DATE as j } from "../utils.mjs";
|
|
21
|
+
import { MOBILE_MEDIUM_DEVISE as G } from "../common/constants.mjs";
|
|
22
|
+
import { dateRangePickerCancel as b, messages as l, dateRangePickerSet as C, start as S, end as E, separator as y, swapStartEnd as u } from "../messages/index.mjs";
|
|
23
|
+
import { Button as X } from "@progress/kendo-react-buttons";
|
|
24
|
+
import { AdaptiveMode as Y } from "../common/AdaptiveMode.mjs";
|
|
25
|
+
import { ActionSheetContent as Z } from "@progress/kendo-react-layout";
|
|
26
26
|
const o = class o extends i.Component {
|
|
27
27
|
constructor(a) {
|
|
28
28
|
super(a), this._element = null, this._calendar = null, this._startDateInput = i.createRef(), this._endDateInput = i.createRef(), this.shouldFocusDateInput = !1, this.shouldFocusCalendar = !1, this.focus = () => {
|
|
@@ -46,7 +46,7 @@ const o = class o extends i.Component {
|
|
|
46
46
|
dir: this.props.dir,
|
|
47
47
|
onChange: this.handleCalendarChange
|
|
48
48
|
};
|
|
49
|
-
return this.props.calendar ? /* @__PURE__ */ i.createElement(this.props.calendar, { ...s }) : /* @__PURE__ */ i.createElement(
|
|
49
|
+
return this.props.calendar ? /* @__PURE__ */ i.createElement(this.props.calendar, { ...s }) : /* @__PURE__ */ i.createElement(W, { ...s, ref: this.setCalendarRef });
|
|
50
50
|
}, this.renderPopup = () => {
|
|
51
51
|
const t = {
|
|
52
52
|
popupClass: D("k-calendar-container", "k-daterangepicker-popup"),
|
|
@@ -64,7 +64,7 @@ const o = class o extends i.Component {
|
|
|
64
64
|
...this.props.popupSettings,
|
|
65
65
|
show: this.show
|
|
66
66
|
};
|
|
67
|
-
return this.props.popup ? /* @__PURE__ */ i.createElement(this.props.popup, { ...t }, this.renderCalendar()) : /* @__PURE__ */ i.createElement(
|
|
67
|
+
return this.props.popup ? /* @__PURE__ */ i.createElement(this.props.popup, { ...t }, this.renderCalendar()) : /* @__PURE__ */ i.createElement(A, { ...t }, this.renderCalendar());
|
|
68
68
|
}, this.renderAdaptivePopup = () => {
|
|
69
69
|
const { windowWidth: t = 0 } = this.state, s = {
|
|
70
70
|
expand: this.show,
|
|
@@ -81,7 +81,7 @@ const o = class o extends i.Component {
|
|
|
81
81
|
onApply: this.handleBlur
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
|
-
return /* @__PURE__ */ i.createElement(
|
|
84
|
+
return /* @__PURE__ */ i.createElement(Y, { ...s }, /* @__PURE__ */ i.createElement(Z, { overflowHidden: !0 }, /* @__PURE__ */ i.createElement("div", { className: "k-scrollable-wrap" }, this.renderCalendar())));
|
|
85
85
|
}, this.handleReverseClick = (t) => {
|
|
86
86
|
const s = {
|
|
87
87
|
start: this.value.end,
|
|
@@ -141,17 +141,17 @@ const o = class o extends i.Component {
|
|
|
141
141
|
this.setState({ value: t }), this.valueDuringOnChange = t;
|
|
142
142
|
const { onChange: n } = this.props;
|
|
143
143
|
if (n) {
|
|
144
|
-
const
|
|
144
|
+
const d = {
|
|
145
145
|
syntheticEvent: s.syntheticEvent,
|
|
146
146
|
nativeEvent: s.nativeEvent,
|
|
147
147
|
value: this.value,
|
|
148
148
|
show: this.show,
|
|
149
149
|
target: this
|
|
150
150
|
};
|
|
151
|
-
n.call(void 0,
|
|
151
|
+
n.call(void 0, d);
|
|
152
152
|
}
|
|
153
153
|
this.valueDuringOnChange = void 0;
|
|
154
|
-
},
|
|
154
|
+
}, F(U), this.state = {
|
|
155
155
|
show: this.props.show || this.props.defaultShow || o.defaultProps.defaultShow,
|
|
156
156
|
value: this.props.value || this.props.defaultValue || o.defaultProps.defaultValue,
|
|
157
157
|
currentValue: r
|
|
@@ -219,7 +219,7 @@ const o = class o extends i.Component {
|
|
|
219
219
|
* The mobile mode of the DateRangePicker.
|
|
220
220
|
*/
|
|
221
221
|
get mobileMode() {
|
|
222
|
-
return !!(this.state.windowWidth && this.state.windowWidth <=
|
|
222
|
+
return !!(this.state.windowWidth && this.state.windowWidth <= G && this.props.adaptive);
|
|
223
223
|
}
|
|
224
224
|
/**
|
|
225
225
|
* @hidden
|
|
@@ -245,15 +245,15 @@ const o = class o extends i.Component {
|
|
|
245
245
|
* @hidden
|
|
246
246
|
*/
|
|
247
247
|
render() {
|
|
248
|
-
const a = this.value || r,
|
|
248
|
+
const { autoFocus: a, inputAttributes: t } = this.props, s = this.value || r, n = this.mobileMode && this.show ? this.state.currentValue : s, d = (this.props.startDateInputSettings || {}).id || this._startInputId, x = (this.props.endDateInputSettings || {}).id || this._endInputId, R = D(
|
|
249
249
|
"k-daterangepicker",
|
|
250
250
|
{
|
|
251
251
|
"k-disabled": this.props.disabled
|
|
252
252
|
},
|
|
253
253
|
this.props.className
|
|
254
|
-
),
|
|
254
|
+
), O = this.localizationService.toLanguageString(S, l[S]), k = this.localizationService.toLanguageString(E, l[E]), M = this.localizationService.toLanguageString(y, l[y]), f = {
|
|
255
255
|
disableSelection: this.mobileMode && !0,
|
|
256
|
-
label:
|
|
256
|
+
label: O,
|
|
257
257
|
format: this.props.format,
|
|
258
258
|
min: this.min,
|
|
259
259
|
max: this.max,
|
|
@@ -264,11 +264,12 @@ const o = class o extends i.Component {
|
|
|
264
264
|
ariaExpanded: this.show,
|
|
265
265
|
clearButton: this.props.clearButton,
|
|
266
266
|
...this.props.startDateInputSettings,
|
|
267
|
-
value:
|
|
268
|
-
onChange: this.handleStartChange
|
|
267
|
+
value: n.start,
|
|
268
|
+
onChange: this.handleStartChange,
|
|
269
|
+
inputAttributes: this.props.inputAttributes
|
|
269
270
|
}, g = {
|
|
270
271
|
disableSelection: this.mobileMode && !0,
|
|
271
|
-
label:
|
|
272
|
+
label: k,
|
|
272
273
|
format: this.props.format,
|
|
273
274
|
min: this.min,
|
|
274
275
|
max: this.max,
|
|
@@ -279,32 +280,33 @@ const o = class o extends i.Component {
|
|
|
279
280
|
ariaExpanded: this.show,
|
|
280
281
|
clearButton: this.props.clearButton,
|
|
281
282
|
...this.props.endDateInputSettings,
|
|
282
|
-
value:
|
|
283
|
-
onChange: this.handleEndChange
|
|
284
|
-
|
|
285
|
-
|
|
283
|
+
value: n.end,
|
|
284
|
+
onChange: this.handleEndChange,
|
|
285
|
+
inputAttributes: this.props.inputAttributes
|
|
286
|
+
}, T = /* @__PURE__ */ i.createElement(
|
|
287
|
+
X,
|
|
286
288
|
{
|
|
287
289
|
type: "button",
|
|
288
290
|
className: "k-select",
|
|
289
291
|
fillMode: "flat",
|
|
290
|
-
title: m(this).toLanguageString(
|
|
292
|
+
title: m(this).toLanguageString(u, l[u]),
|
|
291
293
|
onMouseDown: this.handleReverseMouseDown,
|
|
292
294
|
onClick: this.handleReverseClick,
|
|
293
|
-
"aria-controls":
|
|
295
|
+
"aria-controls": d + " " + x,
|
|
294
296
|
"aria-label": m(this).toLanguageString(
|
|
295
|
-
|
|
296
|
-
l[
|
|
297
|
+
u,
|
|
298
|
+
l[u]
|
|
297
299
|
)
|
|
298
300
|
},
|
|
299
|
-
/* @__PURE__ */ i.createElement(
|
|
301
|
+
/* @__PURE__ */ i.createElement(P, { style: { transform: "rotate(90deg)" }, name: "arrows-swap", icon: K })
|
|
300
302
|
);
|
|
301
303
|
return /* @__PURE__ */ i.createElement(i.Fragment, null, /* @__PURE__ */ i.createElement(
|
|
302
304
|
"span",
|
|
303
305
|
{
|
|
304
|
-
ref: (
|
|
305
|
-
this._element =
|
|
306
|
+
ref: (_) => {
|
|
307
|
+
this._element = _;
|
|
306
308
|
},
|
|
307
|
-
className:
|
|
309
|
+
className: R,
|
|
308
310
|
style: this.props.style,
|
|
309
311
|
id: this.props.id,
|
|
310
312
|
"aria-labelledby": this.props.ariaLabelledBy,
|
|
@@ -320,13 +322,13 @@ const o = class o extends i.Component {
|
|
|
320
322
|
w,
|
|
321
323
|
{
|
|
322
324
|
...f,
|
|
323
|
-
autoFocus:
|
|
325
|
+
autoFocus: a,
|
|
324
326
|
ref: this._startDateInput,
|
|
325
327
|
ariaRole: "combobox",
|
|
326
328
|
ariaControls: this._popupId
|
|
327
329
|
}
|
|
328
330
|
),
|
|
329
|
-
(this.props.allowReverse || this.props.calendarSettings && this.props.calendarSettings.allowReverse) && this.props.swapButton ?
|
|
331
|
+
(this.props.allowReverse || this.props.calendarSettings && this.props.calendarSettings.allowReverse) && this.props.swapButton ? T : M,
|
|
330
332
|
this.props.endDateInput ? /* @__PURE__ */ i.createElement(this.props.endDateInput, { ...g }) : /* @__PURE__ */ i.createElement(
|
|
331
333
|
w,
|
|
332
334
|
{
|
|
@@ -342,7 +344,7 @@ const o = class o extends i.Component {
|
|
|
342
344
|
focusDateInputElement() {
|
|
343
345
|
if (!document || !this.startDateInput || !this.startDateInput.element || !this.endDateInput || !this.endDateInput.element)
|
|
344
346
|
return;
|
|
345
|
-
const a =
|
|
347
|
+
const a = B(document);
|
|
346
348
|
(this.value.start === null || this.value.end !== null) && a !== this.endDateInput.element ? this.startDateInput.element.focus({ preventScroll: !0 }) : a !== this.startDateInput.element && this.endDateInput.element.focus({ preventScroll: !0 });
|
|
347
349
|
}
|
|
348
350
|
nextTick(a) {
|
|
@@ -371,7 +373,7 @@ o.displayName = "DateRangePicker", o.propTypes = {
|
|
|
371
373
|
end: h(e.instanceOf(Date).isRequired)
|
|
372
374
|
}),
|
|
373
375
|
disabled: e.bool,
|
|
374
|
-
endDateInputSettings: e.shape(
|
|
376
|
+
endDateInputSettings: e.shape(q.propTypes),
|
|
375
377
|
focusedDate: e.instanceOf(Date),
|
|
376
378
|
format: e.oneOfType([
|
|
377
379
|
e.string,
|
|
@@ -412,29 +414,30 @@ o.displayName = "DateRangePicker", o.propTypes = {
|
|
|
412
414
|
start: h(e.instanceOf(Date).isRequired),
|
|
413
415
|
end: h(e.instanceOf(Date).isRequired)
|
|
414
416
|
}),
|
|
415
|
-
autoFocus: e.bool
|
|
417
|
+
autoFocus: e.bool,
|
|
418
|
+
inputAttributes: e.object
|
|
416
419
|
}, o.defaultProps = {
|
|
417
420
|
allowReverse: !1,
|
|
418
421
|
defaultShow: !1,
|
|
419
422
|
defaultValue: r,
|
|
420
423
|
disabled: !1,
|
|
421
424
|
format: "d",
|
|
422
|
-
max:
|
|
423
|
-
min:
|
|
425
|
+
max: H,
|
|
426
|
+
min: j,
|
|
424
427
|
swapButton: !1,
|
|
425
428
|
autoFocus: !1
|
|
426
429
|
};
|
|
427
|
-
let
|
|
428
|
-
const
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
430
|
+
let p = o;
|
|
431
|
+
const J = z(), Q = N(
|
|
432
|
+
L(
|
|
433
|
+
J,
|
|
434
|
+
p
|
|
432
435
|
)
|
|
433
436
|
);
|
|
434
|
-
|
|
435
|
-
|
|
437
|
+
Q.displayName = "KendoReactDateRangePicker";
|
|
438
|
+
V(p);
|
|
436
439
|
export {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
+
Q as DateRangePicker,
|
|
441
|
+
J as DateRangePickerPropsContext,
|
|
442
|
+
p as DateRangePickerWithoutContext
|
|
440
443
|
};
|
|
@@ -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 $=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:M,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:M,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",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(),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 G=require("react"),e=require("prop-types"),J=require("@progress/kendo-react-popup"),T=require("@progress/kendo-date-math"),o=require("@progress/kendo-react-common"),Q=require("@progress/kendo-svg-icons"),ee=require("../dateinput/DateInput.js"),te=require("@progress/kendo-react-buttons"),ie=require("../package-metadata.js"),p=require("../utils.js"),se=require("../common/constants.js"),l=require("../messages/index.js"),m=require("@progress/kendo-react-intl"),oe=require("./DateTimeSelector.js"),ae=require("../timepicker/utils.js"),ne=require("../hooks/usePickerFloatingLabel.js"),re=require("../common/AdaptiveMode.js"),le=require("@progress/kendo-react-layout");function ue(h){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(h){for(const i in h)if(i!=="default"){const s=Object.getOwnPropertyDescriptor(h,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:()=>h[i]})}}return t.default=h,Object.freeze(t)}const r=ue(G),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:c,calendar:d,cancelButton:u,weekNumber:v,focusedDate:f,unstyled:w}=this.props;return r.createElement(oe.DateTimeSelector,{ref:b=>{this._dateTimeSelector=b},cancelButton:u,steps:this.props.steps,value:this.value,onChange:this.handleValueChange,onReject:this.handleReject,disabled:i,weekNumber:v,min:this.min,max:this.max,minTime:s,maxTime:n,focusedDate:f,format:c,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]),c={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(re.AdaptiveMode,{...c},r.createElement(le.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(ie.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<=se.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)&&ae.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,inputAttributes:c,disabled:d,tabIndex:u,title:v,id:f,format:w,formatPlaceholder:b,min:M,max:k,className:C,width:x,name:E,validationMessage:q,required:F,validityStyles:R,minTime:z,maxTime:A,ariaLabelledBy:B,ariaDescribedBy:N,popup:L=J.Popup,unstyled:y,autoFill:_,twoDigitYearMax:K,enableMouseWheel:V,autoCorrectParts:j,autoSwitchParts:U,autoSwitchKeys:H,allowCaretMode:W}=this.props,D=y&&y.uDateTimePicker,S=!this.validityStyles||this.validity.valid,X={id:f,ariaLabelledBy:B,ariaDescribedBy:N,format:w,formatPlaceholder:b,disabled:d,title:v,validityStyles:R,validationMessage:q,required:F,min:M,max:k,minTime:z,maxTime:A,name:E,tabIndex:this.show?-1:u,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:_,twoDigitYearMax:K,enableMouseWheel:V,autoCorrectParts:j,autoSwitchParts:U,autoSwitchKeys:H,allowCaretMode:W},I=r.createElement(o.AsyncFocusBlur,{onFocus:this.handleFocus,onBlur:this.handleBlur,onSyncFocus:this.props.onFocus,onSyncBlur:this.props.onBlur},({onFocus:Y,onBlur:Z})=>r.createElement(r.Fragment,null,r.createElement("div",{ref:$=>{this._element=$},className:o.classNames(o.uDateTimePicker.wrapper({c:D,size:t,fillMode:s,rounded:i,disabled:d,required:this.required,invalid:!S}),C),onKeyDown:this.handleKeyDown,style:{width:x},onFocus:this.mobileMode?void 0:Y,onBlur:Z,onClick:this.mobileMode?this.handleDateIconClick:void 0},r.createElement(this.dateInputComp,{_ref:this._dateInput,ariaRole:"combobox",ariaControls:this._popupId,ariaHasPopup:"dialog",autoFocus:n,inputAttributes:c,...X}),r.createElement(te.Button,{tabIndex:-1,type:"button",icon:"calendar",svgIcon:Q.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(L,{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(ne.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,inputAttributes:e.object},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:ee.DateInput,size:"medium",rounded:"medium",fillMode:"solid",autoFocus:!1};let g=a;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;
|