@progress/kendo-react-dateinputs 8.3.0-develop.8 → 8.3.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/calendar/components/Navigation.js +1 -1
- package/calendar/components/Navigation.mjs +14 -14
- package/calendar/components/ViewList.js +1 -1
- package/calendar/components/ViewList.mjs +27 -25
- package/dateinput/DateInput.js +1 -1
- package/dateinput/DateInput.mjs +63 -51
- package/datepicker/DatePicker.js +1 -1
- package/datepicker/DatePicker.mjs +29 -24
- package/datetimepicker/DateTimePicker.js +1 -1
- package/datetimepicker/DateTimePicker.mjs +24 -24
- package/datetimepicker/DateTimeSelector.js +1 -1
- package/datetimepicker/DateTimeSelector.mjs +66 -79
- package/dist/cdn/js/kendo-react-dateinputs.js +1 -1
- package/index.d.mts +3 -5
- package/index.d.ts +3 -5
- package/package-metadata.mjs +1 -1
- package/package.json +7 -7
- package/timepicker/TimePicker.js +1 -1
- package/timepicker/TimePicker.mjs +25 -26
- package/utils.js +1 -1
- package/utils.mjs +24 -31
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
import * as n from "react";
|
|
10
10
|
import e from "prop-types";
|
|
11
11
|
import { Popup as W } from "@progress/kendo-react-popup";
|
|
12
|
-
import { getDate as _, cloneDate as
|
|
13
|
-
import { classNames as
|
|
12
|
+
import { getDate as _, cloneDate as M } from "@progress/kendo-date-math";
|
|
13
|
+
import { classNames as k, Keys as r, validatePackage as K, canUseDOM as P, AsyncFocusBlur as U, kendoThemeMaps as T, createPropsContext as $, withIdHOC as H, withPropsContext as X } from "@progress/kendo-react-common";
|
|
14
14
|
import { calendarIcon as Z } from "@progress/kendo-svg-icons";
|
|
15
15
|
import { packageMetadata as j } from "../package-metadata.mjs";
|
|
16
16
|
import { DateInput as G } from "../dateinput/DateInput.mjs";
|
|
@@ -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 && _(d), u =
|
|
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 && _(d), u = k(
|
|
35
35
|
f
|
|
36
36
|
), b = {
|
|
37
37
|
popupClass: "k-datepicker-popup",
|
|
@@ -47,7 +47,8 @@ const o = class o extends n.Component {
|
|
|
47
47
|
horizontal: "left",
|
|
48
48
|
vertical: "top"
|
|
49
49
|
},
|
|
50
|
-
...g
|
|
50
|
+
...g,
|
|
51
|
+
onMouseDownOutside: this.handleMouseDownOutside
|
|
51
52
|
}, h = {
|
|
52
53
|
disabled: t,
|
|
53
54
|
value: w,
|
|
@@ -75,7 +76,7 @@ const o = class o extends n.Component {
|
|
|
75
76
|
this.handleValueChange(s, t);
|
|
76
77
|
}, this.handleValueChange = (t, s) => {
|
|
77
78
|
this.setState({
|
|
78
|
-
value:
|
|
79
|
+
value: M(t || void 0)
|
|
79
80
|
}), this.valueDuringOnChange = t, this.showDuringOnChange = !1, this.mobileMode || (this.shouldFocusDateInput = !0);
|
|
80
81
|
const { onChange: a } = this.props;
|
|
81
82
|
a && a.call(void 0, {
|
|
@@ -89,6 +90,11 @@ const o = class o extends n.Component {
|
|
|
89
90
|
this.setState({ focused: !0 });
|
|
90
91
|
}, this.handleBlur = () => {
|
|
91
92
|
this.setState({ focused: !1 }), this.setShow(!1);
|
|
93
|
+
}, this.togglePopup = () => {
|
|
94
|
+
this.setShow(!this.show);
|
|
95
|
+
}, this.handleMouseDownOutside = (t) => {
|
|
96
|
+
var s;
|
|
97
|
+
(s = this.props.popupSettings) != null && s.onMouseDownOutside && this.props.popupSettings.onMouseDownOutside.call(void 0, t);
|
|
92
98
|
}, this.handleIconClick = () => {
|
|
93
99
|
this.props.disabled || (this.shouldFocusDateInput = !0, this.setShow(!this.show));
|
|
94
100
|
}, this.handleIconMouseDown = (t) => {
|
|
@@ -142,7 +148,7 @@ const o = class o extends n.Component {
|
|
|
142
148
|
*/
|
|
143
149
|
get value() {
|
|
144
150
|
const i = this.valueDuringOnChange !== void 0 ? this.valueDuringOnChange : this.props.value !== void 0 ? this.props.value : this.state.value;
|
|
145
|
-
return i !== null ?
|
|
151
|
+
return i !== null ? M(i) : null;
|
|
146
152
|
}
|
|
147
153
|
/**
|
|
148
154
|
* Gets the popup state of the DatePickerWithoutContext.
|
|
@@ -200,7 +206,7 @@ const o = class o extends n.Component {
|
|
|
200
206
|
* @hidden
|
|
201
207
|
*/
|
|
202
208
|
get required() {
|
|
203
|
-
return this.props.required !== void 0 ? this.props.required :
|
|
209
|
+
return this.props.required !== void 0 ? this.props.required : !1;
|
|
204
210
|
}
|
|
205
211
|
/**
|
|
206
212
|
* @hidden
|
|
@@ -260,10 +266,10 @@ const o = class o extends n.Component {
|
|
|
260
266
|
toggleButton: Ie,
|
|
261
267
|
onChange: Ce,
|
|
262
268
|
onBlur: De,
|
|
263
|
-
onFocus:
|
|
264
|
-
show:
|
|
265
|
-
onOpen:
|
|
266
|
-
pickerWrap:
|
|
269
|
+
onFocus: Oe,
|
|
270
|
+
show: Se,
|
|
271
|
+
onOpen: Me,
|
|
272
|
+
pickerWrap: ke,
|
|
267
273
|
adaptive: Pe,
|
|
268
274
|
adaptiveTitle: Te,
|
|
269
275
|
valid: Ee,
|
|
@@ -273,7 +279,7 @@ const o = class o extends n.Component {
|
|
|
273
279
|
touched: Be,
|
|
274
280
|
modified: Fe,
|
|
275
281
|
...I
|
|
276
|
-
} = this.props, A = this.value, C = !this.validityStyles || this.validity.valid,
|
|
282
|
+
} = this.props, A = this.value, C = !this.validityStyles || this.validity.valid, L = {
|
|
277
283
|
disabled: a,
|
|
278
284
|
format: f,
|
|
279
285
|
formatPlaceholder: g,
|
|
@@ -298,7 +304,7 @@ const o = class o extends n.Component {
|
|
|
298
304
|
size: null,
|
|
299
305
|
fillMode: null,
|
|
300
306
|
rounded: null
|
|
301
|
-
}, D = se(this).toLanguageString(E, ie[E]),
|
|
307
|
+
}, D = se(this).toLanguageString(E, ie[E]), O = /* @__PURE__ */ n.createElement(
|
|
302
308
|
U,
|
|
303
309
|
{
|
|
304
310
|
onFocus: this.handleFocus,
|
|
@@ -306,14 +312,14 @@ const o = class o extends n.Component {
|
|
|
306
312
|
onSyncBlur: this.props.onBlur,
|
|
307
313
|
onSyncFocus: this.props.onFocus
|
|
308
314
|
},
|
|
309
|
-
(
|
|
315
|
+
(S) => /* @__PURE__ */ n.createElement(n.Fragment, null, /* @__PURE__ */ n.createElement(
|
|
310
316
|
"span",
|
|
311
317
|
{
|
|
312
318
|
...y ? {} : I,
|
|
313
|
-
ref: (
|
|
314
|
-
this._element =
|
|
319
|
+
ref: (q) => {
|
|
320
|
+
this._element = q;
|
|
315
321
|
},
|
|
316
|
-
className:
|
|
322
|
+
className: k(
|
|
317
323
|
"k-input",
|
|
318
324
|
"k-datepicker",
|
|
319
325
|
{
|
|
@@ -328,8 +334,8 @@ const o = class o extends n.Component {
|
|
|
328
334
|
),
|
|
329
335
|
onKeyDown: this.handleKeyDown,
|
|
330
336
|
style: { width: u },
|
|
331
|
-
onFocus:
|
|
332
|
-
onBlur:
|
|
337
|
+
onFocus: S.onFocus,
|
|
338
|
+
onBlur: S.onBlur,
|
|
333
339
|
onClick: this.mobileMode ? this.handleIconClick : void 0
|
|
334
340
|
},
|
|
335
341
|
/* @__PURE__ */ n.createElement(
|
|
@@ -341,7 +347,7 @@ const o = class o extends n.Component {
|
|
|
341
347
|
ariaExpanded: this.show,
|
|
342
348
|
ariaControls: this._popupId,
|
|
343
349
|
autoFocus: R,
|
|
344
|
-
...
|
|
350
|
+
...L
|
|
345
351
|
}
|
|
346
352
|
),
|
|
347
353
|
/* @__PURE__ */ n.createElement(
|
|
@@ -370,11 +376,11 @@ const o = class o extends n.Component {
|
|
|
370
376
|
editorId: l,
|
|
371
377
|
editorValid: C,
|
|
372
378
|
editorDisabled: a,
|
|
373
|
-
children:
|
|
379
|
+
children: O,
|
|
374
380
|
style: { width: u },
|
|
375
381
|
...I
|
|
376
382
|
}
|
|
377
|
-
) :
|
|
383
|
+
) : O;
|
|
378
384
|
}
|
|
379
385
|
setShow(i) {
|
|
380
386
|
const { onOpen: t, onClose: s } = this.props;
|
|
@@ -391,7 +397,7 @@ const o = class o extends n.Component {
|
|
|
391
397
|
clearTimeout(this.nextTickId), this.nextTickId = window.setTimeout(() => i());
|
|
392
398
|
}
|
|
393
399
|
calculateMedia(i) {
|
|
394
|
-
for (
|
|
400
|
+
for (const t of i)
|
|
395
401
|
this.setState({ windowWidth: t.target.clientWidth });
|
|
396
402
|
}
|
|
397
403
|
};
|
|
@@ -475,7 +481,6 @@ o.displayName = "DatePicker", o.propTypes = {
|
|
|
475
481
|
popupSettings: {},
|
|
476
482
|
tabIndex: 0,
|
|
477
483
|
weekNumber: !1,
|
|
478
|
-
required: !1,
|
|
479
484
|
validityStyles: !0,
|
|
480
485
|
size: "medium",
|
|
481
486
|
rounded: "medium",
|
|
@@ -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"),I=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}=this.props;return r.createElement(G.DateTimeSelector,{ref:w=>{this._dateTimeSelector=w},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})},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:I.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?I.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:n.defaultProps.required}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:O,max:k,className:M,width:C,name:x,validationMessage:q,required:E,validityStyles:R,minTime:F,maxTime:z,ariaLabelledBy:B,ariaDescribedBy:A,popup:N=U.Popup,unstyled:y}=this.props,b=y&&y.uDateTimePicker,D=!this.validityStyles||this.validity.valid,L={id:f,ariaLabelledBy:B,ariaDescribedBy:A,format:v,formatPlaceholder:w,disabled:h,title:u,validityStyles:R,validationMessage:q,required:E,min:O,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},S=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:b,size:t,fillMode:s,rounded:i,disabled:h,required:this.required,invalid:!D}),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,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:b})),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:b})),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:D,editorDisabled:this.props.disabled,children:S,style:{width:this.props.width}}):S}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,required:!1,validityStyles:!0,cancelButton:!0,dateInput:W.DateInput,size:"medium",rounded:"medium",fillMode:"solid",autoFocus:!1};let g=n;const T=o.createPropsContext(),P=o.withIdHOC(o.withPropsContext(T,o.withUnstyledHOC(g)));P.displayName="KendoReactDateTimePicker";m.registerForLocalization(g);exports.DateTimePicker=P;exports.DateTimePickerPropsContext=T;exports.DateTimePickerWithoutContext=g;
|
|
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"),I=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}=this.props;return r.createElement(G.DateTimeSelector,{ref:w=>{this._dateTimeSelector=w},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})},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:I.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?I.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:O,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,b=y&&y.uDateTimePicker,D=!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:O,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},S=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:b,size:t,fillMode:s,rounded:i,disabled:h,required:this.required,invalid:!D}),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:b})),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:b})),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:D,editorDisabled:this.props.disabled,children:S,style:{width:this.props.width}}):S}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 T=o.createPropsContext(),P=o.withIdHOC(o.withPropsContext(T,o.withUnstyledHOC(g)));P.displayName="KendoReactDateTimePicker";m.registerForLocalization(g);exports.DateTimePicker=P;exports.DateTimePickerPropsContext=T;exports.DateTimePickerWithoutContext=g;
|
|
@@ -10,7 +10,7 @@ import * as a from "react";
|
|
|
10
10
|
import e from "prop-types";
|
|
11
11
|
import { Popup as H } from "@progress/kendo-react-popup";
|
|
12
12
|
import { cloneDate as T } from "@progress/kendo-date-math";
|
|
13
|
-
import { Keys as
|
|
13
|
+
import { Keys as d, validatePackage as W, canUseDOM as O, AsyncFocusBlur as X, classNames as b, uDateTimePicker as y, createPropsContext as Z, withIdHOC as G, withPropsContext as J, withUnstyledHOC as Q } from "@progress/kendo-react-common";
|
|
14
14
|
import { calendarIcon as Y } from "@progress/kendo-svg-icons";
|
|
15
15
|
import { DateInput as $ } from "../dateinput/DateInput.mjs";
|
|
16
16
|
import { Button as ee } from "@progress/kendo-react-buttons";
|
|
@@ -19,8 +19,8 @@ import { MAX_DATE as ie, MIN_DATE as se, isInDateRange as oe, MAX_TIME as ne, MI
|
|
|
19
19
|
import { MOBILE_MEDIUM_DEVISE as re } from "../common/constants.mjs";
|
|
20
20
|
import { dateTimePickerCancel as M, messages as p, dateTimePickerSet as P, toggleDateTimeSelector as c } from "../messages/index.mjs";
|
|
21
21
|
import { provideLocalizationService as m, registerForLocalization as le } from "@progress/kendo-react-intl";
|
|
22
|
-
import { DateTimeSelector as
|
|
23
|
-
import { isInTimeRange as
|
|
22
|
+
import { DateTimeSelector as he } from "./DateTimeSelector.mjs";
|
|
23
|
+
import { isInTimeRange as de } from "../timepicker/utils.mjs";
|
|
24
24
|
import { PickerFloatingLabel as ue } from "../hooks/usePickerFloatingLabel.mjs";
|
|
25
25
|
import { AdaptiveMode as pe } from "../common/AdaptiveMode.mjs";
|
|
26
26
|
import { ActionSheetContent as ce } from "@progress/kendo-react-layout";
|
|
@@ -34,14 +34,14 @@ const o = class o extends a.Component {
|
|
|
34
34
|
disabled: i,
|
|
35
35
|
minTime: s,
|
|
36
36
|
maxTime: n,
|
|
37
|
-
format:
|
|
37
|
+
format: h,
|
|
38
38
|
calendar: l,
|
|
39
39
|
cancelButton: r,
|
|
40
40
|
weekNumber: u,
|
|
41
41
|
focusedDate: g
|
|
42
42
|
} = this.props;
|
|
43
43
|
return /* @__PURE__ */ a.createElement(
|
|
44
|
-
|
|
44
|
+
he,
|
|
45
45
|
{
|
|
46
46
|
ref: (v) => {
|
|
47
47
|
this._dateTimeSelector = v;
|
|
@@ -58,14 +58,14 @@ const o = class o extends a.Component {
|
|
|
58
58
|
minTime: s,
|
|
59
59
|
maxTime: n,
|
|
60
60
|
focusedDate: g,
|
|
61
|
-
format:
|
|
61
|
+
format: h,
|
|
62
62
|
calendar: l,
|
|
63
63
|
mobileMode: this.mobileMode,
|
|
64
64
|
footerActions: !this.mobileMode
|
|
65
65
|
}
|
|
66
66
|
);
|
|
67
67
|
}, this.renderAdaptivePopup = () => {
|
|
68
|
-
const { windowWidth: i = 0 } = this.state, s = m(this).toLanguageString(M, p[M]), n = m(this).toLanguageString(P, p[P]),
|
|
68
|
+
const { windowWidth: i = 0 } = this.state, s = m(this).toLanguageString(M, p[M]), n = m(this).toLanguageString(P, p[P]), h = {
|
|
69
69
|
expand: this.show,
|
|
70
70
|
onClose: this.handleBlur,
|
|
71
71
|
adaptiveTitle: this.props.adaptiveTitle,
|
|
@@ -83,7 +83,7 @@ const o = class o extends a.Component {
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
|
-
return /* @__PURE__ */ a.createElement(pe, { ...
|
|
86
|
+
return /* @__PURE__ */ a.createElement(pe, { ...h }, /* @__PURE__ */ a.createElement(ce, { overflowHidden: !0 }, this.renderPicker()));
|
|
87
87
|
}, this.handleReject = () => {
|
|
88
88
|
this.shouldFocusDateInput = !0, this.setShow(!1);
|
|
89
89
|
}, this.handleValueChange = (i) => {
|
|
@@ -108,11 +108,11 @@ const o = class o extends a.Component {
|
|
|
108
108
|
i.preventDefault();
|
|
109
109
|
}, this.handleKeyDown = (i) => {
|
|
110
110
|
const { altKey: s, keyCode: n } = i;
|
|
111
|
-
if (n ===
|
|
111
|
+
if (n === d.esc) {
|
|
112
112
|
this.shouldFocusDateInput = !0, this.setShow(!1);
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
|
-
s && (n ===
|
|
115
|
+
s && (n === d.up || n === d.down) && (i.preventDefault(), i.stopPropagation(), this.shouldFocusDateInput = n === d.up, this.setShow(n === d.down));
|
|
116
116
|
}, this.dateInputElement = () => this.dateInput && this.dateInput.element || this.element && this.element.querySelector(".k-dateinput > input.k-input-inner"), W(te), this.state = {
|
|
117
117
|
value: this.props.defaultValue || o.defaultProps.defaultValue,
|
|
118
118
|
show: this.props.defaultShow || o.defaultProps.defaultShow,
|
|
@@ -173,7 +173,7 @@ const o = class o extends a.Component {
|
|
|
173
173
|
* Represents the validity state into which the DateTimePicker is set.
|
|
174
174
|
*/
|
|
175
175
|
get validity() {
|
|
176
|
-
const t = oe(this.value, this.min, this.max) &&
|
|
176
|
+
const t = oe(this.value, this.min, this.max) && de(this.value, this.props.minTime || ae, this.props.maxTime || ne), i = this.props.validationMessage !== void 0, s = (!this.required || this.value !== null) && t, n = this.props.valid !== void 0 ? this.props.valid : s;
|
|
177
177
|
return {
|
|
178
178
|
customError: i,
|
|
179
179
|
rangeOverflow: this.value && this.max.getTime() < this.value.getTime() || !1,
|
|
@@ -192,7 +192,7 @@ const o = class o extends a.Component {
|
|
|
192
192
|
* @hidden
|
|
193
193
|
*/
|
|
194
194
|
get required() {
|
|
195
|
-
return this.props.required !== void 0 ? this.props.required :
|
|
195
|
+
return this.props.required !== void 0 ? this.props.required : !1;
|
|
196
196
|
}
|
|
197
197
|
/**
|
|
198
198
|
* @hidden
|
|
@@ -230,7 +230,7 @@ const o = class o extends a.Component {
|
|
|
230
230
|
rounded: i = o.defaultProps.rounded,
|
|
231
231
|
fillMode: s = o.defaultProps.fillMode,
|
|
232
232
|
autoFocus: n = o.defaultProps.autoFocus,
|
|
233
|
-
disabled:
|
|
233
|
+
disabled: h,
|
|
234
234
|
tabIndex: l,
|
|
235
235
|
title: r,
|
|
236
236
|
id: u,
|
|
@@ -246,17 +246,17 @@ const o = class o extends a.Component {
|
|
|
246
246
|
validityStyles: z,
|
|
247
247
|
minTime: A,
|
|
248
248
|
maxTime: N,
|
|
249
|
-
ariaLabelledBy:
|
|
250
|
-
ariaDescribedBy:
|
|
251
|
-
popup:
|
|
249
|
+
ariaLabelledBy: V,
|
|
250
|
+
ariaDescribedBy: L,
|
|
251
|
+
popup: _ = H,
|
|
252
252
|
unstyled: I
|
|
253
|
-
} = this.props, w = I && I.uDateTimePicker, D = !this.validityStyles || this.validity.valid,
|
|
253
|
+
} = this.props, w = I && I.uDateTimePicker, D = !this.validityStyles || this.validity.valid, q = {
|
|
254
254
|
id: u,
|
|
255
|
-
ariaLabelledBy:
|
|
256
|
-
ariaDescribedBy:
|
|
255
|
+
ariaLabelledBy: V,
|
|
256
|
+
ariaDescribedBy: L,
|
|
257
257
|
format: g,
|
|
258
258
|
formatPlaceholder: v,
|
|
259
|
-
disabled:
|
|
259
|
+
disabled: h,
|
|
260
260
|
title: r,
|
|
261
261
|
validityStyles: z,
|
|
262
262
|
validationMessage: R,
|
|
@@ -297,7 +297,7 @@ const o = class o extends a.Component {
|
|
|
297
297
|
size: t,
|
|
298
298
|
fillMode: s,
|
|
299
299
|
rounded: i,
|
|
300
|
-
disabled:
|
|
300
|
+
disabled: h,
|
|
301
301
|
required: this.required,
|
|
302
302
|
invalid: !D
|
|
303
303
|
}),
|
|
@@ -315,9 +315,10 @@ const o = class o extends a.Component {
|
|
|
315
315
|
_ref: this._dateInput,
|
|
316
316
|
ariaRole: "combobox",
|
|
317
317
|
ariaControls: this._popupId,
|
|
318
|
+
ariaHasPopup: "dialog",
|
|
318
319
|
readonly: this.mobileMode,
|
|
319
320
|
autoFocus: n,
|
|
320
|
-
...
|
|
321
|
+
...q
|
|
321
322
|
}
|
|
322
323
|
),
|
|
323
324
|
/* @__PURE__ */ a.createElement(
|
|
@@ -337,7 +338,7 @@ const o = class o extends a.Component {
|
|
|
337
338
|
}
|
|
338
339
|
),
|
|
339
340
|
/* @__PURE__ */ a.createElement(
|
|
340
|
-
|
|
341
|
+
_,
|
|
341
342
|
{
|
|
342
343
|
show: this.show,
|
|
343
344
|
animate: this.element !== null,
|
|
@@ -460,7 +461,6 @@ o.displayName = "DateTimePicker", o.propTypes = {
|
|
|
460
461
|
popupSettings: {},
|
|
461
462
|
tabIndex: 0,
|
|
462
463
|
weekNumber: !1,
|
|
463
|
-
required: !1,
|
|
464
464
|
validityStyles: !0,
|
|
465
465
|
cancelButton: !0,
|
|
466
466
|
dateInput: $,
|
|
@@ -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 E=require("react"),_=require("@progress/kendo-react-intl"),l=require("../messages/index.js"),p=require("@progress/kendo-react-buttons"),N=require("../calendar/components/Calendar.js"),B=require("../timepicker/TimePart.js"),
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("react"),_=require("@progress/kendo-react-intl"),l=require("../messages/index.js"),p=require("@progress/kendo-react-buttons"),N=require("../calendar/components/Calendar.js"),B=require("../timepicker/TimePart.js"),c=require("../utils.js"),y=require("@progress/kendo-date-math"),a=require("@progress/kendo-react-common"),b=require("../timepicker/utils.js");function V(d){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(d){for(const e in d)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(d,e);Object.defineProperty(s,e,t.get?t:{enumerable:!0,get:()=>d[e]})}}return s.default=d,Object.freeze(s)}const n=V(E),D=class D extends n.Component{constructor(s){super(s),this._calendar=null,this._timePart=null,this._cancelButton=null,this._acceptButton=null,this._dateButtonRef=null,this._calendarWrap=null,this.shouldFocusPart=!1,this.focus=e=>{Promise.resolve().then(()=>{this.state.tab==="time"&&this._timePart&&this._timePart.focus(e);const t=this.calendarElement();this.state.tab==="date"&&t&&t.focus(e)})},this.calendarElement=()=>this._calendar&&this._calendar.element||this._calendarWrap&&this._calendarWrap.querySelector(".k-calendar"),this.move=e=>{if(e==="right"&&this.state.tab==="time"||e==="left"&&this.state.tab==="date")return;const t=e==="left"?"date":"time";this.shouldFocusPart=!0,this.setState({tab:t})},this.dateTimeFooter=()=>{const{cancelButton:e,unstyled:t}=this.props,i=t&&t.uDateTimePicker,o=this.localizationService.toLanguageString(l.dateTimePickerCancel,l.messages[l.dateTimePickerCancel]),h=this.localizationService.toLanguageString(l.dateTimePickerSet,l.messages[l.dateTimePickerSet]);return n.createElement("div",{className:a.classNames(a.uDateTimePicker.timeFooter({c:i}))},e&&n.createElement(p.Button,{type:"button",ref:r=>{this._cancelButton=r},className:a.classNames(a.uTime.cancel({c:i})),onClick:this.handleReject,onKeyDown:this.handleCancelKeyDown,title:o,"aria-label":o},o),n.createElement(p.Button,{type:"button",themeColor:"primary",ref:r=>{this._acceptButton=r},className:a.classNames(a.uTime.accept({c:i})),disabled:!this.hasDateValue,onClick:this.handleAccept,onKeyDown:this.handleSetKeyDown,title:h,"aria-label":h},h))},this.handleReject=e=>{this.setState({dateValue:this.props.value,timeValue:this.props.value||c.MIDNIGHT_DATE});const t=this.mergeDate(this.props.value,this.props.value||c.MIDNIGHT_DATE);if(this.props.onReject){const i={nativeEvent:e.nativeEvent,syntheticEvent:e,target:this,value:t};this.props.onReject.call(void 0,i)}},this.handleAccept=(e,t)=>{if(!this.state.dateValue||!this.state.timeValue||!this.hasDateValue)return;const i=this.mergeDate(this.state.dateValue,t||this.state.timeValue);this.props.onChange.call(void 0,{syntheticEvent:e,nativeEvent:e.nativeEvent,value:i,target:this})},this.handleNowClick=e=>{this.setState({timeValue:b.getNow()}),this.handleAccept(e,b.getNow())},this.handleCalendarValueChange=e=>{e.syntheticEvent.stopPropagation(),this.setState({dateValue:e.value,tab:"time"}),this.shouldFocusPart=!0},this.handleTimeListContainerChange=e=>{this.setState({timeValue:e})},this.handleDateClick=e=>{e.stopPropagation(),this.move("left")},this.handleTimeClick=e=>{e.stopPropagation(),this.move("right")},this.handleKeyDown=e=>{const{keyCode:t,altKey:i}=e;if(!this.props.disabled)switch(t){case a.Keys.enter:!this.hasActiveButton()&&this.hasDateValue&&this.handleAccept(e);return;case a.Keys.left:if(!i)return;this.move("left");return;case a.Keys.right:if(!i)return;this.move("right");return;default:return}},this.handleCancelKeyDown=e=>{const{keyCode:t}=e;t===a.Keys.tab&&this._dateButtonRef&&this._dateButtonRef.element&&!this.hasDateValue&&(e.preventDefault(),this._dateButtonRef.element.focus())},this.handleSetKeyDown=e=>{const{keyCode:t}=e;t===a.Keys.tab&&this._dateButtonRef&&this._dateButtonRef.element&&(e.preventDefault(),this._dateButtonRef.element.focus())},this.handleDateKeyDown=e=>{var o,h,r,g;const{keyCode:t,shiftKey:i}=e;i&&t===a.Keys.tab&&(e.stopPropagation(),this.hasDateValue?(g=(r=this._acceptButton)==null?void 0:r.element)==null||g.focus():(h=(o=this._cancelButton)==null?void 0:o.element)==null||h.focus()),t===a.Keys.enter&&(e.stopPropagation(),this.move("left"))},this.handleTimeKeyDown=e=>{const{keyCode:t}=e;t===a.Keys.enter&&(e.stopPropagation(),this.move("right"))},this.handleTimePartMount=e=>{this.setState({timeValue:e})},this.state={tab:"date",dateValue:this.props.value,timeValue:this.props.value||c.MIDNIGHT_DATE}}get calendar(){return this._calendar}get timePart(){return this._timePart}get hasDateValue(){return this.state.dateValue!==null}get localizationService(){return _.provideLocalizationService(this)}componentDidUpdate(s,e){var t,i;this.shouldFocusPart&&this.focus({preventScroll:!0}),(((t=s.value)==null?void 0:t.getTime())!==((i=this.props.value)==null?void 0:i.getTime())||this.state.tab!==e.tab&&this.props.value)&&this.setState(o=>({dateValue:s.value&&this.props.value&&y.isEqualDate(s.value,this.props.value)?o.dateValue:this.props.value,timeValue:this.props.value||c.MIDNIGHT_DATE})),this.shouldFocusPart=!1}render(){const{disabled:s,min:e,max:t,weekNumber:i,focusedDate:o,format:h,mobileMode:r,footerActions:g,unstyled:v}=this.props,m=v&&v.uDateTimePicker,k=a.classNames(a.uDateTimePicker.wrap({c:m,date:this.state.tab==="date",time:this.state.tab==="time",disabled:s})),C=this.localizationService.toLanguageString(l.date,l.messages[l.date]),P=this.localizationService.toLanguageString(l.time,l.messages[l.time]),T={min:e,max:t,weekNumber:i,focusedDate:o,disabled:s||this.state.tab!=="date",value:this.state.dateValue,onChange:this.handleCalendarValueChange,navigation:!1,tabIndex:s||this.state.tab!=="date"?-1:void 0,mobileMode:r};return n.createElement("div",{onKeyDown:this.handleKeyDown,className:k,tabIndex:-1},n.createElement("div",{className:a.classNames(a.uDateTimePicker.buttonGroup({c:m}))},n.createElement(p.ButtonGroup,{width:"100%"},n.createElement(p.Button,{ref:u=>this._dateButtonRef=u,type:"button",selected:this.state.tab==="date",togglable:!0,onClick:this.handleDateClick,onKeyDown:this.handleDateKeyDown},C),n.createElement(p.Button,{type:"button",selected:this.state.tab==="time",togglable:!0,onClick:this.handleTimeClick,onKeyDown:this.handleTimeKeyDown},P))),n.createElement("div",{className:a.classNames(a.uDateTimePicker.selector({c:m}))},n.createElement("div",{className:a.classNames(a.uDateTimePicker.calendarWrap({c:m})),ref:u=>this._calendarWrap=u},this.props.calendar?n.createElement(this.props.calendar,{key:this.state.tab,...T}):n.createElement(N.Calendar,{key:this.state.tab,ref:u=>{this._calendar=u},...T})),n.createElement("div",{className:a.classNames(a.uDateTimePicker.timeWrap({c:m}))},n.createElement("div",{className:a.classNames(a.uDateTimePicker.timeSelector({c:m,mobileMode:r}))},n.createElement(B.TimePart,{key:1,onNowClick:this.handleNowClick,disabled:s||this.state.tab!=="time",ref:u=>{this._timePart=u},min:this.minTime||c.MIN_TIME,max:this.maxTime||c.MAX_TIME,steps:this.props.steps,value:this.state.timeValue,format:h,onChange:this.handleTimeListContainerChange,onMount:this.handleTimePartMount,mobileMode:r,unstyled:v})))),g&&this.dateTimeFooter())}get minTime(){return this.props.minTime!==void 0?this.props.minTime:this.normalizeRange(this.props.min,this.state.dateValue)}get maxTime(){return this.props.maxTime!==void 0?this.props.maxTime:this.normalizeRange(this.props.max,this.state.dateValue)}normalizeRange(s,e){return y.isEqualDate(s,e||c.getToday())?s:null}hasActiveButton(){if(!this._acceptButton)return!1;const s=a.getActiveElement(document);return this._acceptButton&&s===this._acceptButton.element||this._cancelButton&&s===this._cancelButton.element}mergeTime(s,e){return s&&e?c.setTime(e,s):e}mergeDate(s,e){return s?c.setTime(s||c.getToday(),e):e}};D.defaultProps={footerActions:!0};let f=D;_.registerForLocalization(f);exports.DateTimeSelector=f;
|
|
@@ -14,7 +14,7 @@ import { Calendar as A } from "../calendar/components/Calendar.mjs";
|
|
|
14
14
|
import { TimePart as z } from "../timepicker/TimePart.mjs";
|
|
15
15
|
import { MIDNIGHT_DATE as g, MIN_TIME as F, MAX_TIME as L, getToday as V, setTime as P } from "../utils.mjs";
|
|
16
16
|
import { isEqualDate as k } from "@progress/kendo-date-math";
|
|
17
|
-
import { classNames as
|
|
17
|
+
import { classNames as l, uDateTimePicker as u, uTime as B, Keys as h, getActiveElement as I } from "@progress/kendo-react-common";
|
|
18
18
|
import { getNow as w } from "../timepicker/utils.mjs";
|
|
19
19
|
const y = class y extends i.Component {
|
|
20
20
|
constructor(a) {
|
|
@@ -30,30 +30,30 @@ const y = class y extends i.Component {
|
|
|
30
30
|
const e = t === "left" ? "date" : "time";
|
|
31
31
|
this.shouldFocusPart = !0, this.setState({ tab: e });
|
|
32
32
|
}, this.dateTimeFooter = () => {
|
|
33
|
-
const { cancelButton: t, unstyled: e } = this.props, s = e && e.uDateTimePicker,
|
|
34
|
-
return /* @__PURE__ */ i.createElement("div", { className:
|
|
33
|
+
const { cancelButton: t, unstyled: e } = this.props, s = e && e.uDateTimePicker, n = this.localizationService.toLanguageString(D, p[D]), r = this.localizationService.toLanguageString(_, p[_]);
|
|
34
|
+
return /* @__PURE__ */ i.createElement("div", { className: l(u.timeFooter({ c: s })) }, t && /* @__PURE__ */ i.createElement(
|
|
35
35
|
f,
|
|
36
36
|
{
|
|
37
37
|
type: "button",
|
|
38
|
-
ref: (
|
|
39
|
-
this._cancelButton =
|
|
38
|
+
ref: (o) => {
|
|
39
|
+
this._cancelButton = o;
|
|
40
40
|
},
|
|
41
|
-
className:
|
|
41
|
+
className: l(B.cancel({ c: s })),
|
|
42
42
|
onClick: this.handleReject,
|
|
43
43
|
onKeyDown: this.handleCancelKeyDown,
|
|
44
|
-
title:
|
|
45
|
-
"aria-label":
|
|
44
|
+
title: n,
|
|
45
|
+
"aria-label": n
|
|
46
46
|
},
|
|
47
|
-
|
|
47
|
+
n
|
|
48
48
|
), /* @__PURE__ */ i.createElement(
|
|
49
49
|
f,
|
|
50
50
|
{
|
|
51
51
|
type: "button",
|
|
52
52
|
themeColor: "primary",
|
|
53
|
-
ref: (
|
|
54
|
-
this._acceptButton =
|
|
53
|
+
ref: (o) => {
|
|
54
|
+
this._acceptButton = o;
|
|
55
55
|
},
|
|
56
|
-
className:
|
|
56
|
+
className: l(B.accept({ c: s })),
|
|
57
57
|
disabled: !this.hasDateValue,
|
|
58
58
|
onClick: this.handleAccept,
|
|
59
59
|
onKeyDown: this.handleSetKeyDown,
|
|
@@ -121,9 +121,9 @@ const y = class y extends i.Component {
|
|
|
121
121
|
const { keyCode: e } = t;
|
|
122
122
|
e === h.tab && this._dateButtonRef && this._dateButtonRef.element && (t.preventDefault(), this._dateButtonRef.element.focus());
|
|
123
123
|
}, this.handleDateKeyDown = (t) => {
|
|
124
|
-
var
|
|
124
|
+
var n, r, o, d;
|
|
125
125
|
const { keyCode: e, shiftKey: s } = t;
|
|
126
|
-
s && e === h.tab && (t.stopPropagation(), this.hasDateValue ? (d = (
|
|
126
|
+
s && e === h.tab && (t.stopPropagation(), this.hasDateValue ? (d = (o = this._acceptButton) == null ? void 0 : o.element) == null || d.focus() : (r = (n = this._cancelButton) == null ? void 0 : n.element) == null || r.focus()), e === h.enter && (t.stopPropagation(), this.move("left"));
|
|
127
127
|
}, this.handleTimeKeyDown = (t) => {
|
|
128
128
|
const { keyCode: e } = t;
|
|
129
129
|
e === h.enter && (t.stopPropagation(), this.move("right"));
|
|
@@ -149,23 +149,13 @@ const y = class y extends i.Component {
|
|
|
149
149
|
}
|
|
150
150
|
componentDidUpdate(a, t) {
|
|
151
151
|
var e, s;
|
|
152
|
-
this.shouldFocusPart && this.focus({ preventScroll: !0 }), (((e = a.value) == null ? void 0 : e.getTime()) !== ((s = this.props.value) == null ? void 0 : s.getTime()) || this.state.tab !== t.tab && this.props.value) && this.setState({
|
|
153
|
-
dateValue: a.value && this.props.value && k(a.value, this.props.value) ?
|
|
152
|
+
this.shouldFocusPart && this.focus({ preventScroll: !0 }), (((e = a.value) == null ? void 0 : e.getTime()) !== ((s = this.props.value) == null ? void 0 : s.getTime()) || this.state.tab !== t.tab && this.props.value) && this.setState((n) => ({
|
|
153
|
+
dateValue: a.value && this.props.value && k(a.value, this.props.value) ? n.dateValue : this.props.value,
|
|
154
154
|
timeValue: this.props.value || g
|
|
155
|
-
}), this.shouldFocusPart = !1;
|
|
155
|
+
})), this.shouldFocusPart = !1;
|
|
156
156
|
}
|
|
157
157
|
render() {
|
|
158
|
-
const {
|
|
159
|
-
disabled: a,
|
|
160
|
-
min: t,
|
|
161
|
-
max: e,
|
|
162
|
-
weekNumber: s,
|
|
163
|
-
focusedDate: l,
|
|
164
|
-
format: r,
|
|
165
|
-
mobileMode: n,
|
|
166
|
-
footerActions: d,
|
|
167
|
-
unstyled: v
|
|
168
|
-
} = this.props, m = v && v.uDateTimePicker, S = o(
|
|
158
|
+
const { disabled: a, min: t, max: e, weekNumber: s, focusedDate: n, format: r, mobileMode: o, footerActions: d, unstyled: v } = this.props, m = v && v.uDateTimePicker, S = l(
|
|
169
159
|
u.wrap({
|
|
170
160
|
c: m,
|
|
171
161
|
date: this.state.tab === "date",
|
|
@@ -176,44 +166,42 @@ const y = class y extends i.Component {
|
|
|
176
166
|
min: t,
|
|
177
167
|
max: e,
|
|
178
168
|
weekNumber: s,
|
|
179
|
-
focusedDate:
|
|
169
|
+
focusedDate: n,
|
|
180
170
|
disabled: a || this.state.tab !== "date",
|
|
181
171
|
value: this.state.dateValue,
|
|
182
172
|
onChange: this.handleCalendarValueChange,
|
|
183
173
|
navigation: !1,
|
|
184
174
|
tabIndex: a || this.state.tab !== "date" ? -1 : void 0,
|
|
185
|
-
mobileMode:
|
|
175
|
+
mobileMode: o
|
|
186
176
|
};
|
|
187
|
-
return /* @__PURE__ */ i.createElement(
|
|
177
|
+
return /* @__PURE__ */ i.createElement("div", { onKeyDown: this.handleKeyDown, className: S, tabIndex: -1 }, /* @__PURE__ */ i.createElement("div", { className: l(u.buttonGroup({ c: m })) }, /* @__PURE__ */ i.createElement(x, { width: "100%" }, /* @__PURE__ */ i.createElement(
|
|
178
|
+
f,
|
|
179
|
+
{
|
|
180
|
+
ref: (c) => this._dateButtonRef = c,
|
|
181
|
+
type: "button",
|
|
182
|
+
selected: this.state.tab === "date",
|
|
183
|
+
togglable: !0,
|
|
184
|
+
onClick: this.handleDateClick,
|
|
185
|
+
onKeyDown: this.handleDateKeyDown
|
|
186
|
+
},
|
|
187
|
+
K
|
|
188
|
+
), /* @__PURE__ */ i.createElement(
|
|
189
|
+
f,
|
|
190
|
+
{
|
|
191
|
+
type: "button",
|
|
192
|
+
selected: this.state.tab === "time",
|
|
193
|
+
togglable: !0,
|
|
194
|
+
onClick: this.handleTimeClick,
|
|
195
|
+
onKeyDown: this.handleTimeKeyDown
|
|
196
|
+
},
|
|
197
|
+
N
|
|
198
|
+
))), /* @__PURE__ */ i.createElement("div", { className: l(u.selector({ c: m })) }, /* @__PURE__ */ i.createElement(
|
|
188
199
|
"div",
|
|
189
200
|
{
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
tabIndex: -1
|
|
201
|
+
className: l(u.calendarWrap({ c: m })),
|
|
202
|
+
ref: (c) => this._calendarWrap = c
|
|
193
203
|
},
|
|
194
|
-
/* @__PURE__ */ i.createElement(
|
|
195
|
-
f,
|
|
196
|
-
{
|
|
197
|
-
ref: (c) => this._dateButtonRef = c,
|
|
198
|
-
type: "button",
|
|
199
|
-
selected: this.state.tab === "date",
|
|
200
|
-
togglable: !0,
|
|
201
|
-
onClick: this.handleDateClick,
|
|
202
|
-
onKeyDown: this.handleDateKeyDown
|
|
203
|
-
},
|
|
204
|
-
K
|
|
205
|
-
), /* @__PURE__ */ i.createElement(
|
|
206
|
-
f,
|
|
207
|
-
{
|
|
208
|
-
type: "button",
|
|
209
|
-
selected: this.state.tab === "time",
|
|
210
|
-
togglable: !0,
|
|
211
|
-
onClick: this.handleTimeClick,
|
|
212
|
-
onKeyDown: this.handleTimeKeyDown
|
|
213
|
-
},
|
|
214
|
-
N
|
|
215
|
-
))),
|
|
216
|
-
/* @__PURE__ */ i.createElement("div", { className: o(u.selector({ c: m })) }, /* @__PURE__ */ i.createElement("div", { className: o(u.calendarWrap({ c: m })), ref: (c) => this._calendarWrap = c }, this.props.calendar ? /* @__PURE__ */ i.createElement(this.props.calendar, { key: this.state.tab, ...C }) : /* @__PURE__ */ i.createElement(
|
|
204
|
+
this.props.calendar ? /* @__PURE__ */ i.createElement(this.props.calendar, { key: this.state.tab, ...C }) : /* @__PURE__ */ i.createElement(
|
|
217
205
|
A,
|
|
218
206
|
{
|
|
219
207
|
key: this.state.tab,
|
|
@@ -222,28 +210,27 @@ const y = class y extends i.Component {
|
|
|
222
210
|
},
|
|
223
211
|
...C
|
|
224
212
|
}
|
|
225
|
-
)
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
);
|
|
213
|
+
)
|
|
214
|
+
), /* @__PURE__ */ i.createElement("div", { className: l(u.timeWrap({ c: m })) }, /* @__PURE__ */ i.createElement("div", { className: l(u.timeSelector({ c: m, mobileMode: o })) }, /* @__PURE__ */ i.createElement(
|
|
215
|
+
z,
|
|
216
|
+
{
|
|
217
|
+
key: 1,
|
|
218
|
+
onNowClick: this.handleNowClick,
|
|
219
|
+
disabled: a || this.state.tab !== "time",
|
|
220
|
+
ref: (c) => {
|
|
221
|
+
this._timePart = c;
|
|
222
|
+
},
|
|
223
|
+
min: this.minTime || F,
|
|
224
|
+
max: this.maxTime || L,
|
|
225
|
+
steps: this.props.steps,
|
|
226
|
+
value: this.state.timeValue,
|
|
227
|
+
format: r,
|
|
228
|
+
onChange: this.handleTimeListContainerChange,
|
|
229
|
+
onMount: this.handleTimePartMount,
|
|
230
|
+
mobileMode: o,
|
|
231
|
+
unstyled: v
|
|
232
|
+
}
|
|
233
|
+
)))), d && this.dateTimeFooter());
|
|
247
234
|
}
|
|
248
235
|
get minTime() {
|
|
249
236
|
return this.props.minTime !== void 0 ? this.props.minTime : this.normalizeRange(this.props.min, this.state.dateValue);
|