@progress/kendo-react-dateinputs 9.1.0 → 9.1.1-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/dateinput/DateInput.js +1 -1
- package/dateinput/DateInput.mjs +78 -67
- package/dist/cdn/js/kendo-react-dateinputs.js +1 -1
- package/index.d.mts +2 -0
- package/index.d.ts +2 -0
- package/package-metadata.mjs +1 -1
- package/package.json +7 -7
package/dateinput/DateInput.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 V=require("react"),e=require("prop-types"),g=require("@progress/kendo-date-math"),x=require("@progress/kendo-react-buttons"),P=require("@progress/kendo-svg-icons"),f=require("@progress/kendo-react-intl"),n=require("@progress/kendo-react-common"),_=require("@progress/kendo-react-labels"),L=require("@progress/kendo-dateinputs-common"),w=require("./utils.js"),N=require("../package-metadata.js"),v=require("../utils.js"),r=require("../messages/index.js"),A=require("../timepicker/utils.js"),F=require("../common/ClearButton.js"),R=require("./dateInputIntl.js");function B(c){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const t in c)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(c,t);Object.defineProperty(i,t,s.get?s:{enumerable:!0,get:()=>c[t]})}}return i.default=c,Object.freeze(i)}const d=B(V),j="Please enter a valid value!",a=class a extends d.Component{constructor(i){super(i),this.kendoDate=null,this.kendoDateObject=null,this.mounted=!1,this._element=null,this._wrapper=null,this._nativeEvent=null,this.focus=()=>{this._element&&this._element.focus()},this.setValidity=()=>{this.element&&this.element.setCustomValidity&&this.element.setCustomValidity(this.validity.valid?"":this.props.validationMessage||a.defaultProps.validationMessage)},this.updateOnPaste=t=>{!this.element||!this.kendoDate||this.triggerChange(t)},this.spinnersMouseDown=t=>{t.preventDefault();const s=n.getActiveElement(document);this.element&&s!==this.element&&this.element.focus({preventScroll:!0})},this.handleClick=t=>{this.props.onChange&&this.props.onChange(t)},this.nativeWheel=t=>{n.getActiveElement(document)===this.element&&t.preventDefault()},this.increasePart=t=>{var s;(s=this.kendoDate)==null||s.modifyDateSegmentValue(1),this.onChange(t)},this.decreasePart=t=>{var s;(s=this.kendoDate)==null||s.modifyDateSegmentValue(-1),this.onChange(t)},this.elementOnFocus=t=>{this.wrapper&&this.wrapper.classList.add("k-focus"),this.setState({focused:!0})},this.elementOnBlur=t=>{this.wrapper&&this.wrapper.classList.remove("k-focus"),this.setState({focused:!1})},n.validatePackage(N.packageMetadata),this.state={focused:!1}}get _inputId(){return this.props.id+"-accessibility-id"}get value(){return this.valueDuringOnChange!==void 0?this.valueDuringOnChange:this.kendoDate&&this.kendoDate.value}get name(){return this.props.name}get min(){return this.props.min!==void 0?this.props.min:a.defaultProps.min}get max(){return this.props.max!==void 0?this.props.max:a.defaultProps.max}get isInSegmentSelection(){const{year:i,month:t,day:s,hours:l,minutes:u,seconds:o}=this.kendoDateObject;return(!i||!t||!s||!l||!u||!o)&&(i||t||s||l||u||o)}get text(){const{placeholder:i}=this.props,t=this.kendoDate&&this.kendoDate.currentText||"";return i!=null&&!this.state.focused&&!this.value?i:t}get validity(){const i=w.isInRange(this.value,this.min,this.max)&&A.isInTimeRange(this.value,this.props.minTime,this.props.maxTime),t=this.props.validationMessage!==void 0,s=(!this.required||this.value!==null)&&i,l=this.props.valid!==void 0?this.props.valid:s;return{customError:t,rangeOverflow:this.value&&this.max.getTime()<this.value.getTime()||!1,rangeUnderflow:this.value&&this.value.getTime()<this.min.getTime()||!1,valid:l,valueMissing:this.value===null}}get element(){return this._element}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:a.defaultProps.validityStyles}get required(){return this.props.required!==void 0?this.props.required:!1}get wrapper(){return this._wrapper}get options(){const{format:i,steps:t,placeholder:s,value:l,autoFill:u,enableMouseWheel:o,autoCorrectParts:h,autoSwitchParts:b,autoSwitchKeys:D,twoDigitYearMax:m,allowCaretMode:y,formatPlaceholder:O}=this.props;return{format:i,steps:t,formatPlaceholder:O,placeholder:s,selectPreviousSegmentOnBackspace:!0,value:l||this.value,intlService:this.intlCommon,autoFill:u!==void 0?u:!1,enableMouseWheel:o,autoCorrectParts:h,autoSwitchParts:b,autoSwitchKeys:D||[],twoDigitYearMax:m,allowCaretMode:y}}componentDidMount(){this.setValidity(),this.mounted||(this.wrapper&&this.wrapper.addEventListener("wheel",this.nativeWheel,{passive:!1}),this.kendoDate=this.initKendoDate(),this.kendoDateObject=this.kendoDate.dateObject,this.mounted=!0)}componentDidUpdate(i){this.setValidity(),this.kendoDate&&((i.format!==this.props.format||i.readonly!==this.props.readonly||i.steps!==this.props.steps||this.intlCommon.locale!==this.kendoDate.options.intlService.locale)&&this.kendoDate.setOptions(this.options,!0),i.value!==this.props.value&&(this.kendoDateObject.getValue()!==null||this.isInSegmentSelection&&this.props.value!==null)&&this.kendoDateObject.setValue(this.props.value),this.props.ariaExpanded!==void 0&&this.props.ariaExpanded&&(this.kendoDate.options.placeholder=null),this.props.ariaExpanded!==void 0&&!this.props.ariaExpanded&&(this.kendoDate.options.placeholder=this.props.placeholder),this.kendoDate.refreshElementValue())}componentWillUnmount(){this.wrapper&&this.wrapper.removeEventListener("wheel",this.nativeWheel)}render(){var S;const{size:i=a.defaultProps.size,fillMode:t=a.defaultProps.fillMode,rounded:s=a.defaultProps.rounded,autoFocus:l=a.defaultProps.autoFocus,unstyled:u}=this.props,o=u&&u.uDateInput;this.props._ref&&(this.props._ref.current=this);const h=f.provideLocalizationService(this),b={...a.defaultProps,...this.props},{name:D,label:m,id:y,disabled:O}=b,q=this.text,I=y||this._inputId,C=!this.validityStyles||this.validity.valid,E=d.createElement("span",{ref:k=>{this._wrapper=k},style:m?void 0:{width:this.props.width},dir:this.props.dir,className:n.classNames(n.uDateInput.wrapper({c:o,size:i,fillMode:t,rounded:s,disabled:O,required:this.required,invalid:!C}),this.props.className)},d.createElement("input",{role:this.props.ariaRole||"textbox",readOnly:this.props.readonly,tabIndex:this.props.tabIndex||0,disabled:this.props.disabled,title:this.props.title!==void 0?this.props.title:q,type:"text",spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoFocus:l,className:n.classNames(n.uDateInput.inputInner({c:o})),id:I,"aria-label":this.props.ariaLabel,"aria-labelledby":this.props.ariaLabelledBy,"aria-describedby":this.props.ariaDescribedBy,"aria-haspopup":this.props.ariaHasPopup,"aria-disabled":this.props.disabled,"aria-expanded":this.props.ariaExpanded,"aria-controls":this.props.ariaControls,"aria-required":this.props.required,"aria-invalid":!C,onKeyDown:this.onChange.bind(this),onChange:this.onChange.bind(this),onWheel:this.onChange.bind(this),onInput:this.onChange.bind(this),onClick:this.onChange.bind(this),name:D,ref:k=>this._element=k}),this.props.children,this.props.clearButton&&this.props.value&&d.createElement(F,{onClick:this.handleClick,key:"clearbutton"}),this.props.spinners&&d.createElement("span",{className:n.classNames(n.uDateInput.inputSpinner({c:o})),onMouseDown:this.spinnersMouseDown},d.createElement(x.Button,{tabIndex:-1,type:"button",rounded:null,className:n.classNames(n.uDateInput.spinnerIncrease({c:o})),icon:"caret-alt-up",svgIcon:P.caretAltUpIcon,"aria-label":h.toLanguageString(r.increaseValue,r.messages[r.increaseValue]),title:h.toLanguageString(r.increaseValue,r.messages[r.increaseValue]),onClick:this.increasePart}),d.createElement(x.Button,{tabIndex:-1,type:"button",rounded:null,className:n.classNames(n.uDateInput.spinnerDecrease({c:o})),icon:"caret-alt-down",svgIcon:P.caretAltDownIcon,"aria-label":h.toLanguageString(r.decreaseValue,r.messages[r.decreaseValue]),title:h.toLanguageString(r.decreaseValue,r.messages[r.decreaseValue]),onClick:this.decreasePart})));return m?d.createElement(_.FloatingLabel,{label:m,editorId:I,editorValue:(S=this._element)==null?void 0:S.value,editorValid:C,editorDisabled:this.props.disabled,children:E,style:{width:this.props.width}}):E}intl(){return f.provideIntlService(this)}get intlCommon(){return new R.DateInputIntl(f.provideIntlService(this))}triggerChange(i){this.valueDuringOnChange=this.value,this.forceUpdate(),this._nativeEvent=i,this.valueDuringOnChange=void 0}onChange(i){this._nativeEvent&&this.props.onChange&&!g.isEqual(this._nativeEvent.oldValue,this.value)&&this.props.onChange.call(void 0,{syntheticEvent:i,nativeEvent:this._nativeEvent.event,value:this._nativeEvent.value,target:this}),this._nativeEvent=null}initKendoDate(){return new L.DateInput(this._element,{...this.options,events:{focus:this.elementOnFocus.bind(this),blur:this.elementOnBlur.bind(this),valueChange:this.triggerChange.bind(this),click:this.handleClick.bind(this)}})}};a.displayName="DateInput",a.propTypes={value: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})]),width:e.oneOfType([e.string,e.number]),tabIndex:e.number,title:e.string,steps:e.shape({year:e.number,month:e.number,day:e.number,hour:e.number,minute:e.number,second:e.number}),min:e.instanceOf(Date),max:e.instanceOf(Date),disabled:e.bool,spinners:e.bool,name:e.string,dir:e.string,label:e.string,id:e.string,ariaLabelledBy:e.string,ariaDescribedBy:e.string,ariaLabel:e.string,ariaRole:e.string,ariaHasPopup:e.oneOfType([e.bool,e.string]),ariaExpanded:e.oneOfType([e.bool]),onChange:e.func,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"]),autoFocus:e.bool},a.defaultProps={format:w.DEFAULT_FORMAT,size:"medium",rounded:"medium",fillMode:"solid",formatPlaceholder:w.DEFAULT_FORMAT_PLACEHOLDER,spinners:!1,disabled:!1,max:g.cloneDate(v.MAX_DATE),min:g.cloneDate(v.MIN_DATE),minTime:g.cloneDate(v.MIN_TIME),maxTime:g.cloneDate(v.MAX_TIME),validityStyles:!0,validationMessage:j,placeholder:null,enableMouseWheel:!0,autoCorrectParts:!0,autoSwitchParts:!0,allowCaretMode:!1,twoDigitYearMax:68,ariaHasPopup:"grid",autoFocus:!1};let p=a;const M=n.createPropsContext(),T=n.withIdHOC(n.withPropsContext(M,n.withUnstyledHOC(p)));T.displayName="KendoReactDateInput";f.registerForIntl(p);f.registerForLocalization(p);exports.DateInput=T;exports.DateInputPropsContext=M;exports.DateInputWithoutContext=p;
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("react"),e=require("prop-types"),g=require("@progress/kendo-date-math"),P=require("@progress/kendo-react-buttons"),M=require("@progress/kendo-svg-icons"),f=require("@progress/kendo-react-intl"),n=require("@progress/kendo-react-common"),_=require("@progress/kendo-react-labels"),L=require("@progress/kendo-dateinputs-common"),w=require("./utils.js"),N=require("../package-metadata.js"),v=require("../utils.js"),o=require("../messages/index.js"),A=require("../timepicker/utils.js"),F=require("../common/ClearButton.js"),R=require("./dateInputIntl.js");function j(c){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const i in c)if(i!=="default"){const s=Object.getOwnPropertyDescriptor(c,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:()=>c[i]})}}return t.default=c,Object.freeze(t)}const d=j(V),B="Please enter a valid value!",a=class a extends d.Component{constructor(t){super(t),this.kendoDate=null,this.kendoDateObject=null,this.mounted=!1,this._element=null,this._wrapper=null,this._nativeEvent=null,this.focus=()=>{this._element&&this._element.focus()},this.setValidity=()=>{this.element&&this.element.setCustomValidity&&this.element.setCustomValidity(this.validity.valid?"":this.props.validationMessage||a.defaultProps.validationMessage)},this.updateOnPaste=i=>{!this.element||!this.kendoDate||this.triggerChange(i)},this.spinnersMouseDown=i=>{i.preventDefault();const s=n.getActiveElement(document);this.element&&s!==this.element&&this.element.focus({preventScroll:!0})},this.handleClick=i=>{this.props.onChange&&this.props.onChange(i)},this.nativeWheel=i=>{n.getActiveElement(document)===this.element&&i.preventDefault()},this.increasePart=i=>{var s;(s=this.kendoDate)==null||s.modifyDateSegmentValue(1),this.onChange(i)},this.decreasePart=i=>{var s;(s=this.kendoDate)==null||s.modifyDateSegmentValue(-1),this.onChange(i)},this.elementOnFocus=i=>{this.wrapper&&this.wrapper.classList.add("k-focus"),this.setState({focused:!0})},this.elementOnBlur=i=>{this.wrapper&&this.wrapper.classList.remove("k-focus"),this.setState({focused:!1})},n.validatePackage(N.packageMetadata),this.state={focused:!1}}get _inputId(){return this.props.id+"-accessibility-id"}isFormatChanged(t,i){return typeof t!=typeof i?!0:typeof t=="string"&&typeof i=="string"?t!==i:typeof t=="object"&&typeof i=="object"?JSON.stringify(t)!==JSON.stringify(i):!1}mapFormatToCommonFormat(t){return typeof t=="string"?t:{inputFormat:t,displayFormat:t}}get value(){return this.valueDuringOnChange!==void 0?this.valueDuringOnChange:this.kendoDate&&this.kendoDate.value}get name(){return this.props.name}get min(){return this.props.min!==void 0?this.props.min:a.defaultProps.min}get max(){return this.props.max!==void 0?this.props.max:a.defaultProps.max}get isInSegmentSelection(){const{year:t,month:i,day:s,hours:l,minutes:u,seconds:r}=this.kendoDateObject;return(!t||!i||!s||!l||!u||!r)&&(t||i||s||l||u||r)}get text(){const{placeholder:t}=this.props,i=this.kendoDate&&this.kendoDate.currentText||"";return t!=null&&!this.state.focused&&!this.value?t:i}get validity(){const t=w.isInRange(this.value,this.min,this.max)&&A.isInTimeRange(this.value,this.props.minTime,this.props.maxTime),i=this.props.validationMessage!==void 0,s=(!this.required||this.value!==null)&&t,l=this.props.valid!==void 0?this.props.valid:s;return{customError:i,rangeOverflow:this.value&&this.max.getTime()<this.value.getTime()||!1,rangeUnderflow:this.value&&this.value.getTime()<this.min.getTime()||!1,valid:l,valueMissing:this.value===null}}get element(){return this._element}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:a.defaultProps.validityStyles}get required(){return this.props.required!==void 0?this.props.required:!1}get wrapper(){return this._wrapper}get options(){const{format:t,steps:i,placeholder:s,value:l,autoFill:u,enableMouseWheel:r,autoCorrectParts:h,autoSwitchParts:b,autoSwitchKeys:y,twoDigitYearMax:m,allowCaretMode:D,formatPlaceholder:C}=this.props;return{format:t,steps:i,formatPlaceholder:C,placeholder:s,selectPreviousSegmentOnBackspace:!0,value:l||this.value,intlService:this.intlCommon,autoFill:u!==void 0?u:!1,enableMouseWheel:r,autoCorrectParts:h,autoSwitchParts:b,autoSwitchKeys:y||[],twoDigitYearMax:m,allowCaretMode:D}}componentDidMount(){this.setValidity(),this.mounted||(this.wrapper&&this.wrapper.addEventListener("wheel",this.nativeWheel,{passive:!1}),this.kendoDate=this.initKendoDate(),this.kendoDateObject=this.kendoDate.dateObject,this.mounted=!0)}componentDidUpdate(t){this.setValidity(),this.kendoDate&&((this.isFormatChanged(t.format,this.props.format)||t.readonly!==this.props.readonly||t.steps!==this.props.steps||this.intlCommon.locale!==this.kendoDate.options.intlService.locale)&&this.kendoDate.setOptions(this.options,!0),t.value!==this.props.value&&(this.kendoDateObject.getValue()!==null||this.isInSegmentSelection&&this.props.value!==null)&&this.kendoDateObject.setValue(this.props.value),this.props.ariaExpanded!==void 0&&this.props.ariaExpanded&&(this.kendoDate.options.placeholder=null),this.props.ariaExpanded!==void 0&&!this.props.ariaExpanded&&(this.kendoDate.options.placeholder=this.props.placeholder),this.kendoDate.refreshElementValue())}componentWillUnmount(){this.wrapper&&this.wrapper.removeEventListener("wheel",this.nativeWheel)}render(){var x;const{size:t=a.defaultProps.size,fillMode:i=a.defaultProps.fillMode,rounded:s=a.defaultProps.rounded,autoFocus:l=a.defaultProps.autoFocus,unstyled:u}=this.props,r=u&&u.uDateInput;this.props._ref&&(this.props._ref.current=this);const h=f.provideLocalizationService(this),b={...a.defaultProps,...this.props},{name:y,label:m,id:D,disabled:C}=b,I=this.text,E=D||this._inputId,O=!this.validityStyles||this.validity.valid,S=d.createElement("span",{ref:k=>{this._wrapper=k},style:m?void 0:{width:this.props.width},dir:this.props.dir,className:n.classNames(n.uDateInput.wrapper({c:r,size:t,fillMode:i,rounded:s,disabled:C,required:this.required,invalid:!O}),this.props.className)},d.createElement("input",{role:this.props.ariaRole||"textbox",readOnly:this.props.readonly,tabIndex:this.props.tabIndex||0,disabled:this.props.disabled,title:this.props.title!==void 0?this.props.title:I,value:I,type:"text",spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoFocus:l,className:n.classNames(n.uDateInput.inputInner({c:r})),id:E,"aria-label":this.props.ariaLabel,"aria-labelledby":this.props.ariaLabelledBy,"aria-describedby":this.props.ariaDescribedBy,"aria-haspopup":this.props.ariaHasPopup,"aria-disabled":this.props.disabled,"aria-expanded":this.props.ariaExpanded,"aria-controls":this.props.ariaControls,"aria-required":this.props.required,"aria-invalid":!O,onKeyDown:this.onChange.bind(this),onChange:this.onChange.bind(this),onWheel:this.onChange.bind(this),onInput:this.onChange.bind(this),onClick:this.onChange.bind(this),name:y,ref:k=>this._element=k}),this.props.children,this.props.clearButton&&this.props.value&&d.createElement(F,{onClick:this.handleClick,key:"clearbutton"}),this.props.spinners&&d.createElement("span",{className:n.classNames(n.uDateInput.inputSpinner({c:r})),onMouseDown:this.spinnersMouseDown},d.createElement(P.Button,{tabIndex:-1,type:"button",rounded:null,className:n.classNames(n.uDateInput.spinnerIncrease({c:r})),icon:"caret-alt-up",svgIcon:M.caretAltUpIcon,"aria-label":h.toLanguageString(o.increaseValue,o.messages[o.increaseValue]),title:h.toLanguageString(o.increaseValue,o.messages[o.increaseValue]),onClick:this.increasePart}),d.createElement(P.Button,{tabIndex:-1,type:"button",rounded:null,className:n.classNames(n.uDateInput.spinnerDecrease({c:r})),icon:"caret-alt-down",svgIcon:M.caretAltDownIcon,"aria-label":h.toLanguageString(o.decreaseValue,o.messages[o.decreaseValue]),title:h.toLanguageString(o.decreaseValue,o.messages[o.decreaseValue]),onClick:this.decreasePart})));return m?d.createElement(_.FloatingLabel,{label:m,editorId:E,editorValue:(x=this._element)==null?void 0:x.value,editorValid:O,editorDisabled:this.props.disabled,children:S,style:{width:this.props.width}}):S}intl(){return f.provideIntlService(this)}get intlCommon(){return new R.DateInputIntl(f.provideIntlService(this))}triggerChange(t){this.valueDuringOnChange=this.value,this.forceUpdate(),this._nativeEvent=t,this.valueDuringOnChange=void 0}onChange(t){this._nativeEvent&&this.props.onChange&&!g.isEqual(this._nativeEvent.oldValue,this.value)&&this.props.onChange.call(void 0,{syntheticEvent:t,nativeEvent:this._nativeEvent.event,value:this._nativeEvent.value,target:this}),this._nativeEvent=null}initKendoDate(){return new L.DateInput(this._element,{...this.options,format:this.mapFormatToCommonFormat(this.options.format),events:{focus:this.elementOnFocus.bind(this),blur:this.elementOnBlur.bind(this),valueChange:this.triggerChange.bind(this),click:this.handleClick.bind(this)}})}};a.displayName="DateInput",a.propTypes={value: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})]),width:e.oneOfType([e.string,e.number]),tabIndex:e.number,title:e.string,steps:e.shape({year:e.number,month:e.number,day:e.number,hour:e.number,minute:e.number,second:e.number}),min:e.instanceOf(Date),max:e.instanceOf(Date),disabled:e.bool,spinners:e.bool,name:e.string,dir:e.string,label:e.string,id:e.string,ariaLabelledBy:e.string,ariaDescribedBy:e.string,ariaLabel:e.string,ariaRole:e.string,ariaHasPopup:e.oneOfType([e.bool,e.string]),ariaExpanded:e.oneOfType([e.bool]),onChange:e.func,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"]),autoFocus:e.bool},a.defaultProps={format:w.DEFAULT_FORMAT,size:"medium",rounded:"medium",fillMode:"solid",formatPlaceholder:w.DEFAULT_FORMAT_PLACEHOLDER,spinners:!1,disabled:!1,max:g.cloneDate(v.MAX_DATE),min:g.cloneDate(v.MIN_DATE),minTime:g.cloneDate(v.MIN_TIME),maxTime:g.cloneDate(v.MAX_TIME),validityStyles:!0,validationMessage:B,placeholder:null,enableMouseWheel:!0,autoCorrectParts:!0,autoSwitchParts:!0,allowCaretMode:!1,twoDigitYearMax:68,ariaHasPopup:"grid",autoFocus:!1};let p=a;const T=n.createPropsContext(),q=n.withIdHOC(n.withPropsContext(T,n.withUnstyledHOC(p)));q.displayName="KendoReactDateInput";f.registerForIntl(p);f.registerForLocalization(p);exports.DateInput=q;exports.DateInputPropsContext=T;exports.DateInputWithoutContext=p;
|
package/dateinput/DateInput.mjs
CHANGED
|
@@ -11,35 +11,35 @@ import e from "prop-types";
|
|
|
11
11
|
import { cloneDate as c, isEqual as T } from "@progress/kendo-date-math";
|
|
12
12
|
import { Button as x } from "@progress/kendo-react-buttons";
|
|
13
13
|
import { caretAltUpIcon as L, caretAltDownIcon as _ } from "@progress/kendo-svg-icons";
|
|
14
|
-
import { provideLocalizationService as V, provideIntlService as
|
|
15
|
-
import { getActiveElement as
|
|
16
|
-
import { FloatingLabel as
|
|
17
|
-
import { DateInput as
|
|
14
|
+
import { provideLocalizationService as V, provideIntlService as P, registerForIntl as A, registerForLocalization as F } from "@progress/kendo-react-intl";
|
|
15
|
+
import { getActiveElement as M, validatePackage as N, classNames as d, uDateInput as u, createPropsContext as q, withIdHOC as B, withPropsContext as R, withUnstyledHOC as j } from "@progress/kendo-react-common";
|
|
16
|
+
import { FloatingLabel as U } from "@progress/kendo-react-labels";
|
|
17
|
+
import { DateInput as z } from "@progress/kendo-dateinputs-common";
|
|
18
18
|
import { DEFAULT_FORMAT as H, DEFAULT_FORMAT_PLACEHOLDER as K, isInRange as W } from "./utils.mjs";
|
|
19
|
-
import { packageMetadata as
|
|
20
|
-
import { MAX_DATE as
|
|
21
|
-
import { increaseValue as
|
|
22
|
-
import { isInTimeRange as
|
|
19
|
+
import { packageMetadata as J } from "../package-metadata.mjs";
|
|
20
|
+
import { MAX_DATE as X, MIN_DATE as Y, MIN_TIME as G, MAX_TIME as Z } from "../utils.mjs";
|
|
21
|
+
import { increaseValue as f, messages as g, decreaseValue as v } from "../messages/index.mjs";
|
|
22
|
+
import { isInTimeRange as $ } from "../timepicker/utils.mjs";
|
|
23
23
|
import Q from "../common/ClearButton.mjs";
|
|
24
24
|
import { DateInputIntl as ee } from "./dateInputIntl.mjs";
|
|
25
|
-
const te = "Please enter a valid value!",
|
|
25
|
+
const te = "Please enter a valid value!", n = class n extends l.Component {
|
|
26
26
|
constructor(t) {
|
|
27
27
|
super(t), this.kendoDate = null, this.kendoDateObject = null, this.mounted = !1, this._element = null, this._wrapper = null, this._nativeEvent = null, this.focus = () => {
|
|
28
28
|
this._element && this._element.focus();
|
|
29
29
|
}, this.setValidity = () => {
|
|
30
30
|
this.element && this.element.setCustomValidity && this.element.setCustomValidity(
|
|
31
|
-
this.validity.valid ? "" : this.props.validationMessage ||
|
|
31
|
+
this.validity.valid ? "" : this.props.validationMessage || n.defaultProps.validationMessage
|
|
32
32
|
);
|
|
33
33
|
}, this.updateOnPaste = (i) => {
|
|
34
34
|
!this.element || !this.kendoDate || this.triggerChange(i);
|
|
35
35
|
}, this.spinnersMouseDown = (i) => {
|
|
36
36
|
i.preventDefault();
|
|
37
|
-
const s =
|
|
37
|
+
const s = M(document);
|
|
38
38
|
this.element && s !== this.element && this.element.focus({ preventScroll: !0 });
|
|
39
39
|
}, this.handleClick = (i) => {
|
|
40
40
|
this.props.onChange && this.props.onChange(i);
|
|
41
41
|
}, this.nativeWheel = (i) => {
|
|
42
|
-
|
|
42
|
+
M(document) === this.element && i.preventDefault();
|
|
43
43
|
}, this.increasePart = (i) => {
|
|
44
44
|
var s;
|
|
45
45
|
(s = this.kendoDate) == null || s.modifyDateSegmentValue(1), this.onChange(i);
|
|
@@ -50,13 +50,22 @@ const te = "Please enter a valid value!", a = class a extends l.Component {
|
|
|
50
50
|
this.wrapper && this.wrapper.classList.add("k-focus"), this.setState({ focused: !0 });
|
|
51
51
|
}, this.elementOnBlur = (i) => {
|
|
52
52
|
this.wrapper && this.wrapper.classList.remove("k-focus"), this.setState({ focused: !1 });
|
|
53
|
-
}, N(
|
|
53
|
+
}, N(J), this.state = {
|
|
54
54
|
focused: !1
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
get _inputId() {
|
|
58
58
|
return this.props.id + "-accessibility-id";
|
|
59
59
|
}
|
|
60
|
+
isFormatChanged(t, i) {
|
|
61
|
+
return typeof t != typeof i ? !0 : typeof t == "string" && typeof i == "string" ? t !== i : typeof t == "object" && typeof i == "object" ? JSON.stringify(t) !== JSON.stringify(i) : !1;
|
|
62
|
+
}
|
|
63
|
+
mapFormatToCommonFormat(t) {
|
|
64
|
+
return typeof t == "string" ? t : {
|
|
65
|
+
inputFormat: t,
|
|
66
|
+
displayFormat: t
|
|
67
|
+
};
|
|
68
|
+
}
|
|
60
69
|
/* Public Getters */
|
|
61
70
|
/**
|
|
62
71
|
* Gets the value of the DateInput.
|
|
@@ -71,14 +80,14 @@ const te = "Please enter a valid value!", a = class a extends l.Component {
|
|
|
71
80
|
return this.props.name;
|
|
72
81
|
}
|
|
73
82
|
get min() {
|
|
74
|
-
return this.props.min !== void 0 ? this.props.min :
|
|
83
|
+
return this.props.min !== void 0 ? this.props.min : n.defaultProps.min;
|
|
75
84
|
}
|
|
76
85
|
get max() {
|
|
77
|
-
return this.props.max !== void 0 ? this.props.max :
|
|
86
|
+
return this.props.max !== void 0 ? this.props.max : n.defaultProps.max;
|
|
78
87
|
}
|
|
79
88
|
get isInSegmentSelection() {
|
|
80
|
-
const { year: t, month: i, day: s, hours: o, minutes: r, seconds:
|
|
81
|
-
return (!t || !i || !s || !o || !r || !
|
|
89
|
+
const { year: t, month: i, day: s, hours: o, minutes: r, seconds: a } = this.kendoDateObject;
|
|
90
|
+
return (!t || !i || !s || !o || !r || !a) && (t || i || s || o || r || a);
|
|
82
91
|
}
|
|
83
92
|
/**
|
|
84
93
|
* @hidden
|
|
@@ -91,7 +100,7 @@ const te = "Please enter a valid value!", a = class a extends l.Component {
|
|
|
91
100
|
* Represents the validity state into which the DateInput is set.
|
|
92
101
|
*/
|
|
93
102
|
get validity() {
|
|
94
|
-
const t = W(this.value, this.min, this.max) &&
|
|
103
|
+
const t = W(this.value, this.min, this.max) && $(this.value, this.props.minTime, this.props.maxTime), i = this.props.validationMessage !== void 0, s = (!this.required || this.value !== null) && t, o = this.props.valid !== void 0 ? this.props.valid : s;
|
|
95
104
|
return {
|
|
96
105
|
customError: i,
|
|
97
106
|
rangeOverflow: this.value && this.max.getTime() < this.value.getTime() || !1,
|
|
@@ -138,7 +147,7 @@ const te = "Please enter a valid value!", a = class a extends l.Component {
|
|
|
138
147
|
* @hidden
|
|
139
148
|
*/
|
|
140
149
|
get validityStyles() {
|
|
141
|
-
return this.props.validityStyles !== void 0 ? this.props.validityStyles :
|
|
150
|
+
return this.props.validityStyles !== void 0 ? this.props.validityStyles : n.defaultProps.validityStyles;
|
|
142
151
|
}
|
|
143
152
|
/**
|
|
144
153
|
* @hidden
|
|
@@ -162,11 +171,11 @@ const te = "Please enter a valid value!", a = class a extends l.Component {
|
|
|
162
171
|
placeholder: s,
|
|
163
172
|
value: o,
|
|
164
173
|
autoFill: r,
|
|
165
|
-
enableMouseWheel:
|
|
174
|
+
enableMouseWheel: a,
|
|
166
175
|
autoCorrectParts: h,
|
|
167
|
-
autoSwitchParts:
|
|
168
|
-
autoSwitchKeys:
|
|
169
|
-
twoDigitYearMax:
|
|
176
|
+
autoSwitchParts: y,
|
|
177
|
+
autoSwitchKeys: b,
|
|
178
|
+
twoDigitYearMax: p,
|
|
170
179
|
allowCaretMode: D,
|
|
171
180
|
formatPlaceholder: C
|
|
172
181
|
} = this.props;
|
|
@@ -179,11 +188,11 @@ const te = "Please enter a valid value!", a = class a extends l.Component {
|
|
|
179
188
|
value: o || this.value,
|
|
180
189
|
intlService: this.intlCommon,
|
|
181
190
|
autoFill: r !== void 0 ? r : !1,
|
|
182
|
-
enableMouseWheel:
|
|
191
|
+
enableMouseWheel: a,
|
|
183
192
|
autoCorrectParts: h,
|
|
184
|
-
autoSwitchParts:
|
|
185
|
-
autoSwitchKeys:
|
|
186
|
-
twoDigitYearMax:
|
|
193
|
+
autoSwitchParts: y,
|
|
194
|
+
autoSwitchKeys: b || [],
|
|
195
|
+
twoDigitYearMax: p,
|
|
187
196
|
allowCaretMode: D
|
|
188
197
|
};
|
|
189
198
|
}
|
|
@@ -197,7 +206,7 @@ const te = "Please enter a valid value!", a = class a extends l.Component {
|
|
|
197
206
|
* @hidden
|
|
198
207
|
*/
|
|
199
208
|
componentDidUpdate(t) {
|
|
200
|
-
this.setValidity(), this.kendoDate && ((t.format
|
|
209
|
+
this.setValidity(), this.kendoDate && ((this.isFormatChanged(t.format, this.props.format) || t.readonly !== this.props.readonly || t.steps !== this.props.steps || this.intlCommon.locale !== this.kendoDate.options.intlService.locale) && this.kendoDate.setOptions(this.options, !0), t.value !== this.props.value && (this.kendoDateObject.getValue() !== null || this.isInSegmentSelection && this.props.value !== null) && this.kendoDateObject.setValue(this.props.value), this.props.ariaExpanded !== void 0 && this.props.ariaExpanded && (this.kendoDate.options.placeholder = null), this.props.ariaExpanded !== void 0 && !this.props.ariaExpanded && (this.kendoDate.options.placeholder = this.props.placeholder), this.kendoDate.refreshElementValue());
|
|
201
210
|
}
|
|
202
211
|
/**
|
|
203
212
|
* @hidden
|
|
@@ -209,26 +218,26 @@ const te = "Please enter a valid value!", a = class a extends l.Component {
|
|
|
209
218
|
* @hidden
|
|
210
219
|
*/
|
|
211
220
|
render() {
|
|
212
|
-
var
|
|
221
|
+
var S;
|
|
213
222
|
const {
|
|
214
|
-
size: t =
|
|
215
|
-
fillMode: i =
|
|
216
|
-
rounded: s =
|
|
217
|
-
autoFocus: o =
|
|
223
|
+
size: t = n.defaultProps.size,
|
|
224
|
+
fillMode: i = n.defaultProps.fillMode,
|
|
225
|
+
rounded: s = n.defaultProps.rounded,
|
|
226
|
+
autoFocus: o = n.defaultProps.autoFocus,
|
|
218
227
|
unstyled: r
|
|
219
|
-
} = this.props,
|
|
228
|
+
} = this.props, a = r && r.uDateInput;
|
|
220
229
|
this.props._ref && (this.props._ref.current = this);
|
|
221
|
-
const h = V(this),
|
|
230
|
+
const h = V(this), y = { ...n.defaultProps, ...this.props }, { name: b, label: p, id: D, disabled: C } = y, E = this.text, k = D || this._inputId, O = !this.validityStyles || this.validity.valid, I = /* @__PURE__ */ l.createElement(
|
|
222
231
|
"span",
|
|
223
232
|
{
|
|
224
233
|
ref: (w) => {
|
|
225
234
|
this._wrapper = w;
|
|
226
235
|
},
|
|
227
|
-
style:
|
|
236
|
+
style: p ? void 0 : { width: this.props.width },
|
|
228
237
|
dir: this.props.dir,
|
|
229
|
-
className:
|
|
238
|
+
className: d(
|
|
230
239
|
u.wrapper({
|
|
231
|
-
c:
|
|
240
|
+
c: a,
|
|
232
241
|
size: t,
|
|
233
242
|
fillMode: i,
|
|
234
243
|
rounded: s,
|
|
@@ -246,14 +255,15 @@ const te = "Please enter a valid value!", a = class a extends l.Component {
|
|
|
246
255
|
readOnly: this.props.readonly,
|
|
247
256
|
tabIndex: this.props.tabIndex || 0,
|
|
248
257
|
disabled: this.props.disabled,
|
|
249
|
-
title: this.props.title !== void 0 ? this.props.title :
|
|
258
|
+
title: this.props.title !== void 0 ? this.props.title : E,
|
|
259
|
+
value: E,
|
|
250
260
|
type: "text",
|
|
251
261
|
spellCheck: !1,
|
|
252
262
|
autoComplete: "off",
|
|
253
263
|
autoCorrect: "off",
|
|
254
264
|
autoFocus: o,
|
|
255
|
-
className:
|
|
256
|
-
id:
|
|
265
|
+
className: d(u.inputInner({ c: a })),
|
|
266
|
+
id: k,
|
|
257
267
|
"aria-label": this.props.ariaLabel,
|
|
258
268
|
"aria-labelledby": this.props.ariaLabelledBy,
|
|
259
269
|
"aria-describedby": this.props.ariaDescribedBy,
|
|
@@ -268,7 +278,7 @@ const te = "Please enter a valid value!", a = class a extends l.Component {
|
|
|
268
278
|
onWheel: this.onChange.bind(this),
|
|
269
279
|
onInput: this.onChange.bind(this),
|
|
270
280
|
onClick: this.onChange.bind(this),
|
|
271
|
-
name:
|
|
281
|
+
name: b,
|
|
272
282
|
ref: (w) => this._element = w
|
|
273
283
|
}
|
|
274
284
|
),
|
|
@@ -277,7 +287,7 @@ const te = "Please enter a valid value!", a = class a extends l.Component {
|
|
|
277
287
|
this.props.spinners && /* @__PURE__ */ l.createElement(
|
|
278
288
|
"span",
|
|
279
289
|
{
|
|
280
|
-
className:
|
|
290
|
+
className: d(u.inputSpinner({ c: a })),
|
|
281
291
|
onMouseDown: this.spinnersMouseDown
|
|
282
292
|
},
|
|
283
293
|
/* @__PURE__ */ l.createElement(
|
|
@@ -286,11 +296,11 @@ const te = "Please enter a valid value!", a = class a extends l.Component {
|
|
|
286
296
|
tabIndex: -1,
|
|
287
297
|
type: "button",
|
|
288
298
|
rounded: null,
|
|
289
|
-
className:
|
|
299
|
+
className: d(u.spinnerIncrease({ c: a })),
|
|
290
300
|
icon: "caret-alt-up",
|
|
291
301
|
svgIcon: L,
|
|
292
|
-
"aria-label": h.toLanguageString(
|
|
293
|
-
title: h.toLanguageString(
|
|
302
|
+
"aria-label": h.toLanguageString(f, g[f]),
|
|
303
|
+
title: h.toLanguageString(f, g[f]),
|
|
294
304
|
onClick: this.increasePart
|
|
295
305
|
}
|
|
296
306
|
),
|
|
@@ -300,40 +310,40 @@ const te = "Please enter a valid value!", a = class a extends l.Component {
|
|
|
300
310
|
tabIndex: -1,
|
|
301
311
|
type: "button",
|
|
302
312
|
rounded: null,
|
|
303
|
-
className:
|
|
313
|
+
className: d(u.spinnerDecrease({ c: a })),
|
|
304
314
|
icon: "caret-alt-down",
|
|
305
315
|
svgIcon: _,
|
|
306
|
-
"aria-label": h.toLanguageString(v,
|
|
307
|
-
title: h.toLanguageString(v,
|
|
316
|
+
"aria-label": h.toLanguageString(v, g[v]),
|
|
317
|
+
title: h.toLanguageString(v, g[v]),
|
|
308
318
|
onClick: this.decreasePart
|
|
309
319
|
}
|
|
310
320
|
)
|
|
311
321
|
)
|
|
312
322
|
);
|
|
313
|
-
return
|
|
314
|
-
|
|
323
|
+
return p ? /* @__PURE__ */ l.createElement(
|
|
324
|
+
U,
|
|
315
325
|
{
|
|
316
|
-
label:
|
|
317
|
-
editorId:
|
|
318
|
-
editorValue: (
|
|
326
|
+
label: p,
|
|
327
|
+
editorId: k,
|
|
328
|
+
editorValue: (S = this._element) == null ? void 0 : S.value,
|
|
319
329
|
editorValid: O,
|
|
320
330
|
editorDisabled: this.props.disabled,
|
|
321
|
-
children:
|
|
331
|
+
children: I,
|
|
322
332
|
style: { width: this.props.width }
|
|
323
333
|
}
|
|
324
|
-
) :
|
|
334
|
+
) : I;
|
|
325
335
|
}
|
|
326
336
|
/**
|
|
327
337
|
* @hidden
|
|
328
338
|
*/
|
|
329
339
|
intl() {
|
|
330
|
-
return
|
|
340
|
+
return P(this);
|
|
331
341
|
}
|
|
332
342
|
/**
|
|
333
343
|
* @hidden
|
|
334
344
|
*/
|
|
335
345
|
get intlCommon() {
|
|
336
|
-
return new ee(
|
|
346
|
+
return new ee(P(this));
|
|
337
347
|
}
|
|
338
348
|
/* end handlers */
|
|
339
349
|
triggerChange(t) {
|
|
@@ -348,8 +358,9 @@ const te = "Please enter a valid value!", a = class a extends l.Component {
|
|
|
348
358
|
}), this._nativeEvent = null;
|
|
349
359
|
}
|
|
350
360
|
initKendoDate() {
|
|
351
|
-
return new
|
|
361
|
+
return new z(this._element, {
|
|
352
362
|
...this.options,
|
|
363
|
+
format: this.mapFormatToCommonFormat(this.options.format),
|
|
353
364
|
events: {
|
|
354
365
|
focus: this.elementOnFocus.bind(this),
|
|
355
366
|
blur: this.elementOnBlur.bind(this),
|
|
@@ -359,7 +370,7 @@ const te = "Please enter a valid value!", a = class a extends l.Component {
|
|
|
359
370
|
});
|
|
360
371
|
}
|
|
361
372
|
};
|
|
362
|
-
|
|
373
|
+
n.displayName = "DateInput", n.propTypes = {
|
|
363
374
|
value: e.instanceOf(Date),
|
|
364
375
|
format: e.oneOfType([
|
|
365
376
|
e.string,
|
|
@@ -431,7 +442,7 @@ a.displayName = "DateInput", a.propTypes = {
|
|
|
431
442
|
rounded: e.oneOf([null, "small", "medium", "large", "full"]),
|
|
432
443
|
fillMode: e.oneOf([null, "solid", "flat", "outline"]),
|
|
433
444
|
autoFocus: e.bool
|
|
434
|
-
},
|
|
445
|
+
}, n.defaultProps = {
|
|
435
446
|
format: H,
|
|
436
447
|
size: "medium",
|
|
437
448
|
rounded: "medium",
|
|
@@ -439,10 +450,10 @@ a.displayName = "DateInput", a.propTypes = {
|
|
|
439
450
|
formatPlaceholder: K,
|
|
440
451
|
spinners: !1,
|
|
441
452
|
disabled: !1,
|
|
442
|
-
max: c(
|
|
443
|
-
min: c(
|
|
444
|
-
minTime: c(
|
|
445
|
-
maxTime: c(
|
|
453
|
+
max: c(X),
|
|
454
|
+
min: c(Y),
|
|
455
|
+
minTime: c(G),
|
|
456
|
+
maxTime: c(Z),
|
|
446
457
|
validityStyles: !0,
|
|
447
458
|
validationMessage: te,
|
|
448
459
|
placeholder: null,
|
|
@@ -455,11 +466,11 @@ a.displayName = "DateInput", a.propTypes = {
|
|
|
455
466
|
ariaHasPopup: "grid",
|
|
456
467
|
autoFocus: !1
|
|
457
468
|
};
|
|
458
|
-
let m =
|
|
469
|
+
let m = n;
|
|
459
470
|
const ie = q(), se = B(
|
|
460
471
|
R(
|
|
461
472
|
ie,
|
|
462
|
-
|
|
473
|
+
j(m)
|
|
463
474
|
)
|
|
464
475
|
);
|
|
465
476
|
se.displayName = "KendoReactDateInput";
|