@progress/kendo-react-dateinputs 7.4.0-develop.8 → 7.4.0
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 +122 -102
- package/dist/cdn/js/kendo-react-dateinputs.js +1 -1
- package/hooks/usePickerFloatingLabel.js +1 -1
- package/hooks/usePickerFloatingLabel.mjs +12 -12
- package/index.d.mts +1 -1
- package/index.d.ts +1 -1
- package/package-metadata.mjs +1 -1
- package/package.json +7 -7
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 client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const K=require("react"),e=require("prop-types"),_=require("@progress/kendo-react-popup"),k=require("@progress/kendo-date-math"),a=require("@progress/kendo-react-common"),W=require("@progress/kendo-svg-icons"),U=require("../package-metadata.js"),j=require("../dateinput/DateInput.js"),$=require("../calendar/components/Calendar.js"),c=require("../utils.js"),C=require("../messages/index.js"),P=require("@progress/kendo-react-intl"),H=require("./ToggleButton.js"),X=require("../common/PickerWrap.js"),Z=require("../hooks/usePickerFloatingLabel.js"),G=require("@progress/kendo-react-layout"),J=require("../common/AdaptiveMode.js"),Q=require("../common/constants.js");function Y(l){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const t in l)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(l,t);Object.defineProperty(s,t,i.get?i:{enumerable:!0,get:()=>l[t]})}}return s.default=l,Object.freeze(s)}const r=Y(K),o=class o extends r.Component{constructor(s){super(s),this._element=null,this._dateInput=r.createRef(),this._calendar=null,this.shouldFocusDateInput=!1,this.prevShow=!1,this.focus=()=>{this.dateInput&&this.dateInput.focus()},this.setCalendarRef=t=>{this._calendar=t},this.nextValue=(t,i)=>t.value!==void 0?t.value:i.value,this.nextShow=(t,i)=>t.show!==void 0?t.show:i.show,this.renderPopup=()=>{const{disabled:t,min:i,max:n,weekNumber:m,focusedDate:g}=this.props,{popupClass:u,...f}=this.props.popupSettings,v=this.show,h=this.value,w=h&&k.getDate(h),b=a.classNames("k-calendar-container k-group k-reset",u),y={popupClass:"k-datepicker-popup",show:v,anchor:this._element,className:b,id:this._popupId,anchorAlign:{horizontal:"left",vertical:"bottom"},popupAlign:{horizontal:"left",vertical:"top"},...f},p={disabled:t,value:w,min:i,max:n,weekNumber:m,focusedDate:g,className:this.mobileMode?"k-calendar-lg":"",navigation:!this.mobileMode,onChange:this.handleCalendarValueChange};return this.mobileMode?r.createElement(this.calendarComp,{_ref:this.setCalendarRef,...p}):r.createElement(this.popupComp,{...y},r.createElement(this.calendarComp,{_ref:this.setCalendarRef,...p}))},this.renderAdaptivePopup=()=>{const{windowWidth:t=0}=this.state,i={expand:this.show,onClose:this.handleBlur,adaptiveTitle:this.props.adaptiveTitle,windowWidth:t};return r.createElement(J.AdaptiveMode,{...i},r.createElement(G.ActionSheetContent,{className:"!k-overflow-hidden"},this.renderPopup()))},this.handleInputValueChange=t=>{this.handleValueChange(t.value,t)},this.handleCalendarValueChange=t=>{const i=this.mergeTime(t.value);this.handleValueChange(i,t)},this.handleValueChange=(t,i)=>{this.setState({value:k.cloneDate(t||void 0)}),this.valueDuringOnChange=t,this.showDuringOnChange=!1,this.mobileMode||(this.shouldFocusDateInput=!0);const{onChange:n}=this.props;n&&n.call(void 0,{syntheticEvent:i.syntheticEvent,nativeEvent:i.nativeEvent,value:this.value,show:this.show,target:this}),this.valueDuringOnChange=void 0,this.showDuringOnChange=void 0,this.setShow(!1)},this.handleFocus=()=>{this.setState({focused:!0})},this.handleBlur=()=>{this.setState({focused:!1}),this.setShow(!1)},this.handleIconClick=()=>{this.props.disabled||(this.shouldFocusDateInput=!0,this.setShow(!this.show))},this.handleIconMouseDown=t=>{t.preventDefault()},this.handleKeyDown=t=>{const{altKey:i,keyCode:n}=t;if(n===a.Keys.esc){this.shouldFocusDateInput=!0,this.setShow(!1);return}i&&(n===a.Keys.up||n===a.Keys.down)&&(t.preventDefault(),t.stopPropagation(),this.shouldFocusDateInput=n===a.Keys.up,this.setShow(n===a.Keys.down))},a.validatePackage(U.packageMetadata),this.state={value:this.props.defaultValue||o.defaultProps.defaultValue,show:this.props.defaultShow||o.defaultProps.defaultShow,focused:!1}}get _popupId(){return this.props.id+"-popup-id"}get document(){if(a.canUseDOM)return this.element&&this.element.ownerDocument||document}get element(){return this._element}get mobileMode(){return!!(this.state.windowWidth&&this.state.windowWidth<=Q.MOBILE_MEDIUM_DEVISE&&this.props.adaptive)}get dateInput(){return this._dateInput.current}get calendar(){return this._calendar}get value(){const s=this.valueDuringOnChange!==void 0?this.valueDuringOnChange:this.props.value!==void 0?this.props.value:this.state.value;return s!==null?k.cloneDate(s):null}get show(){return this.showDuringOnChange!==void 0?this.showDuringOnChange:this.props.show!==void 0?this.props.show:this.state.show}get name(){return this.props.name}get min(){return this.props.min!==void 0?this.props.min:o.defaultProps.min}get max(){return this.props.max!==void 0?this.props.max:o.defaultProps.max}get dateInputComp(){return this.props.dateInput||o.defaultProps.dateInput}get toggleButtonComp(){return this.props.toggleButton||o.defaultProps.toggleButton}get calendarComp(){return this.props.calendar||o.defaultProps.calendar}get popupComp(){return this.props.popup||o.defaultProps.popup}get pickerWrapComp(){return this.props.pickerWrap||o.defaultProps.pickerWrap}get validity(){const s=c.isInDateRange(this.value,this.min,this.max),t=this.props.validationMessage!==void 0,i=(!this.required||this.value!==null)&&s,n=this.props.valid!==void 0?this.props.valid:i;return{customError:t,rangeOverflow:this.value&&this.max.getTime()<this.value.getTime()||!1,rangeUnderflow:this.value&&this.value.getTime()<this.min.getTime()||!1,valid:n,valueMissing:this.value===null}}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:o.defaultProps.validityStyles}get required(){return this.props.required!==void 0?this.props.required:o.defaultProps.required}componentDidMount(){var s;this.observerResize=a.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.show&&this.forceUpdate(),(s=this.document)!=null&&s.body&&this.observerResize&&this.observerResize.observe(this.document.body)}componentDidUpdate(){this._calendar&&this._calendar.element&&this.show&&!this.prevShow&&this._calendar.element.focus({preventScroll:!0}),this.dateInput&&this.dateInput.element&&!this.show&&this.shouldFocusDateInput&&this.dateInput.element.focus({preventScroll:!0}),this.prevShow=this.show,this.shouldFocusDateInput=!1}componentWillUnmount(){var s;clearTimeout(this.nextTickId),(s=this.document)!=null&&s.body&&this.observerResize&&this.observerResize.disconnect()}render(){const{size:s=o.defaultProps.size,rounded:t=o.defaultProps.rounded,fillMode:i=o.defaultProps.fillMode,disabled:n,tabIndex:m,title:g,id:u,format:f,formatPlaceholder:v,min:h,max:w,className:b,width:y,name:p,validationMessage:T,required:q,validityStyles:x,ariaLabelledBy:E,ariaDescribedBy:R,ariaLabel:B}=this.props,z=this.show,N=this.value,D=!this.validityStyles||this.validity.valid,F={disabled:n,format:f,formatPlaceholder:v,id:u,ariaLabelledBy:E,ariaDescribedBy:R,ariaLabel:B,max:w,min:h,name:p,onChange:this.handleInputValueChange,required:q,tabIndex:z?-1:m,title:g,valid:this.validity.valid,validationMessage:T,validityStyles:x,value:N,label:void 0,placeholder:this.state.focused?null:this.props.placeholder,ariaExpanded:this.show,size:null,fillMode:null,rounded:null},I=P.provideLocalizationService(this).toLanguageString(C.toggleCalendar,C.messages[C.toggleCalendar]),O=r.createElement(a.AsyncFocusBlur,{onFocus:this.handleFocus,onBlur:this.mobileMode?void 0:this.handleBlur,onSyncBlur:this.props.onBlur,onSyncFocus:this.props.onFocus},({onFocus:V,onBlur:A})=>r.createElement(r.Fragment,null,r.createElement("span",{ref:L=>{this._element=L},className:a.classNames("k-input","k-datepicker",{[`k-input-${a.kendoThemeMaps.sizeMap[s]||s}`]:s,[`k-rounded-${a.kendoThemeMaps.roundedMap[t]||t}`]:t,[`k-input-${i}`]:i,"k-invalid":!D,"k-required":this.required,"k-disabled":this.props.disabled},b),onKeyDown:this.handleKeyDown,style:{width:y},onFocus:V,onBlur:A,onClick:this.mobileMode?this.handleIconClick:void 0},r.createElement(this.dateInputComp,{_ref:this._dateInput,ariaRole:"combobox",readonly:this.mobileMode,ariaExpanded:this.show,ariaControls:this._popupId,...F}),r.createElement(this.toggleButtonComp,{type:"button",icon:"calendar",svgIcon:W.calendarIcon,title:I,className:"k-input-button",rounded:null,onClick:this.mobileMode?void 0:this.handleIconClick,"aria-label":I,onMouseDown:this.handleIconMouseDown}),!this.mobileMode&&this.renderPopup()),this.mobileMode&&this.renderAdaptivePopup()));return this.props.label?r.createElement(Z.PickerFloatingLabel,{dateInput:this._dateInput,label:this.props.label,editorId:u,editorValid:D,editorDisabled:this.props.disabled,children:O,style:{width:this.props.width}}):O}setShow(s){const{onOpen:t,onClose:i}=this.props;this.show!==s&&(this.setState({show:s}),s&&t&&t.call(void 0,{target:this}),!s&&i&&i.call(void 0,{target:this}))}mergeTime(s){return this.value&&s?c.setTime(s,this.value):s}nextTick(s){clearTimeout(this.nextTickId),this.nextTickId=window.setTimeout(()=>s())}calculateMedia(s){for(let t of s)this.setState({windowWidth:t.target.clientWidth})}};o.displayName="DatePicker",o.propTypes={className:e.string,defaultShow:e.bool,defaultValue:e.instanceOf(Date),disabled:e.bool,focusedDate:e.instanceOf(Date),format:e.oneOfType([e.string,e.shape({skeleton:e.string,pattern:e.string,date:e.oneOf(["short","medium","long","full"]),time:e.oneOf(["short","medium","long","full"]),datetime:e.oneOf(["short","medium","long","full"]),era:e.oneOf(["narrow","short","long"]),year:e.oneOf(["numeric","2-digit"]),month:e.oneOf(["numeric","2-digit","narrow","short","long"]),day:e.oneOf(["numeric","2-digit"]),weekday:e.oneOf(["narrow","short","long"]),hour:e.oneOf(["numeric","2-digit"]),hour12:e.bool,minute:e.oneOf(["numeric","2-digit"]),second:e.oneOf(["numeric","2-digit"]),timeZoneName:e.oneOf(["short","long"])})]),formatPlaceholder:e.oneOfType([e.oneOf(["wide","narrow","short","formatPattern"]),e.shape({year:e.string,month:e.string,day:e.string,hour:e.string,minute:e.string,second:e.string})]),id:e.string,ariaLabelledBy:e.string,ariaDescribedBy:e.string,ariaLabel:e.string,min:e.instanceOf(Date),max:e.instanceOf(Date),name:e.string,popupSettings:e.shape({animate:e.bool,appendTo:e.any,popupClass:e.string}),show:e.bool,tabIndex:e.number,title:e.string,value:e.instanceOf(Date),weekNumber:e.bool,width:e.oneOfType([e.number,e.string]),validationMessage:e.string,required:e.bool,validate:e.bool,valid:e.bool,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},o.defaultProps={defaultShow:!1,defaultValue:null,dateInput:j.DateInput,calendar:$.Calendar,toggleButton:H.ToggleButton,popup:_.Popup,pickerWrap:X.PickerWrap,disabled:!1,format:"d",max:c.MAX_DATE,min:c.MIN_DATE,popupSettings:{},tabIndex:0,weekNumber:!1,required:!1,validityStyles:!0,size:"medium",rounded:"medium",fillMode:"solid"};let d=o;const M=a.createPropsContext(),S=a.withIdHOC(a.withPropsContext(M,d));S.displayName="KendoReactDatePicker";P.registerForLocalization(d);exports.DatePicker=S;exports.DatePickerPropsContext=M;exports.DatePickerWithoutContext=d;
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=require("react"),e=require("prop-types"),_=require("@progress/kendo-react-popup"),I=require("@progress/kendo-date-math"),n=require("@progress/kendo-react-common"),U=require("@progress/kendo-svg-icons"),j=require("../package-metadata.js"),$=require("../dateinput/DateInput.js"),H=require("../calendar/components/Calendar.js"),m=require("../utils.js"),D=require("../messages/index.js"),q=require("@progress/kendo-react-intl"),X=require("./ToggleButton.js"),Z=require("../common/PickerWrap.js"),G=require("../hooks/usePickerFloatingLabel.js"),J=require("@progress/kendo-react-layout"),Q=require("../common/AdaptiveMode.js"),Y=require("../common/constants.js");function ee(l){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const t in l)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(l,t);Object.defineProperty(s,t,i.get?i:{enumerable:!0,get:()=>l[t]})}}return s.default=l,Object.freeze(s)}const r=ee(W),o=class o extends r.Component{constructor(s){super(s),this._element=null,this._dateInput=r.createRef(),this._calendar=null,this.shouldFocusDateInput=!1,this.prevShow=!1,this.focus=()=>{this.dateInput&&this.dateInput.focus()},this.setCalendarRef=t=>{this._calendar=t},this.nextValue=(t,i)=>t.value!==void 0?t.value:i.value,this.nextShow=(t,i)=>t.show!==void 0?t.show:i.show,this.renderPopup=()=>{const{disabled:t,min:i,max:a,weekNumber:g,focusedDate:f,popupSettings:d}=this.props,{popupClass:v,...w}=d,b=this.show,h=this.value,y=h&&I.getDate(h),p=n.classNames("k-calendar-container k-group k-reset",v),k={popupClass:"k-datepicker-popup",show:b,anchor:this._element,className:p,id:this._popupId,anchorAlign:{horizontal:"left",vertical:"bottom"},popupAlign:{horizontal:"left",vertical:"top"},...w},c={disabled:t,value:y,min:i,max:a,weekNumber:g,focusedDate:f,className:this.mobileMode?"k-calendar-lg":"",navigation:!this.mobileMode,onChange:this.handleCalendarValueChange};return this.mobileMode?r.createElement(this.calendarComp,{_ref:this.setCalendarRef,...c}):r.createElement(this.popupComp,{...k},r.createElement(this.calendarComp,{_ref:this.setCalendarRef,...c}))},this.renderAdaptivePopup=()=>{const{windowWidth:t=0}=this.state,i={expand:this.show,onClose:this.handleBlur,adaptiveTitle:this.props.adaptiveTitle,windowWidth:t};return r.createElement(Q.AdaptiveMode,{...i},r.createElement(J.ActionSheetContent,{className:"!k-overflow-hidden"},this.renderPopup()))},this.handleInputValueChange=t=>{this.handleValueChange(t.value,t)},this.handleCalendarValueChange=t=>{const i=this.mergeTime(t.value);this.handleValueChange(i,t)},this.handleValueChange=(t,i)=>{this.setState({value:I.cloneDate(t||void 0)}),this.valueDuringOnChange=t,this.showDuringOnChange=!1,this.mobileMode||(this.shouldFocusDateInput=!0);const{onChange:a}=this.props;a&&a.call(void 0,{syntheticEvent:i.syntheticEvent,nativeEvent:i.nativeEvent,value:this.value,show:this.show,target:this}),this.valueDuringOnChange=void 0,this.showDuringOnChange=void 0,this.setShow(!1)},this.handleFocus=()=>{this.setState({focused:!0})},this.handleBlur=()=>{this.setState({focused:!1}),this.setShow(!1)},this.handleIconClick=()=>{this.props.disabled||(this.shouldFocusDateInput=!0,this.setShow(!this.show))},this.handleIconMouseDown=t=>{t.preventDefault()},this.handleKeyDown=t=>{const{altKey:i,keyCode:a}=t;if(a===n.Keys.esc){this.shouldFocusDateInput=!0,this.setShow(!1);return}i&&(a===n.Keys.up||a===n.Keys.down)&&(t.preventDefault(),t.stopPropagation(),this.shouldFocusDateInput=a===n.Keys.up,this.setShow(a===n.Keys.down))},n.validatePackage(j.packageMetadata),this.state={value:this.props.defaultValue||o.defaultProps.defaultValue,show:this.props.defaultShow||o.defaultProps.defaultShow,focused:!1}}get _popupId(){return this.props.id+"-popup-id"}get document(){if(n.canUseDOM)return this.element&&this.element.ownerDocument||document}get element(){return this._element}get mobileMode(){return!!(this.state.windowWidth&&this.state.windowWidth<=Y.MOBILE_MEDIUM_DEVISE&&this.props.adaptive)}get dateInput(){return this._dateInput.current}get calendar(){return this._calendar}get value(){const s=this.valueDuringOnChange!==void 0?this.valueDuringOnChange:this.props.value!==void 0?this.props.value:this.state.value;return s!==null?I.cloneDate(s):null}get show(){return this.showDuringOnChange!==void 0?this.showDuringOnChange:this.props.show!==void 0?this.props.show:this.state.show}get name(){return this.props.name}get min(){return this.props.min!==void 0?this.props.min:o.defaultProps.min}get max(){return this.props.max!==void 0?this.props.max:o.defaultProps.max}get dateInputComp(){return this.props.dateInput||o.defaultProps.dateInput}get toggleButtonComp(){return this.props.toggleButton||o.defaultProps.toggleButton}get calendarComp(){return this.props.calendar||o.defaultProps.calendar}get popupComp(){return this.props.popup||o.defaultProps.popup}get pickerWrapComp(){return this.props.pickerWrap||o.defaultProps.pickerWrap}get validity(){const s=m.isInDateRange(this.value,this.min,this.max),t=this.props.validationMessage!==void 0,i=(!this.required||this.value!==null)&&s,a=this.props.valid!==void 0?this.props.valid:i;return{customError:t,rangeOverflow:this.value&&this.max.getTime()<this.value.getTime()||!1,rangeUnderflow:this.value&&this.value.getTime()<this.min.getTime()||!1,valid:a,valueMissing:this.value===null}}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:o.defaultProps.validityStyles}get required(){return this.props.required!==void 0?this.props.required:o.defaultProps.required}componentDidMount(){var s;this.observerResize=n.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.show&&this.forceUpdate(),(s=this.document)!=null&&s.body&&this.observerResize&&this.observerResize.observe(this.document.body)}componentDidUpdate(){this._calendar&&this._calendar.element&&this.show&&!this.prevShow&&this._calendar.element.focus({preventScroll:!0}),this.dateInput&&this.dateInput.element&&!this.show&&this.shouldFocusDateInput&&this.dateInput.element.focus({preventScroll:!0}),this.prevShow=this.show,this.shouldFocusDateInput=!1}componentWillUnmount(){var s;clearTimeout(this.nextTickId),(s=this.document)!=null&&s.body&&this.observerResize&&this.observerResize.disconnect()}render(){const{size:s=o.defaultProps.size,rounded:t=o.defaultProps.rounded,fillMode:i=o.defaultProps.fillMode,disabled:a,tabIndex:g,title:f,id:d,format:v,formatPlaceholder:w,min:b,max:h,className:y,width:p,name:k,validationMessage:c,required:E,validityStyles:R,ariaLabelledBy:z,ariaDescribedBy:F,ariaLabel:N,placeholder:V,label:C,popupSettings:te,defaultValue:se,defaultShow:ie,value:oe,popup:ae,weekNumber:ne,dateInput:re,calendar:le,toggleButton:ue,onChange:de,onBlur:he,onFocus:pe,show:ce,onOpen:me,pickerWrap:ge,...O}=this.props,A=this.value,S=!this.validityStyles||this.validity.valid,L={disabled:a,format:v,formatPlaceholder:w,id:d,ariaLabelledBy:z,ariaDescribedBy:F,ariaLabel:N,max:h,min:b,name:k,onChange:this.handleInputValueChange,required:E,tabIndex:this.show?-1:g,title:f,valid:this.validity.valid,validationMessage:c,validityStyles:R,value:A,label:void 0,placeholder:this.state.focused?null:V,ariaExpanded:this.show,size:null,fillMode:null,rounded:null},M=q.provideLocalizationService(this).toLanguageString(D.toggleCalendar,D.messages[D.toggleCalendar]),P=r.createElement(n.AsyncFocusBlur,{onFocus:this.handleFocus,onBlur:this.mobileMode?void 0:this.handleBlur,onSyncBlur:this.props.onBlur,onSyncFocus:this.props.onFocus},T=>r.createElement(r.Fragment,null,r.createElement("span",{...C?{}:O,ref:K=>{this._element=K},className:n.classNames("k-input","k-datepicker",{[`k-input-${n.kendoThemeMaps.sizeMap[s]||s}`]:s,[`k-rounded-${n.kendoThemeMaps.roundedMap[t]||t}`]:t,[`k-input-${i}`]:i,"k-invalid":!S,"k-required":this.required,"k-disabled":a},y),onKeyDown:this.handleKeyDown,style:{width:p},onFocus:T.onFocus,onBlur:T.onBlur,onClick:this.mobileMode?this.handleIconClick:void 0},r.createElement(this.dateInputComp,{_ref:this._dateInput,ariaRole:"combobox",readonly:this.mobileMode,ariaExpanded:this.show,ariaControls:this._popupId,...L}),r.createElement(this.toggleButtonComp,{type:"button",icon:"calendar",svgIcon:U.calendarIcon,title:M,className:"k-input-button",rounded:null,onClick:this.mobileMode?void 0:this.handleIconClick,"aria-label":M,onMouseDown:this.handleIconMouseDown}),!this.mobileMode&&this.renderPopup()),this.mobileMode&&this.renderAdaptivePopup()));return C?r.createElement(G.PickerFloatingLabel,{dateInput:this._dateInput,label:C,editorId:d,editorValid:S,editorDisabled:a,children:P,style:{width:p},...O}):P}setShow(s){const{onOpen:t,onClose:i}=this.props;this.show!==s&&(this.setState({show:s}),s&&t&&t.call(void 0,{target:this}),!s&&i&&i.call(void 0,{target:this}))}mergeTime(s){return this.value&&s?m.setTime(s,this.value):s}nextTick(s){clearTimeout(this.nextTickId),this.nextTickId=window.setTimeout(()=>s())}calculateMedia(s){for(let t of s)this.setState({windowWidth:t.target.clientWidth})}};o.displayName="DatePicker",o.propTypes={className:e.string,defaultShow:e.bool,defaultValue:e.instanceOf(Date),disabled:e.bool,focusedDate:e.instanceOf(Date),format:e.oneOfType([e.string,e.shape({skeleton:e.string,pattern:e.string,date:e.oneOf(["short","medium","long","full"]),time:e.oneOf(["short","medium","long","full"]),datetime:e.oneOf(["short","medium","long","full"]),era:e.oneOf(["narrow","short","long"]),year:e.oneOf(["numeric","2-digit"]),month:e.oneOf(["numeric","2-digit","narrow","short","long"]),day:e.oneOf(["numeric","2-digit"]),weekday:e.oneOf(["narrow","short","long"]),hour:e.oneOf(["numeric","2-digit"]),hour12:e.bool,minute:e.oneOf(["numeric","2-digit"]),second:e.oneOf(["numeric","2-digit"]),timeZoneName:e.oneOf(["short","long"])})]),formatPlaceholder:e.oneOfType([e.oneOf(["wide","narrow","short","formatPattern"]),e.shape({year:e.string,month:e.string,day:e.string,hour:e.string,minute:e.string,second:e.string})]),id:e.string,ariaLabelledBy:e.string,ariaDescribedBy:e.string,ariaLabel:e.string,min:e.instanceOf(Date),max:e.instanceOf(Date),name:e.string,popupSettings:e.shape({animate:e.bool,appendTo:e.any,popupClass:e.string}),show:e.bool,tabIndex:e.number,title:e.string,value:e.instanceOf(Date),weekNumber:e.bool,width:e.oneOfType([e.number,e.string]),validationMessage:e.string,required:e.bool,validate:e.bool,valid:e.bool,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},o.defaultProps={defaultShow:!1,defaultValue:null,dateInput:$.DateInput,calendar:H.Calendar,toggleButton:X.ToggleButton,popup:_.Popup,pickerWrap:Z.PickerWrap,disabled:!1,format:"d",max:m.MAX_DATE,min:m.MIN_DATE,popupSettings:{},tabIndex:0,weekNumber:!1,required:!1,validityStyles:!0,size:"medium",rounded:"medium",fillMode:"solid"};let u=o;const x=n.createPropsContext(),B=n.withIdHOC(n.withPropsContext(x,u));B.displayName="KendoReactDatePicker";q.registerForLocalization(u);exports.DatePicker=B;exports.DatePickerPropsContext=x;exports.DatePickerWithoutContext=u;
|
|
@@ -8,22 +8,22 @@
|
|
|
8
8
|
"use client";
|
|
9
9
|
import * as n from "react";
|
|
10
10
|
import e from "prop-types";
|
|
11
|
-
import { Popup as
|
|
12
|
-
import { getDate as
|
|
13
|
-
import { classNames as
|
|
14
|
-
import { calendarIcon as
|
|
15
|
-
import { packageMetadata as
|
|
16
|
-
import { DateInput as
|
|
17
|
-
import { Calendar as
|
|
18
|
-
import { MAX_DATE as
|
|
19
|
-
import { toggleCalendar as
|
|
20
|
-
import { provideLocalizationService as
|
|
21
|
-
import { ToggleButton as
|
|
22
|
-
import { PickerWrap as
|
|
23
|
-
import { PickerFloatingLabel as
|
|
24
|
-
import { ActionSheetContent as
|
|
25
|
-
import { AdaptiveMode as
|
|
26
|
-
import { MOBILE_MEDIUM_DEVISE as
|
|
11
|
+
import { Popup as L } from "@progress/kendo-react-popup";
|
|
12
|
+
import { getDate as W, cloneDate as O } from "@progress/kendo-date-math";
|
|
13
|
+
import { classNames as M, Keys as r, validatePackage as _, canUseDOM as P, AsyncFocusBlur as K, kendoThemeMaps as T, createPropsContext as U, withIdHOC as $, withPropsContext as H } from "@progress/kendo-react-common";
|
|
14
|
+
import { calendarIcon as X } from "@progress/kendo-svg-icons";
|
|
15
|
+
import { packageMetadata as Z } from "../package-metadata.mjs";
|
|
16
|
+
import { DateInput as j } from "../dateinput/DateInput.mjs";
|
|
17
|
+
import { Calendar as G } from "../calendar/components/Calendar.mjs";
|
|
18
|
+
import { MAX_DATE as J, MIN_DATE as Q, isInDateRange as Y, setTime as ee } from "../utils.mjs";
|
|
19
|
+
import { toggleCalendar as E, messages as te } from "../messages/index.mjs";
|
|
20
|
+
import { provideLocalizationService as ie, registerForLocalization as se } from "@progress/kendo-react-intl";
|
|
21
|
+
import { ToggleButton as oe } from "./ToggleButton.mjs";
|
|
22
|
+
import { PickerWrap as ae } from "../common/PickerWrap.mjs";
|
|
23
|
+
import { PickerFloatingLabel as ne } from "../hooks/usePickerFloatingLabel.mjs";
|
|
24
|
+
import { ActionSheetContent as re } from "@progress/kendo-react-layout";
|
|
25
|
+
import { AdaptiveMode as le } from "../common/AdaptiveMode.mjs";
|
|
26
|
+
import { MOBILE_MEDIUM_DEVISE as de } from "../common/constants.mjs";
|
|
27
27
|
const o = class o extends n.Component {
|
|
28
28
|
constructor(i) {
|
|
29
29
|
super(i), this._element = null, this._dateInput = n.createRef(), this._calendar = null, this.shouldFocusDateInput = !1, this.prevShow = !1, this.focus = () => {
|
|
@@ -31,14 +31,14 @@ const o = class o extends n.Component {
|
|
|
31
31
|
}, this.setCalendarRef = (t) => {
|
|
32
32
|
this._calendar = t;
|
|
33
33
|
}, this.nextValue = (t, s) => t.value !== void 0 ? t.value : s.value, this.nextShow = (t, s) => t.show !== void 0 ? t.show : s.show, this.renderPopup = () => {
|
|
34
|
-
const { disabled: t, min: s, max: a, weekNumber:
|
|
34
|
+
const { disabled: t, min: s, max: a, weekNumber: c, focusedDate: m, popupSettings: l } = this.props, { popupClass: f, ...g } = l, v = this.show, d = this.value, w = d && W(d), u = M(
|
|
35
35
|
"k-calendar-container k-group k-reset",
|
|
36
|
-
|
|
37
|
-
),
|
|
36
|
+
f
|
|
37
|
+
), b = {
|
|
38
38
|
popupClass: "k-datepicker-popup",
|
|
39
|
-
show:
|
|
39
|
+
show: v,
|
|
40
40
|
anchor: this._element,
|
|
41
|
-
className:
|
|
41
|
+
className: u,
|
|
42
42
|
id: this._popupId,
|
|
43
43
|
anchorAlign: {
|
|
44
44
|
horizontal: "left",
|
|
@@ -48,19 +48,19 @@ const o = class o extends n.Component {
|
|
|
48
48
|
horizontal: "left",
|
|
49
49
|
vertical: "top"
|
|
50
50
|
},
|
|
51
|
-
...
|
|
51
|
+
...g
|
|
52
52
|
}, h = {
|
|
53
53
|
disabled: t,
|
|
54
|
-
value:
|
|
54
|
+
value: w,
|
|
55
55
|
min: s,
|
|
56
56
|
max: a,
|
|
57
|
-
weekNumber:
|
|
58
|
-
focusedDate:
|
|
57
|
+
weekNumber: c,
|
|
58
|
+
focusedDate: m,
|
|
59
59
|
className: this.mobileMode ? "k-calendar-lg" : "",
|
|
60
60
|
navigation: !this.mobileMode,
|
|
61
61
|
onChange: this.handleCalendarValueChange
|
|
62
62
|
};
|
|
63
|
-
return this.mobileMode ? /* @__PURE__ */ n.createElement(this.calendarComp, { _ref: this.setCalendarRef, ...h }) : /* @__PURE__ */ n.createElement(this.popupComp, { ...
|
|
63
|
+
return this.mobileMode ? /* @__PURE__ */ n.createElement(this.calendarComp, { _ref: this.setCalendarRef, ...h }) : /* @__PURE__ */ n.createElement(this.popupComp, { ...b }, /* @__PURE__ */ n.createElement(this.calendarComp, { _ref: this.setCalendarRef, ...h }));
|
|
64
64
|
}, this.renderAdaptivePopup = () => {
|
|
65
65
|
const { windowWidth: t = 0 } = this.state, s = {
|
|
66
66
|
expand: this.show,
|
|
@@ -68,7 +68,7 @@ const o = class o extends n.Component {
|
|
|
68
68
|
adaptiveTitle: this.props.adaptiveTitle,
|
|
69
69
|
windowWidth: t
|
|
70
70
|
};
|
|
71
|
-
return /* @__PURE__ */ n.createElement(
|
|
71
|
+
return /* @__PURE__ */ n.createElement(le, { ...s }, /* @__PURE__ */ n.createElement(re, { className: "!k-overflow-hidden" }, this.renderPopup()));
|
|
72
72
|
}, this.handleInputValueChange = (t) => {
|
|
73
73
|
this.handleValueChange(t.value, t);
|
|
74
74
|
}, this.handleCalendarValueChange = (t) => {
|
|
@@ -76,7 +76,7 @@ const o = class o extends n.Component {
|
|
|
76
76
|
this.handleValueChange(s, t);
|
|
77
77
|
}, this.handleValueChange = (t, s) => {
|
|
78
78
|
this.setState({
|
|
79
|
-
value:
|
|
79
|
+
value: O(t || void 0)
|
|
80
80
|
}), this.valueDuringOnChange = t, this.showDuringOnChange = !1, this.mobileMode || (this.shouldFocusDateInput = !0);
|
|
81
81
|
const { onChange: a } = this.props;
|
|
82
82
|
a && a.call(void 0, {
|
|
@@ -101,7 +101,7 @@ const o = class o extends n.Component {
|
|
|
101
101
|
return;
|
|
102
102
|
}
|
|
103
103
|
s && (a === r.up || a === r.down) && (t.preventDefault(), t.stopPropagation(), this.shouldFocusDateInput = a === r.up, this.setShow(a === r.down));
|
|
104
|
-
},
|
|
104
|
+
}, _(Z), this.state = {
|
|
105
105
|
value: this.props.defaultValue || o.defaultProps.defaultValue,
|
|
106
106
|
show: this.props.defaultShow || o.defaultProps.defaultShow,
|
|
107
107
|
focused: !1
|
|
@@ -111,7 +111,7 @@ const o = class o extends n.Component {
|
|
|
111
111
|
return this.props.id + "-popup-id";
|
|
112
112
|
}
|
|
113
113
|
get document() {
|
|
114
|
-
if (
|
|
114
|
+
if (P)
|
|
115
115
|
return this.element && this.element.ownerDocument || document;
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
@@ -124,7 +124,7 @@ const o = class o extends n.Component {
|
|
|
124
124
|
* The mobile mode of the DatePicker.
|
|
125
125
|
*/
|
|
126
126
|
get mobileMode() {
|
|
127
|
-
return !!(this.state.windowWidth && this.state.windowWidth <=
|
|
127
|
+
return !!(this.state.windowWidth && this.state.windowWidth <= de && this.props.adaptive);
|
|
128
128
|
}
|
|
129
129
|
/**
|
|
130
130
|
* Gets the DateInput component inside the DatePicker component.
|
|
@@ -143,7 +143,7 @@ const o = class o extends n.Component {
|
|
|
143
143
|
*/
|
|
144
144
|
get value() {
|
|
145
145
|
const i = this.valueDuringOnChange !== void 0 ? this.valueDuringOnChange : this.props.value !== void 0 ? this.props.value : this.state.value;
|
|
146
|
-
return i !== null ?
|
|
146
|
+
return i !== null ? O(i) : null;
|
|
147
147
|
}
|
|
148
148
|
/**
|
|
149
149
|
* Gets the popup state of the DatePickerWithoutContext.
|
|
@@ -182,7 +182,7 @@ const o = class o extends n.Component {
|
|
|
182
182
|
* Represents the validity state into which the DatePicker is set.
|
|
183
183
|
*/
|
|
184
184
|
get validity() {
|
|
185
|
-
const i =
|
|
185
|
+
const i = Y(this.value, this.min, this.max), t = this.props.validationMessage !== void 0, s = (!this.required || this.value !== null) && i, a = this.props.valid !== void 0 ? this.props.valid : s;
|
|
186
186
|
return {
|
|
187
187
|
customError: t,
|
|
188
188
|
rangeOverflow: this.value && this.max.getTime() < this.value.getTime() || !1,
|
|
@@ -208,7 +208,7 @@ const o = class o extends n.Component {
|
|
|
208
208
|
*/
|
|
209
209
|
componentDidMount() {
|
|
210
210
|
var i;
|
|
211
|
-
this.observerResize =
|
|
211
|
+
this.observerResize = P && window.ResizeObserver && new window.ResizeObserver(this.calculateMedia.bind(this)), this.show && this.forceUpdate(), (i = this.document) != null && i.body && this.observerResize && this.observerResize.observe(this.document.body);
|
|
212
212
|
}
|
|
213
213
|
/**
|
|
214
214
|
* @hidden
|
|
@@ -232,78 +232,97 @@ const o = class o extends n.Component {
|
|
|
232
232
|
rounded: t = o.defaultProps.rounded,
|
|
233
233
|
fillMode: s = o.defaultProps.fillMode,
|
|
234
234
|
disabled: a,
|
|
235
|
-
tabIndex:
|
|
236
|
-
title:
|
|
235
|
+
tabIndex: c,
|
|
236
|
+
title: m,
|
|
237
237
|
id: l,
|
|
238
|
-
format:
|
|
239
|
-
formatPlaceholder:
|
|
240
|
-
min:
|
|
241
|
-
max:
|
|
242
|
-
className:
|
|
243
|
-
width:
|
|
244
|
-
name:
|
|
245
|
-
validationMessage:
|
|
246
|
-
required:
|
|
247
|
-
validityStyles:
|
|
248
|
-
ariaLabelledBy:
|
|
249
|
-
ariaDescribedBy:
|
|
250
|
-
ariaLabel:
|
|
251
|
-
|
|
238
|
+
format: f,
|
|
239
|
+
formatPlaceholder: g,
|
|
240
|
+
min: v,
|
|
241
|
+
max: d,
|
|
242
|
+
className: w,
|
|
243
|
+
width: u,
|
|
244
|
+
name: b,
|
|
245
|
+
validationMessage: h,
|
|
246
|
+
required: x,
|
|
247
|
+
validityStyles: B,
|
|
248
|
+
ariaLabelledBy: V,
|
|
249
|
+
ariaDescribedBy: z,
|
|
250
|
+
ariaLabel: F,
|
|
251
|
+
placeholder: N,
|
|
252
|
+
label: y,
|
|
253
|
+
popupSettings: pe,
|
|
254
|
+
defaultValue: ce,
|
|
255
|
+
defaultShow: me,
|
|
256
|
+
value: fe,
|
|
257
|
+
popup: ge,
|
|
258
|
+
weekNumber: ve,
|
|
259
|
+
dateInput: we,
|
|
260
|
+
calendar: be,
|
|
261
|
+
toggleButton: ye,
|
|
262
|
+
onChange: Ie,
|
|
263
|
+
onBlur: Ce,
|
|
264
|
+
onFocus: De,
|
|
265
|
+
show: ke,
|
|
266
|
+
onOpen: Se,
|
|
267
|
+
pickerWrap: Oe,
|
|
268
|
+
...I
|
|
269
|
+
} = this.props, R = this.value, C = !this.validityStyles || this.validity.valid, A = {
|
|
252
270
|
disabled: a,
|
|
253
|
-
format:
|
|
254
|
-
formatPlaceholder:
|
|
271
|
+
format: f,
|
|
272
|
+
formatPlaceholder: g,
|
|
255
273
|
id: l,
|
|
256
|
-
ariaLabelledBy:
|
|
257
|
-
ariaDescribedBy:
|
|
258
|
-
ariaLabel:
|
|
259
|
-
max:
|
|
260
|
-
min:
|
|
261
|
-
name:
|
|
274
|
+
ariaLabelledBy: V,
|
|
275
|
+
ariaDescribedBy: z,
|
|
276
|
+
ariaLabel: F,
|
|
277
|
+
max: d,
|
|
278
|
+
min: v,
|
|
279
|
+
name: b,
|
|
262
280
|
onChange: this.handleInputValueChange,
|
|
263
|
-
required:
|
|
264
|
-
tabIndex:
|
|
265
|
-
title:
|
|
281
|
+
required: x,
|
|
282
|
+
tabIndex: this.show ? -1 : c,
|
|
283
|
+
title: m,
|
|
266
284
|
valid: this.validity.valid,
|
|
267
|
-
validationMessage:
|
|
268
|
-
validityStyles:
|
|
269
|
-
value:
|
|
285
|
+
validationMessage: h,
|
|
286
|
+
validityStyles: B,
|
|
287
|
+
value: R,
|
|
270
288
|
label: void 0,
|
|
271
|
-
placeholder: this.state.focused ? null :
|
|
289
|
+
placeholder: this.state.focused ? null : N,
|
|
272
290
|
ariaExpanded: this.show,
|
|
273
291
|
size: null,
|
|
274
292
|
fillMode: null,
|
|
275
293
|
rounded: null
|
|
276
|
-
},
|
|
277
|
-
|
|
294
|
+
}, D = ie(this).toLanguageString(E, te[E]), k = /* @__PURE__ */ n.createElement(
|
|
295
|
+
K,
|
|
278
296
|
{
|
|
279
297
|
onFocus: this.handleFocus,
|
|
280
298
|
onBlur: this.mobileMode ? void 0 : this.handleBlur,
|
|
281
299
|
onSyncBlur: this.props.onBlur,
|
|
282
300
|
onSyncFocus: this.props.onFocus
|
|
283
301
|
},
|
|
284
|
-
(
|
|
302
|
+
(S) => /* @__PURE__ */ n.createElement(n.Fragment, null, /* @__PURE__ */ n.createElement(
|
|
285
303
|
"span",
|
|
286
304
|
{
|
|
287
|
-
|
|
288
|
-
|
|
305
|
+
...y ? {} : I,
|
|
306
|
+
ref: (q) => {
|
|
307
|
+
this._element = q;
|
|
289
308
|
},
|
|
290
|
-
className:
|
|
309
|
+
className: M(
|
|
291
310
|
"k-input",
|
|
292
311
|
"k-datepicker",
|
|
293
312
|
{
|
|
294
|
-
[`k-input-${
|
|
295
|
-
[`k-rounded-${
|
|
313
|
+
[`k-input-${T.sizeMap[i] || i}`]: i,
|
|
314
|
+
[`k-rounded-${T.roundedMap[t] || t}`]: t,
|
|
296
315
|
[`k-input-${s}`]: s,
|
|
297
|
-
"k-invalid": !
|
|
316
|
+
"k-invalid": !C,
|
|
298
317
|
"k-required": this.required,
|
|
299
|
-
"k-disabled":
|
|
318
|
+
"k-disabled": a
|
|
300
319
|
},
|
|
301
|
-
|
|
320
|
+
w
|
|
302
321
|
),
|
|
303
322
|
onKeyDown: this.handleKeyDown,
|
|
304
|
-
style: { width:
|
|
305
|
-
onFocus:
|
|
306
|
-
onBlur:
|
|
323
|
+
style: { width: u },
|
|
324
|
+
onFocus: S.onFocus,
|
|
325
|
+
onBlur: S.onBlur,
|
|
307
326
|
onClick: this.mobileMode ? this.handleIconClick : void 0
|
|
308
327
|
},
|
|
309
328
|
/* @__PURE__ */ n.createElement(
|
|
@@ -314,7 +333,7 @@ const o = class o extends n.Component {
|
|
|
314
333
|
readonly: this.mobileMode,
|
|
315
334
|
ariaExpanded: this.show,
|
|
316
335
|
ariaControls: this._popupId,
|
|
317
|
-
...
|
|
336
|
+
...A
|
|
318
337
|
}
|
|
319
338
|
),
|
|
320
339
|
/* @__PURE__ */ n.createElement(
|
|
@@ -322,30 +341,31 @@ const o = class o extends n.Component {
|
|
|
322
341
|
{
|
|
323
342
|
type: "button",
|
|
324
343
|
icon: "calendar",
|
|
325
|
-
svgIcon:
|
|
326
|
-
title:
|
|
344
|
+
svgIcon: X,
|
|
345
|
+
title: D,
|
|
327
346
|
className: "k-input-button",
|
|
328
347
|
rounded: null,
|
|
329
348
|
onClick: this.mobileMode ? void 0 : this.handleIconClick,
|
|
330
|
-
"aria-label":
|
|
349
|
+
"aria-label": D,
|
|
331
350
|
onMouseDown: this.handleIconMouseDown
|
|
332
351
|
}
|
|
333
352
|
),
|
|
334
353
|
!this.mobileMode && this.renderPopup()
|
|
335
354
|
), this.mobileMode && this.renderAdaptivePopup())
|
|
336
355
|
);
|
|
337
|
-
return
|
|
338
|
-
|
|
356
|
+
return y ? /* @__PURE__ */ n.createElement(
|
|
357
|
+
ne,
|
|
339
358
|
{
|
|
340
359
|
dateInput: this._dateInput,
|
|
341
|
-
label:
|
|
360
|
+
label: y,
|
|
342
361
|
editorId: l,
|
|
343
|
-
editorValid:
|
|
344
|
-
editorDisabled:
|
|
345
|
-
children:
|
|
346
|
-
style: { width:
|
|
362
|
+
editorValid: C,
|
|
363
|
+
editorDisabled: a,
|
|
364
|
+
children: k,
|
|
365
|
+
style: { width: u },
|
|
366
|
+
...I
|
|
347
367
|
}
|
|
348
|
-
) :
|
|
368
|
+
) : k;
|
|
349
369
|
}
|
|
350
370
|
setShow(i) {
|
|
351
371
|
const { onOpen: t, onClose: s } = this.props;
|
|
@@ -356,7 +376,7 @@ const o = class o extends n.Component {
|
|
|
356
376
|
}));
|
|
357
377
|
}
|
|
358
378
|
mergeTime(i) {
|
|
359
|
-
return this.value && i ?
|
|
379
|
+
return this.value && i ? ee(i, this.value) : i;
|
|
360
380
|
}
|
|
361
381
|
nextTick(i) {
|
|
362
382
|
clearTimeout(this.nextTickId), this.nextTickId = window.setTimeout(() => i());
|
|
@@ -433,15 +453,15 @@ o.displayName = "DatePicker", o.propTypes = {
|
|
|
433
453
|
}, o.defaultProps = {
|
|
434
454
|
defaultShow: !1,
|
|
435
455
|
defaultValue: null,
|
|
436
|
-
dateInput:
|
|
437
|
-
calendar:
|
|
438
|
-
toggleButton:
|
|
439
|
-
popup:
|
|
440
|
-
pickerWrap:
|
|
456
|
+
dateInput: j,
|
|
457
|
+
calendar: G,
|
|
458
|
+
toggleButton: oe,
|
|
459
|
+
popup: L,
|
|
460
|
+
pickerWrap: ae,
|
|
441
461
|
disabled: !1,
|
|
442
462
|
format: "d",
|
|
443
|
-
max:
|
|
444
|
-
min:
|
|
463
|
+
max: J,
|
|
464
|
+
min: Q,
|
|
445
465
|
popupSettings: {},
|
|
446
466
|
tabIndex: 0,
|
|
447
467
|
weekNumber: !1,
|
|
@@ -452,11 +472,11 @@ o.displayName = "DatePicker", o.propTypes = {
|
|
|
452
472
|
fillMode: "solid"
|
|
453
473
|
};
|
|
454
474
|
let p = o;
|
|
455
|
-
const
|
|
475
|
+
const ue = U(), he = $(H(ue, p));
|
|
456
476
|
he.displayName = "KendoReactDatePicker";
|
|
457
|
-
|
|
477
|
+
se(p);
|
|
458
478
|
export {
|
|
459
479
|
he as DatePicker,
|
|
460
|
-
|
|
480
|
+
ue as DatePickerPropsContext,
|
|
461
481
|
p as DatePickerWithoutContext
|
|
462
482
|
};
|