@progress/kendo-react-dateinputs 8.3.0-develop.6 → 8.3.0-develop.7
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/Calendar.js +2 -2
- package/calendar/components/Calendar.mjs +123 -115
- package/calendar/components/CalendarCell.js +1 -1
- package/calendar/components/CalendarCell.mjs +37 -39
- package/calendar/components/CalendarHeaderTitle.js +1 -1
- package/calendar/components/CalendarHeaderTitle.mjs +6 -12
- package/calendar/components/CalendarNavigationItem.js +1 -1
- package/calendar/components/CalendarNavigationItem.mjs +15 -19
- package/calendar/components/CalendarWeekCell.js +1 -1
- package/calendar/components/CalendarWeekCell.mjs +10 -15
- package/calendar/components/Header.js +1 -1
- package/calendar/components/Header.mjs +30 -40
- package/calendar/components/Navigation.js +1 -1
- package/calendar/components/Navigation.mjs +52 -49
- package/calendar/components/TodayCommand.js +1 -1
- package/calendar/components/TodayCommand.mjs +21 -25
- package/calendar/components/View.js +1 -1
- package/calendar/components/View.mjs +48 -42
- package/calendar/components/ViewList.js +1 -1
- package/calendar/components/ViewList.mjs +99 -94
- package/common/ClearButton.js +1 -1
- package/common/ClearButton.mjs +25 -31
- package/dateinput/DateInput.js +1 -1
- package/dateinput/DateInput.mjs +113 -110
- package/dateinput/utils.js +1 -1
- package/dateinput/utils.mjs +22 -23
- package/datepicker/DatePicker.js +1 -1
- package/datepicker/DatePicker.mjs +9 -9
- package/daterangepicker/DateRangePicker.js +1 -1
- package/daterangepicker/DateRangePicker.mjs +5 -5
- package/datetimepicker/DateTimePicker.js +1 -1
- package/datetimepicker/DateTimePicker.mjs +95 -90
- package/datetimepicker/DateTimeSelector.js +1 -1
- package/datetimepicker/DateTimeSelector.mjs +83 -81
- package/dist/cdn/js/kendo-react-dateinputs.js +1 -1
- package/index.d.mts +38 -28
- package/index.d.ts +38 -28
- package/package-metadata.mjs +1 -1
- package/package.json +7 -7
- package/timepicker/TimeList.js +3 -3
- package/timepicker/TimeList.mjs +83 -81
- package/timepicker/TimePart.js +1 -1
- package/timepicker/TimePart.mjs +74 -68
- package/timepicker/TimePicker.js +1 -1
- package/timepicker/TimePicker.mjs +112 -107
- package/timepicker/TimeSelector.js +1 -1
- package/timepicker/TimeSelector.mjs +66 -59
- package/virtualization/Virtualization.js +1 -1
- package/virtualization/Virtualization.mjs +49 -48
package/timepicker/TimeList.mjs
CHANGED
|
@@ -7,55 +7,55 @@
|
|
|
7
7
|
*/
|
|
8
8
|
"use client";
|
|
9
9
|
import * as n from "react";
|
|
10
|
-
import
|
|
11
|
-
import { cloneDate as
|
|
12
|
-
import { Keys as
|
|
13
|
-
import { provideIntlService as
|
|
14
|
-
import { Virtualization as
|
|
15
|
-
import { TIME_PART as
|
|
16
|
-
import { DayPeriodService as
|
|
17
|
-
import { DOMService as
|
|
18
|
-
import { HoursService as
|
|
19
|
-
import { MinutesService as
|
|
20
|
-
import { SecondsService as
|
|
21
|
-
import { debounce as
|
|
22
|
-
const
|
|
23
|
-
[
|
|
24
|
-
[
|
|
25
|
-
[
|
|
26
|
-
[
|
|
27
|
-
},
|
|
28
|
-
[
|
|
29
|
-
[
|
|
30
|
-
[
|
|
31
|
-
[
|
|
10
|
+
import p from "prop-types";
|
|
11
|
+
import { cloneDate as O } from "@progress/kendo-date-math";
|
|
12
|
+
import { Keys as l, getActiveElement as I, noop as H, classNames as m, uTime as u } from "@progress/kendo-react-common";
|
|
13
|
+
import { provideIntlService as y, registerForIntl as E } from "@progress/kendo-react-intl";
|
|
14
|
+
import { Virtualization as M } from "../virtualization/Virtualization.mjs";
|
|
15
|
+
import { TIME_PART as f } from "./models/TimePart.mjs";
|
|
16
|
+
import { DayPeriodService as D } from "./services/DayPeriodService.mjs";
|
|
17
|
+
import { DOMService as w } from "./services/DOMService.mjs";
|
|
18
|
+
import { HoursService as R } from "./services/HoursService.mjs";
|
|
19
|
+
import { MinutesService as C } from "./services/MinutesService.mjs";
|
|
20
|
+
import { SecondsService as P } from "./services/SecondsService.mjs";
|
|
21
|
+
import { debounce as z, MAX_TIME as _, MIDNIGHT_DATE as A } from "../utils.mjs";
|
|
22
|
+
const F = 2, T = 0.05, N = 100, k = 0, b = 9, B = {
|
|
23
|
+
[l.end]: (h, s) => h[h.length - 1],
|
|
24
|
+
[l.home]: (h, s) => h[0],
|
|
25
|
+
[l.up]: (h, s) => h[s - 1],
|
|
26
|
+
[l.down]: (h, s) => h[s + 1]
|
|
27
|
+
}, g = {
|
|
28
|
+
[f.dayperiod]: D,
|
|
29
|
+
[f.hour]: R,
|
|
30
|
+
[f.minute]: C,
|
|
31
|
+
[f.second]: P
|
|
32
32
|
}, r = class r extends n.Component {
|
|
33
|
-
constructor(
|
|
34
|
-
super(
|
|
33
|
+
constructor(s) {
|
|
34
|
+
super(s), this.intl = null, this._element = null, this.service = null, this.virtualization = null, this.topOffset = 0, this.bottomOffset = 0, this.itemHeight = 0, this.listHeight = 0, this.topThreshold = 0, this.bottomThreshold = 0, this.animateToIndex = !1, this.focus = (t) => {
|
|
35
35
|
Promise.resolve().then(() => {
|
|
36
36
|
this.element && this.element.focus(t);
|
|
37
37
|
});
|
|
38
38
|
}, this.itemOffset = (t) => {
|
|
39
39
|
if (!this.virtualization || !this.service)
|
|
40
40
|
return -1;
|
|
41
|
-
const e = this.service.selectedIndex(this.props.value), i = this.virtualization.activeIndex(),
|
|
42
|
-
if (e === i &&
|
|
43
|
-
return
|
|
44
|
-
const
|
|
45
|
-
return
|
|
41
|
+
const e = this.service.selectedIndex(this.props.value), i = this.virtualization.activeIndex(), o = this.virtualization.itemOffset(i), a = Math.abs(Math.ceil(t) - o);
|
|
42
|
+
if (e === i && a < F)
|
|
43
|
+
return o;
|
|
44
|
+
const d = e > i;
|
|
45
|
+
return d && a >= this.bottomThreshold || !d && a > this.topThreshold ? this.virtualization.itemOffset(i + 1) : o;
|
|
46
46
|
}, this.calculateHeights = () => {
|
|
47
|
-
this.dom.didCalculate && (this.itemHeight = this.dom.itemHeight, this.listHeight = this.dom.timeListHeight, this.topOffset = (this.listHeight - this.itemHeight) / 2, this.bottomOffset = this.listHeight - this.itemHeight, this.props.mobileMode && (this.topOffset +=
|
|
47
|
+
this.dom.didCalculate && (this.itemHeight = this.dom.itemHeight, this.listHeight = this.dom.timeListHeight, this.topOffset = (this.listHeight - this.itemHeight) / 2, this.bottomOffset = this.listHeight - this.itemHeight, this.props.mobileMode && (this.topOffset += b, this.bottomOffset += b * 2), this.topThreshold = this.itemHeight * T, this.bottomThreshold = this.itemHeight * (1 - T));
|
|
48
48
|
}, this.configureServices = ({ min: t, max: e, value: i } = this.props) => {
|
|
49
49
|
if (this.service) {
|
|
50
|
-
const [
|
|
51
|
-
this.service.configure(this.serviceSettings({ min:
|
|
50
|
+
const [o, a] = this.service.limitRange(t || this.min, e || this.max, i || this.props.value);
|
|
51
|
+
this.service.configure(this.serviceSettings({ min: o, max: a }));
|
|
52
52
|
}
|
|
53
53
|
}, this.serviceSettings = (t) => {
|
|
54
54
|
const e = {
|
|
55
55
|
boundRange: this.props.boundRange || r.defaultProps.boundRange,
|
|
56
56
|
insertUndividedMax: !1,
|
|
57
|
-
min:
|
|
58
|
-
max:
|
|
57
|
+
min: O(this.min),
|
|
58
|
+
max: O(this.max),
|
|
59
59
|
part: this.props.part,
|
|
60
60
|
step: this.step
|
|
61
61
|
}, i = Object.assign({}, e, t);
|
|
@@ -63,8 +63,8 @@ const k = 2, v = 0.05, C = 100, P = 0, g = 9, z = {
|
|
|
63
63
|
}, this.handleScrollAction = ({ target: t, animationInProgress: e }) => {
|
|
64
64
|
if (!(!this.virtualization || !this.service) && t && !e) {
|
|
65
65
|
this.animateToIndex = !1;
|
|
66
|
-
const i = this.virtualization.itemIndex(this.itemOffset(t.scrollTop)),
|
|
67
|
-
this.handleChange(
|
|
66
|
+
const i = this.virtualization.itemIndex(this.itemOffset(t.scrollTop)), o = this.service.data(this.props.value)[i];
|
|
67
|
+
this.handleChange(o);
|
|
68
68
|
}
|
|
69
69
|
}, this.handleFocus = (t) => {
|
|
70
70
|
const { onFocus: e } = this.props;
|
|
@@ -75,19 +75,19 @@ const k = 2, v = 0.05, C = 100, P = 0, g = 9, z = {
|
|
|
75
75
|
}, this.handleMouseOver = () => {
|
|
76
76
|
if (!this._element)
|
|
77
77
|
return;
|
|
78
|
-
const t =
|
|
78
|
+
const t = I(document);
|
|
79
79
|
document && t !== this._element && this.props.show && this._element.focus({ preventScroll: !0 });
|
|
80
80
|
}, this.handleKeyDown = (t) => {
|
|
81
81
|
if (!this.service)
|
|
82
82
|
return;
|
|
83
83
|
const { keyCode: e } = t;
|
|
84
|
-
(e ===
|
|
85
|
-
const
|
|
84
|
+
(e === l.down || e === l.up || e === l.end || e === l.home) && t.preventDefault();
|
|
85
|
+
const o = (B[t.keyCode] || H)(
|
|
86
86
|
this.service.data(this.props.value),
|
|
87
87
|
this.service.selectedIndex(this.props.value)
|
|
88
88
|
);
|
|
89
|
-
|
|
90
|
-
}, this.handleChange =
|
|
89
|
+
o && this.handleChange(o);
|
|
90
|
+
}, this.handleChange = z((t) => {
|
|
91
91
|
if (!this.service)
|
|
92
92
|
return;
|
|
93
93
|
const e = this.service.apply(this.props.value, t.value);
|
|
@@ -95,7 +95,7 @@ const k = 2, v = 0.05, C = 100, P = 0, g = 9, z = {
|
|
|
95
95
|
return;
|
|
96
96
|
const { onChange: i } = this.props;
|
|
97
97
|
i && i.call(void 0, e);
|
|
98
|
-
},
|
|
98
|
+
}, N), this.dom = new w();
|
|
99
99
|
}
|
|
100
100
|
get element() {
|
|
101
101
|
return this._element;
|
|
@@ -126,34 +126,36 @@ const k = 2, v = 0.05, C = 100, P = 0, g = 9, z = {
|
|
|
126
126
|
componentDidUpdate() {
|
|
127
127
|
if (!this.virtualization || !this.service)
|
|
128
128
|
return;
|
|
129
|
-
const
|
|
130
|
-
this.virtualization[this.animate ? "animateToIndex" : "scrollToIndex"](
|
|
129
|
+
const s = this.service.selectedIndex(this.props.value);
|
|
130
|
+
this.virtualization[this.animate ? "animateToIndex" : "scrollToIndex"](s), this.animateToIndex = !0;
|
|
131
131
|
}
|
|
132
132
|
/**
|
|
133
133
|
* @hidden
|
|
134
134
|
*/
|
|
135
135
|
render() {
|
|
136
|
-
|
|
136
|
+
const { part: s, value: t, unstyled: e } = this.props;
|
|
137
|
+
if (!s.type || !g[s.type])
|
|
137
138
|
return;
|
|
138
|
-
|
|
139
|
-
|
|
139
|
+
const i = e && e.uTime;
|
|
140
|
+
this.calculateHeights(), this.intl = y(this), this.service = new g[s.type](this.intl), this.configureServices();
|
|
141
|
+
const o = this.service.data(t), a = "translateY(" + this.topOffset + "px)", d = this.service.total(t), v = /* @__PURE__ */ n.createElement(n.Fragment, null, /* @__PURE__ */ n.createElement(
|
|
140
142
|
"ul",
|
|
141
143
|
{
|
|
142
|
-
style: { transform:
|
|
143
|
-
className:
|
|
144
|
+
style: { transform: a, msTransform: a },
|
|
145
|
+
className: m(u.ul({ c: i }))
|
|
144
146
|
},
|
|
145
|
-
o.map((
|
|
146
|
-
this.handleChange(
|
|
147
|
-
} }, /* @__PURE__ */ n.createElement("span", null,
|
|
148
|
-
), /* @__PURE__ */ n.createElement("div", { className:
|
|
147
|
+
o.map((c, S) => /* @__PURE__ */ n.createElement("li", { key: S, className: m(u.li({ c: i })), onClick: () => {
|
|
148
|
+
this.handleChange(c);
|
|
149
|
+
} }, /* @__PURE__ */ n.createElement("span", null, c.text)))
|
|
150
|
+
), /* @__PURE__ */ n.createElement("div", { className: m(u.scrollablePlaceholder({ c: i })) }));
|
|
149
151
|
return /* @__PURE__ */ n.createElement(
|
|
150
152
|
"div",
|
|
151
153
|
{
|
|
152
|
-
className:
|
|
154
|
+
className: m(u.list({ c: i })),
|
|
153
155
|
id: String(this.props.id || ""),
|
|
154
156
|
tabIndex: this.props.disabled ? -1 : 0,
|
|
155
|
-
ref: (
|
|
156
|
-
this._element =
|
|
157
|
+
ref: (c) => {
|
|
158
|
+
this._element = c;
|
|
157
159
|
},
|
|
158
160
|
onKeyDown: this.handleKeyDown,
|
|
159
161
|
onFocus: this.handleFocus,
|
|
@@ -161,43 +163,43 @@ const k = 2, v = 0.05, C = 100, P = 0, g = 9, z = {
|
|
|
161
163
|
onMouseOver: this.handleMouseOver
|
|
162
164
|
},
|
|
163
165
|
this.dom.didCalculate ? /* @__PURE__ */ n.createElement(
|
|
164
|
-
|
|
166
|
+
M,
|
|
165
167
|
{
|
|
166
168
|
bottomOffset: this.bottomOffset,
|
|
167
|
-
children:
|
|
168
|
-
className:
|
|
169
|
+
children: v,
|
|
170
|
+
className: m(u.container({ c: i })),
|
|
169
171
|
itemHeight: this.itemHeight,
|
|
170
172
|
maxScrollDifference: this.listHeight,
|
|
171
173
|
onScrollAction: this.handleScrollAction,
|
|
172
|
-
ref: (
|
|
173
|
-
this.virtualization =
|
|
174
|
+
ref: (c) => {
|
|
175
|
+
this.virtualization = c;
|
|
174
176
|
},
|
|
175
177
|
role: "presentation",
|
|
176
|
-
skip:
|
|
178
|
+
skip: k,
|
|
177
179
|
tabIndex: -1,
|
|
178
|
-
take:
|
|
180
|
+
take: d,
|
|
179
181
|
topOffset: this.topOffset,
|
|
180
|
-
total:
|
|
182
|
+
total: d
|
|
181
183
|
}
|
|
182
|
-
) : /* @__PURE__ */ n.createElement("div", { className:
|
|
184
|
+
) : /* @__PURE__ */ n.createElement("div", { className: m(u.container({ c: i, content: !0, scrollable: !0 })) }, v)
|
|
183
185
|
);
|
|
184
186
|
}
|
|
185
187
|
};
|
|
186
188
|
r.propTypes = {
|
|
187
|
-
id:
|
|
188
|
-
max:
|
|
189
|
-
min:
|
|
190
|
-
part: function(
|
|
191
|
-
const i =
|
|
192
|
-
if (!i || !
|
|
189
|
+
id: p.number,
|
|
190
|
+
max: p.instanceOf(Date),
|
|
191
|
+
min: p.instanceOf(Date),
|
|
192
|
+
part: function(s, t, e) {
|
|
193
|
+
const i = s[t];
|
|
194
|
+
if (!i || !g[i.type])
|
|
193
195
|
throw new Error(`
|
|
194
196
|
Invalid prop '${t}' supplied to ${e}.
|
|
195
197
|
Supported part types are hour|minute|second|dayperiod.
|
|
196
198
|
`);
|
|
197
199
|
return null;
|
|
198
200
|
},
|
|
199
|
-
step: function(
|
|
200
|
-
const i =
|
|
201
|
+
step: function(s, t, e) {
|
|
202
|
+
const i = s[t];
|
|
201
203
|
if (i !== void 0 && i <= 0)
|
|
202
204
|
throw new Error(`
|
|
203
205
|
Invalid prop '${t}' supplied to ${e}.
|
|
@@ -205,18 +207,18 @@ r.propTypes = {
|
|
|
205
207
|
`);
|
|
206
208
|
return null;
|
|
207
209
|
},
|
|
208
|
-
value:
|
|
209
|
-
smoothScroll:
|
|
210
|
-
show:
|
|
210
|
+
value: p.instanceOf(Date),
|
|
211
|
+
smoothScroll: p.bool,
|
|
212
|
+
show: p.bool
|
|
211
213
|
}, r.defaultProps = {
|
|
212
214
|
boundRange: !1,
|
|
213
|
-
max:
|
|
214
|
-
min:
|
|
215
|
+
max: _,
|
|
216
|
+
min: A,
|
|
215
217
|
step: 1,
|
|
216
218
|
smoothScroll: !0
|
|
217
219
|
};
|
|
218
|
-
let
|
|
219
|
-
|
|
220
|
+
let x = r;
|
|
221
|
+
E(x);
|
|
220
222
|
export {
|
|
221
|
-
|
|
223
|
+
x as TimeList
|
|
222
224
|
};
|
package/timepicker/TimePart.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react"),e=require("prop-types"),D=require("@progress/kendo-date-math"),n=require("@progress/kendo-react-common"),v=require("@progress/kendo-react-intl"),h=require("../messages/index.js"),E=require("./TimeList.js"),b=require("../utils.js"),T=require("./models/TimePart.js"),m=require("./utils.js"),k=require("@progress/kendo-react-buttons");function P(p){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(p){for(const s in p)if(s!=="default"){const t=Object.getOwnPropertyDescriptor(p,s);Object.defineProperty(i,s,t.get?t:{enumerable:!0,get:()=>p[s]})}}return i.default=p,Object.freeze(i)}const o=P(B),y=new RegExp(`${T.TIME_PART.hour}|${T.TIME_PART.minute}|${T.TIME_PART.second}|${T.TIME_PART.dayperiod}|literal`),l=class l extends o.Component{constructor(i){super(i),this._element=null,this._nowButton=null,this.dateFormatParts=[],this.timeLists=[],this.focus=(s,t)=>{Promise.resolve().then(()=>{t&&this._nowButton&&this._nowButton.element&&this._nowButton.element.focus();const a=this.timeLists[0];!t&&this.state.activeListIndex===-1&&!this.hasActiveButton()&&a&&a.element&&a.focus(s)})},this.timeFormatReducer=(s,t)=>s+t.pattern,this.timeFormatFilter=(s,t,a)=>{const r=t>=1&&a[t-1];return r&&r&&s.type==="literal"?y.test(r.type||""):y.test(s.type||"")},this.focusList=s=>{this.timeLists.length&&this.timeLists.reduce(this.listReducer,[]).map(t=>s===1?t.next:t.prev).map(t=>t&&t.element&&t.element.focus({preventScroll:!0}))},this.listReducer=(s,t,a,r)=>s.length||t.props.id!==this.state.activeListIndex?s:[{next:r[a+1]||t,prev:r[a-1]||t}],this.showNowButton=()=>!this.hasSteps()&&this.props.nowButton&&m.isInTimeRange(m.getNow(),this.min,this.max),this.handleKeyDown=s=>{const{keyCode:t}=s;switch(t){case n.Keys.left:s.preventDefault(),this.focusList(0);return;case n.Keys.right:s.preventDefault(),this.focusList(1);return;default:return}},this.handleListBlur=()=>{this.nextTick(()=>{this.setState({activeListIndex:-1})})},this.handleListFocus=s=>{clearTimeout(this.nextTickId),this.setState({activeListIndex:s})},this.handleChange=s=>{const{onChange:t}=this.props;t&&t.call(void 0,s)},this.snapTime=m.snapTime(m.generateSnappers(this.props.steps,this.props.min||l.defaultProps.min)),this.state={activeListIndex:-1},this.hasActiveButton=this.hasActiveButton.bind(this)}get element(){return this._element}get value(){return m.timeInRange(this.snapTime(D.cloneDate(this.props.value||b.MIDNIGHT_DATE)),this.min,this.max)}get intl(){return v.provideIntlService(this)}get min(){return this.snapTime(this.props.min||l.defaultProps.min)}get max(){return this.snapTime(this.props.max||l.defaultProps.max)}get steps(){return this.props.steps||l.defaultProps.steps}get boundRange(){return this.props.boundRange!==void 0?this.props.boundRange:l.defaultProps.boundRange}componentWillUnmount(){clearTimeout(this.nextTickId)}componentDidMount(){const{onMount:i}=this.props;i&&i.call(void 0,this.value)}render(){const{format:i,smoothScroll:s,onNowClick:t,className:a,disabled:r,mobileMode:N,show:x,onNowKeyDown:R,unstyled:w}=this.props,u=w&&w.uTime;this.snapTime=m.snapTime(m.generateSnappers(this.steps,this.min)),this.dateFormatParts=this.intl.splitDateFormat(i||l.defaultProps.format).filter(this.timeFormatFilter);const O=n.classNames(n.uTime.part({c:u,mobileMode:N,disabled:r}),a);this.timeLists=[];const I=v.provideLocalizationService(this),L=I.toLanguageString(h.selectNow,h.messages[h.selectNow]);return o.createElement("div",{className:O},o.createElement("div",{className:n.classNames(n.uTime.header({c:u}))},o.createElement("span",{className:n.classNames(n.uTime.title({c:u}))},this.intl.formatDate(this.value,this.dateFormatParts.reduce(this.timeFormatReducer,""))),this.showNowButton()&&o.createElement(k.Button,{type:"button",ref:c=>{this._nowButton=c},className:n.classNames(n.uTime.now({c:u})),fillMode:"flat",themeColor:"base",title:L,onKeyDown:R,"aria-label":L,onClick:t,tabIndex:r?-1:0},I.toLanguageString(h.now,h.messages[h.now]))),o.createElement("div",{className:n.classNames(n.uTime.listContainer({c:u})),onKeyDown:this.handleKeyDown},o.createElement("span",{className:n.classNames(n.uTime.highlight({c:u}))}),this.dateFormatParts.map((c,d)=>c.type!=="literal"?o.createElement("div",{key:d,className:n.classNames(n.uTime.listWrapper({c:u,focused:d===this.state.activeListIndex})),role:"presentation",tabIndex:-1},o.createElement("span",{className:n.classNames(n.uTime.title({c:u})),onMouseDown:g=>{g.preventDefault()}},this.intl.dateFieldName(c)),o.createElement(E.TimeList,{min:this.min,max:this.max,boundRange:this.boundRange,part:c,step:c.type?this.steps[c.type]:1,smoothScroll:s,ref:g=>{g&&this.timeLists.push(g)},id:d,onFocus:()=>{this.handleListFocus(d)},onBlur:this.handleListBlur,onChange:this.handleChange,value:this.value,disabled:r,show:x,mobileMode:N,unstyled:w})):o.createElement("div",{key:d,className:n.classNames(n.uTime.separator({c:u}))},c.pattern))))}nextTick(i){clearTimeout(this.nextTickId),this.nextTickId=window.setTimeout(()=>i())}hasActiveButton(){const i=n.getActiveElement(document);return this._nowButton&&i===this._nowButton.element}hasSteps(){const i=Object.keys(this.steps);return i.length!==i.reduce((s,t)=>s+this.steps[t],0)}};l.propTypes={cancelButton:e.bool,disabled:e.bool,format:e.oneOfType([e.string,e.shape({skeleton:e.string,pattern:e.string,date:e.oneOf(["short","medium","long","full"]),time:e.oneOf(["short","medium","long","full"]),datetime:e.oneOf(["short","medium","long","full"]),era:e.oneOf(["narrow","short","long"]),year:e.oneOf(["numeric","2-digit"]),month:e.oneOf(["numeric","2-digit","narrow","short","long"]),day:e.oneOf(["numeric","2-digit"]),weekday:e.oneOf(["narrow","short","long"]),hour:e.oneOf(["numeric","2-digit"]),hour12:e.bool,minute:e.oneOf(["numeric","2-digit"]),second:e.oneOf(["numeric","2-digit"]),timeZoneName:e.oneOf(["short","long"])})]),max:e.instanceOf(Date),min:e.instanceOf(Date),nowButton:e.bool,steps:e.shape({hour:e.number,minute:e.number,second:e.number}),smoothScroll:e.bool,tabIndex:e.number,value:e.instanceOf(Date),show:e.bool},l.defaultProps={value:null,disabled:!1,nowButton:!0,cancelButton:!0,format:"hh:mm a",min:b.MIN_TIME,max:b.MAX_TIME,steps:{},boundRange:!1};let f=l;v.registerForIntl(f);v.registerForLocalization(f);exports.TimePart=f;
|
package/timepicker/TimePart.mjs
CHANGED
|
@@ -8,16 +8,16 @@
|
|
|
8
8
|
"use client";
|
|
9
9
|
import * as n from "react";
|
|
10
10
|
import t from "prop-types";
|
|
11
|
-
import { cloneDate as
|
|
12
|
-
import { Keys as
|
|
13
|
-
import { provideIntlService as
|
|
14
|
-
import { selectNow as
|
|
15
|
-
import { TimeList as
|
|
16
|
-
import { MIN_TIME as
|
|
17
|
-
import { TIME_PART as
|
|
18
|
-
import { isInTimeRange as
|
|
19
|
-
import { Button as
|
|
20
|
-
const
|
|
11
|
+
import { cloneDate as O } from "@progress/kendo-date-math";
|
|
12
|
+
import { Keys as T, classNames as l, uTime as h, getActiveElement as R } from "@progress/kendo-react-common";
|
|
13
|
+
import { provideIntlService as k, provideLocalizationService as S, registerForIntl as C, registerForLocalization as M } from "@progress/kendo-react-intl";
|
|
14
|
+
import { selectNow as L, messages as x, now as I } from "../messages/index.mjs";
|
|
15
|
+
import { TimeList as P } from "./TimeList.mjs";
|
|
16
|
+
import { MIN_TIME as A, MAX_TIME as K, MIDNIGHT_DATE as _ } from "../utils.mjs";
|
|
17
|
+
import { TIME_PART as d } from "./models/TimePart.mjs";
|
|
18
|
+
import { isInTimeRange as $, getNow as z, snapTime as N, generateSnappers as B, timeInRange as W } from "./utils.mjs";
|
|
19
|
+
import { Button as j } from "@progress/kendo-react-buttons";
|
|
20
|
+
const v = new RegExp(`${d.hour}|${d.minute}|${d.second}|${d.dayperiod}|literal`), a = class a extends n.Component {
|
|
21
21
|
constructor(i) {
|
|
22
22
|
super(i), this._element = null, this._nowButton = null, this.dateFormatParts = [], this.timeLists = [], this.focus = (s, e) => {
|
|
23
23
|
Promise.resolve().then(() => {
|
|
@@ -27,22 +27,22 @@ const p = new RegExp(`${u.hour}|${u.minute}|${u.second}|${u.dayperiod}|literal`)
|
|
|
27
27
|
});
|
|
28
28
|
}, this.timeFormatReducer = (s, e) => s + e.pattern, this.timeFormatFilter = (s, e, o) => {
|
|
29
29
|
const r = e >= 1 && o[e - 1];
|
|
30
|
-
return r && r && s.type === "literal" ?
|
|
30
|
+
return r && r && s.type === "literal" ? v.test(r.type || "") : v.test(s.type || "");
|
|
31
31
|
}, this.focusList = (s) => {
|
|
32
32
|
this.timeLists.length && this.timeLists.reduce(this.listReducer, []).map((e) => s === 1 ? e.next : e.prev).map((e) => e && e.element && e.element.focus({ preventScroll: !0 }));
|
|
33
33
|
}, this.listReducer = (s, e, o, r) => s.length || e.props.id !== this.state.activeListIndex ? s : [{
|
|
34
34
|
next: r[o + 1] || e,
|
|
35
35
|
prev: r[o - 1] || e
|
|
36
|
-
}], this.showNowButton = () => !this.hasSteps() && this.props.nowButton &&
|
|
36
|
+
}], this.showNowButton = () => !this.hasSteps() && this.props.nowButton && $(z(), this.min, this.max), this.handleKeyDown = (s) => {
|
|
37
37
|
const { keyCode: e } = s;
|
|
38
38
|
switch (e) {
|
|
39
|
-
case
|
|
39
|
+
case T.left:
|
|
40
40
|
s.preventDefault(), this.focusList(
|
|
41
41
|
0
|
|
42
42
|
/* Left */
|
|
43
43
|
);
|
|
44
44
|
return;
|
|
45
|
-
case
|
|
45
|
+
case T.right:
|
|
46
46
|
s.preventDefault(), this.focusList(
|
|
47
47
|
1
|
|
48
48
|
/* Right */
|
|
@@ -62,8 +62,8 @@ const p = new RegExp(`${u.hour}|${u.minute}|${u.second}|${u.dayperiod}|literal`)
|
|
|
62
62
|
}, this.handleChange = (s) => {
|
|
63
63
|
const { onChange: e } = this.props;
|
|
64
64
|
e && e.call(void 0, s);
|
|
65
|
-
}, this.snapTime =
|
|
66
|
-
|
|
65
|
+
}, this.snapTime = N(
|
|
66
|
+
B(this.props.steps, this.props.min || a.defaultProps.min)
|
|
67
67
|
), this.state = {
|
|
68
68
|
activeListIndex: -1
|
|
69
69
|
}, this.hasActiveButton = this.hasActiveButton.bind(this);
|
|
@@ -75,14 +75,14 @@ const p = new RegExp(`${u.hour}|${u.minute}|${u.second}|${u.dayperiod}|literal`)
|
|
|
75
75
|
return this._element;
|
|
76
76
|
}
|
|
77
77
|
get value() {
|
|
78
|
-
return
|
|
79
|
-
this.snapTime(
|
|
78
|
+
return W(
|
|
79
|
+
this.snapTime(O(this.props.value || _)),
|
|
80
80
|
this.min,
|
|
81
81
|
this.max
|
|
82
82
|
);
|
|
83
83
|
}
|
|
84
84
|
get intl() {
|
|
85
|
-
return
|
|
85
|
+
return k(this);
|
|
86
86
|
}
|
|
87
87
|
get min() {
|
|
88
88
|
return this.snapTime(this.props.min || a.defaultProps.min);
|
|
@@ -116,88 +116,94 @@ const p = new RegExp(`${u.hour}|${u.minute}|${u.second}|${u.dayperiod}|literal`)
|
|
|
116
116
|
onNowClick: e,
|
|
117
117
|
className: o,
|
|
118
118
|
disabled: r,
|
|
119
|
-
mobileMode:
|
|
120
|
-
show:
|
|
121
|
-
onNowKeyDown:
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
119
|
+
mobileMode: w,
|
|
120
|
+
show: D,
|
|
121
|
+
onNowKeyDown: E,
|
|
122
|
+
unstyled: g
|
|
123
|
+
} = this.props, m = g && g.uTime;
|
|
124
|
+
this.snapTime = N(B(this.steps, this.min)), this.dateFormatParts = this.intl.splitDateFormat(i || a.defaultProps.format).filter(this.timeFormatFilter);
|
|
125
|
+
const F = l(
|
|
126
|
+
h.part({
|
|
127
|
+
c: m,
|
|
128
|
+
mobileMode: w,
|
|
129
|
+
disabled: r
|
|
130
|
+
}),
|
|
129
131
|
o
|
|
130
132
|
);
|
|
131
133
|
this.timeLists = [];
|
|
132
|
-
const
|
|
133
|
-
return /* @__PURE__ */ n.createElement("div", { className:
|
|
134
|
-
|
|
134
|
+
const b = S(this), y = b.toLanguageString(L, x[L]);
|
|
135
|
+
return /* @__PURE__ */ n.createElement("div", { className: F }, /* @__PURE__ */ n.createElement("div", { className: l(h.header({ c: m })) }, /* @__PURE__ */ n.createElement("span", { className: l(h.title({ c: m })) }, this.intl.formatDate(this.value, this.dateFormatParts.reduce(this.timeFormatReducer, ""))), this.showNowButton() && /* @__PURE__ */ n.createElement(
|
|
136
|
+
j,
|
|
135
137
|
{
|
|
136
138
|
type: "button",
|
|
137
|
-
ref: (
|
|
138
|
-
this._nowButton =
|
|
139
|
+
ref: (u) => {
|
|
140
|
+
this._nowButton = u;
|
|
139
141
|
},
|
|
140
|
-
className:
|
|
142
|
+
className: l(h.now({ c: m })),
|
|
141
143
|
fillMode: "flat",
|
|
142
144
|
themeColor: "base",
|
|
143
|
-
title:
|
|
144
|
-
onKeyDown:
|
|
145
|
-
"aria-label":
|
|
145
|
+
title: y,
|
|
146
|
+
onKeyDown: E,
|
|
147
|
+
"aria-label": y,
|
|
146
148
|
onClick: e,
|
|
147
149
|
tabIndex: r ? -1 : 0
|
|
148
150
|
},
|
|
149
|
-
|
|
151
|
+
b.toLanguageString(I, x[I])
|
|
150
152
|
)), /* @__PURE__ */ n.createElement(
|
|
151
153
|
"div",
|
|
152
154
|
{
|
|
153
|
-
className:
|
|
155
|
+
className: l(h.listContainer({ c: m })),
|
|
154
156
|
onKeyDown: this.handleKeyDown
|
|
155
157
|
},
|
|
156
|
-
/* @__PURE__ */ n.createElement("span", { className:
|
|
157
|
-
this.dateFormatParts.map((
|
|
158
|
+
/* @__PURE__ */ n.createElement("span", { className: l(h.highlight({ c: m })) }),
|
|
159
|
+
this.dateFormatParts.map((u, c) => u.type !== "literal" ? /* @__PURE__ */ n.createElement(
|
|
158
160
|
"div",
|
|
159
161
|
{
|
|
160
|
-
key:
|
|
161
|
-
className:
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
key: c,
|
|
163
|
+
className: l(
|
|
164
|
+
h.listWrapper({
|
|
165
|
+
c: m,
|
|
166
|
+
focused: c === this.state.activeListIndex
|
|
167
|
+
})
|
|
168
|
+
),
|
|
164
169
|
role: "presentation",
|
|
165
170
|
tabIndex: -1
|
|
166
171
|
},
|
|
167
|
-
/* @__PURE__ */ n.createElement("span", { className:
|
|
168
|
-
|
|
169
|
-
} }, this.intl.dateFieldName(
|
|
172
|
+
/* @__PURE__ */ n.createElement("span", { className: l(h.title({ c: m })), onMouseDown: (p) => {
|
|
173
|
+
p.preventDefault();
|
|
174
|
+
} }, this.intl.dateFieldName(u)),
|
|
170
175
|
/* @__PURE__ */ n.createElement(
|
|
171
|
-
|
|
176
|
+
P,
|
|
172
177
|
{
|
|
173
178
|
min: this.min,
|
|
174
179
|
max: this.max,
|
|
175
180
|
boundRange: this.boundRange,
|
|
176
|
-
part:
|
|
177
|
-
step:
|
|
181
|
+
part: u,
|
|
182
|
+
step: u.type ? this.steps[u.type] : 1,
|
|
178
183
|
smoothScroll: s,
|
|
179
|
-
ref: (
|
|
180
|
-
|
|
184
|
+
ref: (p) => {
|
|
185
|
+
p && this.timeLists.push(p);
|
|
181
186
|
},
|
|
182
|
-
id:
|
|
187
|
+
id: c,
|
|
183
188
|
onFocus: () => {
|
|
184
|
-
this.handleListFocus(
|
|
189
|
+
this.handleListFocus(c);
|
|
185
190
|
},
|
|
186
191
|
onBlur: this.handleListBlur,
|
|
187
192
|
onChange: this.handleChange,
|
|
188
193
|
value: this.value,
|
|
189
194
|
disabled: r,
|
|
190
|
-
show:
|
|
191
|
-
mobileMode:
|
|
195
|
+
show: D,
|
|
196
|
+
mobileMode: w,
|
|
197
|
+
unstyled: g
|
|
192
198
|
}
|
|
193
199
|
)
|
|
194
200
|
) : /* @__PURE__ */ n.createElement(
|
|
195
201
|
"div",
|
|
196
202
|
{
|
|
197
|
-
key:
|
|
198
|
-
className:
|
|
203
|
+
key: c,
|
|
204
|
+
className: l(h.separator({ c: m }))
|
|
199
205
|
},
|
|
200
|
-
|
|
206
|
+
u.pattern
|
|
201
207
|
))
|
|
202
208
|
));
|
|
203
209
|
}
|
|
@@ -205,7 +211,7 @@ const p = new RegExp(`${u.hour}|${u.minute}|${u.second}|${u.dayperiod}|literal`)
|
|
|
205
211
|
clearTimeout(this.nextTickId), this.nextTickId = window.setTimeout(() => i());
|
|
206
212
|
}
|
|
207
213
|
hasActiveButton() {
|
|
208
|
-
const i =
|
|
214
|
+
const i = R(document);
|
|
209
215
|
return this._nowButton && i === this._nowButton.element;
|
|
210
216
|
}
|
|
211
217
|
hasSteps() {
|
|
@@ -254,14 +260,14 @@ a.propTypes = {
|
|
|
254
260
|
nowButton: !0,
|
|
255
261
|
cancelButton: !0,
|
|
256
262
|
format: "hh:mm a",
|
|
257
|
-
min:
|
|
258
|
-
max:
|
|
263
|
+
min: A,
|
|
264
|
+
max: K,
|
|
259
265
|
steps: {},
|
|
260
266
|
boundRange: !1
|
|
261
267
|
};
|
|
262
|
-
let
|
|
263
|
-
|
|
264
|
-
|
|
268
|
+
let f = a;
|
|
269
|
+
C(f);
|
|
270
|
+
M(f);
|
|
265
271
|
export {
|
|
266
|
-
|
|
272
|
+
f as TimePart
|
|
267
273
|
};
|
package/timepicker/TimePicker.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("react"),e=require("prop-types"),L=require("@progress/kendo-react-popup"),w=require("@progress/kendo-date-math"),a=require("@progress/kendo-react-common"),_=require("@progress/kendo-svg-icons"),b=require("@progress/kendo-react-intl"),K=require("../package-metadata.js"),l=require("../messages/index.js"),j=require("../dateinput/DateInput.js"),U=require("./TimeSelector.js"),c=require("../utils.js"),g=require("./utils.js"),$=require("../hooks/usePickerFloatingLabel.js"),H=require("@progress/kendo-react-buttons"),W=require("../common/constants.js"),G=require("../common/AdaptiveMode.js"),X=require("@progress/kendo-react-layout");function Z(d){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(d){for(const t in d)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(d,t);Object.defineProperty(i,t,s.get?s:{enumerable:!0,get:()=>d[t]})}}return i.default=d,Object.freeze(i)}const r=Z(A),n=class n extends r.Component{constructor(i){super(i),this._element=null,this._dateInput=r.createRef(),this._timeSelector=null,this.shouldFocusDateInput=!1,this.prevShow=!1,this.focus=()=>{this.dateInput&&this.dateInput.focus()},this.renderTimeSelector=()=>{const{smoothScroll:t,cancelButton:s,nowButton:o,disabled:h,format:p,steps:u}=this.props;return r.createElement(U.TimeSelector,{ref:this.setTimeSelectorRef,className:this.mobileMode?"k-reset k-timeselector-lg":"",mobileMode:this.mobileMode,show:this.show,cancelButton:s,disabled:h,nowButton:o,format:p,min:this.min,max:this.max,steps:u,smoothScroll:t,value:this.value,footer:!this.mobileMode,handleTimeChange:this.mobileMode&&this.handleTimeChange,onChange:this.handleValueChange,onReject:this.handleValueReject})},this.renderPopup=()=>{const{popupClass:t,...s}=this.popupSettings,o=a.classNames(t),h={popupClass:"k-timepicker-popup k-list-container",show:this.show,animate:this.element!==null,anchor:this.element,className:o,id:this._popupId,anchorAlign:{horizontal:"left",vertical:"bottom"},popupAlign:{horizontal:"left",vertical:"top"},...s};return this.props.popup?r.createElement(this.props.popup,{...h},this.renderTimeSelector()):r.createElement(L.Popup,{...h},this.renderTimeSelector())},this.renderAdaptivePopup=()=>{const{windowWidth:t=0}=this.state,s={expand:this.show,onClose:this.handleBlur,adaptiveTitle:this.props.adaptiveTitle,windowWidth:t,footer:{cancelText:this.localizationService.toLanguageString(l.toggleClock,l.messages[l.timePickerCancel]),onCancel:this.handleValueReject,applyText:this.localizationService.toLanguageString(l.timePickerSet,l.messages[l.timePickerSet]),onApply:o=>this.handleValueChange(o)}};return r.createElement(G.AdaptiveMode,{...s},r.createElement(X.ActionSheetContent,{className:"!k-overflow-hidden"},this.renderTimeSelector()))},this.setTimeSelectorRef=t=>{this._timeSelector=t},this.nextValue=(t,s)=>t.value!==void 0?t.value:s.value,this.nextShow=(t,s)=>t.show!==void 0?t.show:s.show,this.handleInputValueChange=t=>{const s=this.mergeTime(t.value);this.handleValueChange({...t,value:s})},this.handleTimeChange=t=>{this.setState({candidate:t.time})},this.handleValueChange=t=>{this.setState({value:w.cloneDate(t.value||this.state.candidate)}),this.valueDuringOnChange=t.value,this.showDuringOnChange=!1,this.shouldFocusDateInput=!0;const{onChange:s}=this.props,o=this.state.candidate||this.value;s&&s.call(void 0,{syntheticEvent:t.syntheticEvent,nativeEvent:t.nativeEvent,value:o,show:this.show,target:this}),this.valueDuringOnChange=void 0,this.showDuringOnChange=void 0,this.setShow(!1)},this.handleFocus=()=>{this.setState({focused:!0})},this.handleBlur=()=>{this.setState({focused:!1}),this.setShow(!1)},this.handleValueReject=t=>{this.setShow(!1)},this.handleIconClick=t=>{this.props.disabled||(this.shouldFocusDateInput=!0,this.setShow(!this.show))},this.handleIconMouseDown=t=>{t.preventDefault()},this.handleKeyDown=t=>{const{altKey:s,keyCode:o}=t;if(o===a.Keys.esc){this.shouldFocusDateInput=!0,this.setShow(!1);return}s&&(o===a.Keys.up||o===a.Keys.down)&&(t.preventDefault(),t.stopPropagation(),this.shouldFocusDateInput=o===a.Keys.up,this.setShow(o===a.Keys.down))},a.validatePackage(K.packageMetadata),this.state={value:this.props.defaultValue||n.defaultProps.defaultValue,show:this.props.defaultShow||n.defaultProps.defaultShow,focused:!1,candidate:null},this.normalizeTime=this.normalizeTime.bind(this),this.setShow=this.setShow.bind(this),this.mergeTime=this.mergeTime.bind(this)}get _popupId(){return this.props.id+"-popup-id"}get document(){if(a.canUseDOM)return this.element&&this.element.ownerDocument||document}get element(){return this._element}get dateInput(){return this._dateInput.current}get timeSelector(){return this._timeSelector}get value(){const i=this.valueDuringOnChange!==void 0?this.valueDuringOnChange:this.props.value!==void 0?this.props.value:this.state.value;return i!==null?w.cloneDate(i):null}get show(){return this.showDuringOnChange!==void 0?this.showDuringOnChange:this.props.show!==void 0?this.props.show:this.state.show}get name(){return this.props.name}get validity(){const i=this.value&&this.normalizeTime(this.value),t=this.normalizeTime(this.min),s=this.normalizeTime(this.max),o=g.isInRange(i,t,s),h=this.props.validationMessage!==void 0,p=(!this.required||this.value!==null)&&o,u=this.props.valid!==void 0?this.props.valid:p;return{customError:h,rangeOverflow:g.isBiggerThanMax(i,s),rangeUnderflow:g.isSmallerThanMin(i,t),valid:u,valueMissing:this.value===null}}get mobileMode(){return!!(this.state.windowWidth&&this.state.windowWidth<=W.MOBILE_MEDIUM_DEVISE&&this.props.adaptive)}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:n.defaultProps.validityStyles}get required(){return this.props.required!==void 0?this.props.required:n.defaultProps.required}get popupSettings(){return this.props.popupSettings||n.defaultProps.popupSettings}get min(){return this.props.min!==void 0?this.props.min:n.defaultProps.min}get max(){return this.props.max!==void 0?this.props.max:n.defaultProps.max}get dateInputComp(){return this.props.dateInput||n.defaultProps.dateInput}get localizationService(){return b.provideLocalizationService(this)}componentDidMount(){var i;this.observerResize=a.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.show&&this.forceUpdate(),(i=this.document)!=null&&i.body&&this.observerResize&&this.observerResize.observe(this.document.body)}componentDidUpdate(){this._timeSelector&&this.show&&!this.prevShow?this._timeSelector.focusActiveList():this.dateInput&&this.dateInput.element&&!this.show&&this.shouldFocusDateInput&&this.dateInput.element.focus({preventScroll:!0}),this.prevShow=this.show,this.shouldFocusDateInput=!1}componentWillUnmount(){var i;(i=this.document)!=null&&i.body&&this.observerResize&&this.observerResize.disconnect()}render(){const{size:i=n.defaultProps.size,rounded:t=n.defaultProps.rounded,fillMode:s=n.defaultProps.fillMode,disabled:o,tabIndex:h,title:p,id:u,className:I,format:k,formatPlaceholder:M,width:T,name:C,steps:D,validationMessage:O,required:P,validityStyles:z,ariaLabelledBy:q,ariaDescribedBy:x}=this.props,f=!this.validityStyles||this.validity.valid,R={disabled:o,format:k,formatPlaceholder:M,id:u,ariaLabelledBy:q,ariaDescribedBy:x,max:this.normalizeTime(this.max),min:this.normalizeTime(this.min),name:C,onChange:this.handleInputValueChange,required:P,steps:D,tabIndex:this.show?-1:h,title:p,valid:this.validity.valid,validationMessage:O,validityStyles:z,value:this.value&&this.normalizeTime(this.value),label:void 0,placeholder:this.state.focused?null:this.props.placeholder,ariaHasPopup:"dialog",ariaExpanded:this.show,size:null,fillMode:null,rounded:null,readonly:this.mobileMode},E=this.localizationService.toLanguageString(l.toggleClock,l.messages[l.toggleClock]),B=this.localizationService.toLanguageString(l.toggleTimeSelector,l.messages[l.toggleTimeSelector]),v=r.createElement(a.AsyncFocusBlur,{onFocus:this.handleFocus,onBlur:this.mobileMode?void 0:this.handleBlur,onSyncBlur:this.props.onBlur,onSyncFocus:this.props.onFocus},({onFocus:V,onBlur:F})=>r.createElement(r.Fragment,null,r.createElement("span",{id:this.props.id,ref:N=>{this._element=N},className:a.classNames("k-input","k-timepicker",{[`k-input-${a.kendoThemeMaps.sizeMap[i]||i}`]:i,[`k-rounded-${a.kendoThemeMaps.roundedMap[t]||t}`]:t,[`k-input-${s}`]:s,"k-invalid":!f,"k-required":this.required,"k-disabled":this.props.disabled},I),onKeyDown:this.handleKeyDown,style:{width:T},onFocus:V,onBlur:F,onClick:this.mobileMode?this.handleIconClick:void 0},r.createElement(this.dateInputComp,{_ref:this._dateInput,ariaRole:"combobox",ariaControls:this._popupId,...R}),r.createElement(H.Button,{tabIndex:-1,type:"button",icon:"clock",svgIcon:_.clockIcon,onMouseDown:this.handleIconMouseDown,onClick:this.mobileMode?void 0:this.handleIconClick,title:B,className:"k-input-button",rounded:null,fillMode:s,"aria-label":E}),!this.mobileMode&&this.renderPopup()),this.mobileMode&&this.renderAdaptivePopup()));return this.props.label?r.createElement($.PickerFloatingLabel,{dateInput:this._dateInput,label:this.props.label,editorId:u,editorValid:f,editorDisabled:this.props.disabled,children:v,style:{width:this.props.width}}):v}normalizeTime(i){return c.setTime(c.MIDNIGHT_DATE,i)}setShow(i){const{onOpen:t,onClose:s}=this.props;this.show!==i&&(this.setState({show:i}),i&&t&&t.call(void 0,{target:this}),!i&&s&&s.call(void 0,{target:this}))}mergeTime(i){return this.value&&i?c.setTime(this.value,i):i}calculateMedia(i){for(let t of i)this.setState({windowWidth:t.target.clientWidth})}};n.displayName="TimePicker",n.propTypes={className:e.string,cancelButton:e.bool,nowButton:e.bool,defaultShow:e.bool,defaultValue:e.instanceOf(Date),disabled:e.bool,format:e.oneOfType([e.string,e.shape({skeleton:e.string,pattern:e.string,date:e.oneOf(["short","medium","long","full"]),time:e.oneOf(["short","medium","long","full"]),datetime:e.oneOf(["short","medium","long","full"]),era:e.oneOf(["narrow","short","long"]),year:e.oneOf(["numeric","2-digit"]),month:e.oneOf(["numeric","2-digit","narrow","short","long"]),day:e.oneOf(["numeric","2-digit"]),weekday:e.oneOf(["narrow","short","long"]),hour:e.oneOf(["numeric","2-digit"]),hour12:e.bool,minute:e.oneOf(["numeric","2-digit"]),second:e.oneOf(["numeric","2-digit"]),timeZoneName:e.oneOf(["short","long"])})]),formatPlaceholder:e.oneOfType([e.oneOf(["wide","narrow","short","formatPattern"]),e.shape({year:e.string,month:e.string,day:e.string,hour:e.string,minute:e.string,second:e.string})]),id:e.string,ariaLabelledBy:e.string,ariaDescribedBy:e.string,min:e.instanceOf(Date),max:e.instanceOf(Date),name:e.string,popupSettings:e.shape({animate:e.bool,appendTo:e.any,popupClass:e.string}),show:e.bool,steps:e.shape({hour:e.number,minute:e.number,second:e.number}),smoothScroll:e.bool,tabIndex:e.number,title:e.string,value:e.instanceOf(Date),width:e.oneOfType([e.number,e.string]),validationMessage:e.string,required:e.bool,validate:e.bool,valid:e.bool,size:e.oneOf([null,"small","medium","large"]),rounded:e.oneOf([null,"small","medium","large","full"]),fillMode:e.oneOf([null,"solid","flat","outline"])},n.defaultProps={defaultShow:!1,defaultValue:null,disabled:!1,format:"t",max:c.MAX_TIME,min:c.MIN_TIME,popupSettings:{},tabIndex:0,steps:{},required:!1,validityStyles:!0,dateInput:j.DateInput,size:"medium",rounded:"medium",fillMode:"solid"};let m=n;const S=a.createPropsContext(),y=a.withIdHOC(a.withPropsContext(S,m));y.displayName="KendoReactTimePicker";b.registerForLocalization(m);exports.TimePicker=y;exports.TimePickerPropsContext=S;exports.TimePickerWithoutContext=m;
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("react"),e=require("prop-types"),K=require("@progress/kendo-react-popup"),y=require("@progress/kendo-date-math"),n=require("@progress/kendo-react-common"),j=require("@progress/kendo-svg-icons"),I=require("@progress/kendo-react-intl"),U=require("../package-metadata.js"),l=require("../messages/index.js"),H=require("../dateinput/DateInput.js"),W=require("./TimeSelector.js"),c=require("../utils.js"),f=require("./utils.js"),G=require("../hooks/usePickerFloatingLabel.js"),X=require("@progress/kendo-react-buttons"),Z=require("../common/constants.js"),$=require("../common/AdaptiveMode.js"),J=require("@progress/kendo-react-layout");function Q(p){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(p){for(const t in p)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(p,t);Object.defineProperty(i,t,s.get?s:{enumerable:!0,get:()=>p[t]})}}return i.default=p,Object.freeze(i)}const r=Q(_),a=class a extends r.Component{constructor(i){super(i),this._element=null,this._dateInput=r.createRef(),this._timeSelector=null,this.shouldFocusDateInput=!1,this.prevShow=!1,this.focus=()=>{this.dateInput&&this.dateInput.focus()},this.renderTimeSelector=()=>{const{smoothScroll:t,cancelButton:s,nowButton:o,disabled:u,format:d,steps:h,unstyled:g}=this.props;return r.createElement(W.TimeSelector,{ref:this.setTimeSelectorRef,mobileMode:this.mobileMode,show:this.show,cancelButton:s,disabled:u,nowButton:o,format:d,min:this.min,max:this.max,steps:h,smoothScroll:t,value:this.value,footer:!this.mobileMode,handleTimeChange:this.mobileMode&&this.handleTimeChange,onChange:this.handleValueChange,onReject:this.handleValueReject,unstyled:g})},this.renderPopup=()=>{const{popupClass:t,...s}=this.popupSettings,{unstyled:o}=this.props,u=o&&o.uTimePicker,d=n.classNames(t),h={popupClass:n.uTimePicker.popup({c:u}),show:this.show,animate:this.element!==null,anchor:this.element,className:d,id:this._popupId,anchorAlign:{horizontal:"left",vertical:"bottom"},popupAlign:{horizontal:"left",vertical:"top"},...s};return this.props.popup?r.createElement(this.props.popup,{...h},this.renderTimeSelector()):r.createElement(K.Popup,{...h},this.renderTimeSelector())},this.renderAdaptivePopup=()=>{const{windowWidth:t=0}=this.state,s={expand:this.show,onClose:this.handleBlur,adaptiveTitle:this.props.adaptiveTitle,windowWidth:t,footer:{cancelText:this.localizationService.toLanguageString(l.toggleClock,l.messages[l.timePickerCancel]),onCancel:this.handleValueReject,applyText:this.localizationService.toLanguageString(l.timePickerSet,l.messages[l.timePickerSet]),onApply:o=>this.handleValueChange(o)}};return r.createElement($.AdaptiveMode,{...s},r.createElement(J.ActionSheetContent,{overflowHidden:!0},this.renderTimeSelector()))},this.setTimeSelectorRef=t=>{this._timeSelector=t},this.nextValue=(t,s)=>t.value!==void 0?t.value:s.value,this.nextShow=(t,s)=>t.show!==void 0?t.show:s.show,this.handleInputValueChange=t=>{const s=this.mergeTime(t.value);this.handleValueChange({...t,value:s})},this.handleTimeChange=t=>{this.setState({candidate:t.time})},this.handleValueChange=t=>{this.setState({value:y.cloneDate(t.value||this.state.candidate)}),this.valueDuringOnChange=t.value,this.showDuringOnChange=!1,this.shouldFocusDateInput=!0;const{onChange:s}=this.props,o=this.state.candidate||this.value;s&&s.call(void 0,{syntheticEvent:t.syntheticEvent,nativeEvent:t.nativeEvent,value:o,show:this.show,target:this}),this.valueDuringOnChange=void 0,this.showDuringOnChange=void 0,this.setShow(!1)},this.handleFocus=()=>{this.setState({focused:!0})},this.handleBlur=()=>{this.setState({focused:!1}),this.setShow(!1)},this.handleValueReject=t=>{this.setShow(!1)},this.handleIconClick=t=>{this.props.disabled||(this.shouldFocusDateInput=!0,this.setShow(!this.show))},this.handleIconMouseDown=t=>{t.preventDefault()},this.handleKeyDown=t=>{const{altKey:s,keyCode:o}=t;if(o===n.Keys.esc){this.shouldFocusDateInput=!0,this.setShow(!1);return}s&&(o===n.Keys.up||o===n.Keys.down)&&(t.preventDefault(),t.stopPropagation(),this.shouldFocusDateInput=o===n.Keys.up,this.setShow(o===n.Keys.down))},n.validatePackage(U.packageMetadata),this.state={value:this.props.defaultValue||a.defaultProps.defaultValue,show:this.props.defaultShow||a.defaultProps.defaultShow,focused:!1,candidate:null},this.normalizeTime=this.normalizeTime.bind(this),this.setShow=this.setShow.bind(this),this.mergeTime=this.mergeTime.bind(this)}get _popupId(){return this.props.id+"-popup-id"}get document(){if(n.canUseDOM)return this.element&&this.element.ownerDocument||document}get element(){return this._element}get dateInput(){return this._dateInput.current}get timeSelector(){return this._timeSelector}get value(){const i=this.valueDuringOnChange!==void 0?this.valueDuringOnChange:this.props.value!==void 0?this.props.value:this.state.value;return i!==null?y.cloneDate(i):null}get show(){return this.showDuringOnChange!==void 0?this.showDuringOnChange:this.props.show!==void 0?this.props.show:this.state.show}get name(){return this.props.name}get validity(){const i=this.value&&this.normalizeTime(this.value),t=this.normalizeTime(this.min),s=this.normalizeTime(this.max),o=f.isInRange(i,t,s),u=this.props.validationMessage!==void 0,d=(!this.required||this.value!==null)&&o,h=this.props.valid!==void 0?this.props.valid:d;return{customError:u,rangeOverflow:f.isBiggerThanMax(i,s),rangeUnderflow:f.isSmallerThanMin(i,t),valid:h,valueMissing:this.value===null}}get mobileMode(){return!!(this.state.windowWidth&&this.state.windowWidth<=Z.MOBILE_MEDIUM_DEVISE&&this.props.adaptive)}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:a.defaultProps.validityStyles}get required(){return this.props.required!==void 0?this.props.required:a.defaultProps.required}get popupSettings(){return this.props.popupSettings||a.defaultProps.popupSettings}get min(){return this.props.min!==void 0?this.props.min:a.defaultProps.min}get max(){return this.props.max!==void 0?this.props.max:a.defaultProps.max}get dateInputComp(){return this.props.dateInput||a.defaultProps.dateInput}get localizationService(){return I.provideLocalizationService(this)}componentDidMount(){var i;this.observerResize=n.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.show&&this.forceUpdate(),(i=this.document)!=null&&i.body&&this.observerResize&&this.observerResize.observe(this.document.body)}componentDidUpdate(){this._timeSelector&&this.show&&!this.prevShow?this._timeSelector.focusActiveList():this.dateInput&&this.dateInput.element&&!this.show&&this.shouldFocusDateInput&&this.dateInput.element.focus({preventScroll:!0}),this.prevShow=this.show,this.shouldFocusDateInput=!1}componentWillUnmount(){var i;(i=this.document)!=null&&i.body&&this.observerResize&&this.observerResize.disconnect()}render(){const{size:i=a.defaultProps.size,rounded:t=a.defaultProps.rounded,fillMode:s=a.defaultProps.fillMode,disabled:o,tabIndex:u,title:d,id:h,className:g,format:M,formatPlaceholder:P,width:D,name:O,steps:k,validationMessage:z,required:q,validityStyles:x,ariaLabelledBy:R,ariaDescribedBy:E,unstyled:v}=this.props,w=v&&v.uTimePicker,S=!this.validityStyles||this.validity.valid,B={disabled:o,format:M,formatPlaceholder:P,id:h,ariaLabelledBy:R,ariaDescribedBy:E,max:this.normalizeTime(this.max),min:this.normalizeTime(this.min),name:O,onChange:this.handleInputValueChange,required:q,steps:k,tabIndex:this.show?-1:u,title:d,valid:this.validity.valid,validationMessage:z,validityStyles:x,value:this.value&&this.normalizeTime(this.value),label:void 0,placeholder:this.state.focused?null:this.props.placeholder,ariaHasPopup:"dialog",ariaExpanded:this.show,size:null,fillMode:null,rounded:null,readonly:this.mobileMode},V=this.localizationService.toLanguageString(l.toggleClock,l.messages[l.toggleClock]),F=this.localizationService.toLanguageString(l.toggleTimeSelector,l.messages[l.toggleTimeSelector]),b=r.createElement(n.AsyncFocusBlur,{onFocus:this.handleFocus,onBlur:this.mobileMode?void 0:this.handleBlur,onSyncBlur:this.props.onBlur,onSyncFocus:this.props.onFocus},({onFocus:N,onBlur:A})=>r.createElement(r.Fragment,null,r.createElement("span",{id:this.props.id,ref:L=>{this._element=L},className:n.classNames(n.uTimePicker.wrapper({c:w,size:i,rounded:t,fillMode:s,invalid:!S,required:this.required,disabled:o}),g),onKeyDown:this.handleKeyDown,style:{width:D},onFocus:N,onBlur:A,onClick:this.mobileMode?this.handleIconClick:void 0},r.createElement(this.dateInputComp,{_ref:this._dateInput,ariaRole:"combobox",ariaControls:this._popupId,...B}),r.createElement(X.Button,{tabIndex:-1,type:"button",icon:"clock",svgIcon:j.clockIcon,onMouseDown:this.handleIconMouseDown,onClick:this.mobileMode?void 0:this.handleIconClick,title:F,className:n.classNames(n.uTimePicker.inputButton({c:w})),rounded:null,fillMode:s,"aria-label":V}),!this.mobileMode&&this.renderPopup()),this.mobileMode&&this.renderAdaptivePopup()));return this.props.label?r.createElement(G.PickerFloatingLabel,{dateInput:this._dateInput,label:this.props.label,editorId:h,editorValid:S,editorDisabled:this.props.disabled,children:b,style:{width:this.props.width}}):b}normalizeTime(i){return c.setTime(c.MIDNIGHT_DATE,i)}setShow(i){const{onOpen:t,onClose:s}=this.props;this.show!==i&&(this.setState({show:i}),i&&t&&t.call(void 0,{target:this}),!i&&s&&s.call(void 0,{target:this}))}mergeTime(i){return this.value&&i?c.setTime(this.value,i):i}calculateMedia(i){for(let t of i)this.setState({windowWidth:t.target.clientWidth})}};a.displayName="TimePicker",a.propTypes={className:e.string,cancelButton:e.bool,nowButton:e.bool,defaultShow:e.bool,defaultValue:e.instanceOf(Date),disabled:e.bool,format:e.oneOfType([e.string,e.shape({skeleton:e.string,pattern:e.string,date:e.oneOf(["short","medium","long","full"]),time:e.oneOf(["short","medium","long","full"]),datetime:e.oneOf(["short","medium","long","full"]),era:e.oneOf(["narrow","short","long"]),year:e.oneOf(["numeric","2-digit"]),month:e.oneOf(["numeric","2-digit","narrow","short","long"]),day:e.oneOf(["numeric","2-digit"]),weekday:e.oneOf(["narrow","short","long"]),hour:e.oneOf(["numeric","2-digit"]),hour12:e.bool,minute:e.oneOf(["numeric","2-digit"]),second:e.oneOf(["numeric","2-digit"]),timeZoneName:e.oneOf(["short","long"])})]),formatPlaceholder:e.oneOfType([e.oneOf(["wide","narrow","short","formatPattern"]),e.shape({year:e.string,month:e.string,day:e.string,hour:e.string,minute:e.string,second:e.string})]),id:e.string,ariaLabelledBy:e.string,ariaDescribedBy:e.string,min:e.instanceOf(Date),max:e.instanceOf(Date),name:e.string,popupSettings:e.shape({animate:e.bool,appendTo:e.any,popupClass:e.string}),show:e.bool,steps:e.shape({hour:e.number,minute:e.number,second:e.number}),smoothScroll:e.bool,tabIndex:e.number,title:e.string,value:e.instanceOf(Date),width:e.oneOfType([e.number,e.string]),validationMessage:e.string,required:e.bool,validate:e.bool,valid:e.bool,size:e.oneOf([null,"small","medium","large"]),rounded:e.oneOf([null,"small","medium","large","full"]),fillMode:e.oneOf([null,"solid","flat","outline"])},a.defaultProps={defaultShow:!1,defaultValue:null,disabled:!1,format:"t",max:c.MAX_TIME,min:c.MIN_TIME,popupSettings:{},tabIndex:0,steps:{},required:!1,validityStyles:!0,dateInput:H.DateInput,size:"medium",rounded:"medium",fillMode:"solid"};let m=a;const T=n.createPropsContext(),C=n.withIdHOC(n.withPropsContext(T,n.withUnstyledHOC(m)));C.displayName="KendoReactTimePicker";I.registerForLocalization(m);exports.TimePicker=C;exports.TimePickerPropsContext=T;exports.TimePickerWithoutContext=m;
|