@progress/kendo-react-dateinputs 11.0.0-develop.5 → 11.0.0-develop.7
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/datepicker/DatePicker.js +1 -1
- package/datepicker/DatePicker.mjs +88 -86
- package/daterangepicker/DateRangePicker.js +1 -1
- package/daterangepicker/DateRangePicker.mjs +60 -52
- 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 +0 -1
- package/timepicker/TimeSelector.js +1 -1
- package/timepicker/TimeSelector.mjs +49 -48
- package/utils.js +1 -1
- package/utils.mjs +3 -1
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
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const at=require("react"),e=require("prop-types"),ot=require("@progress/kendo-react-popup"),W=require("@progress/kendo-date-math"),i=require("@progress/kendo-react-common"),rt=require("@progress/kendo-svg-icons"),lt=require("../dateinput/DateInput.js"),ut=require("../calendar/components/Calendar.js"),o=require("../utils.js"),j=require("../messages/index.js"),it=require("@progress/kendo-react-intl"),st=require("./ToggleButton.js"),ct=require("../common/PickerWrap.js"),dt=require("../hooks/usePickerFloatingLabel.js"),ft=require("@progress/kendo-react-layout"),mt=require("../common/AdaptiveMode.js");function pt(n){const v=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const m in n)if(m!=="default"){const M=Object.getOwnPropertyDescriptor(n,m);Object.defineProperty(v,m,M.get?M:{enumerable:!0,get:()=>n[m]})}}return v.default=n,Object.freeze(v)}const a=pt(at),U=a.forwardRef((n,v)=>{const m=i.useId(n.id),M=it.useLocalization(),w=i.useAdaptiveModeContext(),{defaultShow:se=l.defaultShow,defaultValue:ce=l.defaultValue,dateInput:de=l.dateInput,calendar:fe=l.calendar,toggleButton:me=l.toggleButton,popup:pe=l.popup,pickerWrap:gt=l.pickerWrap,disabled:y=l.disabled,format:ge=l.format,max:_=l.max,min:T=l.min,popupSettings:k=l.popupSettings,tabIndex:be=l.tabIndex,weekNumber:he=l.weekNumber,validityStyles:H=l.validityStyles,size:B=l.size,rounded:E=l.rounded,fillMode:x=l.fillMode,autoFocus:ve=l.autoFocus,show:Y,autoSwitchParts:we,autoSwitchKeys:ye,twoDigitYearMax:ke,ariaLabel:De,adaptive:bt,adaptiveTitle:Ce=n.label||void 0,adaptiveSubtitle:Pe,formatPlaceholder:Oe,inputAttributes:Me,validationMessage:$,visited:ht,value:q,touched:vt,modified:wt,_adaptiveMode:yt=w,valid:X,focusedDate:Re,id:Se,ariaLabelledBy:Ie,ariaDescribedBy:_e,placeholder:Te,...Z}=i.usePropsContext(ie,n),A=()=>{if(i.canUseDOM)return C.current&&C.current.ownerDocument||window.document},s=()=>!!(h.windowWidth&&w&&h.windowWidth<=(w==null?void 0:w.medium)&&n.adaptive),p=()=>{const t=R.current!==void 0?R.current:q!==void 0?q:h.value;return t!==null?W.cloneDate(t):null},u=()=>S.current!==void 0?S.current:Y!==void 0?Y:h.show,Be=()=>de||l.dateInput,Ee=()=>me||l.toggleButton,xe=()=>fe||l.calendar,qe=()=>pe||l.popup,G=()=>n.required!==void 0?n.required:!1,N=()=>{const t=p()||q||null,r=T,c=_,I=o.isInDateRange(t,r,c),z=$!==void 0,L=(!G()||t!=null)&&I,K=X!==void 0?X:L;return{customError:z,rangeOverflow:t&&c.getTime()<t.getTime()||!1,rangeUnderflow:t&&t.getTime()<r.getTime()||!1,valid:K,valueMissing:t===null}},Ae=t=>{for(const r of t)O({windowWidth:r.target.clientWidth})},Ne=()=>{d.current&&d.current.focus()},J=t=>{f.current=t},g=t=>{u()!==t&&(O({show:t}),t&&n.onOpen&&n.onOpen.call(void 0,{target:D.current}),!t&&n.onClose&&n.onClose.call(void 0,{target:D.current}))},Fe=t=>{const r=p();return r&&t?o.setTime(t,r):t},Ve=t=>{k!=null&&k.onMouseDownOutside&&k.onMouseDownOutside.call(void 0,t)},Q=(t,r)=>{O({value:W.cloneDate(t||void 0)}),R.current=t,S.current=!1,s()||(b.current=!0),n.onChange&&n.onChange.call(void 0,{syntheticEvent:r.syntheticEvent,nativeEvent:r.nativeEvent,value:p(),show:u(),target:D.current}),R.current=void 0,S.current=void 0,g(!1)},ze=t=>{const r=Fe(t.value);Q(r,t)},ee=()=>{const{popupClass:t,...r}=k,c=u(),I=p(),z=I&&W.getDate(I),L=i.classNames(t),K={popupClass:"k-datepicker-popup",show:c,anchor:C.current,className:L,id:ne,anchorAlign:{horizontal:"left",vertical:"bottom"},popupAlign:{horizontal:"left",vertical:"top"},...r,onMouseDownOutside:Ve},le={disabled:y,value:z,min:T,max:_,weekNumber:he,focusedDate:Re,className:s()?"k-calendar-lg":"",navigation:!s(),onChange:ze},ue=xe(),nt=qe();return s()?a.createElement(ue,{_ref:J,...le}):a.createElement(nt,{...K},a.createElement(ue,{_ref:J,...le}))},te=()=>{O({focused:!1}),g(!1)},Le=()=>{const{windowWidth:t=0}=h,r={expand:u(),onClose:te,title:Ce,subTitle:Pe,windowWidth:t};return a.createElement(mt.AdaptiveMode,{...r},a.createElement(ft.ActionSheetContent,null,ee()))},Ke=t=>{Q(t.value,t)},We=()=>{O({focused:!0})},je=()=>{g(!u())},F=()=>{y||(b.current=!0,g(!u()))},Ue=t=>{t.preventDefault()},He=t=>{const{altKey:r,keyCode:c}=t;if(c===i.Keys.esc&&u()){b.current=!0,g(!1);return}r&&(c===i.Keys.up||c===i.Keys.down)&&(t.preventDefault(),t.stopPropagation(),b.current=c===i.Keys.up,g(c===i.Keys.down))},D=a.useRef(null),C=a.useRef(null),d=a.useRef(null),f=a.useRef(null);a.useImperativeHandle(D,()=>({props:n,get element(){return C.current},get calendar(){return f.current},get dateInput(){return d.current},get name(){return n.name},get show(){return u()},get validity(){return N()},get value(){return p()},get mobileMode(){return s()},togglePopup:je,focus:Ne})),a.useImperativeHandle(v,()=>D.current);const R=a.useRef(void 0),S=a.useRef(void 0),Ye=a.useRef(null),b=a.useRef(!1),V=a.useRef(!1),P=a.useRef(null),[h,$e]=a.useState({value:ce,show:se,focused:!1}),[,Xe]=a.useReducer(t=>t,!0),O=t=>{$e(r=>({...r,...t}))};a.useEffect(()=>{f.current&&f.current.element&&u()&&!V.current&&f.current.element.focus({preventScroll:!0}),s()&&u()&&!V.current&&setTimeout(()=>{f.current&&f.current.element&&f.current.element.focus({preventScroll:!0})},300),d.current&&d.current.element&&!u()&&b.current&&d.current.element.focus({preventScroll:!0}),V.current=u(),b.current=!1}),a.useEffect(()=>{var t;return P.current=i.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(r=>Ae(r)),u()&&Xe(),(t=A())!=null&&t.body&&P.current&&P.current.observe(A().body),()=>{var r;clearTimeout(Ye.current),(r=A())!=null&&r.body&&P.current&&P.current.disconnect()}},[]);const ne=m+"-popup-id",Ze=ee(),Ge=Be(),Je=p(),Qe=Ee(),et=Le(),ae=!H||N().valid,oe=M.toLanguageString(j.toggleCalendar,j.messages[j.toggleCalendar]),tt={disabled:y,format:ge,formatPlaceholder:Oe,id:Se,ariaLabelledBy:Ie,ariaDescribedBy:_e,ariaLabel:De,max:_,min:T,name:n.name,onChange:Ke,required:n.required,_ref:d,tabIndex:u()?-1:be,title:n.title,valid:N().valid,validationMessage:$,validityStyles:H,value:Je,label:void 0,placeholder:h.focused?null:Te,ariaExpanded:u(),size:null,fillMode:null,rounded:null,autoFill:n.autoFill,twoDigitYearMax:ke,enableMouseWheel:n.enableMouseWheel,autoCorrectParts:n.autoCorrectParts,autoSwitchParts:we,autoSwitchKeys:ye,allowCaretMode:n.allowCaretMode,inputAttributes:Me},re=a.createElement(i.AsyncFocusBlur,{onFocus:We,onBlur:s()?void 0:te,onSyncBlur:n.onBlur,onSyncFocus:n.onFocus},t=>a.createElement(a.Fragment,null,a.createElement("span",{...n.label?{}:Z,ref:C,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":!ae,"k-required":G(),"k-disabled":y},n.className),onKeyDown:He,style:{width:n.width},onFocus:s()?F:t.onFocus,onBlur:t.onBlur,onClick:s()?F:void 0},a.createElement(Ge,{_ref:d,ariaRole:"combobox",ariaExpanded:u(),ariaControls:ne,autoFocus:ve,...tt}),a.createElement(Qe,{type:"button",icon:"calendar",svgIcon:rt.calendarIcon,title:oe,className:"k-input-button",rounded:null,onClick:s()?void 0:F,"aria-label":oe,fillMode:x,onMouseDown:Ue}),!s()&&Ze),s()&&et));return n.label?a.createElement(dt.PickerFloatingLabel,{dateInput:d,label:n.label,editorId:m,editorValid:ae,editorDisabled:y,children:re,style:{width:n.width},...Z}):re});U.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:o.nullable(e.string),pattern:o.nullable(e.string),date:o.nullable(e.oneOf(["short","medium","long","full"])),time:o.nullable(e.oneOf(["short","medium","long","full"])),datetime:o.nullable(e.oneOf(["short","medium","long","full"])),era:o.nullable(e.oneOf(["narrow","short","long"])),year:o.nullable(e.oneOf(["numeric","2-digit"])),month:o.nullable(e.oneOf(["numeric","2-digit","narrow","short","long"])),day:o.nullable(e.oneOf(["numeric","2-digit"])),weekday:o.nullable(e.oneOf(["narrow","short","long"])),hour:o.nullable(e.oneOf(["numeric","2-digit"])),hour12:o.nullable(e.bool),minute:o.nullable(e.oneOf(["numeric","2-digit"])),second:o.nullable(e.oneOf(["numeric","2-digit"])),timeZoneName:o.nullable(e.oneOf(["short","long"]))})]),formatPlaceholder:e.oneOfType([o.nullable(e.oneOf(["wide","narrow","short","formatPattern"])),e.shape({year:o.nullable(e.string),month:o.nullable(e.string),day:o.nullable(e.string),hour:o.nullable(e.string),minute:o.nullable(e.string),second:o.nullable(e.string)})]),id:e.string,ariaLabelledBy:e.string,ariaDescribedBy:e.string,ariaLabel:e.string,min:e.instanceOf(Date),max:e.instanceOf(Date),name:e.string,popupSettings:e.shape({animate:o.nullable(e.bool),appendTo:o.nullable(e.any),popupClass:o.nullable(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,valid:e.bool,size:e.oneOf([null,"small","medium","large"]),rounded:e.oneOf([null,"small","medium","large","full"]),fillMode:e.oneOf([null,"solid","flat","outline"]),adaptive:e.bool,adaptiveTitle:e.string,adaptiveSubtitle:e.string,autoFocus:e.bool,inputAttributes:e.object};const l={defaultShow:!1,defaultValue:null,dateInput:lt.DateInput,calendar:ut.Calendar,toggleButton:st.ToggleButton,popup:ot.Popup,pickerWrap:ct.PickerWrap,disabled:!1,format:"d",max:o.MAX_DATE,min:o.MIN_DATE,popupSettings:{},tabIndex:0,weekNumber:!1,validityStyles:!0,size:"medium",rounded:"medium",fillMode:"solid",autoFocus:!1},ie=i.createPropsContext();U.displayName="KendoReactDatePicker";exports.DatePicker=U;exports.DatePickerPropsContext=ie;exports.datePickerDefaultProps=l;
|
|
@@ -7,29 +7,29 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import * as o from "react";
|
|
9
9
|
import e from "prop-types";
|
|
10
|
-
import { Popup as
|
|
11
|
-
import { cloneDate as oe, getDate as
|
|
12
|
-
import { useId as
|
|
13
|
-
import { calendarIcon as
|
|
14
|
-
import { DateInput as
|
|
15
|
-
import { Calendar as
|
|
16
|
-
import { nullable as a, MAX_DATE as
|
|
17
|
-
import { toggleCalendar as ie, messages as
|
|
18
|
-
import { useLocalization as
|
|
19
|
-
import { ToggleButton as
|
|
20
|
-
import { PickerWrap as
|
|
21
|
-
import { PickerFloatingLabel as
|
|
22
|
-
import { ActionSheetContent as
|
|
23
|
-
import { AdaptiveMode as
|
|
10
|
+
import { Popup as at } from "@progress/kendo-react-popup";
|
|
11
|
+
import { cloneDate as oe, getDate as lt } from "@progress/kendo-date-math";
|
|
12
|
+
import { useId as it, useAdaptiveModeContext as ut, usePropsContext as st, canUseDOM as re, AsyncFocusBlur as ct, classNames as ae, kendoThemeMaps as le, createPropsContext as dt, Keys as k } from "@progress/kendo-react-common";
|
|
13
|
+
import { calendarIcon as ft } from "@progress/kendo-svg-icons";
|
|
14
|
+
import { DateInput as mt } from "../dateinput/DateInput.mjs";
|
|
15
|
+
import { Calendar as pt } from "../calendar/components/Calendar.mjs";
|
|
16
|
+
import { nullable as a, MAX_DATE as gt, MIN_DATE as ht, isInDateRange as vt, setTime as bt } from "../utils.mjs";
|
|
17
|
+
import { toggleCalendar as ie, messages as wt } from "../messages/index.mjs";
|
|
18
|
+
import { useLocalization as yt } from "@progress/kendo-react-intl";
|
|
19
|
+
import { ToggleButton as Ct } from "./ToggleButton.mjs";
|
|
20
|
+
import { PickerWrap as Dt } from "../common/PickerWrap.mjs";
|
|
21
|
+
import { PickerFloatingLabel as kt } from "../hooks/usePickerFloatingLabel.mjs";
|
|
22
|
+
import { ActionSheetContent as Ot } from "@progress/kendo-react-layout";
|
|
23
|
+
import { AdaptiveMode as Mt } from "../common/AdaptiveMode.mjs";
|
|
24
24
|
const ue = o.forwardRef((n, se) => {
|
|
25
|
-
const L =
|
|
25
|
+
const L = it(n.id), ce = yt(), h = ut(), {
|
|
26
26
|
defaultShow: de = l.defaultShow,
|
|
27
27
|
defaultValue: fe = l.defaultValue,
|
|
28
28
|
dateInput: me = l.dateInput,
|
|
29
29
|
calendar: pe = l.calendar,
|
|
30
30
|
toggleButton: ge = l.toggleButton,
|
|
31
31
|
popup: he = l.popup,
|
|
32
|
-
pickerWrap:
|
|
32
|
+
pickerWrap: Rt = l.pickerWrap,
|
|
33
33
|
disabled: v = l.disabled,
|
|
34
34
|
format: ve = l.format,
|
|
35
35
|
max: R = l.max,
|
|
@@ -39,38 +39,40 @@ const ue = o.forwardRef((n, se) => {
|
|
|
39
39
|
weekNumber: we = l.weekNumber,
|
|
40
40
|
validityStyles: W = l.validityStyles,
|
|
41
41
|
size: S = l.size,
|
|
42
|
-
rounded:
|
|
43
|
-
fillMode:
|
|
42
|
+
rounded: _ = l.rounded,
|
|
43
|
+
fillMode: E = l.fillMode,
|
|
44
44
|
autoFocus: ye = l.autoFocus,
|
|
45
45
|
show: K,
|
|
46
46
|
autoSwitchParts: Ce,
|
|
47
47
|
autoSwitchKeys: De,
|
|
48
48
|
twoDigitYearMax: ke,
|
|
49
49
|
ariaLabel: Oe,
|
|
50
|
-
adaptive:
|
|
50
|
+
adaptive: It,
|
|
51
51
|
adaptiveTitle: Me = n.label || void 0,
|
|
52
52
|
adaptiveSubtitle: Pe,
|
|
53
53
|
formatPlaceholder: Re,
|
|
54
54
|
inputAttributes: Ie,
|
|
55
55
|
validationMessage: q,
|
|
56
|
-
visited:
|
|
57
|
-
value:
|
|
58
|
-
touched:
|
|
59
|
-
modified:
|
|
60
|
-
_adaptiveMode:
|
|
56
|
+
visited: St,
|
|
57
|
+
value: B,
|
|
58
|
+
touched: _t,
|
|
59
|
+
modified: Et,
|
|
60
|
+
_adaptiveMode: Bt = h,
|
|
61
61
|
valid: H,
|
|
62
62
|
focusedDate: Se,
|
|
63
|
-
id:
|
|
64
|
-
ariaLabelledBy:
|
|
63
|
+
id: _e,
|
|
64
|
+
ariaLabelledBy: Ee,
|
|
65
|
+
ariaDescribedBy: Be,
|
|
66
|
+
placeholder: xe,
|
|
65
67
|
...U
|
|
66
|
-
} =
|
|
68
|
+
} = st(Pt, n), x = () => {
|
|
67
69
|
if (re)
|
|
68
70
|
return y.current && y.current.ownerDocument || window.document;
|
|
69
71
|
}, u = () => !!(g.windowWidth && h && g.windowWidth <= (h == null ? void 0 : h.medium) && n.adaptive), f = () => {
|
|
70
|
-
const t = O.current !== void 0 ? O.current :
|
|
72
|
+
const t = O.current !== void 0 ? O.current : B !== void 0 ? B : g.value;
|
|
71
73
|
return t !== null ? oe(t) : null;
|
|
72
|
-
}, i = () => M.current !== void 0 ? M.current : K !== void 0 ? K : g.show,
|
|
73
|
-
const t = f() ||
|
|
74
|
+
}, i = () => M.current !== void 0 ? M.current : K !== void 0 ? K : g.show, Te = () => me || l.dateInput, Ae = () => ge || l.toggleButton, Ve = () => pe || l.calendar, Fe = () => he || l.popup, Y = () => n.required !== void 0 ? n.required : !1, T = () => {
|
|
75
|
+
const t = f() || B || null, r = I, s = R, P = vt(t, r, s), F = q !== void 0, N = (!Y() || t != null) && P, z = H !== void 0 ? H : N;
|
|
74
76
|
return {
|
|
75
77
|
customError: F,
|
|
76
78
|
rangeOverflow: t && s.getTime() < t.getTime() || !1,
|
|
@@ -78,19 +80,19 @@ const ue = o.forwardRef((n, se) => {
|
|
|
78
80
|
valid: z,
|
|
79
81
|
valueMissing: t === null
|
|
80
82
|
};
|
|
81
|
-
},
|
|
83
|
+
}, Ne = (t) => {
|
|
82
84
|
for (const r of t)
|
|
83
85
|
D({ windowWidth: r.target.clientWidth });
|
|
84
|
-
},
|
|
86
|
+
}, ze = () => {
|
|
85
87
|
c.current && c.current.focus();
|
|
86
88
|
}, $ = (t) => {
|
|
87
89
|
d.current = t;
|
|
88
90
|
}, m = (t) => {
|
|
89
91
|
i() !== t && (D({ show: t }), t && n.onOpen && n.onOpen.call(void 0, { target: w.current }), !t && n.onClose && n.onClose.call(void 0, { target: w.current }));
|
|
90
|
-
},
|
|
92
|
+
}, Le = (t) => {
|
|
91
93
|
const r = f();
|
|
92
|
-
return r && t ?
|
|
93
|
-
},
|
|
94
|
+
return r && t ? bt(t, r) : t;
|
|
95
|
+
}, We = (t) => {
|
|
94
96
|
b != null && b.onMouseDownOutside && b.onMouseDownOutside.call(void 0, t);
|
|
95
97
|
}, j = (t, r) => {
|
|
96
98
|
D({ value: oe(t || void 0) }), O.current = t, M.current = !1, u() || (p.current = !0), n.onChange && n.onChange.call(void 0, {
|
|
@@ -100,11 +102,11 @@ const ue = o.forwardRef((n, se) => {
|
|
|
100
102
|
show: i(),
|
|
101
103
|
target: w.current
|
|
102
104
|
}), O.current = void 0, M.current = void 0, m(!1);
|
|
103
|
-
},
|
|
104
|
-
const r =
|
|
105
|
+
}, Ke = (t) => {
|
|
106
|
+
const r = Le(t.value);
|
|
105
107
|
j(r, t);
|
|
106
108
|
}, X = () => {
|
|
107
|
-
const { popupClass: t, ...r } = b, s = i(), P = f(), F = P &&
|
|
109
|
+
const { popupClass: t, ...r } = b, s = i(), P = f(), F = P && lt(P), N = ae(t), z = {
|
|
108
110
|
popupClass: "k-datepicker-popup",
|
|
109
111
|
show: s,
|
|
110
112
|
anchor: y.current,
|
|
@@ -119,7 +121,7 @@ const ue = o.forwardRef((n, se) => {
|
|
|
119
121
|
vertical: "top"
|
|
120
122
|
},
|
|
121
123
|
...r,
|
|
122
|
-
onMouseDownOutside:
|
|
124
|
+
onMouseDownOutside: We
|
|
123
125
|
}, te = {
|
|
124
126
|
disabled: v,
|
|
125
127
|
value: F,
|
|
@@ -129,12 +131,12 @@ const ue = o.forwardRef((n, se) => {
|
|
|
129
131
|
focusedDate: Se,
|
|
130
132
|
className: u() ? "k-calendar-lg" : "",
|
|
131
133
|
navigation: !u(),
|
|
132
|
-
onChange:
|
|
133
|
-
}, ne =
|
|
134
|
-
return u() ? /* @__PURE__ */ o.createElement(ne, { _ref: $, ...te }) : /* @__PURE__ */ o.createElement(
|
|
134
|
+
onChange: Ke
|
|
135
|
+
}, ne = Ve(), rt = Fe();
|
|
136
|
+
return u() ? /* @__PURE__ */ o.createElement(ne, { _ref: $, ...te }) : /* @__PURE__ */ o.createElement(rt, { ...z }, /* @__PURE__ */ o.createElement(ne, { _ref: $, ...te }));
|
|
135
137
|
}, Z = () => {
|
|
136
138
|
D({ focused: !1 }), m(!1);
|
|
137
|
-
},
|
|
139
|
+
}, qe = () => {
|
|
138
140
|
const { windowWidth: t = 0 } = g, r = {
|
|
139
141
|
expand: i(),
|
|
140
142
|
onClose: Z,
|
|
@@ -142,18 +144,18 @@ const ue = o.forwardRef((n, se) => {
|
|
|
142
144
|
subTitle: Pe,
|
|
143
145
|
windowWidth: t
|
|
144
146
|
};
|
|
145
|
-
return /* @__PURE__ */ o.createElement(
|
|
146
|
-
},
|
|
147
|
+
return /* @__PURE__ */ o.createElement(Mt, { ...r }, /* @__PURE__ */ o.createElement(Ot, null, X()));
|
|
148
|
+
}, He = (t) => {
|
|
147
149
|
j(t.value, t);
|
|
148
|
-
},
|
|
150
|
+
}, Ue = () => {
|
|
149
151
|
D({ focused: !0 });
|
|
150
|
-
},
|
|
152
|
+
}, Ye = () => {
|
|
151
153
|
m(!i());
|
|
152
154
|
}, A = () => {
|
|
153
155
|
v || (p.current = !0, m(!i()));
|
|
154
|
-
},
|
|
156
|
+
}, $e = (t) => {
|
|
155
157
|
t.preventDefault();
|
|
156
|
-
},
|
|
158
|
+
}, je = (t) => {
|
|
157
159
|
const { altKey: r, keyCode: s } = t;
|
|
158
160
|
if (s === k.esc && i()) {
|
|
159
161
|
p.current = !0, m(!1);
|
|
@@ -189,17 +191,17 @@ const ue = o.forwardRef((n, se) => {
|
|
|
189
191
|
get mobileMode() {
|
|
190
192
|
return u();
|
|
191
193
|
},
|
|
192
|
-
togglePopup:
|
|
194
|
+
togglePopup: Ye,
|
|
193
195
|
// Hidden Methods but still accessible
|
|
194
|
-
focus:
|
|
196
|
+
focus: ze
|
|
195
197
|
})
|
|
196
198
|
), o.useImperativeHandle(se, () => w.current);
|
|
197
|
-
const O = o.useRef(void 0), M = o.useRef(void 0),
|
|
199
|
+
const O = o.useRef(void 0), M = o.useRef(void 0), Xe = o.useRef(null), p = o.useRef(!1), V = o.useRef(!1), C = o.useRef(null), [g, Ze] = o.useState({
|
|
198
200
|
value: fe,
|
|
199
201
|
show: de,
|
|
200
202
|
focused: !1
|
|
201
|
-
}), [,
|
|
202
|
-
|
|
203
|
+
}), [, Ge] = o.useReducer((t) => t, !0), D = (t) => {
|
|
204
|
+
Ze((r) => ({ ...r, ...t }));
|
|
203
205
|
};
|
|
204
206
|
o.useEffect(() => {
|
|
205
207
|
d.current && d.current.element && i() && !V.current && d.current.element.focus({ preventScroll: !0 }), u() && i() && !V.current && setTimeout(() => {
|
|
@@ -207,23 +209,23 @@ const ue = o.forwardRef((n, se) => {
|
|
|
207
209
|
}, 300), c.current && c.current.element && !i() && p.current && c.current.element.focus({ preventScroll: !0 }), V.current = i(), p.current = !1;
|
|
208
210
|
}), o.useEffect(() => {
|
|
209
211
|
var t;
|
|
210
|
-
return C.current = re && window.ResizeObserver && new window.ResizeObserver((r) =>
|
|
212
|
+
return C.current = re && window.ResizeObserver && new window.ResizeObserver((r) => Ne(r)), i() && Ge(), (t = x()) != null && t.body && C.current && C.current.observe(x().body), () => {
|
|
211
213
|
var r;
|
|
212
|
-
clearTimeout(
|
|
214
|
+
clearTimeout(Xe.current), (r = x()) != null && r.body && C.current && C.current.disconnect();
|
|
213
215
|
};
|
|
214
216
|
}, []);
|
|
215
|
-
const G = L + "-popup-id",
|
|
217
|
+
const G = L + "-popup-id", Je = X(), Qe = Te(), et = f(), tt = Ae(), nt = qe(), J = !W || T().valid, Q = ce.toLanguageString(ie, wt[ie]), ot = {
|
|
216
218
|
disabled: v,
|
|
217
219
|
format: ve,
|
|
218
220
|
formatPlaceholder: Re,
|
|
219
|
-
id:
|
|
220
|
-
ariaLabelledBy:
|
|
221
|
-
ariaDescribedBy:
|
|
221
|
+
id: _e,
|
|
222
|
+
ariaLabelledBy: Ee,
|
|
223
|
+
ariaDescribedBy: Be,
|
|
222
224
|
ariaLabel: Oe,
|
|
223
225
|
max: R,
|
|
224
226
|
min: I,
|
|
225
227
|
name: n.name,
|
|
226
|
-
onChange:
|
|
228
|
+
onChange: He,
|
|
227
229
|
required: n.required,
|
|
228
230
|
_ref: c,
|
|
229
231
|
tabIndex: i() ? -1 : be,
|
|
@@ -231,9 +233,9 @@ const ue = o.forwardRef((n, se) => {
|
|
|
231
233
|
valid: T().valid,
|
|
232
234
|
validationMessage: q,
|
|
233
235
|
validityStyles: W,
|
|
234
|
-
value:
|
|
236
|
+
value: et,
|
|
235
237
|
label: void 0,
|
|
236
|
-
placeholder: g.focused ? null :
|
|
238
|
+
placeholder: g.focused ? null : xe,
|
|
237
239
|
ariaExpanded: i(),
|
|
238
240
|
size: null,
|
|
239
241
|
fillMode: null,
|
|
@@ -247,9 +249,9 @@ const ue = o.forwardRef((n, se) => {
|
|
|
247
249
|
allowCaretMode: n.allowCaretMode,
|
|
248
250
|
inputAttributes: Ie
|
|
249
251
|
}, ee = /* @__PURE__ */ o.createElement(
|
|
250
|
-
|
|
252
|
+
ct,
|
|
251
253
|
{
|
|
252
|
-
onFocus:
|
|
254
|
+
onFocus: Ue,
|
|
253
255
|
onBlur: u() ? void 0 : Z,
|
|
254
256
|
onSyncBlur: n.onBlur,
|
|
255
257
|
onSyncFocus: n.onFocus
|
|
@@ -264,51 +266,51 @@ const ue = o.forwardRef((n, se) => {
|
|
|
264
266
|
"k-datepicker",
|
|
265
267
|
{
|
|
266
268
|
[`k-input-${le.sizeMap[S] || S}`]: S,
|
|
267
|
-
[`k-rounded-${le.roundedMap[
|
|
268
|
-
[`k-input-${
|
|
269
|
+
[`k-rounded-${le.roundedMap[_] || _}`]: _,
|
|
270
|
+
[`k-input-${E}`]: E,
|
|
269
271
|
"k-invalid": !J,
|
|
270
272
|
"k-required": Y(),
|
|
271
273
|
"k-disabled": v
|
|
272
274
|
},
|
|
273
275
|
n.className
|
|
274
276
|
),
|
|
275
|
-
onKeyDown:
|
|
277
|
+
onKeyDown: je,
|
|
276
278
|
style: { width: n.width },
|
|
277
279
|
onFocus: u() ? A : t.onFocus,
|
|
278
280
|
onBlur: t.onBlur,
|
|
279
281
|
onClick: u() ? A : void 0
|
|
280
282
|
},
|
|
281
283
|
/* @__PURE__ */ o.createElement(
|
|
282
|
-
|
|
284
|
+
Qe,
|
|
283
285
|
{
|
|
284
286
|
_ref: c,
|
|
285
287
|
ariaRole: "combobox",
|
|
286
288
|
ariaExpanded: i(),
|
|
287
289
|
ariaControls: G,
|
|
288
290
|
autoFocus: ye,
|
|
289
|
-
...
|
|
291
|
+
...ot
|
|
290
292
|
}
|
|
291
293
|
),
|
|
292
294
|
/* @__PURE__ */ o.createElement(
|
|
293
|
-
|
|
295
|
+
tt,
|
|
294
296
|
{
|
|
295
297
|
type: "button",
|
|
296
298
|
icon: "calendar",
|
|
297
|
-
svgIcon:
|
|
299
|
+
svgIcon: ft,
|
|
298
300
|
title: Q,
|
|
299
301
|
className: "k-input-button",
|
|
300
302
|
rounded: null,
|
|
301
303
|
onClick: u() ? void 0 : A,
|
|
302
304
|
"aria-label": Q,
|
|
303
|
-
fillMode:
|
|
304
|
-
onMouseDown:
|
|
305
|
+
fillMode: E,
|
|
306
|
+
onMouseDown: $e
|
|
305
307
|
}
|
|
306
308
|
),
|
|
307
|
-
!u() &&
|
|
308
|
-
), u() &&
|
|
309
|
+
!u() && Je
|
|
310
|
+
), u() && nt)
|
|
309
311
|
);
|
|
310
312
|
return n.label ? /* @__PURE__ */ o.createElement(
|
|
311
|
-
|
|
313
|
+
kt,
|
|
312
314
|
{
|
|
313
315
|
dateInput: c,
|
|
314
316
|
label: n.label,
|
|
@@ -393,15 +395,15 @@ ue.propTypes = {
|
|
|
393
395
|
const l = {
|
|
394
396
|
defaultShow: !1,
|
|
395
397
|
defaultValue: null,
|
|
396
|
-
dateInput:
|
|
397
|
-
calendar:
|
|
398
|
-
toggleButton:
|
|
399
|
-
popup:
|
|
400
|
-
pickerWrap:
|
|
398
|
+
dateInput: mt,
|
|
399
|
+
calendar: pt,
|
|
400
|
+
toggleButton: Ct,
|
|
401
|
+
popup: at,
|
|
402
|
+
pickerWrap: Dt,
|
|
401
403
|
disabled: !1,
|
|
402
404
|
format: "d",
|
|
403
|
-
max:
|
|
404
|
-
min:
|
|
405
|
+
max: gt,
|
|
406
|
+
min: ht,
|
|
405
407
|
popupSettings: {},
|
|
406
408
|
tabIndex: 0,
|
|
407
409
|
weekNumber: !1,
|
|
@@ -410,10 +412,10 @@ const l = {
|
|
|
410
412
|
rounded: "medium",
|
|
411
413
|
fillMode: "solid",
|
|
412
414
|
autoFocus: !1
|
|
413
|
-
},
|
|
415
|
+
}, Pt = dt();
|
|
414
416
|
ue.displayName = "KendoReactDatePicker";
|
|
415
417
|
export {
|
|
416
418
|
ue as DatePicker,
|
|
417
|
-
|
|
419
|
+
Pt as DatePickerPropsContext,
|
|
418
420
|
l as datePickerDefaultProps
|
|
419
421
|
};
|
|
@@ -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"),x=require("../package-metadata.js"),f=require("../dateinput/DateInput.js"),P=require("../calendar/components/MultiViewCalendar.js"),h=require("../calendar/models/SelectionRange.js"),u=require("../utils.js"),n=require("../messages/index.js"),_=require("@progress/kendo-react-buttons"),A=require("../common/AdaptiveMode.js"),N=require("@progress/kendo-react-layout");function F(d){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(d){for(const e in d)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(d,e);Object.defineProperty(a,e,s.get?s:{enumerable:!0,get:()=>d[e]})}}return a.default=d,Object.freeze(a)}const i=F(M),l=class l extends i.Component{constructor(a){super(a),this._element=null,this._calendar=null,this._startDateInput=i.createRef(),this._endDateInput=i.createRef(),this.shouldFocusDateInput=!1,this.shouldFocusCalendar=!1,this.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?i.createElement(this.props.calendar,{...s}):i.createElement(P.MultiViewCalendar,{...s,ref:this.setCalendarRef})},this.renderPopup=()=>{const e={popupClass:o.classNames("k-calendar-container","k-daterangepicker-popup"),animate:this._element!==null,anchor:this._element,id:this._popupId,anchorAlign:{horizontal:"left",vertical:"bottom"},popupAlign:{horizontal:"left",vertical:"top"},...this.props.popupSettings,show:this.show};return this.props.popup?i.createElement(this.props.popup,{...e},this.renderCalendar()):i.createElement(O.Popup,{...e},this.renderCalendar())},this.renderAdaptivePopup=()=>{const{windowWidth:e=0}=this.state,s={expand:this.show,onClose:r=>this.handleBlur(r),title:this.props.adaptiveTitle,subTitle:this.props.adaptiveSubtitle,windowWidth:e};return i.createElement(A.AdaptiveMode,{...s},i.createElement(N.ActionSheetContent,null,i.createElement("div",{className:"k-scrollable-wrap"},this.renderCalendar())))},this.handleReverseClick=e=>{const s={start:this.value.end,end:this.value.start},r={syntheticEvent:e,nativeEvent:e.nativeEvent};this.handleChange(s,r)},this.handleReverseMouseDown=e=>{e.preventDefault()},this.handleFocus=e=>{clearTimeout(this.nextTickId),this.shouldFocusDateInput||this.mobileMode&&this.setState({currentValue:this.value});const{onFocus:s}=this.props;s&&s.call(void 0,e)},this.handleClick=()=>{this.shouldFocusDateInput||this.setShow(!0)},this.handleBlur=e=>{this.nextTick(()=>{this.setShow(!1)});const{onBlur:s}=this.props;s&&s.call(void 0,e)},this.handleCancel=e=>{this.nextTick(()=>{this.setShow(!1),this.setState({currentValue:h.EMPTY_SELECTIONRANGE})});const{onCancel:s}=this.props;s&&s.call(void 0,e)},this.handleEndChange=e=>{const s={start:this.value.start,end: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(x.packageMetadata,{component:"DateRangePicker"}),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,inputAttributes:e}=this.props,s=this.value||h.EMPTY_SELECTIONRANGE,r=this.mobileMode&&this.show?this.state.currentValue:s,m=(this.props.startDateInputSettings||{}).id||this._startInputId,w=(this.props.endDateInputSettings||{}).id||this._endInputId,E=o.classNames("k-daterangepicker",{"k-disabled":this.props.disabled},this.props.className),S=this.localizationService.toLanguageString(n.start,n.messages[n.start]),C=this.localizationService.toLanguageString(n.end,n.messages[n.end]),y=this.localizationService.toLanguageString(n.separator,n.messages[n.separator]),g={disableSelection:this.mobileMode&&!0,label:S,format:this.props.format,min:this.min,max:this.max,id:this._startInputId,disabled:this.props.disabled,valid:this.props.valid,tabIndex:this.props.tabIndex,ariaExpanded:this.show,clearButton:this.props.clearButton,...this.props.startDateInputSettings,value:r.start,onChange:this.handleStartChange,inputAttributes:this.props.inputAttributes},v={disableSelection:this.mobileMode&&!0,label:C,format:this.props.format,min:this.min,max:this.max,id:this._endInputId,disabled:this.props.disabled,valid:this.props.valid,tabIndex:this.props.tabIndex,ariaExpanded:this.show,clearButton:this.props.clearButton,...this.props.endDateInputSettings,value:r.end,onChange:this.handleEndChange,inputAttributes:this.props.inputAttributes},R=i.createElement(_.Button,{type:"button",className:"k-select",fillMode:"flat",title:c.provideLocalizationService(this).toLanguageString(n.swapStartEnd,n.messages[n.swapStartEnd]),onMouseDown:this.handleReverseMouseDown,onClick:this.handleReverseClick,"aria-controls":m+" "+w,"aria-label":c.provideLocalizationService(this).toLanguageString(n.swapStartEnd,n.messages[n.swapStartEnd])},i.createElement(o.IconWrap,{style:{transform:"rotate(90deg)"},name:"arrows-swap",icon:T.arrowsSwapIcon}));return i.createElement(i.Fragment,null,i.createElement("span",{ref:k=>{this._element=k},className:E,style:this.props.style,id:this.props.id,"aria-labelledby":this.props.ariaLabelledBy,"aria-describedby":this.props.ariaDescribedBy,tabIndex:this.props.tabIndex,onFocus:this.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?i.createElement(this.props.startDateInput,{...g}):i.createElement(f.DateInput,{...g,autoFocus:a,ref:this._startDateInput,ariaRole:"combobox",ariaControls:this._popupId}),(this.props.allowReverse||this.props.calendarSettings&&this.props.calendarSettings.allowReverse)&&this.props.swapButton?R:y,this.props.endDateInput?i.createElement(this.props.endDateInput,{...v}):i.createElement(f.DateInput,{...v,ref:this._endDateInput,ariaRole:"combobox",ariaControls:this._popupId}),!this.mobileMode&&this.renderPopup()),this.mobileMode&&this.renderAdaptivePopup(),this.showLicenseWatermark&&i.createElement(o.WatermarkOverlay,null))}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(f.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 D=o.createPropsContext(),I=o.withIdHOC(o.withPropsContext(D,o.withAdaptiveModeContext(p)));I.displayName="KendoReactDateRangePicker";c.registerForLocalization(p);exports.DateRangePicker=I;exports.DateRangePickerPropsContext=D;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"),x=require("../package-metadata.js"),g=require("../dateinput/DateInput.js"),P=require("../calendar/components/MultiViewCalendar.js"),h=require("../calendar/models/SelectionRange.js"),u=require("../utils.js"),n=require("../messages/index.js"),_=require("@progress/kendo-react-buttons"),A=require("../common/AdaptiveMode.js"),N=require("@progress/kendo-react-layout");function L(d){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(d){for(const e in d)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(d,e);Object.defineProperty(a,e,s.get?s:{enumerable:!0,get:()=>d[e]})}}return a.default=d,Object.freeze(a)}const i=L(M),l=class l extends i.Component{constructor(a){super(a),this._element=null,this._calendar=null,this._startDateInput=i.createRef(),this._endDateInput=i.createRef(),this.shouldFocusDateInput=!1,this.shouldFocusCalendar=!1,this.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?i.createElement(this.props.calendar,{...s}):i.createElement(P.MultiViewCalendar,{...s,ref:this.setCalendarRef})},this.renderPopup=()=>{const e={popupClass:o.classNames("k-calendar-container","k-daterangepicker-popup"),animate:this._element!==null,anchor:this._element,id:this._popupId,anchorAlign:{horizontal:"left",vertical:"bottom"},popupAlign:{horizontal:"left",vertical:"top"},...this.props.popupSettings,show:this.show};return this.props.popup?i.createElement(this.props.popup,{...e},this.renderCalendar()):i.createElement(O.Popup,{...e},this.renderCalendar())},this.renderAdaptivePopup=()=>{const{windowWidth:e=0}=this.state,s={expand:this.show,onClose:r=>this.handleCancel(r),title:this.props.adaptiveTitle,windowWidth:e,footer:{cancelText:this.localizationService.toLanguageString(n.dateRangePickerCancel,n.messages[n.dateRangePickerCancel]),onCancel:this.handleCancel,applyText:this.localizationService.toLanguageString(n.dateRangePickerSet,n.messages[n.dateRangePickerSet]),onApply:this.handleBlur}};return i.createElement(A.AdaptiveMode,{...s},i.createElement(N.ActionSheetContent,null,i.createElement("div",{className:"k-scrollable-wrap"},this.renderCalendar())))},this.handleReverseClick=e=>{const s={start:this.value.end,end:this.value.start},r={syntheticEvent:e,nativeEvent:e.nativeEvent};this.handleChange(s,r)},this.handleReverseMouseDown=e=>{e.preventDefault()},this.handleFocus=e=>{clearTimeout(this.nextTickId),this.shouldFocusDateInput||this.mobileMode&&this.setState({currentValue:this.value});const{onFocus:s}=this.props;s&&s.call(void 0,e)},this.handleClick=()=>{this.shouldFocusDateInput||this.setShow(!0)},this.handleBlur=e=>{this.nextTick(()=>{this.setShow(!1)});const{onBlur:s}=this.props;s&&s.call(void 0,e)},this.handleCancel=e=>{this.nextTick(()=>{this.setShow(!1),this.setState({currentValue:h.EMPTY_SELECTIONRANGE})});const{onCancel:s}=this.props;s&&s.call(void 0,e)},this.handleEndChange=e=>{const s={start:this.value.start,end: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(x.packageMetadata,{component:"DateRangePicker"}),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,inputAttributes:e}=this.props,s=this.value||h.EMPTY_SELECTIONRANGE,r=this.mobileMode&&this.show?this.state.currentValue:s,m=(this.props.startDateInputSettings||{}).id||this._startInputId,w=(this.props.endDateInputSettings||{}).id||this._endInputId,S=o.classNames("k-daterangepicker",{"k-disabled":this.props.disabled},this.props.className),C=this.localizationService.toLanguageString(n.start,n.messages[n.start]),E=this.localizationService.toLanguageString(n.end,n.messages[n.end]),y=this.localizationService.toLanguageString(n.separator,n.messages[n.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:r.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:r.end,onChange:this.handleEndChange,inputAttributes:this.props.inputAttributes},R=i.createElement(_.Button,{type:"button",className:"k-select",fillMode:"flat",title:c.provideLocalizationService(this).toLanguageString(n.swapStartEnd,n.messages[n.swapStartEnd]),onMouseDown:this.handleReverseMouseDown,onClick:this.handleReverseClick,"aria-controls":m+" "+w,"aria-label":c.provideLocalizationService(this).toLanguageString(n.swapStartEnd,n.messages[n.swapStartEnd])},i.createElement(o.IconWrap,{style:{transform:"rotate(90deg)"},name:"arrows-swap",icon:T.arrowsSwapIcon}));return i.createElement(i.Fragment,null,i.createElement("span",{ref:k=>{this._element=k},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?i.createElement(this.props.startDateInput,{...f}):i.createElement(g.DateInput,{...f,autoFocus:a,ref:this._startDateInput,ariaRole:"combobox",ariaControls:this._popupId}),(this.props.allowReverse||this.props.calendarSettings&&this.props.calendarSettings.allowReverse)&&this.props.swapButton?R:y,this.props.endDateInput?i.createElement(this.props.endDateInput,{...v}):i.createElement(g.DateInput,{...v,ref:this._endDateInput,ariaRole:"combobox",ariaControls:this._popupId}),!this.mobileMode&&this.renderPopup()),this.mobileMode&&this.renderAdaptivePopup(),this.showLicenseWatermark&&i.createElement(o.WatermarkOverlay,null))}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 D=o.createPropsContext(),I=o.withIdHOC(o.withPropsContext(D,o.withAdaptiveModeContext(p)));I.displayName="KendoReactDateRangePicker";c.registerForLocalization(p);exports.DateRangePicker=I;exports.DateRangePickerPropsContext=D;exports.DateRangePickerWithoutContext=p;
|