@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,503 @@
|
|
|
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 h from "react";
|
|
10
|
+
import e from "prop-types";
|
|
11
|
+
import { cloneDate as m, isEqual as M } from "@progress/kendo-date-math";
|
|
12
|
+
import { Button as k } from "@progress/kendo-react-buttons";
|
|
13
|
+
import { caretAltUpIcon as T, caretAltDownIcon as V } from "@progress/kendo-svg-icons";
|
|
14
|
+
import { provideIntlService as w, provideLocalizationService as B, registerForIntl as _, registerForLocalization as L } from "@progress/kendo-react-intl";
|
|
15
|
+
import { KendoDate as N } from "./models/kendo-date.mjs";
|
|
16
|
+
import { getActiveElement as c, validatePackage as A, AsyncFocusBlur as q, classNames as z, kendoThemeMaps as P, noop as R, createPropsContext as K, withIdHOC as U, withPropsContext as H } from "@progress/kendo-react-common";
|
|
17
|
+
import { FloatingLabel as $ } from "@progress/kendo-react-labels";
|
|
18
|
+
import { packageMetadata as j } from "../package-metadata.mjs";
|
|
19
|
+
import { approximateStringMatching as X, defaultFormat as Y, defaultFormatPlaceholder as G, isInRange as W, wrapperClasses as Z } from "./utils.mjs";
|
|
20
|
+
import { MAX_DATE as J, MIN_DATE as Q, MIN_TIME as ee, MAX_TIME as te } from "../utils.mjs";
|
|
21
|
+
import { increaseValue as f, messages as g, decreaseValue as v } from "../messages/index.mjs";
|
|
22
|
+
import { isInTimeRange as ie } from "../timepicker/utils.mjs";
|
|
23
|
+
const se = "Please enter a valid value!", o = class o extends h.Component {
|
|
24
|
+
constructor(i) {
|
|
25
|
+
super(i), this.kendoDate = null, this.currentFormat = "", this.paste = !1, this._element = null, this._wrapper = null, this._lastSelectedSymbol = "", this.focus = () => {
|
|
26
|
+
this._element && this._element.focus();
|
|
27
|
+
}, this.setValidity = () => {
|
|
28
|
+
this.element && this.element.setCustomValidity && this.element.setCustomValidity(
|
|
29
|
+
this.validity.valid ? "" : this.props.validationMessage || o.defaultProps.validationMessage
|
|
30
|
+
);
|
|
31
|
+
}, this.updateOnPaste = (t) => {
|
|
32
|
+
if (!this.element || !this.kendoDate)
|
|
33
|
+
return;
|
|
34
|
+
const s = w(this).parseDate(this.element.value, this.props.format) || this.value, r = this.value;
|
|
35
|
+
this.kendoDate.setValue(s), this.triggerChange(t, r);
|
|
36
|
+
}, this.spinnersMouseDown = (t) => {
|
|
37
|
+
t.preventDefault();
|
|
38
|
+
const s = c(document);
|
|
39
|
+
this.element && s !== this.element && this.element.focus({ preventScroll: !0 });
|
|
40
|
+
}, this.handlePaste = () => {
|
|
41
|
+
this.paste = !0;
|
|
42
|
+
}, this.elementChange = (t) => {
|
|
43
|
+
if (!this.element || !this.kendoDate)
|
|
44
|
+
return;
|
|
45
|
+
if (this.paste) {
|
|
46
|
+
this.updateOnPaste(t), this.paste = !1;
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const { text: s, format: r } = this.kendoDate.getTextAndFormat();
|
|
50
|
+
this.currentFormat = r;
|
|
51
|
+
const n = this.value, a = X(
|
|
52
|
+
s,
|
|
53
|
+
this.currentFormat,
|
|
54
|
+
this.element.value,
|
|
55
|
+
this.selection.start
|
|
56
|
+
), l = a.length === 1 && a[0][1] === "_";
|
|
57
|
+
if (!l)
|
|
58
|
+
for (let d = 0; d < a.length; d++)
|
|
59
|
+
this.kendoDate.parsePart(a[d][0], a[d][1]);
|
|
60
|
+
a.length && a[0][0] !== "_" && this.setSelection(this.selectionBySymbol(a[0][0])), l && this.switchDateSegment(1), this.triggerChange(t, n);
|
|
61
|
+
}, this.elementClick = (t) => {
|
|
62
|
+
this.setSelection(this.selectionByIndex(this.selection.start));
|
|
63
|
+
}, this.nativeWheel = (t) => {
|
|
64
|
+
c(document) === this.element && t.preventDefault();
|
|
65
|
+
}, this.wheel = (t) => {
|
|
66
|
+
c(document) === this.element && (t.nativeEvent.deltaY < 0 && this.increasePart(t), t.nativeEvent.deltaY > 0 && this.decreasePart(t));
|
|
67
|
+
}, this.increasePart = (t) => {
|
|
68
|
+
this.modifyDateSegmentValue(1, t);
|
|
69
|
+
}, this.decreasePart = (t) => {
|
|
70
|
+
this.modifyDateSegmentValue(-1, t);
|
|
71
|
+
}, this.elementKeyDown = (t) => {
|
|
72
|
+
if (!t.altKey) {
|
|
73
|
+
switch (t.keyCode) {
|
|
74
|
+
case 37:
|
|
75
|
+
this.switchDateSegment(-1);
|
|
76
|
+
break;
|
|
77
|
+
case 38:
|
|
78
|
+
this.modifyDateSegmentValue(1, t);
|
|
79
|
+
break;
|
|
80
|
+
case 39:
|
|
81
|
+
this.switchDateSegment(1);
|
|
82
|
+
break;
|
|
83
|
+
case 40:
|
|
84
|
+
this.modifyDateSegmentValue(-1, t);
|
|
85
|
+
break;
|
|
86
|
+
default:
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
t.preventDefault();
|
|
90
|
+
}
|
|
91
|
+
}, this.elementOnFocus = (t) => {
|
|
92
|
+
this.wrapper && this.wrapper.classList.add("k-focus"), this.setState({ focused: !0 });
|
|
93
|
+
}, this.elementOnBlur = (t) => {
|
|
94
|
+
this.wrapper && this.wrapper.classList.remove("k-focus"), this.setState({ focused: !1 });
|
|
95
|
+
}, A(j), this.state = {
|
|
96
|
+
focused: !1
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
get _inputId() {
|
|
100
|
+
return this.props.id + "-accessibility-id";
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* @hidden
|
|
104
|
+
*/
|
|
105
|
+
componentDidMount() {
|
|
106
|
+
this.setValidity(), this.wrapper && this.wrapper.addEventListener("wheel", this.nativeWheel, { passive: !1 });
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* @hidden
|
|
110
|
+
*/
|
|
111
|
+
componentDidUpdate(i, t) {
|
|
112
|
+
this._lastSelectedSymbol && t.focused === this.state.focused ? this.setSelection(this.selectionBySymbol(this._lastSelectedSymbol)) : this.props.placeholder !== void 0 && this.selection.start === this.selection.end && this.setSelection({ start: 0, end: this.currentFormat.length }), this.setValidity();
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* @hidden
|
|
116
|
+
*/
|
|
117
|
+
componentWillUnmount() {
|
|
118
|
+
this.wrapper && this.wrapper.removeEventListener("wheel", this.nativeWheel);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* @hidden
|
|
122
|
+
*/
|
|
123
|
+
render() {
|
|
124
|
+
const {
|
|
125
|
+
size: i = o.defaultProps.size,
|
|
126
|
+
fillMode: t = o.defaultProps.fillMode,
|
|
127
|
+
rounded: s = o.defaultProps.rounded
|
|
128
|
+
} = this.props;
|
|
129
|
+
this.props._ref && (this.props._ref.current = this);
|
|
130
|
+
const r = B(this), n = { ...o.defaultProps, ...this.props }, { name: a, label: l, id: d } = n, p = this.text, O = p === this.props.placeholder ? "" : p, E = p === this.props.placeholder ? p : void 0, b = d || this._inputId, D = !this.validityStyles || this.validity.valid;
|
|
131
|
+
let x = [...Z];
|
|
132
|
+
this.props.className && x.push(this.props.className);
|
|
133
|
+
const S = /* @__PURE__ */ h.createElement(q, { onFocus: this.elementOnFocus, onBlur: this.elementOnBlur }, ({ onFocus: C, onBlur: I }) => /* @__PURE__ */ h.createElement(
|
|
134
|
+
"span",
|
|
135
|
+
{
|
|
136
|
+
ref: (y) => {
|
|
137
|
+
this._wrapper = y;
|
|
138
|
+
},
|
|
139
|
+
style: l ? void 0 : { width: this.props.width },
|
|
140
|
+
dir: this.props.dir,
|
|
141
|
+
className: z(
|
|
142
|
+
"k-dateinput",
|
|
143
|
+
"k-input",
|
|
144
|
+
{
|
|
145
|
+
[`k-input-${P.sizeMap[i] || i}`]: i,
|
|
146
|
+
[`k-input-${t}`]: t,
|
|
147
|
+
[`k-rounded-${P.roundedMap[s] || s}`]: s,
|
|
148
|
+
"k-invalid": !D,
|
|
149
|
+
"k-required": this.required,
|
|
150
|
+
"k-disabled": this.props.disabled
|
|
151
|
+
},
|
|
152
|
+
this.props.className
|
|
153
|
+
),
|
|
154
|
+
onFocus: C,
|
|
155
|
+
onBlur: I
|
|
156
|
+
},
|
|
157
|
+
/* @__PURE__ */ h.createElement(
|
|
158
|
+
"input",
|
|
159
|
+
{
|
|
160
|
+
role: this.props.ariaRole || "textbox",
|
|
161
|
+
readOnly: this.props.readonly,
|
|
162
|
+
tabIndex: this.props.tabIndex,
|
|
163
|
+
disabled: this.props.disabled,
|
|
164
|
+
title: this.props.title !== void 0 ? this.props.title : p,
|
|
165
|
+
type: "text",
|
|
166
|
+
spellCheck: !1,
|
|
167
|
+
autoComplete: "off",
|
|
168
|
+
autoCorrect: "off",
|
|
169
|
+
className: "k-input-inner",
|
|
170
|
+
id: b,
|
|
171
|
+
"aria-label": this.props.ariaLabel,
|
|
172
|
+
"aria-labelledby": this.props.ariaLabelledBy,
|
|
173
|
+
"aria-describedby": this.props.ariaDescribedBy,
|
|
174
|
+
"aria-haspopup": this.props.ariaHasPopup,
|
|
175
|
+
"aria-disabled": this.props.disabled,
|
|
176
|
+
"aria-expanded": this.props.ariaExpanded,
|
|
177
|
+
"aria-controls": this.props.ariaControls,
|
|
178
|
+
onWheel: this.wheel,
|
|
179
|
+
onClick: this.elementClick,
|
|
180
|
+
onInput: this.elementChange,
|
|
181
|
+
onPaste: this.handlePaste,
|
|
182
|
+
onKeyDown: this.elementKeyDown,
|
|
183
|
+
onChange: R,
|
|
184
|
+
value: O,
|
|
185
|
+
placeholder: E,
|
|
186
|
+
name: a,
|
|
187
|
+
ref: (y) => this._element = y
|
|
188
|
+
}
|
|
189
|
+
),
|
|
190
|
+
this.props.children,
|
|
191
|
+
this.props.spinners && /* @__PURE__ */ h.createElement("span", { className: "k-input-spinner k-spin-button", onMouseDown: this.spinnersMouseDown }, /* @__PURE__ */ h.createElement(
|
|
192
|
+
k,
|
|
193
|
+
{
|
|
194
|
+
tabIndex: -1,
|
|
195
|
+
type: "button",
|
|
196
|
+
rounded: null,
|
|
197
|
+
className: "k-spinner-increase",
|
|
198
|
+
icon: "caret-alt-up",
|
|
199
|
+
svgIcon: T,
|
|
200
|
+
"aria-label": r.toLanguageString(f, g[f]),
|
|
201
|
+
title: r.toLanguageString(f, g[f]),
|
|
202
|
+
onClick: this.increasePart
|
|
203
|
+
}
|
|
204
|
+
), /* @__PURE__ */ h.createElement(
|
|
205
|
+
k,
|
|
206
|
+
{
|
|
207
|
+
tabIndex: -1,
|
|
208
|
+
type: "button",
|
|
209
|
+
rounded: null,
|
|
210
|
+
className: "k-spinner-decrease",
|
|
211
|
+
icon: "caret-alt-down",
|
|
212
|
+
svgIcon: V,
|
|
213
|
+
"aria-label": r.toLanguageString(v, g[v]),
|
|
214
|
+
title: r.toLanguageString(v, g[v]),
|
|
215
|
+
onClick: this.decreasePart
|
|
216
|
+
}
|
|
217
|
+
))
|
|
218
|
+
));
|
|
219
|
+
return l ? /* @__PURE__ */ h.createElement(
|
|
220
|
+
$,
|
|
221
|
+
{
|
|
222
|
+
label: l,
|
|
223
|
+
editorId: b,
|
|
224
|
+
editorValue: p,
|
|
225
|
+
editorValid: D,
|
|
226
|
+
editorDisabled: this.props.disabled,
|
|
227
|
+
children: S,
|
|
228
|
+
style: { width: this.props.width }
|
|
229
|
+
}
|
|
230
|
+
) : S;
|
|
231
|
+
}
|
|
232
|
+
/* Public Getters */
|
|
233
|
+
/**
|
|
234
|
+
* Gets the value of the DateInput.
|
|
235
|
+
*/
|
|
236
|
+
get value() {
|
|
237
|
+
return this.valueDuringOnChange !== void 0 ? this.valueDuringOnChange : this.kendoDate && this.kendoDate.getDateObject();
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Gets the `name` property of the DateInput.
|
|
241
|
+
*/
|
|
242
|
+
get name() {
|
|
243
|
+
return this.props.name;
|
|
244
|
+
}
|
|
245
|
+
get min() {
|
|
246
|
+
return this.props.min !== void 0 ? this.props.min : o.defaultProps.min;
|
|
247
|
+
}
|
|
248
|
+
get max() {
|
|
249
|
+
return this.props.max !== void 0 ? this.props.max : o.defaultProps.max;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* @hidden
|
|
253
|
+
*/
|
|
254
|
+
get text() {
|
|
255
|
+
const i = { ...F.defaultProps, ...this.props }, {
|
|
256
|
+
formatPlaceholder: t = o.defaultProps.formatPlaceholder,
|
|
257
|
+
format: s = o.defaultProps.format,
|
|
258
|
+
value: r,
|
|
259
|
+
defaultValue: n
|
|
260
|
+
} = i;
|
|
261
|
+
this.kendoDate === null ? (this.kendoDate = new N(this.intl.bind(this), t, s), this.kendoDate.setValue(r || n || null)) : (this.kendoDate.format = s, this.kendoDate.formatPlaceholder = t), r !== void 0 && this.value !== r && this.kendoDate.setValue(r);
|
|
262
|
+
const { text: a, format: l } = this.kendoDate.getTextAndFormat();
|
|
263
|
+
return this.currentFormat = l, i.placeholder !== null && i.placeholder !== void 0 && !this.state.focused && !this.kendoDate.hasValue() ? i.placeholder : a;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Represents the validity state into which the DateInput is set.
|
|
267
|
+
*/
|
|
268
|
+
get validity() {
|
|
269
|
+
const i = W(this.value, this.min, this.max) && ie(this.value, this.props.minTime, this.props.maxTime), t = this.props.validationMessage !== void 0, s = (!this.required || this.value !== null) && i, r = this.props.valid !== void 0 ? this.props.valid : s;
|
|
270
|
+
return {
|
|
271
|
+
customError: t,
|
|
272
|
+
rangeOverflow: this.value && this.max.getTime() < this.value.getTime() || !1,
|
|
273
|
+
rangeUnderflow: this.value && this.value.getTime() < this.min.getTime() || !1,
|
|
274
|
+
valid: r,
|
|
275
|
+
valueMissing: this.value === null
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Gets the element of the DateInput.
|
|
280
|
+
*
|
|
281
|
+
* @return - An `HTMLInputElement`.
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* ```jsx
|
|
285
|
+
* class App extends React.Component {
|
|
286
|
+
* constructor(props) {
|
|
287
|
+
* super(props);
|
|
288
|
+
* }
|
|
289
|
+
* element = null;
|
|
290
|
+
* render() {
|
|
291
|
+
* return (
|
|
292
|
+
* <div>
|
|
293
|
+
* <DateInput
|
|
294
|
+
* ref={(dateInput) =>
|
|
295
|
+
* this.element = dateInput ? dateInput.element : null}
|
|
296
|
+
* />
|
|
297
|
+
* <button onClick={() => console.log(this.element)}>console.log the element</button>
|
|
298
|
+
* </div>
|
|
299
|
+
* );
|
|
300
|
+
* }
|
|
301
|
+
* }
|
|
302
|
+
*
|
|
303
|
+
* ReactDOM.render(
|
|
304
|
+
* <App />,
|
|
305
|
+
* document.getElementsByTagName('my-app')[0]
|
|
306
|
+
* );
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
get element() {
|
|
310
|
+
return this._element;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* @hidden
|
|
314
|
+
*/
|
|
315
|
+
get validityStyles() {
|
|
316
|
+
return this.props.validityStyles !== void 0 ? this.props.validityStyles : o.defaultProps.validityStyles;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* @hidden
|
|
320
|
+
*/
|
|
321
|
+
get required() {
|
|
322
|
+
return this.props.required !== void 0 ? this.props.required : o.defaultProps.required;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* @hidden
|
|
326
|
+
*/
|
|
327
|
+
get wrapper() {
|
|
328
|
+
return this._wrapper;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* @hidden
|
|
332
|
+
*/
|
|
333
|
+
intl() {
|
|
334
|
+
return w(this);
|
|
335
|
+
}
|
|
336
|
+
/* end handlers */
|
|
337
|
+
get selection() {
|
|
338
|
+
let i = { start: 0, end: 0 };
|
|
339
|
+
return this.element !== null && this.element.selectionStart !== void 0 && (i = { start: this.element.selectionStart, end: this.element.selectionEnd }), i;
|
|
340
|
+
}
|
|
341
|
+
setSelection(i) {
|
|
342
|
+
this._lastSelectedSymbol = this.currentFormat[i.start], window.requestAnimationFrame(() => {
|
|
343
|
+
const t = c(document);
|
|
344
|
+
this.element && t === this.element && !this.props.disableSelection && this.element.setSelectionRange(i.start, i.end);
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
triggerChange(i, t) {
|
|
348
|
+
this.valueDuringOnChange = this.value, this.forceUpdate(), this.props.onChange && !M(t, this.value) && this.props.onChange.call(void 0, {
|
|
349
|
+
syntheticEvent: i,
|
|
350
|
+
nativeEvent: i.nativeEvent,
|
|
351
|
+
value: this.value,
|
|
352
|
+
target: this
|
|
353
|
+
// inRange: this.props.min && this.props.max ? isInRange(value, this.props.min, this.props.max) : true
|
|
354
|
+
}), this.valueDuringOnChange = void 0;
|
|
355
|
+
}
|
|
356
|
+
selectionBySymbol(i) {
|
|
357
|
+
let t = -1, s = 0;
|
|
358
|
+
for (let r = 0; r < this.currentFormat.length; r++)
|
|
359
|
+
this.currentFormat[r] === i && (s = r + 1, t === -1 && (t = r));
|
|
360
|
+
return t < 0 && (t = 0), { start: t, end: s };
|
|
361
|
+
}
|
|
362
|
+
selectionByIndex(i) {
|
|
363
|
+
let t = { start: i, end: i };
|
|
364
|
+
for (let s = i, r = i - 1; s < this.currentFormat.length || r >= 0; s++, r--) {
|
|
365
|
+
if (s < this.currentFormat.length && this.currentFormat[s] !== "_") {
|
|
366
|
+
t = this.selectionBySymbol(this.currentFormat[s]);
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
if (r >= 0 && this.currentFormat[r] !== "_") {
|
|
370
|
+
t = this.selectionBySymbol(this.currentFormat[r]);
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
return t;
|
|
375
|
+
}
|
|
376
|
+
switchDateSegment(i) {
|
|
377
|
+
const { start: t, end: s } = this.selection;
|
|
378
|
+
if (t < s && this.currentFormat[t] !== this.currentFormat[s - 1]) {
|
|
379
|
+
this.setSelection(this.selectionByIndex(i > 0 ? t : s - 1));
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
const r = this.currentFormat[t];
|
|
383
|
+
let n = t + i;
|
|
384
|
+
for (; n > 0 && n < this.currentFormat.length && !(this.currentFormat[n] !== r && this.currentFormat[n] !== "_"); )
|
|
385
|
+
n += i;
|
|
386
|
+
if (this.currentFormat[n] === "_")
|
|
387
|
+
return;
|
|
388
|
+
let a = n;
|
|
389
|
+
for (; a >= 0 && a < this.currentFormat.length && this.currentFormat[a] === this.currentFormat[n]; )
|
|
390
|
+
a += i;
|
|
391
|
+
n > a && (a + 1 !== t || n + 1 !== s) ? this.setSelection({ start: a + 1, end: n + 1 }) : n < a && (n !== t || a !== s) && this.setSelection({ start: n, end: a });
|
|
392
|
+
}
|
|
393
|
+
modifyDateSegmentValue(i, t) {
|
|
394
|
+
if (!this.kendoDate)
|
|
395
|
+
return;
|
|
396
|
+
const s = this.value, r = this.currentFormat[this.selection.start], n = this.kendoDate.symbolMap(r), a = ((this.props.steps || {})[n] || 1) * i;
|
|
397
|
+
this.kendoDate.modifyPart(r, a), this.triggerChange(t, s);
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
o.displayName = "DateInput", o.propTypes = {
|
|
401
|
+
value: e.instanceOf(Date),
|
|
402
|
+
format: e.oneOfType([
|
|
403
|
+
e.string,
|
|
404
|
+
e.shape({
|
|
405
|
+
skeleton: e.string,
|
|
406
|
+
pattern: e.string,
|
|
407
|
+
date: e.oneOf(["short", "medium", "long", "full"]),
|
|
408
|
+
time: e.oneOf(["short", "medium", "long", "full"]),
|
|
409
|
+
datetime: e.oneOf(["short", "medium", "long", "full"]),
|
|
410
|
+
era: e.oneOf(["narrow", "short", "long"]),
|
|
411
|
+
year: e.oneOf(["numeric", "2-digit"]),
|
|
412
|
+
month: e.oneOf(["numeric", "2-digit", "narrow", "short", "long"]),
|
|
413
|
+
day: e.oneOf(["numeric", "2-digit"]),
|
|
414
|
+
weekday: e.oneOf(["narrow", "short", "long"]),
|
|
415
|
+
hour: e.oneOf(["numeric", "2-digit"]),
|
|
416
|
+
hour12: e.bool,
|
|
417
|
+
minute: e.oneOf(["numeric", "2-digit"]),
|
|
418
|
+
second: e.oneOf(["numeric", "2-digit"]),
|
|
419
|
+
timeZoneName: e.oneOf(["short", "long"])
|
|
420
|
+
})
|
|
421
|
+
]),
|
|
422
|
+
formatPlaceholder: e.oneOfType([
|
|
423
|
+
e.oneOf(["wide", "narrow", "short", "formatPattern"]),
|
|
424
|
+
e.shape({
|
|
425
|
+
year: e.string,
|
|
426
|
+
month: e.string,
|
|
427
|
+
day: e.string,
|
|
428
|
+
hour: e.string,
|
|
429
|
+
minute: e.string,
|
|
430
|
+
second: e.string
|
|
431
|
+
})
|
|
432
|
+
]),
|
|
433
|
+
width: e.oneOfType([
|
|
434
|
+
e.string,
|
|
435
|
+
e.number
|
|
436
|
+
]),
|
|
437
|
+
tabIndex: e.number,
|
|
438
|
+
title: e.string,
|
|
439
|
+
steps: e.shape({
|
|
440
|
+
year: e.number,
|
|
441
|
+
month: e.number,
|
|
442
|
+
day: e.number,
|
|
443
|
+
hour: e.number,
|
|
444
|
+
minute: e.number,
|
|
445
|
+
second: e.number
|
|
446
|
+
}),
|
|
447
|
+
min: e.instanceOf(Date),
|
|
448
|
+
max: e.instanceOf(Date),
|
|
449
|
+
disabled: e.bool,
|
|
450
|
+
spinners: e.bool,
|
|
451
|
+
name: e.string,
|
|
452
|
+
dir: e.string,
|
|
453
|
+
label: e.string,
|
|
454
|
+
id: e.string,
|
|
455
|
+
ariaLabelledBy: e.string,
|
|
456
|
+
ariaDescribedBy: e.string,
|
|
457
|
+
ariaLabel: e.string,
|
|
458
|
+
ariaRole: e.string,
|
|
459
|
+
ariaHasPopup: e.oneOfType([
|
|
460
|
+
e.bool,
|
|
461
|
+
e.string
|
|
462
|
+
]),
|
|
463
|
+
ariaExpanded: e.oneOfType([
|
|
464
|
+
e.bool
|
|
465
|
+
]),
|
|
466
|
+
onChange: e.func,
|
|
467
|
+
validationMessage: e.string,
|
|
468
|
+
required: e.bool,
|
|
469
|
+
validate: e.bool,
|
|
470
|
+
valid: e.bool,
|
|
471
|
+
size: e.oneOf([null, "small", "medium", "large"]),
|
|
472
|
+
rounded: e.oneOf([null, "small", "medium", "large", "full"]),
|
|
473
|
+
fillMode: e.oneOf([null, "solid", "flat", "outline"])
|
|
474
|
+
}, o.defaultProps = {
|
|
475
|
+
format: Y,
|
|
476
|
+
size: "medium",
|
|
477
|
+
rounded: "medium",
|
|
478
|
+
fillMode: "solid",
|
|
479
|
+
formatPlaceholder: G,
|
|
480
|
+
// defaultValue: null as Date | null,
|
|
481
|
+
spinners: !1,
|
|
482
|
+
disabled: !1,
|
|
483
|
+
max: m(J),
|
|
484
|
+
min: m(Q),
|
|
485
|
+
minTime: m(ee),
|
|
486
|
+
maxTime: m(te),
|
|
487
|
+
required: !1,
|
|
488
|
+
validityStyles: !0,
|
|
489
|
+
validationMessage: se,
|
|
490
|
+
placeholder: null,
|
|
491
|
+
// the rest of the properties are undefined by default
|
|
492
|
+
ariaHasPopup: "grid"
|
|
493
|
+
};
|
|
494
|
+
let u = o;
|
|
495
|
+
const re = K(), F = U(H(re, u));
|
|
496
|
+
F.displayName = "KendoReactDateInput";
|
|
497
|
+
_(u);
|
|
498
|
+
L(u);
|
|
499
|
+
export {
|
|
500
|
+
F as DateInput,
|
|
501
|
+
re as DateInputPropsContext,
|
|
502
|
+
u as DateInputWithoutContext
|
|
503
|
+
};
|
|
@@ -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 r=require("@progress/kendo-date-math"),p=require("./mask.js"),M=require("../utils.js");class y{constructor(t,e,s){this.year=!0,this.month=!0,this.date=!0,this.hours=!0,this.minutes=!0,this.seconds=!0,this.milliseconds=!0,this.leadingZero=null,this.typedMonthPart="",this.knownParts="adHhmMsEy",this.symbols={E:"E",H:"H",M:"M",a:"a",d:"d",h:"h",m:"m",s:"s",y:"y"},this._value=r.getDate(new Date),this.intlProvider=t,this.formatPlaceholder=e,this.format=s,this.monthNames=this.allFormatedMonths()}get intl(){return this.intlProvider()}get value(){return this._value}setValue(t){t?r.isEqual(t,this._value)||(this._value=r.cloneDate(t),this.modifyExisting(!0)):(this._value=r.getDate(new Date),this.modifyExisting(!1))}hasValue(){const t=(e,s)=>e||s.type!=="literal"&&s.type!=="dayperiod"&&this.getExisting(s.pattern[0]);return this.intl.splitDateFormat(this.format).reduce(t,!1)}getDateObject(){for(let t=0;t<this.knownParts.length;t++)if(!this.getExisting(this.knownParts[t]))return null;return r.cloneDate(this.value)}getTextAndFormat(){return this.merge(this.intl.formatDate(this.value,this.format),this.dateFormatString(this.value,this.format))}modifyExisting(t){const e=this.dateFormatString(this.value,this.format).symbols;for(let s=0;s<e.length;s++)this.setExisting(e[s],t)}getExisting(t){switch(t){case"y":return this.year;case"M":case"L":return this.month;case"d":return this.date;case"E":return this.date&&this.month&&this.year;case"h":case"H":return this.hours;case"m":return this.minutes;case"s":return this.seconds;default:return!0}}setExisting(t,e){switch(t){case"y":this.year=e,e===!1&&this._value.setFullYear(2e3);break;case"M":this.month=e,e===!1&&this._value.setMonth(0);break;case"d":this.date=e;break;case"h":case"H":this.hours=e;break;case"m":this.minutes=e;break;case"s":this.seconds=e;break;default:return}}modifyPart(t,e){let s=r.cloneDate(this.value);switch(t){case"y":s.setFullYear(s.getFullYear()+e);break;case"M":s=r.addMonths(this.value,e);break;case"d":case"E":s.setDate(s.getDate()+e);break;case"h":case"H":s.setHours(s.getHours()+e);break;case"m":s.setMinutes(s.getMinutes()+e);break;case"s":s.setSeconds(s.getSeconds()+e);break;case"a":s.setHours(s.getHours()+12*e);break}this.setExisting(t,!0),this._value=s}parsePart(t,e){if(this.resetLeadingZero(),!e)return this.setExisting(t,!1),{value:null};const s=this.intl.formatDate(this.value,this.format),n=this.dateFormatString(this.value,this.format),h=n.symbols;let i=!1,l="",o="",m="";for(let u=0;u<s.length;u++)h[u]===t?(o+=this.getExisting(t)?s[u]:"0",i=!0):i?m+=s[u]:l+=s[u];let a=null;const c=this.matchMonth(e);for(;o.length>0&&o.charAt(0)==="0";)o=o.slice(1);o.length>=4&&(o="");for(let u=0;u<2;u++){let g=o+e,f=parseInt(g,10);if(a=this.intl.parseDate(l+g+m,this.format),!a&&!isNaN(f)&&!isNaN(parseInt(e,10))){if(t==="M"&&!c){const d=f-1;d>-1&&d<12&&(a=r.cloneDate(this.value),a.setMonth(d),a.getMonth()!==d&&(a=r.lastDayOfMonth(r.addMonths(a,-1))))}t==="y"&&(a=r.createDate(parseInt(g,10),this.month?this.value.getMonth():0,this.date?this.value.getDate():1,this.hours?this.value.getHours():0,this.minutes?this.value.getMinutes():0,this.seconds?this.value.getSeconds():0,this.milliseconds?this.value.getMilliseconds():0),this.date&&a.getDate()!==this.value.getDate()&&(a=r.lastDayOfMonth(r.addMonths(a,-1))))}if(a)return this._value=a,this.setExisting(t,!0),{value:this.value};o=""}return c&&(a=this.intl.parseDate(l+c+m,this.format),a)?(this._value=a,this.setExisting(t,!0),{value:this.value}):(e==="0"&&(this.leadingZero=this.isAbbrMonth(n.partMap,t)?null:{[t]:!0},this.setExisting(t,!1)),{value:null})}symbolMap(t){return this.intl.splitDateFormat(this.format).reduce(M.dateSymbolMap,{})[t]}resetLeadingZero(){const t=this.leadingZero!==null;return this.leadingZero=null,t}isAbbrMonth(t,e){const s=this.partPattern(t,e);return s.type==="month"&&s.names}partPattern(t,e){return t.filter(s=>s.pattern.indexOf(e)!==-1)[0]}matchMonth(t){if(this.typedMonthPart+=t.toLowerCase(),this.monthNames.length===0)return"";for(;this.typedMonthPart.length>0;){for(let s=0;s<this.monthNames.length;s++)if(this.monthNames[s].toLowerCase().indexOf(this.typedMonthPart)===0)return this.monthNames[s];const e=parseInt(this.typedMonthPart,10);if(e>=1&&e<=12&&e.toString()===this.typedMonthPart)return this.monthNames[e-1];this.typedMonthPart=this.typedMonthPart.substring(1,this.typedMonthPart.length)}return""}allFormatedMonths(){const t=this.intl.splitDateFormat(this.format);for(let e=0;e<t.length;e++)if(t[e].type==="month"&&t[e].names)return this.intl.dateFormatNames(t[e].names);return[]}dateFormatString(t,e){const s=this.intl.splitDateFormat(e),n=[],h=[];for(let l=0;l<s.length;l++){let o=this.intl.formatDate(t,{pattern:s[l].pattern}).length;for(;o>0;)n.push(this.symbols[s[l].pattern[0]]||"_"),h.push(s[l]),o--}const i=new p.Mask;return i.symbols=n.join(""),i.partMap=h,i}merge(t,e){let s="",n="",h=e.symbols;for(let i=h.length-1;i>=0;i--)if(this.knownParts.indexOf(h[i])===-1||this.getExisting(h[i]))s=t[i]+s,n=h[i]+n;else{const l=h[i];for(;i>=0&&l===h[i];)i--;for(i++,this.leadingZero&&this.leadingZero[l]?s="0"+s:s=this.dateFieldName(e.partMap[i])+s;n.length<s.length;)n=h[i]+n}return{text:s,format:n}}dateFieldName(t){const e=this.formatPlaceholder||"wide";return e[t.type]?e[t.type]:e==="formatPattern"?t.pattern:this.intl.dateFieldName(Object.assign(t,{nameType:e}))}}exports.KendoDate=y;
|