@progress/kendo-react-dateinputs 7.2.4-develop.3 → 7.3.0-develop.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/calendar/components/Calendar.js +12 -0
- package/calendar/components/Calendar.mjs +328 -0
- package/calendar/components/CalendarCell.js +8 -0
- package/calendar/components/CalendarCell.mjs +101 -0
- package/calendar/components/CalendarHeaderTitle.js +8 -0
- package/calendar/components/CalendarHeaderTitle.mjs +23 -0
- package/calendar/components/CalendarNavigationItem.js +8 -0
- package/calendar/components/CalendarNavigationItem.mjs +29 -0
- package/calendar/components/CalendarWeekCell.js +8 -0
- package/calendar/components/CalendarWeekCell.mjs +23 -0
- package/calendar/components/Header.js +8 -0
- package/calendar/components/Header.mjs +78 -0
- package/calendar/components/HorizontalViewList.js +8 -0
- package/calendar/components/HorizontalViewList.mjs +120 -0
- package/calendar/components/MultiViewCalendar.js +8 -0
- package/calendar/components/MultiViewCalendar.mjs +428 -0
- package/calendar/components/Navigation.js +8 -0
- package/calendar/components/Navigation.mjs +117 -0
- package/calendar/components/TodayCommand.js +8 -0
- package/calendar/components/TodayCommand.mjs +74 -0
- package/calendar/components/View.js +8 -0
- package/calendar/components/View.mjs +153 -0
- package/calendar/components/ViewList.js +8 -0
- package/calendar/components/ViewList.mjs +228 -0
- package/calendar/models/CalendarViewEnum.js +8 -0
- package/calendar/models/CalendarViewEnum.mjs +12 -0
- package/calendar/models/NavigationAction.js +8 -0
- package/calendar/models/NavigationAction.mjs +12 -0
- package/calendar/models/SelectionRange.js +8 -0
- package/calendar/models/SelectionRange.mjs +12 -0
- package/calendar/services/BusViewService.js +8 -0
- package/calendar/services/BusViewService.mjs +58 -0
- package/calendar/services/CenturyViewService.js +8 -0
- package/calendar/services/CenturyViewService.mjs +126 -0
- package/calendar/services/DOMService.js +14 -0
- package/calendar/services/DOMService.mjs +124 -0
- package/calendar/services/DecadeViewService.js +8 -0
- package/calendar/services/DecadeViewService.mjs +126 -0
- package/calendar/services/MonthViewService.js +8 -0
- package/calendar/services/MonthViewService.mjs +139 -0
- package/calendar/services/NavigationService.js +8 -0
- package/calendar/services/NavigationService.mjs +36 -0
- package/calendar/services/ScrollSyncService.js +8 -0
- package/calendar/services/ScrollSyncService.mjs +50 -0
- package/calendar/services/WeekNamesService.js +8 -0
- package/calendar/services/WeekNamesService.mjs +24 -0
- package/calendar/services/YearViewService.js +8 -0
- package/calendar/services/YearViewService.mjs +135 -0
- package/common/AdaptiveMode.js +8 -0
- package/common/AdaptiveMode.mjs +73 -0
- package/common/PickerWrap.js +8 -0
- package/common/PickerWrap.mjs +32 -0
- package/common/constants.js +8 -0
- package/common/constants.mjs +12 -0
- package/dateinput/DateInput.js +8 -0
- package/dateinput/DateInput.mjs +503 -0
- package/dateinput/models/kendo-date.js +8 -0
- package/dateinput/models/kendo-date.mjs +233 -0
- package/dateinput/models/mask.js +8 -0
- package/dateinput/models/mask.mjs +16 -0
- package/dateinput/utils.js +8 -0
- package/dateinput/utils.mjs +38 -0
- package/datepicker/DatePicker.js +8 -0
- package/datepicker/DatePicker.mjs +462 -0
- package/datepicker/ToggleButton.js +8 -0
- package/datepicker/ToggleButton.mjs +13 -0
- package/daterangepicker/DateRangePicker.js +8 -0
- package/daterangepicker/DateRangePicker.mjs +426 -0
- package/datetimepicker/DateTimePicker.js +8 -0
- package/datetimepicker/DateTimePicker.mjs +475 -0
- package/datetimepicker/DateTimeSelector.js +8 -0
- package/datetimepicker/DateTimeSelector.mjs +275 -0
- package/dist/cdn/js/kendo-react-dateinputs.js +8 -21
- package/hooks/usePickerFloatingLabel.js +8 -0
- package/hooks/usePickerFloatingLabel.mjs +31 -0
- package/index.d.mts +4528 -5
- package/index.d.ts +4528 -39
- package/index.js +8 -21
- package/index.mjs +114 -6540
- package/messages/index.js +8 -0
- package/messages/index.mjs +59 -0
- package/package-metadata.js +8 -0
- package/package-metadata.mjs +19 -0
- package/package.json +7 -7
- package/timepicker/TimeList.js +14 -0
- package/timepicker/TimeList.mjs +230 -0
- package/timepicker/TimePart.js +8 -0
- package/timepicker/TimePart.mjs +267 -0
- package/timepicker/TimePicker.js +8 -0
- package/timepicker/TimePicker.mjs +479 -0
- package/timepicker/TimeSelector.js +8 -0
- package/timepicker/TimeSelector.mjs +250 -0
- package/timepicker/models/TimePart.js +8 -0
- package/timepicker/models/TimePart.mjs +18 -0
- package/timepicker/services/DOMService.js +8 -0
- package/timepicker/services/DOMService.mjs +34 -0
- package/timepicker/services/DayPeriodService.js +8 -0
- package/timepicker/services/DayPeriodService.mjs +89 -0
- package/timepicker/services/HoursService.js +8 -0
- package/timepicker/services/HoursService.mjs +92 -0
- package/timepicker/services/MinutesService.js +8 -0
- package/timepicker/services/MinutesService.mjs +91 -0
- package/timepicker/services/SecondsService.js +8 -0
- package/timepicker/services/SecondsService.mjs +91 -0
- package/timepicker/utils.js +8 -0
- package/timepicker/utils.mjs +91 -0
- package/utils.js +8 -0
- package/utils.mjs +111 -0
- package/virtualization/Virtualization.js +8 -0
- package/virtualization/Virtualization.mjs +204 -0
- package/virtualization/services/RowHeightService.js +8 -0
- package/virtualization/services/RowHeightService.mjs +50 -0
- package/virtualization/services/ScrollerService.js +8 -0
- package/virtualization/services/ScrollerService.mjs +52 -0
- package/PopupSettings.d.ts +0 -18
- package/calendar/components/Calendar.d.ts +0 -191
- package/calendar/components/CalendarCell.d.ts +0 -39
- package/calendar/components/CalendarHeaderTitle.d.ts +0 -32
- package/calendar/components/CalendarNavigationItem.d.ts +0 -31
- package/calendar/components/CalendarWeekCell.d.ts +0 -29
- package/calendar/components/Header.d.ts +0 -58
- package/calendar/components/HorizontalViewList.d.ts +0 -71
- package/calendar/components/MultiViewCalendar.d.ts +0 -212
- package/calendar/components/Navigation.d.ts +0 -80
- package/calendar/components/TodayCommand.d.ts +0 -35
- package/calendar/components/View.d.ts +0 -89
- package/calendar/components/ViewList.d.ts +0 -115
- package/calendar/models/ActiveView.d.ts +0 -8
- package/calendar/models/CalendarSettings.d.ts +0 -106
- package/calendar/models/CalendarViewEnum.d.ts +0 -13
- package/calendar/models/CellContext.d.ts +0 -23
- package/calendar/models/MultiViewCalendarMode.d.ts +0 -13
- package/calendar/models/MultiViewCalendarSettings.d.ts +0 -115
- package/calendar/models/NavigationAction.d.ts +0 -19
- package/calendar/models/SelectionRange.d.ts +0 -21
- package/calendar/models/SelectionRangeEnd.d.ts +0 -8
- package/calendar/models/ViewService.d.ts +0 -29
- package/calendar/models/index.d.ts +0 -15
- package/calendar/services/BusViewService.d.ts +0 -25
- package/calendar/services/CenturyViewService.d.ts +0 -29
- package/calendar/services/DOMService.d.ts +0 -33
- package/calendar/services/DecadeViewService.d.ts +0 -31
- package/calendar/services/MonthViewService.d.ts +0 -37
- package/calendar/services/NavigationService.d.ts +0 -18
- package/calendar/services/ScrollSyncService.d.ts +0 -25
- package/calendar/services/WeekNamesService.d.ts +0 -13
- package/calendar/services/YearViewService.d.ts +0 -35
- package/calendar/services/index.d.ts +0 -14
- package/common/AdaptiveMode.d.ts +0 -25
- package/common/PickerWrap.d.ts +0 -22
- package/common/constants.d.ts +0 -8
- package/dateinput/DateInput.d.ts +0 -355
- package/dateinput/models/DateInputSettings.d.ts +0 -103
- package/dateinput/models/format-placeholder.d.ts +0 -43
- package/dateinput/models/incremental-steps.d.ts +0 -15
- package/dateinput/models/index.d.ts +0 -11
- package/dateinput/models/kendo-date.d.ts +0 -57
- package/dateinput/models/mask.d.ts +0 -11
- package/dateinput/models/selection.d.ts +0 -11
- package/dateinput/utils.d.ts +0 -34
- package/datepicker/DatePicker.d.ts +0 -358
- package/datepicker/ToggleButton.d.ts +0 -14
- package/datepicker/models/DatePickerSettings.d.ts +0 -141
- package/datepicker/models/index.d.ts +0 -6
- package/daterangepicker/DateRangePicker.d.ts +0 -354
- package/daterangepicker/models/DateRangePickerCalendarSettings.d.ts +0 -10
- package/daterangepicker/models/DateRangePickerDateInputSettings.d.ts +0 -10
- package/daterangepicker/models/DateRangePickerPopupSettings.d.ts +0 -10
- package/daterangepicker/models/DateRangePickerSettings.d.ts +0 -126
- package/daterangepicker/models/index.d.ts +0 -9
- package/datetimepicker/DateTimePicker.d.ts +0 -342
- package/datetimepicker/DateTimeSelector.d.ts +0 -106
- package/datetimepicker/models/DateTimePickerSettings.d.ts +0 -144
- package/datetimepicker/models/index.d.ts +0 -6
- package/hooks/usePickerFloatingLabel.d.ts +0 -24
- package/messages/index.d.ts +0 -124
- package/package-metadata.d.ts +0 -9
- package/timepicker/TimeList.d.ts +0 -91
- package/timepicker/TimePart.d.ts +0 -141
- package/timepicker/TimePicker.d.ts +0 -355
- package/timepicker/TimeSelector.d.ts +0 -144
- package/timepicker/models/IncrementalSteps.d.ts +0 -12
- package/timepicker/models/ListItem.d.ts +0 -11
- package/timepicker/models/ListService.d.ts +0 -19
- package/timepicker/models/ListServiceSettings.d.ts +0 -16
- package/timepicker/models/TimePart.d.ts +0 -14
- package/timepicker/models/TimePickerSettings.d.ts +0 -133
- package/timepicker/models/index.d.ts +0 -11
- package/timepicker/services/DOMService.d.ts +0 -14
- package/timepicker/services/DayPeriodService.d.ts +0 -51
- package/timepicker/services/HoursService.d.ts +0 -37
- package/timepicker/services/MinutesService.d.ts +0 -36
- package/timepicker/services/SecondsService.d.ts +0 -36
- package/timepicker/services/index.d.ts +0 -10
- package/timepicker/utils.d.ts +0 -60
- package/utils.d.ts +0 -100
- package/virtualization/Virtualization.d.ts +0 -120
- package/virtualization/services/RowHeightService.d.ts +0 -22
- package/virtualization/services/ScrollerService.d.ts +0 -53
- package/virtualization/services/index.d.ts +0 -7
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import * as n from "react";
|
|
10
|
+
import t from "prop-types";
|
|
11
|
+
import { cloneDate as B } from "@progress/kendo-date-math";
|
|
12
|
+
import { Keys as v, classNames as w, getActiveElement as D } from "@progress/kendo-react-common";
|
|
13
|
+
import { provideIntlService as E, provideLocalizationService as F, registerForIntl as O, registerForLocalization as R } from "@progress/kendo-react-intl";
|
|
14
|
+
import { selectNow as b, messages as y, now as k } from "../messages/index.mjs";
|
|
15
|
+
import { TimeList as S } from "./TimeList.mjs";
|
|
16
|
+
import { MIN_TIME as M, MAX_TIME as P, MIDNIGHT_DATE as C } from "../utils.mjs";
|
|
17
|
+
import { TIME_PART as u } from "./models/TimePart.mjs";
|
|
18
|
+
import { isInTimeRange as A, getNow as K, snapTime as L, generateSnappers as x, timeInRange as _ } from "./utils.mjs";
|
|
19
|
+
import { Button as $ } from "@progress/kendo-react-buttons";
|
|
20
|
+
const p = new RegExp(`${u.hour}|${u.minute}|${u.second}|${u.dayperiod}|literal`), a = class a extends n.Component {
|
|
21
|
+
constructor(i) {
|
|
22
|
+
super(i), this._element = null, this._nowButton = null, this.dateFormatParts = [], this.timeLists = [], this.focus = (s, e) => {
|
|
23
|
+
Promise.resolve().then(() => {
|
|
24
|
+
e && this._nowButton && this._nowButton.element && this._nowButton.element.focus();
|
|
25
|
+
const o = this.timeLists[0];
|
|
26
|
+
!e && this.state.activeListIndex === -1 && !this.hasActiveButton() && o && o.element && o.focus(s);
|
|
27
|
+
});
|
|
28
|
+
}, this.timeFormatReducer = (s, e) => s + e.pattern, this.timeFormatFilter = (s, e, o) => {
|
|
29
|
+
const r = e >= 1 && o[e - 1];
|
|
30
|
+
return r && r && s.type === "literal" ? p.test(r.type || "") : p.test(s.type || "");
|
|
31
|
+
}, this.focusList = (s) => {
|
|
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
|
+
}, this.listReducer = (s, e, o, r) => s.length || e.props.id !== this.state.activeListIndex ? s : [{
|
|
34
|
+
next: r[o + 1] || e,
|
|
35
|
+
prev: r[o - 1] || e
|
|
36
|
+
}], this.showNowButton = () => !this.hasSteps() && this.props.nowButton && A(K(), this.min, this.max), this.handleKeyDown = (s) => {
|
|
37
|
+
const { keyCode: e } = s;
|
|
38
|
+
switch (e) {
|
|
39
|
+
case v.left:
|
|
40
|
+
s.preventDefault(), this.focusList(
|
|
41
|
+
0
|
|
42
|
+
/* Left */
|
|
43
|
+
);
|
|
44
|
+
return;
|
|
45
|
+
case v.right:
|
|
46
|
+
s.preventDefault(), this.focusList(
|
|
47
|
+
1
|
|
48
|
+
/* Right */
|
|
49
|
+
);
|
|
50
|
+
return;
|
|
51
|
+
default:
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
}, this.handleListBlur = () => {
|
|
55
|
+
this.nextTick(() => {
|
|
56
|
+
this.setState({ activeListIndex: -1 });
|
|
57
|
+
});
|
|
58
|
+
}, this.handleListFocus = (s) => {
|
|
59
|
+
clearTimeout(this.nextTickId), this.setState({
|
|
60
|
+
activeListIndex: s
|
|
61
|
+
});
|
|
62
|
+
}, this.handleChange = (s) => {
|
|
63
|
+
const { onChange: e } = this.props;
|
|
64
|
+
e && e.call(void 0, s);
|
|
65
|
+
}, this.snapTime = L(
|
|
66
|
+
x(this.props.steps, this.props.min || a.defaultProps.min)
|
|
67
|
+
), this.state = {
|
|
68
|
+
activeListIndex: -1
|
|
69
|
+
}, this.hasActiveButton = this.hasActiveButton.bind(this);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* @hidden
|
|
73
|
+
*/
|
|
74
|
+
get element() {
|
|
75
|
+
return this._element;
|
|
76
|
+
}
|
|
77
|
+
get value() {
|
|
78
|
+
return _(
|
|
79
|
+
this.snapTime(B(this.props.value || C)),
|
|
80
|
+
this.min,
|
|
81
|
+
this.max
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
get intl() {
|
|
85
|
+
return E(this);
|
|
86
|
+
}
|
|
87
|
+
get min() {
|
|
88
|
+
return this.snapTime(this.props.min || a.defaultProps.min);
|
|
89
|
+
}
|
|
90
|
+
get max() {
|
|
91
|
+
return this.snapTime(this.props.max || a.defaultProps.max);
|
|
92
|
+
}
|
|
93
|
+
get steps() {
|
|
94
|
+
return this.props.steps || a.defaultProps.steps;
|
|
95
|
+
}
|
|
96
|
+
get boundRange() {
|
|
97
|
+
return this.props.boundRange !== void 0 ? this.props.boundRange : a.defaultProps.boundRange;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* @hidden
|
|
101
|
+
*/
|
|
102
|
+
componentWillUnmount() {
|
|
103
|
+
clearTimeout(this.nextTickId);
|
|
104
|
+
}
|
|
105
|
+
componentDidMount() {
|
|
106
|
+
const { onMount: i } = this.props;
|
|
107
|
+
i && i.call(void 0, this.value);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* @hidden
|
|
111
|
+
*/
|
|
112
|
+
render() {
|
|
113
|
+
const {
|
|
114
|
+
format: i,
|
|
115
|
+
smoothScroll: s,
|
|
116
|
+
onNowClick: e,
|
|
117
|
+
className: o,
|
|
118
|
+
disabled: r,
|
|
119
|
+
mobileMode: d,
|
|
120
|
+
show: I,
|
|
121
|
+
onNowKeyDown: T
|
|
122
|
+
} = this.props;
|
|
123
|
+
this.snapTime = L(x(this.steps, this.min)), this.dateFormatParts = this.intl.splitDateFormat(i || a.defaultProps.format).filter(this.timeFormatFilter);
|
|
124
|
+
const N = w(
|
|
125
|
+
{
|
|
126
|
+
"k-disabled": r,
|
|
127
|
+
"k-time-part": d
|
|
128
|
+
},
|
|
129
|
+
o
|
|
130
|
+
);
|
|
131
|
+
this.timeLists = [];
|
|
132
|
+
const f = F(this), g = f.toLanguageString(b, y[b]);
|
|
133
|
+
return /* @__PURE__ */ n.createElement("div", { className: N }, /* @__PURE__ */ n.createElement("div", { className: "k-time-header" }, /* @__PURE__ */ n.createElement("span", { className: "k-title" }, this.intl.formatDate(this.value, this.dateFormatParts.reduce(this.timeFormatReducer, ""))), this.showNowButton() && /* @__PURE__ */ n.createElement(
|
|
134
|
+
$,
|
|
135
|
+
{
|
|
136
|
+
type: "button",
|
|
137
|
+
ref: (m) => {
|
|
138
|
+
this._nowButton = m;
|
|
139
|
+
},
|
|
140
|
+
className: "k-time-now",
|
|
141
|
+
fillMode: "flat",
|
|
142
|
+
themeColor: "primary",
|
|
143
|
+
title: g,
|
|
144
|
+
onKeyDown: T,
|
|
145
|
+
"aria-label": g,
|
|
146
|
+
onClick: e,
|
|
147
|
+
tabIndex: r ? -1 : 0
|
|
148
|
+
},
|
|
149
|
+
f.toLanguageString(k, y[k])
|
|
150
|
+
)), /* @__PURE__ */ n.createElement(
|
|
151
|
+
"div",
|
|
152
|
+
{
|
|
153
|
+
className: "k-time-list-container",
|
|
154
|
+
onKeyDown: this.handleKeyDown
|
|
155
|
+
},
|
|
156
|
+
/* @__PURE__ */ n.createElement("span", { className: "k-time-highlight" }),
|
|
157
|
+
this.dateFormatParts.map((m, l) => m.type !== "literal" ? /* @__PURE__ */ n.createElement(
|
|
158
|
+
"div",
|
|
159
|
+
{
|
|
160
|
+
key: l,
|
|
161
|
+
className: w("k-time-list-wrapper", {
|
|
162
|
+
"k-focus": l === this.state.activeListIndex
|
|
163
|
+
}),
|
|
164
|
+
role: "presentation",
|
|
165
|
+
tabIndex: -1
|
|
166
|
+
},
|
|
167
|
+
/* @__PURE__ */ n.createElement("span", { className: "k-title", onMouseDown: (h) => {
|
|
168
|
+
h.preventDefault();
|
|
169
|
+
} }, this.intl.dateFieldName(m)),
|
|
170
|
+
/* @__PURE__ */ n.createElement(
|
|
171
|
+
S,
|
|
172
|
+
{
|
|
173
|
+
min: this.min,
|
|
174
|
+
max: this.max,
|
|
175
|
+
boundRange: this.boundRange,
|
|
176
|
+
part: m,
|
|
177
|
+
step: m.type ? this.steps[m.type] : 1,
|
|
178
|
+
smoothScroll: s,
|
|
179
|
+
ref: (h) => {
|
|
180
|
+
h && this.timeLists.push(h);
|
|
181
|
+
},
|
|
182
|
+
id: l,
|
|
183
|
+
onFocus: () => {
|
|
184
|
+
this.handleListFocus(l);
|
|
185
|
+
},
|
|
186
|
+
onBlur: this.handleListBlur,
|
|
187
|
+
onChange: this.handleChange,
|
|
188
|
+
value: this.value,
|
|
189
|
+
disabled: r,
|
|
190
|
+
show: I,
|
|
191
|
+
mobileMode: d
|
|
192
|
+
}
|
|
193
|
+
)
|
|
194
|
+
) : /* @__PURE__ */ n.createElement(
|
|
195
|
+
"div",
|
|
196
|
+
{
|
|
197
|
+
key: l,
|
|
198
|
+
className: "k-time-separator"
|
|
199
|
+
},
|
|
200
|
+
m.pattern
|
|
201
|
+
))
|
|
202
|
+
));
|
|
203
|
+
}
|
|
204
|
+
nextTick(i) {
|
|
205
|
+
clearTimeout(this.nextTickId), this.nextTickId = window.setTimeout(() => i());
|
|
206
|
+
}
|
|
207
|
+
hasActiveButton() {
|
|
208
|
+
const i = D(document);
|
|
209
|
+
return this._nowButton && i === this._nowButton.element;
|
|
210
|
+
}
|
|
211
|
+
hasSteps() {
|
|
212
|
+
const i = Object.keys(this.steps);
|
|
213
|
+
return i.length !== i.reduce((s, e) => s + this.steps[e], 0);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
a.propTypes = {
|
|
217
|
+
cancelButton: t.bool,
|
|
218
|
+
disabled: t.bool,
|
|
219
|
+
format: t.oneOfType([
|
|
220
|
+
t.string,
|
|
221
|
+
t.shape({
|
|
222
|
+
skeleton: t.string,
|
|
223
|
+
pattern: t.string,
|
|
224
|
+
date: t.oneOf(["short", "medium", "long", "full"]),
|
|
225
|
+
time: t.oneOf(["short", "medium", "long", "full"]),
|
|
226
|
+
datetime: t.oneOf(["short", "medium", "long", "full"]),
|
|
227
|
+
era: t.oneOf(["narrow", "short", "long"]),
|
|
228
|
+
year: t.oneOf(["numeric", "2-digit"]),
|
|
229
|
+
month: t.oneOf(["numeric", "2-digit", "narrow", "short", "long"]),
|
|
230
|
+
day: t.oneOf(["numeric", "2-digit"]),
|
|
231
|
+
weekday: t.oneOf(["narrow", "short", "long"]),
|
|
232
|
+
hour: t.oneOf(["numeric", "2-digit"]),
|
|
233
|
+
hour12: t.bool,
|
|
234
|
+
minute: t.oneOf(["numeric", "2-digit"]),
|
|
235
|
+
second: t.oneOf(["numeric", "2-digit"]),
|
|
236
|
+
timeZoneName: t.oneOf(["short", "long"])
|
|
237
|
+
})
|
|
238
|
+
]),
|
|
239
|
+
max: t.instanceOf(Date),
|
|
240
|
+
min: t.instanceOf(Date),
|
|
241
|
+
nowButton: t.bool,
|
|
242
|
+
steps: t.shape({
|
|
243
|
+
hour: t.number,
|
|
244
|
+
minute: t.number,
|
|
245
|
+
second: t.number
|
|
246
|
+
}),
|
|
247
|
+
smoothScroll: t.bool,
|
|
248
|
+
tabIndex: t.number,
|
|
249
|
+
value: t.instanceOf(Date),
|
|
250
|
+
show: t.bool
|
|
251
|
+
}, a.defaultProps = {
|
|
252
|
+
value: null,
|
|
253
|
+
disabled: !1,
|
|
254
|
+
nowButton: !0,
|
|
255
|
+
cancelButton: !0,
|
|
256
|
+
format: "hh:mm a",
|
|
257
|
+
min: M,
|
|
258
|
+
max: P,
|
|
259
|
+
steps: {},
|
|
260
|
+
boundRange: !1
|
|
261
|
+
};
|
|
262
|
+
let c = a;
|
|
263
|
+
O(c);
|
|
264
|
+
R(c);
|
|
265
|
+
export {
|
|
266
|
+
c as TimePart
|
|
267
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
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("k-group k-reset",t),h={popupClass:"k-timepicker-popup",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.value||this.state.candidate;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("div",{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,"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;
|