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