@progress/kendo-react-dateinputs 14.3.3-develop.2 → 14.4.0-develop.10
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/NOTICE.txt +366 -82
- package/dateinput/DateInput.js +1 -1
- package/dateinput/DateInput.mjs +36 -36
- package/datepicker/DatePicker.js +1 -1
- package/datepicker/DatePicker.mjs +1 -1
- package/daterangepicker/DateRangePicker.js +1 -1
- package/daterangepicker/DateRangePicker.mjs +10 -10
- package/datetimepicker/DateTimePicker.js +1 -1
- package/datetimepicker/DateTimePicker.mjs +1 -1
- package/datetimepicker/DateTimeSelector.js +1 -1
- package/datetimepicker/DateTimeSelector.mjs +75 -73
- package/dist/cdn/js/kendo-react-dateinputs.js +1 -1
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +8 -8
- package/timepicker/TimePicker.js +1 -1
- package/timepicker/TimePicker.mjs +1 -1
package/dateinput/DateInput.mjs
CHANGED
|
@@ -7,23 +7,23 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import * as r from "react";
|
|
9
9
|
import e from "prop-types";
|
|
10
|
-
import { cloneDate as
|
|
10
|
+
import { cloneDate as T, isEqual as ke } from "@progress/kendo-date-math";
|
|
11
11
|
import { Button as $ } from "@progress/kendo-react-buttons";
|
|
12
12
|
import { caretAltUpIcon as _e, caretAltDownIcon as Fe } from "@progress/kendo-svg-icons";
|
|
13
13
|
import { useInternationalization as He, useLocalization as Be } from "@progress/kendo-react-intl";
|
|
14
|
-
import { useId as qe, useUnstyled as ze, usePropsContext as Q, classNames as h, uDateInput as O, createPropsContext as
|
|
15
|
-
import { FloatingLabel as
|
|
16
|
-
import { DateInput as
|
|
14
|
+
import { useId as qe, useUnstyled as ze, usePropsContext as Q, classNames as h, uDateInput as O, createPropsContext as je, getActiveElement as ee } from "@progress/kendo-react-common";
|
|
15
|
+
import { FloatingLabel as Ue } from "@progress/kendo-react-labels";
|
|
16
|
+
import { DateInput as We } from "@progress/kendo-dateinputs-common";
|
|
17
17
|
import { DEFAULT_FORMAT_PLACEHOLDER as Ke, DEFAULT_FORMAT as Je, isInRange as Ye } from "./utils.mjs";
|
|
18
18
|
import { MAX_TIME as Xe, MIN_TIME as Ze, MIN_DATE as Ge, MAX_DATE as $e, nullable as u } from "../utils.mjs";
|
|
19
|
-
import { increaseValue as
|
|
19
|
+
import { increaseValue as M, messages as S, decreaseValue as P } from "../messages/index.mjs";
|
|
20
20
|
import { isInTimeRange as Qe } from "../timepicker/utils.mjs";
|
|
21
21
|
import et from "../common/ClearButton.mjs";
|
|
22
22
|
import { DateInputIntl as tt } from "./dateInputIntl.mjs";
|
|
23
23
|
const nt = "Please enter a valid value!", ne = r.forwardRef((t, re) => {
|
|
24
24
|
var G;
|
|
25
25
|
const ae = qe(t.id), ie = He(), E = Be(), oe = ze(), F = Q(te, t).unstyled || oe, {
|
|
26
|
-
format:
|
|
26
|
+
format: R = o.format,
|
|
27
27
|
size: le = o.size,
|
|
28
28
|
rounded: ue = o.rounded,
|
|
29
29
|
fillMode: se = o.fillMode,
|
|
@@ -44,10 +44,10 @@ const nt = "Please enter a valid value!", ne = r.forwardRef((t, re) => {
|
|
|
44
44
|
twoDigitYearMax: Ie = o.twoDigitYearMax,
|
|
45
45
|
ariaHasPopup: xe = o.ariaHasPopup,
|
|
46
46
|
autoFocus: g = o.autoFocus
|
|
47
|
-
} = Q(te, t), d = () =>
|
|
47
|
+
} = Q(te, t), d = () => D.current !== void 0 ? D.current : a.current && a.current.value, B = () => {
|
|
48
48
|
const n = a.current && a.current.currentText || "", i = d();
|
|
49
49
|
return m != null && !Ae.focused && !i ? m : n;
|
|
50
|
-
}, q = () => t.required !== void 0 ? t.required : !1,
|
|
50
|
+
}, q = () => t.required !== void 0 ? t.required : !1, L = () => {
|
|
51
51
|
const n = d() || t.value, i = fe, b = me, V = Ye(n, i, b) && Qe(n, ge, ve), k = H !== void 0, _ = (!q() || n != null) && V, Ve = t.valid !== void 0 ? t.valid : _;
|
|
52
52
|
return {
|
|
53
53
|
customError: k,
|
|
@@ -61,7 +61,7 @@ const nt = "Please enter a valid value!", ne = r.forwardRef((t, re) => {
|
|
|
61
61
|
}, z = () => new tt(ie), x = () => {
|
|
62
62
|
const n = d();
|
|
63
63
|
return {
|
|
64
|
-
format:
|
|
64
|
+
format: R,
|
|
65
65
|
steps: t.steps,
|
|
66
66
|
formatPlaceholder: ce,
|
|
67
67
|
placeholder: m,
|
|
@@ -83,24 +83,24 @@ const nt = "Please enter a valid value!", ne = r.forwardRef((t, re) => {
|
|
|
83
83
|
}, Te = (n, i) => typeof n != typeof i ? !0 : typeof n == "string" && typeof i == "string" ? n !== i : typeof n == "object" && typeof i == "object" ? JSON.stringify(n) !== JSON.stringify(i) : !1, Me = (n) => typeof n == "string" ? n : {
|
|
84
84
|
inputFormat: n,
|
|
85
85
|
displayFormat: n
|
|
86
|
+
}, j = (n) => {
|
|
87
|
+
D.current = d(), Ne(), f.current = n, D.current = void 0;
|
|
86
88
|
}, U = (n) => {
|
|
87
|
-
w.current = d(), Ne(), f.current = n, w.current = void 0;
|
|
88
|
-
}, W = (n) => {
|
|
89
89
|
t.onChange && t.onChange(n);
|
|
90
|
-
},
|
|
90
|
+
}, W = (n) => {
|
|
91
91
|
ee(document) === l.current && n.preventDefault();
|
|
92
|
-
}, Se = () => new
|
|
92
|
+
}, Se = () => new We(l.current, {
|
|
93
93
|
...x(),
|
|
94
94
|
format: Me(x().format),
|
|
95
95
|
events: {
|
|
96
96
|
focus: we,
|
|
97
97
|
blur: De,
|
|
98
|
-
valueChange:
|
|
99
|
-
click:
|
|
98
|
+
valueChange: j,
|
|
99
|
+
click: U
|
|
100
100
|
}
|
|
101
101
|
}), K = () => {
|
|
102
102
|
l.current && l.current.setCustomValidity && l.current.setCustomValidity(
|
|
103
|
-
|
|
103
|
+
L().valid ? "" : H || o.validationMessage
|
|
104
104
|
);
|
|
105
105
|
}, J = r.useCallback(
|
|
106
106
|
(n) => {
|
|
@@ -112,7 +112,7 @@ const nt = "Please enter a valid value!", ne = r.forwardRef((t, re) => {
|
|
|
112
112
|
},
|
|
113
113
|
[g]
|
|
114
114
|
), Pe = (n) => {
|
|
115
|
-
!l.current || !a.current ||
|
|
115
|
+
!l.current || !a.current || j(n);
|
|
116
116
|
}, Re = (n) => {
|
|
117
117
|
n.preventDefault();
|
|
118
118
|
const i = ee(document);
|
|
@@ -152,28 +152,28 @@ const nt = "Please enter a valid value!", ne = r.forwardRef((t, re) => {
|
|
|
152
152
|
return d();
|
|
153
153
|
},
|
|
154
154
|
get validity() {
|
|
155
|
-
return
|
|
155
|
+
return L();
|
|
156
156
|
},
|
|
157
157
|
// hidden methods
|
|
158
158
|
focus: Ce,
|
|
159
159
|
updateOnPaste: Pe
|
|
160
160
|
})
|
|
161
161
|
), r.useImperativeHandle(re, () => C.current);
|
|
162
|
-
const a = r.useRef(null),
|
|
162
|
+
const a = r.useRef(null), w = r.useRef(null), p = r.useRef(!1), D = r.useRef(null), f = r.useRef(null), v = r.useRef(t), [Ae, A] = r.useState({ focused: !1 }), [, Ne] = r.useReducer((n) => n + 1, 0);
|
|
163
163
|
r.useLayoutEffect(() => {
|
|
164
|
-
p.current || (a.current = Se(),
|
|
165
|
-
}, []), r.useEffect(() => (K(), p.current || s.current && s.current.addEventListener("wheel",
|
|
166
|
-
s.current && s.current.removeEventListener("wheel",
|
|
164
|
+
p.current || (a.current = Se(), w.current = a.current.dateObject, p.current = !0);
|
|
165
|
+
}, []), r.useEffect(() => (K(), p.current || s.current && s.current.addEventListener("wheel", W, { passive: !1 }), g && (A({ focused: !0 }), J(!0)), () => {
|
|
166
|
+
s.current && s.current.removeEventListener("wheel", W);
|
|
167
167
|
}), []), r.useEffect(() => {
|
|
168
|
-
K(), a.current && ((Te(v.current.format,
|
|
169
|
-
format:
|
|
168
|
+
K(), a.current && (w.current = a.current.dateObject, (Te(v.current.format, R) || v.current.readonly !== t.readonly || JSON.stringify(v.current.steps) !== JSON.stringify(t.steps) || z().locale !== a.current.options.intlService.locale) && a.current.setOptions(x(), !0), v.current.value !== t.value && (w.current.getValue() !== null || t.value !== null) && w.current.setValue(t.value), t.ariaExpanded !== void 0 && t.ariaExpanded && (a.current.options.placeholder = null), t.ariaExpanded !== void 0 && !t.ariaExpanded && (a.current.options.placeholder = m), a.current.refreshElementValue(), v.current = {
|
|
169
|
+
format: R,
|
|
170
170
|
readonly: t.readonly,
|
|
171
171
|
ariaExpanded: t.ariaExpanded,
|
|
172
172
|
steps: t.steps,
|
|
173
173
|
value: t.value
|
|
174
174
|
});
|
|
175
175
|
});
|
|
176
|
-
const Y = t.id || ae + "-accessibility-id", y = F && F.uDateInput, X = B(), N = !ye ||
|
|
176
|
+
const Y = t.id || ae + "-accessibility-id", y = F && F.uDateInput, X = B(), N = !ye || L().valid;
|
|
177
177
|
r.useImperativeHandle(t._ref, () => C.current);
|
|
178
178
|
const Z = /* @__PURE__ */ r.createElement(
|
|
179
179
|
"span",
|
|
@@ -234,7 +234,7 @@ const nt = "Please enter a valid value!", ne = r.forwardRef((t, re) => {
|
|
|
234
234
|
}
|
|
235
235
|
),
|
|
236
236
|
t.children,
|
|
237
|
-
t.clearButton && t.value && /* @__PURE__ */ r.createElement(et, { onClick:
|
|
237
|
+
t.clearButton && t.value && /* @__PURE__ */ r.createElement(et, { onClick: U, key: "clearbutton" }),
|
|
238
238
|
de && /* @__PURE__ */ r.createElement("span", { className: h(O.inputSpinner({ c: y })), onMouseDown: Re }, /* @__PURE__ */ r.createElement(
|
|
239
239
|
$,
|
|
240
240
|
{
|
|
@@ -243,8 +243,8 @@ const nt = "Please enter a valid value!", ne = r.forwardRef((t, re) => {
|
|
|
243
243
|
className: h(O.spinnerIncrease({ c: y })),
|
|
244
244
|
icon: "caret-alt-up",
|
|
245
245
|
svgIcon: _e,
|
|
246
|
-
"aria-label": E.toLanguageString(
|
|
247
|
-
title: E.toLanguageString(
|
|
246
|
+
"aria-label": E.toLanguageString(M, S[M]),
|
|
247
|
+
title: E.toLanguageString(M, S[M]),
|
|
248
248
|
onClick: Le
|
|
249
249
|
}
|
|
250
250
|
), /* @__PURE__ */ r.createElement(
|
|
@@ -255,14 +255,14 @@ const nt = "Please enter a valid value!", ne = r.forwardRef((t, re) => {
|
|
|
255
255
|
className: h(O.spinnerDecrease({ c: y })),
|
|
256
256
|
icon: "caret-alt-down",
|
|
257
257
|
svgIcon: Fe,
|
|
258
|
-
"aria-label": E.toLanguageString(
|
|
259
|
-
title: E.toLanguageString(
|
|
258
|
+
"aria-label": E.toLanguageString(P, S[P]),
|
|
259
|
+
title: E.toLanguageString(P, S[P]),
|
|
260
260
|
onClick: pe
|
|
261
261
|
}
|
|
262
262
|
))
|
|
263
263
|
);
|
|
264
264
|
return t.label ? /* @__PURE__ */ r.createElement(
|
|
265
|
-
|
|
265
|
+
Ue,
|
|
266
266
|
{
|
|
267
267
|
label: t.label,
|
|
268
268
|
editorId: Y,
|
|
@@ -355,10 +355,10 @@ const o = {
|
|
|
355
355
|
formatPlaceholder: Ke,
|
|
356
356
|
spinners: !1,
|
|
357
357
|
disabled: !1,
|
|
358
|
-
max:
|
|
359
|
-
min:
|
|
360
|
-
minTime:
|
|
361
|
-
maxTime:
|
|
358
|
+
max: T($e),
|
|
359
|
+
min: T(Ge),
|
|
360
|
+
minTime: T(Ze),
|
|
361
|
+
maxTime: T(Xe),
|
|
362
362
|
validityStyles: !0,
|
|
363
363
|
validationMessage: nt,
|
|
364
364
|
placeholder: null,
|
|
@@ -369,7 +369,7 @@ const o = {
|
|
|
369
369
|
twoDigitYearMax: 68,
|
|
370
370
|
ariaHasPopup: "grid",
|
|
371
371
|
autoFocus: !1
|
|
372
|
-
}, te =
|
|
372
|
+
}, te = je();
|
|
373
373
|
ne.displayName = "KendoReactDateInput";
|
|
374
374
|
export {
|
|
375
375
|
ne as DateInput,
|
package/datepicker/DatePicker.js
CHANGED
|
@@ -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 it=require("react"),t=require("prop-types"),st=require("@progress/kendo-react-popup"),j=require("@progress/kendo-date-math"),
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const it=require("react"),t=require("prop-types"),st=require("@progress/kendo-react-popup"),j=require("@progress/kendo-date-math"),i=require("@progress/kendo-react-common"),ct=require("@progress/kendo-svg-icons"),dt=require("../dateinput/DateInput.js"),ft=require("../calendar/components/Calendar.js"),r=require("../utils.js"),U=require("../messages/index.js"),mt=require("@progress/kendo-react-intl"),pt=require("./ToggleButton.js"),gt=require("../hooks/usePickerFloatingLabel.js"),bt=require("@progress/kendo-react-layout"),ht=require("../common/AdaptiveMode.js");function vt(a){const y=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const f in a)if(f!=="default"){const S=Object.getOwnPropertyDescriptor(a,f);Object.defineProperty(y,f,S.get?S:{enumerable:!0,get:()=>a[f]})}}return y.default=a,Object.freeze(y)}const o=vt(it),H=o.forwardRef((a,y)=>{const f=i.useId(a.id),S=mt.useLocalization(),D=i.useAdaptiveModeContext(),{defaultShow:me=l.defaultShow,defaultValue:pe=l.defaultValue,dateInput:ge=l.dateInput,calendar:be=l.calendar,toggleButton:he=l.toggleButton,popup:ve=l.popup,disabled:g=l.disabled,format:we=l.format,max:C=l.max,min:k=l.min,popupSettings:P=l.popupSettings,tabIndex:ye=l.tabIndex,weekNumber:De=l.weekNumber,validityStyles:Y=l.validityStyles,size:B=l.size,rounded:E=l.rounded,fillMode:x=l.fillMode,autoFocus:Ce=l.autoFocus,show:$,autoSwitchParts:ke,autoSwitchKeys:Pe,twoDigitYearMax:Oe,ariaLabel:Me,adaptive:wt,adaptiveTitle:Re=a.label||void 0,adaptiveSubtitle:Se,formatPlaceholder:Ie,inputAttributes:_e,validationMessage:X,visited:yt,value:q,touched:Dt,modified:Ct,_adaptiveMode:kt=D,valid:Z,focusedDate:Te,id:Be,ariaLabelledBy:Ee,ariaDescribedBy:xe,placeholder:qe,onChange:G,onOpen:J,onClose:Q,...ee}=i.usePropsContext(fe,a),N=()=>{if(i.canUseDOM)return m.current&&m.current.ownerDocument||window.document},c=()=>!!(w.windowWidth&&D&&w.windowWidth<=(D==null?void 0:D.medium)&&a.adaptive),b=()=>{const e=I.current!==void 0?I.current:q!==void 0?q:w.value;return e!==null?j.cloneDate(e):null},u=()=>_.current!==void 0?_.current:$!==void 0?$:w.show,Ne=()=>ge||l.dateInput,Ae=()=>he||l.toggleButton,Fe=()=>be||l.calendar,ze=()=>ve||l.popup,te=()=>a.required!==void 0?a.required:!1,A=()=>{const e=b()||q||null,n=k,s=C,T=r.isInDateRange(e,n,s),L=X!==void 0,V=(!te()||e!=null)&&T,W=Z!==void 0?Z:V;return{customError:L,rangeOverflow:e&&s.getTime()<e.getTime()||!1,rangeUnderflow:e&&e.getTime()<n.getTime()||!1,valid:W,valueMissing:e===null}},Ke=e=>{for(const n of e)R({windowWidth:n.target.clientWidth})},Le=()=>{d.current&&d.current.focus()},ne=e=>{p.current=e},h=e=>{u()!==e&&(R({show:e}),e&&J&&J({target:O.current}),!e&&Q&&Q({target:O.current}))},Ve=e=>{const n=b();return n&&e?r.setTime(e,n):e},We=e=>{P!=null&&P.onMouseDownOutside&&P.onMouseDownOutside(e)},F=(e,n)=>{R({value:j.cloneDate(e||void 0)}),I.current=e,_.current=!1,c()||(v.current=!0),G&&G({syntheticEvent:n.syntheticEvent,nativeEvent:n.nativeEvent,value:b(),show:u(),target:O.current}),I.current=void 0,_.current=void 0,h(!1)},je=e=>{const n=Ve(e.value);F(n,e)},ae=()=>{const{popupClass:e,...n}=P,s=u(),T=b(),L=T&&j.getDate(T),V=i.classNames(e),W={popupClass:"k-datepicker-popup",show:s,anchor:m.current,className:V,id:le,anchorAlign:{horizontal:"left",vertical:"bottom"},popupAlign:{horizontal:"left",vertical:"top"},...n,onMouseDownOutside:We},ce={disabled:g,value:L,min:k,max:C,weekNumber:De,focusedDate:Te,className:c()?"k-calendar-lg":"",navigation:!c(),onChange:je},de=Fe(),ut=ze();return c()?o.createElement(de,{_ref:ne,...ce}):o.createElement(ut,{...W},o.createElement(de,{_ref:ne,...ce}))},oe=()=>{R({focused:!1}),h(!1)},Ue=()=>{const{windowWidth:e=0}=w,n={expand:u(),onClose:oe,title:Re,subTitle:Se,windowWidth:e};return o.createElement(ht.AdaptiveMode,{...n},o.createElement(bt.ActionSheetContent,null,ae()))},He=e=>{F(e.value,e)},Ye=()=>{R({focused:!0})},$e=()=>{h(!u())},z=()=>{g||(v.current=!0,h(!u()))},Xe=e=>{e.preventDefault()},Ze=e=>{const{altKey:n,keyCode:s}=e;if(s===i.Keys.esc&&u()){v.current=!0,h(!1);return}n&&(s===i.Keys.up||s===i.Keys.down)&&(e.preventDefault(),e.stopPropagation(),v.current=s===i.Keys.up,h(s===i.Keys.down))},O=o.useRef(null),m=o.useRef(null),d=o.useRef(null),p=o.useRef(null);o.useImperativeHandle(O,()=>({props:a,get element(){return m.current},get calendar(){return p.current},get dateInput(){return d.current},get name(){return a.name},get show(){return u()},get validity(){return A()},get value(){return b()},get mobileMode(){return c()},togglePopup:$e,focus:Le})),o.useImperativeHandle(y,()=>O.current);const I=o.useRef(void 0),_=o.useRef(void 0),Ge=o.useRef(null),v=o.useRef(!1),K=o.useRef(!1),M=o.useRef(null),[w,Je]=o.useState({value:pe,show:me,focused:!1}),[,Qe]=o.useReducer(e=>e,!0),re=a.name||f||void 0,et=o.useCallback(e=>{if(g)return;let n=null;if(e!=null){if(e instanceof Date)n=e;else if(typeof e=="string"||typeof e=="number"){const s=new Date(e);isNaN(s.getTime())||(n=s)}}if(n&&r.isInDateRange(n,k,C)){const s={target:m.current,currentTarget:m.current};F(n,{syntheticEvent:s})}},[g,k,C]);i.useKendoPaste(m,{fieldName:re,onValueChange:et,enabled:!!re});const R=e=>{Je(n=>({...n,...e}))};o.useEffect(()=>{p.current&&p.current.element&&u()&&!K.current&&p.current.element.focus({preventScroll:!0}),c()&&u()&&!K.current&&setTimeout(()=>{p.current&&p.current.element&&p.current.element.focus({preventScroll:!0})},300),d.current&&d.current.element&&!u()&&v.current&&d.current.element.focus({preventScroll:!0}),K.current=u(),v.current=!1}),o.useEffect(()=>{var e;return M.current=i.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(n=>Ke(n)),u()&&Qe(),(e=N())!=null&&e.body&&M.current&&M.current.observe(N().body),()=>{var n;clearTimeout(Ge.current),(n=N())!=null&&n.body&&M.current&&M.current.disconnect()}},[]);const le=f+"-popup-id",tt=ae(),nt=Ne(),at=b(),ot=Ae(),rt=Ue(),ue=!Y||A().valid,ie=S.toLanguageString(U.toggleCalendar,U.messages[U.toggleCalendar]),lt={disabled:g,format:we,formatPlaceholder:Ie,id:Be,ariaLabelledBy:Ee,ariaDescribedBy:xe,ariaLabel:Me,max:C,min:k,name:a.name,onChange:He,required:a.required,_ref:d,tabIndex:u()?-1:ye,title:a.title,valid:A().valid,validationMessage:X,validityStyles:Y,value:at,label:void 0,placeholder:w.focused?null:qe,ariaExpanded:u(),autoFill:a.autoFill,twoDigitYearMax:Oe,enableMouseWheel:a.enableMouseWheel,autoCorrectParts:a.autoCorrectParts,autoSwitchParts:ke,autoSwitchKeys:Pe,allowCaretMode:a.allowCaretMode,inputAttributes:_e},se=o.createElement(i.AsyncFocusBlur,{onFocus:Ye,onBlur:c()?void 0:oe,onSyncBlur:a.onBlur,onSyncFocus:a.onFocus},e=>o.createElement(o.Fragment,null,o.createElement("span",{...a.label?{}:ee,ref:m,className:i.classNames("k-input","k-datepicker",{[`k-input-${i.kendoThemeMaps.sizeMap[B]||B}`]:B,[`k-rounded-${i.kendoThemeMaps.roundedMap[E]||E}`]:E,[`k-input-${x}`]:x,"k-invalid":!ue,"k-required":te(),"k-disabled":g},a.className),onKeyDown:Ze,style:{width:a.width},onFocus:c()?z:e.onFocus,onBlur:e.onBlur,onClick:c()?z:void 0},o.createElement(nt,{_ref:d,ariaRole:"combobox",ariaExpanded:u(),ariaControls:u()?le:void 0,autoFocus:Ce,...lt}),o.createElement(ot,{type:"button",icon:"calendar",svgIcon:ct.calendarIcon,title:ie,className:"k-input-button",onClick:c()?void 0:z,"aria-label":ie,fillMode:x,onMouseDown:Xe}),!c()&&tt),c()&&rt));return a.label?o.createElement(gt.PickerFloatingLabel,{dateInput:d,label:a.label,editorId:f,editorValid:ue,editorDisabled:g,children:se,style:{width:a.width},...ee}):se});H.propTypes={className:t.string,defaultShow:t.bool,defaultValue:t.instanceOf(Date),disabled:t.bool,focusedDate:t.instanceOf(Date),format:t.oneOfType([t.string,t.shape({skeleton:r.nullable(t.string),pattern:r.nullable(t.string),date:r.nullable(t.oneOf(["short","medium","long","full"])),time:r.nullable(t.oneOf(["short","medium","long","full"])),datetime:r.nullable(t.oneOf(["short","medium","long","full"])),era:r.nullable(t.oneOf(["narrow","short","long"])),year:r.nullable(t.oneOf(["numeric","2-digit"])),month:r.nullable(t.oneOf(["numeric","2-digit","narrow","short","long"])),day:r.nullable(t.oneOf(["numeric","2-digit"])),weekday:r.nullable(t.oneOf(["narrow","short","long"])),hour:r.nullable(t.oneOf(["numeric","2-digit"])),hour12:r.nullable(t.bool),minute:r.nullable(t.oneOf(["numeric","2-digit"])),second:r.nullable(t.oneOf(["numeric","2-digit"])),timeZoneName:r.nullable(t.oneOf(["short","long"]))})]),formatPlaceholder:t.oneOfType([r.nullable(t.oneOf(["wide","narrow","short","formatPattern"])),t.shape({year:r.nullable(t.string),month:r.nullable(t.string),day:r.nullable(t.string),hour:r.nullable(t.string),minute:r.nullable(t.string),second:r.nullable(t.string)})]),id:t.string,ariaLabelledBy:t.string,ariaDescribedBy:t.string,ariaLabel:t.string,min:t.instanceOf(Date),max:t.instanceOf(Date),name:t.string,popupSettings:t.shape({animate:r.nullable(t.bool),appendTo:r.nullable(t.any),popupClass:r.nullable(t.string)}),show:t.bool,tabIndex:t.number,title:t.string,value:t.instanceOf(Date),weekNumber:t.bool,width:t.oneOfType([t.number,t.string]),validationMessage:t.string,required:t.bool,valid:t.bool,size:t.oneOf(["small","medium","large"]),rounded:t.oneOf(["small","medium","large","full","none"]),fillMode:t.oneOf(["solid","flat","outline"]),adaptive:t.bool,adaptiveTitle:t.string,adaptiveSubtitle:t.string,autoFocus:t.bool,inputAttributes:t.object};const l={defaultShow:!1,defaultValue:null,dateInput:dt.DateInput,calendar:ft.Calendar,toggleButton:pt.ToggleButton,popup:st.Popup,disabled:!1,format:"d",max:r.MAX_DATE,min:r.MIN_DATE,popupSettings:{},tabIndex:0,weekNumber:!1,validityStyles:!0,size:void 0,rounded:void 0,fillMode:void 0,autoFocus:!1},fe=i.createPropsContext();H.displayName="KendoReactDatePicker";exports.DatePicker=H;exports.DatePickerPropsContext=fe;exports.datePickerDefaultProps=l;
|
|
@@ -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 M=require("react"),t=require("prop-types"),O=require("@progress/kendo-react-popup"),b=require("@progress/kendo-date-math"),o=require("@progress/kendo-react-common"),c=require("@progress/kendo-react-intl"),T=require("@progress/kendo-svg-icons"),D=require("../package-metadata.js"),g=require("../dateinput/DateInput.js"),x=require("../calendar/components/MultiViewCalendar.js"),h=require("../calendar/models/SelectionRange.js"),u=require("../utils.js"),i=require("../messages/index.js"),P=require("@progress/kendo-react-buttons"),_=require("../common/AdaptiveMode.js"),A=require("@progress/kendo-react-layout");function N(d){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(d){for(const e in d)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(d,e);Object.defineProperty(a,e,s.get?s:{enumerable:!0,get:()=>d[e]})}}return a.default=d,Object.freeze(a)}const n=N(M),l=class l extends n.Component{constructor(a){super(a),this._element=null,this._calendar=null,this._startDateInput=n.createRef(),this._endDateInput=n.createRef(),this.shouldFocusDateInput=!1,this.shouldFocusCalendar=!1,this.showLicenseWatermark=!1,this.focus=()=>{this.startDateInput&&this.startDateInput.focus()},this.setCalendarRef=e=>{this._calendar=e},this.focusCalendarElement=()=>{this._calendar&&this._calendar.element&&this._calendar.element.focus({preventScroll:!0})},this.calculateValue=(e,s)=>(e.value!==void 0?e.value:s.value)||h.EMPTY_SELECTIONRANGE,this.calculateShow=(e,s)=>e.show!==void 0?e.show:s.show,this.renderCalendar=()=>{const e=this.value||h.EMPTY_SELECTIONRANGE,s={min:this.min,max:this.max,allowReverse:this.props.allowReverse,mode:"range",focusedDate:this.props.focusedDate,disabled:this.props.disabled,className:this.mobileMode?"k-calendar-lg":"",mobileMode:this.mobileMode,...this.props.calendarSettings,value:e,dir:this.props.dir,onChange:this.handleCalendarChange};return this.props.calendar?n.createElement(this.props.calendar,{...s}):n.createElement(x.MultiViewCalendar,{...s,ref:this.setCalendarRef})},this.renderPopup=()=>{const e={popupClass:o.classNames("k-calendar-container","k-daterangepicker-popup"),animate:this._element!==null,anchor:this._element,id:this._popupId,anchorAlign:{horizontal:"left",vertical:"bottom"},popupAlign:{horizontal:"left",vertical:"top"},...this.props.popupSettings,show:this.show};return this.props.popup?n.createElement(this.props.popup,{...e},this.renderCalendar()):n.createElement(O.Popup,{...e},this.renderCalendar())},this.renderAdaptivePopup=()=>{const{windowWidth:e=0}=this.state,s={expand:this.show,onClose:r=>this.handleCancel(r),title:this.props.adaptiveTitle,subTitle:this.props.adaptiveSubtitle,windowWidth:e,footer:{cancelText:this.localizationService.toLanguageString(i.dateRangePickerCancel,i.messages[i.dateRangePickerCancel]),onCancel:this.handleCancel,applyText:this.localizationService.toLanguageString(i.dateRangePickerSet,i.messages[i.dateRangePickerSet]),onApply:this.handleBlur}};return n.createElement(_.AdaptiveMode,{...s},n.createElement(A.ActionSheetContent,null,n.createElement("div",{className:"k-scrollable-wrap"},this.renderCalendar())))},this.handleReverseClick=e=>{const s={start:this.value.end,end:this.value.start},r={syntheticEvent:e,nativeEvent:e.nativeEvent};this.handleChange(s,r)},this.handleReverseMouseDown=e=>{e.preventDefault()},this.handleFocus=e=>{clearTimeout(this.nextTickId),this.shouldFocusDateInput||this.mobileMode&&this.setState({currentValue:this.value});const{onFocus:s}=this.props;s&&s.call(void 0,e)},this.handleClick=()=>{this.shouldFocusDateInput||this.setShow(!0)},this.handleBlur=e=>{this.nextTick(()=>{this.setShow(!1)});const{onBlur:s}=this.props;s&&s.call(void 0,e)},this.handleCancel=e=>{this.nextTick(()=>{this.setShow(!1),this.setState({currentValue:h.EMPTY_SELECTIONRANGE})});const{onCancel:s}=this.props;s&&s.call(void 0,e)},this.handleEndChange=e=>{const s={start:this.value.start,end:b.cloneDate(e.value||void 0)};this.handleChange(s,e)},this.handleStartChange=e=>{const s={start:b.cloneDate(e.value||void 0),end:this.value.end};this.handleChange(s,e)},this.extractRangeFromValue=e=>{if(!Array.isArray(e.value)&&!(e.value instanceof Date))return e.value||h.EMPTY_SELECTIONRANGE;const s=Array.isArray(e.value)?e.value[0]:e.value;return{start:this.value.end!==null?s:this.value.start,end:this.value.start!==null?s:this.value.end}},this.handleCalendarChange=e=>{const s=this.extractRangeFromValue(e);this.handleChange(s,e)},this.handleKeyDown=e=>{const{keyCode:s,altKey:r}=e;s===o.Keys.esc?(e.preventDefault(),this.shouldFocusDateInput=!0,this.setShow(!1)):r&&s===o.Keys.down?(e.preventDefault(),this.shouldFocusCalendar=!0,this.setShow(!0),this.focusCalendarElement()):r&&s===o.Keys.up&&(e.preventDefault(),this.shouldFocusDateInput=!0,this.setShow(!1))},this.handleChange=(e,s)=>{this.setState({value:e}),this.valueDuringOnChange=e;const{onChange:r}=this.props;if(r){const m={syntheticEvent:s.syntheticEvent,nativeEvent:s.nativeEvent,value:this.value,show:this.show,target:this};r.call(void 0,m)}this.valueDuringOnChange=void 0},this.showLicenseWatermark=!o.validatePackage(D.packageMetadata,{component:"DateRangePicker"}),this.licenseMessage=o.getLicenseMessage(D.packageMetadata),this.state={show:this.props.show||this.props.defaultShow||l.defaultProps.defaultShow,value:this.props.value||this.props.defaultValue||l.defaultProps.defaultValue,currentValue:h.EMPTY_SELECTIONRANGE},this.nextTick=this.nextTick.bind(this),this.setShow=this.setShow.bind(this),this.focusCalendarElement=this.focusCalendarElement.bind(this),this.focusDateInputElement=this.focusDateInputElement.bind(this)}get _popupId(){return this.props.id+"-popup-id"}get _startInputId(){return this.props.id+"-start-input-id"}get _endInputId(){return this.props.id+"-end-input-id"}get element(){return this._element}get startDateInput(){return this._startDateInput.current}get endDateInput(){return this._endDateInput.current}get calendar(){return this._calendar}get value(){return(this.valueDuringOnChange!==void 0?this.valueDuringOnChange:this.props.value!==void 0?this.props.value:this.state.value)||h.EMPTY_SELECTIONRANGE}get show(){return this.showDuringOnChange!==void 0?this.showDuringOnChange:this.props.show!==void 0?this.props.show:this.state.show}get min(){return this.props.min!==void 0?this.props.min:l.defaultProps.min}get max(){return this.props.max!==void 0?this.props.max:l.defaultProps.max}get document(){if(o.canUseDOM)return this.element&&this.element.ownerDocument||document}get localizationService(){return c.provideLocalizationService(this)}get mobileMode(){var e;return!!(this.state.windowWidth&&this.props._adaptiveMode&&this.state.windowWidth<=((e=this.props._adaptiveMode)==null?void 0:e.medium)&&this.props.adaptive)}componentDidMount(){var a;this.observerResize=o.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.show&&this.forceUpdate(),(a=this.document)!=null&&a.body&&this.observerResize&&this.observerResize.observe(this.document.body)}componentDidUpdate(){this.shouldFocusCalendar&&this.focusCalendarElement(),this.mobileMode&&this.show&&setTimeout(()=>{this.focusCalendarElement()},300),this.shouldFocusDateInput&&this.focusDateInputElement(),this.shouldFocusCalendar=!1,this.shouldFocusDateInput=!1}componentWillUnmount(){var a;clearTimeout(this.nextTickId),(a=this.document)!=null&&a.body&&this.observerResize&&this.observerResize.disconnect()}render(){const{autoFocus:a}=this.props,e=this.value||h.EMPTY_SELECTIONRANGE,s=this.mobileMode&&this.show?this.state.currentValue:e,r=(this.props.startDateInputSettings||{}).id||this._startInputId,m=(this.props.endDateInputSettings||{}).id||this._endInputId,S=o.classNames("k-daterangepicker",{"k-disabled":this.props.disabled},this.props.className),C=this.localizationService.toLanguageString(i.start,i.messages[i.start]),E=this.localizationService.toLanguageString(i.end,i.messages[i.end]),y=this.localizationService.toLanguageString(i.separator,i.messages[i.separator]),f={disableSelection:this.mobileMode&&!0,label:C,format:this.props.format,min:this.min,max:this.max,id:this._startInputId,disabled:this.props.disabled,valid:this.props.valid,tabIndex:this.props.tabIndex,ariaExpanded:this.show,clearButton:this.props.clearButton,...this.props.startDateInputSettings,value:s.start,onChange:this.handleStartChange,inputAttributes:this.props.inputAttributes},v={disableSelection:this.mobileMode&&!0,label:E,format:this.props.format,min:this.min,max:this.max,id:this._endInputId,disabled:this.props.disabled,valid:this.props.valid,tabIndex:this.props.tabIndex,ariaExpanded:this.show,clearButton:this.props.clearButton,...this.props.endDateInputSettings,value:s.end,onChange:this.handleEndChange,inputAttributes:this.props.inputAttributes},k=n.createElement(P.Button,{type:"button",className:"k-select",fillMode:"flat",title:c.provideLocalizationService(this).toLanguageString(i.swapStartEnd,i.messages[i.swapStartEnd]),onMouseDown:this.handleReverseMouseDown,onClick:this.handleReverseClick,"aria-controls":r+" "+m,"aria-label":c.provideLocalizationService(this).toLanguageString(i.swapStartEnd,i.messages[i.swapStartEnd])},n.createElement(o.IconWrap,{style:{transform:"rotate(90deg)"},name:"arrows-swap",icon:T.arrowsSwapIcon}));return n.createElement(n.Fragment,null,n.createElement("span",{ref:R=>{this._element=R},className:S,style:this.props.style,id:this.props.id,"aria-labelledby":this.props.ariaLabelledBy,"aria-describedby":this.props.ariaDescribedBy,tabIndex:this.props.tabIndex,onFocus:this.mobileMode?this.handleClick:this.handleFocus,onClick:this.handleClick,onKeyDown:this.handleKeyDown,onBlur:this.mobileMode?void 0:this.handleBlur,dir:this.props.dir},this.props.startDateInput?n.createElement(this.props.startDateInput,{...f}):n.createElement(g.DateInput,{...f,autoFocus:a,ref:this._startDateInput,ariaRole:"combobox",ariaControls:this._popupId}),(this.props.allowReverse||this.props.calendarSettings&&this.props.calendarSettings.allowReverse)&&this.props.swapButton?k:y,this.props.endDateInput?n.createElement(this.props.endDateInput,{...v}):n.createElement(g.DateInput,{...v,ref:this._endDateInput,ariaRole:"combobox",ariaControls:this._popupId}),!this.mobileMode&&this.renderPopup()),this.mobileMode&&this.renderAdaptivePopup(),this.showLicenseWatermark&&n.createElement(o.WatermarkOverlay,{message:this.licenseMessage}))}focusDateInputElement(){if(!document||!this.startDateInput||!this.startDateInput.element||!this.endDateInput||!this.endDateInput.element)return;const a=o.getActiveElement(document);(this.value.start===null||this.value.end!==null)&&a!==this.endDateInput.element?this.startDateInput.element.focus({preventScroll:!0}):a!==this.startDateInput.element&&this.endDateInput.element.focus({preventScroll:!0})}nextTick(a){clearTimeout(this.nextTickId),this.nextTickId=window.setTimeout(()=>a())}setShow(a){const{onOpen:e,onClose:s}=this.props;this.show!==a&&(this.setState({show:a}),a&&e&&e.call(void 0,{target:this}),!a&&s&&s.call(void 0,{target:this}))}calculateMedia(a){for(const e of a)this.setState({windowWidth:e.target.clientWidth})}};l.displayName="DateRangePicker",l.propTypes={allowReverse:t.bool,calendarSettings:t.any,className:t.string,defaultShow:t.bool,defaultValue:t.shape({start:u.nullable(t.instanceOf(Date).isRequired),end:u.nullable(t.instanceOf(Date).isRequired)}),disabled:t.bool,endDateInputSettings:t.shape(g.DateInput.propTypes),focusedDate:t.instanceOf(Date),format:t.oneOfType([t.string,t.shape({skeleton:t.string,pattern:t.string,date:t.oneOf(["short","medium","long","full"]),time:t.oneOf(["short","medium","long","full"]),datetime:t.oneOf(["short","medium","long","full"]),era:t.oneOf(["narrow","short","long"]),year:t.oneOf(["numeric","2-digit"]),month:t.oneOf(["numeric","2-digit","narrow","short","long"]),day:t.oneOf(["numeric","2-digit"]),weekday:t.oneOf(["narrow","short","long"]),hour:t.oneOf(["numeric","2-digit"]),hour12:t.bool,minute:t.oneOf(["numeric","2-digit"]),second:t.oneOf(["numeric","2-digit"]),timeZoneName:t.oneOf(["short","long"])})]),id:t.string,ariaLabelledBy:t.string,ariaDescribedBy:t.string,max:t.instanceOf(Date),min:t.instanceOf(Date),onBlur:t.func,onChange:t.func,onFocus:t.func,popupSettings:t.any,show:t.bool,startDateInputSettings:t.any,style:t.any,swapButton:t.any,tabIndex:t.number,dir:t.string,value:t.shape({start:u.nullable(t.instanceOf(Date)),end:u.nullable(t.instanceOf(Date))}),autoFocus:t.bool,inputAttributes:t.object},l.defaultProps={allowReverse:!1,defaultShow:!1,defaultValue:h.EMPTY_SELECTIONRANGE,disabled:!1,format:"d",max:u.MAX_DATE,min:u.MIN_DATE,swapButton:!1,autoFocus:!1};let p=l;const I=o.createPropsContext(),w=o.withIdHOC(o.withPropsContext(I,o.withAdaptiveModeContext(p)));w.displayName="KendoReactDateRangePicker";c.registerForLocalization(p);exports.DateRangePicker=w;exports.DateRangePickerPropsContext=I;exports.DateRangePickerWithoutContext=p;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("react"),t=require("prop-types"),O=require("@progress/kendo-react-popup"),b=require("@progress/kendo-date-math"),o=require("@progress/kendo-react-common"),c=require("@progress/kendo-react-intl"),T=require("@progress/kendo-svg-icons"),D=require("../package-metadata.js"),g=require("../dateinput/DateInput.js"),x=require("../calendar/components/MultiViewCalendar.js"),h=require("../calendar/models/SelectionRange.js"),u=require("../utils.js"),i=require("../messages/index.js"),P=require("@progress/kendo-react-buttons"),_=require("../common/AdaptiveMode.js"),A=require("@progress/kendo-react-layout");function N(d){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(d){for(const e in d)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(d,e);Object.defineProperty(a,e,s.get?s:{enumerable:!0,get:()=>d[e]})}}return a.default=d,Object.freeze(a)}const n=N(M),l=class l extends n.Component{constructor(a){super(a),this._element=null,this._calendar=null,this._startDateInput=n.createRef(),this._endDateInput=n.createRef(),this.shouldFocusDateInput=!1,this.shouldFocusCalendar=!1,this.showLicenseWatermark=!1,this.focus=()=>{this.startDateInput&&this.startDateInput.focus()},this.setCalendarRef=e=>{this._calendar=e},this.focusCalendarElement=()=>{this._calendar&&this._calendar.element&&this._calendar.element.focus({preventScroll:!0})},this.calculateValue=(e,s)=>(e.value!==void 0?e.value:s.value)||h.EMPTY_SELECTIONRANGE,this.calculateShow=(e,s)=>e.show!==void 0?e.show:s.show,this.renderCalendar=()=>{const e=this.value||h.EMPTY_SELECTIONRANGE,s={min:this.min,max:this.max,allowReverse:this.props.allowReverse,mode:"range",focusedDate:this.props.focusedDate,disabled:this.props.disabled,className:this.mobileMode?"k-calendar-lg":"",mobileMode:this.mobileMode,...this.props.calendarSettings,value:e,dir:this.props.dir,onChange:this.handleCalendarChange};return this.props.calendar?n.createElement(this.props.calendar,{...s}):n.createElement(x.MultiViewCalendar,{...s,ref:this.setCalendarRef})},this.renderPopup=()=>{const e={popupClass:o.classNames("k-calendar-container","k-daterangepicker-popup"),animate:this._element!==null,anchor:this._element,id:this._popupId,anchorAlign:{horizontal:"left",vertical:"bottom"},popupAlign:{horizontal:"left",vertical:"top"},...this.props.popupSettings,show:this.show};return this.props.popup?n.createElement(this.props.popup,{...e},this.renderCalendar()):n.createElement(O.Popup,{...e},this.renderCalendar())},this.renderAdaptivePopup=()=>{const{windowWidth:e=0}=this.state,s={expand:this.show,onClose:r=>this.handleCancel(r),title:this.props.adaptiveTitle,subTitle:this.props.adaptiveSubtitle,windowWidth:e,footer:{cancelText:this.localizationService.toLanguageString(i.dateRangePickerCancel,i.messages[i.dateRangePickerCancel]),onCancel:this.handleCancel,applyText:this.localizationService.toLanguageString(i.dateRangePickerSet,i.messages[i.dateRangePickerSet]),onApply:this.handleBlur}};return n.createElement(_.AdaptiveMode,{...s},n.createElement(A.ActionSheetContent,null,n.createElement("div",{className:"k-scrollable-wrap"},this.renderCalendar())))},this.handleReverseClick=e=>{const s={start:this.value.end,end:this.value.start},r={syntheticEvent:e,nativeEvent:e.nativeEvent};this.handleChange(s,r)},this.handleReverseMouseDown=e=>{e.preventDefault()},this.handleFocus=e=>{clearTimeout(this.nextTickId),this.shouldFocusDateInput||this.mobileMode&&this.setState({currentValue:this.value});const{onFocus:s}=this.props;s&&s.call(void 0,e)},this.handleClick=()=>{this.shouldFocusDateInput||this.setShow(!0)},this.handleBlur=e=>{this.nextTick(()=>{this.setShow(!1)});const{onBlur:s}=this.props;s&&s.call(void 0,e)},this.handleCancel=e=>{this.nextTick(()=>{this.setShow(!1),this.setState({currentValue:h.EMPTY_SELECTIONRANGE})});const{onCancel:s}=this.props;s&&s.call(void 0,e)},this.handleEndChange=e=>{const s={start:this.value.start,end:b.cloneDate(e.value||void 0)};this.handleChange(s,e)},this.handleStartChange=e=>{const s={start:b.cloneDate(e.value||void 0),end:this.value.end};this.handleChange(s,e)},this.extractRangeFromValue=e=>{if(!Array.isArray(e.value)&&!(e.value instanceof Date))return e.value||h.EMPTY_SELECTIONRANGE;const s=Array.isArray(e.value)?e.value[0]:e.value;return{start:this.value.end!==null?s:this.value.start,end:this.value.start!==null?s:this.value.end}},this.handleCalendarChange=e=>{const s=this.extractRangeFromValue(e);this.handleChange(s,e)},this.handleKeyDown=e=>{const{keyCode:s,altKey:r}=e;s===o.Keys.esc?(e.preventDefault(),this.shouldFocusDateInput=!0,this.setShow(!1)):r&&s===o.Keys.down?(e.preventDefault(),this.shouldFocusCalendar=!0,this.setShow(!0),this.focusCalendarElement()):r&&s===o.Keys.up&&(e.preventDefault(),this.shouldFocusDateInput=!0,this.setShow(!1))},this.handleChange=(e,s)=>{this.setState({value:e}),this.valueDuringOnChange=e;const{onChange:r}=this.props;if(r){const m={syntheticEvent:s.syntheticEvent,nativeEvent:s.nativeEvent,value:this.value,show:this.show,target:this};r.call(void 0,m)}this.valueDuringOnChange=void 0},this.showLicenseWatermark=!o.validatePackage(D.packageMetadata,{component:"DateRangePicker"}),this.licenseMessage=o.getLicenseMessage(D.packageMetadata),this.state={show:this.props.show||this.props.defaultShow||l.defaultProps.defaultShow,value:this.props.value||this.props.defaultValue||l.defaultProps.defaultValue,currentValue:h.EMPTY_SELECTIONRANGE},this.nextTick=this.nextTick.bind(this),this.setShow=this.setShow.bind(this),this.focusCalendarElement=this.focusCalendarElement.bind(this),this.focusDateInputElement=this.focusDateInputElement.bind(this)}get _popupId(){return this.props.id+"-popup-id"}get _startInputId(){return this.props.id+"-start-input-id"}get _endInputId(){return this.props.id+"-end-input-id"}get element(){return this._element}get startDateInput(){return this._startDateInput.current}get endDateInput(){return this._endDateInput.current}get calendar(){return this._calendar}get value(){return(this.valueDuringOnChange!==void 0?this.valueDuringOnChange:this.props.value!==void 0?this.props.value:this.state.value)||h.EMPTY_SELECTIONRANGE}get show(){return this.showDuringOnChange!==void 0?this.showDuringOnChange:this.props.show!==void 0?this.props.show:this.state.show}get min(){return this.props.min!==void 0?this.props.min:l.defaultProps.min}get max(){return this.props.max!==void 0?this.props.max:l.defaultProps.max}get document(){if(o.canUseDOM)return this.element&&this.element.ownerDocument||document}get localizationService(){return c.provideLocalizationService(this)}get mobileMode(){var e;return!!(this.state.windowWidth&&this.props._adaptiveMode&&this.state.windowWidth<=((e=this.props._adaptiveMode)==null?void 0:e.medium)&&this.props.adaptive)}componentDidMount(){var a;this.observerResize=o.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.show&&this.forceUpdate(),(a=this.document)!=null&&a.body&&this.observerResize&&this.observerResize.observe(this.document.body)}componentDidUpdate(){this.shouldFocusCalendar&&this.focusCalendarElement(),this.mobileMode&&this.show&&setTimeout(()=>{this.focusCalendarElement()},300),this.shouldFocusDateInput&&this.focusDateInputElement(),this.shouldFocusCalendar=!1,this.shouldFocusDateInput=!1}componentWillUnmount(){var a;clearTimeout(this.nextTickId),(a=this.document)!=null&&a.body&&this.observerResize&&this.observerResize.disconnect()}render(){const{autoFocus:a}=this.props,e=this.value||h.EMPTY_SELECTIONRANGE,s=this.mobileMode&&this.show?this.state.currentValue:e,r=(this.props.startDateInputSettings||{}).id||this._startInputId,m=(this.props.endDateInputSettings||{}).id||this._endInputId,S=o.classNames("k-daterangepicker",{"k-disabled":this.props.disabled},this.props.className),C=this.localizationService.toLanguageString(i.start,i.messages[i.start]),E=this.localizationService.toLanguageString(i.end,i.messages[i.end]),y=this.localizationService.toLanguageString(i.separator,i.messages[i.separator]),f={disableSelection:this.mobileMode&&!0,label:C,format:this.props.format,min:this.min,max:this.max,id:this._startInputId,disabled:this.props.disabled,valid:this.props.valid,tabIndex:this.props.tabIndex,ariaExpanded:this.show,clearButton:this.props.clearButton,...this.props.startDateInputSettings,value:s.start,onChange:this.handleStartChange,inputAttributes:this.props.inputAttributes},v={disableSelection:this.mobileMode&&!0,label:E,format:this.props.format,min:this.min,max:this.max,id:this._endInputId,disabled:this.props.disabled,valid:this.props.valid,tabIndex:this.props.tabIndex,ariaExpanded:this.show,clearButton:this.props.clearButton,...this.props.endDateInputSettings,value:s.end,onChange:this.handleEndChange,inputAttributes:this.props.inputAttributes},k=n.createElement(P.Button,{type:"button",className:"k-select",fillMode:"flat",title:c.provideLocalizationService(this).toLanguageString(i.swapStartEnd,i.messages[i.swapStartEnd]),onMouseDown:this.handleReverseMouseDown,onClick:this.handleReverseClick,"aria-controls":r+" "+m,"aria-label":c.provideLocalizationService(this).toLanguageString(i.swapStartEnd,i.messages[i.swapStartEnd])},n.createElement(o.IconWrap,{style:{transform:"rotate(90deg)"},name:"arrows-swap",icon:T.arrowsSwapIcon}));return n.createElement(n.Fragment,null,n.createElement("span",{ref:R=>{this._element=R},className:S,style:this.props.style,id:this.props.id,"aria-labelledby":this.props.ariaLabelledBy,"aria-describedby":this.props.ariaDescribedBy,tabIndex:this.props.tabIndex,onFocus:this.mobileMode?this.handleClick:this.handleFocus,onClick:this.handleClick,onKeyDown:this.handleKeyDown,onBlur:this.mobileMode?void 0:this.handleBlur,dir:this.props.dir},this.props.startDateInput?n.createElement(this.props.startDateInput,{...f}):n.createElement(g.DateInput,{...f,autoFocus:a,ref:this._startDateInput,ariaRole:"combobox",ariaControls:this.show?this._popupId:void 0}),(this.props.allowReverse||this.props.calendarSettings&&this.props.calendarSettings.allowReverse)&&this.props.swapButton?k:y,this.props.endDateInput?n.createElement(this.props.endDateInput,{...v}):n.createElement(g.DateInput,{...v,ref:this._endDateInput,ariaRole:"combobox",ariaControls:this.show?this._popupId:void 0}),!this.mobileMode&&this.renderPopup()),this.mobileMode&&this.renderAdaptivePopup(),this.showLicenseWatermark&&n.createElement(o.WatermarkOverlay,{message:this.licenseMessage}))}focusDateInputElement(){if(!document||!this.startDateInput||!this.startDateInput.element||!this.endDateInput||!this.endDateInput.element)return;const a=o.getActiveElement(document);(this.value.start===null||this.value.end!==null)&&a!==this.endDateInput.element?this.startDateInput.element.focus({preventScroll:!0}):a!==this.startDateInput.element&&this.endDateInput.element.focus({preventScroll:!0})}nextTick(a){clearTimeout(this.nextTickId),this.nextTickId=window.setTimeout(()=>a())}setShow(a){const{onOpen:e,onClose:s}=this.props;this.show!==a&&(this.setState({show:a}),a&&e&&e.call(void 0,{target:this}),!a&&s&&s.call(void 0,{target:this}))}calculateMedia(a){for(const e of a)this.setState({windowWidth:e.target.clientWidth})}};l.displayName="DateRangePicker",l.propTypes={allowReverse:t.bool,calendarSettings:t.any,className:t.string,defaultShow:t.bool,defaultValue:t.shape({start:u.nullable(t.instanceOf(Date).isRequired),end:u.nullable(t.instanceOf(Date).isRequired)}),disabled:t.bool,endDateInputSettings:t.shape(g.DateInput.propTypes),focusedDate:t.instanceOf(Date),format:t.oneOfType([t.string,t.shape({skeleton:t.string,pattern:t.string,date:t.oneOf(["short","medium","long","full"]),time:t.oneOf(["short","medium","long","full"]),datetime:t.oneOf(["short","medium","long","full"]),era:t.oneOf(["narrow","short","long"]),year:t.oneOf(["numeric","2-digit"]),month:t.oneOf(["numeric","2-digit","narrow","short","long"]),day:t.oneOf(["numeric","2-digit"]),weekday:t.oneOf(["narrow","short","long"]),hour:t.oneOf(["numeric","2-digit"]),hour12:t.bool,minute:t.oneOf(["numeric","2-digit"]),second:t.oneOf(["numeric","2-digit"]),timeZoneName:t.oneOf(["short","long"])})]),id:t.string,ariaLabelledBy:t.string,ariaDescribedBy:t.string,max:t.instanceOf(Date),min:t.instanceOf(Date),onBlur:t.func,onChange:t.func,onFocus:t.func,popupSettings:t.any,show:t.bool,startDateInputSettings:t.any,style:t.any,swapButton:t.any,tabIndex:t.number,dir:t.string,value:t.shape({start:u.nullable(t.instanceOf(Date)),end:u.nullable(t.instanceOf(Date))}),autoFocus:t.bool,inputAttributes:t.object},l.defaultProps={allowReverse:!1,defaultShow:!1,defaultValue:h.EMPTY_SELECTIONRANGE,disabled:!1,format:"d",max:u.MAX_DATE,min:u.MIN_DATE,swapButton:!1,autoFocus:!1};let p=l;const w=o.createPropsContext(),I=o.withIdHOC(o.withPropsContext(w,o.withAdaptiveModeContext(p)));I.displayName="KendoReactDateRangePicker";c.registerForLocalization(p);exports.DateRangePicker=I;exports.DateRangePickerPropsContext=w;exports.DateRangePickerWithoutContext=p;
|
|
@@ -140,14 +140,14 @@ const o = class o extends i.Component {
|
|
|
140
140
|
this.setState({ value: t }), this.valueDuringOnChange = t;
|
|
141
141
|
const { onChange: n } = this.props;
|
|
142
142
|
if (n) {
|
|
143
|
-
const
|
|
143
|
+
const u = {
|
|
144
144
|
syntheticEvent: s.syntheticEvent,
|
|
145
145
|
nativeEvent: s.nativeEvent,
|
|
146
146
|
value: this.value,
|
|
147
147
|
show: this.show,
|
|
148
148
|
target: this
|
|
149
149
|
};
|
|
150
|
-
n.call(void 0,
|
|
150
|
+
n.call(void 0, u);
|
|
151
151
|
}
|
|
152
152
|
this.valueDuringOnChange = void 0;
|
|
153
153
|
}, this.showLicenseWatermark = !L(I, { component: "DateRangePicker" }), this.licenseMessage = N(I), this.state = {
|
|
@@ -250,7 +250,7 @@ const o = class o extends i.Component {
|
|
|
250
250
|
* @hidden
|
|
251
251
|
*/
|
|
252
252
|
render() {
|
|
253
|
-
const { autoFocus: a } = this.props, t = this.value || r, s = this.mobileMode && this.show ? this.state.currentValue : t, n = (this.props.startDateInputSettings || {}).id || this._startInputId,
|
|
253
|
+
const { autoFocus: a } = this.props, t = this.value || r, s = this.mobileMode && this.show ? this.state.currentValue : t, n = (this.props.startDateInputSettings || {}).id || this._startInputId, u = (this.props.endDateInputSettings || {}).id || this._endInputId, k = b(
|
|
254
254
|
"k-daterangepicker",
|
|
255
255
|
{
|
|
256
256
|
"k-disabled": this.props.disabled
|
|
@@ -297,7 +297,7 @@ const o = class o extends i.Component {
|
|
|
297
297
|
title: m(this).toLanguageString(p, l[p]),
|
|
298
298
|
onMouseDown: this.handleReverseMouseDown,
|
|
299
299
|
onClick: this.handleReverseClick,
|
|
300
|
-
"aria-controls": n + " " +
|
|
300
|
+
"aria-controls": n + " " + u,
|
|
301
301
|
"aria-label": m(this).toLanguageString(
|
|
302
302
|
p,
|
|
303
303
|
l[p]
|
|
@@ -330,7 +330,7 @@ const o = class o extends i.Component {
|
|
|
330
330
|
autoFocus: a,
|
|
331
331
|
ref: this._startDateInput,
|
|
332
332
|
ariaRole: "combobox",
|
|
333
|
-
ariaControls: this._popupId
|
|
333
|
+
ariaControls: this.show ? this._popupId : void 0
|
|
334
334
|
}
|
|
335
335
|
),
|
|
336
336
|
(this.props.allowReverse || this.props.calendarSettings && this.props.calendarSettings.allowReverse) && this.props.swapButton ? T : R,
|
|
@@ -340,7 +340,7 @@ const o = class o extends i.Component {
|
|
|
340
340
|
...v,
|
|
341
341
|
ref: this._endDateInput,
|
|
342
342
|
ariaRole: "combobox",
|
|
343
|
-
ariaControls: this._popupId
|
|
343
|
+
ariaControls: this.show ? this._popupId : void 0
|
|
344
344
|
}
|
|
345
345
|
),
|
|
346
346
|
!this.mobileMode && this.renderPopup()
|
|
@@ -432,17 +432,17 @@ o.displayName = "DateRangePicker", o.propTypes = {
|
|
|
432
432
|
swapButton: !1,
|
|
433
433
|
autoFocus: !1
|
|
434
434
|
};
|
|
435
|
-
let
|
|
435
|
+
let d = o;
|
|
436
436
|
const J = B(), Q = F(
|
|
437
437
|
P(
|
|
438
438
|
J,
|
|
439
|
-
z(
|
|
439
|
+
z(d)
|
|
440
440
|
)
|
|
441
441
|
);
|
|
442
442
|
Q.displayName = "KendoReactDateRangePicker";
|
|
443
|
-
U(
|
|
443
|
+
U(d);
|
|
444
444
|
export {
|
|
445
445
|
Q as DateRangePicker,
|
|
446
446
|
J as DateRangePickerPropsContext,
|
|
447
|
-
|
|
447
|
+
d as DateRangePickerWithoutContext
|
|
448
448
|
};
|
|
@@ -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"),P=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"),d=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(c){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const t in c)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(c,t);Object.defineProperty(i,t,s.get?s:{enumerable:!0,get:()=>c[t]})}}return i.default=c,Object.freeze(i)}const r=re(G),a=class a extends r.Component{constructor(i){super(i),this._element=null,this._dateInput=r.createRef(),this._dateTimeSelector=null,this.shouldFocusDateInput=!1,this.prevShow=!1,this.handleSmartPasteValue=t=>{if(t instanceof Date&&!isNaN(t.getTime())){this.applyKendoPasteDate(t);return}const s=t!=null?String(t):"";if(!s)return;const n=new Date(s);isNaN(n.getTime())||this.applyKendoPasteDate(n)},this.applyKendoPasteDate=t=>{if(!d.isInDateRange(t,this.min,this.max))return;const s=new Event("change",{bubbles:!0}),n={target:this._element,currentTarget:this._element,nativeEvent:s};this.handleValueChange({syntheticEvent:n,nativeEvent:s,value:t})},this.focus=()=>{const t=this.dateInputElement();t&&t.focus()},this.renderPicker=()=>{const{disabled:t,minTime:s,maxTime:n,format:p,calendar:u,cancelButton:h,weekNumber:v,focusedDate:f,unstyled:b}=this.props;return r.createElement(ie.DateTimeSelector,{ref:w=>{this._dateTimeSelector=w},cancelButton:h,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:n,focusedDate:f,format:p,calendar:u,mobileMode:this.mobileMode,footerActions:!this.mobileMode,unstyled:b})},this.renderAdaptivePopup=()=>{const{windowWidth:t=0}=this.state,s=m.provideLocalizationService(this).toLanguageString(l.dateTimePickerCancel,l.messages[l.dateTimePickerCancel]),n=m.provideLocalizationService(this).toLanguageString(l.dateTimePickerSet,l.messages[l.dateTimePickerSet]),p={expand:this.show,onClose:this.handleBlur,title:this.props.adaptiveTitle||this.props.label,subTitle:this.props.adaptiveSubtitle,windowWidth:t,footer:{cancelText:s,onCancel:u=>{var h;return(h=this._dateTimeSelector)==null?void 0:h.handleReject(u)},applyText:n,onApply:u=>{var h;return(h=this._dateTimeSelector)==null?void 0:h.handleAccept(u)}}};return r.createElement(ne.AdaptiveMode,{...p},r.createElement(ae.ActionSheetContent,null,this.renderPicker()))},this.handleReject=()=>{this.shouldFocusDateInput=!0,this.setShow(!1)},this.handleValueChange=t=>{this.setState({value:P.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:n}=t;if(n===o.Keys.esc){this.shouldFocusDateInput=!0,this.setShow(!1);return}s&&(n===o.Keys.up||n===o.Keys.down)&&(t.preventDefault(),t.stopPropagation(),this.shouldFocusDateInput=n===o.Keys.up,this.setShow(n===o.Keys.down))},this.dateInputElement=()=>this.dateInput&&this.dateInput.element||this.element&&this.element.querySelector(".k-dateinput > input.k-input-inner"),this.state={value:this.props.defaultValue||a.defaultProps.defaultValue,show:this.props.defaultShow||a.defaultProps.defaultShow,focused:!1}}get _popupId(){return this.props.id+"-popup-id"}get document(){if(o.canUseDOM)return this.element&&this.element.ownerDocument||document}get element(){return this._element}get dateInput(){return this._dateInput.current}get value(){const i=this.valueDuringOnChange!==void 0?this.valueDuringOnChange:this.props.value!==void 0?this.props.value:this.state.value;return i!==null?P.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:a.defaultProps.min}get max(){return this.props.max!==void 0?this.props.max:a.defaultProps.max}get validity(){const i=d.isInDateRange(this.value,this.min,this.max)&&se.isInTimeRange(this.value,this.props.minTime||d.MIN_TIME,this.props.maxTime||d.MAX_TIME),t=this.props.validationMessage!==void 0,s=(!this.required||this.value!==null)&&i,n=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:n,valueMissing:this.value===null}}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:a.defaultProps.validityStyles}get required(){return this.props.required!==void 0?this.props.required:!1}get dateInputComp(){return this.props.dateInput||a.defaultProps.dateInput}componentDidMount(){var t;this.observerResize=o.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.show&&this.forceUpdate(),(t=this.document)!=null&&t.body&&this.observerResize&&this.observerResize.observe(this.document.body);const i=this.props.name||this.props.id;this.KendoPasteSubscription=o.subscribeToKendoPaste(this._element,{fieldName:i,onValueChange:s=>{this.handleSmartPasteValue(s)}})}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,t;clearTimeout(this.nextTickId),(i=this.document)!=null&&i.body&&this.observerResize&&this.observerResize.disconnect(),(t=this.KendoPasteSubscription)==null||t.unsubscribe()}render(){const{size:i=a.defaultProps.size,rounded:t=a.defaultProps.rounded,fillMode:s=a.defaultProps.fillMode,autoFocus:n=a.defaultProps.autoFocus,inputAttributes:p,disabled:u,tabIndex:h,title:v,id:f,format:b,formatPlaceholder:w,min:C,max:M,className:k,width:x,name:E,validationMessage:q,required:R,validityStyles:F,minTime:N,maxTime:A,ariaLabelledBy:z,ariaDescribedBy:_,popup:B=J.Popup,unstyled:S,autoFill:K,twoDigitYearMax:L,enableMouseWheel:V,autoCorrectParts:j,autoSwitchParts:U,autoSwitchKeys:W,allowCaretMode:H}=this.props,y=S&&S.uDateTimePicker,D=!this.validityStyles||this.validity.valid,X={id:f,ariaLabelledBy:z,ariaDescribedBy:_,format:b,formatPlaceholder:w,disabled:u,title:v,validityStyles:F,validationMessage:q,required:R,min:C,max:M,minTime:N,maxTime:A,name:E,tabIndex:this.show?-1:h,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,unstyled:S,autoFill:K,twoDigitYearMax:L,enableMouseWheel:V,autoCorrectParts:j,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:y,size:i,fillMode:s,rounded:t,disabled:u,required:this.required,invalid:!D}),k),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:n,inputAttributes:p,...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:y})),fillMode:s,"aria-label":m.provideLocalizationService(this).toLanguageString(l.toggleDateTimeSelector,l.messages[l.toggleDateTimeSelector])}),r.createElement(B,{show:this.show,animate:this.element!==null,anchor:this.element,popupClass:o.classNames(o.uDateTimePicker.popup({c:y})),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})}};a.displayName="DateTimePicker",a.propTypes={className:e.string,defaultShow:e.bool,defaultValue:e.instanceOf(Date),disabled:e.bool,focusedDate:e.instanceOf(Date),format:e.oneOfType([e.string,e.shape({skeleton:e.string,pattern:e.string,date:e.oneOf(["short","medium","long","full"]),time:e.oneOf(["short","medium","long","full"]),datetime:e.oneOf(["short","medium","long","full"]),era:e.oneOf(["narrow","short","long"]),year:e.oneOf(["numeric","2-digit"]),month:e.oneOf(["numeric","2-digit","narrow","short","long"]),day:e.oneOf(["numeric","2-digit"]),weekday:e.oneOf(["narrow","short","long"]),hour:e.oneOf(["numeric","2-digit"]),hour12:e.bool,minute:e.oneOf(["numeric","2-digit"]),second:e.oneOf(["numeric","2-digit"]),timeZoneName:e.oneOf(["short","long"])})]),formatPlaceholder:e.oneOfType([e.oneOf(["wide","narrow","short","formatPattern"]),e.shape({year:e.string,month:e.string,day:e.string,hour:e.string,minute:e.string,second:e.string})]),id:e.string,ariaLabelledBy:e.string,ariaDescribedBy:e.string,min:e.instanceOf(Date),max:e.instanceOf(Date),name:e.string,popupSettings:e.shape({animate:e.bool,appendTo:e.any,popupClass:e.string}),show:e.bool,tabIndex:e.number,title:e.string,value:e.instanceOf(Date),weekNumber:e.bool,width:e.oneOfType([e.number,e.string]),validationMessage:e.string,required:e.bool,validate:e.bool,valid:e.bool,cancelButton:e.bool,size:e.oneOf(["small","medium","large"]),rounded:e.oneOf(["small","medium","large","full","none"]),fillMode:e.oneOf(["solid","flat","outline"]),autoFocus:e.bool,inputAttributes:e.object},a.defaultProps={defaultShow:!1,defaultValue:null,disabled:!1,format:"g",max:d.MAX_DATE,min:d.MIN_DATE,popupSettings:{},tabIndex:0,weekNumber:!1,validityStyles:!0,cancelButton:!0,dateInput:ee.DateInput,size:void 0,rounded:void 0,fillMode:void 0,autoFocus:!1};let g=a;const I=o.createPropsContext(),O=o.withIdHOC(o.withPropsContext(I,o.withUnstyledHOC(o.withAdaptiveModeContext(g))));O.displayName="KendoReactDateTimePicker";m.registerForLocalization(g);exports.DateTimePicker=O;exports.DateTimePickerPropsContext=I;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"),P=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"),d=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(c){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const t in c)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(c,t);Object.defineProperty(i,t,s.get?s:{enumerable:!0,get:()=>c[t]})}}return i.default=c,Object.freeze(i)}const r=re(G),a=class a extends r.Component{constructor(i){super(i),this._element=null,this._dateInput=r.createRef(),this._dateTimeSelector=null,this.shouldFocusDateInput=!1,this.prevShow=!1,this.handleSmartPasteValue=t=>{if(t instanceof Date&&!isNaN(t.getTime())){this.applyKendoPasteDate(t);return}const s=t!=null?String(t):"";if(!s)return;const n=new Date(s);isNaN(n.getTime())||this.applyKendoPasteDate(n)},this.applyKendoPasteDate=t=>{if(!d.isInDateRange(t,this.min,this.max))return;const s=new Event("change",{bubbles:!0}),n={target:this._element,currentTarget:this._element,nativeEvent:s};this.handleValueChange({syntheticEvent:n,nativeEvent:s,value:t})},this.focus=()=>{const t=this.dateInputElement();t&&t.focus()},this.renderPicker=()=>{const{disabled:t,minTime:s,maxTime:n,format:p,calendar:u,cancelButton:h,weekNumber:v,focusedDate:f,unstyled:b}=this.props;return r.createElement(ie.DateTimeSelector,{ref:w=>{this._dateTimeSelector=w},cancelButton:h,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:n,focusedDate:f,format:p,calendar:u,mobileMode:this.mobileMode,footerActions:!this.mobileMode,unstyled:b})},this.renderAdaptivePopup=()=>{const{windowWidth:t=0}=this.state,s=m.provideLocalizationService(this).toLanguageString(l.dateTimePickerCancel,l.messages[l.dateTimePickerCancel]),n=m.provideLocalizationService(this).toLanguageString(l.dateTimePickerSet,l.messages[l.dateTimePickerSet]),p={expand:this.show,onClose:this.handleBlur,title:this.props.adaptiveTitle||this.props.label,subTitle:this.props.adaptiveSubtitle,windowWidth:t,footer:{cancelText:s,onCancel:u=>{var h;return(h=this._dateTimeSelector)==null?void 0:h.handleReject(u)},applyText:n,onApply:u=>{var h;return(h=this._dateTimeSelector)==null?void 0:h.handleAccept(u)}}};return r.createElement(ne.AdaptiveMode,{...p},r.createElement(ae.ActionSheetContent,null,this.renderPicker()))},this.handleReject=()=>{this.shouldFocusDateInput=!0,this.setShow(!1)},this.handleValueChange=t=>{this.setState({value:P.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:n}=t;if(n===o.Keys.esc){this.shouldFocusDateInput=!0,this.setShow(!1);return}s&&(n===o.Keys.up||n===o.Keys.down)&&(t.preventDefault(),t.stopPropagation(),this.shouldFocusDateInput=n===o.Keys.up,this.setShow(n===o.Keys.down))},this.dateInputElement=()=>this.dateInput&&this.dateInput.element||this.element&&this.element.querySelector(".k-dateinput > input.k-input-inner"),this.state={value:this.props.defaultValue||a.defaultProps.defaultValue,show:this.props.defaultShow||a.defaultProps.defaultShow,focused:!1}}get _popupId(){return this.props.id+"-popup-id"}get document(){if(o.canUseDOM)return this.element&&this.element.ownerDocument||document}get element(){return this._element}get dateInput(){return this._dateInput.current}get value(){const i=this.valueDuringOnChange!==void 0?this.valueDuringOnChange:this.props.value!==void 0?this.props.value:this.state.value;return i!==null?P.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:a.defaultProps.min}get max(){return this.props.max!==void 0?this.props.max:a.defaultProps.max}get validity(){const i=d.isInDateRange(this.value,this.min,this.max)&&se.isInTimeRange(this.value,this.props.minTime||d.MIN_TIME,this.props.maxTime||d.MAX_TIME),t=this.props.validationMessage!==void 0,s=(!this.required||this.value!==null)&&i,n=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:n,valueMissing:this.value===null}}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:a.defaultProps.validityStyles}get required(){return this.props.required!==void 0?this.props.required:!1}get dateInputComp(){return this.props.dateInput||a.defaultProps.dateInput}componentDidMount(){var t;this.observerResize=o.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.show&&this.forceUpdate(),(t=this.document)!=null&&t.body&&this.observerResize&&this.observerResize.observe(this.document.body);const i=this.props.name||this.props.id;this.KendoPasteSubscription=o.subscribeToKendoPaste(this._element,{fieldName:i,onValueChange:s=>{this.handleSmartPasteValue(s)}})}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,t;clearTimeout(this.nextTickId),(i=this.document)!=null&&i.body&&this.observerResize&&this.observerResize.disconnect(),(t=this.KendoPasteSubscription)==null||t.unsubscribe()}render(){const{size:i=a.defaultProps.size,rounded:t=a.defaultProps.rounded,fillMode:s=a.defaultProps.fillMode,autoFocus:n=a.defaultProps.autoFocus,inputAttributes:p,disabled:u,tabIndex:h,title:v,id:f,format:b,formatPlaceholder:w,min:C,max:M,className:k,width:x,name:E,validationMessage:q,required:R,validityStyles:F,minTime:N,maxTime:A,ariaLabelledBy:z,ariaDescribedBy:_,popup:B=J.Popup,unstyled:S,autoFill:K,twoDigitYearMax:L,enableMouseWheel:V,autoCorrectParts:j,autoSwitchParts:U,autoSwitchKeys:W,allowCaretMode:H}=this.props,y=S&&S.uDateTimePicker,D=!this.validityStyles||this.validity.valid,X={id:f,ariaLabelledBy:z,ariaDescribedBy:_,format:b,formatPlaceholder:w,disabled:u,title:v,validityStyles:F,validationMessage:q,required:R,min:C,max:M,minTime:N,maxTime:A,name:E,tabIndex:this.show?-1:h,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,unstyled:S,autoFill:K,twoDigitYearMax:L,enableMouseWheel:V,autoCorrectParts:j,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:y,size:i,fillMode:s,rounded:t,disabled:u,required:this.required,invalid:!D}),k),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.show?this._popupId:void 0,ariaHasPopup:"dialog",autoFocus:n,inputAttributes:p,...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:y})),fillMode:s,"aria-label":m.provideLocalizationService(this).toLanguageString(l.toggleDateTimeSelector,l.messages[l.toggleDateTimeSelector])}),r.createElement(B,{show:this.show,animate:this.element!==null,anchor:this.element,popupClass:o.classNames(o.uDateTimePicker.popup({c:y})),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})}};a.displayName="DateTimePicker",a.propTypes={className:e.string,defaultShow:e.bool,defaultValue:e.instanceOf(Date),disabled:e.bool,focusedDate:e.instanceOf(Date),format:e.oneOfType([e.string,e.shape({skeleton:e.string,pattern:e.string,date:e.oneOf(["short","medium","long","full"]),time:e.oneOf(["short","medium","long","full"]),datetime:e.oneOf(["short","medium","long","full"]),era:e.oneOf(["narrow","short","long"]),year:e.oneOf(["numeric","2-digit"]),month:e.oneOf(["numeric","2-digit","narrow","short","long"]),day:e.oneOf(["numeric","2-digit"]),weekday:e.oneOf(["narrow","short","long"]),hour:e.oneOf(["numeric","2-digit"]),hour12:e.bool,minute:e.oneOf(["numeric","2-digit"]),second:e.oneOf(["numeric","2-digit"]),timeZoneName:e.oneOf(["short","long"])})]),formatPlaceholder:e.oneOfType([e.oneOf(["wide","narrow","short","formatPattern"]),e.shape({year:e.string,month:e.string,day:e.string,hour:e.string,minute:e.string,second:e.string})]),id:e.string,ariaLabelledBy:e.string,ariaDescribedBy:e.string,min:e.instanceOf(Date),max:e.instanceOf(Date),name:e.string,popupSettings:e.shape({animate:e.bool,appendTo:e.any,popupClass:e.string}),show:e.bool,tabIndex:e.number,title:e.string,value:e.instanceOf(Date),weekNumber:e.bool,width:e.oneOfType([e.number,e.string]),validationMessage:e.string,required:e.bool,validate:e.bool,valid:e.bool,cancelButton:e.bool,size:e.oneOf(["small","medium","large"]),rounded:e.oneOf(["small","medium","large","full","none"]),fillMode:e.oneOf(["solid","flat","outline"]),autoFocus:e.bool,inputAttributes:e.object},a.defaultProps={defaultShow:!1,defaultValue:null,disabled:!1,format:"g",max:d.MAX_DATE,min:d.MIN_DATE,popupSettings:{},tabIndex:0,weekNumber:!1,validityStyles:!0,cancelButton:!0,dateInput:ee.DateInput,size:void 0,rounded:void 0,fillMode:void 0,autoFocus:!1};let g=a;const I=o.createPropsContext(),O=o.withIdHOC(o.withPropsContext(I,o.withUnstyledHOC(o.withAdaptiveModeContext(g))));O.displayName="KendoReactDateTimePicker";m.registerForLocalization(g);exports.DateTimePicker=O;exports.DateTimePickerPropsContext=I;exports.DateTimePickerWithoutContext=g;
|
|
@@ -356,7 +356,7 @@ const a = class a extends n.Component {
|
|
|
356
356
|
{
|
|
357
357
|
_ref: this._dateInput,
|
|
358
358
|
ariaRole: "combobox",
|
|
359
|
-
ariaControls: this._popupId,
|
|
359
|
+
ariaControls: this.show ? this._popupId : void 0,
|
|
360
360
|
ariaHasPopup: "dialog",
|
|
361
361
|
autoFocus: o,
|
|
362
362
|
inputAttributes: h,
|
|
@@ -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"),
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("react"),b=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"),D=require("../timepicker/utils.js");function S(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=S(E),v=class v 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}))},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),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))},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:D.getNow()}),this.handleAccept(e,D.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=>{var i;const{keyCode:t}=e;t===a.Keys.tab&&((i=this._dateButtonRef)!=null&&i.element)&&(e.preventDefault(),this._dateButtonRef.element.focus())},this.handleSetKeyDown=e=>{var i;const{keyCode:t}=e;t===a.Keys.tab&&!this.props.cancelButton&&((i=this._dateButtonRef)!=null&&i.element)&&(e.preventDefault(),this._dateButtonRef.element.focus())},this.handleDateKeyDown=e=>{var r,h,l;const{keyCode:t,shiftKey:i}=e;i&&t===a.Keys.tab&&(e.stopPropagation(),(r=this._cancelButton)!=null&&r.element?this._cancelButton.element.focus():(l=(h=this._acceptButton)==null?void 0:h.element)==null||l.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 b.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:_,unstyled:g}=this.props,m=g&&g.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:g},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: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}};v.defaultProps={footerActions:!0};let f=v;b.registerForLocalization(f);exports.DateTimeSelector=f;
|