@kalyx/react 1.0.0-rc.1 → 1.0.0-rc.2
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/CHANGELOG.md +49 -0
- package/dist/index.cjs +251 -152
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +254 -155
- package/dist/index.js.map +1 -1
- package/package.json +18 -3
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
'use strict';
|
|
2
3
|
|
|
3
4
|
var react = require('react');
|
|
@@ -57,10 +58,10 @@ function DatePickerRoot({
|
|
|
57
58
|
const currentValue = isControlled ? controlledValue ?? null : uncontrolledValue;
|
|
58
59
|
const [isOpen, setIsOpen] = react.useState(false);
|
|
59
60
|
const [viewMonth, setViewMonth] = react.useState(
|
|
60
|
-
currentValue ?? adapter.today(displayTimezone)
|
|
61
|
+
() => currentValue ?? adapter.today(displayTimezone)
|
|
61
62
|
);
|
|
62
63
|
const [focusedDate, setFocusedDate] = react.useState(
|
|
63
|
-
currentValue ?? adapter.today(displayTimezone)
|
|
64
|
+
() => currentValue ?? adapter.today(displayTimezone)
|
|
64
65
|
);
|
|
65
66
|
useChangeEffect(isOpen, onOpenChange);
|
|
66
67
|
const viewMonthStart = react.useMemo(() => adapter.startOfMonth(viewMonth), [viewMonth, adapter]);
|
|
@@ -151,10 +152,11 @@ function DatePickerRoot({
|
|
|
151
152
|
return /* @__PURE__ */ jsxRuntime.jsx(DatePickerContext.Provider, { value: contextValue, children });
|
|
152
153
|
}
|
|
153
154
|
var DatePickerInput = react.forwardRef(
|
|
154
|
-
function DatePickerInput2({ format: formatProp, onClick, onBlur, onKeyDown, ...props }, ref) {
|
|
155
|
+
function DatePickerInput2({ format: formatProp, name, onClick, onBlur, onKeyDown, ...props }, ref) {
|
|
155
156
|
const ctx = useDatePickerContext("DatePicker.Input");
|
|
156
157
|
const displayFormat = formatProp ?? ctx.displayFormat;
|
|
157
158
|
const [inputText, setInputText] = react.useState(null);
|
|
159
|
+
const isComposingRef = react.useRef(false);
|
|
158
160
|
let formattedValue = "";
|
|
159
161
|
if (ctx.value) {
|
|
160
162
|
try {
|
|
@@ -171,47 +173,62 @@ var DatePickerInput = react.forwardRef(
|
|
|
171
173
|
},
|
|
172
174
|
[ctx, onClick]
|
|
173
175
|
);
|
|
176
|
+
const commitText = react.useCallback(
|
|
177
|
+
(text) => {
|
|
178
|
+
if (!text) {
|
|
179
|
+
ctx.selectDate(null);
|
|
180
|
+
setInputText(null);
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
const parsed = core.parseInputValue(text, ctx.adapter);
|
|
184
|
+
if (parsed) {
|
|
185
|
+
ctx.selectDate(parsed);
|
|
186
|
+
setInputText(null);
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
return false;
|
|
190
|
+
},
|
|
191
|
+
[ctx]
|
|
192
|
+
);
|
|
174
193
|
const handleBlur = react.useCallback(
|
|
175
194
|
(e) => {
|
|
176
195
|
if (inputText !== null) {
|
|
177
|
-
|
|
178
|
-
if (parsed) {
|
|
179
|
-
ctx.selectDate(parsed);
|
|
180
|
-
}
|
|
196
|
+
commitText(inputText);
|
|
181
197
|
setInputText(null);
|
|
182
198
|
}
|
|
183
199
|
onBlur?.(e);
|
|
184
200
|
},
|
|
185
|
-
[inputText,
|
|
201
|
+
[inputText, commitText, onBlur]
|
|
186
202
|
);
|
|
187
203
|
const handleChange = react.useCallback(
|
|
188
204
|
(e) => {
|
|
189
205
|
const text = e.target.value;
|
|
190
206
|
setInputText(text);
|
|
191
|
-
if (
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
207
|
+
if (isComposingRef.current) return;
|
|
208
|
+
commitText(text);
|
|
209
|
+
},
|
|
210
|
+
[commitText]
|
|
211
|
+
);
|
|
212
|
+
const handleCompositionStart = react.useCallback(() => {
|
|
213
|
+
isComposingRef.current = true;
|
|
214
|
+
}, []);
|
|
215
|
+
const handleCompositionEnd = react.useCallback(
|
|
216
|
+
(e) => {
|
|
217
|
+
isComposingRef.current = false;
|
|
218
|
+
commitText(e.target.value);
|
|
201
219
|
},
|
|
202
|
-
[
|
|
220
|
+
[commitText]
|
|
203
221
|
);
|
|
204
222
|
const handleKeyDown = react.useCallback(
|
|
205
223
|
(e) => {
|
|
206
224
|
if (e.key === "Escape") {
|
|
207
225
|
ctx.close();
|
|
208
226
|
} else if (e.key === "Enter") {
|
|
227
|
+
if (ctx.isOpen) e.preventDefault();
|
|
209
228
|
if (inputText !== null) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
setInputText(null);
|
|
214
|
-
}
|
|
229
|
+
commitText(inputText);
|
|
230
|
+
} else if (ctx.isOpen) {
|
|
231
|
+
ctx.selectDate(ctx.focusedDate);
|
|
215
232
|
}
|
|
216
233
|
} else if (e.key === "ArrowDown" && !ctx.isOpen) {
|
|
217
234
|
e.preventDefault();
|
|
@@ -219,36 +236,42 @@ var DatePickerInput = react.forwardRef(
|
|
|
219
236
|
}
|
|
220
237
|
onKeyDown?.(e);
|
|
221
238
|
},
|
|
222
|
-
[ctx, inputText,
|
|
239
|
+
[ctx, inputText, commitText, onKeyDown]
|
|
223
240
|
);
|
|
224
241
|
const calendarId = `${ctx.pickerId}-calendar`;
|
|
225
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
242
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
243
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
244
|
+
"input",
|
|
245
|
+
{
|
|
246
|
+
ref: (node) => {
|
|
247
|
+
ctx.referenceRef.current = node;
|
|
248
|
+
if (typeof ref === "function") ref(node);
|
|
249
|
+
else if (ref) ref.current = node;
|
|
250
|
+
},
|
|
251
|
+
type: "text",
|
|
252
|
+
role: "combobox",
|
|
253
|
+
"aria-expanded": ctx.isOpen,
|
|
254
|
+
"aria-haspopup": "dialog",
|
|
255
|
+
"aria-controls": ctx.isOpen ? calendarId : void 0,
|
|
256
|
+
"aria-autocomplete": "none",
|
|
257
|
+
autoComplete: "off",
|
|
258
|
+
value: displayValue,
|
|
259
|
+
disabled: ctx.isDisabled || props.disabled,
|
|
260
|
+
readOnly: ctx.isReadOnly,
|
|
261
|
+
onChange: handleChange,
|
|
262
|
+
onClick: handleClick,
|
|
263
|
+
onBlur: handleBlur,
|
|
264
|
+
onKeyDown: handleKeyDown,
|
|
265
|
+
onCompositionStart: handleCompositionStart,
|
|
266
|
+
onCompositionEnd: handleCompositionEnd,
|
|
267
|
+
...props
|
|
268
|
+
}
|
|
269
|
+
),
|
|
270
|
+
name ? /* @__PURE__ */ jsxRuntime.jsx("input", { type: "hidden", name, value: ctx.value ?? "" }) : null
|
|
271
|
+
] });
|
|
250
272
|
}
|
|
251
273
|
);
|
|
274
|
+
DatePickerInput.displayName = "DatePicker.Input";
|
|
252
275
|
var DatePickerTrigger = react.forwardRef(
|
|
253
276
|
function DatePickerTrigger2({ onClick, children, ...props }, ref) {
|
|
254
277
|
const ctx = useDatePickerContext("DatePicker.Trigger");
|
|
@@ -272,6 +295,7 @@ var DatePickerTrigger = react.forwardRef(
|
|
|
272
295
|
tabIndex: 0,
|
|
273
296
|
"aria-label": ctx.isOpen ? ctx.labels.triggerClose : ctx.labels.triggerOpen,
|
|
274
297
|
"aria-expanded": ctx.isOpen,
|
|
298
|
+
"aria-haspopup": "dialog",
|
|
275
299
|
"aria-controls": ctx.isOpen ? calendarId : void 0,
|
|
276
300
|
disabled: ctx.isDisabled || props.disabled,
|
|
277
301
|
onClick: handleClick,
|
|
@@ -302,6 +326,8 @@ var DatePickerTrigger = react.forwardRef(
|
|
|
302
326
|
);
|
|
303
327
|
}
|
|
304
328
|
);
|
|
329
|
+
DatePickerTrigger.displayName = "DatePicker.Trigger";
|
|
330
|
+
var POPOVER_MIDDLEWARE = [react$1.offset(4), react$1.flip(), react$1.shift({ padding: 8 })];
|
|
305
331
|
function usePopover({
|
|
306
332
|
isOpen,
|
|
307
333
|
close,
|
|
@@ -313,7 +339,7 @@ function usePopover({
|
|
|
313
339
|
const { refs, floatingStyles, isPositioned } = react$1.useFloating({
|
|
314
340
|
open: isOpen,
|
|
315
341
|
placement,
|
|
316
|
-
middleware:
|
|
342
|
+
middleware: POPOVER_MIDDLEWARE,
|
|
317
343
|
whileElementsMounted: react$1.autoUpdate
|
|
318
344
|
});
|
|
319
345
|
react.useEffect(() => {
|
|
@@ -360,6 +386,24 @@ function usePopover({
|
|
|
360
386
|
document.addEventListener("keydown", handleKeyDown);
|
|
361
387
|
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
362
388
|
}, [isOpen, close]);
|
|
389
|
+
react.useEffect(() => {
|
|
390
|
+
if (!isOpen) return;
|
|
391
|
+
function handleFocusOut(e) {
|
|
392
|
+
const next = e.relatedTarget;
|
|
393
|
+
const floating = floatingRef.current;
|
|
394
|
+
const reference = referenceRef.current;
|
|
395
|
+
if (!next) return;
|
|
396
|
+
const insideFloating = floating?.contains(next) ?? false;
|
|
397
|
+
const insideReference = reference?.contains(next) ?? false;
|
|
398
|
+
if (!insideFloating && !insideReference) {
|
|
399
|
+
close();
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
const node = floatingRef.current;
|
|
403
|
+
if (!node) return;
|
|
404
|
+
node.addEventListener("focusout", handleFocusOut);
|
|
405
|
+
return () => node.removeEventListener("focusout", handleFocusOut);
|
|
406
|
+
}, [isOpen, close, referenceRef]);
|
|
363
407
|
const setFloatingRef = react.useCallback(
|
|
364
408
|
(node) => {
|
|
365
409
|
floatingRef.current = node;
|
|
@@ -427,14 +471,17 @@ function DatePickerCalendar({
|
|
|
427
471
|
const gridRef = react.useRef(null);
|
|
428
472
|
const [announcement, setAnnouncement] = react.useState("");
|
|
429
473
|
const { adapter, viewMonth, focusedDate, weekStartsOn, disabled, locale, displayTimezone } = ctx;
|
|
430
|
-
const weekdays = core.getWeekdayNames(locale, weekStartsOn);
|
|
431
|
-
const weeks =
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
474
|
+
const weekdays = react.useMemo(() => core.getWeekdayNames(locale, weekStartsOn), [locale, weekStartsOn]);
|
|
475
|
+
const weeks = react.useMemo(
|
|
476
|
+
() => core.getCalendarDays(viewMonth, adapter, {
|
|
477
|
+
weekStartsOn,
|
|
478
|
+
selected: ctx.value,
|
|
479
|
+
focusedDate,
|
|
480
|
+
disabled,
|
|
481
|
+
timezone: displayTimezone
|
|
482
|
+
}),
|
|
483
|
+
[viewMonth, adapter, weekStartsOn, ctx.value, focusedDate, disabled, displayTimezone]
|
|
484
|
+
);
|
|
438
485
|
const year = adapter.getYear(viewMonth);
|
|
439
486
|
const month = adapter.getMonth(viewMonth);
|
|
440
487
|
const title = core.formatMonthYear(year, month, locale);
|
|
@@ -514,6 +561,15 @@ function DatePickerCalendar({
|
|
|
514
561
|
}
|
|
515
562
|
if (newFocused) {
|
|
516
563
|
e.preventDefault();
|
|
564
|
+
const skipStep = e.key === "ArrowLeft" || e.key === "ArrowUp" || e.key === "PageUp" || e.key === "Home" ? -1 : 1;
|
|
565
|
+
let attempts = 0;
|
|
566
|
+
while (core.isDateDisabled(newFocused, disabled, adapter) && attempts < 42) {
|
|
567
|
+
newFocused = adapter.addDays(newFocused, skipStep);
|
|
568
|
+
attempts++;
|
|
569
|
+
}
|
|
570
|
+
if (attempts >= 42) {
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
517
573
|
ctx.setFocusedDate(newFocused);
|
|
518
574
|
if (!adapter.isSameMonth(newFocused, viewMonth)) {
|
|
519
575
|
ctx.setViewMonth(newFocused);
|
|
@@ -561,56 +617,69 @@ function DatePickerCalendar({
|
|
|
561
617
|
ref: gridRef,
|
|
562
618
|
role: "grid",
|
|
563
619
|
"aria-label": title,
|
|
620
|
+
"aria-rowcount": weeks.length + 1,
|
|
621
|
+
"aria-colcount": 7,
|
|
564
622
|
className: classNames?.grid,
|
|
565
623
|
onKeyDown: handleKeyDown,
|
|
566
624
|
children: [
|
|
567
|
-
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsx("tr", { role: "row", children: weekdays.map((day) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
625
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsx("tr", { role: "row", "aria-rowindex": 1, children: weekdays.map((day, colIndex) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
568
626
|
"th",
|
|
569
627
|
{
|
|
570
628
|
role: "columnheader",
|
|
571
629
|
abbr: day.full,
|
|
572
630
|
scope: "col",
|
|
631
|
+
"aria-colindex": colIndex + 1,
|
|
573
632
|
className: classNames?.weekdayHeader,
|
|
574
633
|
children: day.short
|
|
575
634
|
},
|
|
576
635
|
day.short
|
|
577
636
|
)) }) }),
|
|
578
|
-
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: weeks.map((week, weekIndex) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
"
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
595
|
-
"button",
|
|
637
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: weeks.map((week, weekIndex) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
638
|
+
"tr",
|
|
639
|
+
{
|
|
640
|
+
role: "row",
|
|
641
|
+
"aria-rowindex": weekIndex + 2,
|
|
642
|
+
className: classNames?.gridRow,
|
|
643
|
+
children: week.map((day, colIndex) => {
|
|
644
|
+
const dayClasses = [
|
|
645
|
+
classNames?.day,
|
|
646
|
+
day.isSelected && classNames?.daySelected,
|
|
647
|
+
day.isToday && classNames?.dayToday,
|
|
648
|
+
day.isDisabled && classNames?.dayDisabled,
|
|
649
|
+
!day.isCurrentMonth && classNames?.dayOutsideMonth
|
|
650
|
+
].filter(Boolean).join(" ") || void 0;
|
|
651
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
652
|
+
"td",
|
|
596
653
|
{
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
"
|
|
601
|
-
"
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
654
|
+
role: "gridcell",
|
|
655
|
+
"aria-colindex": colIndex + 1,
|
|
656
|
+
"aria-selected": day.isSelected || void 0,
|
|
657
|
+
"aria-disabled": day.isDisabled || void 0,
|
|
658
|
+
"aria-current": day.isToday ? "date" : void 0,
|
|
659
|
+
className: classNames?.gridCell,
|
|
660
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
661
|
+
"button",
|
|
662
|
+
{
|
|
663
|
+
type: "button",
|
|
664
|
+
tabIndex: day.isFocused ? 0 : -1,
|
|
665
|
+
disabled: day.isDisabled,
|
|
666
|
+
"data-focused": day.isFocused || void 0,
|
|
667
|
+
"data-selected": day.isSelected || void 0,
|
|
668
|
+
"data-today": day.isToday || void 0,
|
|
669
|
+
"data-outside-month": !day.isCurrentMonth || void 0,
|
|
670
|
+
className: dayClasses,
|
|
671
|
+
onClick: () => handleDayClick(day),
|
|
672
|
+
"aria-label": safeFormatFullDate(day.isoString, locale),
|
|
673
|
+
children: day.dayNumber
|
|
674
|
+
}
|
|
675
|
+
)
|
|
676
|
+
},
|
|
677
|
+
day.isoString
|
|
678
|
+
);
|
|
679
|
+
})
|
|
680
|
+
},
|
|
681
|
+
weekIndex
|
|
682
|
+
)) })
|
|
614
683
|
]
|
|
615
684
|
}
|
|
616
685
|
),
|
|
@@ -931,10 +1000,10 @@ function RangePickerRoot({
|
|
|
931
1000
|
const [selectingTarget, setSelectingTarget] = react.useState("start");
|
|
932
1001
|
const [hoverDate, setHoverDate] = react.useState(null);
|
|
933
1002
|
const [viewMonth, setViewMonth] = react.useState(
|
|
934
|
-
currentValue.start ?? adapter.today(displayTimezone)
|
|
1003
|
+
() => currentValue.start ?? adapter.today(displayTimezone)
|
|
935
1004
|
);
|
|
936
1005
|
const [focusedDate, setFocusedDate] = react.useState(
|
|
937
|
-
currentValue.start ?? adapter.today(displayTimezone)
|
|
1006
|
+
() => currentValue.start ?? adapter.today(displayTimezone)
|
|
938
1007
|
);
|
|
939
1008
|
useChangeEffect(isOpen, onOpenChange);
|
|
940
1009
|
const viewMonthStart = react.useMemo(() => adapter.startOfMonth(viewMonth), [viewMonth, adapter]);
|
|
@@ -1084,6 +1153,8 @@ var RangePickerInput = react.forwardRef(
|
|
|
1084
1153
|
(e) => {
|
|
1085
1154
|
if (e.key === "Escape") {
|
|
1086
1155
|
ctx.close();
|
|
1156
|
+
} else if (e.key === "Enter" && ctx.isOpen) {
|
|
1157
|
+
e.preventDefault();
|
|
1087
1158
|
} else if (e.key === "ArrowDown" && !ctx.isOpen) {
|
|
1088
1159
|
e.preventDefault();
|
|
1089
1160
|
ctx.open();
|
|
@@ -1120,6 +1191,7 @@ var RangePickerInput = react.forwardRef(
|
|
|
1120
1191
|
);
|
|
1121
1192
|
}
|
|
1122
1193
|
);
|
|
1194
|
+
RangePickerInput.displayName = "RangePicker.Input";
|
|
1123
1195
|
function RangePickerPopover({ children, ...props }) {
|
|
1124
1196
|
const ctx = useRangePickerContext("RangePicker.Popover");
|
|
1125
1197
|
const calendarId = `${ctx.pickerId}-calendar`;
|
|
@@ -1186,15 +1258,18 @@ function RangePickerCalendar({
|
|
|
1186
1258
|
displayTimezone
|
|
1187
1259
|
} = ctx;
|
|
1188
1260
|
const { locale } = ctx;
|
|
1189
|
-
const weekdays = core.getWeekdayNames(locale, weekStartsOn);
|
|
1190
|
-
const weeks =
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1261
|
+
const weekdays = react.useMemo(() => core.getWeekdayNames(locale, weekStartsOn), [locale, weekStartsOn]);
|
|
1262
|
+
const weeks = react.useMemo(
|
|
1263
|
+
() => core.getCalendarDays(viewMonth, adapter, {
|
|
1264
|
+
weekStartsOn,
|
|
1265
|
+
focusedDate,
|
|
1266
|
+
disabled,
|
|
1267
|
+
range: value,
|
|
1268
|
+
rangeHover: hoverDate,
|
|
1269
|
+
timezone: displayTimezone
|
|
1270
|
+
}),
|
|
1271
|
+
[viewMonth, adapter, weekStartsOn, focusedDate, disabled, value, hoverDate, displayTimezone]
|
|
1272
|
+
);
|
|
1198
1273
|
const year = adapter.getYear(viewMonth);
|
|
1199
1274
|
const month = adapter.getMonth(viewMonth);
|
|
1200
1275
|
const title = core.formatMonthYear(year, month, locale);
|
|
@@ -1294,6 +1369,13 @@ function RangePickerCalendar({
|
|
|
1294
1369
|
}
|
|
1295
1370
|
if (newFocused) {
|
|
1296
1371
|
e.preventDefault();
|
|
1372
|
+
const skipStep = e.key === "ArrowLeft" || e.key === "ArrowUp" || e.key === "PageUp" || e.key === "Home" ? -1 : 1;
|
|
1373
|
+
let attempts = 0;
|
|
1374
|
+
while (core.isDateDisabled(newFocused, disabled, adapter) && attempts < 42) {
|
|
1375
|
+
newFocused = adapter.addDays(newFocused, skipStep);
|
|
1376
|
+
attempts++;
|
|
1377
|
+
}
|
|
1378
|
+
if (attempts >= 42) return;
|
|
1297
1379
|
ctx.setFocusedDate(newFocused);
|
|
1298
1380
|
if (!adapter.isSameMonth(newFocused, viewMonth)) {
|
|
1299
1381
|
ctx.setViewMonth(newFocused);
|
|
@@ -1347,62 +1429,75 @@ function RangePickerCalendar({
|
|
|
1347
1429
|
role: "grid",
|
|
1348
1430
|
"aria-label": title,
|
|
1349
1431
|
"aria-multiselectable": "true",
|
|
1432
|
+
"aria-rowcount": weeks.length + 1,
|
|
1433
|
+
"aria-colcount": 7,
|
|
1350
1434
|
className: classNames?.grid,
|
|
1351
1435
|
onKeyDown: handleKeyDown,
|
|
1352
1436
|
children: [
|
|
1353
|
-
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsx("tr", { role: "row", children: weekdays.map((day) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1437
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsx("tr", { role: "row", "aria-rowindex": 1, children: weekdays.map((day, colIndex) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1354
1438
|
"th",
|
|
1355
1439
|
{
|
|
1356
1440
|
role: "columnheader",
|
|
1357
1441
|
abbr: day.full,
|
|
1358
1442
|
scope: "col",
|
|
1443
|
+
"aria-colindex": colIndex + 1,
|
|
1359
1444
|
className: classNames?.weekdayHeader,
|
|
1360
1445
|
children: day.short
|
|
1361
1446
|
},
|
|
1362
1447
|
day.short
|
|
1363
1448
|
)) }) }),
|
|
1364
|
-
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: weeks.map((week, weekIndex) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
day
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
"
|
|
1380
|
-
"
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1384
|
-
"button",
|
|
1449
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: weeks.map((week, weekIndex) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1450
|
+
"tr",
|
|
1451
|
+
{
|
|
1452
|
+
role: "row",
|
|
1453
|
+
"aria-rowindex": weekIndex + 2,
|
|
1454
|
+
className: classNames?.gridRow,
|
|
1455
|
+
children: week.map((day, colIndex) => {
|
|
1456
|
+
const dayClasses = [
|
|
1457
|
+
classNames?.day,
|
|
1458
|
+
day.isRangeStart && classNames?.dayRangeStart,
|
|
1459
|
+
day.isRangeEnd && classNames?.dayRangeEnd,
|
|
1460
|
+
day.isInRange && classNames?.dayInRange,
|
|
1461
|
+
day.isToday && classNames?.dayToday,
|
|
1462
|
+
day.isDisabled && classNames?.dayDisabled,
|
|
1463
|
+
!day.isCurrentMonth && classNames?.dayOutsideMonth
|
|
1464
|
+
].filter(Boolean).join(" ") || void 0;
|
|
1465
|
+
const isSelected = selectionMode === "week" ? day.isRangeStart || day.isRangeEnd || day.isInRange : day.isRangeStart || day.isRangeEnd;
|
|
1466
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1467
|
+
"td",
|
|
1385
1468
|
{
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
"
|
|
1390
|
-
"
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1469
|
+
role: "gridcell",
|
|
1470
|
+
"aria-colindex": colIndex + 1,
|
|
1471
|
+
"aria-selected": isSelected || void 0,
|
|
1472
|
+
"aria-disabled": day.isDisabled || void 0,
|
|
1473
|
+
"aria-current": day.isToday ? "date" : void 0,
|
|
1474
|
+
className: classNames?.gridCell,
|
|
1475
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1476
|
+
"button",
|
|
1477
|
+
{
|
|
1478
|
+
type: "button",
|
|
1479
|
+
tabIndex: day.isFocused ? 0 : -1,
|
|
1480
|
+
disabled: day.isDisabled,
|
|
1481
|
+
"data-focused": day.isFocused || void 0,
|
|
1482
|
+
"data-range-start": day.isRangeStart || void 0,
|
|
1483
|
+
"data-range-end": day.isRangeEnd || void 0,
|
|
1484
|
+
"data-in-range": day.isInRange || void 0,
|
|
1485
|
+
"data-today": day.isToday || void 0,
|
|
1486
|
+
"data-outside-month": !day.isCurrentMonth || void 0,
|
|
1487
|
+
className: dayClasses,
|
|
1488
|
+
onClick: () => handleDayClick(day),
|
|
1489
|
+
onMouseEnter: () => handleDayMouseEnter(day),
|
|
1490
|
+
"aria-label": safeFormatFullDate2(day.isoString, locale),
|
|
1491
|
+
children: day.dayNumber
|
|
1492
|
+
}
|
|
1493
|
+
)
|
|
1494
|
+
},
|
|
1495
|
+
day.isoString
|
|
1496
|
+
);
|
|
1497
|
+
})
|
|
1498
|
+
},
|
|
1499
|
+
weekIndex
|
|
1500
|
+
)) })
|
|
1406
1501
|
]
|
|
1407
1502
|
}
|
|
1408
1503
|
),
|
|
@@ -1655,6 +1750,7 @@ var TimePickerInput = react.forwardRef(
|
|
|
1655
1750
|
);
|
|
1656
1751
|
}
|
|
1657
1752
|
);
|
|
1753
|
+
TimePickerInput.displayName = "TimePicker.Input";
|
|
1658
1754
|
function useListboxNavigation({
|
|
1659
1755
|
items,
|
|
1660
1756
|
onSelect,
|
|
@@ -1703,7 +1799,7 @@ function useListboxNavigation({
|
|
|
1703
1799
|
function TimePickerHourList({ classNames, ...props }) {
|
|
1704
1800
|
const ctx = useTimePickerContext("TimePicker.HourList");
|
|
1705
1801
|
const { format, currentTime, isDisabled, isReadOnly } = ctx;
|
|
1706
|
-
const hours = core.generateHours(format);
|
|
1802
|
+
const hours = react.useMemo(() => core.generateHours(format), [format]);
|
|
1707
1803
|
const selectedHourDisplay = format === "12h" ? core.to12Hour(currentTime.hours).hours12 : currentTime.hours;
|
|
1708
1804
|
const currentPeriod = format === "12h" ? core.to12Hour(currentTime.hours).period : null;
|
|
1709
1805
|
const handleSelect = react.useCallback(
|
|
@@ -1754,7 +1850,7 @@ function TimePickerHourList({ classNames, ...props }) {
|
|
|
1754
1850
|
function TimePickerMinuteList({ classNames, ...props }) {
|
|
1755
1851
|
const ctx = useTimePickerContext("TimePicker.MinuteList");
|
|
1756
1852
|
const { step, currentTime, isDisabled, isReadOnly } = ctx;
|
|
1757
|
-
const minutes = core.generateMinutes(step);
|
|
1853
|
+
const minutes = react.useMemo(() => core.generateMinutes(step), [step]);
|
|
1758
1854
|
const handleSelect = react.useCallback(
|
|
1759
1855
|
(minute) => {
|
|
1760
1856
|
if (isDisabled || isReadOnly) return;
|
|
@@ -1888,10 +1984,10 @@ function DateTimePickerRoot({
|
|
|
1888
1984
|
const currentValue = isControlled ? controlledValue ?? null : uncontrolledValue;
|
|
1889
1985
|
const [isOpen, setIsOpen] = react.useState(false);
|
|
1890
1986
|
const [viewMonth, setViewMonth] = react.useState(
|
|
1891
|
-
currentValue ?? adapter.today(displayTimezone)
|
|
1987
|
+
() => currentValue ?? adapter.today(displayTimezone)
|
|
1892
1988
|
);
|
|
1893
1989
|
const [focusedDate, setFocusedDate] = react.useState(
|
|
1894
|
-
currentValue ?? adapter.today(displayTimezone)
|
|
1990
|
+
() => currentValue ?? adapter.today(displayTimezone)
|
|
1895
1991
|
);
|
|
1896
1992
|
useChangeEffect(isOpen, onOpenChange);
|
|
1897
1993
|
const viewMonthStart = react.useMemo(() => adapter.startOfMonth(viewMonth), [viewMonth, adapter]);
|
|
@@ -2049,6 +2145,8 @@ var DateTimePickerInput = react.forwardRef(
|
|
|
2049
2145
|
(e) => {
|
|
2050
2146
|
if (e.key === "Escape") {
|
|
2051
2147
|
ctx.close();
|
|
2148
|
+
} else if (e.key === "Enter" && ctx.isOpen) {
|
|
2149
|
+
e.preventDefault();
|
|
2052
2150
|
} else if (e.key === "ArrowDown" && !ctx.isOpen) {
|
|
2053
2151
|
e.preventDefault();
|
|
2054
2152
|
ctx.open();
|
|
@@ -2084,6 +2182,7 @@ var DateTimePickerInput = react.forwardRef(
|
|
|
2084
2182
|
);
|
|
2085
2183
|
}
|
|
2086
2184
|
);
|
|
2185
|
+
DateTimePickerInput.displayName = "DateTimePicker.Input";
|
|
2087
2186
|
|
|
2088
2187
|
// src/components/DateTimePicker/index.ts
|
|
2089
2188
|
var DateTimePicker = Object.assign(DateTimePickerRoot, {
|