@progress/kendo-react-dateinputs 10.2.0-develop.2 → 10.2.0-develop.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/calendar/components/ViewList.js +1 -1
- package/calendar/components/ViewList.mjs +3 -1
- package/dateinput/DateInput.js +1 -1
- package/dateinput/DateInput.mjs +6 -2
- package/datetimepicker/DateTimeSelector.js +1 -1
- package/datetimepicker/DateTimeSelector.mjs +6 -2
- package/dist/cdn/js/kendo-react-dateinputs.js +1 -1
- package/index.d.mts +20 -20
- package/index.d.ts +20 -20
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +8 -8
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("react"),o=require("prop-types"),n=require("@progress/kendo-react-common"),m=require("@progress/kendo-date-math"),C=require("@progress/kendo-react-intl"),N=require("../../virtualization/Virtualization.js"),O=require("./View.js"),q=require("./Header.js"),H=require("../services/WeekNamesService.js"),f=require("../../utils.js"),p=require("../models/CalendarViewEnum.js"),R=require("./TodayCommand.js");function z(d){const r=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(r,e,t.get?t:{enumerable:!0,get:()=>d[e]})}}return r.default=d,Object.freeze(r)}const a=z(T),_=5,u=class u extends a.Component{constructor(r){super(r),this.virtualization=null,this.calendarView=null,this.table=null,this.intl=null,this.bottomOffset=0,this.viewOffset=0,this.viewHeight=0,this._element=null,this.isActive=!1,this.animateToIndex=!0,this.shouldScroll=!1,this.weekService=null,this.focusActiveDate=()=>{if(!this._element)return;const e=this._element.querySelector("td.k-focus"),t=this._element.querySelector(".k-state-pending-focus");e&&e[0]&&e[0].classList.remove("k-focus"),t&&t.classList.add("k-focus"),this.isActive=!0},this.blurActiveDate=()=>{if(!this._element)return;const e=this._element.querySelector("td.k-focus");e&&e.classList.remove("k-focus"),this.isActive=!1},this.handleVirtualizationMount=e=>{if(this.virtualization=e,this.virtualization&&this.table){this.table.style.transform=`translateY(${this.viewOffset}px)`;const t=f.dateInRange(this.props.focusedDate,this.props.min,this.props.max),s=this.props.service.skip(t,this.props.min);this.virtualization.scrollToIndex(s)}},this.buildMonthView=(e,t)=>{const{unstyled:s}=this.props,i=s&&s.uCalendar;return a.createElement("table",{key:"calendar-view-list-weekdays",className:n.classNames(n.uCalendar.table({c:i,weekdays:!0})),role:"grid",tabIndex:this.props.tabIndex},a.createElement("colgroup",null,e.map((h,l)=>a.createElement("col",{key:l}))),a.createElement("thead",{className:n.classNames(n.uCalendar.thead({c:i}))},a.createElement("tr",{className:n.classNames(n.uCalendar.tr({c:i}))},t.map((h,l)=>a.createElement("th",{key:l,className:n.classNames(n.uCalendar.th({c:i}))},h)))))},this.buildDates=(e,t)=>{const s=this.props.cellUID,{unstyled:i}=this.props,h=i&&i.uCalendar;return a.createElement("table",{className:n.classNames(n.uCalendar.table({c:h})),ref:l=>this.table=l,role:"grid",tabIndex:this.props.tabIndex,"aria-activedescendant":s+this.props.focusedDate.getTime()},a.createElement("colgroup",null,e.map((l,c)=>a.createElement("col",{key:c}))),t.map(l=>a.createElement(O.View,{ref:c=>{this.calendarView||(this.calendarView=c)},key:l.getTime(),activeView:this.props.activeView,viewDate:l,min:this.props.min,max:this.props.max,cellUID:s,focusedDate:this.props.focusedDate,cell:this.props.cell,selectedDate:this.props.value,showWeekNumbers:this.weekNumber,onChange:this.handleDateChange,bus:this.props.bus,service:this.props.service,weekCell:this.props.weekCell,showOtherMonthDays:this.props.showOtherMonthDays,unstyled:i})))},this.calculateHeights=()=>{if(!this.props.dom)return;const e=this.props.activeView===p.CalendarViewEnum.month?this.props.dom.scrollableContentHeight:this.props.dom.scrollableYearContentHeight;this.bottomOffset=e-this.props.dom.viewHeight(this.props.activeView),this.viewOffset=-1*this.props.dom.headerHeight,this.viewHeight=this.props.dom.viewHeight(this.props.activeView)||1},this.getTake=(e,t)=>Math.min(t-e,this.take),this.handleScrollAction=({index:e,scrollAction:t,pageAction:s})=>{const i=s?s.skip:this.state.skip;if((this.state.index!==e||this.state.skip!==i)&&this.setState({index:e,skip:i}),this.table&&t){const h=`translateY(${t.offset}px)`;this.table.style.transform=h}},this.handleTodayClick=e=>{this.shouldScroll=!0,this.handleDateChange.call(void 0,e,!0)},this.handleDateChange=(e,t=!1)=>{const{onChange:s}=this.props;if(s){const i={syntheticEvent:e.syntheticEvent,nativeEvent:e.nativeEvent,value:m.cloneDate(e.value),target:this,isTodayClick:t};s.call(void 0,i)}},this.lastView=this.props.activeView,this.lastFocus=this.props.focusedDate,this.state={skip:this.props.service.skip(this.props.focusedDate,this.props.min),index:this.props.service.skip(this.props.focusedDate,this.props.min)}}get element(){return this._element}get weekNames(){return this.intl=C.provideIntlService(this),this.weekService=new H.WeekNamesService(this.intl),this.weekService.getWeekNames(this.weekNumber,this.props.weekDaysFormat)}get weekNumber(){return!!(this.props.showWeekNumbers&&this.props.activeView===p.CalendarViewEnum.month)}get take(){return this.props.take!==void 0?this.props.take:u.defaultProps.take}get animate(){return!!(this.props.smoothScroll&&this.animateToIndex)}get todayIsInRange(){return f.isInRange(f.getToday(),m.getDate(this.props.min),m.getDate(this.props.max))}componentDidUpdate(r,e){this.shouldScroll=!1,this.indexToScroll!==void 0&&this.virtualization&&this.virtualization[this.animate?"animateToIndex":"scrollToIndex"](this.indexToScroll),this.isActive&&this.focusActiveDate(),this.lastView=this.props.activeView,this.indexToScroll=void 0}render(){const{activeView:r,min:e,max:t,service:s,unstyled:i}=this.props,h=i&&i.uCalendar;this.calculateHeights();const l=this.lastView!==r,c=f.dateInRange(this.props.focusedDate,e,t),w=l?s.skip(c,e):this.state.skip,b=s.total(e,t),y=this.getTake(w,b),x=s.addToDate(e,w),S=s.addToDate(e,this.state.index),g=new Array(s.rowLength(this.weekNumber)).fill(""),D=r!==this.lastView;this.animateToIndex=!D,(D||!m.isEqualDate(this.lastFocus,c)||this.shouldScroll||!this.props.shouldScroll||this.props.shouldScroll())&&(this.indexToScroll=this.props.service.skip(c,this.props.min)),this.lastFocus=c;const V=n.classNames(n.uCalendar.view({c:h,month:r===p.CalendarViewEnum.month,year:r===p.CalendarViewEnum.year,decade:r===p.CalendarViewEnum.decade,century:r===p.CalendarViewEnum.century})),E=this.buildDates(g,s.datesList(x,y)),I=a.createElement(a.Fragment,null,a.createElement(q.Header,{key:"calendar-view-list-header",currentDate:S,min:this.props.min,max:this.props.max,activeView:this.props.activeView,bus:this.props.bus,service:this.props.service,headerTitle:this.props.headerTitle,header:this.props.header,unstyled:i,commands:a.createElement(R.TodayCommand,{min:this.props.min,max:this.props.max,onClick:this.handleTodayClick,disabled:!this.todayIsInRange,tabIndex:this.props.tabIndex,unstyled:i})}),this.props.activeView===p.CalendarViewEnum.month&&this.buildMonthView(g,this.weekNames),a.createElement(N.Virtualization,{key:"calendar-view-list-content",skip:w,take:this.take,total:b,itemHeight:this.viewHeight,topOffset:this.viewOffset,bottomOffset:this.bottomOffset,scrollOffsetSize:this.viewOffset,maxScrollDifference:this.viewHeight,onScroll:this.props.onScroll,onScrollAction:this.handleScrollAction,onMount:k=>!this.virtualization&&this.handleVirtualizationMount(k),children:E,tabIndex:this.props.tabIndex,unstyled:i}));return a.createElement("div",{ref:k=>{this._element=k},className:V},this.props.dom.didCalculate?I:null)}};u.propTypes={activeView:o.number.isRequired,bottomOffset:o.number,cellUID:o.string.isRequired,focusedDate:o.instanceOf(Date).isRequired,max:o.instanceOf(Date).isRequired,min:o.instanceOf(Date).isRequired,onChange:o.func,showWeekNumbers:o.bool,smoothScroll:o.bool,take:o.number,value:o.instanceOf(Date),viewHeight:o.number,viewOffset:o.number,weekDaysFormat:o.oneOf(["short","abbreviated","narrow"]),tabIndex:o.number},u.defaultProps={take:_,showWeekNumbers:!1,weekDaysFormat:"short",smoothScroll:!0};let v=u;C.registerForIntl(v);exports.ViewList=v;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("react"),o=require("prop-types"),n=require("@progress/kendo-react-common"),m=require("@progress/kendo-date-math"),C=require("@progress/kendo-react-intl"),N=require("../../virtualization/Virtualization.js"),O=require("./View.js"),q=require("./Header.js"),H=require("../services/WeekNamesService.js"),f=require("../../utils.js"),p=require("../models/CalendarViewEnum.js"),R=require("./TodayCommand.js");function z(d){const r=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(r,e,t.get?t:{enumerable:!0,get:()=>d[e]})}}return r.default=d,Object.freeze(r)}const a=z(T),_=5,u=class u extends a.Component{constructor(r){super(r),this.virtualization=null,this.calendarView=null,this.table=null,this.intl=null,this.bottomOffset=0,this.viewOffset=0,this.viewHeight=0,this._element=null,this.isActive=!1,this.animateToIndex=!0,this.shouldScroll=!1,this.weekService=null,this.focusActiveDate=()=>{if(!this._element)return;const e=this._element.querySelector("td.k-focus"),t=this._element.querySelector(".k-state-pending-focus");e&&e[0]&&e[0].classList.remove("k-focus"),t&&t.classList.add("k-focus"),this.isActive=!0},this.blurActiveDate=()=>{if(!this._element)return;const e=this._element.querySelector("td.k-focus");e&&e.classList.remove("k-focus"),this.isActive=!1},this.handleVirtualizationMount=e=>{if(this.virtualization=e,this.virtualization&&this.table){this.table.style.transform=`translateY(${this.viewOffset}px)`;const t=f.dateInRange(this.props.focusedDate,this.props.min,this.props.max),s=this.props.service.skip(t,this.props.min);this.virtualization.scrollToIndex(s)}},this.buildMonthView=(e,t)=>{const{unstyled:s}=this.props,i=s&&s.uCalendar;return a.createElement("table",{key:"calendar-view-list-weekdays",className:n.classNames(n.uCalendar.table({c:i,weekdays:!0})),role:"grid",tabIndex:this.props.tabIndex},a.createElement("colgroup",null,e.map((h,l)=>a.createElement("col",{key:l}))),a.createElement("thead",{className:n.classNames(n.uCalendar.thead({c:i}))},a.createElement("tr",{className:n.classNames(n.uCalendar.tr({c:i}))},t.map((h,l)=>a.createElement("th",{key:l,className:n.classNames(n.uCalendar.th({c:i}))},h)))))},this.buildDates=(e,t)=>{const s=this.props.cellUID,{unstyled:i}=this.props,h=i&&i.uCalendar;return a.createElement("table",{className:n.classNames(n.uCalendar.table({c:h})),ref:l=>{this.table=l},role:"grid",tabIndex:this.props.tabIndex,"aria-activedescendant":s+this.props.focusedDate.getTime()},a.createElement("colgroup",null,e.map((l,c)=>a.createElement("col",{key:c}))),t.map(l=>a.createElement(O.View,{ref:c=>{this.calendarView||(this.calendarView=c)},key:l.getTime(),activeView:this.props.activeView,viewDate:l,min:this.props.min,max:this.props.max,cellUID:s,focusedDate:this.props.focusedDate,cell:this.props.cell,selectedDate:this.props.value,showWeekNumbers:this.weekNumber,onChange:this.handleDateChange,bus:this.props.bus,service:this.props.service,weekCell:this.props.weekCell,showOtherMonthDays:this.props.showOtherMonthDays,unstyled:i})))},this.calculateHeights=()=>{if(!this.props.dom)return;const e=this.props.activeView===p.CalendarViewEnum.month?this.props.dom.scrollableContentHeight:this.props.dom.scrollableYearContentHeight;this.bottomOffset=e-this.props.dom.viewHeight(this.props.activeView),this.viewOffset=-1*this.props.dom.headerHeight,this.viewHeight=this.props.dom.viewHeight(this.props.activeView)||1},this.getTake=(e,t)=>Math.min(t-e,this.take),this.handleScrollAction=({index:e,scrollAction:t,pageAction:s})=>{const i=s?s.skip:this.state.skip;if((this.state.index!==e||this.state.skip!==i)&&this.setState({index:e,skip:i}),this.table&&t){const h=`translateY(${t.offset}px)`;this.table.style.transform=h}},this.handleTodayClick=e=>{this.shouldScroll=!0,this.handleDateChange.call(void 0,e,!0)},this.handleDateChange=(e,t=!1)=>{const{onChange:s}=this.props;if(s){const i={syntheticEvent:e.syntheticEvent,nativeEvent:e.nativeEvent,value:m.cloneDate(e.value),target:this,isTodayClick:t};s.call(void 0,i)}},this.lastView=this.props.activeView,this.lastFocus=this.props.focusedDate,this.state={skip:this.props.service.skip(this.props.focusedDate,this.props.min),index:this.props.service.skip(this.props.focusedDate,this.props.min)}}get element(){return this._element}get weekNames(){return this.intl=C.provideIntlService(this),this.weekService=new H.WeekNamesService(this.intl),this.weekService.getWeekNames(this.weekNumber,this.props.weekDaysFormat)}get weekNumber(){return!!(this.props.showWeekNumbers&&this.props.activeView===p.CalendarViewEnum.month)}get take(){return this.props.take!==void 0?this.props.take:u.defaultProps.take}get animate(){return!!(this.props.smoothScroll&&this.animateToIndex)}get todayIsInRange(){return f.isInRange(f.getToday(),m.getDate(this.props.min),m.getDate(this.props.max))}componentDidUpdate(r,e){this.shouldScroll=!1,this.indexToScroll!==void 0&&this.virtualization&&this.virtualization[this.animate?"animateToIndex":"scrollToIndex"](this.indexToScroll),this.isActive&&this.focusActiveDate(),this.lastView=this.props.activeView,this.indexToScroll=void 0}render(){const{activeView:r,min:e,max:t,service:s,unstyled:i}=this.props,h=i&&i.uCalendar;this.calculateHeights();const l=this.lastView!==r,c=f.dateInRange(this.props.focusedDate,e,t),w=l?s.skip(c,e):this.state.skip,b=s.total(e,t),y=this.getTake(w,b),x=s.addToDate(e,w),S=s.addToDate(e,this.state.index),g=new Array(s.rowLength(this.weekNumber)).fill(""),D=r!==this.lastView;this.animateToIndex=!D,(D||!m.isEqualDate(this.lastFocus,c)||this.shouldScroll||!this.props.shouldScroll||this.props.shouldScroll())&&(this.indexToScroll=this.props.service.skip(c,this.props.min)),this.lastFocus=c;const V=n.classNames(n.uCalendar.view({c:h,month:r===p.CalendarViewEnum.month,year:r===p.CalendarViewEnum.year,decade:r===p.CalendarViewEnum.decade,century:r===p.CalendarViewEnum.century})),E=this.buildDates(g,s.datesList(x,y)),I=a.createElement(a.Fragment,null,a.createElement(q.Header,{key:"calendar-view-list-header",currentDate:S,min:this.props.min,max:this.props.max,activeView:this.props.activeView,bus:this.props.bus,service:this.props.service,headerTitle:this.props.headerTitle,header:this.props.header,unstyled:i,commands:a.createElement(R.TodayCommand,{min:this.props.min,max:this.props.max,onClick:this.handleTodayClick,disabled:!this.todayIsInRange,tabIndex:this.props.tabIndex,unstyled:i})}),this.props.activeView===p.CalendarViewEnum.month&&this.buildMonthView(g,this.weekNames),a.createElement(N.Virtualization,{key:"calendar-view-list-content",skip:w,take:this.take,total:b,itemHeight:this.viewHeight,topOffset:this.viewOffset,bottomOffset:this.bottomOffset,scrollOffsetSize:this.viewOffset,maxScrollDifference:this.viewHeight,onScroll:this.props.onScroll,onScrollAction:this.handleScrollAction,onMount:k=>!this.virtualization&&this.handleVirtualizationMount(k),children:E,tabIndex:this.props.tabIndex,unstyled:i}));return a.createElement("div",{ref:k=>{this._element=k},className:V},this.props.dom.didCalculate?I:null)}};u.propTypes={activeView:o.number.isRequired,bottomOffset:o.number,cellUID:o.string.isRequired,focusedDate:o.instanceOf(Date).isRequired,max:o.instanceOf(Date).isRequired,min:o.instanceOf(Date).isRequired,onChange:o.func,showWeekNumbers:o.bool,smoothScroll:o.bool,take:o.number,value:o.instanceOf(Date),viewHeight:o.number,viewOffset:o.number,weekDaysFormat:o.oneOf(["short","abbreviated","narrow"]),tabIndex:o.number},u.defaultProps={take:_,showWeekNumbers:!1,weekDaysFormat:"short",smoothScroll:!0};let v=u;C.registerForIntl(v);exports.ViewList=v;
|
|
@@ -54,7 +54,9 @@ const M = 5, d = class d extends a.Component {
|
|
|
54
54
|
"table",
|
|
55
55
|
{
|
|
56
56
|
className: p(m.table({ c: l })),
|
|
57
|
-
ref: (r) =>
|
|
57
|
+
ref: (r) => {
|
|
58
|
+
this.table = r;
|
|
59
|
+
},
|
|
58
60
|
role: "grid",
|
|
59
61
|
tabIndex: this.props.tabIndex,
|
|
60
62
|
"aria-activedescendant": t + this.props.focusedDate.getTime()
|
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 Ve=require("react"),e=require("prop-types"),I=require("@progress/kendo-date-math"),$=require("@progress/kendo-react-buttons"),G=require("@progress/kendo-svg-icons"),Z=require("@progress/kendo-react-intl"),i=require("@progress/kendo-react-common"),Le=require("@progress/kendo-react-labels"),Ne=require("@progress/kendo-dateinputs-common"),q=require("./utils.js"),u=require("../utils.js"),c=require("../messages/index.js"),pe=require("../timepicker/utils.js"),Ae=require("../common/ClearButton.js"),_e=require("./dateInputIntl.js");function Be(t){const b=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const m in t)if(m!=="default"){const O=Object.getOwnPropertyDescriptor(t,m);Object.defineProperty(b,m,O.get?O:{enumerable:!0,get:()=>t[m]})}}return b.default=t,Object.freeze(b)}const a=Be(Ve),je="Please enter a valid value!",L=a.forwardRef((t,b)=>{var Y;const m=i.useId(t.id),O=Z.useInternationalization(),E=Z.useLocalization(),Q=i.useUnstyled(),N=i.usePropsContext(V,t).unstyled||Q,{format:R=r.format,size:ee=r.size,rounded:te=r.rounded,fillMode:ne=r.fillMode,formatPlaceholder:ae=r.formatPlaceholder,spinners:re=r.spinners,disabled:C=r.disabled,min:le=r.min,max:ue=r.max,minTime:ie=r.minTime,maxTime:oe=r.maxTime,validityStyles:se=r.validityStyles,validationMessage:p=r.validationMessage,placeholder:y=r.placeholder,enableMouseWheel:ce=r.enableMouseWheel,autoCorrectParts:de=r.autoCorrectParts,autoSwitchParts:fe=r.autoSwitchParts,allowCaretMode:me=r.allowCaretMode,twoDigitYearMax:ge=r.twoDigitYearMax,ariaHasPopup:ve=r.ariaHasPopup,autoFocus:be=r.autoFocus}=i.usePropsContext(V,t),g=()=>M.current!==void 0?M.current:o.current&&o.current.value,A=()=>{const n=o.current&&o.current.currentText||"",l=g();return y!=null&&!Re.focused&&!l?y:n},_=()=>t.required!==void 0?t.required:!1,P=()=>{const n=g()||t.value,l=le,X=ue,Te=q.isInRange(n,l,X)&&pe.isInTimeRange(n,ie,oe),Se=p!==void 0,ke=(!_()||n!=null)&&Te,qe=t.valid!==void 0?t.valid:ke;return{customError:Se,rangeOverflow:n&&X.getTime()<n.getTime()||!1,rangeUnderflow:n&&n.getTime()<l.getTime()||!1,valid:qe,valueMissing:n===null}},ye=()=>{s.current&&s.current.focus()},B=()=>new _e.DateInputIntl(O),x=()=>{const n=g();return{format:R,steps:t.steps,formatPlaceholder:ae,placeholder:y,selectPreviousSegmentOnBackspace:!0,value:t.value||n,intlService:B(),autoFill:t.autoFill!==void 0?t.autoFill:!1,enableMouseWheel:ce,autoCorrectParts:de,autoSwitchParts:fe,autoSwitchKeys:t.autoSwitchKeys||[],twoDigitYearMax:ge,allowCaretMode:me}},he=n=>{d.current&&d.current.classList.add("k-focus"),U({focused:!0})},De=n=>{d.current&&d.current.classList.remove("k-focus"),U({focused:!1})},Ie=(n,l)=>typeof n!=typeof l?!0:typeof n=="string"&&typeof l=="string"?n!==l:typeof n=="object"&&typeof l=="object"?JSON.stringify(n)!==JSON.stringify(l):!1,Oe=n=>typeof n=="string"?n:{inputFormat:n,displayFormat:n},j=n=>{M.current=g(),Pe(),v.current=n,M.current=void 0},F=n=>{t.onChange&&t.onChange(n)},H=n=>{i.getActiveElement(document)===s.current&&n.preventDefault()},Ee=()=>new Ne.DateInput(s.current,{...x(),format:Oe(x().format),events:{focus:he,blur:De,valueChange:j,click:F}}),z=()=>{s.current&&s.current.setCustomValidity&&s.current.setCustomValidity(P().valid?"":p||r.validationMessage)},Ce=n=>{!s.current||!o.current||j(n)},xe=n=>{n.preventDefault();const l=i.getActiveElement(document);s.current&&l!==s.current&&s.current.focus({preventScroll:!0})},f=n=>{const l=g();v.current&&t.onChange&&!I.isEqual(v.current.oldValue,l)&&t.onChange.call(void 0,{syntheticEvent:n,nativeEvent:v.current.event,value:v.current.value,target:w.current}),v.current=null},we=n=>{var l;(l=o.current)==null||l.modifyDateSegmentValue(1),f(n)},Me=n=>{var l;(l=o.current)==null||l.modifyDateSegmentValue(-1),f(n)},w=a.useRef(null),s=a.useRef(null),d=a.useRef(null);a.useImperativeHandle(w,()=>({props:t,get options(){return x()},get text(){return A()},get element(){return s.current},get name(){return t.name},get value(){return g()},get validity(){return P()},focus:ye,updateOnPaste:Ce})),a.useImperativeHandle(b,()=>w.current);const o=a.useRef(null),T=a.useRef(null),S=a.useRef(!1),M=a.useRef(null),v=a.useRef(null),h=a.useRef(t),[Re,U]=a.useState({focused:!1}),[,Pe]=a.useReducer(n=>n+1,0);a.useLayoutEffect(()=>{S.current||(o.current=Ee(),T.current=o.current.dateObject,S.current=!0)},[]),a.useEffect(()=>(z(),S.current||d.current&&d.current.addEventListener("wheel",H,{passive:!1}),()=>{d.current&&d.current.removeEventListener("wheel",H)}),[]),a.useEffect(()=>{z(),o.current&&((Ie(h.current.format,R)||h.current.readonly!==t.readonly||JSON.stringify(h.current.steps)!==JSON.stringify(t.steps)||B().locale!==o.current.options.intlService.locale)&&o.current.setOptions(x(),!0),h.current.value!==t.value&&(T.current.getValue()!==null||t.value!==null)&&T.current.setValue(t.value),t.ariaExpanded!==void 0&&t.ariaExpanded&&(o.current.options.placeholder=null),t.ariaExpanded!==void 0&&!t.ariaExpanded&&(o.current.options.placeholder=y),o.current.refreshElementValue(),h.current={format:R,readonly:t.readonly,ariaExpanded:t.ariaExpanded,steps:t.steps,value:t.value})});const W=t.id||m+"-accessibility-id",D=N&&N.uDateInput,K=A(),k=!se||P().valid;a.useImperativeHandle(t._ref,()=>w.current);const J=a.createElement("span",{ref:n=>d.current=n,style:t.label?void 0:{width:t.width},dir:t.dir,className:i.classNames(i.uDateInput.wrapper({c:D,size:ee,fillMode:ne,rounded:te,disabled:C,required:_(),invalid:!k}),t.className)},a.createElement("input",{ref:n=>s.current=n,role:t.ariaRole||"textbox",readOnly:t.readonly,tabIndex:t.tabIndex||0,disabled:C,title:t.title!==void 0?t.title:K,type:"text",spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoFocus:be,className:i.classNames(i.uDateInput.inputInner({c:D})),id:W,value:K,"aria-label":t.ariaLabel,"aria-labelledby":t.ariaLabelledBy,"aria-describedby":t.ariaDescribedBy,"aria-haspopup":ve,"aria-disabled":C,"aria-expanded":t.ariaExpanded,"aria-controls":t.ariaControls,"aria-required":t.required,"aria-invalid":!k,onKeyDown:f,onChange:f,onWheel:f,onInput:f,onClick:f,name:t.name,...t.inputAttributes}),t.children,t.clearButton&&t.value&&a.createElement(Ae,{onClick:F,key:"clearbutton"}),re&&a.createElement("span",{className:i.classNames(i.uDateInput.inputSpinner({c:D})),onMouseDown:xe},a.createElement($.Button,{tabIndex:-1,type:"button",rounded:null,className:i.classNames(i.uDateInput.spinnerIncrease({c:D})),icon:"caret-alt-up",svgIcon:G.caretAltUpIcon,"aria-label":E.toLanguageString(c.increaseValue,c.messages[c.increaseValue]),title:E.toLanguageString(c.increaseValue,c.messages[c.increaseValue]),onClick:we}),a.createElement($.Button,{tabIndex:-1,type:"button",rounded:null,className:i.classNames(i.uDateInput.spinnerDecrease({c:D})),icon:"caret-alt-down",svgIcon:G.caretAltDownIcon,"aria-label":E.toLanguageString(c.decreaseValue,c.messages[c.decreaseValue]),title:E.toLanguageString(c.decreaseValue,c.messages[c.decreaseValue]),onClick:Me})));return t.label?a.createElement(Le.FloatingLabel,{label:t.label,editorId:W,editorValue:(Y=s.current)==null?void 0:Y.value,editorValid:k,editorDisabled:C,children:J,style:{width:t.width}}):J});L.propTypes={value:e.instanceOf(Date),format:e.oneOfType([u.nullable(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([u.nullable(e.oneOf(["wide","narrow","short","formatPattern"])),e.shape({year:u.nullable(e.string),month:u.nullable(e.string),day:u.nullable(e.string),hour:u.nullable(e.string),minute:u.nullable(e.string),second:u.nullable(e.string)})]),width:e.oneOfType([e.string,e.number]),tabIndex:e.number,title:e.string,steps:e.shape({year:u.nullable(e.number),month:u.nullable(e.number),day:u.nullable(e.number),hour:u.nullable(e.number),minute:u.nullable(e.number),second:u.nullable(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.oneOf(["grid","dialog"])]),ariaExpanded:e.oneOfType([e.bool]),onChange:e.func,validationMessage:e.string,required:e.bool,valid:e.bool,size:e.oneOf([null,"small","medium","large"]),rounded:e.oneOf([null,"small","medium","large","full"]),fillMode:e.oneOf([null,"solid","flat","outline"]),autoFocus:e.bool,inputAttributes:e.object};const r={format:q.DEFAULT_FORMAT,size:"medium",rounded:"medium",fillMode:"solid",formatPlaceholder:q.DEFAULT_FORMAT_PLACEHOLDER,spinners:!1,disabled:!1,max:I.cloneDate(u.MAX_DATE),min:I.cloneDate(u.MIN_DATE),minTime:I.cloneDate(u.MIN_TIME),maxTime:I.cloneDate(u.MAX_TIME),validityStyles:!0,validationMessage:je,placeholder:null,enableMouseWheel:!0,autoCorrectParts:!0,autoSwitchParts:!0,allowCaretMode:!1,twoDigitYearMax:68,ariaHasPopup:"grid",autoFocus:!1},V=i.createPropsContext();L.displayName="KendoReactDateInput";exports.DateInput=L;exports.DateInputPropsContext=V;exports.dateInputDefaultProps=r;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ve=require("react"),e=require("prop-types"),I=require("@progress/kendo-date-math"),$=require("@progress/kendo-react-buttons"),G=require("@progress/kendo-svg-icons"),Z=require("@progress/kendo-react-intl"),i=require("@progress/kendo-react-common"),Le=require("@progress/kendo-react-labels"),Ne=require("@progress/kendo-dateinputs-common"),q=require("./utils.js"),u=require("../utils.js"),c=require("../messages/index.js"),pe=require("../timepicker/utils.js"),Ae=require("../common/ClearButton.js"),_e=require("./dateInputIntl.js");function Be(t){const b=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const m in t)if(m!=="default"){const O=Object.getOwnPropertyDescriptor(t,m);Object.defineProperty(b,m,O.get?O:{enumerable:!0,get:()=>t[m]})}}return b.default=t,Object.freeze(b)}const a=Be(Ve),je="Please enter a valid value!",L=a.forwardRef((t,b)=>{var Y;const m=i.useId(t.id),O=Z.useInternationalization(),E=Z.useLocalization(),Q=i.useUnstyled(),N=i.usePropsContext(V,t).unstyled||Q,{format:R=r.format,size:ee=r.size,rounded:te=r.rounded,fillMode:ne=r.fillMode,formatPlaceholder:ae=r.formatPlaceholder,spinners:re=r.spinners,disabled:C=r.disabled,min:le=r.min,max:ue=r.max,minTime:ie=r.minTime,maxTime:oe=r.maxTime,validityStyles:se=r.validityStyles,validationMessage:p=r.validationMessage,placeholder:y=r.placeholder,enableMouseWheel:ce=r.enableMouseWheel,autoCorrectParts:de=r.autoCorrectParts,autoSwitchParts:fe=r.autoSwitchParts,allowCaretMode:me=r.allowCaretMode,twoDigitYearMax:ge=r.twoDigitYearMax,ariaHasPopup:ve=r.ariaHasPopup,autoFocus:be=r.autoFocus}=i.usePropsContext(V,t),g=()=>M.current!==void 0?M.current:o.current&&o.current.value,A=()=>{const n=o.current&&o.current.currentText||"",l=g();return y!=null&&!Re.focused&&!l?y:n},_=()=>t.required!==void 0?t.required:!1,P=()=>{const n=g()||t.value,l=le,X=ue,Te=q.isInRange(n,l,X)&&pe.isInTimeRange(n,ie,oe),Se=p!==void 0,ke=(!_()||n!=null)&&Te,qe=t.valid!==void 0?t.valid:ke;return{customError:Se,rangeOverflow:n&&X.getTime()<n.getTime()||!1,rangeUnderflow:n&&n.getTime()<l.getTime()||!1,valid:qe,valueMissing:n===null}},ye=()=>{s.current&&s.current.focus()},B=()=>new _e.DateInputIntl(O),x=()=>{const n=g();return{format:R,steps:t.steps,formatPlaceholder:ae,placeholder:y,selectPreviousSegmentOnBackspace:!0,value:t.value||n,intlService:B(),autoFill:t.autoFill!==void 0?t.autoFill:!1,enableMouseWheel:ce,autoCorrectParts:de,autoSwitchParts:fe,autoSwitchKeys:t.autoSwitchKeys||[],twoDigitYearMax:ge,allowCaretMode:me}},he=n=>{d.current&&d.current.classList.add("k-focus"),U({focused:!0})},De=n=>{d.current&&d.current.classList.remove("k-focus"),U({focused:!1})},Ie=(n,l)=>typeof n!=typeof l?!0:typeof n=="string"&&typeof l=="string"?n!==l:typeof n=="object"&&typeof l=="object"?JSON.stringify(n)!==JSON.stringify(l):!1,Oe=n=>typeof n=="string"?n:{inputFormat:n,displayFormat:n},j=n=>{M.current=g(),Pe(),v.current=n,M.current=void 0},F=n=>{t.onChange&&t.onChange(n)},H=n=>{i.getActiveElement(document)===s.current&&n.preventDefault()},Ee=()=>new Ne.DateInput(s.current,{...x(),format:Oe(x().format),events:{focus:he,blur:De,valueChange:j,click:F}}),z=()=>{s.current&&s.current.setCustomValidity&&s.current.setCustomValidity(P().valid?"":p||r.validationMessage)},Ce=n=>{!s.current||!o.current||j(n)},xe=n=>{n.preventDefault();const l=i.getActiveElement(document);s.current&&l!==s.current&&s.current.focus({preventScroll:!0})},f=n=>{const l=g();v.current&&t.onChange&&!I.isEqual(v.current.oldValue,l)&&t.onChange.call(void 0,{syntheticEvent:n,nativeEvent:v.current.event,value:v.current.value,target:w.current}),v.current=null},we=n=>{var l;(l=o.current)==null||l.modifyDateSegmentValue(1),f(n)},Me=n=>{var l;(l=o.current)==null||l.modifyDateSegmentValue(-1),f(n)},w=a.useRef(null),s=a.useRef(null),d=a.useRef(null);a.useImperativeHandle(w,()=>({props:t,get options(){return x()},get text(){return A()},get element(){return s.current},get name(){return t.name},get value(){return g()},get validity(){return P()},focus:ye,updateOnPaste:Ce})),a.useImperativeHandle(b,()=>w.current);const o=a.useRef(null),T=a.useRef(null),S=a.useRef(!1),M=a.useRef(null),v=a.useRef(null),h=a.useRef(t),[Re,U]=a.useState({focused:!1}),[,Pe]=a.useReducer(n=>n+1,0);a.useLayoutEffect(()=>{S.current||(o.current=Ee(),T.current=o.current.dateObject,S.current=!0)},[]),a.useEffect(()=>(z(),S.current||d.current&&d.current.addEventListener("wheel",H,{passive:!1}),()=>{d.current&&d.current.removeEventListener("wheel",H)}),[]),a.useEffect(()=>{z(),o.current&&((Ie(h.current.format,R)||h.current.readonly!==t.readonly||JSON.stringify(h.current.steps)!==JSON.stringify(t.steps)||B().locale!==o.current.options.intlService.locale)&&o.current.setOptions(x(),!0),h.current.value!==t.value&&(T.current.getValue()!==null||t.value!==null)&&T.current.setValue(t.value),t.ariaExpanded!==void 0&&t.ariaExpanded&&(o.current.options.placeholder=null),t.ariaExpanded!==void 0&&!t.ariaExpanded&&(o.current.options.placeholder=y),o.current.refreshElementValue(),h.current={format:R,readonly:t.readonly,ariaExpanded:t.ariaExpanded,steps:t.steps,value:t.value})});const W=t.id||m+"-accessibility-id",D=N&&N.uDateInput,K=A(),k=!se||P().valid;a.useImperativeHandle(t._ref,()=>w.current);const J=a.createElement("span",{ref:n=>{d.current=n},style:t.label?void 0:{width:t.width},dir:t.dir,className:i.classNames(i.uDateInput.wrapper({c:D,size:ee,fillMode:ne,rounded:te,disabled:C,required:_(),invalid:!k}),t.className)},a.createElement("input",{ref:n=>{s.current=n},role:t.ariaRole||"textbox",readOnly:t.readonly,tabIndex:t.tabIndex||0,disabled:C,title:t.title!==void 0?t.title:K,type:"text",spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoFocus:be,className:i.classNames(i.uDateInput.inputInner({c:D})),id:W,value:K,"aria-label":t.ariaLabel,"aria-labelledby":t.ariaLabelledBy,"aria-describedby":t.ariaDescribedBy,"aria-haspopup":ve,"aria-disabled":C,"aria-expanded":t.ariaExpanded,"aria-controls":t.ariaControls,"aria-required":t.required,"aria-invalid":!k,onKeyDown:f,onChange:f,onWheel:f,onInput:f,onClick:f,name:t.name,...t.inputAttributes}),t.children,t.clearButton&&t.value&&a.createElement(Ae,{onClick:F,key:"clearbutton"}),re&&a.createElement("span",{className:i.classNames(i.uDateInput.inputSpinner({c:D})),onMouseDown:xe},a.createElement($.Button,{tabIndex:-1,type:"button",rounded:null,className:i.classNames(i.uDateInput.spinnerIncrease({c:D})),icon:"caret-alt-up",svgIcon:G.caretAltUpIcon,"aria-label":E.toLanguageString(c.increaseValue,c.messages[c.increaseValue]),title:E.toLanguageString(c.increaseValue,c.messages[c.increaseValue]),onClick:we}),a.createElement($.Button,{tabIndex:-1,type:"button",rounded:null,className:i.classNames(i.uDateInput.spinnerDecrease({c:D})),icon:"caret-alt-down",svgIcon:G.caretAltDownIcon,"aria-label":E.toLanguageString(c.decreaseValue,c.messages[c.decreaseValue]),title:E.toLanguageString(c.decreaseValue,c.messages[c.decreaseValue]),onClick:Me})));return t.label?a.createElement(Le.FloatingLabel,{label:t.label,editorId:W,editorValue:(Y=s.current)==null?void 0:Y.value,editorValid:k,editorDisabled:C,children:J,style:{width:t.width}}):J});L.propTypes={value:e.instanceOf(Date),format:e.oneOfType([u.nullable(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([u.nullable(e.oneOf(["wide","narrow","short","formatPattern"])),e.shape({year:u.nullable(e.string),month:u.nullable(e.string),day:u.nullable(e.string),hour:u.nullable(e.string),minute:u.nullable(e.string),second:u.nullable(e.string)})]),width:e.oneOfType([e.string,e.number]),tabIndex:e.number,title:e.string,steps:e.shape({year:u.nullable(e.number),month:u.nullable(e.number),day:u.nullable(e.number),hour:u.nullable(e.number),minute:u.nullable(e.number),second:u.nullable(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.oneOf(["grid","dialog"])]),ariaExpanded:e.oneOfType([e.bool]),onChange:e.func,validationMessage:e.string,required:e.bool,valid:e.bool,size:e.oneOf([null,"small","medium","large"]),rounded:e.oneOf([null,"small","medium","large","full"]),fillMode:e.oneOf([null,"solid","flat","outline"]),autoFocus:e.bool,inputAttributes:e.object};const r={format:q.DEFAULT_FORMAT,size:"medium",rounded:"medium",fillMode:"solid",formatPlaceholder:q.DEFAULT_FORMAT_PLACEHOLDER,spinners:!1,disabled:!1,max:I.cloneDate(u.MAX_DATE),min:I.cloneDate(u.MIN_DATE),minTime:I.cloneDate(u.MIN_TIME),maxTime:I.cloneDate(u.MAX_TIME),validityStyles:!0,validationMessage:je,placeholder:null,enableMouseWheel:!0,autoCorrectParts:!0,autoSwitchParts:!0,allowCaretMode:!1,twoDigitYearMax:68,ariaHasPopup:"grid",autoFocus:!1},V=i.createPropsContext();L.displayName="KendoReactDateInput";exports.DateInput=L;exports.DateInputPropsContext=V;exports.dateInputDefaultProps=r;
|
package/dateinput/DateInput.mjs
CHANGED
|
@@ -169,7 +169,9 @@ const tt = "Please enter a valid value!", Z = a.forwardRef((t, $) => {
|
|
|
169
169
|
const W = /* @__PURE__ */ a.createElement(
|
|
170
170
|
"span",
|
|
171
171
|
{
|
|
172
|
-
ref: (n) =>
|
|
172
|
+
ref: (n) => {
|
|
173
|
+
s.current = n;
|
|
174
|
+
},
|
|
173
175
|
style: t.label ? void 0 : { width: t.width },
|
|
174
176
|
dir: t.dir,
|
|
175
177
|
className: y(
|
|
@@ -188,7 +190,9 @@ const tt = "Please enter a valid value!", Z = a.forwardRef((t, $) => {
|
|
|
188
190
|
/* @__PURE__ */ a.createElement(
|
|
189
191
|
"input",
|
|
190
192
|
{
|
|
191
|
-
ref: (n) =>
|
|
193
|
+
ref: (n) => {
|
|
194
|
+
o.current = n;
|
|
195
|
+
},
|
|
192
196
|
role: t.ariaRole || "textbox",
|
|
193
197
|
readOnly: t.readonly,
|
|
194
198
|
tabIndex: t.tabIndex || 0,
|
|
@@ -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"),_=require("@progress/kendo-react-intl"),l=require("../messages/index.js"),p=require("@progress/kendo-react-buttons"),N=require("../calendar/components/Calendar.js"),B=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 n=V(E),D=class D extends n.Component{constructor(s){super(s),this._calendar=null,this._timePart=null,this._cancelButton=null,this._acceptButton=null,this._dateButtonRef=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,o=this.localizationService.toLanguageString(l.dateTimePickerCancel,l.messages[l.dateTimePickerCancel]),h=this.localizationService.toLanguageString(l.dateTimePickerSet,l.messages[l.dateTimePickerSet]);return n.createElement("div",{className:a.classNames(a.uDateTimePicker.timeFooter({c:i}))},e&&n.createElement(p.Button,{type:"button",ref:r=>{this._cancelButton=r},className:a.classNames(a.uTime.cancel({c:i})),onClick:this.handleReject,onKeyDown:this.handleCancelKeyDown,title:o,"aria-label":o},o),n.createElement(p.Button,{type:"button",themeColor:"primary",ref:r=>{this._acceptButton=r},className:a.classNames(a.uTime.accept({c:i})),disabled:!this.hasDateValue,onClick:this.handleAccept,onKeyDown:this.handleSetKeyDown,title:h,"aria-label":h},h))},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=this.mergeDate(this.state.dateValue,t||this.state.timeValue);this.props.onChange.call(void 0,{syntheticEvent:e,nativeEvent:e.nativeEvent,value:i,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.handleDateClick=e=>{e.stopPropagation(),this.move("left")},this.handleTimeClick=e=>{e.stopPropagation(),this.move("right")},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=>{const{keyCode:t}=e;t===a.Keys.tab&&this._dateButtonRef&&this._dateButtonRef.element&&!this.hasDateValue&&(e.preventDefault(),this._dateButtonRef.element.focus())},this.handleSetKeyDown=e=>{const{keyCode:t}=e;t===a.Keys.tab&&this._dateButtonRef&&this._dateButtonRef.element&&(e.preventDefault(),this._dateButtonRef.element.focus())},this.handleDateKeyDown=e=>{var o,h,r,g;const{keyCode:t,shiftKey:i}=e;i&&t===a.Keys.tab&&(e.stopPropagation(),this.hasDateValue?(g=(r=this._acceptButton)==null?void 0:r.element)==null||g.focus():(h=(o=this._cancelButton)==null?void 0:o.element)==null||h.focus()),t===a.Keys.enter&&(e.stopPropagation(),this.move("left"))},this.handleTimeKeyDown=e=>{const{keyCode:t}=e;t===a.Keys.enter&&(e.stopPropagation(),this.move("right"))},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 _.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(o=>({dateValue:s.value&&this.props.value&&y.isEqualDate(s.value,this.props.value)?o.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:o,format:h,mobileMode:r,footerActions:g,unstyled:f}=this.props,m=f&&f.uDateTimePicker,k=a.classNames(a.uDateTimePicker.wrap({c:m,date:this.state.tab==="date",time:this.state.tab==="time",disabled:s})),C=this.localizationService.toLanguageString(l.date,l.messages[l.date]),P=this.localizationService.toLanguageString(l.time,l.messages[l.time]),T={min:e,max:t,weekNumber:i,focusedDate:o,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:r};return n.createElement("div",{onKeyDown:this.handleKeyDown,className:k,tabIndex:-1},n.createElement("div",{className:a.classNames(a.uDateTimePicker.buttonGroup({c:m}))},n.createElement(p.ButtonGroup,{width:"100%",unstyled:f},n.createElement(p.Button,{ref:u=>this._dateButtonRef=u,type:"button",selected:this.state.tab==="date",togglable:!0,onClick:this.handleDateClick,onKeyDown:this.handleDateKeyDown},C),n.createElement(p.Button,{type:"button",selected:this.state.tab==="time",togglable:!0,onClick:this.handleTimeClick,onKeyDown:this.handleTimeKeyDown},P))),n.createElement("div",{className:a.classNames(a.uDateTimePicker.selector({c:m}))},n.createElement("div",{className:a.classNames(a.uDateTimePicker.calendarWrap({c:m})),ref:u=>this._calendarWrap=u},this.props.calendar?n.createElement(this.props.calendar,{key:this.state.tab,...T}):n.createElement(N.Calendar,{key:this.state.tab,ref:u=>{this._calendar=u},...T})),n.createElement("div",{className:a.classNames(a.uDateTimePicker.timeWrap({c:m}))},n.createElement("div",{className:a.classNames(a.uDateTimePicker.timeSelector({c:m,mobileMode:r}))},n.createElement(B.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:r,unstyled:f})))),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}};D.defaultProps={footerActions:!0};let v=D;_.registerForLocalization(v);exports.DateTimeSelector=v;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("react"),_=require("@progress/kendo-react-intl"),l=require("../messages/index.js"),p=require("@progress/kendo-react-buttons"),N=require("../calendar/components/Calendar.js"),B=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 n=V(E),D=class D extends n.Component{constructor(s){super(s),this._calendar=null,this._timePart=null,this._cancelButton=null,this._acceptButton=null,this._dateButtonRef=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,o=this.localizationService.toLanguageString(l.dateTimePickerCancel,l.messages[l.dateTimePickerCancel]),h=this.localizationService.toLanguageString(l.dateTimePickerSet,l.messages[l.dateTimePickerSet]);return n.createElement("div",{className:a.classNames(a.uDateTimePicker.timeFooter({c:i}))},e&&n.createElement(p.Button,{type:"button",ref:r=>{this._cancelButton=r},className:a.classNames(a.uTime.cancel({c:i})),onClick:this.handleReject,onKeyDown:this.handleCancelKeyDown,title:o,"aria-label":o},o),n.createElement(p.Button,{type:"button",themeColor:"primary",ref:r=>{this._acceptButton=r},className:a.classNames(a.uTime.accept({c:i})),disabled:!this.hasDateValue,onClick:this.handleAccept,onKeyDown:this.handleSetKeyDown,title:h,"aria-label":h},h))},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=this.mergeDate(this.state.dateValue,t||this.state.timeValue);this.props.onChange.call(void 0,{syntheticEvent:e,nativeEvent:e.nativeEvent,value:i,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.handleDateClick=e=>{e.stopPropagation(),this.move("left")},this.handleTimeClick=e=>{e.stopPropagation(),this.move("right")},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=>{const{keyCode:t}=e;t===a.Keys.tab&&this._dateButtonRef&&this._dateButtonRef.element&&!this.hasDateValue&&(e.preventDefault(),this._dateButtonRef.element.focus())},this.handleSetKeyDown=e=>{const{keyCode:t}=e;t===a.Keys.tab&&this._dateButtonRef&&this._dateButtonRef.element&&(e.preventDefault(),this._dateButtonRef.element.focus())},this.handleDateKeyDown=e=>{var o,h,r,g;const{keyCode:t,shiftKey:i}=e;i&&t===a.Keys.tab&&(e.stopPropagation(),this.hasDateValue?(g=(r=this._acceptButton)==null?void 0:r.element)==null||g.focus():(h=(o=this._cancelButton)==null?void 0:o.element)==null||h.focus()),t===a.Keys.enter&&(e.stopPropagation(),this.move("left"))},this.handleTimeKeyDown=e=>{const{keyCode:t}=e;t===a.Keys.enter&&(e.stopPropagation(),this.move("right"))},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 _.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(o=>({dateValue:s.value&&this.props.value&&y.isEqualDate(s.value,this.props.value)?o.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:o,format:h,mobileMode:r,footerActions:g,unstyled:f}=this.props,m=f&&f.uDateTimePicker,k=a.classNames(a.uDateTimePicker.wrap({c:m,date:this.state.tab==="date",time:this.state.tab==="time",disabled:s})),C=this.localizationService.toLanguageString(l.date,l.messages[l.date]),P=this.localizationService.toLanguageString(l.time,l.messages[l.time]),T={min:e,max:t,weekNumber:i,focusedDate:o,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:r};return n.createElement("div",{onKeyDown:this.handleKeyDown,className:k,tabIndex:-1},n.createElement("div",{className:a.classNames(a.uDateTimePicker.buttonGroup({c:m}))},n.createElement(p.ButtonGroup,{width:"100%",unstyled:f},n.createElement(p.Button,{ref:u=>{this._dateButtonRef=u},type:"button",selected:this.state.tab==="date",togglable:!0,onClick:this.handleDateClick,onKeyDown:this.handleDateKeyDown},C),n.createElement(p.Button,{type:"button",selected:this.state.tab==="time",togglable:!0,onClick:this.handleTimeClick,onKeyDown:this.handleTimeKeyDown},P))),n.createElement("div",{className:a.classNames(a.uDateTimePicker.selector({c:m}))},n.createElement("div",{className:a.classNames(a.uDateTimePicker.calendarWrap({c:m})),ref:u=>{this._calendarWrap=u}},this.props.calendar?n.createElement(this.props.calendar,{key:this.state.tab,...T}):n.createElement(N.Calendar,{key:this.state.tab,ref:u=>{this._calendar=u},...T})),n.createElement("div",{className:a.classNames(a.uDateTimePicker.timeWrap({c:m}))},n.createElement("div",{className:a.classNames(a.uDateTimePicker.timeSelector({c:m,mobileMode:r}))},n.createElement(B.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:r,unstyled:f})))),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}};D.defaultProps={footerActions:!0};let v=D;_.registerForLocalization(v);exports.DateTimeSelector=v;
|
|
@@ -176,7 +176,9 @@ const y = class y extends i.Component {
|
|
|
176
176
|
return /* @__PURE__ */ i.createElement("div", { onKeyDown: this.handleKeyDown, className: S, tabIndex: -1 }, /* @__PURE__ */ i.createElement("div", { className: l(u.buttonGroup({ c: m })) }, /* @__PURE__ */ i.createElement(x, { width: "100%", unstyled: p }, /* @__PURE__ */ i.createElement(
|
|
177
177
|
g,
|
|
178
178
|
{
|
|
179
|
-
ref: (c) =>
|
|
179
|
+
ref: (c) => {
|
|
180
|
+
this._dateButtonRef = c;
|
|
181
|
+
},
|
|
180
182
|
type: "button",
|
|
181
183
|
selected: this.state.tab === "date",
|
|
182
184
|
togglable: !0,
|
|
@@ -198,7 +200,9 @@ const y = class y extends i.Component {
|
|
|
198
200
|
"div",
|
|
199
201
|
{
|
|
200
202
|
className: l(u.calendarWrap({ c: m })),
|
|
201
|
-
ref: (c) =>
|
|
203
|
+
ref: (c) => {
|
|
204
|
+
this._calendarWrap = c;
|
|
205
|
+
}
|
|
202
206
|
},
|
|
203
207
|
this.props.calendar ? /* @__PURE__ */ i.createElement(this.props.calendar, { key: this.state.tab, ...C }) : /* @__PURE__ */ i.createElement(
|
|
204
208
|
A,
|