@progress/kendo-react-dateinputs 15.1.1-develop.2 → 15.2.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/datepicker/DatePicker.js +1 -1
- package/datepicker/DatePicker.mjs +164 -164
- package/daterangepicker/DateRangePicker.js +1 -1
- package/daterangepicker/DateRangePicker.mjs +61 -63
- package/datetimepicker/DateTimePicker.d.ts +1 -0
- package/datetimepicker/DateTimePicker.js +1 -1
- package/datetimepicker/DateTimePicker.mjs +103 -105
- package/datetimepicker/models/DateTimePickerSettings.d.ts +7 -0
- 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.d.ts +1 -0
- package/timepicker/TimePicker.js +1 -1
- package/timepicker/TimePicker.mjs +113 -112
- package/timepicker/models/TimePickerSettings.d.ts +7 -0
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 st=require("react"),t=require("prop-types"),ct=require("@progress/kendo-react-popup"),H=require("@progress/kendo-date-math"),u=require("@progress/kendo-react-common"),dt=require("@progress/kendo-svg-icons"),ft=require("../dateinput/DateInput.js"),mt=require("../calendar/components/Calendar.js"),r=require("../utils.js"),D=require("../messages/index.js"),gt=require("@progress/kendo-react-intl"),pt=require("./ToggleButton.js"),bt=require("../hooks/usePickerFloatingLabel.js"),ht=require("@progress/kendo-react-layout"),vt=require("../common/AdaptiveMode.js");function wt(n){const k=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const f in n)if(f!=="default"){const C=Object.getOwnPropertyDescriptor(n,f);Object.defineProperty(k,f,C.get?C:{enumerable:!0,get:()=>n[f]})}}return k.default=n,Object.freeze(k)}const o=wt(st),U=o.forwardRef((n,k)=>{const f=u.useId(n.id),C=gt.useLocalization(),P=u.useAdaptiveModeContext(),{defaultShow:me=l.defaultShow,defaultValue:ge=l.defaultValue,dateInput:pe=l.dateInput,calendar:be=l.calendar,toggleButton:he=l.toggleButton,popup:ve=l.popup,disabled:p=l.disabled,format:we=l.format,max:O=l.max,min:M=l.min,popupSettings:R=l.popupSettings,tabIndex:ye=l.tabIndex,weekNumber:De=l.weekNumber,validityStyles:Y=l.validityStyles,size:E=l.size,rounded:x=l.rounded,fillMode:q=l.fillMode,autoFocus:ke=l.autoFocus,show:$,autoSwitchParts:Ce,autoSwitchKeys:Pe,twoDigitYearMax:Oe,ariaLabel:Me,adaptive:yt,adaptiveTitle:Re=n.label||void 0,adaptiveSubtitle:Se,formatPlaceholder:Ie,inputAttributes:_e,validationMessage:X,visited:Dt,value:N,touched:kt,modified:Ct,_adaptiveMode:Pt=P,valid:Z,focusedDate:Te,id:Be,ariaLabelledBy:Ee,ariaDescribedBy:xe,placeholder:qe,onChange:G,onOpen:J,onClose:Q,...ee}=u.usePropsContext(fe,n),A=()=>{if(u.canUseDOM)return m.current&&m.current.ownerDocument||window.document},c=()=>!!(b.windowWidth&&P&&b.windowWidth<=(P==null?void 0:P.medium)&&n.adaptive),h=()=>{const e=_.current!==void 0?_.current:N!==void 0?N:b.value;return e!==null?H.cloneDate(e):null},i=()=>T.current!==void 0?T.current:$!==void 0?$:b.show,Ne=()=>pe||l.dateInput,Ae=()=>he||l.toggleButton,Fe=()=>be||l.calendar,Le=()=>ve||l.popup,te=()=>n.required!==void 0?n.required:!1,F=()=>{const e=h()||N||null,a=M,s=O,B=r.isInDateRange(e,a,s),V=X!==void 0,W=(!te()||e!=null)&&B,j=Z!==void 0?Z:W;return{customError:V,rangeOverflow:e&&s.getTime()<e.getTime()||!1,rangeUnderflow:e&&e.getTime()<a.getTime()||!1,valid:j,valueMissing:e===null}},ze=e=>{for(const a of e)I({windowWidth:a.target.clientWidth})},Ke=()=>{d.current&&d.current.focus()},ne=e=>{g.current=e},v=e=>{i()!==e&&(I({show:e}),e&&J&&J({target:w.current}),!e&&Q&&Q({target:w.current}))},Ve=e=>{const a=h();return a&&e?r.setTime(e,a):e},We=e=>{R!=null&&R.onMouseDownOutside&&R.onMouseDownOutside(e)},L=(e,a)=>{I({value:H.cloneDate(e||void 0)}),_.current=e,T.current=!1,c()||(y.current=!0),G&&G({syntheticEvent:a.syntheticEvent,nativeEvent:a.nativeEvent,value:h(),show:i(),target:w.current}),_.current=void 0,T.current=void 0,v(!1)},je=e=>{const a=Ve(e.value);L(a,e)},ae=()=>{const{popupClass:e,...a}=R,s=i(),B=h(),V=B&&H.getDate(B),W=u.classNames(e),j={popupClass:"k-datepicker-popup",show:s,anchor:m.current,className:W,id:le,anchorAlign:{horizontal:"left",vertical:"bottom"},popupAlign:{horizontal:"left",vertical:"top"},...a,onMouseDownOutside:We},ce={disabled:p,value:V,min:M,max:O,weekNumber:De,focusedDate:Te,className:c()?"k-calendar-lg":"",navigation:!c(),onChange:je},de=Fe(),it=Le();return c()?o.createElement(de,{_ref:ne,...ce}):o.createElement(it,{...j},o.createElement(de,{_ref:ne,...ce}))},oe=()=>{I({focused:!1}),v(!1)},He=()=>{const{windowWidth:e=0}=b,a={expand:i(),onClose:oe,title:Re,subTitle:Se,windowWidth:e};return o.createElement(vt.AdaptiveMode,{...a},o.createElement(ht.ActionSheetContent,null,ae()))},Ue=e=>{L(e.value,e)},Ye=()=>{I({focused:!0})},$e=()=>{v(!i())},z=()=>{p||(y.current=!0,v(!i()))},Xe=e=>{e.preventDefault()},Ze=e=>{const{altKey:a,keyCode:s}=e;if(s===u.Keys.esc&&i()){y.current=!0,v(!1);return}a&&(s===u.Keys.up||s===u.Keys.down)&&(e.preventDefault(),e.stopPropagation(),y.current=s===u.Keys.up,v(s===u.Keys.down))},w=o.useRef(null),m=o.useRef(null),d=o.useRef(null),g=o.useRef(null);o.useImperativeHandle(w,()=>({props:n,get element(){return m.current},get calendar(){return g.current},get dateInput(){return d.current},get name(){return n.name},get show(){return i()},get validity(){return F()},get value(){return h()},get mobileMode(){return c()},togglePopup:$e,focus:Ke})),o.useImperativeHandle(k,()=>w.current),u.useWebMcpRegister("datepicker",w,n,n.webMcp);const _=o.useRef(void 0),T=o.useRef(void 0),Ge=o.useRef(null),y=o.useRef(!1),K=o.useRef(!1),S=o.useRef(null),[b,Je]=o.useState({value:ge,show:me,focused:!1}),[,Qe]=o.useReducer(e=>e,!0),re=n.name||f||void 0,et=o.useCallback(e=>{if(p)return;let a=null;if(e!=null){if(e instanceof Date)a=e;else if(typeof e=="string"||typeof e=="number"){const s=new Date(e);isNaN(s.getTime())||(a=s)}}if(a&&r.isInDateRange(a,M,O)){const s={target:m.current,currentTarget:m.current};L(a,{syntheticEvent:s})}},[p,M,O]);u.useKendoPaste(m,{fieldName:re,onValueChange:et,enabled:!!re});const I=e=>{Je(a=>({...a,...e}))};o.useEffect(()=>{g.current&&g.current.element&&i()&&!K.current&&g.current.element.focus({preventScroll:!0}),c()&&i()&&!K.current&&setTimeout(()=>{g.current&&g.current.element&&g.current.element.focus({preventScroll:!0})},300),d.current&&d.current.element&&!i()&&y.current&&d.current.element.focus({preventScroll:!0}),K.current=i(),y.current=!1}),o.useEffect(()=>{var e;return S.current=u.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(a=>ze(a)),i()&&Qe(),(e=A())!=null&&e.body&&S.current&&S.current.observe(A().body),()=>{var a;clearTimeout(Ge.current),(a=A())!=null&&a.body&&S.current&&S.current.disconnect()}},[]);const le=f+"-popup-id",tt=ae(),nt=Ne(),at=h(),ot=Ae(),rt=He(),ue=!Y||F().valid,ie=C.toLanguageString(D.toggleCalendar,D.messages[D.toggleCalendar]),lt=Me||C.toLanguageString(D.selectDate,D.messages[D.selectDate]),ut={disabled:p,format:we,formatPlaceholder:Ie,id:Be,ariaLabelledBy:Ee,ariaDescribedBy:xe,ariaLabel:lt,max:O,min:M,name:n.name,onChange:Ue,required:n.required,_ref:d,tabIndex:i()?-1:ye,title:n.title,valid:F().valid,validationMessage:X,validityStyles:Y,value:at,label:void 0,placeholder:b.focused?null:qe,ariaExpanded:i(),autoFill:n.autoFill,twoDigitYearMax:Oe,enableMouseWheel:n.enableMouseWheel,autoCorrectParts:n.autoCorrectParts,autoSwitchParts:Ce,autoSwitchKeys:Pe,allowCaretMode:n.allowCaretMode,inputAttributes:_e},se=o.createElement(u.AsyncFocusBlur,{onFocus:Ye,onBlur:c()?void 0:oe,onSyncBlur:n.onBlur,onSyncFocus:n.onFocus},e=>o.createElement(o.Fragment,null,o.createElement("span",{...n.label?{}:ee,ref:m,className:u.classNames("k-input","k-datepicker",{[`k-input-${u.kendoThemeMaps.sizeMap[E]||E}`]:E,[`k-rounded-${u.kendoThemeMaps.roundedMap[x]||x}`]:x,[`k-input-${q}`]:q,"k-invalid":!ue,"k-required":te(),"k-disabled":p,"k-focus":b.focused},n.className),onKeyDown:Ze,style:{width:n.width},onFocus:c()?z:e.onFocus,onBlur:e.onBlur,onClick:c()?z:void 0},o.createElement(nt,{_ref:d,ariaRole:"combobox",ariaHasPopup:"grid",ariaExpanded:i(),ariaControls:i()?le:void 0,autoFocus:ke,...ut}),o.createElement(ot,{type:"button",icon:"calendar",svgIcon:dt.calendarIcon,title:ie,className:"k-input-button",onClick:c()?void 0:z,"aria-label":ie,fillMode:q,onMouseDown:Xe}),!c()&&tt),c()&&rt));return n.label?o.createElement(bt.PickerFloatingLabel,{dateInput:d,label:n.label,editorId:f,editorValid:ue,editorDisabled:p,children:se,style:{width:n.width},...ee}):se});U.propTypes={className:t.string,defaultShow:t.bool,defaultValue:t.instanceOf(Date),disabled:t.bool,focusedDate:t.instanceOf(Date),format:t.oneOfType([t.string,t.shape({skeleton:r.nullable(t.string),pattern:r.nullable(t.string),date:r.nullable(t.oneOf(["short","medium","long","full"])),time:r.nullable(t.oneOf(["short","medium","long","full"])),datetime:r.nullable(t.oneOf(["short","medium","long","full"])),era:r.nullable(t.oneOf(["narrow","short","long"])),year:r.nullable(t.oneOf(["numeric","2-digit"])),month:r.nullable(t.oneOf(["numeric","2-digit","narrow","short","long"])),day:r.nullable(t.oneOf(["numeric","2-digit"])),weekday:r.nullable(t.oneOf(["narrow","short","long"])),hour:r.nullable(t.oneOf(["numeric","2-digit"])),hour12:r.nullable(t.bool),minute:r.nullable(t.oneOf(["numeric","2-digit"])),second:r.nullable(t.oneOf(["numeric","2-digit"])),timeZoneName:r.nullable(t.oneOf(["short","long"]))})]),formatPlaceholder:t.oneOfType([r.nullable(t.oneOf(["wide","narrow","short","formatPattern"])),t.shape({year:r.nullable(t.string),month:r.nullable(t.string),day:r.nullable(t.string),hour:r.nullable(t.string),minute:r.nullable(t.string),second:r.nullable(t.string)})]),id:t.string,ariaLabelledBy:t.string,ariaDescribedBy:t.string,ariaLabel:t.string,min:t.instanceOf(Date),max:t.instanceOf(Date),name:t.string,popupSettings:t.shape({animate:r.nullable(t.bool),appendTo:r.nullable(t.any),popupClass:r.nullable(t.string)}),show:t.bool,tabIndex:t.number,title:t.string,value:t.instanceOf(Date),weekNumber:t.bool,width:t.oneOfType([t.number,t.string]),validationMessage:t.string,required:t.bool,valid:t.bool,size:t.oneOf(["small","medium","large"]),rounded:t.oneOf(["small","medium","large","full","none"]),fillMode:t.oneOf(["solid","flat","outline"]),adaptive:t.bool,adaptiveTitle:t.string,adaptiveSubtitle:t.string,autoFocus:t.bool,inputAttributes:t.object};const l={defaultShow:!1,defaultValue:null,dateInput:ft.DateInputInner,calendar:mt.Calendar,toggleButton:pt.ToggleButton,popup:ct.Popup,disabled:!1,format:"d",max:r.MAX_DATE,min:r.MIN_DATE,popupSettings:{},tabIndex:0,weekNumber:!1,validityStyles:!0,size:void 0,rounded:void 0,fillMode:void 0,autoFocus:!1},fe=u.createPropsContext();U.displayName="KendoReactDatePicker";exports.DatePicker=U;exports.DatePickerPropsContext=fe;exports.datePickerDefaultProps=l;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const it=require("react"),t=require("prop-types"),st=require("@progress/kendo-react-popup"),j=require("@progress/kendo-date-math"),u=require("@progress/kendo-react-common"),ct=require("@progress/kendo-svg-icons"),dt=require("../dateinput/DateInput.js"),ft=require("../calendar/components/Calendar.js"),r=require("../utils.js"),H=require("../messages/index.js"),mt=require("@progress/kendo-react-intl"),pt=require("./ToggleButton.js"),gt=require("../hooks/usePickerFloatingLabel.js"),bt=require("@progress/kendo-react-layout"),ht=require("../common/AdaptiveMode.js");function vt(n){const D=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const f in n)if(f!=="default"){const I=Object.getOwnPropertyDescriptor(n,f);Object.defineProperty(D,f,I.get?I:{enumerable:!0,get:()=>n[f]})}}return D.default=n,Object.freeze(D)}const o=vt(it),U=o.forwardRef((n,D)=>{const f=u.useId(n.id),I=mt.useLocalization(),k=u.useAdaptiveModeContext(),{defaultShow:me=l.defaultShow,defaultValue:pe=l.defaultValue,dateInput:ge=l.dateInput,calendar:be=l.calendar,toggleButton:he=l.toggleButton,popup:ve=l.popup,disabled:g=l.disabled,format:we=l.format,max:C=l.max,min:P=l.min,popupSettings:O=l.popupSettings,tabIndex:ye=l.tabIndex,weekNumber:De=l.weekNumber,validityStyles:Y=l.validityStyles,size:B=l.size,rounded:E=l.rounded,fillMode:x=l.fillMode,autoFocus:ke=l.autoFocus,show:$,autoSwitchParts:Ce,autoSwitchKeys:Pe,twoDigitYearMax:Oe,ariaLabel:Me,adaptive:wt,adaptiveTitle:Re=n.label||void 0,adaptiveSubtitle:Ie,formatPlaceholder:Se,inputAttributes:_e,validationMessage:X,visited:yt,value:q,touched:Dt,modified:kt,_adaptiveMode:Ct=k,valid:Z,focusedDate:Te,id:Be,ariaLabelledBy:Ee,ariaDescribedBy:xe,placeholder:qe,onChange:G,onOpen:J,onClose:Q,...ee}=u.usePropsContext(fe,n),N=()=>{if(u.canUseDOM)return m.current&&m.current.ownerDocument||window.document},c=()=>!!(b.windowWidth&&k&&b.windowWidth<=(k==null?void 0:k.medium)&&n.adaptive),h=()=>{const e=S.current!==void 0?S.current:q!==void 0?q:b.value;return e!==null?j.cloneDate(e):null},i=()=>_.current!==void 0?_.current:$!==void 0?$:b.show,Ne=()=>ge||l.dateInput,Ae=()=>he||l.toggleButton,Fe=()=>be||l.calendar,Le=()=>ve||l.popup,te=()=>n.required!==void 0?n.required:!1,A=()=>{const e=h()||q||null,a=P,s=C,T=r.isInDateRange(e,a,s),K=X!==void 0,V=(!te()||e!=null)&&T,W=Z!==void 0?Z:V;return{customError:K,rangeOverflow:e&&s.getTime()<e.getTime()||!1,rangeUnderflow:e&&e.getTime()<a.getTime()||!1,valid:W,valueMissing:e===null}},ze=e=>{for(const a of e)R({windowWidth:a.target.clientWidth})},Ke=()=>{d.current&&d.current.focus()},ne=e=>{p.current=e},v=e=>{i()!==e&&(R({show:e}),e&&J&&J({target:w.current}),!e&&Q&&Q({target:w.current}))},Ve=e=>{const a=h();return a&&e?r.setTime(e,a):e},We=e=>{O!=null&&O.onMouseDownOutside&&O.onMouseDownOutside(e)},F=(e,a)=>{R({value:j.cloneDate(e||void 0)}),S.current=e,_.current=!1,c()||(y.current=!0),G&&G({syntheticEvent:a.syntheticEvent,nativeEvent:a.nativeEvent,value:h(),show:i(),target:w.current}),S.current=void 0,_.current=void 0,v(!1)},je=e=>{const a=Ve(e.value);F(a,e)},ae=()=>{const{popupClass:e,...a}=O,s=i(),T=h(),K=T&&j.getDate(T),V=u.classNames(e),W={popupClass:"k-datepicker-popup",show:s,anchor:m.current,className:V,id:le,anchorAlign:{horizontal:"left",vertical:"bottom"},popupAlign:{horizontal:"left",vertical:"top"},...a,onMouseDownOutside:We},ce={disabled:g,value:K,min:P,max:C,weekNumber:De,focusedDate:Te,className:c()?"k-calendar-lg":"",navigation:!c(),onChange:je},de=Fe(),ut=Le();return c()?o.createElement(de,{_ref:ne,...ce}):o.createElement(ut,{...W},o.createElement(de,{_ref:ne,...ce}))},oe=()=>{R({focused:!1}),v(!1)},He=()=>{const{windowWidth:e=0}=b,a={expand:i(),onClose:oe,title:Re,subTitle:Ie,windowWidth:e};return o.createElement(ht.AdaptiveMode,{...a},o.createElement(bt.ActionSheetContent,null,ae()))},Ue=e=>{F(e.value,e)},Ye=()=>{R({focused:!0})},$e=()=>{v(!i())},L=()=>{g||(y.current=!0,v(!i()))},Xe=e=>{e.preventDefault()},Ze=e=>{const{altKey:a,keyCode:s}=e;if(s===u.Keys.esc&&i()){y.current=!0,v(!1);return}a&&(s===u.Keys.up||s===u.Keys.down)&&(e.preventDefault(),e.stopPropagation(),y.current=s===u.Keys.up,v(s===u.Keys.down))},w=o.useRef(null),m=o.useRef(null),d=o.useRef(null),p=o.useRef(null);o.useImperativeHandle(w,()=>({props:n,get element(){return m.current},get calendar(){return p.current},get dateInput(){return d.current},get name(){return n.name},get show(){return i()},get validity(){return A()},get value(){return h()},get mobileMode(){return c()},togglePopup:$e,focus:Ke})),o.useImperativeHandle(D,()=>w.current),u.useWebMcpRegister("datepicker",w,n,n.webMcp);const S=o.useRef(void 0),_=o.useRef(void 0),Ge=o.useRef(null),y=o.useRef(!1),z=o.useRef(!1),M=o.useRef(null),[b,Je]=o.useState({value:pe,show:me,focused:!1}),[,Qe]=o.useReducer(e=>e,!0),re=n.name||f||void 0,et=o.useCallback(e=>{if(g)return;let a=null;if(e!=null){if(e instanceof Date)a=e;else if(typeof e=="string"||typeof e=="number"){const s=new Date(e);isNaN(s.getTime())||(a=s)}}if(a&&r.isInDateRange(a,P,C)){const s={target:m.current,currentTarget:m.current};F(a,{syntheticEvent:s})}},[g,P,C]);u.useKendoPaste(m,{fieldName:re,onValueChange:et,enabled:!!re});const R=e=>{Je(a=>({...a,...e}))};o.useEffect(()=>{p.current&&p.current.element&&i()&&!z.current&&p.current.element.focus({preventScroll:!0}),c()&&i()&&!z.current&&setTimeout(()=>{p.current&&p.current.element&&p.current.element.focus({preventScroll:!0})},300),d.current&&d.current.element&&!i()&&y.current&&d.current.element.focus({preventScroll:!0}),z.current=i(),y.current=!1}),o.useEffect(()=>{var e;return M.current=u.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(a=>ze(a)),i()&&Qe(),(e=N())!=null&&e.body&&M.current&&M.current.observe(N().body),()=>{var a;clearTimeout(Ge.current),(a=N())!=null&&a.body&&M.current&&M.current.disconnect()}},[]);const le=f+"-popup-id",tt=ae(),nt=Ne(),at=h(),ot=Ae(),rt=He(),ue=!Y||A().valid,ie=I.toLanguageString(H.toggleCalendar,H.messages[H.toggleCalendar]),lt={disabled:g,format:we,formatPlaceholder:Se,id:Be,ariaLabelledBy:Ee,ariaDescribedBy:xe,ariaLabel:Me,max:C,min:P,name:n.name,onChange:Ue,required:n.required,_ref:d,tabIndex:i()?-1:ye,title:n.title,valid:A().valid,validationMessage:X,validityStyles:Y,value:at,label:void 0,placeholder:b.focused?null:qe,ariaExpanded:i(),autoFill:n.autoFill,twoDigitYearMax:Oe,enableMouseWheel:n.enableMouseWheel,autoCorrectParts:n.autoCorrectParts,autoSwitchParts:Ce,autoSwitchKeys:Pe,allowCaretMode:n.allowCaretMode,inputAttributes:_e},se=o.createElement(u.AsyncFocusBlur,{onFocus:Ye,onBlur:c()?void 0:oe,onSyncBlur:n.onBlur,onSyncFocus:n.onFocus},e=>o.createElement(o.Fragment,null,o.createElement("span",{...n.label?{}:ee,ref:m,className:u.classNames("k-input","k-datepicker",{[`k-input-${u.kendoThemeMaps.sizeMap[B]||B}`]:B,[`k-rounded-${u.kendoThemeMaps.roundedMap[E]||E}`]:E,[`k-input-${x}`]:x,"k-invalid":!ue,"k-required":te(),"k-disabled":g,"k-focus":b.focused},n.className),onKeyDown:Ze,style:{width:n.width},onFocus:c()?L:e.onFocus,onBlur:e.onBlur,onClick:c()?L:void 0},o.createElement(nt,{_ref:d,ariaRole:"combobox",ariaHasPopup:"grid",ariaExpanded:i(),ariaControls:i()?le:void 0,autoFocus:ke,...lt}),o.createElement(ot,{type:"button",icon:"calendar",svgIcon:ct.calendarIcon,title:ie,className:"k-input-button",onClick:c()?void 0:L,"aria-label":ie,fillMode:x,onMouseDown:Xe}),!c()&&tt),c()&&rt));return n.label?o.createElement(gt.PickerFloatingLabel,{dateInput:d,label:n.label,editorId:f,editorValid:ue,editorDisabled:g,children:se,style:{width:n.width},...ee}):se});U.propTypes={className:t.string,defaultShow:t.bool,defaultValue:t.instanceOf(Date),disabled:t.bool,focusedDate:t.instanceOf(Date),format:t.oneOfType([t.string,t.shape({skeleton:r.nullable(t.string),pattern:r.nullable(t.string),date:r.nullable(t.oneOf(["short","medium","long","full"])),time:r.nullable(t.oneOf(["short","medium","long","full"])),datetime:r.nullable(t.oneOf(["short","medium","long","full"])),era:r.nullable(t.oneOf(["narrow","short","long"])),year:r.nullable(t.oneOf(["numeric","2-digit"])),month:r.nullable(t.oneOf(["numeric","2-digit","narrow","short","long"])),day:r.nullable(t.oneOf(["numeric","2-digit"])),weekday:r.nullable(t.oneOf(["narrow","short","long"])),hour:r.nullable(t.oneOf(["numeric","2-digit"])),hour12:r.nullable(t.bool),minute:r.nullable(t.oneOf(["numeric","2-digit"])),second:r.nullable(t.oneOf(["numeric","2-digit"])),timeZoneName:r.nullable(t.oneOf(["short","long"]))})]),formatPlaceholder:t.oneOfType([r.nullable(t.oneOf(["wide","narrow","short","formatPattern"])),t.shape({year:r.nullable(t.string),month:r.nullable(t.string),day:r.nullable(t.string),hour:r.nullable(t.string),minute:r.nullable(t.string),second:r.nullable(t.string)})]),id:t.string,ariaLabelledBy:t.string,ariaDescribedBy:t.string,ariaLabel:t.string,min:t.instanceOf(Date),max:t.instanceOf(Date),name:t.string,popupSettings:t.shape({animate:r.nullable(t.bool),appendTo:r.nullable(t.any),popupClass:r.nullable(t.string)}),show:t.bool,tabIndex:t.number,title:t.string,value:t.instanceOf(Date),weekNumber:t.bool,width:t.oneOfType([t.number,t.string]),validationMessage:t.string,required:t.bool,valid:t.bool,size:t.oneOf(["small","medium","large"]),rounded:t.oneOf(["small","medium","large","full","none"]),fillMode:t.oneOf(["solid","flat","outline"]),adaptive:t.bool,adaptiveTitle:t.string,adaptiveSubtitle:t.string,autoFocus:t.bool,inputAttributes:t.object};const l={defaultShow:!1,defaultValue:null,dateInput:dt.DateInputInner,calendar:ft.Calendar,toggleButton:pt.ToggleButton,popup:st.Popup,disabled:!1,format:"d",max:r.MAX_DATE,min:r.MIN_DATE,popupSettings:{},tabIndex:0,weekNumber:!1,validityStyles:!0,size:void 0,rounded:void 0,fillMode:void 0,autoFocus:!1},fe=u.createPropsContext();U.displayName="KendoReactDatePicker";exports.DatePicker=U;exports.DatePickerPropsContext=fe;exports.datePickerDefaultProps=l;
|
|
@@ -7,73 +7,73 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import * as o from "react";
|
|
9
9
|
import t from "prop-types";
|
|
10
|
-
import { Popup as
|
|
11
|
-
import { cloneDate as
|
|
12
|
-
import { useId as
|
|
13
|
-
import { calendarIcon as
|
|
14
|
-
import { DateInputInner as
|
|
15
|
-
import { Calendar as
|
|
16
|
-
import { MIN_DATE as
|
|
17
|
-
import { toggleCalendar as
|
|
18
|
-
import { useLocalization as
|
|
19
|
-
import { ToggleButton as
|
|
20
|
-
import { PickerFloatingLabel as
|
|
21
|
-
import { ActionSheetContent as
|
|
22
|
-
import { AdaptiveMode as
|
|
23
|
-
const
|
|
24
|
-
const S =
|
|
25
|
-
defaultShow:
|
|
26
|
-
defaultValue:
|
|
27
|
-
dateInput:
|
|
28
|
-
calendar:
|
|
29
|
-
toggleButton:
|
|
30
|
-
popup:
|
|
10
|
+
import { Popup as dt } from "@progress/kendo-react-popup";
|
|
11
|
+
import { cloneDate as le, getDate as ft } from "@progress/kendo-date-math";
|
|
12
|
+
import { useId as mt, useAdaptiveModeContext as pt, usePropsContext as gt, useWebMcpRegister as ht, useKendoPaste as vt, canUseDOM as ue, AsyncFocusBlur as bt, classNames as se, kendoThemeMaps as ce, createPropsContext as wt, Keys as O } from "@progress/kendo-react-common";
|
|
13
|
+
import { calendarIcon as yt } from "@progress/kendo-svg-icons";
|
|
14
|
+
import { DateInputInner as Ct } from "../dateinput/DateInput.mjs";
|
|
15
|
+
import { Calendar as Dt } from "../calendar/components/Calendar.mjs";
|
|
16
|
+
import { MIN_DATE as Pt, MAX_DATE as kt, isInDateRange as de, setTime as Ot, nullable as a } from "../utils.mjs";
|
|
17
|
+
import { toggleCalendar as fe, messages as Mt } from "../messages/index.mjs";
|
|
18
|
+
import { useLocalization as It } from "@progress/kendo-react-intl";
|
|
19
|
+
import { ToggleButton as Rt } from "./ToggleButton.mjs";
|
|
20
|
+
import { PickerFloatingLabel as St } from "../hooks/usePickerFloatingLabel.mjs";
|
|
21
|
+
import { ActionSheetContent as _t } from "@progress/kendo-react-layout";
|
|
22
|
+
import { AdaptiveMode as Et } from "../common/AdaptiveMode.mjs";
|
|
23
|
+
const me = o.forwardRef((r, pe) => {
|
|
24
|
+
const S = mt(r.id), ge = It(), w = pt(), {
|
|
25
|
+
defaultShow: he = i.defaultShow,
|
|
26
|
+
defaultValue: ve = i.defaultValue,
|
|
27
|
+
dateInput: be = i.dateInput,
|
|
28
|
+
calendar: we = i.calendar,
|
|
29
|
+
toggleButton: ye = i.toggleButton,
|
|
30
|
+
popup: Ce = i.popup,
|
|
31
31
|
disabled: m = i.disabled,
|
|
32
|
-
format:
|
|
32
|
+
format: De = i.format,
|
|
33
33
|
max: y = i.max,
|
|
34
34
|
min: C = i.min,
|
|
35
35
|
popupSettings: D = i.popupSettings,
|
|
36
|
-
tabIndex:
|
|
37
|
-
weekNumber:
|
|
38
|
-
validityStyles:
|
|
36
|
+
tabIndex: Pe = i.tabIndex,
|
|
37
|
+
weekNumber: ke = i.weekNumber,
|
|
38
|
+
validityStyles: W = i.validityStyles,
|
|
39
39
|
size: _ = i.size,
|
|
40
40
|
rounded: E = i.rounded,
|
|
41
41
|
fillMode: B = i.fillMode,
|
|
42
|
-
autoFocus:
|
|
43
|
-
show:
|
|
44
|
-
autoSwitchParts:
|
|
45
|
-
autoSwitchKeys:
|
|
46
|
-
twoDigitYearMax:
|
|
47
|
-
ariaLabel:
|
|
48
|
-
adaptive:
|
|
49
|
-
adaptiveTitle:
|
|
50
|
-
adaptiveSubtitle:
|
|
51
|
-
formatPlaceholder:
|
|
52
|
-
inputAttributes:
|
|
53
|
-
validationMessage:
|
|
54
|
-
visited:
|
|
42
|
+
autoFocus: Oe = i.autoFocus,
|
|
43
|
+
show: q,
|
|
44
|
+
autoSwitchParts: Me,
|
|
45
|
+
autoSwitchKeys: Ie,
|
|
46
|
+
twoDigitYearMax: Re,
|
|
47
|
+
ariaLabel: Se,
|
|
48
|
+
adaptive: Tt,
|
|
49
|
+
adaptiveTitle: _e = r.label || void 0,
|
|
50
|
+
adaptiveSubtitle: Ee,
|
|
51
|
+
formatPlaceholder: Be,
|
|
52
|
+
inputAttributes: Te,
|
|
53
|
+
validationMessage: H,
|
|
54
|
+
visited: xt,
|
|
55
55
|
value: T,
|
|
56
|
-
touched:
|
|
57
|
-
modified:
|
|
58
|
-
_adaptiveMode:
|
|
59
|
-
valid:
|
|
60
|
-
focusedDate:
|
|
61
|
-
id:
|
|
62
|
-
ariaLabelledBy:
|
|
63
|
-
ariaDescribedBy:
|
|
64
|
-
placeholder:
|
|
65
|
-
onChange:
|
|
66
|
-
onOpen:
|
|
67
|
-
onClose:
|
|
68
|
-
...
|
|
69
|
-
} =
|
|
70
|
-
if (
|
|
56
|
+
touched: At,
|
|
57
|
+
modified: Nt,
|
|
58
|
+
_adaptiveMode: Ft = w,
|
|
59
|
+
valid: U,
|
|
60
|
+
focusedDate: xe,
|
|
61
|
+
id: Ae,
|
|
62
|
+
ariaLabelledBy: Ne,
|
|
63
|
+
ariaDescribedBy: Fe,
|
|
64
|
+
placeholder: Le,
|
|
65
|
+
onChange: Y,
|
|
66
|
+
onOpen: $,
|
|
67
|
+
onClose: j,
|
|
68
|
+
...X
|
|
69
|
+
} = gt(Bt, r), x = () => {
|
|
70
|
+
if (ue)
|
|
71
71
|
return d.current && d.current.ownerDocument || window.document;
|
|
72
72
|
}, s = () => !!(p.windowWidth && w && p.windowWidth <= (w == null ? void 0 : w.medium) && r.adaptive), g = () => {
|
|
73
73
|
const e = M.current !== void 0 ? M.current : T !== void 0 ? T : p.value;
|
|
74
|
-
return e !== null ?
|
|
75
|
-
}, l = () =>
|
|
76
|
-
const e = g() || T || null, n = C, u = y,
|
|
74
|
+
return e !== null ? le(e) : null;
|
|
75
|
+
}, l = () => I.current !== void 0 ? I.current : q !== void 0 ? q : p.show, Ve = () => be || i.dateInput, ze = () => ye || i.toggleButton, Ke = () => we || i.calendar, We = () => Ce || i.popup, Z = () => r.required !== void 0 ? r.required : !1, A = () => {
|
|
76
|
+
const e = g() || T || null, n = C, u = y, R = de(e, n, u), V = H !== void 0, z = (!Z() || e != null) && R, K = U !== void 0 ? U : z;
|
|
77
77
|
return {
|
|
78
78
|
customError: V,
|
|
79
79
|
rangeOverflow: e && u.getTime() < e.getTime() || !1,
|
|
@@ -81,38 +81,38 @@ const he = o.forwardRef((r, ve) => {
|
|
|
81
81
|
valid: K,
|
|
82
82
|
valueMissing: e === null
|
|
83
83
|
};
|
|
84
|
-
},
|
|
84
|
+
}, qe = (e) => {
|
|
85
85
|
for (const n of e)
|
|
86
86
|
k({ windowWidth: n.target.clientWidth });
|
|
87
|
-
},
|
|
87
|
+
}, He = () => {
|
|
88
88
|
c.current && c.current.focus();
|
|
89
|
-
},
|
|
89
|
+
}, G = (e) => {
|
|
90
90
|
f.current = e;
|
|
91
91
|
}, h = (e) => {
|
|
92
|
-
l() !== e && (k({ show: e }), e &&
|
|
93
|
-
},
|
|
92
|
+
l() !== e && (k({ show: e }), e && $ && $({ target: v.current }), !e && j && j({ target: v.current }));
|
|
93
|
+
}, Ue = (e) => {
|
|
94
94
|
const n = g();
|
|
95
|
-
return n && e ?
|
|
96
|
-
},
|
|
95
|
+
return n && e ? Ot(e, n) : e;
|
|
96
|
+
}, Ye = (e) => {
|
|
97
97
|
D != null && D.onMouseDownOutside && D.onMouseDownOutside(e);
|
|
98
|
-
},
|
|
99
|
-
k({ value:
|
|
98
|
+
}, N = (e, n) => {
|
|
99
|
+
k({ value: le(e || void 0) }), M.current = e, I.current = !1, s() || (b.current = !0), Y && Y({
|
|
100
100
|
syntheticEvent: n.syntheticEvent,
|
|
101
101
|
nativeEvent: n.nativeEvent,
|
|
102
102
|
value: g(),
|
|
103
103
|
show: l(),
|
|
104
104
|
target: v.current
|
|
105
|
-
}), M.current = void 0,
|
|
106
|
-
},
|
|
107
|
-
const n =
|
|
108
|
-
|
|
109
|
-
},
|
|
110
|
-
const { popupClass: e, ...n } = D, u = l(),
|
|
105
|
+
}), M.current = void 0, I.current = void 0, h(!1);
|
|
106
|
+
}, $e = (e) => {
|
|
107
|
+
const n = Ue(e.value);
|
|
108
|
+
N(n, e);
|
|
109
|
+
}, J = () => {
|
|
110
|
+
const { popupClass: e, ...n } = D, u = l(), R = g(), V = R && ft(R), z = se(e), K = {
|
|
111
111
|
popupClass: "k-datepicker-popup",
|
|
112
112
|
show: u,
|
|
113
113
|
anchor: d.current,
|
|
114
114
|
className: z,
|
|
115
|
-
id:
|
|
115
|
+
id: te,
|
|
116
116
|
anchorAlign: {
|
|
117
117
|
horizontal: "left",
|
|
118
118
|
vertical: "bottom"
|
|
@@ -122,41 +122,41 @@ const he = o.forwardRef((r, ve) => {
|
|
|
122
122
|
vertical: "top"
|
|
123
123
|
},
|
|
124
124
|
...n,
|
|
125
|
-
onMouseDownOutside:
|
|
126
|
-
},
|
|
125
|
+
onMouseDownOutside: Ye
|
|
126
|
+
}, ae = {
|
|
127
127
|
disabled: m,
|
|
128
128
|
value: V,
|
|
129
129
|
min: C,
|
|
130
130
|
max: y,
|
|
131
|
-
weekNumber:
|
|
132
|
-
focusedDate:
|
|
131
|
+
weekNumber: ke,
|
|
132
|
+
focusedDate: xe,
|
|
133
133
|
className: s() ? "k-calendar-lg" : "",
|
|
134
134
|
navigation: !s(),
|
|
135
|
-
onChange:
|
|
136
|
-
},
|
|
137
|
-
return s() ? /* @__PURE__ */ o.createElement(
|
|
138
|
-
},
|
|
135
|
+
onChange: $e
|
|
136
|
+
}, ie = Ke(), ct = We();
|
|
137
|
+
return s() ? /* @__PURE__ */ o.createElement(ie, { _ref: G, ...ae }) : /* @__PURE__ */ o.createElement(ct, { ...K }, /* @__PURE__ */ o.createElement(ie, { _ref: G, ...ae }));
|
|
138
|
+
}, Q = () => {
|
|
139
139
|
k({ focused: !1 }), h(!1);
|
|
140
|
-
},
|
|
140
|
+
}, je = () => {
|
|
141
141
|
const { windowWidth: e = 0 } = p, n = {
|
|
142
142
|
expand: l(),
|
|
143
|
-
onClose:
|
|
144
|
-
title:
|
|
145
|
-
subTitle:
|
|
143
|
+
onClose: Q,
|
|
144
|
+
title: _e,
|
|
145
|
+
subTitle: Ee,
|
|
146
146
|
windowWidth: e
|
|
147
147
|
};
|
|
148
|
-
return /* @__PURE__ */ o.createElement(
|
|
149
|
-
},
|
|
150
|
-
|
|
151
|
-
},
|
|
148
|
+
return /* @__PURE__ */ o.createElement(Et, { ...n }, /* @__PURE__ */ o.createElement(_t, null, J()));
|
|
149
|
+
}, Xe = (e) => {
|
|
150
|
+
N(e.value, e);
|
|
151
|
+
}, Ze = () => {
|
|
152
152
|
k({ focused: !0 });
|
|
153
|
-
},
|
|
153
|
+
}, Ge = () => {
|
|
154
154
|
h(!l());
|
|
155
155
|
}, F = () => {
|
|
156
156
|
m || (b.current = !0, h(!l()));
|
|
157
|
-
},
|
|
157
|
+
}, Je = (e) => {
|
|
158
158
|
e.preventDefault();
|
|
159
|
-
},
|
|
159
|
+
}, Qe = (e) => {
|
|
160
160
|
const { altKey: n, keyCode: u } = e;
|
|
161
161
|
if (u === O.esc && l()) {
|
|
162
162
|
b.current = !0, h(!1);
|
|
@@ -184,7 +184,7 @@ const he = o.forwardRef((r, ve) => {
|
|
|
184
184
|
return l();
|
|
185
185
|
},
|
|
186
186
|
get validity() {
|
|
187
|
-
return
|
|
187
|
+
return A();
|
|
188
188
|
},
|
|
189
189
|
get value() {
|
|
190
190
|
return g();
|
|
@@ -192,16 +192,16 @@ const he = o.forwardRef((r, ve) => {
|
|
|
192
192
|
get mobileMode() {
|
|
193
193
|
return s();
|
|
194
194
|
},
|
|
195
|
-
togglePopup:
|
|
195
|
+
togglePopup: Ge,
|
|
196
196
|
// Hidden Methods but still accessible
|
|
197
|
-
focus:
|
|
197
|
+
focus: He
|
|
198
198
|
})
|
|
199
|
-
), o.useImperativeHandle(
|
|
200
|
-
const M = o.useRef(void 0),
|
|
201
|
-
value:
|
|
202
|
-
show:
|
|
199
|
+
), o.useImperativeHandle(pe, () => v.current), ht("datepicker", v, r, r.webMcp);
|
|
200
|
+
const M = o.useRef(void 0), I = o.useRef(void 0), et = o.useRef(null), b = o.useRef(!1), L = o.useRef(!1), P = o.useRef(null), [p, tt] = o.useState({
|
|
201
|
+
value: ve,
|
|
202
|
+
show: he,
|
|
203
203
|
focused: !1
|
|
204
|
-
}), [,
|
|
204
|
+
}), [, nt] = o.useReducer((e) => e, !0), ee = r.name || S || void 0, ot = o.useCallback(
|
|
205
205
|
(e) => {
|
|
206
206
|
if (m)
|
|
207
207
|
return;
|
|
@@ -214,23 +214,23 @@ const he = o.forwardRef((r, ve) => {
|
|
|
214
214
|
isNaN(u.getTime()) || (n = u);
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
if (n &&
|
|
217
|
+
if (n && de(n, C, y)) {
|
|
218
218
|
const u = {
|
|
219
219
|
target: d.current,
|
|
220
220
|
currentTarget: d.current
|
|
221
221
|
};
|
|
222
|
-
|
|
222
|
+
N(n, { syntheticEvent: u });
|
|
223
223
|
}
|
|
224
224
|
},
|
|
225
225
|
[m, C, y]
|
|
226
226
|
);
|
|
227
|
-
|
|
228
|
-
fieldName:
|
|
229
|
-
onValueChange:
|
|
230
|
-
enabled: !!
|
|
227
|
+
vt(d, {
|
|
228
|
+
fieldName: ee,
|
|
229
|
+
onValueChange: ot,
|
|
230
|
+
enabled: !!ee
|
|
231
231
|
});
|
|
232
232
|
const k = (e) => {
|
|
233
|
-
|
|
233
|
+
tt((n) => ({ ...n, ...e }));
|
|
234
234
|
};
|
|
235
235
|
o.useEffect(() => {
|
|
236
236
|
f.current && f.current.element && l() && !L.current && f.current.element.focus({ preventScroll: !0 }), s() && l() && !L.current && setTimeout(() => {
|
|
@@ -238,119 +238,119 @@ const he = o.forwardRef((r, ve) => {
|
|
|
238
238
|
}, 300), c.current && c.current.element && !l() && b.current && c.current.element.focus({ preventScroll: !0 }), L.current = l(), b.current = !1;
|
|
239
239
|
}), o.useEffect(() => {
|
|
240
240
|
var e;
|
|
241
|
-
return P.current =
|
|
241
|
+
return P.current = ue && window.ResizeObserver && new window.ResizeObserver((n) => qe(n)), l() && nt(), (e = x()) != null && e.body && P.current && P.current.observe(x().body), () => {
|
|
242
242
|
var n;
|
|
243
|
-
clearTimeout(
|
|
243
|
+
clearTimeout(et.current), (n = x()) != null && n.body && P.current && P.current.disconnect();
|
|
244
244
|
};
|
|
245
245
|
}, []);
|
|
246
|
-
const
|
|
246
|
+
const te = S + "-popup-id", rt = J(), at = Ve(), it = g(), lt = ze(), ut = je(), ne = !W || A().valid, oe = ge.toLanguageString(fe, Mt[fe]), st = {
|
|
247
247
|
disabled: m,
|
|
248
|
-
format:
|
|
249
|
-
formatPlaceholder:
|
|
250
|
-
id:
|
|
251
|
-
ariaLabelledBy:
|
|
252
|
-
ariaDescribedBy:
|
|
253
|
-
ariaLabel:
|
|
248
|
+
format: De,
|
|
249
|
+
formatPlaceholder: Be,
|
|
250
|
+
id: Ae,
|
|
251
|
+
ariaLabelledBy: Ne,
|
|
252
|
+
ariaDescribedBy: Fe,
|
|
253
|
+
ariaLabel: Se,
|
|
254
254
|
max: y,
|
|
255
255
|
min: C,
|
|
256
256
|
name: r.name,
|
|
257
|
-
onChange:
|
|
257
|
+
onChange: Xe,
|
|
258
258
|
required: r.required,
|
|
259
259
|
_ref: c,
|
|
260
|
-
tabIndex: l() ? -1 :
|
|
260
|
+
tabIndex: l() ? -1 : Pe,
|
|
261
261
|
title: r.title,
|
|
262
|
-
valid:
|
|
263
|
-
validationMessage:
|
|
264
|
-
validityStyles:
|
|
265
|
-
value:
|
|
262
|
+
valid: A().valid,
|
|
263
|
+
validationMessage: H,
|
|
264
|
+
validityStyles: W,
|
|
265
|
+
value: it,
|
|
266
266
|
label: void 0,
|
|
267
|
-
placeholder: p.focused ? null :
|
|
267
|
+
placeholder: p.focused ? null : Le,
|
|
268
268
|
ariaExpanded: l(),
|
|
269
269
|
autoFill: r.autoFill,
|
|
270
|
-
twoDigitYearMax:
|
|
270
|
+
twoDigitYearMax: Re,
|
|
271
271
|
enableMouseWheel: r.enableMouseWheel,
|
|
272
272
|
autoCorrectParts: r.autoCorrectParts,
|
|
273
|
-
autoSwitchParts:
|
|
274
|
-
autoSwitchKeys:
|
|
273
|
+
autoSwitchParts: Me,
|
|
274
|
+
autoSwitchKeys: Ie,
|
|
275
275
|
allowCaretMode: r.allowCaretMode,
|
|
276
|
-
inputAttributes:
|
|
277
|
-
},
|
|
278
|
-
|
|
276
|
+
inputAttributes: Te
|
|
277
|
+
}, re = /* @__PURE__ */ o.createElement(
|
|
278
|
+
bt,
|
|
279
279
|
{
|
|
280
|
-
onFocus:
|
|
281
|
-
onBlur: s() ? void 0 :
|
|
280
|
+
onFocus: Ze,
|
|
281
|
+
onBlur: s() ? void 0 : Q,
|
|
282
282
|
onSyncBlur: r.onBlur,
|
|
283
283
|
onSyncFocus: r.onFocus
|
|
284
284
|
},
|
|
285
285
|
(e) => /* @__PURE__ */ o.createElement(o.Fragment, null, /* @__PURE__ */ o.createElement(
|
|
286
286
|
"span",
|
|
287
287
|
{
|
|
288
|
-
...r.label ? {} :
|
|
288
|
+
...r.label ? {} : X,
|
|
289
289
|
ref: d,
|
|
290
|
-
className:
|
|
290
|
+
className: se(
|
|
291
291
|
"k-input",
|
|
292
292
|
"k-datepicker",
|
|
293
293
|
{
|
|
294
|
-
[`k-input-${
|
|
295
|
-
[`k-rounded-${
|
|
294
|
+
[`k-input-${ce.sizeMap[_] || _}`]: _,
|
|
295
|
+
[`k-rounded-${ce.roundedMap[E] || E}`]: E,
|
|
296
296
|
[`k-input-${B}`]: B,
|
|
297
|
-
"k-invalid": !
|
|
298
|
-
"k-required":
|
|
297
|
+
"k-invalid": !ne,
|
|
298
|
+
"k-required": Z(),
|
|
299
299
|
"k-disabled": m,
|
|
300
300
|
"k-focus": p.focused
|
|
301
301
|
},
|
|
302
302
|
r.className
|
|
303
303
|
),
|
|
304
|
-
onKeyDown:
|
|
304
|
+
onKeyDown: Qe,
|
|
305
305
|
style: { width: r.width },
|
|
306
306
|
onFocus: s() ? F : e.onFocus,
|
|
307
307
|
onBlur: e.onBlur,
|
|
308
308
|
onClick: s() ? F : void 0
|
|
309
309
|
},
|
|
310
310
|
/* @__PURE__ */ o.createElement(
|
|
311
|
-
|
|
311
|
+
at,
|
|
312
312
|
{
|
|
313
313
|
_ref: c,
|
|
314
314
|
ariaRole: "combobox",
|
|
315
315
|
ariaHasPopup: "grid",
|
|
316
316
|
ariaExpanded: l(),
|
|
317
|
-
ariaControls: l() ?
|
|
318
|
-
autoFocus:
|
|
319
|
-
...
|
|
317
|
+
ariaControls: l() ? te : void 0,
|
|
318
|
+
autoFocus: Oe,
|
|
319
|
+
...st
|
|
320
320
|
}
|
|
321
321
|
),
|
|
322
322
|
/* @__PURE__ */ o.createElement(
|
|
323
|
-
|
|
323
|
+
lt,
|
|
324
324
|
{
|
|
325
325
|
type: "button",
|
|
326
326
|
icon: "calendar",
|
|
327
|
-
svgIcon:
|
|
328
|
-
title:
|
|
327
|
+
svgIcon: yt,
|
|
328
|
+
title: oe,
|
|
329
329
|
className: "k-input-button",
|
|
330
330
|
onClick: s() ? void 0 : F,
|
|
331
|
-
"aria-label":
|
|
331
|
+
"aria-label": oe,
|
|
332
332
|
fillMode: B,
|
|
333
|
-
onMouseDown:
|
|
333
|
+
onMouseDown: Je
|
|
334
334
|
}
|
|
335
335
|
),
|
|
336
|
-
!s() &&
|
|
337
|
-
), s() &&
|
|
336
|
+
!s() && rt
|
|
337
|
+
), s() && ut)
|
|
338
338
|
);
|
|
339
339
|
return r.label ? /* @__PURE__ */ o.createElement(
|
|
340
|
-
|
|
340
|
+
St,
|
|
341
341
|
{
|
|
342
342
|
dateInput: c,
|
|
343
343
|
label: r.label,
|
|
344
344
|
editorId: S,
|
|
345
|
-
editorValid:
|
|
345
|
+
editorValid: ne,
|
|
346
346
|
editorDisabled: m,
|
|
347
|
-
children:
|
|
347
|
+
children: re,
|
|
348
348
|
style: { width: r.width },
|
|
349
|
-
...
|
|
349
|
+
...X
|
|
350
350
|
}
|
|
351
|
-
) :
|
|
351
|
+
) : re;
|
|
352
352
|
});
|
|
353
|
-
|
|
353
|
+
me.propTypes = {
|
|
354
354
|
className: t.string,
|
|
355
355
|
defaultShow: t.bool,
|
|
356
356
|
defaultValue: t.instanceOf(Date),
|
|
@@ -422,14 +422,14 @@ he.propTypes = {
|
|
|
422
422
|
const i = {
|
|
423
423
|
defaultShow: !1,
|
|
424
424
|
defaultValue: null,
|
|
425
|
-
dateInput:
|
|
426
|
-
calendar:
|
|
427
|
-
toggleButton:
|
|
428
|
-
popup:
|
|
425
|
+
dateInput: Ct,
|
|
426
|
+
calendar: Dt,
|
|
427
|
+
toggleButton: Rt,
|
|
428
|
+
popup: dt,
|
|
429
429
|
disabled: !1,
|
|
430
430
|
format: "d",
|
|
431
|
-
max:
|
|
432
|
-
min:
|
|
431
|
+
max: kt,
|
|
432
|
+
min: Pt,
|
|
433
433
|
popupSettings: {},
|
|
434
434
|
tabIndex: 0,
|
|
435
435
|
weekNumber: !1,
|
|
@@ -438,10 +438,10 @@ const i = {
|
|
|
438
438
|
rounded: void 0,
|
|
439
439
|
fillMode: void 0,
|
|
440
440
|
autoFocus: !1
|
|
441
|
-
},
|
|
442
|
-
|
|
441
|
+
}, Bt = wt();
|
|
442
|
+
me.displayName = "KendoReactDatePicker";
|
|
443
443
|
export {
|
|
444
|
-
|
|
445
|
-
|
|
444
|
+
me as DatePicker,
|
|
445
|
+
Bt as DatePickerPropsContext,
|
|
446
446
|
i as datePickerDefaultProps
|
|
447
447
|
};
|
|
@@ -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 T=require("react"),t=require("prop-types"),P=require("@progress/kendo-react-popup"),D=require("@progress/kendo-date-math"),o=require("@progress/kendo-react-common"),c=require("@progress/kendo-react-intl"),x=require("@progress/kendo-svg-icons"),b=require("../package-metadata.js"),g=require("../dateinput/DateInput.js"),_=require("../calendar/components/MultiViewCalendar.js"),h=require("../calendar/models/SelectionRange.js"),u=require("../utils.js"),i=require("../messages/index.js"),A=require("@progress/kendo-react-buttons"),L=require("../common/AdaptiveMode.js"),N=require("@progress/kendo-react-layout");function z(d){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(d){for(const e in d)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(d,e);Object.defineProperty(a,e,s.get?s:{enumerable:!0,get:()=>d[e]})}}return a.default=d,Object.freeze(a)}const n=z(T),l=class l extends n.Component{constructor(a){super(a),this._element=null,this._calendar=null,this._startDateInput=n.createRef(),this._endDateInput=n.createRef(),this.shouldFocusDateInput=!1,this.shouldFocusCalendar=!1,this.showLicenseWatermark=!1,this.focus=()=>{this.startDateInput&&this.startDateInput.focus()},this.setCalendarRef=e=>{this._calendar=e},this.focusCalendarElement=()=>{this._calendar&&this._calendar.element&&this._calendar.element.focus({preventScroll:!0})},this.calculateValue=(e,s)=>(e.value!==void 0?e.value:s.value)||h.EMPTY_SELECTIONRANGE,this.calculateShow=(e,s)=>e.show!==void 0?e.show:s.show,this.renderCalendar=()=>{const e=this.value||h.EMPTY_SELECTIONRANGE,s={min:this.min,max:this.max,allowReverse:this.props.allowReverse,mode:"range",focusedDate:this.props.focusedDate,disabled:this.props.disabled,className:this.mobileMode?"k-calendar-lg":"",mobileMode:this.mobileMode,...this.props.calendarSettings,value:e,dir:this.props.dir,onChange:this.handleCalendarChange};return this.props.calendar?n.createElement(this.props.calendar,{...s}):n.createElement(_.MultiViewCalendar,{...s,ref:this.setCalendarRef})},this.renderPopup=()=>{const e={popupClass:o.classNames("k-calendar-container","k-daterangepicker-popup"),animate:this._element!==null,anchor:this._element,id:this._popupId,anchorAlign:{horizontal:"left",vertical:"bottom"},popupAlign:{horizontal:"left",vertical:"top"},...this.props.popupSettings,show:this.show};return this.props.popup?n.createElement(this.props.popup,{...e},this.renderCalendar()):n.createElement(P.Popup,{...e},this.renderCalendar())},this.renderAdaptivePopup=()=>{const{windowWidth:e=0}=this.state,s={expand:this.show,onClose:r=>this.handleCancel(r),title:this.props.adaptiveTitle,subTitle:this.props.adaptiveSubtitle,windowWidth:e,footer:{cancelText:this.localizationService.toLanguageString(i.dateRangePickerCancel,i.messages[i.dateRangePickerCancel]),onCancel:this.handleCancel,applyText:this.localizationService.toLanguageString(i.dateRangePickerSet,i.messages[i.dateRangePickerSet]),onApply:this.handleBlur}};return n.createElement(L.AdaptiveMode,{...s},n.createElement(N.ActionSheetContent,null,n.createElement("div",{className:"k-scrollable-wrap"},this.renderCalendar())))},this.handleReverseClick=e=>{const s={start:this.value.end,end:this.value.start},r={syntheticEvent:e,nativeEvent:e.nativeEvent};this.handleChange(s,r)},this.handleReverseMouseDown=e=>{e.preventDefault()},this.handleFocus=e=>{clearTimeout(this.nextTickId),this.shouldFocusDateInput||this.mobileMode&&this.setState({currentValue:this.value});const{onFocus:s}=this.props;s&&s.call(void 0,e)},this.handleClick=()=>{this.shouldFocusDateInput||this.setShow(!0)},this.handleBlur=e=>{this.nextTick(()=>{this.setShow(!1)});const{onBlur:s}=this.props;s&&s.call(void 0,e)},this.handleCancel=e=>{this.nextTick(()=>{this.setShow(!1),this.setState({currentValue:h.EMPTY_SELECTIONRANGE})});const{onCancel:s}=this.props;s&&s.call(void 0,e)},this.handleEndChange=e=>{const s={start:this.value.start,end: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(b.packageMetadata,{component:"DateRangePicker"}),this.licenseMessage=o.getLicenseMessage(b.packageMetadata),this.state={show:this.props.show||this.props.defaultShow||l.defaultProps.defaultShow,value:this.props.value||this.props.defaultValue||l.defaultProps.defaultValue,currentValue:h.EMPTY_SELECTIONRANGE},this.nextTick=this.nextTick.bind(this),this.setShow=this.setShow.bind(this),this.focusCalendarElement=this.focusCalendarElement.bind(this),this.focusDateInputElement=this.focusDateInputElement.bind(this)}get _popupId(){return this.props.id+"-popup-id"}get _startInputId(){return this.props.id+"-start-input-id"}get _endInputId(){return this.props.id+"-end-input-id"}get element(){return this._element}get startDateInput(){return this._startDateInput.current}get endDateInput(){return this._endDateInput.current}get calendar(){return this._calendar}get value(){return(this.valueDuringOnChange!==void 0?this.valueDuringOnChange:this.props.value!==void 0?this.props.value:this.state.value)||h.EMPTY_SELECTIONRANGE}get show(){return this.showDuringOnChange!==void 0?this.showDuringOnChange:this.props.show!==void 0?this.props.show:this.state.show}get min(){return this.props.min!==void 0?this.props.min:l.defaultProps.min}get max(){return this.props.max!==void 0?this.props.max:l.defaultProps.max}get document(){if(o.canUseDOM)return this.element&&this.element.ownerDocument||document}get localizationService(){return c.provideLocalizationService(this)}get mobileMode(){var e;return!!(this.state.windowWidth&&this.props._adaptiveMode&&this.state.windowWidth<=((e=this.props._adaptiveMode)==null?void 0:e.medium)&&this.props.adaptive)}componentDidMount(){var a;this.observerResize=o.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.show&&this.forceUpdate(),(a=this.document)!=null&&a.body&&this.observerResize&&this.observerResize.observe(this.document.body)}componentDidUpdate(){this.shouldFocusCalendar&&this.focusCalendarElement(),this.mobileMode&&this.show&&setTimeout(()=>{this.focusCalendarElement()},300),this.shouldFocusDateInput&&this.focusDateInputElement(),this.shouldFocusCalendar=!1,this.shouldFocusDateInput=!1}componentWillUnmount(){var a;clearTimeout(this.nextTickId),(a=this.document)!=null&&a.body&&this.observerResize&&this.observerResize.disconnect()}render(){const{autoFocus:a}=this.props,e=this.value||h.EMPTY_SELECTIONRANGE,s=this.mobileMode&&this.show?this.state.currentValue:e,r=(this.props.startDateInputSettings||{}).id||this._startInputId,m=(this.props.endDateInputSettings||{}).id||this._endInputId,S=o.classNames("k-daterangepicker",{"k-disabled":this.props.disabled},this.props.className),E=this.localizationService.toLanguageString(i.start,i.messages[i.start]),C=this.localizationService.toLanguageString(i.end,i.messages[i.end]),y=this.localizationService.toLanguageString(i.separator,i.messages[i.separator]),k=this.localizationService.toLanguageString(i.selectStartDate,i.messages[i.selectStartDate]),R=this.localizationService.toLanguageString(i.selectEndDate,i.messages[i.selectEndDate]),f={disableSelection:this.mobileMode&&!0,label:E,ariaLabel:k,ariaHasPopup:"grid",format:this.props.format,min:this.min,max:this.max,id:this._startInputId,disabled:this.props.disabled,valid:this.props.valid,tabIndex:this.props.tabIndex,ariaExpanded:this.show,clearButton:this.props.clearButton,...this.props.startDateInputSettings,value:s.start,onChange:this.handleStartChange,inputAttributes:this.props.inputAttributes},v={disableSelection:this.mobileMode&&!0,label:C,ariaLabel:R,ariaHasPopup:"grid",format:this.props.format,min:this.min,max:this.max,id:this._endInputId,disabled:this.props.disabled,valid:this.props.valid,tabIndex:this.props.tabIndex,ariaExpanded:this.show,clearButton:this.props.clearButton,...this.props.endDateInputSettings,value:s.end,onChange:this.handleEndChange,inputAttributes:this.props.inputAttributes},M=n.createElement(A.Button,{type:"button",className:"k-select",fillMode:"flat",title:c.provideLocalizationService(this).toLanguageString(i.swapStartEnd,i.messages[i.swapStartEnd]),onMouseDown:this.handleReverseMouseDown,onClick:this.handleReverseClick,"aria-controls":r+" "+m,"aria-label":c.provideLocalizationService(this).toLanguageString(i.swapStartEnd,i.messages[i.swapStartEnd])},n.createElement(o.IconWrap,{style:{transform:"rotate(90deg)"},name:"arrows-swap",icon:x.arrowsSwapIcon}));return n.createElement(n.Fragment,null,n.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.mobileMode?this.handleClick:this.handleFocus,onClick:this.handleClick,onKeyDown:this.handleKeyDown,onBlur:this.mobileMode?void 0:this.handleBlur,dir:this.props.dir},this.props.startDateInput?n.createElement(this.props.startDateInput,{...f}):n.createElement(g.DateInput,{...f,autoFocus:a,ref:this._startDateInput,ariaRole:"combobox",ariaControls:this.show?this._popupId:void 0}),(this.props.allowReverse||this.props.calendarSettings&&this.props.calendarSettings.allowReverse)&&this.props.swapButton?M:y,this.props.endDateInput?n.createElement(this.props.endDateInput,{...v}):n.createElement(g.DateInput,{...v,ref:this._endDateInput,ariaRole:"combobox",ariaControls:this.show?this._popupId:void 0}),!this.mobileMode&&this.renderPopup()),this.mobileMode&&this.renderAdaptivePopup(),this.showLicenseWatermark&&n.createElement(o.WatermarkOverlay,{message:this.licenseMessage}))}focusDateInputElement(){if(!document||!this.startDateInput||!this.startDateInput.element||!this.endDateInput||!this.endDateInput.element)return;const a=o.getActiveElement(document);(this.value.start===null||this.value.end!==null)&&a!==this.endDateInput.element?this.startDateInput.element.focus({preventScroll:!0}):a!==this.startDateInput.element&&this.endDateInput.element.focus({preventScroll:!0})}nextTick(a){clearTimeout(this.nextTickId),this.nextTickId=window.setTimeout(()=>a())}setShow(a){const{onOpen:e,onClose:s}=this.props;this.show!==a&&(this.setState({show:a}),a&&e&&e.call(void 0,{target:this}),!a&&s&&s.call(void 0,{target:this}))}calculateMedia(a){for(const e of a)this.setState({windowWidth:e.target.clientWidth})}};l.displayName="DateRangePicker",l.propTypes={allowReverse:t.bool,calendarSettings:t.any,className:t.string,defaultShow:t.bool,defaultValue:t.shape({start:u.nullable(t.instanceOf(Date).isRequired),end:u.nullable(t.instanceOf(Date).isRequired)}),disabled:t.bool,endDateInputSettings:t.shape(g.DateInput.propTypes),focusedDate:t.instanceOf(Date),format:t.oneOfType([t.string,t.shape({skeleton:t.string,pattern:t.string,date:t.oneOf(["short","medium","long","full"]),time:t.oneOf(["short","medium","long","full"]),datetime:t.oneOf(["short","medium","long","full"]),era:t.oneOf(["narrow","short","long"]),year:t.oneOf(["numeric","2-digit"]),month:t.oneOf(["numeric","2-digit","narrow","short","long"]),day:t.oneOf(["numeric","2-digit"]),weekday:t.oneOf(["narrow","short","long"]),hour:t.oneOf(["numeric","2-digit"]),hour12:t.bool,minute:t.oneOf(["numeric","2-digit"]),second:t.oneOf(["numeric","2-digit"]),timeZoneName:t.oneOf(["short","long"])})]),id:t.string,ariaLabelledBy:t.string,ariaDescribedBy:t.string,max:t.instanceOf(Date),min:t.instanceOf(Date),onBlur:t.func,onChange:t.func,onFocus:t.func,popupSettings:t.any,show:t.bool,startDateInputSettings:t.any,style:t.any,swapButton:t.any,tabIndex:t.number,dir:t.string,value:t.shape({start:u.nullable(t.instanceOf(Date)),end:u.nullable(t.instanceOf(Date))}),autoFocus:t.bool,inputAttributes:t.object},l.defaultProps={allowReverse:!1,defaultShow:!1,defaultValue:h.EMPTY_SELECTIONRANGE,disabled:!1,format:"d",max:u.MAX_DATE,min:u.MIN_DATE,swapButton:!1,autoFocus:!1};let p=l;const w=o.createPropsContext(),I=o.withIdHOC(o.withPropsContext(w,o.withAdaptiveModeContext(p)));I.displayName="KendoReactDateRangePicker";c.registerForLocalization(p);exports.DateRangePicker=I;exports.DateRangePickerPropsContext=w;exports.DateRangePickerWithoutContext=p;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("react"),t=require("prop-types"),O=require("@progress/kendo-react-popup"),b=require("@progress/kendo-date-math"),o=require("@progress/kendo-react-common"),c=require("@progress/kendo-react-intl"),T=require("@progress/kendo-svg-icons"),D=require("../package-metadata.js"),g=require("../dateinput/DateInput.js"),P=require("../calendar/components/MultiViewCalendar.js"),h=require("../calendar/models/SelectionRange.js"),u=require("../utils.js"),i=require("../messages/index.js"),x=require("@progress/kendo-react-buttons"),_=require("../common/AdaptiveMode.js"),A=require("@progress/kendo-react-layout");function N(d){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(d){for(const e in d)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(d,e);Object.defineProperty(a,e,s.get?s:{enumerable:!0,get:()=>d[e]})}}return a.default=d,Object.freeze(a)}const n=N(M),l=class l extends n.Component{constructor(a){super(a),this._element=null,this._calendar=null,this._startDateInput=n.createRef(),this._endDateInput=n.createRef(),this.shouldFocusDateInput=!1,this.shouldFocusCalendar=!1,this.showLicenseWatermark=!1,this.focus=()=>{this.startDateInput&&this.startDateInput.focus()},this.setCalendarRef=e=>{this._calendar=e},this.focusCalendarElement=()=>{this._calendar&&this._calendar.element&&this._calendar.element.focus({preventScroll:!0})},this.calculateValue=(e,s)=>(e.value!==void 0?e.value:s.value)||h.EMPTY_SELECTIONRANGE,this.calculateShow=(e,s)=>e.show!==void 0?e.show:s.show,this.renderCalendar=()=>{const e=this.value||h.EMPTY_SELECTIONRANGE,s={min:this.min,max:this.max,allowReverse:this.props.allowReverse,mode:"range",focusedDate:this.props.focusedDate,disabled:this.props.disabled,className:this.mobileMode?"k-calendar-lg":"",mobileMode:this.mobileMode,...this.props.calendarSettings,value:e,dir:this.props.dir,onChange:this.handleCalendarChange};return this.props.calendar?n.createElement(this.props.calendar,{...s}):n.createElement(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?n.createElement(this.props.popup,{...e},this.renderCalendar()):n.createElement(O.Popup,{...e},this.renderCalendar())},this.renderAdaptivePopup=()=>{const{windowWidth:e=0}=this.state,s={expand:this.show,onClose:r=>this.handleCancel(r),title:this.props.adaptiveTitle,subTitle:this.props.adaptiveSubtitle,windowWidth:e,footer:{cancelText:this.localizationService.toLanguageString(i.dateRangePickerCancel,i.messages[i.dateRangePickerCancel]),onCancel:this.handleCancel,applyText:this.localizationService.toLanguageString(i.dateRangePickerSet,i.messages[i.dateRangePickerSet]),onApply:this.handleBlur}};return n.createElement(_.AdaptiveMode,{...s},n.createElement(A.ActionSheetContent,null,n.createElement("div",{className:"k-scrollable-wrap"},this.renderCalendar())))},this.handleReverseClick=e=>{const s={start:this.value.end,end:this.value.start},r={syntheticEvent:e,nativeEvent:e.nativeEvent};this.handleChange(s,r)},this.handleReverseMouseDown=e=>{e.preventDefault()},this.handleFocus=e=>{clearTimeout(this.nextTickId),this.shouldFocusDateInput||this.mobileMode&&this.setState({currentValue:this.value});const{onFocus:s}=this.props;s&&s.call(void 0,e)},this.handleClick=()=>{this.shouldFocusDateInput||this.setShow(!0)},this.handleBlur=e=>{this.nextTick(()=>{this.setShow(!1)});const{onBlur:s}=this.props;s&&s.call(void 0,e)},this.handleCancel=e=>{this.nextTick(()=>{this.setShow(!1),this.setState({currentValue:h.EMPTY_SELECTIONRANGE})});const{onCancel:s}=this.props;s&&s.call(void 0,e)},this.handleEndChange=e=>{const s={start:this.value.start,end:b.cloneDate(e.value||void 0)};this.handleChange(s,e)},this.handleStartChange=e=>{const s={start:b.cloneDate(e.value||void 0),end:this.value.end};this.handleChange(s,e)},this.extractRangeFromValue=e=>{if(!Array.isArray(e.value)&&!(e.value instanceof Date))return e.value||h.EMPTY_SELECTIONRANGE;const s=Array.isArray(e.value)?e.value[0]:e.value;return{start:this.value.end!==null?s:this.value.start,end:this.value.start!==null?s:this.value.end}},this.handleCalendarChange=e=>{const s=this.extractRangeFromValue(e);this.handleChange(s,e)},this.handleKeyDown=e=>{const{keyCode:s,altKey:r}=e;s===o.Keys.esc?(e.preventDefault(),this.shouldFocusDateInput=!0,this.setShow(!1)):r&&s===o.Keys.down?(e.preventDefault(),this.shouldFocusCalendar=!0,this.setShow(!0),this.focusCalendarElement()):r&&s===o.Keys.up&&(e.preventDefault(),this.shouldFocusDateInput=!0,this.setShow(!1))},this.handleChange=(e,s)=>{this.setState({value:e}),this.valueDuringOnChange=e;const{onChange:r}=this.props;if(r){const m={syntheticEvent:s.syntheticEvent,nativeEvent:s.nativeEvent,value:this.value,show:this.show,target:this};r.call(void 0,m)}this.valueDuringOnChange=void 0},this.showLicenseWatermark=!o.validatePackage(D.packageMetadata,{component:"DateRangePicker"}),this.licenseMessage=o.getLicenseMessage(D.packageMetadata),this.state={show:this.props.show||this.props.defaultShow||l.defaultProps.defaultShow,value:this.props.value||this.props.defaultValue||l.defaultProps.defaultValue,currentValue:h.EMPTY_SELECTIONRANGE},this.nextTick=this.nextTick.bind(this),this.setShow=this.setShow.bind(this),this.focusCalendarElement=this.focusCalendarElement.bind(this),this.focusDateInputElement=this.focusDateInputElement.bind(this)}get _popupId(){return this.props.id+"-popup-id"}get _startInputId(){return this.props.id+"-start-input-id"}get _endInputId(){return this.props.id+"-end-input-id"}get element(){return this._element}get startDateInput(){return this._startDateInput.current}get endDateInput(){return this._endDateInput.current}get calendar(){return this._calendar}get value(){return(this.valueDuringOnChange!==void 0?this.valueDuringOnChange:this.props.value!==void 0?this.props.value:this.state.value)||h.EMPTY_SELECTIONRANGE}get show(){return this.showDuringOnChange!==void 0?this.showDuringOnChange:this.props.show!==void 0?this.props.show:this.state.show}get min(){return this.props.min!==void 0?this.props.min:l.defaultProps.min}get max(){return this.props.max!==void 0?this.props.max:l.defaultProps.max}get document(){if(o.canUseDOM)return this.element&&this.element.ownerDocument||document}get localizationService(){return c.provideLocalizationService(this)}get mobileMode(){var e;return!!(this.state.windowWidth&&this.props._adaptiveMode&&this.state.windowWidth<=((e=this.props._adaptiveMode)==null?void 0:e.medium)&&this.props.adaptive)}componentDidMount(){var a;this.observerResize=o.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.show&&this.forceUpdate(),(a=this.document)!=null&&a.body&&this.observerResize&&this.observerResize.observe(this.document.body)}componentDidUpdate(){this.shouldFocusCalendar&&this.focusCalendarElement(),this.mobileMode&&this.show&&setTimeout(()=>{this.focusCalendarElement()},300),this.shouldFocusDateInput&&this.focusDateInputElement(),this.shouldFocusCalendar=!1,this.shouldFocusDateInput=!1}componentWillUnmount(){var a;clearTimeout(this.nextTickId),(a=this.document)!=null&&a.body&&this.observerResize&&this.observerResize.disconnect()}render(){const{autoFocus:a}=this.props,e=this.value||h.EMPTY_SELECTIONRANGE,s=this.mobileMode&&this.show?this.state.currentValue:e,r=(this.props.startDateInputSettings||{}).id||this._startInputId,m=(this.props.endDateInputSettings||{}).id||this._endInputId,S=o.classNames("k-daterangepicker",{"k-disabled":this.props.disabled},this.props.className),C=this.localizationService.toLanguageString(i.start,i.messages[i.start]),E=this.localizationService.toLanguageString(i.end,i.messages[i.end]),y=this.localizationService.toLanguageString(i.separator,i.messages[i.separator]),f={disableSelection:this.mobileMode&&!0,label:C,ariaHasPopup:"grid",format:this.props.format,min:this.min,max:this.max,id:this._startInputId,disabled:this.props.disabled,valid:this.props.valid,tabIndex:this.props.tabIndex,ariaExpanded:this.show,clearButton:this.props.clearButton,...this.props.startDateInputSettings,value:s.start,onChange:this.handleStartChange,inputAttributes:this.props.inputAttributes},v={disableSelection:this.mobileMode&&!0,label:E,ariaHasPopup:"grid",format:this.props.format,min:this.min,max:this.max,id:this._endInputId,disabled:this.props.disabled,valid:this.props.valid,tabIndex:this.props.tabIndex,ariaExpanded:this.show,clearButton:this.props.clearButton,...this.props.endDateInputSettings,value:s.end,onChange:this.handleEndChange,inputAttributes:this.props.inputAttributes},k=n.createElement(x.Button,{type:"button",className:"k-select",fillMode:"flat",title:c.provideLocalizationService(this).toLanguageString(i.swapStartEnd,i.messages[i.swapStartEnd]),onMouseDown:this.handleReverseMouseDown,onClick:this.handleReverseClick,"aria-controls":r+" "+m,"aria-label":c.provideLocalizationService(this).toLanguageString(i.swapStartEnd,i.messages[i.swapStartEnd])},n.createElement(o.IconWrap,{style:{transform:"rotate(90deg)"},name:"arrows-swap",icon:T.arrowsSwapIcon}));return n.createElement(n.Fragment,null,n.createElement("span",{ref:R=>{this._element=R},className:S,style:this.props.style,id:this.props.id,"aria-labelledby":this.props.ariaLabelledBy,"aria-describedby":this.props.ariaDescribedBy,tabIndex:this.props.tabIndex,onFocus:this.mobileMode?this.handleClick:this.handleFocus,onClick:this.handleClick,onKeyDown:this.handleKeyDown,onBlur:this.mobileMode?void 0:this.handleBlur,dir:this.props.dir},this.props.startDateInput?n.createElement(this.props.startDateInput,{...f}):n.createElement(g.DateInput,{...f,autoFocus:a,ref:this._startDateInput,ariaRole:"combobox",ariaControls:this.show?this._popupId:void 0}),(this.props.allowReverse||this.props.calendarSettings&&this.props.calendarSettings.allowReverse)&&this.props.swapButton?k:y,this.props.endDateInput?n.createElement(this.props.endDateInput,{...v}):n.createElement(g.DateInput,{...v,ref:this._endDateInput,ariaRole:"combobox",ariaControls:this.show?this._popupId:void 0}),!this.mobileMode&&this.renderPopup()),this.mobileMode&&this.renderAdaptivePopup(),this.showLicenseWatermark&&n.createElement(o.WatermarkOverlay,{message:this.licenseMessage}))}focusDateInputElement(){if(!document||!this.startDateInput||!this.startDateInput.element||!this.endDateInput||!this.endDateInput.element)return;const a=o.getActiveElement(document);(this.value.start===null||this.value.end!==null)&&a!==this.endDateInput.element?this.startDateInput.element.focus({preventScroll:!0}):a!==this.startDateInput.element&&this.endDateInput.element.focus({preventScroll:!0})}nextTick(a){clearTimeout(this.nextTickId),this.nextTickId=window.setTimeout(()=>a())}setShow(a){const{onOpen:e,onClose:s}=this.props;this.show!==a&&(this.setState({show:a}),a&&e&&e.call(void 0,{target:this}),!a&&s&&s.call(void 0,{target:this}))}calculateMedia(a){for(const e of a)this.setState({windowWidth:e.target.clientWidth})}};l.displayName="DateRangePicker",l.propTypes={allowReverse:t.bool,calendarSettings:t.any,className:t.string,defaultShow:t.bool,defaultValue:t.shape({start:u.nullable(t.instanceOf(Date).isRequired),end:u.nullable(t.instanceOf(Date).isRequired)}),disabled:t.bool,endDateInputSettings:t.shape(g.DateInput.propTypes),focusedDate:t.instanceOf(Date),format:t.oneOfType([t.string,t.shape({skeleton:t.string,pattern:t.string,date:t.oneOf(["short","medium","long","full"]),time:t.oneOf(["short","medium","long","full"]),datetime:t.oneOf(["short","medium","long","full"]),era:t.oneOf(["narrow","short","long"]),year:t.oneOf(["numeric","2-digit"]),month:t.oneOf(["numeric","2-digit","narrow","short","long"]),day:t.oneOf(["numeric","2-digit"]),weekday:t.oneOf(["narrow","short","long"]),hour:t.oneOf(["numeric","2-digit"]),hour12:t.bool,minute:t.oneOf(["numeric","2-digit"]),second:t.oneOf(["numeric","2-digit"]),timeZoneName:t.oneOf(["short","long"])})]),id:t.string,ariaLabelledBy:t.string,ariaDescribedBy:t.string,max:t.instanceOf(Date),min:t.instanceOf(Date),onBlur:t.func,onChange:t.func,onFocus:t.func,popupSettings:t.any,show:t.bool,startDateInputSettings:t.any,style:t.any,swapButton:t.any,tabIndex:t.number,dir:t.string,value:t.shape({start:u.nullable(t.instanceOf(Date)),end:u.nullable(t.instanceOf(Date))}),autoFocus:t.bool,inputAttributes:t.object},l.defaultProps={allowReverse:!1,defaultShow:!1,defaultValue:h.EMPTY_SELECTIONRANGE,disabled:!1,format:"d",max:u.MAX_DATE,min:u.MIN_DATE,swapButton:!1,autoFocus:!1};let p=l;const w=o.createPropsContext(),I=o.withIdHOC(o.withPropsContext(w,o.withAdaptiveModeContext(p)));I.displayName="KendoReactDateRangePicker";c.registerForLocalization(p);exports.DateRangePicker=I;exports.DateRangePickerPropsContext=w;exports.DateRangePickerWithoutContext=p;
|