@progress/kendo-react-dateinputs 14.5.0-develop.7 → 14.5.0-develop.9
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 +55 -55
- package/datetimepicker/DateTimeSelector.d.ts +2 -3
- package/datetimepicker/DateTimeSelector.js +1 -1
- package/datetimepicker/DateTimeSelector.mjs +86 -83
- 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 +14 -9
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 strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ae=require("react"),t=require("prop-types"),x=require("@progress/kendo-date-math"),ne=require("@progress/kendo-react-buttons"),ae=require("@progress/kendo-svg-icons"),re=require("@progress/kendo-react-intl"),o=require("@progress/kendo-react-common"),pe=require("@progress/kendo-react-labels"),_e=require("@progress/kendo-dateinputs-common"),j=require("./utils.js"),i=require("../utils.js"),c=require("../messages/index.js"),je=require("../timepicker/utils.js"),Be=require("../common/ClearButton.js"),Fe=require("./dateInputIntl.js");function He(e){const b=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const m in e)if(m!=="default"){const C=Object.getOwnPropertyDescriptor(e,m);Object.defineProperty(b,m,C.get?C:{enumerable:!0,get:()=>e[m]})}}return b.default=e,Object.freeze(b)}const r=He(Ae),ze="Please enter a valid value!",F=r.forwardRef((e,b)=>{var te;const m=o.useId(e.id),C=re.useInternationalization(),E=re.useLocalization(),le=o.useUnstyled(),H=o.usePropsContext(B,e).unstyled||le,{format:V=u.format,defaultValue:ue=u.defaultValue,size:ie=u.size,rounded:oe=u.rounded,fillMode:se=u.fillMode,formatPlaceholder:ce=u.formatPlaceholder,spinners:de=u.spinners,disabled:w=u.disabled,min:fe=u.min,max:me=u.max,minTime:ge=u.minTime,maxTime:ve=u.maxTime,validityStyles:be=u.validityStyles,validationMessage:z=u.validationMessage,placeholder:y=u.placeholder,enableMouseWheel:ye=u.enableMouseWheel,autoCorrectParts:he=u.autoCorrectParts,autoSwitchParts:Ie=u.autoSwitchParts,allowCaretMode:Oe=u.allowCaretMode,twoDigitYearMax:De=u.twoDigitYearMax,ariaHasPopup:xe=u.ariaHasPopup,autoFocus:h=u.autoFocus}=o.usePropsContext(B,e),S=n=>{Le(a=>({...a,...n}))},g=()=>N.value?N.value:R.current!==void 0?R.current:l.current&&l.current.value,U=()=>{const n=l.current&&l.current.currentText||"",a=g();return y!=null&&!N.focused&&!a?y:n},W=()=>e.required!==void 0?e.required:!1,q=()=>{const n=g()||e.value,a=fe,D=me,A=j.isInRange(n,a,D)&&je.isInTimeRange(n,ge,ve),p=z!==void 0,_=(!W()||n!=null)&&A,ke=e.valid!==void 0?e.valid:_;return{customError:p,rangeOverflow:n&&D.getTime()<n.getTime()||!1,rangeUnderflow:n&&n.getTime()<a.getTime()||!1,valid:ke,valueMissing:n===null}},Ce=()=>{s.current&&s.current.focus()},K=()=>new Fe.DateInputIntl(C),T=()=>{const n=g();return{format:V,steps:e.steps,formatPlaceholder:ce,placeholder:y,selectPreviousSegmentOnBackspace:!0,value:e.value!==void 0?e.value:n,intlService:K(),autoFill:e.autoFill!==void 0?e.autoFill:!1,enableMouseWheel:ye,autoCorrectParts:he,autoSwitchParts:Ie,autoSwitchKeys:e.autoSwitchKeys||[],twoDigitYearMax:De,allowCaretMode:Oe}},Ee=n=>{d.current&&d.current.classList.add("k-focus"),S({focused:!0}),h&&$(!0)},we=n=>{d.current&&d.current.classList.remove("k-focus"),S({focused:!1})},Se=(n,a)=>typeof n!=typeof a?!0:typeof n=="string"&&typeof a=="string"?n!==a:typeof n=="object"&&typeof a=="object"?JSON.stringify(n)!==JSON.stringify(a):!1,Te=n=>typeof n=="string"?n:{inputFormat:n,displayFormat:n},J=n=>{R.current=g(),e.value===void 0&&S({value:n.value!==void 0?n.value:null}),Ne(),v.current=n,R.current=void 0},Y=n=>{e.onChange&&e.onChange(n)},X=n=>{o.getActiveElement(document)===s.current&&n.preventDefault()},Me=()=>new _e.DateInput(s.current,{...T(),format:Te(T().format),events:{focus:Ee,blur:we,valueChange:J,click:Y}}),Z=()=>{s.current&&s.current.setCustomValidity&&s.current.setCustomValidity(q().valid?"":z||u.validationMessage)},$=r.useCallback(n=>{var a;if(s.current&&h&&n){const D=(l==null?void 0:l.current).currentText,A=(l==null?void 0:l.current).currentText.search(/[^a-zA-Z]/),p=D[A],_=D.split(p)[0].length;d.current&&d.current.classList.add("k-focus"),(a=l==null?void 0:l.current)==null||a.selectNearestSegment(_)}},[h]),Pe=n=>{!s.current||!l.current||J(n)},Re=n=>{n.preventDefault();const a=o.getActiveElement(document);s.current&&a!==s.current&&s.current.focus({preventScroll:!0})},f=n=>{const a=g();v.current&&e.onChange&&!x.isEqual(v.current.oldValue,a)&&e.onChange.call(void 0,{syntheticEvent:n,nativeEvent:v.current.event,value:v.current.value,target:M.current}),v.current=null},Ve=n=>{var a;(a=l.current)==null||a.modifyDateSegmentValue(1),f(n)},qe=n=>{var a;(a=l.current)==null||a.modifyDateSegmentValue(-1),f(n)},M=r.useRef(null),s=r.useRef(null),d=r.useRef(null);r.useImperativeHandle(M,()=>({props:e,get options(){return T()},get text(){return U()},get element(){return s.current},get name(){return e.name},get value(){return g()},get validity(){return q()},focus:Ce,updateOnPaste:Pe})),r.useImperativeHandle(b,()=>M.current);const l=r.useRef(null),P=r.useRef(null),L=r.useRef(!1),R=r.useRef(null),v=r.useRef(null),I=r.useRef(e),[N,Le]=r.useState({value:e.value===void 0?ue:null,focused:!1}),[,Ne]=r.useReducer(n=>n+1,0);r.useLayoutEffect(()=>{L.current||(l.current=Me(),P.current=l.current.dateObject,L.current=!0)},[]),r.useEffect(()=>(Z(),L.current||d.current&&d.current.addEventListener("wheel",X,{passive:!1}),h&&(S({focused:!0}),$(!0)),()=>{d.current&&d.current.removeEventListener("wheel",X)}),[]),r.useEffect(()=>{Z(),l.current&&(P.current=l.current.dateObject,(Se(I.current.format,V)||I.current.readonly!==e.readonly||JSON.stringify(I.current.steps)!==JSON.stringify(e.steps)||K().locale!==l.current.options.intlService.locale)&&l.current.setOptions(T(),!0),I.current.value!==e.value&&(P.current.getValue()!==null||e.value!==null)&&P.current.setValue(e.value),e.ariaExpanded!==void 0&&e.ariaExpanded&&(l.current.options.placeholder=null),e.ariaExpanded!==void 0&&!e.ariaExpanded&&(l.current.options.placeholder=y),l.current.refreshElementValue(),I.current={format:V,readonly:e.readonly,ariaExpanded:e.ariaExpanded,steps:e.steps,value:e.value})});const G=e.id||m+"-accessibility-id",O=H&&H.uDateInput,Q=U(),k=!be||q().valid;r.useImperativeHandle(e._ref,()=>M.current);const ee=r.createElement("span",{ref:n=>{d.current=n},style:e.label?void 0:{width:e.width},dir:e.dir,className:o.classNames(o.uDateInput.wrapper({c:O,size:ie,fillMode:se,rounded:oe,disabled:w,required:W(),invalid:!k}),e.className)},r.createElement("input",{ref:n=>{s.current=n},role:e.ariaRole||"textbox",readOnly:e.readonly,tabIndex:e.tabIndex||0,disabled:w,title:e.title!==void 0?e.title:Q,type:"text",spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoFocus:h,className:o.classNames(o.uDateInput.inputInner({c:O})),id:G,value:Q,"aria-label":e.ariaLabel,"aria-labelledby":e.ariaLabelledBy,"aria-describedby":e.ariaDescribedBy,"aria-haspopup":xe,"aria-disabled":w,"aria-expanded":e.ariaExpanded,"aria-controls":e.ariaControls,"aria-required":e.required,"aria-invalid":!k,onKeyDown:f,onChange:f,onWheel:f,onInput:f,onClick:f,name:e.name,...e.inputAttributes}),e.children,e.clearButton&&e.value&&r.createElement(Be,{onClick:Y,key:"clearbutton"}),de&&r.createElement("span",{className:o.classNames(o.uDateInput.inputSpinner({c:O})),onMouseDown:Re},r.createElement(ne.Button,{tabIndex:-1,type:"button",className:o.classNames(o.uDateInput.spinnerIncrease({c:O})),icon:"caret-alt-up",svgIcon:ae.caretAltUpIcon,"aria-label":E.toLanguageString(c.increaseValue,c.messages[c.increaseValue]),title:E.toLanguageString(c.increaseValue,c.messages[c.increaseValue]),onClick:Ve}),r.createElement(ne.Button,{tabIndex:-1,type:"button",className:o.classNames(o.uDateInput.spinnerDecrease({c:O})),icon:"caret-alt-down",svgIcon:ae.caretAltDownIcon,"aria-label":E.toLanguageString(c.decreaseValue,c.messages[c.decreaseValue]),title:E.toLanguageString(c.decreaseValue,c.messages[c.decreaseValue]),onClick:qe})));return e.label?r.createElement(pe.FloatingLabel,{label:e.label,editorId:G,editorValue:(te=s.current)==null?void 0:te.value,editorValid:k,editorDisabled:w,children:ee,style:{width:e.width}}):ee});F.propTypes={value:t.instanceOf(Date),format:t.oneOfType([i.nullable(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"])})]),formatPlaceholder:t.oneOfType([i.nullable(t.oneOf(["wide","narrow","short","formatPattern"])),t.shape({year:i.nullable(t.string),month:i.nullable(t.string),day:i.nullable(t.string),hour:i.nullable(t.string),minute:i.nullable(t.string),second:i.nullable(t.string)})]),width:t.oneOfType([t.string,t.number]),tabIndex:t.number,title:t.string,steps:t.shape({year:i.nullable(t.number),month:i.nullable(t.number),day:i.nullable(t.number),hour:i.nullable(t.number),minute:i.nullable(t.number),second:i.nullable(t.number)}),min:t.instanceOf(Date),max:t.instanceOf(Date),disabled:t.bool,spinners:t.bool,name:t.string,dir:t.string,label:t.node,id:t.string,ariaLabelledBy:t.string,ariaDescribedBy:t.string,ariaLabel:t.string,ariaRole:t.string,ariaHasPopup:t.oneOfType([t.bool,t.oneOf(["grid","dialog"])]),ariaExpanded:t.oneOfType([t.bool]),onChange:t.func,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"]),autoFocus:t.bool,inputAttributes:t.object};const u={format:j.DEFAULT_FORMAT,defaultValue:null,size:void 0,rounded:void 0,fillMode:void 0,formatPlaceholder:j.DEFAULT_FORMAT_PLACEHOLDER,spinners:!1,disabled:!1,max:x.cloneDate(i.MAX_DATE),min:x.cloneDate(i.MIN_DATE),minTime:x.cloneDate(i.MIN_TIME),maxTime:x.cloneDate(i.MAX_TIME),validityStyles:!0,validationMessage:ze,placeholder:null,enableMouseWheel:!0,autoCorrectParts:!0,autoSwitchParts:!0,allowCaretMode:!1,twoDigitYearMax:68,ariaHasPopup:"grid",autoFocus:!1},B=o.createPropsContext();F.displayName="KendoReactDateInput";exports.DateInput=F;exports.DateInputPropsContext=B;exports.dateInputDefaultProps=u;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const pe=require("react"),t=require("prop-types"),x=require("@progress/kendo-date-math"),ne=require("@progress/kendo-react-buttons"),ae=require("@progress/kendo-svg-icons"),re=require("@progress/kendo-react-intl"),o=require("@progress/kendo-react-common"),Ae=require("@progress/kendo-react-labels"),_e=require("@progress/kendo-dateinputs-common"),j=require("./utils.js"),i=require("../utils.js"),c=require("../messages/index.js"),je=require("../timepicker/utils.js"),Be=require("../common/ClearButton.js"),Fe=require("./dateInputIntl.js");function He(e){const b=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const m in e)if(m!=="default"){const C=Object.getOwnPropertyDescriptor(e,m);Object.defineProperty(b,m,C.get?C:{enumerable:!0,get:()=>e[m]})}}return b.default=e,Object.freeze(b)}const r=He(pe),ze="Please enter a valid value!",F=r.forwardRef((e,b)=>{var te;const m=o.useId(e.id),C=re.useInternationalization(),E=re.useLocalization(),le=o.useUnstyled(),H=o.usePropsContext(B,e).unstyled||le,{format:V=u.format,defaultValue:ue=u.defaultValue,size:ie=u.size,rounded:oe=u.rounded,fillMode:se=u.fillMode,formatPlaceholder:ce=u.formatPlaceholder,spinners:de=u.spinners,disabled:w=u.disabled,min:fe=u.min,max:me=u.max,minTime:ge=u.minTime,maxTime:ve=u.maxTime,validityStyles:be=u.validityStyles,validationMessage:z=u.validationMessage,placeholder:y=u.placeholder,enableMouseWheel:ye=u.enableMouseWheel,autoCorrectParts:he=u.autoCorrectParts,autoSwitchParts:Ie=u.autoSwitchParts,allowCaretMode:Oe=u.allowCaretMode,twoDigitYearMax:De=u.twoDigitYearMax,ariaHasPopup:xe=u.ariaHasPopup,autoFocus:h=u.autoFocus}=o.usePropsContext(B,e),S=n=>{Le(a=>({...a,...n}))},g=()=>N.value?N.value:R.current!==void 0?R.current:l.current&&l.current.value,U=()=>{const n=l.current&&l.current.currentText||"",a=g();return y!=null&&!N.focused&&!a?y:n},W=()=>e.required!==void 0?e.required:!1,q=()=>{const n=g()||e.value,a=fe,D=me,p=j.isInRange(n,a,D)&&je.isInTimeRange(n,ge,ve),A=z!==void 0,_=(!W()||n!=null)&&p,ke=e.valid!==void 0?e.valid:_;return{customError:A,rangeOverflow:n&&D.getTime()<n.getTime()||!1,rangeUnderflow:n&&n.getTime()<a.getTime()||!1,valid:ke,valueMissing:n===null}},Ce=()=>{s.current&&s.current.focus()},K=()=>new Fe.DateInputIntl(C),T=()=>{const n=g();return{format:V,steps:e.steps,formatPlaceholder:ce,placeholder:y,selectPreviousSegmentOnBackspace:!0,value:e.value!==void 0?e.value:n,intlService:K(),autoFill:e.autoFill!==void 0?e.autoFill:!1,enableMouseWheel:ye,autoCorrectParts:he,autoSwitchParts:Ie,autoSwitchKeys:e.autoSwitchKeys||[],twoDigitYearMax:De,allowCaretMode:Oe}},Ee=n=>{d.current&&d.current.classList.add("k-focus"),S({focused:!0}),h&&$(!0)},we=n=>{d.current&&d.current.classList.remove("k-focus"),S({focused:!1})},Se=(n,a)=>typeof n!=typeof a?!0:typeof n=="string"&&typeof a=="string"?n!==a:typeof n=="object"&&typeof a=="object"?JSON.stringify(n)!==JSON.stringify(a):!1,Te=n=>typeof n=="string"?n:{inputFormat:n,displayFormat:n},J=n=>{R.current=g(),e.value===void 0&&S({value:n.value!==void 0?n.value:null}),Ne(),v.current=n,R.current=void 0},Y=n=>{e.onChange&&e.onChange(n)},X=n=>{o.getActiveElement(document)===s.current&&n.preventDefault()},Me=()=>new _e.DateInput(s.current,{...T(),format:Te(T().format),events:{focus:Ee,blur:we,valueChange:J,click:Y}}),Z=()=>{s.current&&s.current.setCustomValidity&&s.current.setCustomValidity(q().valid?"":z||u.validationMessage)},$=r.useCallback(n=>{var a;if(s.current&&h&&n){const D=(l==null?void 0:l.current).currentText,p=(l==null?void 0:l.current).currentText.search(/[^a-zA-Z]/),A=D[p],_=D.split(A)[0].length;d.current&&d.current.classList.add("k-focus"),(a=l==null?void 0:l.current)==null||a.selectNearestSegment(_)}},[h]),Pe=n=>{!s.current||!l.current||J(n)},Re=n=>{n.preventDefault();const a=o.getActiveElement(document);s.current&&a!==s.current&&s.current.focus({preventScroll:!0})},f=n=>{const a=g();v.current&&e.onChange&&!x.isEqual(v.current.oldValue,a)&&e.onChange.call(void 0,{syntheticEvent:n,nativeEvent:v.current.event,value:v.current.value,target:M.current}),v.current=null},Ve=n=>{var a;(a=l.current)==null||a.modifyDateSegmentValue(1),f(n)},qe=n=>{var a;(a=l.current)==null||a.modifyDateSegmentValue(-1),f(n)},M=r.useRef(null),s=r.useRef(null),d=r.useRef(null);r.useImperativeHandle(M,()=>({props:e,get options(){return T()},get text(){return U()},get element(){return s.current},get name(){return e.name},get value(){return g()},get validity(){return q()},focus:Ce,updateOnPaste:Pe})),r.useImperativeHandle(b,()=>M.current);const l=r.useRef(null),P=r.useRef(null),L=r.useRef(!1),R=r.useRef(null),v=r.useRef(null),I=r.useRef(e),[N,Le]=r.useState({value:e.value===void 0?ue:null,focused:!1}),[,Ne]=r.useReducer(n=>n+1,0);r.useLayoutEffect(()=>{L.current||(l.current=Me(),P.current=l.current.dateObject,L.current=!0)},[]),r.useEffect(()=>(Z(),L.current||d.current&&d.current.addEventListener("wheel",X,{passive:!1}),h&&(S({focused:!0}),$(!0)),()=>{d.current&&d.current.removeEventListener("wheel",X)}),[]),r.useEffect(()=>{Z(),l.current&&(P.current=l.current.dateObject,(Se(I.current.format,V)||I.current.readonly!==e.readonly||JSON.stringify(I.current.steps)!==JSON.stringify(e.steps)||K().locale!==l.current.options.intlService.locale)&&l.current.setOptions(T(),!0),I.current.value!==e.value&&(P.current.getValue()!==null||e.value!==null)&&P.current.setValue(e.value),e.ariaExpanded!==void 0&&e.ariaExpanded&&(l.current.options.placeholder=null),e.ariaExpanded!==void 0&&!e.ariaExpanded&&(l.current.options.placeholder=y),l.current.refreshElementValue(),I.current={format:V,readonly:e.readonly,ariaExpanded:e.ariaExpanded,steps:e.steps,value:e.value})});const G=e.id||m+"-accessibility-id",O=H&&H.uDateInput,Q=U(),k=!be||q().valid;r.useImperativeHandle(e._ref,()=>M.current);const ee=r.createElement("span",{ref:n=>{d.current=n},style:e.label?void 0:{width:e.width},dir:e.dir,className:o.classNames(o.uDateInput.wrapper({c:O,size:ie,fillMode:se,rounded:oe,disabled:w,required:W(),invalid:!k}),e.className)},r.createElement("input",{ref:n=>{s.current=n},role:e.ariaRole||"textbox",readOnly:e.readonly,tabIndex:e.tabIndex||0,disabled:w,title:e.title!==void 0?e.title:Q,type:"text",spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoFocus:h,className:o.classNames(o.uDateInput.inputInner({c:O})),id:G,value:Q,"aria-label":e.ariaLabel,"aria-labelledby":e.ariaLabelledBy,"aria-describedby":e.ariaDescribedBy,"aria-haspopup":xe,"aria-disabled":w,"aria-expanded":e.ariaExpanded,"aria-controls":e.ariaControls,"aria-required":e.required,"aria-invalid":!k,onKeyDown:f,onChange:f,onWheel:f,onInput:f,onClick:f,name:e.name,...e.inputAttributes}),e.children,e.clearButton&&e.value&&r.createElement(Be,{onClick:Y,key:"clearbutton"}),de&&r.createElement("span",{className:o.classNames(o.uDateInput.inputSpinner({c:O})),onMouseDown:Re},r.createElement(ne.Button,{tabIndex:-1,type:"button",className:o.classNames(o.uDateInput.spinnerIncrease({c:O})),icon:"chevron-up",svgIcon:ae.chevronUpIcon,"aria-label":E.toLanguageString(c.increaseValue,c.messages[c.increaseValue]),title:E.toLanguageString(c.increaseValue,c.messages[c.increaseValue]),onClick:Ve}),r.createElement(ne.Button,{tabIndex:-1,type:"button",className:o.classNames(o.uDateInput.spinnerDecrease({c:O})),icon:"chevron-down",svgIcon:ae.chevronDownIcon,"aria-label":E.toLanguageString(c.decreaseValue,c.messages[c.decreaseValue]),title:E.toLanguageString(c.decreaseValue,c.messages[c.decreaseValue]),onClick:qe})));return e.label?r.createElement(Ae.FloatingLabel,{label:e.label,editorId:G,editorValue:(te=s.current)==null?void 0:te.value,editorValid:k,editorDisabled:w,children:ee,style:{width:e.width}}):ee});F.propTypes={value:t.instanceOf(Date),format:t.oneOfType([i.nullable(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"])})]),formatPlaceholder:t.oneOfType([i.nullable(t.oneOf(["wide","narrow","short","formatPattern"])),t.shape({year:i.nullable(t.string),month:i.nullable(t.string),day:i.nullable(t.string),hour:i.nullable(t.string),minute:i.nullable(t.string),second:i.nullable(t.string)})]),width:t.oneOfType([t.string,t.number]),tabIndex:t.number,title:t.string,steps:t.shape({year:i.nullable(t.number),month:i.nullable(t.number),day:i.nullable(t.number),hour:i.nullable(t.number),minute:i.nullable(t.number),second:i.nullable(t.number)}),min:t.instanceOf(Date),max:t.instanceOf(Date),disabled:t.bool,spinners:t.bool,name:t.string,dir:t.string,label:t.node,id:t.string,ariaLabelledBy:t.string,ariaDescribedBy:t.string,ariaLabel:t.string,ariaRole:t.string,ariaHasPopup:t.oneOfType([t.bool,t.oneOf(["grid","dialog"])]),ariaExpanded:t.oneOfType([t.bool]),onChange:t.func,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"]),autoFocus:t.bool,inputAttributes:t.object};const u={format:j.DEFAULT_FORMAT,defaultValue:null,size:void 0,rounded:void 0,fillMode:void 0,formatPlaceholder:j.DEFAULT_FORMAT_PLACEHOLDER,spinners:!1,disabled:!1,max:x.cloneDate(i.MAX_DATE),min:x.cloneDate(i.MIN_DATE),minTime:x.cloneDate(i.MIN_TIME),maxTime:x.cloneDate(i.MAX_TIME),validityStyles:!0,validationMessage:ze,placeholder:null,enableMouseWheel:!0,autoCorrectParts:!0,autoSwitchParts:!0,allowCaretMode:!1,twoDigitYearMax:68,ariaHasPopup:"grid",autoFocus:!1},B=o.createPropsContext();F.displayName="KendoReactDateInput";exports.DateInput=F;exports.DateInputPropsContext=B;exports.dateInputDefaultProps=u;
|
package/dateinput/DateInput.mjs
CHANGED
|
@@ -9,22 +9,22 @@ import * as r from "react";
|
|
|
9
9
|
import e from "prop-types";
|
|
10
10
|
import { cloneDate as M, isEqual as Fe } from "@progress/kendo-date-math";
|
|
11
11
|
import { Button as Q } from "@progress/kendo-react-buttons";
|
|
12
|
-
import {
|
|
12
|
+
import { chevronUpIcon as He, chevronDownIcon as Be } from "@progress/kendo-svg-icons";
|
|
13
13
|
import { useInternationalization as qe, useLocalization as ze } from "@progress/kendo-react-intl";
|
|
14
|
-
import { useId as je, useUnstyled as Ue, usePropsContext as ee, classNames as
|
|
14
|
+
import { useId as je, useUnstyled as Ue, usePropsContext as ee, classNames as b, uDateInput as O, createPropsContext as We, getActiveElement as te } from "@progress/kendo-react-common";
|
|
15
15
|
import { FloatingLabel as Ke } from "@progress/kendo-react-labels";
|
|
16
16
|
import { DateInput as Je } from "@progress/kendo-dateinputs-common";
|
|
17
17
|
import { DEFAULT_FORMAT_PLACEHOLDER as Ye, DEFAULT_FORMAT as Xe, isInRange as Ze } from "./utils.mjs";
|
|
18
|
-
import { MAX_TIME as Ge, MIN_TIME as $e, MIN_DATE as Qe, MAX_DATE as et, nullable as
|
|
18
|
+
import { MAX_TIME as Ge, MIN_TIME as $e, MIN_DATE as Qe, MAX_DATE as et, nullable as u } from "../utils.mjs";
|
|
19
19
|
import { increaseValue as S, messages as P, decreaseValue as R } from "../messages/index.mjs";
|
|
20
20
|
import { isInTimeRange as tt } from "../timepicker/utils.mjs";
|
|
21
21
|
import nt from "../common/ClearButton.mjs";
|
|
22
22
|
import { DateInputIntl as at } from "./dateInputIntl.mjs";
|
|
23
23
|
const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
24
24
|
var $;
|
|
25
|
-
const ie = je(t.id), le = qe(), E = ze(),
|
|
25
|
+
const ie = je(t.id), le = qe(), E = ze(), oe = Ue(), H = ee(ne, t).unstyled || oe, {
|
|
26
26
|
format: L = l.format,
|
|
27
|
-
defaultValue:
|
|
27
|
+
defaultValue: ue = l.defaultValue,
|
|
28
28
|
size: se = l.size,
|
|
29
29
|
rounded: ce = l.rounded,
|
|
30
30
|
fillMode: de = l.fillMode,
|
|
@@ -33,9 +33,9 @@ const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
|
33
33
|
disabled: I = l.disabled,
|
|
34
34
|
min: ge = l.min,
|
|
35
35
|
max: ve = l.max,
|
|
36
|
-
minTime:
|
|
37
|
-
maxTime:
|
|
38
|
-
validityStyles:
|
|
36
|
+
minTime: he = l.minTime,
|
|
37
|
+
maxTime: ye = l.maxTime,
|
|
38
|
+
validityStyles: be = l.validityStyles,
|
|
39
39
|
validationMessage: B = l.validationMessage,
|
|
40
40
|
placeholder: m = l.placeholder,
|
|
41
41
|
enableMouseWheel: Oe = l.enableMouseWheel,
|
|
@@ -47,20 +47,20 @@ const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
|
47
47
|
autoFocus: g = l.autoFocus
|
|
48
48
|
} = ee(ne, t), x = (n) => {
|
|
49
49
|
pe((a) => ({ ...a, ...n }));
|
|
50
|
-
}, d = () =>
|
|
50
|
+
}, d = () => A.value ? A.value : T.current !== void 0 ? T.current : i.current && i.current.value, q = () => {
|
|
51
51
|
const n = i.current && i.current.currentText || "", a = d();
|
|
52
|
-
return m != null && !
|
|
52
|
+
return m != null && !A.focused && !a ? m : n;
|
|
53
53
|
}, z = () => t.required !== void 0 ? t.required : !1, V = () => {
|
|
54
|
-
const n = d() || t.value, a = ge,
|
|
54
|
+
const n = d() || t.value, a = ge, y = ve, k = Ze(n, a, y) && tt(n, he, ye), _ = B !== void 0, F = (!z() || n != null) && k, _e = t.valid !== void 0 ? t.valid : F;
|
|
55
55
|
return {
|
|
56
56
|
customError: _,
|
|
57
|
-
rangeOverflow: n &&
|
|
57
|
+
rangeOverflow: n && y.getTime() < n.getTime() || !1,
|
|
58
58
|
rangeUnderflow: n && n.getTime() < a.getTime() || !1,
|
|
59
59
|
valid: _e,
|
|
60
60
|
valueMissing: n === null
|
|
61
61
|
};
|
|
62
62
|
}, De = () => {
|
|
63
|
-
|
|
63
|
+
o.current && o.current.focus();
|
|
64
64
|
}, j = () => new at(le), C = () => {
|
|
65
65
|
const n = d();
|
|
66
66
|
return {
|
|
@@ -91,8 +91,8 @@ const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
|
91
91
|
}, W = (n) => {
|
|
92
92
|
t.onChange && t.onChange(n);
|
|
93
93
|
}, K = (n) => {
|
|
94
|
-
te(document) ===
|
|
95
|
-
}, Re = () => new Je(
|
|
94
|
+
te(document) === o.current && n.preventDefault();
|
|
95
|
+
}, Re = () => new Je(o.current, {
|
|
96
96
|
...C(),
|
|
97
97
|
format: Pe(C().format),
|
|
98
98
|
events: {
|
|
@@ -102,24 +102,24 @@ const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
|
102
102
|
click: W
|
|
103
103
|
}
|
|
104
104
|
}), J = () => {
|
|
105
|
-
|
|
105
|
+
o.current && o.current.setCustomValidity && o.current.setCustomValidity(
|
|
106
106
|
V().valid ? "" : B || l.validationMessage
|
|
107
107
|
);
|
|
108
108
|
}, Y = r.useCallback(
|
|
109
109
|
(n) => {
|
|
110
110
|
var a;
|
|
111
|
-
if (
|
|
112
|
-
const
|
|
111
|
+
if (o.current && g && n) {
|
|
112
|
+
const y = (i == null ? void 0 : i.current).currentText, k = (i == null ? void 0 : i.current).currentText.search(/[^a-zA-Z]/), _ = y[k], F = y.split(_)[0].length;
|
|
113
113
|
s.current && s.current.classList.add("k-focus"), (a = i == null ? void 0 : i.current) == null || a.selectNearestSegment(F);
|
|
114
114
|
}
|
|
115
115
|
},
|
|
116
116
|
[g]
|
|
117
117
|
), Le = (n) => {
|
|
118
|
-
!
|
|
118
|
+
!o.current || !i.current || U(n);
|
|
119
119
|
}, Ve = (n) => {
|
|
120
120
|
n.preventDefault();
|
|
121
121
|
const a = te(document);
|
|
122
|
-
|
|
122
|
+
o.current && a !== o.current && o.current.focus({ preventScroll: !0 });
|
|
123
123
|
}, c = (n) => {
|
|
124
124
|
const a = d();
|
|
125
125
|
f.current && t.onChange && !Fe(f.current.oldValue, a) && t.onChange.call(void 0, {
|
|
@@ -128,13 +128,13 @@ const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
|
128
128
|
value: f.current.value,
|
|
129
129
|
target: w.current
|
|
130
130
|
}), f.current = null;
|
|
131
|
-
},
|
|
131
|
+
}, Ne = (n) => {
|
|
132
132
|
var a;
|
|
133
133
|
(a = i.current) == null || a.modifyDateSegmentValue(1), c(n);
|
|
134
|
-
},
|
|
134
|
+
}, Ae = (n) => {
|
|
135
135
|
var a;
|
|
136
136
|
(a = i.current) == null || a.modifyDateSegmentValue(-1), c(n);
|
|
137
|
-
}, w = r.useRef(null),
|
|
137
|
+
}, w = r.useRef(null), o = r.useRef(null), s = r.useRef(null);
|
|
138
138
|
r.useImperativeHandle(
|
|
139
139
|
w,
|
|
140
140
|
() => ({
|
|
@@ -146,7 +146,7 @@ const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
|
146
146
|
return q();
|
|
147
147
|
},
|
|
148
148
|
get element() {
|
|
149
|
-
return
|
|
149
|
+
return o.current;
|
|
150
150
|
},
|
|
151
151
|
get name() {
|
|
152
152
|
return t.name;
|
|
@@ -162,13 +162,13 @@ const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
|
162
162
|
updateOnPaste: Le
|
|
163
163
|
})
|
|
164
164
|
), r.useImperativeHandle(re, () => w.current);
|
|
165
|
-
const i = r.useRef(null), D = r.useRef(null),
|
|
166
|
-
value: t.value === void 0 ?
|
|
165
|
+
const i = r.useRef(null), D = r.useRef(null), N = r.useRef(!1), T = r.useRef(null), f = r.useRef(null), v = r.useRef(t), [A, pe] = r.useState({
|
|
166
|
+
value: t.value === void 0 ? ue : null,
|
|
167
167
|
focused: !1
|
|
168
168
|
}), [, ke] = r.useReducer((n) => n + 1, 0);
|
|
169
169
|
r.useLayoutEffect(() => {
|
|
170
|
-
|
|
171
|
-
}, []), r.useEffect(() => (J(),
|
|
170
|
+
N.current || (i.current = Re(), D.current = i.current.dateObject, N.current = !0);
|
|
171
|
+
}, []), r.useEffect(() => (J(), N.current || s.current && s.current.addEventListener("wheel", K, { passive: !1 }), g && (x({ focused: !0 }), Y(!0)), () => {
|
|
172
172
|
s.current && s.current.removeEventListener("wheel", K);
|
|
173
173
|
}), []), r.useEffect(() => {
|
|
174
174
|
J(), i.current && (D.current = i.current.dateObject, (Se(v.current.format, L) || v.current.readonly !== t.readonly || JSON.stringify(v.current.steps) !== JSON.stringify(t.steps) || j().locale !== i.current.options.intlService.locale) && i.current.setOptions(C(), !0), v.current.value !== t.value && (D.current.getValue() !== null || t.value !== null) && D.current.setValue(t.value), t.ariaExpanded !== void 0 && t.ariaExpanded && (i.current.options.placeholder = null), t.ariaExpanded !== void 0 && !t.ariaExpanded && (i.current.options.placeholder = m), i.current.refreshElementValue(), v.current = {
|
|
@@ -179,7 +179,7 @@ const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
|
179
179
|
value: t.value
|
|
180
180
|
});
|
|
181
181
|
});
|
|
182
|
-
const X = t.id || ie + "-accessibility-id",
|
|
182
|
+
const X = t.id || ie + "-accessibility-id", h = H && H.uDateInput, Z = q(), p = !be || V().valid;
|
|
183
183
|
r.useImperativeHandle(t._ref, () => w.current);
|
|
184
184
|
const G = /* @__PURE__ */ r.createElement(
|
|
185
185
|
"span",
|
|
@@ -189,9 +189,9 @@ const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
|
189
189
|
},
|
|
190
190
|
style: t.label ? void 0 : { width: t.width },
|
|
191
191
|
dir: t.dir,
|
|
192
|
-
className:
|
|
192
|
+
className: b(
|
|
193
193
|
O.wrapper({
|
|
194
|
-
c:
|
|
194
|
+
c: h,
|
|
195
195
|
size: se,
|
|
196
196
|
fillMode: de,
|
|
197
197
|
rounded: ce,
|
|
@@ -206,7 +206,7 @@ const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
|
206
206
|
"input",
|
|
207
207
|
{
|
|
208
208
|
ref: (n) => {
|
|
209
|
-
|
|
209
|
+
o.current = n;
|
|
210
210
|
},
|
|
211
211
|
role: t.ariaRole || "textbox",
|
|
212
212
|
readOnly: t.readonly,
|
|
@@ -218,7 +218,7 @@ const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
|
218
218
|
autoComplete: "off",
|
|
219
219
|
autoCorrect: "off",
|
|
220
220
|
autoFocus: g,
|
|
221
|
-
className:
|
|
221
|
+
className: b(O.inputInner({ c: h })),
|
|
222
222
|
id: X,
|
|
223
223
|
value: Z,
|
|
224
224
|
"aria-label": t.ariaLabel,
|
|
@@ -241,29 +241,29 @@ const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
|
241
241
|
),
|
|
242
242
|
t.children,
|
|
243
243
|
t.clearButton && t.value && /* @__PURE__ */ r.createElement(nt, { onClick: W, key: "clearbutton" }),
|
|
244
|
-
me && /* @__PURE__ */ r.createElement("span", { className:
|
|
244
|
+
me && /* @__PURE__ */ r.createElement("span", { className: b(O.inputSpinner({ c: h })), onMouseDown: Ve }, /* @__PURE__ */ r.createElement(
|
|
245
245
|
Q,
|
|
246
246
|
{
|
|
247
247
|
tabIndex: -1,
|
|
248
248
|
type: "button",
|
|
249
|
-
className:
|
|
250
|
-
icon: "
|
|
249
|
+
className: b(O.spinnerIncrease({ c: h })),
|
|
250
|
+
icon: "chevron-up",
|
|
251
251
|
svgIcon: He,
|
|
252
252
|
"aria-label": E.toLanguageString(S, P[S]),
|
|
253
253
|
title: E.toLanguageString(S, P[S]),
|
|
254
|
-
onClick:
|
|
254
|
+
onClick: Ne
|
|
255
255
|
}
|
|
256
256
|
), /* @__PURE__ */ r.createElement(
|
|
257
257
|
Q,
|
|
258
258
|
{
|
|
259
259
|
tabIndex: -1,
|
|
260
260
|
type: "button",
|
|
261
|
-
className:
|
|
262
|
-
icon: "
|
|
261
|
+
className: b(O.spinnerDecrease({ c: h })),
|
|
262
|
+
icon: "chevron-down",
|
|
263
263
|
svgIcon: Be,
|
|
264
264
|
"aria-label": E.toLanguageString(R, P[R]),
|
|
265
265
|
title: E.toLanguageString(R, P[R]),
|
|
266
|
-
onClick:
|
|
266
|
+
onClick: Ae
|
|
267
267
|
}
|
|
268
268
|
))
|
|
269
269
|
);
|
|
@@ -272,7 +272,7 @@ const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
|
272
272
|
{
|
|
273
273
|
label: t.label,
|
|
274
274
|
editorId: X,
|
|
275
|
-
editorValue: ($ =
|
|
275
|
+
editorValue: ($ = o.current) == null ? void 0 : $.value,
|
|
276
276
|
editorValid: p,
|
|
277
277
|
editorDisabled: I,
|
|
278
278
|
children: G,
|
|
@@ -283,7 +283,7 @@ const rt = "Please enter a valid value!", ae = r.forwardRef((t, re) => {
|
|
|
283
283
|
ae.propTypes = {
|
|
284
284
|
value: e.instanceOf(Date),
|
|
285
285
|
format: e.oneOfType([
|
|
286
|
-
|
|
286
|
+
u(e.string),
|
|
287
287
|
e.shape({
|
|
288
288
|
skeleton: e.string,
|
|
289
289
|
pattern: e.string,
|
|
@@ -303,28 +303,28 @@ ae.propTypes = {
|
|
|
303
303
|
})
|
|
304
304
|
]),
|
|
305
305
|
formatPlaceholder: e.oneOfType([
|
|
306
|
-
|
|
306
|
+
u(
|
|
307
307
|
e.oneOf(["wide", "narrow", "short", "formatPattern"])
|
|
308
308
|
),
|
|
309
309
|
e.shape({
|
|
310
|
-
year:
|
|
311
|
-
month:
|
|
312
|
-
day:
|
|
313
|
-
hour:
|
|
314
|
-
minute:
|
|
315
|
-
second:
|
|
310
|
+
year: u(e.string),
|
|
311
|
+
month: u(e.string),
|
|
312
|
+
day: u(e.string),
|
|
313
|
+
hour: u(e.string),
|
|
314
|
+
minute: u(e.string),
|
|
315
|
+
second: u(e.string)
|
|
316
316
|
})
|
|
317
317
|
]),
|
|
318
318
|
width: e.oneOfType([e.string, e.number]),
|
|
319
319
|
tabIndex: e.number,
|
|
320
320
|
title: e.string,
|
|
321
321
|
steps: e.shape({
|
|
322
|
-
year:
|
|
323
|
-
month:
|
|
324
|
-
day:
|
|
325
|
-
hour:
|
|
326
|
-
minute:
|
|
327
|
-
second:
|
|
322
|
+
year: u(e.number),
|
|
323
|
+
month: u(e.number),
|
|
324
|
+
day: u(e.number),
|
|
325
|
+
hour: u(e.number),
|
|
326
|
+
minute: u(e.number),
|
|
327
|
+
second: u(e.number)
|
|
328
328
|
}),
|
|
329
329
|
min: e.instanceOf(Date),
|
|
330
330
|
max: e.instanceOf(Date),
|
|
@@ -75,7 +75,7 @@ export declare class DateTimeSelector extends React.Component<DateTimeSelectorPr
|
|
|
75
75
|
private _timePart;
|
|
76
76
|
private _cancelButton;
|
|
77
77
|
private _acceptButton;
|
|
78
|
-
private
|
|
78
|
+
private _buttonGroupRef;
|
|
79
79
|
private _calendarWrap;
|
|
80
80
|
private shouldFocusPart;
|
|
81
81
|
get calendar(): Calendar | null;
|
|
@@ -100,8 +100,7 @@ export declare class DateTimeSelector extends React.Component<DateTimeSelectorPr
|
|
|
100
100
|
private handleNowClick;
|
|
101
101
|
private handleCalendarValueChange;
|
|
102
102
|
private handleTimeListContainerChange;
|
|
103
|
-
private
|
|
104
|
-
private handleTimeClick;
|
|
103
|
+
private readonly handleTabChange;
|
|
105
104
|
private handleKeyDown;
|
|
106
105
|
private handleCancelKeyDown;
|
|
107
106
|
private handleSetKeyDown;
|
|
@@ -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 E=require("react"),
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("react"),D=require("@progress/kendo-react-intl"),r=require("../messages/index.js"),f=require("@progress/kendo-react-buttons"),N=require("../calendar/components/Calendar.js"),S=require("../timepicker/TimePart.js"),c=require("../utils.js"),y=require("@progress/kendo-date-math"),a=require("@progress/kendo-react-common"),b=require("../timepicker/utils.js");function V(d){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(d){for(const e in d)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(d,e);Object.defineProperty(s,e,t.get?t:{enumerable:!0,get:()=>d[e]})}}return s.default=d,Object.freeze(s)}const o=V(E),v=class v extends o.Component{constructor(s){super(s),this._calendar=null,this._timePart=null,this._cancelButton=null,this._acceptButton=null,this._buttonGroupRef=null,this._calendarWrap=null,this.shouldFocusPart=!1,this.focus=e=>{Promise.resolve().then(()=>{this.state.tab==="time"&&this._timePart&&this._timePart.focus(e);const t=this.calendarElement();this.state.tab==="date"&&t&&t.focus(e)})},this.calendarElement=()=>this._calendar&&this._calendar.element||this._calendarWrap&&this._calendarWrap.querySelector(".k-calendar"),this.move=e=>{if(e==="right"&&this.state.tab==="time"||e==="left"&&this.state.tab==="date")return;const t=e==="left"?"date":"time";this.shouldFocusPart=!0,this.setState({tab:t})},this.dateTimeFooter=()=>{const{cancelButton:e,unstyled:t}=this.props,i=t&&t.uDateTimePicker,n=this.localizationService.toLanguageString(r.dateTimePickerCancel,r.messages[r.dateTimePickerCancel]),h=this.localizationService.toLanguageString(r.dateTimePickerSet,r.messages[r.dateTimePickerSet]);return o.createElement("div",{className:a.classNames(a.uDateTimePicker.timeFooter({c:i}))},o.createElement(f.Button,{type:"button",themeColor:"primary",ref:l=>{this._acceptButton=l},className:a.classNames(a.uTime.accept({c:i})),disabled:!this.hasDateValue,onClick:this.handleAccept,onKeyDown:this.handleSetKeyDown,title:h,"aria-label":h},h),e&&o.createElement(f.Button,{type:"button",ref:l=>{this._cancelButton=l},className:a.classNames(a.uTime.cancel({c:i})),onClick:this.handleReject,onKeyDown:this.handleCancelKeyDown,title:n,"aria-label":n},n))},this.handleReject=e=>{this.setState({dateValue:this.props.value,timeValue:this.props.value||c.MIDNIGHT_DATE});const t=this.mergeDate(this.props.value,this.props.value||c.MIDNIGHT_DATE);if(this.props.onReject){const i={nativeEvent:e.nativeEvent,syntheticEvent:e,target:this,value:t};this.props.onReject.call(void 0,i)}},this.handleAccept=(e,t)=>{if(!this.state.dateValue||!this.state.timeValue||!this.hasDateValue)return;const i=t||(this._timePart?this._timePart.value:this.state.timeValue),n=this.mergeDate(this.state.dateValue,i);this.props.onChange.call(void 0,{syntheticEvent:e,nativeEvent:e.nativeEvent,value:n,target:this})},this.handleNowClick=e=>{this.setState({timeValue:b.getNow()}),this.handleAccept(e,b.getNow())},this.handleCalendarValueChange=e=>{e.syntheticEvent.stopPropagation(),this.setState({dateValue:e.value,tab:"time"}),this.shouldFocusPart=!0},this.handleTimeListContainerChange=e=>{this.setState({timeValue:e})},this.handleTabChange=e=>{const t=e==="date"?"left":"right";this.move(t)},this.handleKeyDown=e=>{const{keyCode:t,altKey:i}=e;if(!this.props.disabled)switch(t){case a.Keys.enter:!this.hasActiveButton()&&this.hasDateValue&&this.handleAccept(e);return;case a.Keys.left:if(!i)return;this.move("left");return;case a.Keys.right:if(!i)return;this.move("right");return;default:return}},this.handleCancelKeyDown=e=>{var n;const{keyCode:t}=e,i=(n=this._buttonGroupRef)==null?void 0:n.querySelector(".k-segmented-control-button");t===a.Keys.tab&&i&&(e.preventDefault(),i.focus())},this.handleSetKeyDown=e=>{var n;const{keyCode:t}=e,i=(n=this._buttonGroupRef)==null?void 0:n.querySelector(".k-segmented-control-button");t===a.Keys.tab&&!this.props.cancelButton&&i&&(e.preventDefault(),i.focus())},this.handleDateKeyDown=e=>{var n,h,l;const{keyCode:t,shiftKey:i}=e;i&&t===a.Keys.tab&&(e.stopPropagation(),(n=this._cancelButton)!=null&&n.element?this._cancelButton.element.focus():(l=(h=this._acceptButton)==null?void 0:h.element)==null||l.focus()),t===a.Keys.enter&&e.stopPropagation()},this.handleTimeKeyDown=e=>{const{keyCode:t}=e;t===a.Keys.enter&&e.stopPropagation()},this.handleTimePartMount=e=>{this.setState({timeValue:e})},this.state={tab:"date",dateValue:this.props.value,timeValue:this.props.value||c.MIDNIGHT_DATE}}get calendar(){return this._calendar}get timePart(){return this._timePart}get hasDateValue(){return this.state.dateValue!==null}get localizationService(){return D.provideLocalizationService(this)}componentDidUpdate(s,e){var t,i;this.shouldFocusPart&&this.focus({preventScroll:!0}),(((t=s.value)==null?void 0:t.getTime())!==((i=this.props.value)==null?void 0:i.getTime())||this.state.tab!==e.tab&&this.props.value)&&this.setState(n=>({dateValue:s.value&&this.props.value&&y.isEqualDate(s.value,this.props.value)?n.dateValue:this.props.value,timeValue:this.props.value||c.MIDNIGHT_DATE})),this.shouldFocusPart=!1}render(){const{disabled:s,min:e,max:t,weekNumber:i,focusedDate:n,format:h,mobileMode:l,footerActions:_,unstyled:g}=this.props,m=g&&g.uDateTimePicker,P=a.classNames(a.uDateTimePicker.wrap({c:m,date:this.state.tab==="date",time:this.state.tab==="time",disabled:s})),C=this.localizationService.toLanguageString(r.date,r.messages[r.date]),k=this.localizationService.toLanguageString(r.time,r.messages[r.time]),T={min:e,max:t,weekNumber:i,focusedDate:n,disabled:s||this.state.tab!=="date",value:this.state.dateValue,onChange:this.handleCalendarValueChange,navigation:!1,tabIndex:s||this.state.tab!=="date"?-1:void 0,mobileMode:l};return o.createElement("div",{onKeyDown:this.handleKeyDown,className:P,tabIndex:-1},o.createElement("div",{className:a.classNames(a.uDateTimePicker.buttonGroup({c:m})),ref:u=>{this._buttonGroupRef=u}},o.createElement(f.SegmentedControl,{layoutMode:"stretch",size:l?"large":void 0,value:this.state.tab,onChange:this.handleTabChange,items:[{value:"date",text:C,onKeyDown:this.handleDateKeyDown},{value:"time",text:k,onKeyDown:this.handleTimeKeyDown}]})),o.createElement("div",{className:a.classNames(a.uDateTimePicker.selector({c:m}))},o.createElement("div",{className:a.classNames(a.uDateTimePicker.calendarWrap({c:m})),ref:u=>{this._calendarWrap=u}},this.props.calendar?o.createElement(this.props.calendar,{key:this.state.tab,...T}):o.createElement(N.Calendar,{key:this.state.tab,ref:u=>{this._calendar=u},...T})),o.createElement("div",{className:a.classNames(a.uDateTimePicker.timeWrap({c:m}))},o.createElement("div",{className:a.classNames(a.uDateTimePicker.timeSelector({c:m,mobileMode:l}))},o.createElement(S.TimePart,{key:1,onNowClick:this.handleNowClick,disabled:s||this.state.tab!=="time",ref:u=>{this._timePart=u},min:this.minTime||c.MIN_TIME,max:this.maxTime||c.MAX_TIME,steps:this.props.steps,value:this.state.timeValue,format:h,onChange:this.handleTimeListContainerChange,onMount:this.handleTimePartMount,mobileMode:l,unstyled:g})))),_&&this.dateTimeFooter())}get minTime(){return this.props.minTime!==void 0?this.props.minTime:this.normalizeRange(this.props.min,this.state.dateValue)}get maxTime(){return this.props.maxTime!==void 0?this.props.maxTime:this.normalizeRange(this.props.max,this.state.dateValue)}normalizeRange(s,e){return y.isEqualDate(s,e||c.getToday())?s:null}hasActiveButton(){if(!this._acceptButton)return!1;const s=a.getActiveElement(document);return this._acceptButton&&s===this._acceptButton.element||this._cancelButton&&s===this._cancelButton.element}mergeTime(s,e){return s&&e?c.setTime(e,s):e}mergeDate(s,e){return s?c.setTime(s||c.getToday(),e):e}};v.defaultProps={footerActions:!0};let p=v;D.registerForLocalization(p);exports.DateTimeSelector=p;
|