clayui-date-picker 3.165.0
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/LICENSE.md +30 -0
- package/README.md +19 -0
- package/lib/cjs/DateNavigation.js +124 -0
- package/lib/cjs/DayNumber.js +116 -0
- package/lib/cjs/DaysTable.js +49 -0
- package/lib/cjs/Helpers.js +98 -0
- package/lib/cjs/Hooks.js +298 -0
- package/lib/cjs/InputDate.js +58 -0
- package/lib/cjs/Select.js +56 -0
- package/lib/cjs/TimePicker.js +82 -0
- package/lib/cjs/Weekday.js +38 -0
- package/lib/cjs/WeekdayHeader.js +57 -0
- package/lib/cjs/index.js +705 -0
- package/lib/cjs/types.js +33 -0
- package/lib/esm/DateNavigation.js +94 -0
- package/lib/esm/DayNumber.js +86 -0
- package/lib/esm/DaysTable.js +19 -0
- package/lib/esm/Helpers.js +68 -0
- package/lib/esm/Hooks.js +278 -0
- package/lib/esm/InputDate.js +28 -0
- package/lib/esm/Select.js +26 -0
- package/lib/esm/TimePicker.js +52 -0
- package/lib/esm/Weekday.js +8 -0
- package/lib/esm/WeekdayHeader.js +27 -0
- package/lib/esm/index.js +697 -0
- package/lib/esm/types.js +13 -0
- package/package.json +51 -0
package/lib/cjs/Hooks.js
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var Hooks_exports = {};
|
|
20
|
+
__export(Hooks_exports, {
|
|
21
|
+
useCalendarNavigation: () => useCalendarNavigation,
|
|
22
|
+
useCurrentTime: () => useCurrentTime,
|
|
23
|
+
useDaysSelected: () => useDaysSelected,
|
|
24
|
+
useWeeks: () => useWeeks
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(Hooks_exports);
|
|
27
|
+
var import_shared = require("@clayui/shared");
|
|
28
|
+
var import_react = require("react");
|
|
29
|
+
var import_Helpers = require("./Helpers");
|
|
30
|
+
function normalizeTime(date) {
|
|
31
|
+
return (0, import_Helpers.setDate)(date, { hours: 12, milliseconds: 0, minutes: 0, seconds: 0 });
|
|
32
|
+
}
|
|
33
|
+
function useDaysSelected(defaultDays) {
|
|
34
|
+
const [daysSelected, set] = (0, import_react.useState)(defaultDays);
|
|
35
|
+
const setDaysSelected = (0, import_react.useCallback)(([start, end]) => {
|
|
36
|
+
if (start === end) {
|
|
37
|
+
const date = normalizeTime(start);
|
|
38
|
+
set([date, date]);
|
|
39
|
+
} else {
|
|
40
|
+
set([normalizeTime(start), normalizeTime(end)]);
|
|
41
|
+
}
|
|
42
|
+
}, []);
|
|
43
|
+
return [daysSelected, setDaysSelected];
|
|
44
|
+
}
|
|
45
|
+
function useWeeks(currentMonth, firstDayOfWeek) {
|
|
46
|
+
const [weeks, set] = (0, import_react.useState)(
|
|
47
|
+
() => getWeekArray(currentMonth, firstDayOfWeek)
|
|
48
|
+
);
|
|
49
|
+
const setWeeks = (0, import_react.useCallback)(
|
|
50
|
+
(value) => set(getWeekArray(value, firstDayOfWeek)),
|
|
51
|
+
[firstDayOfWeek]
|
|
52
|
+
);
|
|
53
|
+
return [weeks, setWeeks];
|
|
54
|
+
}
|
|
55
|
+
function useCurrentTime(defaultTime, use12Hours) {
|
|
56
|
+
const [currentTime, set] = (0, import_react.useState)(defaultTime);
|
|
57
|
+
const setCurrentTime = (0, import_react.useCallback)(
|
|
58
|
+
(hours, minutes, ampm) => {
|
|
59
|
+
const date = (0, import_Helpers.setDate)(/* @__PURE__ */ new Date(), { hours, minutes });
|
|
60
|
+
if (typeof hours !== "string") {
|
|
61
|
+
if (use12Hours) {
|
|
62
|
+
hours = (0, import_Helpers.formatDate)(date, "hh");
|
|
63
|
+
} else {
|
|
64
|
+
hours = (0, import_Helpers.formatDate)(date, "HH");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (typeof minutes !== "string") {
|
|
68
|
+
minutes = (0, import_Helpers.formatDate)(date, "mm");
|
|
69
|
+
}
|
|
70
|
+
const value = ampm ? `${hours}:${minutes} ${ampm}` : `${hours}:${minutes}`;
|
|
71
|
+
set(value);
|
|
72
|
+
return value;
|
|
73
|
+
},
|
|
74
|
+
[use12Hours]
|
|
75
|
+
);
|
|
76
|
+
return [currentTime, setCurrentTime];
|
|
77
|
+
}
|
|
78
|
+
function useCalendarNavigation({
|
|
79
|
+
daysSelected,
|
|
80
|
+
isOpen,
|
|
81
|
+
onChangeMonth,
|
|
82
|
+
weeks
|
|
83
|
+
}) {
|
|
84
|
+
const [lastItemFocused, setLastItemFocused] = (0, import_react.useState)(null);
|
|
85
|
+
const gridRef = (0, import_react.useRef)(null);
|
|
86
|
+
const lastKeyPressedRef = (0, import_react.useRef)("");
|
|
87
|
+
const hasNextFocusRef = (0, import_react.useRef)(false);
|
|
88
|
+
const focusNext = (0, import_react.useCallback)((day) => {
|
|
89
|
+
if (!gridRef.current) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const nextFocusElement = gridRef.current.querySelector(
|
|
93
|
+
`button[aria-label="${(0, import_Helpers.setDate)(day.date, {
|
|
94
|
+
hours: 12,
|
|
95
|
+
milliseconds: 0,
|
|
96
|
+
minutes: 0,
|
|
97
|
+
seconds: 0
|
|
98
|
+
}).toDateString()}"]`
|
|
99
|
+
);
|
|
100
|
+
if (nextFocusElement) {
|
|
101
|
+
nextFocusElement.focus();
|
|
102
|
+
setLastItemFocused(String(day.date.getDate()));
|
|
103
|
+
}
|
|
104
|
+
}, []);
|
|
105
|
+
const onKeyDown = (0, import_react.useCallback)(
|
|
106
|
+
(event) => {
|
|
107
|
+
switch (event.key) {
|
|
108
|
+
case import_shared.Keys.Down:
|
|
109
|
+
case import_shared.Keys.Up:
|
|
110
|
+
case import_shared.Keys.Right:
|
|
111
|
+
case import_shared.Keys.Left: {
|
|
112
|
+
event.preventDefault();
|
|
113
|
+
const currentRowPosition = Number(
|
|
114
|
+
document.activeElement.closest("[role=row]").getAttribute("data-index")
|
|
115
|
+
);
|
|
116
|
+
const position = Number(
|
|
117
|
+
document.activeElement.getAttribute("data-index")
|
|
118
|
+
);
|
|
119
|
+
const currentRow = weeks[currentRowPosition];
|
|
120
|
+
let nextFocus = null;
|
|
121
|
+
switch (event.key) {
|
|
122
|
+
case import_shared.Keys.Right:
|
|
123
|
+
case import_shared.Keys.Left: {
|
|
124
|
+
nextFocus = currentRow[event.key === import_shared.Keys.Left ? position - 1 : position + 1];
|
|
125
|
+
if (!nextFocus) {
|
|
126
|
+
nextFocus = weeks[event.key === import_shared.Keys.Left ? currentRowPosition - 1 : currentRowPosition + 1]?.[event.key === import_shared.Keys.Left ? currentRow.length - 1 : 0];
|
|
127
|
+
}
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
case import_shared.Keys.Up:
|
|
131
|
+
case import_shared.Keys.Down: {
|
|
132
|
+
nextFocus = weeks[event.key === import_shared.Keys.Up ? currentRowPosition - 1 : currentRowPosition + 1]?.[position];
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
default:
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
if (nextFocus && !nextFocus.nextMonth && !nextFocus.previousMonth) {
|
|
139
|
+
focusNext(nextFocus);
|
|
140
|
+
} else {
|
|
141
|
+
onChangeMonth(
|
|
142
|
+
event.key === import_shared.Keys.Left || event.key === import_shared.Keys.Up ? -1 : 1
|
|
143
|
+
);
|
|
144
|
+
lastKeyPressedRef.current = event.key;
|
|
145
|
+
hasNextFocusRef.current = true;
|
|
146
|
+
}
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
case import_shared.Keys.End:
|
|
150
|
+
case import_shared.Keys.Home: {
|
|
151
|
+
event.preventDefault();
|
|
152
|
+
const grid = event.currentTarget.querySelectorAll(
|
|
153
|
+
"button:not(.previous-month-date):not(.next-month-date)"
|
|
154
|
+
);
|
|
155
|
+
const day = grid[event.key === import_shared.Keys.Home ? 0 : grid.length - 1];
|
|
156
|
+
if (day) {
|
|
157
|
+
day.focus();
|
|
158
|
+
setLastItemFocused(day.innerText);
|
|
159
|
+
}
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
case "PageDown":
|
|
163
|
+
case "PageUp": {
|
|
164
|
+
event.preventDefault();
|
|
165
|
+
const value = event.key === "PageUp" ? -1 : 1;
|
|
166
|
+
if (event.shiftKey) {
|
|
167
|
+
onChangeMonth(0, value);
|
|
168
|
+
} else {
|
|
169
|
+
onChangeMonth(value);
|
|
170
|
+
}
|
|
171
|
+
lastKeyPressedRef.current = event.key;
|
|
172
|
+
hasNextFocusRef.current = true;
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
default:
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
[weeks]
|
|
180
|
+
);
|
|
181
|
+
const onFocus = (0, import_react.useCallback)((event) => {
|
|
182
|
+
setLastItemFocused(event.target.innerText);
|
|
183
|
+
}, []);
|
|
184
|
+
const isFocused = (0, import_react.useCallback)(
|
|
185
|
+
(day) => {
|
|
186
|
+
return !day.nextMonth && !day.previousMonth && (lastItemFocused === String(day.date.getDate()) || lastItemFocused === null && day.date.toDateString() === daysSelected[0].toDateString());
|
|
187
|
+
},
|
|
188
|
+
[lastItemFocused, daysSelected]
|
|
189
|
+
);
|
|
190
|
+
(0, import_react.useEffect)(() => {
|
|
191
|
+
if (gridRef.current && isOpen) {
|
|
192
|
+
focusNext({ date: daysSelected[0] });
|
|
193
|
+
}
|
|
194
|
+
}, [daysSelected]);
|
|
195
|
+
(0, import_react.useEffect)(() => {
|
|
196
|
+
if (gridRef.current) {
|
|
197
|
+
if (isOpen) {
|
|
198
|
+
const focusNext2 = gridRef.current.querySelector(
|
|
199
|
+
'button:not([tabindex="-1"])'
|
|
200
|
+
);
|
|
201
|
+
if (focusNext2) {
|
|
202
|
+
focusNext2.focus();
|
|
203
|
+
}
|
|
204
|
+
} else {
|
|
205
|
+
setLastItemFocused(null);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}, [isOpen]);
|
|
209
|
+
(0, import_react.useEffect)(() => {
|
|
210
|
+
if (hasNextFocusRef.current && gridRef.current) {
|
|
211
|
+
hasNextFocusRef.current = false;
|
|
212
|
+
const position = Number(
|
|
213
|
+
document.activeElement.getAttribute("data-index")
|
|
214
|
+
);
|
|
215
|
+
const row = weeks[lastKeyPressedRef.current === import_shared.Keys.Left || lastKeyPressedRef.current === import_shared.Keys.Up ? weeks.length - 1 : 0];
|
|
216
|
+
switch (lastKeyPressedRef.current) {
|
|
217
|
+
case import_shared.Keys.Right:
|
|
218
|
+
case import_shared.Keys.Left: {
|
|
219
|
+
const newRow = row.filter(
|
|
220
|
+
(value) => !value.nextMonth && !value.previousMonth
|
|
221
|
+
);
|
|
222
|
+
focusNext(
|
|
223
|
+
newRow[lastKeyPressedRef.current === import_shared.Keys.Left ? newRow.length - 1 : 0]
|
|
224
|
+
);
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
case import_shared.Keys.Down:
|
|
228
|
+
case import_shared.Keys.Up: {
|
|
229
|
+
let nextFocus = row.map(
|
|
230
|
+
(value) => !value.nextMonth && !value.previousMonth ? value : null
|
|
231
|
+
)[position];
|
|
232
|
+
if (!nextFocus) {
|
|
233
|
+
nextFocus = weeks[lastKeyPressedRef.current === import_shared.Keys.Up ? weeks.length - 2 : 1][position];
|
|
234
|
+
}
|
|
235
|
+
focusNext(nextFocus);
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
case "PageDown":
|
|
239
|
+
case "PageUp": {
|
|
240
|
+
const focusNext2 = gridRef.current.querySelector(
|
|
241
|
+
'button:not([tabindex="-1"])'
|
|
242
|
+
);
|
|
243
|
+
if (focusNext2) {
|
|
244
|
+
focusNext2.focus();
|
|
245
|
+
}
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
default:
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
lastKeyPressedRef.current = "";
|
|
252
|
+
}
|
|
253
|
+
}, [weeks]);
|
|
254
|
+
const gridProps = { onFocus, onKeyDown, ref: gridRef };
|
|
255
|
+
return {
|
|
256
|
+
gridProps,
|
|
257
|
+
isFocused
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
function getDaysInMonth(d) {
|
|
261
|
+
const firstDayOfMonth = new Date(d.getFullYear(), d.getMonth(), 1, 12);
|
|
262
|
+
firstDayOfMonth.setMonth(firstDayOfMonth.getMonth() + 1);
|
|
263
|
+
firstDayOfMonth.setDate(firstDayOfMonth.getDate() - 1);
|
|
264
|
+
return firstDayOfMonth.getDate();
|
|
265
|
+
}
|
|
266
|
+
function getWeekArray(d, firstDayOfWeek = 0) {
|
|
267
|
+
const daysInMonth = getDaysInMonth(d);
|
|
268
|
+
const dayArray = [];
|
|
269
|
+
let week = [];
|
|
270
|
+
const weekArray = [];
|
|
271
|
+
for (let i = 1; i <= daysInMonth; i += 1) {
|
|
272
|
+
const genDay = new Date(d.getFullYear(), d.getMonth(), i, 12);
|
|
273
|
+
dayArray.push({ date: genDay });
|
|
274
|
+
}
|
|
275
|
+
dayArray.forEach((day) => {
|
|
276
|
+
if (!!week.length && day.date.getDay() === firstDayOfWeek) {
|
|
277
|
+
weekArray.push(week);
|
|
278
|
+
week = [];
|
|
279
|
+
}
|
|
280
|
+
week.push(day);
|
|
281
|
+
if (dayArray.indexOf(day) === dayArray.length - 1) {
|
|
282
|
+
weekArray.push(week);
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
const firstWeek = weekArray[0];
|
|
286
|
+
for (let i = 7 - firstWeek.length; i > 0; i -= 1) {
|
|
287
|
+
const outsideDate = (0, import_Helpers.clone)(firstWeek[0].date);
|
|
288
|
+
outsideDate.setDate(firstWeek[0].date.getDate() - 1);
|
|
289
|
+
firstWeek.unshift({ date: outsideDate, previousMonth: true });
|
|
290
|
+
}
|
|
291
|
+
const lastWeek = weekArray[weekArray.length - 1];
|
|
292
|
+
for (let i = lastWeek.length; i < 7; i += 1) {
|
|
293
|
+
const outsideDate = (0, import_Helpers.clone)(lastWeek[lastWeek.length - 1].date);
|
|
294
|
+
outsideDate.setDate(lastWeek[lastWeek.length - 1].date.getDate() + 1);
|
|
295
|
+
lastWeek.push({ date: outsideDate, nextMonth: true });
|
|
296
|
+
}
|
|
297
|
+
return weekArray;
|
|
298
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var InputDate_exports = {};
|
|
30
|
+
__export(InputDate_exports, {
|
|
31
|
+
default: () => InputDate_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(InputDate_exports);
|
|
34
|
+
var import_form = require("@clayui/form");
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
const ClayDatePickerInputDate = import_react.default.forwardRef(
|
|
37
|
+
({
|
|
38
|
+
ariaLabel,
|
|
39
|
+
inputName = "datePicker",
|
|
40
|
+
useNative = false,
|
|
41
|
+
value = "",
|
|
42
|
+
...otherProps
|
|
43
|
+
}, ref) => {
|
|
44
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("input", { name: inputName, type: "hidden", value }), /* @__PURE__ */ import_react.default.createElement(
|
|
45
|
+
import_form.ClayInput,
|
|
46
|
+
{
|
|
47
|
+
...otherProps,
|
|
48
|
+
"aria-label": ariaLabel,
|
|
49
|
+
insetAfter: !useNative,
|
|
50
|
+
ref,
|
|
51
|
+
type: useNative ? "date" : "text",
|
|
52
|
+
value
|
|
53
|
+
}
|
|
54
|
+
));
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
ClayDatePickerInputDate.displayName = "ClayDatePickerInputDate";
|
|
58
|
+
var InputDate_default = ClayDatePickerInputDate;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var Select_exports = {};
|
|
30
|
+
__export(Select_exports, {
|
|
31
|
+
default: () => Select_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(Select_exports);
|
|
34
|
+
var import_react = __toESM(require("react"));
|
|
35
|
+
const ClayDatePickerSelect = import_react.default.forwardRef(
|
|
36
|
+
({ options, testId, ...otherProps }, ref) => /* @__PURE__ */ import_react.default.createElement(
|
|
37
|
+
"select",
|
|
38
|
+
{
|
|
39
|
+
...otherProps,
|
|
40
|
+
className: "form-control form-control-sm",
|
|
41
|
+
"data-testid": testId,
|
|
42
|
+
ref
|
|
43
|
+
},
|
|
44
|
+
options.map((option, index) => /* @__PURE__ */ import_react.default.createElement(
|
|
45
|
+
"option",
|
|
46
|
+
{
|
|
47
|
+
key: index,
|
|
48
|
+
selected: option.selected ? true : void 0,
|
|
49
|
+
value: option.value
|
|
50
|
+
},
|
|
51
|
+
option.label
|
|
52
|
+
))
|
|
53
|
+
)
|
|
54
|
+
);
|
|
55
|
+
ClayDatePickerSelect.displayName = "ClayDatePickerSelect";
|
|
56
|
+
var Select_default = ClayDatePickerSelect;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var TimePicker_exports = {};
|
|
30
|
+
__export(TimePicker_exports, {
|
|
31
|
+
default: () => TimePicker_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(TimePicker_exports);
|
|
34
|
+
var import_time_picker = __toESM(require("@clayui/time-picker"));
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
const DEFAULT_VALUE = "--";
|
|
37
|
+
function ClayDatePickerTimePicker({
|
|
38
|
+
config,
|
|
39
|
+
currentTime,
|
|
40
|
+
disabled,
|
|
41
|
+
onTimeChange,
|
|
42
|
+
spritemap,
|
|
43
|
+
timezone,
|
|
44
|
+
use12Hours
|
|
45
|
+
}) {
|
|
46
|
+
const [values, setValues] = import_react.default.useState({
|
|
47
|
+
ampm: DEFAULT_VALUE,
|
|
48
|
+
hours: DEFAULT_VALUE,
|
|
49
|
+
minutes: DEFAULT_VALUE
|
|
50
|
+
});
|
|
51
|
+
const handleOnChange = (values2) => {
|
|
52
|
+
const hours = values2.hours === DEFAULT_VALUE ? DEFAULT_VALUE : Number(values2.hours);
|
|
53
|
+
const minutes = values2.minutes === DEFAULT_VALUE ? DEFAULT_VALUE : Number(values2.minutes);
|
|
54
|
+
const ampm = values2.ampm ? values2.ampm : DEFAULT_VALUE;
|
|
55
|
+
setValues(values2);
|
|
56
|
+
onTimeChange(hours, minutes, ampm);
|
|
57
|
+
};
|
|
58
|
+
import_react.default.useEffect(() => {
|
|
59
|
+
const [hours, minutesAndAmpm] = currentTime.split(":");
|
|
60
|
+
const [minutes, ampm] = minutesAndAmpm.split(" ");
|
|
61
|
+
setValues((prevValues) => ({
|
|
62
|
+
...prevValues,
|
|
63
|
+
ampm,
|
|
64
|
+
hours: String(hours),
|
|
65
|
+
minutes: String(minutes)
|
|
66
|
+
}));
|
|
67
|
+
}, [currentTime, use12Hours]);
|
|
68
|
+
return /* @__PURE__ */ import_react.default.createElement("div", { className: "time-picker" }, /* @__PURE__ */ import_react.default.createElement(
|
|
69
|
+
import_time_picker.default,
|
|
70
|
+
{
|
|
71
|
+
config,
|
|
72
|
+
disabled,
|
|
73
|
+
icon: true,
|
|
74
|
+
onInputChange: handleOnChange,
|
|
75
|
+
spritemap,
|
|
76
|
+
timezone,
|
|
77
|
+
use12Hours,
|
|
78
|
+
values
|
|
79
|
+
}
|
|
80
|
+
));
|
|
81
|
+
}
|
|
82
|
+
var TimePicker_default = ClayDatePickerTimePicker;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var Weekday_exports = {};
|
|
30
|
+
__export(Weekday_exports, {
|
|
31
|
+
default: () => Weekday_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(Weekday_exports);
|
|
34
|
+
var import_react = __toESM(require("react"));
|
|
35
|
+
function ClayDatePickerWeekday({ weekday }) {
|
|
36
|
+
return /* @__PURE__ */ import_react.default.createElement("div", { className: "date-picker-col" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "date-picker-calendar-item date-picker-day" }, /* @__PURE__ */ import_react.default.createElement("abbr", null, weekday)));
|
|
37
|
+
}
|
|
38
|
+
var Weekday_default = ClayDatePickerWeekday;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var WeekdayHeader_exports = {};
|
|
30
|
+
__export(WeekdayHeader_exports, {
|
|
31
|
+
default: () => WeekdayHeader_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(WeekdayHeader_exports);
|
|
34
|
+
var import_react = __toESM(require("react"));
|
|
35
|
+
function ClayDatePickerWeekdayHeader({
|
|
36
|
+
children,
|
|
37
|
+
firstDayOfWeek = 0,
|
|
38
|
+
weekdaysShort
|
|
39
|
+
}) {
|
|
40
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
41
|
+
"div",
|
|
42
|
+
{
|
|
43
|
+
"aria-hidden": "true",
|
|
44
|
+
className: "date-picker-days-row date-picker-row",
|
|
45
|
+
role: "presentation"
|
|
46
|
+
},
|
|
47
|
+
weekdaysShort.map((_weekday, index) => {
|
|
48
|
+
return import_react.default.Children.only(
|
|
49
|
+
children({
|
|
50
|
+
key: index,
|
|
51
|
+
weekday: weekdaysShort[(index + firstDayOfWeek) % 7]
|
|
52
|
+
})
|
|
53
|
+
);
|
|
54
|
+
})
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
var WeekdayHeader_default = ClayDatePickerWeekdayHeader;
|