@progress/kendo-react-dateinputs 9.5.0-develop.6 → 10.0.0-develop.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/calendar/components/Calendar.js +2 -2
- package/calendar/components/Calendar.mjs +47 -48
- package/calendar/components/MultiViewCalendar.js +1 -1
- package/calendar/components/MultiViewCalendar.mjs +103 -101
- package/dateinput/DateInput.js +1 -1
- package/dateinput/DateInput.mjs +30 -32
- package/datepicker/DatePicker.js +1 -1
- package/datepicker/DatePicker.mjs +47 -49
- package/daterangepicker/DateRangePicker.js +1 -1
- package/daterangepicker/DateRangePicker.mjs +28 -28
- package/datetimepicker/DateTimePicker.js +1 -1
- package/datetimepicker/DateTimePicker.mjs +53 -54
- package/dist/cdn/js/kendo-react-dateinputs.js +1 -1
- package/index.d.mts +3 -0
- package/index.d.ts +3 -0
- 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 +77 -77
package/dateinput/DateInput.mjs
CHANGED
|
@@ -11,20 +11,18 @@ import { cloneDate as x, isEqual as Ve } from "@progress/kendo-date-math";
|
|
|
11
11
|
import { Button as J } from "@progress/kendo-react-buttons";
|
|
12
12
|
import { caretAltUpIcon as Ne, caretAltDownIcon as _e } from "@progress/kendo-svg-icons";
|
|
13
13
|
import { useInternationalization as Fe, useLocalization as He } from "@progress/kendo-react-intl";
|
|
14
|
-
import {
|
|
15
|
-
import { FloatingLabel as
|
|
16
|
-
import { DateInput as
|
|
17
|
-
import { DEFAULT_FORMAT as
|
|
18
|
-
import {
|
|
19
|
-
import { nullable as u, MAX_DATE as Ge, MIN_DATE as Ze, MIN_TIME as $e, MAX_TIME as Qe } from "../utils.mjs";
|
|
14
|
+
import { useId as Be, useUnstyled as qe, usePropsContext as Y, classNames as y, uDateInput as b, createPropsContext as ze, getActiveElement as X } 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
|
+
import { DEFAULT_FORMAT as je, DEFAULT_FORMAT_PLACEHOLDER as Ke, isInRange as Je } from "./utils.mjs";
|
|
18
|
+
import { nullable as u, MAX_DATE as Ye, MIN_DATE as Xe, MIN_TIME as Ge, MAX_TIME as Ze } from "../utils.mjs";
|
|
20
19
|
import { increaseValue as C, messages as w, decreaseValue as M } from "../messages/index.mjs";
|
|
21
|
-
import { isInTimeRange as
|
|
22
|
-
import
|
|
23
|
-
import { DateInputIntl as
|
|
24
|
-
const
|
|
20
|
+
import { isInTimeRange as $e } from "../timepicker/utils.mjs";
|
|
21
|
+
import Qe from "../common/ClearButton.mjs";
|
|
22
|
+
import { DateInputIntl as et } from "./dateInputIntl.mjs";
|
|
23
|
+
const tt = "Please enter a valid value!", Z = a.forwardRef((t, $) => {
|
|
25
24
|
var j;
|
|
26
|
-
Be(
|
|
27
|
-
const Q = qe(t.id), ee = Fe(), h = He(), te = ze(), p = Y(G, t).unstyled || te, {
|
|
25
|
+
const Q = Be(t.id), ee = Fe(), h = He(), te = qe(), k = Y(G, t).unstyled || te, {
|
|
28
26
|
format: T = r.format,
|
|
29
27
|
size: ne = r.size,
|
|
30
28
|
rounded: ae = r.rounded,
|
|
@@ -37,7 +35,7 @@ const at = "Please enter a valid value!", Z = a.forwardRef((t, $) => {
|
|
|
37
35
|
minTime: se = r.minTime,
|
|
38
36
|
maxTime: ce = r.maxTime,
|
|
39
37
|
validityStyles: de = r.validityStyles,
|
|
40
|
-
validationMessage:
|
|
38
|
+
validationMessage: p = r.validationMessage,
|
|
41
39
|
placeholder: f = r.placeholder,
|
|
42
40
|
enableMouseWheel: me = r.enableMouseWheel,
|
|
43
41
|
autoCorrectParts: fe = r.autoCorrectParts,
|
|
@@ -50,9 +48,9 @@ const at = "Please enter a valid value!", Z = a.forwardRef((t, $) => {
|
|
|
50
48
|
const n = l.current && l.current.currentText || "", i = d();
|
|
51
49
|
return f != null && !Pe.focused && !i ? f : n;
|
|
52
50
|
}, V = () => t.required !== void 0 ? t.required : !1, R = () => {
|
|
53
|
-
const n = d() || t.value, i = oe, K = ue,
|
|
51
|
+
const n = d() || t.value, i = oe, K = ue, Le = Je(n, i, K) && $e(n, se, ce), ke = p !== void 0, pe = (!V() || n != null) && Le, Ae = t.valid !== void 0 ? t.valid : pe;
|
|
54
52
|
return {
|
|
55
|
-
customError:
|
|
53
|
+
customError: ke,
|
|
56
54
|
rangeOverflow: n && K.getTime() < n.getTime() || !1,
|
|
57
55
|
rangeUnderflow: n && n.getTime() < i.getTime() || !1,
|
|
58
56
|
valid: Ae,
|
|
@@ -60,7 +58,7 @@ const at = "Please enter a valid value!", Z = a.forwardRef((t, $) => {
|
|
|
60
58
|
};
|
|
61
59
|
}, Oe = () => {
|
|
62
60
|
o.current && o.current.focus();
|
|
63
|
-
}, N = () => new
|
|
61
|
+
}, N = () => new et(ee), E = () => {
|
|
64
62
|
const n = d();
|
|
65
63
|
return {
|
|
66
64
|
format: T,
|
|
@@ -91,7 +89,7 @@ const at = "Please enter a valid value!", Z = a.forwardRef((t, $) => {
|
|
|
91
89
|
t.onChange && t.onChange(n);
|
|
92
90
|
}, H = (n) => {
|
|
93
91
|
X(document) === o.current && n.preventDefault();
|
|
94
|
-
}, Ce = () => new
|
|
92
|
+
}, Ce = () => new We(o.current, {
|
|
95
93
|
...E(),
|
|
96
94
|
format: xe(E().format),
|
|
97
95
|
events: {
|
|
@@ -102,7 +100,7 @@ const at = "Please enter a valid value!", Z = a.forwardRef((t, $) => {
|
|
|
102
100
|
}
|
|
103
101
|
}), B = () => {
|
|
104
102
|
o.current && o.current.setCustomValidity && o.current.setCustomValidity(
|
|
105
|
-
R().valid ? "" :
|
|
103
|
+
R().valid ? "" : p || r.validationMessage
|
|
106
104
|
);
|
|
107
105
|
}, we = (n) => {
|
|
108
106
|
!o.current || !l.current || _(n);
|
|
@@ -166,7 +164,7 @@ const at = "Please enter a valid value!", Z = a.forwardRef((t, $) => {
|
|
|
166
164
|
value: t.value
|
|
167
165
|
});
|
|
168
166
|
});
|
|
169
|
-
const z = t.id || Q + "-accessibility-id", v =
|
|
167
|
+
const z = t.id || Q + "-accessibility-id", v = k && k.uDateInput, U = A(), L = !de || R().valid;
|
|
170
168
|
a.useImperativeHandle(t._ref, () => I.current);
|
|
171
169
|
const W = /* @__PURE__ */ a.createElement(
|
|
172
170
|
"span",
|
|
@@ -182,7 +180,7 @@ const at = "Please enter a valid value!", Z = a.forwardRef((t, $) => {
|
|
|
182
180
|
rounded: ae,
|
|
183
181
|
disabled: O,
|
|
184
182
|
required: V(),
|
|
185
|
-
invalid: !
|
|
183
|
+
invalid: !L
|
|
186
184
|
}),
|
|
187
185
|
t.className
|
|
188
186
|
)
|
|
@@ -212,7 +210,7 @@ const at = "Please enter a valid value!", Z = a.forwardRef((t, $) => {
|
|
|
212
210
|
"aria-expanded": t.ariaExpanded,
|
|
213
211
|
"aria-controls": t.ariaControls,
|
|
214
212
|
"aria-required": t.required,
|
|
215
|
-
"aria-invalid": !
|
|
213
|
+
"aria-invalid": !L,
|
|
216
214
|
onKeyDown: c,
|
|
217
215
|
onChange: c,
|
|
218
216
|
onWheel: c,
|
|
@@ -223,7 +221,7 @@ const at = "Please enter a valid value!", Z = a.forwardRef((t, $) => {
|
|
|
223
221
|
}
|
|
224
222
|
),
|
|
225
223
|
t.children,
|
|
226
|
-
t.clearButton && t.value && /* @__PURE__ */ a.createElement(
|
|
224
|
+
t.clearButton && t.value && /* @__PURE__ */ a.createElement(Qe, { onClick: F, key: "clearbutton" }),
|
|
227
225
|
le && /* @__PURE__ */ a.createElement("span", { className: y(b.inputSpinner({ c: v })), onMouseDown: Me }, /* @__PURE__ */ a.createElement(
|
|
228
226
|
J,
|
|
229
227
|
{
|
|
@@ -253,12 +251,12 @@ const at = "Please enter a valid value!", Z = a.forwardRef((t, $) => {
|
|
|
253
251
|
))
|
|
254
252
|
);
|
|
255
253
|
return t.label ? /* @__PURE__ */ a.createElement(
|
|
256
|
-
|
|
254
|
+
Ue,
|
|
257
255
|
{
|
|
258
256
|
label: t.label,
|
|
259
257
|
editorId: z,
|
|
260
258
|
editorValue: (j = o.current) == null ? void 0 : j.value,
|
|
261
|
-
editorValid:
|
|
259
|
+
editorValid: L,
|
|
262
260
|
editorDisabled: O,
|
|
263
261
|
children: W,
|
|
264
262
|
style: { width: t.width }
|
|
@@ -339,19 +337,19 @@ Z.propTypes = {
|
|
|
339
337
|
inputAttributes: e.object
|
|
340
338
|
};
|
|
341
339
|
const r = {
|
|
342
|
-
format:
|
|
340
|
+
format: je,
|
|
343
341
|
size: "medium",
|
|
344
342
|
rounded: "medium",
|
|
345
343
|
fillMode: "solid",
|
|
346
|
-
formatPlaceholder:
|
|
344
|
+
formatPlaceholder: Ke,
|
|
347
345
|
spinners: !1,
|
|
348
346
|
disabled: !1,
|
|
349
|
-
max: x(
|
|
350
|
-
min: x(
|
|
351
|
-
minTime: x(
|
|
352
|
-
maxTime: x(
|
|
347
|
+
max: x(Ye),
|
|
348
|
+
min: x(Xe),
|
|
349
|
+
minTime: x(Ge),
|
|
350
|
+
maxTime: x(Ze),
|
|
353
351
|
validityStyles: !0,
|
|
354
|
-
validationMessage:
|
|
352
|
+
validationMessage: tt,
|
|
355
353
|
placeholder: null,
|
|
356
354
|
enableMouseWheel: !0,
|
|
357
355
|
autoCorrectParts: !0,
|
|
@@ -360,7 +358,7 @@ const r = {
|
|
|
360
358
|
twoDigitYearMax: 68,
|
|
361
359
|
ariaHasPopup: "grid",
|
|
362
360
|
autoFocus: !1
|
|
363
|
-
}, G =
|
|
361
|
+
}, G = ze();
|
|
364
362
|
Z.displayName = "KendoReactDateInput";
|
|
365
363
|
export {
|
|
366
364
|
Z 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 Qe=require("react"),e=require("prop-types"),et=require("@progress/kendo-react-popup"),K=require("@progress/kendo-date-math"),u=require("@progress/kendo-react-common"),tt=require("@progress/kendo-svg-icons"),nt=require("../
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Qe=require("react"),e=require("prop-types"),et=require("@progress/kendo-react-popup"),K=require("@progress/kendo-date-math"),u=require("@progress/kendo-react-common"),tt=require("@progress/kendo-svg-icons"),nt=require("../dateinput/DateInput.js"),ot=require("../calendar/components/Calendar.js"),a=require("../utils.js"),L=require("../messages/index.js"),at=require("@progress/kendo-react-intl"),rt=require("./ToggleButton.js"),lt=require("../common/PickerWrap.js"),ut=require("../hooks/usePickerFloatingLabel.js"),it=require("@progress/kendo-react-layout"),st=require("../common/AdaptiveMode.js");function ct(n){const h=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const f in n)if(f!=="default"){const M=Object.getOwnPropertyDescriptor(n,f);Object.defineProperty(h,f,M.get?M:{enumerable:!0,get:()=>n[f]})}}return h.default=n,Object.freeze(h)}const o=ct(Qe),W=o.forwardRef((n,h)=>{const f=u.useId(n.id),M=at.useLocalization(),v=u.useAdaptiveModeContext(),{defaultShow:se=l.defaultShow,defaultValue:ce=l.defaultValue,dateInput:de=l.dateInput,calendar:fe=l.calendar,toggleButton:me=l.toggleButton,popup:ge=l.popup,pickerWrap:dt=l.pickerWrap,disabled:w=l.disabled,format:pe=l.format,max:_=l.max,min:E=l.min,popupSettings:y=l.popupSettings,tabIndex:be=l.tabIndex,weekNumber:he=l.weekNumber,validityStyles:j=l.validityStyles,size:T=l.size,rounded:x=l.rounded,fillMode:q=l.fillMode,autoFocus:ve=l.autoFocus,show:H,autoSwitchParts:we,autoSwitchKeys:ye,twoDigitYearMax:ke,ariaLabel:De,adaptive:ft,formatPlaceholder:Ce,adaptiveTitle:Pe,inputAttributes:Oe,validationMessage:U,visited:mt,value:B,touched:gt,modified:pt,_adaptiveMode:bt=v,valid:Y,focusedDate:Me,id:Re,...$}=u.usePropsContext(ie,n),A=()=>{if(u.canUseDOM)return D.current&&D.current.ownerDocument||window.document},c=()=>!!(b.windowWidth&&v&&b.windowWidth<=(v==null?void 0:v.medium)&&n.adaptive),m=()=>{const t=R.current!==void 0?R.current:B!==void 0?B:b.value;return t!==null?K.cloneDate(t):null},i=()=>I.current!==void 0?I.current:H!==void 0?H:b.show,Ie=()=>de||l.dateInput,Se=()=>me||l.toggleButton,_e=()=>fe||l.calendar,Ee=()=>ge||l.popup,X=()=>n.required!==void 0?n.required:!1,N=()=>{const t=m()||B||null,r=E,s=_,S=a.isInDateRange(t,r,s),F=U!==void 0,V=(!X()||t!=null)&&S,z=Y!==void 0?Y:V;return{customError:F,rangeOverflow:t&&s.getTime()<t.getTime()||!1,rangeUnderflow:t&&t.getTime()<r.getTime()||!1,valid:z,valueMissing:t===null}},Te=t=>{for(const r of t)O({windowWidth:r.target.clientWidth})},xe=()=>{d.current&&d.current.focus()},Z=t=>{C.current=t},g=t=>{i()!==t&&(O({show:t}),t&&n.onOpen&&n.onOpen.call(void 0,{target:k.current}),!t&&n.onClose&&n.onClose.call(void 0,{target:k.current}))},qe=t=>{const r=m();return r&&t?a.setTime(t,r):t},Be=t=>{y!=null&&y.onMouseDownOutside&&y.onMouseDownOutside.call(void 0,t)},G=(t,r)=>{O({value:K.cloneDate(t||void 0)}),R.current=t,I.current=!1,c()||(p.current=!0),n.onChange&&n.onChange.call(void 0,{syntheticEvent:r.syntheticEvent,nativeEvent:r.nativeEvent,value:m(),show:i(),target:k.current}),R.current=void 0,I.current=void 0,g(!1)},Ae=t=>{const r=qe(t.value);G(r,t)},J=()=>{const{popupClass:t,...r}=y,s=i(),S=m(),F=S&&K.getDate(S),V=u.classNames(t),z={popupClass:"k-datepicker-popup",show:s,anchor:D.current,className:V,id:ne,anchorAlign:{horizontal:"left",vertical:"bottom"},popupAlign:{horizontal:"left",vertical:"top"},...r,onMouseDownOutside:Be},le={disabled:w,value:F,min:E,max:_,weekNumber:he,focusedDate:Me,className:c()?"k-calendar-lg":"",navigation:!c(),onChange:Ae},ue=_e(),Je=Ee();return c()?o.createElement(ue,{_ref:Z,...le}):o.createElement(Je,{...z},o.createElement(ue,{_ref:Z,...le}))},Q=()=>{O({focused:!1}),g(!1)},Ne=()=>{const{windowWidth:t=0}=b,r={expand:i(),onClose:Q,adaptiveTitle:Pe,windowWidth:t},s=J();return o.createElement(st.AdaptiveMode,{...r},o.createElement(it.ActionSheetContent,{overflowHidden:!0},s))},Fe=t=>{G(t.value,t)},Ve=()=>{O({focused:!0})},ze=()=>{g(!i())},ee=()=>{w||(p.current=!0,g(!i()))},Ke=t=>{t.preventDefault()},Le=t=>{const{altKey:r,keyCode:s}=t;if(s===u.Keys.esc&&i()){p.current=!0,g(!1);return}r&&(s===u.Keys.up||s===u.Keys.down)&&(t.preventDefault(),t.stopPropagation(),p.current=s===u.Keys.up,g(s===u.Keys.down))},k=o.useRef(null),D=o.useRef(null),d=o.useRef(null),C=o.useRef(null);o.useImperativeHandle(k,()=>({props:n,get element(){return D.current},get calendar(){return C.current},get dateInput(){return d.current},get name(){return n.name},get show(){return i()},get validity(){return N()},get value(){return m()},get mobileMode(){return c()},togglePopup:ze,focus:xe})),o.useImperativeHandle(h,()=>k.current);const R=o.useRef(void 0),I=o.useRef(void 0),We=o.useRef(null),p=o.useRef(!1),te=o.useRef(!1),P=o.useRef(null),[b,je]=o.useState({value:ce,show:se,focused:!1}),[,He]=o.useReducer(t=>t,!0),O=t=>{je(r=>({...r,...t}))};o.useEffect(()=>{C.current&&C.current.element&&i()&&!te.current&&C.current.element.focus({preventScroll:!0}),d.current&&d.current.element&&!i()&&p.current&&d.current.element.focus({preventScroll:!0}),te.current=i(),p.current=!1}),o.useEffect(()=>{var t;return P.current=u.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(r=>Te(r)),i()&&He(),(t=A())!=null&&t.body&&P.current&&P.current.observe(A().body),()=>{var r;clearTimeout(We.current),(r=A())!=null&&r.body&&P.current&&P.current.disconnect()}},[]);const ne=f+"-popup-id",Ue=J(),Ye=Ie(),$e=m(),Xe=Se(),Ze=Ne(),oe=!j||N().valid,ae=M.toLanguageString(L.toggleCalendar,L.messages[L.toggleCalendar]),Ge={disabled:w,format:pe,formatPlaceholder:Ce,id:Re,ariaLabelledBy:n.ariaLabelledBy,ariaDescribedBy:n.ariaDescribedBy,ariaLabel:De,max:_,min:E,name:n.name,onChange:Fe,required:n.required,_ref:d,tabIndex:i()?-1:be,title:n.title,valid:N().valid,validationMessage:U,validityStyles:j,value:$e,label:void 0,placeholder:b.focused?null:n.placeholder,ariaExpanded:i(),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:Oe},re=o.createElement(u.AsyncFocusBlur,{onFocus:Ve,onBlur:c()?void 0:Q,onSyncBlur:n.onBlur,onSyncFocus:n.onFocus},t=>o.createElement(o.Fragment,null,o.createElement("span",{...n.label?{}:$,ref:D,className:u.classNames("k-input","k-datepicker",{[`k-input-${u.kendoThemeMaps.sizeMap[T]||T}`]:T,[`k-rounded-${u.kendoThemeMaps.roundedMap[x]||x}`]:x,[`k-input-${q}`]:q,"k-invalid":!oe,"k-required":X(),"k-disabled":w},n.className),onKeyDown:Le,style:{width:n.width},onFocus:t.onFocus,onBlur:t.onBlur,onClick:c()?ee:void 0},o.createElement(Ye,{_ref:d,ariaRole:"combobox",ariaExpanded:i(),ariaControls:ne,autoFocus:ve,...Ge}),o.createElement(Xe,{type:"button",icon:"calendar",svgIcon:tt.calendarIcon,title:ae,className:"k-input-button",rounded:null,onClick:c()?void 0:ee,"aria-label":ae,fillMode:q,onMouseDown:Ke}),!c()&&Ue),c()&&Ze));return n.label?o.createElement(ut.PickerFloatingLabel,{dateInput:d,label:n.label,editorId:f,editorValid:oe,editorDisabled:w,children:re,style:{width:n.width},...$}):re});W.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:a.nullable(e.string),pattern:a.nullable(e.string),date:a.nullable(e.oneOf(["short","medium","long","full"])),time:a.nullable(e.oneOf(["short","medium","long","full"])),datetime:a.nullable(e.oneOf(["short","medium","long","full"])),era:a.nullable(e.oneOf(["narrow","short","long"])),year:a.nullable(e.oneOf(["numeric","2-digit"])),month:a.nullable(e.oneOf(["numeric","2-digit","narrow","short","long"])),day:a.nullable(e.oneOf(["numeric","2-digit"])),weekday:a.nullable(e.oneOf(["narrow","short","long"])),hour:a.nullable(e.oneOf(["numeric","2-digit"])),hour12:a.nullable(e.bool),minute:a.nullable(e.oneOf(["numeric","2-digit"])),second:a.nullable(e.oneOf(["numeric","2-digit"])),timeZoneName:a.nullable(e.oneOf(["short","long"]))})]),formatPlaceholder:e.oneOfType([a.nullable(e.oneOf(["wide","narrow","short","formatPattern"])),e.shape({year:a.nullable(e.string),month:a.nullable(e.string),day:a.nullable(e.string),hour:a.nullable(e.string),minute:a.nullable(e.string),second:a.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:a.nullable(e.bool),appendTo:a.nullable(e.any),popupClass:a.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,autoFocus:e.bool,inputAttributes:e.object};const l={defaultShow:!1,defaultValue:null,dateInput:nt.DateInput,calendar:ot.Calendar,toggleButton:rt.ToggleButton,popup:et.Popup,pickerWrap:lt.PickerWrap,disabled:!1,format:"d",max:a.MAX_DATE,min:a.MIN_DATE,popupSettings:{},tabIndex:0,weekNumber:!1,validityStyles:!0,size:"medium",rounded:"medium",fillMode:"solid",autoFocus:!1},ie=u.createPropsContext();W.displayName="KendoReactDatePicker";exports.DatePicker=W;exports.DatePickerPropsContext=ie;exports.datePickerDefaultProps=l;
|
|
@@ -9,29 +9,27 @@ import * as o from "react";
|
|
|
9
9
|
import e from "prop-types";
|
|
10
10
|
import { Popup as tt } from "@progress/kendo-react-popup";
|
|
11
11
|
import { cloneDate as oe, getDate as nt } from "@progress/kendo-date-math";
|
|
12
|
-
import {
|
|
13
|
-
import { calendarIcon as
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import { AdaptiveMode as Dt } from "../common/AdaptiveMode.mjs";
|
|
12
|
+
import { useId as ot, useAdaptiveModeContext as rt, usePropsContext as at, canUseDOM as re, AsyncFocusBlur as lt, classNames as ae, kendoThemeMaps as le, createPropsContext as it, Keys as k } from "@progress/kendo-react-common";
|
|
13
|
+
import { calendarIcon as ut } from "@progress/kendo-svg-icons";
|
|
14
|
+
import { DateInput as st } from "../dateinput/DateInput.mjs";
|
|
15
|
+
import { Calendar as ct } from "../calendar/components/Calendar.mjs";
|
|
16
|
+
import { nullable as a, MAX_DATE as dt, MIN_DATE as ft, isInDateRange as mt, setTime as pt } from "../utils.mjs";
|
|
17
|
+
import { toggleCalendar as ie, messages as gt } from "../messages/index.mjs";
|
|
18
|
+
import { useLocalization as ht } from "@progress/kendo-react-intl";
|
|
19
|
+
import { ToggleButton as vt } from "./ToggleButton.mjs";
|
|
20
|
+
import { PickerWrap as wt } from "../common/PickerWrap.mjs";
|
|
21
|
+
import { PickerFloatingLabel as bt } from "../hooks/usePickerFloatingLabel.mjs";
|
|
22
|
+
import { ActionSheetContent as yt } from "@progress/kendo-react-layout";
|
|
23
|
+
import { AdaptiveMode as Ct } from "../common/AdaptiveMode.mjs";
|
|
25
24
|
const ue = o.forwardRef((n, se) => {
|
|
26
|
-
ot(
|
|
27
|
-
const N = rt(n.id), ce = wt(), g = at(), {
|
|
25
|
+
const N = ot(n.id), ce = ht(), g = rt(), {
|
|
28
26
|
defaultShow: de = l.defaultShow,
|
|
29
27
|
defaultValue: fe = l.defaultValue,
|
|
30
28
|
dateInput: me = l.dateInput,
|
|
31
29
|
calendar: pe = l.calendar,
|
|
32
30
|
toggleButton: ge = l.toggleButton,
|
|
33
31
|
popup: he = l.popup,
|
|
34
|
-
pickerWrap:
|
|
32
|
+
pickerWrap: kt = l.pickerWrap,
|
|
35
33
|
disabled: h = l.disabled,
|
|
36
34
|
format: ve = l.format,
|
|
37
35
|
max: R = l.max,
|
|
@@ -46,31 +44,31 @@ const ue = o.forwardRef((n, se) => {
|
|
|
46
44
|
autoFocus: ye = l.autoFocus,
|
|
47
45
|
show: W,
|
|
48
46
|
autoSwitchParts: Ce,
|
|
49
|
-
autoSwitchKeys:
|
|
50
|
-
twoDigitYearMax:
|
|
47
|
+
autoSwitchKeys: De,
|
|
48
|
+
twoDigitYearMax: ke,
|
|
51
49
|
ariaLabel: Oe,
|
|
52
|
-
adaptive:
|
|
50
|
+
adaptive: Ot,
|
|
53
51
|
formatPlaceholder: Pe,
|
|
54
52
|
adaptiveTitle: Me,
|
|
55
53
|
inputAttributes: Re,
|
|
56
54
|
validationMessage: L,
|
|
57
|
-
visited:
|
|
55
|
+
visited: Pt,
|
|
58
56
|
value: x,
|
|
59
|
-
touched:
|
|
60
|
-
modified:
|
|
61
|
-
_adaptiveMode:
|
|
57
|
+
touched: Mt,
|
|
58
|
+
modified: Rt,
|
|
59
|
+
_adaptiveMode: It = g,
|
|
62
60
|
valid: K,
|
|
63
61
|
focusedDate: Ie,
|
|
64
62
|
id: Se,
|
|
65
63
|
...q
|
|
66
|
-
} =
|
|
64
|
+
} = at(Dt, n), B = () => {
|
|
67
65
|
if (re)
|
|
68
66
|
return b.current && b.current.ownerDocument || window.document;
|
|
69
67
|
}, s = () => !!(p.windowWidth && g && p.windowWidth <= (g == null ? void 0 : g.medium) && n.adaptive), d = () => {
|
|
70
68
|
const t = O.current !== void 0 ? O.current : x !== void 0 ? x : p.value;
|
|
71
69
|
return t !== null ? oe(t) : null;
|
|
72
70
|
}, i = () => P.current !== void 0 ? P.current : W !== void 0 ? W : p.show, Ee = () => me || l.dateInput, _e = () => ge || l.toggleButton, xe = () => pe || l.calendar, Be = () => he || l.popup, H = () => n.required !== void 0 ? n.required : !1, T = () => {
|
|
73
|
-
const t = d() || x || null, r = I, u = R, M =
|
|
71
|
+
const t = d() || x || null, r = I, u = R, M = mt(t, r, u), A = L !== void 0, V = (!H() || t != null) && M, F = K !== void 0 ? K : V;
|
|
74
72
|
return {
|
|
75
73
|
customError: A,
|
|
76
74
|
rangeOverflow: t && u.getTime() < t.getTime() || !1,
|
|
@@ -80,20 +78,20 @@ const ue = o.forwardRef((n, se) => {
|
|
|
80
78
|
};
|
|
81
79
|
}, Te = (t) => {
|
|
82
80
|
for (const r of t)
|
|
83
|
-
|
|
81
|
+
D({ windowWidth: r.target.clientWidth });
|
|
84
82
|
}, Ae = () => {
|
|
85
83
|
c.current && c.current.focus();
|
|
86
84
|
}, U = (t) => {
|
|
87
85
|
y.current = t;
|
|
88
86
|
}, f = (t) => {
|
|
89
|
-
i() !== t && (
|
|
87
|
+
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
88
|
}, Ve = (t) => {
|
|
91
89
|
const r = d();
|
|
92
|
-
return r && t ?
|
|
90
|
+
return r && t ? pt(t, r) : t;
|
|
93
91
|
}, Fe = (t) => {
|
|
94
92
|
v != null && v.onMouseDownOutside && v.onMouseDownOutside.call(void 0, t);
|
|
95
93
|
}, Y = (t, r) => {
|
|
96
|
-
|
|
94
|
+
D({ value: oe(t || void 0) }), O.current = t, P.current = !1, s() || (m.current = !0), n.onChange && n.onChange.call(void 0, {
|
|
97
95
|
syntheticEvent: r.syntheticEvent,
|
|
98
96
|
nativeEvent: r.nativeEvent,
|
|
99
97
|
value: d(),
|
|
@@ -133,7 +131,7 @@ const ue = o.forwardRef((n, se) => {
|
|
|
133
131
|
}, ne = xe(), et = Be();
|
|
134
132
|
return s() ? /* @__PURE__ */ o.createElement(ne, { _ref: U, ...te }) : /* @__PURE__ */ o.createElement(et, { ...F }, /* @__PURE__ */ o.createElement(ne, { _ref: U, ...te }));
|
|
135
133
|
}, j = () => {
|
|
136
|
-
|
|
134
|
+
D({ focused: !1 }), f(!1);
|
|
137
135
|
}, ze = () => {
|
|
138
136
|
const { windowWidth: t = 0 } = p, r = {
|
|
139
137
|
expand: i(),
|
|
@@ -141,11 +139,11 @@ const ue = o.forwardRef((n, se) => {
|
|
|
141
139
|
adaptiveTitle: Me,
|
|
142
140
|
windowWidth: t
|
|
143
141
|
}, u = $();
|
|
144
|
-
return /* @__PURE__ */ o.createElement(
|
|
142
|
+
return /* @__PURE__ */ o.createElement(Ct, { ...r }, /* @__PURE__ */ o.createElement(yt, { overflowHidden: !0 }, u));
|
|
145
143
|
}, We = (t) => {
|
|
146
144
|
Y(t.value, t);
|
|
147
145
|
}, Le = () => {
|
|
148
|
-
|
|
146
|
+
D({ focused: !0 });
|
|
149
147
|
}, Ke = () => {
|
|
150
148
|
f(!i());
|
|
151
149
|
}, X = () => {
|
|
@@ -154,11 +152,11 @@ const ue = o.forwardRef((n, se) => {
|
|
|
154
152
|
t.preventDefault();
|
|
155
153
|
}, He = (t) => {
|
|
156
154
|
const { altKey: r, keyCode: u } = t;
|
|
157
|
-
if (u ===
|
|
155
|
+
if (u === k.esc && i()) {
|
|
158
156
|
m.current = !0, f(!1);
|
|
159
157
|
return;
|
|
160
158
|
}
|
|
161
|
-
r && (u ===
|
|
159
|
+
r && (u === k.up || u === k.down) && (t.preventDefault(), t.stopPropagation(), m.current = u === k.up, f(u === k.down));
|
|
162
160
|
}, w = o.useRef(null), b = o.useRef(null), c = o.useRef(null), y = o.useRef(null);
|
|
163
161
|
o.useImperativeHandle(
|
|
164
162
|
w,
|
|
@@ -197,7 +195,7 @@ const ue = o.forwardRef((n, se) => {
|
|
|
197
195
|
value: fe,
|
|
198
196
|
show: de,
|
|
199
197
|
focused: !1
|
|
200
|
-
}), [, $e] = o.useReducer((t) => t, !0),
|
|
198
|
+
}), [, $e] = o.useReducer((t) => t, !0), D = (t) => {
|
|
201
199
|
Ye((r) => ({ ...r, ...t }));
|
|
202
200
|
};
|
|
203
201
|
o.useEffect(() => {
|
|
@@ -209,7 +207,7 @@ const ue = o.forwardRef((n, se) => {
|
|
|
209
207
|
clearTimeout(Ue.current), (r = B()) != null && r.body && C.current && C.current.disconnect();
|
|
210
208
|
};
|
|
211
209
|
}, []);
|
|
212
|
-
const G = N + "-popup-id", je = $(), Xe = Ee(), Ze = d(), Ge = _e(), Je = ze(), J = !z || T().valid, Q = ce.toLanguageString(ie,
|
|
210
|
+
const G = N + "-popup-id", je = $(), Xe = Ee(), Ze = d(), Ge = _e(), Je = ze(), J = !z || T().valid, Q = ce.toLanguageString(ie, gt[ie]), Qe = {
|
|
213
211
|
disabled: h,
|
|
214
212
|
format: ve,
|
|
215
213
|
formatPlaceholder: Pe,
|
|
@@ -236,15 +234,15 @@ const ue = o.forwardRef((n, se) => {
|
|
|
236
234
|
fillMode: null,
|
|
237
235
|
rounded: null,
|
|
238
236
|
autoFill: n.autoFill,
|
|
239
|
-
twoDigitYearMax:
|
|
237
|
+
twoDigitYearMax: ke,
|
|
240
238
|
enableMouseWheel: n.enableMouseWheel,
|
|
241
239
|
autoCorrectParts: n.autoCorrectParts,
|
|
242
240
|
autoSwitchParts: Ce,
|
|
243
|
-
autoSwitchKeys:
|
|
241
|
+
autoSwitchKeys: De,
|
|
244
242
|
allowCaretMode: n.allowCaretMode,
|
|
245
243
|
inputAttributes: Re
|
|
246
244
|
}, ee = /* @__PURE__ */ o.createElement(
|
|
247
|
-
|
|
245
|
+
lt,
|
|
248
246
|
{
|
|
249
247
|
onFocus: Le,
|
|
250
248
|
onBlur: s() ? void 0 : j,
|
|
@@ -291,7 +289,7 @@ const ue = o.forwardRef((n, se) => {
|
|
|
291
289
|
{
|
|
292
290
|
type: "button",
|
|
293
291
|
icon: "calendar",
|
|
294
|
-
svgIcon:
|
|
292
|
+
svgIcon: ut,
|
|
295
293
|
title: Q,
|
|
296
294
|
className: "k-input-button",
|
|
297
295
|
rounded: null,
|
|
@@ -305,7 +303,7 @@ const ue = o.forwardRef((n, se) => {
|
|
|
305
303
|
), s() && Je)
|
|
306
304
|
);
|
|
307
305
|
return n.label ? /* @__PURE__ */ o.createElement(
|
|
308
|
-
|
|
306
|
+
bt,
|
|
309
307
|
{
|
|
310
308
|
dateInput: c,
|
|
311
309
|
label: n.label,
|
|
@@ -389,15 +387,15 @@ ue.propTypes = {
|
|
|
389
387
|
const l = {
|
|
390
388
|
defaultShow: !1,
|
|
391
389
|
defaultValue: null,
|
|
392
|
-
dateInput:
|
|
393
|
-
calendar:
|
|
394
|
-
toggleButton:
|
|
390
|
+
dateInput: st,
|
|
391
|
+
calendar: ct,
|
|
392
|
+
toggleButton: vt,
|
|
395
393
|
popup: tt,
|
|
396
|
-
pickerWrap:
|
|
394
|
+
pickerWrap: wt,
|
|
397
395
|
disabled: !1,
|
|
398
396
|
format: "d",
|
|
399
|
-
max:
|
|
400
|
-
min:
|
|
397
|
+
max: dt,
|
|
398
|
+
min: ft,
|
|
401
399
|
popupSettings: {},
|
|
402
400
|
tabIndex: 0,
|
|
403
401
|
weekNumber: !1,
|
|
@@ -406,10 +404,10 @@ const l = {
|
|
|
406
404
|
rounded: "medium",
|
|
407
405
|
fillMode: "solid",
|
|
408
406
|
autoFocus: !1
|
|
409
|
-
},
|
|
407
|
+
}, Dt = it();
|
|
410
408
|
ue.displayName = "KendoReactDatePicker";
|
|
411
409
|
export {
|
|
412
410
|
ue as DatePicker,
|
|
413
|
-
|
|
411
|
+
Dt as DatePickerPropsContext,
|
|
414
412
|
l as datePickerDefaultProps
|
|
415
413
|
};
|
|
@@ -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 k=require("react"),t=require("prop-types"),M=require("@progress/kendo-react-popup"),D=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 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(k),l=class l extends i.Component{constructor(a){super(a),this._element=null,this._calendar=null,this._startDateInput=i.createRef(),this._endDateInput=i.createRef(),this.shouldFocusDateInput=!1,this.shouldFocusCalendar=!1,this.focus=()=>{this.startDateInput&&this.startDateInput.focus()},this.setCalendarRef=e=>{this._calendar=e},this.focusCalendarElement=()=>{this._calendar&&this._calendar.element&&this._calendar.element.focus({preventScroll:!0})},this.calculateValue=(e,s)=>(e.value!==void 0?e.value:s.value)||h.EMPTY_SELECTIONRANGE,this.calculateShow=(e,s)=>e.show!==void 0?e.show:s.show,this.renderCalendar=()=>{const e=this.value||h.EMPTY_SELECTIONRANGE,s={min:this.min,max:this.max,allowReverse:this.props.allowReverse,mode:"range",focusedDate:this.props.focusedDate,disabled:this.props.disabled,className:this.mobileMode?"k-calendar-lg":"",mobileMode:this.mobileMode,...this.props.calendarSettings,value:e,dir:this.props.dir,onChange:this.handleCalendarChange};return this.props.calendar?i.createElement(this.props.calendar,{...s}):i.createElement(P.MultiViewCalendar,{...s,ref:this.setCalendarRef})},this.renderPopup=()=>{const e={popupClass: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(M.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,{overflowHidden:!0},i.createElement("div",{className:"k-scrollable-wrap"},this.renderCalendar())))},this.handleReverseClick=e=>{const s={start:this.value.end,end:this.value.start},r={syntheticEvent:e,nativeEvent:e.nativeEvent};this.handleChange(s,r)},this.handleReverseMouseDown=e=>{e.preventDefault()},this.handleFocus=e=>{clearTimeout(this.nextTickId),this.shouldFocusDateInput||this.mobileMode&&this.setState({currentValue:this.value});const{onFocus:s}=this.props;s&&s.call(void 0,e)},this.handleClick=()=>{this.shouldFocusDateInput||this.setShow(!0)},this.handleBlur=e=>{this.nextTick(()=>{this.setShow(!1)});const{onBlur:s}=this.props;s&&s.call(void 0,e)},this.handleCancel=e=>{this.nextTick(()=>{this.setShow(!1),this.setState({currentValue:h.EMPTY_SELECTIONRANGE})});const{onCancel:s}=this.props;s&&s.call(void 0,e)},this.handleEndChange=e=>{const s={start:this.value.start,end:D.cloneDate(e.value||void 0)};this.handleChange(s,e)},this.handleStartChange=e=>{const s={start:D.cloneDate(e.value||void 0),end:this.value.end};this.handleChange(s,e)},this.extractRangeFromValue=e=>{if(!Array.isArray(e.value)&&!(e.value instanceof Date))return e.value||h.EMPTY_SELECTIONRANGE;const s=Array.isArray(e.value)?e.value[0]:e.value;return{start:this.value.end!==null?s:this.value.start,end:this.value.start!==null?s:this.value.end}},this.handleCalendarChange=e=>{const s=this.extractRangeFromValue(e);this.handleChange(s,e)},this.handleKeyDown=e=>{const{keyCode:s,altKey:r}=e;s===o.Keys.esc?(e.preventDefault(),this.shouldFocusDateInput=!0,this.setShow(!1)):r&&s===o.Keys.down?(e.preventDefault(),this.shouldFocusCalendar=!0,this.setShow(!0),this.focusCalendarElement()):r&&s===o.Keys.up&&(e.preventDefault(),this.shouldFocusDateInput=!0,this.setShow(!1))},this.handleChange=(e,s)=>{this.setState({value:e}),this.valueDuringOnChange=e;const{onChange:r}=this.props;if(r){const m={syntheticEvent:s.syntheticEvent,nativeEvent:s.nativeEvent,value:this.value,show:this.show,target:this};r.call(void 0,m)}this.valueDuringOnChange=void 0},o.validatePackage(x.packageMetadata),this.state={show:this.props.show||this.props.defaultShow||l.defaultProps.defaultShow,value:this.props.value||this.props.defaultValue||l.defaultProps.defaultValue,currentValue:h.EMPTY_SELECTIONRANGE},this.nextTick=this.nextTick.bind(this),this.setShow=this.setShow.bind(this),this.focusCalendarElement=this.focusCalendarElement.bind(this),this.focusDateInputElement=this.focusDateInputElement.bind(this)}get _popupId(){return this.props.id+"-popup-id"}get _startInputId(){return this.props.id+"-start-input-id"}get _endInputId(){return this.props.id+"-end-input-id"}get element(){return this._element}get startDateInput(){return this._startDateInput.current}get endDateInput(){return this._endDateInput.current}get calendar(){return this._calendar}get value(){return(this.valueDuringOnChange!==void 0?this.valueDuringOnChange:this.props.value!==void 0?this.props.value:this.state.value)||h.EMPTY_SELECTIONRANGE}get show(){return this.showDuringOnChange!==void 0?this.showDuringOnChange:this.props.show!==void 0?this.props.show:this.state.show}get min(){return this.props.min!==void 0?this.props.min:l.defaultProps.min}get max(){return this.props.max!==void 0?this.props.max:l.defaultProps.max}get document(){if(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.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:O=>{this._element=O},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.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())}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 b=o.createPropsContext(),I=o.withIdHOC(o.withPropsContext(b,o.withAdaptiveModeContext(p)));I.displayName="KendoReactDateRangePicker";c.registerForLocalization(p);exports.DateRangePicker=I;exports.DateRangePickerPropsContext=b;exports.DateRangePickerWithoutContext=p;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("react"),t=require("prop-types"),M=require("@progress/kendo-react-popup"),D=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(O),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(M.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,{overflowHidden:!0},i.createElement("div",{className:"k-scrollable-wrap"},this.renderCalendar())))},this.handleReverseClick=e=>{const s={start:this.value.end,end:this.value.start},r={syntheticEvent:e,nativeEvent:e.nativeEvent};this.handleChange(s,r)},this.handleReverseMouseDown=e=>{e.preventDefault()},this.handleFocus=e=>{clearTimeout(this.nextTickId),this.shouldFocusDateInput||this.mobileMode&&this.setState({currentValue:this.value});const{onFocus:s}=this.props;s&&s.call(void 0,e)},this.handleClick=()=>{this.shouldFocusDateInput||this.setShow(!0)},this.handleBlur=e=>{this.nextTick(()=>{this.setShow(!1)});const{onBlur:s}=this.props;s&&s.call(void 0,e)},this.handleCancel=e=>{this.nextTick(()=>{this.setShow(!1),this.setState({currentValue:h.EMPTY_SELECTIONRANGE})});const{onCancel:s}=this.props;s&&s.call(void 0,e)},this.handleEndChange=e=>{const s={start:this.value.start,end:D.cloneDate(e.value||void 0)};this.handleChange(s,e)},this.handleStartChange=e=>{const s={start:D.cloneDate(e.value||void 0),end:this.value.end};this.handleChange(s,e)},this.extractRangeFromValue=e=>{if(!Array.isArray(e.value)&&!(e.value instanceof Date))return e.value||h.EMPTY_SELECTIONRANGE;const s=Array.isArray(e.value)?e.value[0]:e.value;return{start:this.value.end!==null?s:this.value.start,end:this.value.start!==null?s:this.value.end}},this.handleCalendarChange=e=>{const s=this.extractRangeFromValue(e);this.handleChange(s,e)},this.handleKeyDown=e=>{const{keyCode:s,altKey:r}=e;s===o.Keys.esc?(e.preventDefault(),this.shouldFocusDateInput=!0,this.setShow(!1)):r&&s===o.Keys.down?(e.preventDefault(),this.shouldFocusCalendar=!0,this.setShow(!0),this.focusCalendarElement()):r&&s===o.Keys.up&&(e.preventDefault(),this.shouldFocusDateInput=!0,this.setShow(!1))},this.handleChange=(e,s)=>{this.setState({value:e}),this.valueDuringOnChange=e;const{onChange:r}=this.props;if(r){const m={syntheticEvent:s.syntheticEvent,nativeEvent:s.nativeEvent,value:this.value,show:this.show,target:this};r.call(void 0,m)}this.valueDuringOnChange=void 0},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.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),E=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]),f={disableSelection:this.mobileMode&&!0,label:E,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: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.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 b=o.createPropsContext(),I=o.withIdHOC(o.withPropsContext(b,o.withAdaptiveModeContext(p)));I.displayName="KendoReactDateRangePicker";c.registerForLocalization(p);exports.DateRangePicker=I;exports.DateRangePickerPropsContext=b;exports.DateRangePickerWithoutContext=p;
|