pixelize-design-library 3.3.1 → 3.3.3
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 +39 -0
- package/dist/Components/DatePicker/CalendarPanel.js +12 -33
- package/dist/Components/DatePicker/RangeDatePicker.js +2 -2
- package/dist/Components/DatePicker/SingleDatePicker.js +102 -99
- package/dist/Components/DatePicker/TimePickerInput.js +29 -21
- package/dist/Components/Select/SelectPopup.js +24 -2
- package/dist/Hooks/exclusiveOverlay.d.ts +4 -1
- package/dist/Hooks/exclusiveOverlay.js +14 -9
- package/dist/Hooks/useExclusiveOverlay.d.ts +2 -1
- package/dist/Hooks/useExclusiveOverlay.js +7 -4
- package/dist/Hooks/useOutsideMouseDown.js +16 -1
- package/dist/esm/Components/DatePicker/CalendarPanel.js +12 -33
- package/dist/esm/Components/DatePicker/RangeDatePicker.js +2 -2
- package/dist/esm/Components/DatePicker/SingleDatePicker.js +102 -99
- package/dist/esm/Components/DatePicker/TimePickerInput.js +30 -22
- package/dist/esm/Components/Select/SelectPopup.js +24 -2
- package/dist/esm/Hooks/exclusiveOverlay.js +14 -9
- package/dist/esm/Hooks/useExclusiveOverlay.js +7 -4
- package/dist/esm/Hooks/useOutsideMouseDown.js +16 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,45 @@ Found a bug or a gap? Report it as a GitHub issue and track it to closure — se
|
|
|
9
9
|
[COMPONENT-GOTCHAS.md](COMPONENT-GOTCHAS.md#found-a-gap-or-a-bug-report-it-then-track-it). A fix's
|
|
10
10
|
line below names its issue number.
|
|
11
11
|
|
|
12
|
+
## [3.3.3] — 2026-11-13
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- **`DatePicker` dropped the first digit typed right after focusing an empty field** (`24` became `04`): the
|
|
17
|
+
deferred first-segment select reset the typing buffer. It now skips once a key has been typed.
|
|
18
|
+
- **`DatePicker` select-all + Delete/Backspace cleared only the last segment**, and cut or a programmatic fill
|
|
19
|
+
of `""` was ignored. Both now clear the whole field.
|
|
20
|
+
- **`DatePicker` calendar month and year pickers were browser-native `<select>`s.** They are now the library
|
|
21
|
+
`Select` (`native={false}`), so they match every other field. Tests that drove them with `selectOption` should
|
|
22
|
+
click the `Month` / `Year` combobox and then the option by name.
|
|
23
|
+
- **Opening a dropdown inside another popup closed the outer one.** The one-overlay-at-a-time rule now lets an
|
|
24
|
+
overlay opened from inside another (the month list inside the calendar) keep its parent open, and a picker's
|
|
25
|
+
outside-click check treats a popup its field owns (`aria-controls` / `aria-owns`) as inside.
|
|
26
|
+
|
|
27
|
+
## [3.3.2] — 2026-11-13
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
|
|
31
|
+
- **`Select` (`native={false}`) options were invisible to `getByRole('option')` inside a `Drawer` or `Modal`.** The
|
|
32
|
+
dialog `aria-hidden`s every sibling portal when it opens, the popup's included, so the whole listbox left the
|
|
33
|
+
accessibility tree. The popup now drops that `aria-hidden` while open (only if the trigger itself is not hidden), and
|
|
34
|
+
each row is named by its label alone (`aria-labelledby`), with the `description` as `aria-describedby` — a row with a
|
|
35
|
+
description used to be named `LabelDescription`. Rows from `renderOption` keep their content as the name.
|
|
36
|
+
|
|
37
|
+
- **`DatePicker` masked typing lost or mangled digits.** In an empty field, digits now fill from the first segment
|
|
38
|
+
wherever the click left the caret (typing `24122026` after a click gave `dd/MM/2026`), and a typed separator moves
|
|
39
|
+
on, padding a one-digit segment (`2/1/2026` → `02/01/2026`). Keys arriving faster than a frame stay in the segment
|
|
40
|
+
being typed (retyping a full date could drop into the year and blank the field on commit). `MM` is a month, no longer
|
|
41
|
+
minutes: `0` then `5` gives `05` instead of `01` plus a stray year digit. A day digit above 3 or a month digit above 1
|
|
42
|
+
completes its segment as `0d`; two-digit months clamp to 1–12 and days to 1–31.
|
|
43
|
+
- **`DatePicker` `pickerType="time"` showed one time and saved another.** Fast typing wrote the field a frame late, so
|
|
44
|
+
later keys landed at stale caret positions (`1415` could show `05:10`, or `05:` with the old value kept). The saved
|
|
45
|
+
time now comes from the typed hour and minute rather than re-parsing with `dateFormat`, so a time field given a date
|
|
46
|
+
format (`dd/MM/yyyy`, `hh:mm` without `a`) saves what it shows, and a controlled value shows its time, not its date
|
|
47
|
+
digits.
|
|
48
|
+
- **`DatePicker` datetime masks could not type minutes `00`–`09` or hour `00`.** A first `0` in the minutes jumped to `01`
|
|
49
|
+
and both clamped to 1–60 / 1–24; minutes now take 0–59, 24-hour hours 0–23, 12-hour hours 1–12.
|
|
50
|
+
|
|
12
51
|
## [3.3.1] — 2026-11-11
|
|
13
52
|
|
|
14
53
|
### Docs
|
|
@@ -9,11 +9,13 @@ const react_1 = require("@chakra-ui/react");
|
|
|
9
9
|
const date_fns_1 = require("date-fns");
|
|
10
10
|
const lucide_react_1 = require("lucide-react");
|
|
11
11
|
const Button_1 = __importDefault(require("../Button/Button"));
|
|
12
|
+
const Select_1 = __importDefault(require("../Select/Select"));
|
|
12
13
|
const useCustomTheme_1 = require("../../Theme/useCustomTheme");
|
|
13
14
|
const filledSurface_1 = require("../../Theme/tokens/builders/filledSurface");
|
|
14
|
-
const focusRing_styles_1 = require("../../Theme/chakra/focusRing.styles");
|
|
15
15
|
const dayStates_1 = require("./dayStates");
|
|
16
16
|
const motion_1 = require("../../Theme/tokens/primitives/motion");
|
|
17
|
+
const MONTH_OPTIONS = Array.from({ length: 12 }, (_, i) => ({ id: i, label: (0, date_fns_1.format)(new Date(2000, i, 1), "MMMM") }));
|
|
18
|
+
const yearOptions = (thisYear) => Array.from({ length: 100 }, (_, i) => ({ id: thisYear - 50 + i, label: String(thisYear - 50 + i) }));
|
|
17
19
|
const BACKGROUND_COLOR_TRANSITION = (0, motion_1.transitionFor)(["background", "color"]);
|
|
18
20
|
/** Internal month grid shared by Single/RangeDatePicker; not published from index.ts, so only reachable via a deep import. */
|
|
19
21
|
const CalendarPanel = ({ currentMonth, setCurrentMonth, today, isRange, tempDate, tempRangeStart, tempRangeEnd, isSameDay, isBefore, isAfter, minDate, maxDate, disablePastDates, disableFutureDates, disableToday, onDaySelect, hoveredDate, onDayHover, renderWeekdays, dayStates, renderDayContent, }) => {
|
|
@@ -29,28 +31,6 @@ const CalendarPanel = ({ currentMonth, setCurrentMonth, today, isRange, tempDate
|
|
|
29
31
|
const rangeEnd = tempRangeEnd !== null && tempRangeEnd !== void 0 ? tempRangeEnd : tentativeEnd;
|
|
30
32
|
const isTentative = !tempRangeEnd && !!tentativeEnd;
|
|
31
33
|
const hasRange = !!(rangeStart && rangeEnd && !isSameDay(rangeStart, rangeEnd));
|
|
32
|
-
const selectStyles = {
|
|
33
|
-
border: "1px solid",
|
|
34
|
-
// boxborder[500] is the control-outline rung the sibling pickers already use; boxborder[200]
|
|
35
|
-
// is decorative and measured 1.85:1 on the dark canvas — the select read as borderless.
|
|
36
|
-
borderColor: theme.colors.boxborder[500],
|
|
37
|
-
borderRadius: "md",
|
|
38
|
-
px: 2,
|
|
39
|
-
py: 1,
|
|
40
|
-
fontSize: "xs",
|
|
41
|
-
fontWeight: 600,
|
|
42
|
-
color: theme.colors.text[700],
|
|
43
|
-
cursor: "pointer",
|
|
44
|
-
bg: theme.colors.background[50],
|
|
45
|
-
outline: "none",
|
|
46
|
-
_hover: { borderColor: theme.colors.primary[300] },
|
|
47
|
-
_focus: { borderColor: theme.colors.primary[500], ...(0, focusRing_styles_1.fieldFocusVisible)(theme.colors) },
|
|
48
|
-
style: {
|
|
49
|
-
WebkitAppearance: "menulist",
|
|
50
|
-
MozAppearance: "menulist",
|
|
51
|
-
appearance: "menulist",
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
34
|
const renderDays = () => {
|
|
55
35
|
var _a;
|
|
56
36
|
const monthStart = (0, date_fns_1.startOfMonth)(currentMonth);
|
|
@@ -139,16 +119,15 @@ const CalendarPanel = ({ currentMonth, setCurrentMonth, today, isRange, tempDate
|
|
|
139
119
|
}
|
|
140
120
|
return rows;
|
|
141
121
|
};
|
|
142
|
-
return ((0, jsx_runtime_1.jsxs)(react_1.Box, { children: [(0, jsx_runtime_1.jsxs)(react_1.Box, { display: "flex", alignItems: "center", justifyContent: "space-between", mb: 2, gap: 1, children: [(0, jsx_runtime_1.jsx)(Button_1.default, { variant: "ghost", size: "xs", sx: { flexShrink: 0 }, onClick: () => setCurrentMonth((prev) => new Date(prev.getFullYear(), prev.getMonth() - 1, 1)), "aria-label": "Previous month", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronLeftIcon, { size: 16 }) }), (0, jsx_runtime_1.jsxs)(react_1.Box, { display: "flex", alignItems: "center", gap: 1.5, minW: 0, children: [(0, jsx_runtime_1.jsx)(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}) })] }), (0, jsx_runtime_1.jsxs)(react_1.Box, { display: "flex", alignItems: "center", gap: 1, flexShrink: 0, children: [!isRange && !isViewingCurrentMonth && ((0, jsx_runtime_1.jsx)(Button_1.default, { variant: "ghost", size: "xs", onClick: () => {
|
|
122
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.Box, { children: [(0, jsx_runtime_1.jsxs)(react_1.Box, { display: "flex", alignItems: "center", justifyContent: "space-between", mb: 2, gap: 1, children: [(0, jsx_runtime_1.jsx)(Button_1.default, { variant: "ghost", size: "xs", sx: { flexShrink: 0 }, onClick: () => setCurrentMonth((prev) => new Date(prev.getFullYear(), prev.getMonth() - 1, 1)), "aria-label": "Previous month", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronLeftIcon, { size: 16 }) }), (0, jsx_runtime_1.jsxs)(react_1.Box, { display: "flex", alignItems: "center", gap: 1.5, minW: 0, children: [(0, jsx_runtime_1.jsx)(Select_1.default, { native: false, size: "xs", width: "7.5rem", "aria-label": "Month", options: MONTH_OPTIONS, value: currentMonth.getMonth(), onChange: (option) => {
|
|
123
|
+
if (option === undefined)
|
|
124
|
+
return;
|
|
125
|
+
setCurrentMonth((prev) => new Date(prev.getFullYear(), Number(option.id), 1));
|
|
126
|
+
} }), (0, jsx_runtime_1.jsx)(Select_1.default, { native: false, size: "xs", width: "5.5rem", "aria-label": "Year", options: yearOptions(new Date().getFullYear()), value: currentMonth.getFullYear(), onChange: (option) => {
|
|
127
|
+
if (option === undefined)
|
|
128
|
+
return;
|
|
129
|
+
setCurrentMonth((prev) => new Date(Number(option.id), prev.getMonth(), 1));
|
|
130
|
+
} })] }), (0, jsx_runtime_1.jsxs)(react_1.Box, { display: "flex", alignItems: "center", gap: 1, flexShrink: 0, children: [!isRange && !isViewingCurrentMonth && ((0, jsx_runtime_1.jsx)(Button_1.default, { variant: "ghost", size: "xs", onClick: () => {
|
|
152
131
|
setCurrentMonth(() => new Date(today.getFullYear(), today.getMonth(), 1));
|
|
153
132
|
if (!disableToday) {
|
|
154
133
|
onDaySelect(new Date(today));
|
|
@@ -73,13 +73,13 @@ exports.RangeDatePicker = (0, react_1.forwardRef)(function RangeDatePicker(props
|
|
|
73
73
|
const calendarIconPx = (0, textInputIconSize_1.getTextInputIconSizePx)(sizeKey);
|
|
74
74
|
const calendarIconWrapperSx = (0, textInputIconSize_1.getTextInputIconWrapperSx)(sizeKey);
|
|
75
75
|
const { isOpen, onOpen, onClose } = (0, react_2.useDisclosure)();
|
|
76
|
-
const
|
|
76
|
+
const popoverRef = (0, react_1.useRef)(null);
|
|
77
|
+
const requestExclusiveOpen = (0, useExclusiveOverlay_1.useExclusiveOverlay)(isOpen, onClose, popoverRef);
|
|
77
78
|
const pickerPortal = (0, PickerPortal_1.usePickerPortal)(isOpen);
|
|
78
79
|
const calendarLabel = label !== null && label !== void 0 ? label : "Choose date range";
|
|
79
80
|
const inputRef = (0, react_1.useRef)(null);
|
|
80
81
|
const mergedInputRef = (0, react_2.useMergeRefs)(inputRef, ref);
|
|
81
82
|
const triggerRef = (0, react_1.useRef)(null);
|
|
82
|
-
const popoverRef = (0, react_1.useRef)(null);
|
|
83
83
|
const today = new Date();
|
|
84
84
|
const placeholder = (0, react_1.useMemo)(() => placeholderText || `${dateFormat} - ${dateFormat}`, [placeholderText, dateFormat]);
|
|
85
85
|
const selectedRange = (_b = (_a = props.value) !== null && _a !== void 0 ? _a : props.selectedDate) !== null && _b !== void 0 ? _b : null;
|
|
@@ -196,63 +196,30 @@ const getFormatForPickerType = (pickerType, dateFormat) => {
|
|
|
196
196
|
}
|
|
197
197
|
return dateFormat;
|
|
198
198
|
};
|
|
199
|
-
const
|
|
199
|
+
const normalizeTwoDigitSegment = (buf, firstMax, min, max) => {
|
|
200
|
+
if (buf.length === 1) {
|
|
201
|
+
const d = parseInt(buf, 10);
|
|
202
|
+
return d > firstMax ? { value: `0${d}`, completed: true } : { value: buf, completed: false };
|
|
203
|
+
}
|
|
204
|
+
const n = Math.min(max, Math.max(min, parseInt(buf, 10)));
|
|
205
|
+
return { value: n.toString().padStart(2, "0"), completed: true };
|
|
206
|
+
};
|
|
207
|
+
const normalizeSegmentBuffer = (tokenChar, rawBuffer, segmentLength, is12Hour) => {
|
|
200
208
|
if (!tokenChar)
|
|
201
209
|
return { value: rawBuffer, completed: rawBuffer.length >= segmentLength };
|
|
202
210
|
const t = tokenChar.toLowerCase();
|
|
203
211
|
const buf = rawBuffer.replace(/\D/g, "").slice(0, segmentLength);
|
|
204
|
-
if (segmentLength !== 2) {
|
|
212
|
+
if (segmentLength !== 2 || buf.length === 0) {
|
|
205
213
|
return { value: buf, completed: buf.length >= segmentLength };
|
|
206
214
|
}
|
|
207
|
-
if (
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
return { value: buf, completed: false };
|
|
216
|
-
}
|
|
217
|
-
if (buf.length === 2) {
|
|
218
|
-
let h = parseInt(buf, 10);
|
|
219
|
-
if (is12Hour) {
|
|
220
|
-
if (h < 1)
|
|
221
|
-
h = 1;
|
|
222
|
-
if (h > 12)
|
|
223
|
-
h = 12;
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
if (h < 1)
|
|
227
|
-
h = 1;
|
|
228
|
-
if (h > 24)
|
|
229
|
-
h = 24;
|
|
230
|
-
}
|
|
231
|
-
const out = h.toString().padStart(2, "0");
|
|
232
|
-
return { value: out, completed: true };
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
if (t === "m") {
|
|
236
|
-
if (buf.length === 1) {
|
|
237
|
-
const d = parseInt(buf[0], 10);
|
|
238
|
-
if (d > 5) {
|
|
239
|
-
return { value: `0${d}`, completed: true };
|
|
240
|
-
}
|
|
241
|
-
if (d === 0) {
|
|
242
|
-
return { value: "01", completed: true };
|
|
243
|
-
}
|
|
244
|
-
return { value: buf, completed: false };
|
|
245
|
-
}
|
|
246
|
-
if (buf.length === 2) {
|
|
247
|
-
let m = parseInt(buf, 10);
|
|
248
|
-
if (m < 1)
|
|
249
|
-
m = 1;
|
|
250
|
-
if (m > 60)
|
|
251
|
-
m = 60;
|
|
252
|
-
const out = m.toString().padStart(2, "0");
|
|
253
|
-
return { value: out, completed: true };
|
|
254
|
-
}
|
|
255
|
-
}
|
|
215
|
+
if (tokenChar === "M")
|
|
216
|
+
return normalizeTwoDigitSegment(buf, 1, 1, 12);
|
|
217
|
+
if (t === "d")
|
|
218
|
+
return normalizeTwoDigitSegment(buf, 3, 1, 31);
|
|
219
|
+
if (t === "h")
|
|
220
|
+
return is12Hour ? normalizeTwoDigitSegment(buf, 1, 1, 12) : normalizeTwoDigitSegment(buf, 2, 0, 23);
|
|
221
|
+
if (tokenChar === "m")
|
|
222
|
+
return normalizeTwoDigitSegment(buf, 5, 0, 59);
|
|
256
223
|
return { value: buf, completed: buf.length >= segmentLength };
|
|
257
224
|
};
|
|
258
225
|
function SingleDatePickerInner(props, ref) {
|
|
@@ -265,12 +232,12 @@ function SingleDatePickerInner(props, ref) {
|
|
|
265
232
|
const calendarIconPx = (0, textInputIconSize_1.getTextInputIconSizePx)(sizeKey);
|
|
266
233
|
const calendarIconWrapperSx = (0, textInputIconSize_1.getTextInputIconWrapperSx)(sizeKey);
|
|
267
234
|
const { isOpen, onOpen, onClose } = (0, react_2.useDisclosure)();
|
|
268
|
-
const
|
|
235
|
+
const popoverRef = (0, react_1.useRef)(null);
|
|
236
|
+
const requestExclusiveOpen = (0, useExclusiveOverlay_1.useExclusiveOverlay)(isOpen, onClose, popoverRef);
|
|
269
237
|
const pickerPortal = (0, PickerPortal_1.usePickerPortal)(isOpen);
|
|
270
238
|
const calendarLabel = label !== null && label !== void 0 ? label : "Choose date";
|
|
271
239
|
const inputRef = (0, react_1.useRef)(null);
|
|
272
240
|
const mergedInputRef = (0, react_2.useMergeRefs)(inputRef, ref);
|
|
273
|
-
const popoverRef = (0, react_1.useRef)(null);
|
|
274
241
|
const triggerRef = (0, react_1.useRef)(null);
|
|
275
242
|
const resolvedPickerType = pickerType !== null && pickerType !== void 0 ? pickerType : (0, pickerField_1.inferPickerTypeFromFormat)(dateFormat);
|
|
276
243
|
const resolvedDateFormat = getFormatForPickerType(pickerType, dateFormat);
|
|
@@ -297,6 +264,7 @@ function SingleDatePickerInner(props, ref) {
|
|
|
297
264
|
}
|
|
298
265
|
return buildFormatSegments(activeFormat);
|
|
299
266
|
}, [enableMask, activeFormat]);
|
|
267
|
+
const separatorKeys = (0, react_1.useMemo)(() => formatSegments.filter((segment) => segment.type === "literal").map((segment) => segment.placeholder), [formatSegments]);
|
|
300
268
|
const tokenSegments = (0, react_1.useMemo)(() => (enableMask ? formatSegments.filter((segment) => segment.type === "token") : []), [enableMask, formatSegments]);
|
|
301
269
|
const maskPlaceholder = (0, react_1.useMemo)(() => {
|
|
302
270
|
if (!enableMask) {
|
|
@@ -317,6 +285,7 @@ function SingleDatePickerInner(props, ref) {
|
|
|
317
285
|
const pendingSegmentNavigationRef = (0, react_1.useRef)(null);
|
|
318
286
|
const restoreSelectionRef = (0, react_1.useRef)(null);
|
|
319
287
|
const segmentInputBufferRef = (0, react_1.useRef)("");
|
|
288
|
+
const keystrokeSeqRef = (0, react_1.useRef)(0);
|
|
320
289
|
const maskInsertedRef = (0, react_1.useRef)(false);
|
|
321
290
|
const today = new Date();
|
|
322
291
|
const tomorrow = (0, date_fns_1.addDays)(today, 1);
|
|
@@ -449,6 +418,8 @@ function SingleDatePickerInner(props, ref) {
|
|
|
449
418
|
};
|
|
450
419
|
const handleInputChange = (e) => {
|
|
451
420
|
if (enableMask && isMaskActive) {
|
|
421
|
+
if (e.target.value === "")
|
|
422
|
+
clearAllSegments();
|
|
452
423
|
return;
|
|
453
424
|
}
|
|
454
425
|
let value = e.target.value;
|
|
@@ -565,6 +536,7 @@ function SingleDatePickerInner(props, ref) {
|
|
|
565
536
|
setCurrentSegmentIndex(clamped);
|
|
566
537
|
lastSegmentIndexRef.current = clamped;
|
|
567
538
|
segmentInputBufferRef.current = "";
|
|
539
|
+
restoreSelectionRef.current = { start: segment.start, end: segment.end };
|
|
568
540
|
const inputEl = inputRef.current;
|
|
569
541
|
if (!inputEl)
|
|
570
542
|
return;
|
|
@@ -614,6 +586,29 @@ function SingleDatePickerInner(props, ref) {
|
|
|
614
586
|
const clamped = Math.max(0, Math.min(tokenSegments.length - 1, nextIndex));
|
|
615
587
|
selectSegment(clamped);
|
|
616
588
|
}, [enableMask, selectSegment, tokenSegments.length]);
|
|
589
|
+
const deferSelectSegment = (index) => {
|
|
590
|
+
const seq = keystrokeSeqRef.current;
|
|
591
|
+
requestAnimationFrame(() => {
|
|
592
|
+
if (keystrokeSeqRef.current === seq)
|
|
593
|
+
selectSegment(index);
|
|
594
|
+
});
|
|
595
|
+
};
|
|
596
|
+
const clearAllSegments = () => {
|
|
597
|
+
keystrokeSeqRef.current += 1;
|
|
598
|
+
segmentInputBufferRef.current = "";
|
|
599
|
+
maskInsertedRef.current = true;
|
|
600
|
+
setInputValue(maskPlaceholder);
|
|
601
|
+
setTempDate(null);
|
|
602
|
+
setIsTyping(true);
|
|
603
|
+
const inputEl = inputRef.current;
|
|
604
|
+
if (inputEl && tokenSegments.length > 0) {
|
|
605
|
+
inputEl.value = maskPlaceholder;
|
|
606
|
+
lastSegmentIndexRef.current = 0;
|
|
607
|
+
setCurrentSegmentIndex(0);
|
|
608
|
+
restoreSelectionRef.current = { start: tokenSegments[0].start, end: tokenSegments[0].end };
|
|
609
|
+
inputEl.setSelectionRange(tokenSegments[0].start, tokenSegments[0].end);
|
|
610
|
+
}
|
|
611
|
+
};
|
|
617
612
|
const getTokenIndexForCaret = (caret, tokens) => {
|
|
618
613
|
if (tokens.length === 0)
|
|
619
614
|
return 0;
|
|
@@ -649,6 +644,7 @@ function SingleDatePickerInner(props, ref) {
|
|
|
649
644
|
return isSegmentComplete(segment, segmentValue);
|
|
650
645
|
});
|
|
651
646
|
};
|
|
647
|
+
const isMaskEmpty = (value) => !value || value === maskPlaceholder;
|
|
652
648
|
const computeFinalDate = (parsed) => {
|
|
653
649
|
if (minDate && (0, date_fns_1.isBefore)(parsed, minDate))
|
|
654
650
|
return null;
|
|
@@ -718,7 +714,7 @@ function SingleDatePickerInner(props, ref) {
|
|
|
718
714
|
maskInsertedRef.current = false;
|
|
719
715
|
}
|
|
720
716
|
segmentInputBufferRef.current = "";
|
|
721
|
-
|
|
717
|
+
deferSelectSegment(0);
|
|
722
718
|
};
|
|
723
719
|
const handleInputClick = (e) => {
|
|
724
720
|
var _a;
|
|
@@ -732,9 +728,11 @@ function SingleDatePickerInner(props, ref) {
|
|
|
732
728
|
if (!inputRef.current)
|
|
733
729
|
return;
|
|
734
730
|
const caret = (_a = inputRef.current.selectionStart) !== null && _a !== void 0 ? _a : 0;
|
|
735
|
-
const index =
|
|
731
|
+
const index = isMaskEmpty(inputRef.current.value)
|
|
732
|
+
? 0
|
|
733
|
+
: tokenSegments.findIndex((segment) => caret >= segment.start && caret <= segment.end);
|
|
736
734
|
if (index >= 0) {
|
|
737
|
-
|
|
735
|
+
deferSelectSegment(index);
|
|
738
736
|
}
|
|
739
737
|
};
|
|
740
738
|
const handleKeyDown = (e) => {
|
|
@@ -827,6 +825,11 @@ function SingleDatePickerInner(props, ref) {
|
|
|
827
825
|
}
|
|
828
826
|
if (key === "Backspace" || key === "Delete") {
|
|
829
827
|
e.preventDefault();
|
|
828
|
+
if (inputEl && selStart === 0 && selEnd > 0 && selEnd >= inputEl.value.length) {
|
|
829
|
+
clearAllSegments();
|
|
830
|
+
return;
|
|
831
|
+
}
|
|
832
|
+
keystrokeSeqRef.current += 1;
|
|
830
833
|
const baseValue = ensureMaskValue();
|
|
831
834
|
const newValue = baseValue.slice(0, segment.start) + segment.placeholder + baseValue.slice(segment.end);
|
|
832
835
|
setInputValue(newValue);
|
|
@@ -834,7 +837,7 @@ function SingleDatePickerInner(props, ref) {
|
|
|
834
837
|
maskInsertedRef.current = false;
|
|
835
838
|
segmentInputBufferRef.current = "";
|
|
836
839
|
updateTempDateFromMask(newValue);
|
|
837
|
-
|
|
840
|
+
deferSelectSegment(activeIdx);
|
|
838
841
|
return;
|
|
839
842
|
}
|
|
840
843
|
if (e.ctrlKey || e.metaKey) {
|
|
@@ -843,6 +846,48 @@ function SingleDatePickerInner(props, ref) {
|
|
|
843
846
|
return;
|
|
844
847
|
}
|
|
845
848
|
}
|
|
849
|
+
const isDigit = /^[0-9]$/.test(key);
|
|
850
|
+
if (isDigit || separatorKeys.includes(key)) {
|
|
851
|
+
e.preventDefault();
|
|
852
|
+
keystrokeSeqRef.current += 1;
|
|
853
|
+
const baseValue = ensureMaskValue();
|
|
854
|
+
const buffered = segmentInputBufferRef.current !== "";
|
|
855
|
+
const typingIdx = buffered ? lastSegmentIndexRef.current : isMaskEmpty(baseValue) ? 0 : activeIdx;
|
|
856
|
+
const typingSegment = tokenSegments[typingIdx];
|
|
857
|
+
if (typingSegment.token === "a" || (!isDigit && !buffered))
|
|
858
|
+
return;
|
|
859
|
+
const segmentLength = typingSegment.placeholder.length;
|
|
860
|
+
const buffer = isDigit ? segmentInputBufferRef.current + key : segmentInputBufferRef.current.padStart(segmentLength, "0");
|
|
861
|
+
const { value: activeValue, completed } = normalizeSegmentBuffer(typingSegment.token, buffer, segmentLength, is12Hour);
|
|
862
|
+
const newSegmentValue = activeValue + typingSegment.placeholder.slice(activeValue.length);
|
|
863
|
+
const newValue = baseValue.slice(0, typingSegment.start) + newSegmentValue + baseValue.slice(typingSegment.end);
|
|
864
|
+
setInputValue(newValue);
|
|
865
|
+
setIsTyping(true);
|
|
866
|
+
maskInsertedRef.current = false;
|
|
867
|
+
lastSegmentIndexRef.current = typingIdx;
|
|
868
|
+
updateTempDateFromMask(newValue);
|
|
869
|
+
const inputEl = inputRef.current;
|
|
870
|
+
if (completed) {
|
|
871
|
+
segmentInputBufferRef.current = "";
|
|
872
|
+
const nextIdx = typingIdx + 1;
|
|
873
|
+
if (nextIdx < tokenSegments.length && inputEl) {
|
|
874
|
+
const nextSegment = tokenSegments[nextIdx];
|
|
875
|
+
pendingSegmentNavigationRef.current = nextIdx;
|
|
876
|
+
restoreSelectionRef.current = { start: nextSegment.start, end: nextSegment.end };
|
|
877
|
+
inputEl.value = newValue;
|
|
878
|
+
inputEl.focus();
|
|
879
|
+
inputEl.setSelectionRange(nextSegment.start, nextSegment.end);
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
else {
|
|
883
|
+
segmentInputBufferRef.current = activeValue;
|
|
884
|
+
if (inputEl) {
|
|
885
|
+
inputEl.value = newValue;
|
|
886
|
+
inputEl.setSelectionRange(typingSegment.start + activeValue.length, typingSegment.end);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
846
891
|
if (((_e = segment.token) === null || _e === void 0 ? void 0 : _e.toLowerCase()) === "a") {
|
|
847
892
|
const lower = key.toLowerCase();
|
|
848
893
|
if (lower === "a" || lower === "p") {
|
|
@@ -875,48 +920,6 @@ function SingleDatePickerInner(props, ref) {
|
|
|
875
920
|
e.preventDefault();
|
|
876
921
|
return;
|
|
877
922
|
}
|
|
878
|
-
if (/^[0-9]$/.test(key)) {
|
|
879
|
-
e.preventDefault();
|
|
880
|
-
const baseValue = ensureMaskValue();
|
|
881
|
-
const placeholderChars = segment.placeholder.split("");
|
|
882
|
-
const buffer = segmentInputBufferRef.current + key;
|
|
883
|
-
const normalized = normalizeTimeBuffer(segment.token, buffer, segment.placeholder.length, is12Hour);
|
|
884
|
-
const activeValue = normalized.value;
|
|
885
|
-
const completed = normalized.completed;
|
|
886
|
-
placeholderChars.forEach((_char, idx) => {
|
|
887
|
-
if (idx < activeValue.length) {
|
|
888
|
-
placeholderChars[idx] = activeValue[idx];
|
|
889
|
-
}
|
|
890
|
-
});
|
|
891
|
-
const newSegmentValue = placeholderChars.join("");
|
|
892
|
-
const newValue = baseValue.slice(0, segment.start) + newSegmentValue + baseValue.slice(segment.end);
|
|
893
|
-
setInputValue(newValue);
|
|
894
|
-
setIsTyping(true);
|
|
895
|
-
maskInsertedRef.current = false;
|
|
896
|
-
updateTempDateFromMask(newValue);
|
|
897
|
-
if (completed) {
|
|
898
|
-
segmentInputBufferRef.current = "";
|
|
899
|
-
const nextIdx = activeIdx + 1;
|
|
900
|
-
if (nextIdx < tokenSegments.length && inputRef.current) {
|
|
901
|
-
const nextSegment = tokenSegments[nextIdx];
|
|
902
|
-
pendingSegmentNavigationRef.current = nextIdx;
|
|
903
|
-
restoreSelectionRef.current = { start: nextSegment.start, end: nextSegment.end };
|
|
904
|
-
inputRef.current.value = newValue;
|
|
905
|
-
inputRef.current.focus();
|
|
906
|
-
inputRef.current.setSelectionRange(nextSegment.start, nextSegment.end);
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
else {
|
|
910
|
-
segmentInputBufferRef.current = activeValue;
|
|
911
|
-
const caretStart = segment.start + activeValue.length;
|
|
912
|
-
requestAnimationFrame(() => {
|
|
913
|
-
if (inputRef.current) {
|
|
914
|
-
inputRef.current.setSelectionRange(caretStart, segment.end);
|
|
915
|
-
}
|
|
916
|
-
});
|
|
917
|
-
}
|
|
918
|
-
return;
|
|
919
|
-
}
|
|
920
923
|
if (key === "ArrowUp" || key === "ArrowDown") {
|
|
921
924
|
e.preventDefault();
|
|
922
925
|
return;
|
|
@@ -91,6 +91,18 @@ const caretFromDigitIndex = (digitIndex, digitsLen) => {
|
|
|
91
91
|
return 3;
|
|
92
92
|
return digitIndex + 1;
|
|
93
93
|
};
|
|
94
|
+
const pad2 = (n) => n.toString().padStart(2, "0");
|
|
95
|
+
const digitsFromDate = (date, is12Hour) => {
|
|
96
|
+
const hours = date.getHours();
|
|
97
|
+
const displayHour = is12Hour ? (hours % 12 === 0 ? 12 : hours % 12) : hours;
|
|
98
|
+
return `${pad2(displayHour)}${pad2(date.getMinutes())}`;
|
|
99
|
+
};
|
|
100
|
+
const dateFromDigits = (digits, is12Hour, meridiem) => {
|
|
101
|
+
const hour = parseInt(digits.slice(0, 2), 10);
|
|
102
|
+
const hour24 = is12Hour ? (hour % 12) + (meridiem === "PM" ? 12 : 0) : hour;
|
|
103
|
+
const today = new Date();
|
|
104
|
+
return new Date(today.getFullYear(), today.getMonth(), today.getDate(), hour24, parseInt(digits.slice(2, 4), 10), 0, 0);
|
|
105
|
+
};
|
|
94
106
|
const formatToPlaceholder = (formatStr) => formatStr.replace(/h{1,2}/gi, "HH").replace(/m{1,2}/gi, "mm").replace(/a{1,2}/gi, "AM");
|
|
95
107
|
/** Masked HH:mm digit input, no seconds; `ref` is the `<input>`. */
|
|
96
108
|
exports.TimePickerInput = (0, react_1.forwardRef)(function TimePickerInput({ value, onChange, dateFormat, isDisabled: disabled = false, placeholder, id, name, isRequired, describedBy, onFocus, onBlur, error, size = controlSizes_1.DEFAULT_CONTROL_SIZE, }, ref) {
|
|
@@ -108,16 +120,15 @@ exports.TimePickerInput = (0, react_1.forwardRef)(function TimePickerInput({ val
|
|
|
108
120
|
const is12Hour = (0, react_1.useMemo)(() => /h{1,2}/i.test(dateFormat) && !/H{1,2}/.test(dateFormat), [dateFormat]);
|
|
109
121
|
const placeholderText = (0, react_1.useMemo)(() => placeholder || formatToPlaceholder(dateFormat), [placeholder, dateFormat]);
|
|
110
122
|
const ampmRef = (0, react_1.useRef)("AM");
|
|
123
|
+
const typedSinceFocusRef = (0, react_1.useRef)(false);
|
|
111
124
|
const [ampm, setAmpm] = (0, react_1.useState)("AM");
|
|
112
125
|
const setInputValueAndCaret = (0, react_1.useCallback)((formatted, caretDigitIndex) => {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
el.setSelectionRange(caretPos, caretPos);
|
|
120
|
-
});
|
|
126
|
+
const el = inputRef.current;
|
|
127
|
+
if (!el)
|
|
128
|
+
return;
|
|
129
|
+
el.value = formatted;
|
|
130
|
+
const caretPos = Math.min(caretFromDigitIndex(caretDigitIndex, digitsRef.current.length), formatted.length);
|
|
131
|
+
el.setSelectionRange(caretPos, caretPos);
|
|
121
132
|
}, []);
|
|
122
133
|
const applyDigits = (0, react_1.useCallback)((rawDigits, desiredDigitIndex) => {
|
|
123
134
|
const clamped = adjustDigits(rawDigits, is12Hour);
|
|
@@ -128,16 +139,13 @@ exports.TimePickerInput = (0, react_1.forwardRef)(function TimePickerInput({ val
|
|
|
128
139
|
const nextDigitIndex = Math.max(0, Math.min(desiredDigitIndex, maxDigitIndex));
|
|
129
140
|
setInputValueAndCaret(formatted, nextDigitIndex);
|
|
130
141
|
if (clamped.length === 4) {
|
|
131
|
-
|
|
132
|
-
const parsed = (0, date_fns_1.parse)(formattedInput, dateFormat, new Date());
|
|
133
|
-
if ((0, date_fns_1.isValid)(parsed))
|
|
134
|
-
onChange(parsed);
|
|
142
|
+
onChange(dateFromDigits(clamped, is12Hour, ampmRef.current || "AM"));
|
|
135
143
|
}
|
|
136
144
|
else if (clamped.length === 0) {
|
|
137
145
|
onChange(null);
|
|
138
146
|
}
|
|
139
147
|
return { digits: clamped, nextDigitIndex };
|
|
140
|
-
}, [
|
|
148
|
+
}, [is12Hour, onChange, setInputValueAndCaret]);
|
|
141
149
|
const updateAmpmValue = (0, react_1.useCallback)((next) => {
|
|
142
150
|
if (!is12Hour)
|
|
143
151
|
return;
|
|
@@ -146,9 +154,7 @@ exports.TimePickerInput = (0, react_1.forwardRef)(function TimePickerInput({ val
|
|
|
146
154
|
ampmRef.current = upperNext;
|
|
147
155
|
setAmpm(upperNext);
|
|
148
156
|
if (digitsRef.current.length === 4) {
|
|
149
|
-
|
|
150
|
-
if ((0, date_fns_1.isValid)(parsed))
|
|
151
|
-
onChange(parsed);
|
|
157
|
+
onChange(dateFromDigits(digitsRef.current, is12Hour, upperNext));
|
|
152
158
|
}
|
|
153
159
|
const el = inputRef.current;
|
|
154
160
|
if (!el)
|
|
@@ -159,7 +165,7 @@ exports.TimePickerInput = (0, react_1.forwardRef)(function TimePickerInput({ val
|
|
|
159
165
|
else {
|
|
160
166
|
el.value = formattedDigits ? `${formattedDigits} ${upperNext}` : "";
|
|
161
167
|
}
|
|
162
|
-
}, [
|
|
168
|
+
}, [is12Hour, onChange]);
|
|
163
169
|
const toggleAmpm = (0, react_1.useCallback)(() => {
|
|
164
170
|
if (!is12Hour)
|
|
165
171
|
return;
|
|
@@ -259,6 +265,8 @@ exports.TimePickerInput = (0, react_1.forwardRef)(function TimePickerInput({ val
|
|
|
259
265
|
if (disabled)
|
|
260
266
|
return;
|
|
261
267
|
const key = e.key;
|
|
268
|
+
if (/^[0-9]$/.test(key) || key === "Backspace" || key === "Delete")
|
|
269
|
+
typedSinceFocusRef.current = true;
|
|
262
270
|
if (/^[0-9]$/.test(key)) {
|
|
263
271
|
e.preventDefault();
|
|
264
272
|
handleDigitInput(key);
|
|
@@ -307,9 +315,10 @@ exports.TimePickerInput = (0, react_1.forwardRef)(function TimePickerInput({ val
|
|
|
307
315
|
setIsFocused(true);
|
|
308
316
|
isFocusedRef.current = true;
|
|
309
317
|
setActiveSegment("hour");
|
|
318
|
+
typedSinceFocusRef.current = false;
|
|
310
319
|
requestAnimationFrame(() => {
|
|
311
320
|
const el = inputRef.current;
|
|
312
|
-
if (!el)
|
|
321
|
+
if (!el || typedSinceFocusRef.current)
|
|
313
322
|
return;
|
|
314
323
|
el.value = formatDigits(digitsRef.current);
|
|
315
324
|
el.focus();
|
|
@@ -368,8 +377,7 @@ exports.TimePickerInput = (0, react_1.forwardRef)(function TimePickerInput({ val
|
|
|
368
377
|
}, [applyDigits]);
|
|
369
378
|
(0, react_1.useEffect)(() => {
|
|
370
379
|
if (value) {
|
|
371
|
-
const
|
|
372
|
-
const newDigits = adjustDigits(formattedValue.replace(/\D/g, ""), is12Hour);
|
|
380
|
+
const newDigits = digitsFromDate(value, is12Hour);
|
|
373
381
|
digitsRef.current = newDigits;
|
|
374
382
|
setDigits(newDigits);
|
|
375
383
|
if (is12Hour) {
|
|
@@ -399,7 +407,7 @@ exports.TimePickerInput = (0, react_1.forwardRef)(function TimePickerInput({ val
|
|
|
399
407
|
inputRef.current.value = "";
|
|
400
408
|
}
|
|
401
409
|
}
|
|
402
|
-
}, [value,
|
|
410
|
+
}, [value, is12Hour]);
|
|
403
411
|
(0, react_1.useEffect)(() => {
|
|
404
412
|
const formatted = formatDigits(digits);
|
|
405
413
|
if (!isFocusedRef.current && inputRef.current) {
|
|
@@ -81,6 +81,15 @@ const truncateLabel = (label, max) => max !== undefined && label.length > max ?
|
|
|
81
81
|
const asIdSet = (values) => new Set((values !== null && values !== void 0 ? values : []).map((v) => v.toString()));
|
|
82
82
|
/** Regression-guarded id scheme — tickets e2e (`e2e/tests/helpers/selectV2.ts`) resolves it verbatim. */
|
|
83
83
|
const optionDomId = (listboxId, id) => `${listboxId}-option-${id.toString().replace(/[^a-zA-Z0-9_-]/g, "-")}`;
|
|
84
|
+
// NOTE: a Drawer/Modal aria-hides sibling portals on open, which hid this popup's options too.
|
|
85
|
+
const unhideFromModal = (popup, trigger) => {
|
|
86
|
+
if (trigger.closest('[aria-hidden="true"]'))
|
|
87
|
+
return;
|
|
88
|
+
for (let node = popup.parentElement; node && !node.contains(trigger); node = node.parentElement) {
|
|
89
|
+
if (node.getAttribute("aria-hidden") === "true" && node.hasAttribute("data-aria-hidden"))
|
|
90
|
+
node.removeAttribute("aria-hidden");
|
|
91
|
+
}
|
|
92
|
+
};
|
|
84
93
|
const parseRemToPx = (value, fallbackPx) => {
|
|
85
94
|
const match = /^(\d*\.?\d+)rem$/.exec(value);
|
|
86
95
|
return match ? parseFloat(match[1]) * 16 : fallbackPx;
|
|
@@ -90,7 +99,9 @@ const OptionRow = react_1.default.memo(function OptionRow({ option, index, listb
|
|
|
90
99
|
const solidDisabledInk = option.isDisabled ? ink.disabled : null;
|
|
91
100
|
const checkSlotPx = Math.max(CHECK_SLOT_MIN_PX, spec.iconSize);
|
|
92
101
|
const checkSlot = ((0, jsx_runtime_1.jsx)(react_2.Box, { as: "span", "aria-hidden": true, display: "inline-flex", justifyContent: "center", flexShrink: 0, width: `${checkSlotPx}px`, children: isSingleSelected ? (0, jsx_runtime_1.jsx)(react_2.Box, { as: lucide_react_1.Check, size: spec.iconSize, color: theme.colors.accentText }) : null }));
|
|
93
|
-
|
|
102
|
+
const rowId = optionDomId(listboxId, option.id);
|
|
103
|
+
const hasOwnText = !renderOption;
|
|
104
|
+
return ((0, jsx_runtime_1.jsxs)(react_2.Box, { id: rowId, "data-index": index, role: "option", "aria-labelledby": hasOwnText ? `${rowId}-label` : undefined, "aria-describedby": hasOwnText && option.description ? `${rowId}-description` : undefined, "aria-selected": isSelected, "aria-disabled": option.isDisabled, onMouseEnter: () => onActivate(index), onClick: () => onSelect(option), mx: spec.mx, px: spec.px, py: spec.py, minH: spec.minH, borderRadius: "md", cursor: option.isDisabled ? "not-allowed" : "pointer", display: "flex", alignItems: "center", gap: spec.gap, fontSize: spec.fontSize, fontWeight: (0, optionRowInk_1.optionRowWeight)(isSingleSelected), color: solidDisabledInk !== null && solidDisabledInk !== void 0 ? solidDisabledInk : (isSingleSelected ? ink.selected : ink.rest), bg: (0, selectRowInk_1.selectRowFill)(backgrounds, { isSelected, isActive }), boxShadow: showRing ? (0, selectKeyboardRing_1.keyboardRingShadow)(backgrounds.keyboardRing) : undefined, transition: ROW_TRANSITION, sx: option.isDisabled && !ink.disabled ? { ...(0, motion_2.reducedMotionSx)(), ...DISABLED_CONTENT_SX } : (0, motion_2.reducedMotionSx)(), children: [!isMulti && checkPlacement === "start" ? checkSlot : null, isMulti ? ((0, jsx_runtime_1.jsx)(react_2.Checkbox, { id: `${rowId}-checkbox`, isChecked: isSelected, isDisabled: option.isDisabled, pointerEvents: "none", tabIndex: -1, sx: DECORATIVE_CHECKBOX_SX })) : null, renderOption ? ((0, jsx_runtime_1.jsx)(react_2.Box, { flex: 1, minW: 0, children: renderOption(option, { isSelected, isActive }) })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [option.icon ? ((0, jsx_runtime_1.jsx)(react_2.Box, { as: "span", display: "inline-flex", flexShrink: 0, children: option.icon })) : null, (0, jsx_runtime_1.jsxs)(react_2.Box, { flex: 1, minW: 0, isTruncated: true, children: [(0, jsx_runtime_1.jsx)(react_2.Box, { as: "span", id: `${rowId}-label`, isTruncated: true, children: option.label }), option.description ? ((0, jsx_runtime_1.jsx)(react_2.Box, { as: "span", id: `${rowId}-description`, display: "block", fontSize: spec.descriptionFontSize, color: solidDisabledInk !== null && solidDisabledInk !== void 0 ? solidDisabledInk : ink.description, isTruncated: true, children: option.description })) : null] })] })), renderOptionEnd ? ((0, jsx_runtime_1.jsx)(react_2.Box, { as: "span", display: "inline-flex", flexShrink: 0, children: renderOptionEnd(option, { isSelected, isActive }) })) : null, optionAction ? ((0, jsx_runtime_1.jsx)(react_2.Box, { as: "span", "aria-hidden": true, title: optionAction.label, onMouseDown: (event) => event.preventDefault(), onClick: (event) => {
|
|
94
105
|
event.stopPropagation();
|
|
95
106
|
optionAction.onAction(option);
|
|
96
107
|
}, display: "inline-flex", alignItems: "center", justifyContent: "center", flexShrink: 0, cursor: "pointer", color: ink.description, _hover: { color: ink.selected }, children: optionAction.icon })) : null, !isMulti && checkPlacement === "end" ? checkSlot : null] }));
|
|
@@ -172,7 +183,7 @@ const SelectPopup = (0, react_1.forwardRef)(function SelectPopup(props, ref) {
|
|
|
172
183
|
const handleOpen = () => {
|
|
173
184
|
if (!isInteractive)
|
|
174
185
|
return;
|
|
175
|
-
requestExclusiveOpen();
|
|
186
|
+
requestExclusiveOpen(triggerRef.current);
|
|
176
187
|
onFocus === null || onFocus === void 0 ? void 0 : onFocus();
|
|
177
188
|
onOpen();
|
|
178
189
|
const firstSelected = props.isMulti
|
|
@@ -262,6 +273,17 @@ const SelectPopup = (0, react_1.forwardRef)(function SelectPopup(props, ref) {
|
|
|
262
273
|
return;
|
|
263
274
|
setTriggerWidth(node.getBoundingClientRect().width);
|
|
264
275
|
}, [isOpen]);
|
|
276
|
+
(0, react_1.useEffect)(() => {
|
|
277
|
+
if (!isOpen)
|
|
278
|
+
return;
|
|
279
|
+
const reveal = () => {
|
|
280
|
+
if (listRef.current && triggerRef.current)
|
|
281
|
+
unhideFromModal(listRef.current, triggerRef.current);
|
|
282
|
+
};
|
|
283
|
+
reveal();
|
|
284
|
+
const frame = requestAnimationFrame(reveal);
|
|
285
|
+
return () => cancelAnimationFrame(frame);
|
|
286
|
+
}, [isOpen]);
|
|
265
287
|
(0, react_1.useEffect)(() => {
|
|
266
288
|
if (!isOpen || !isSearchable)
|
|
267
289
|
return;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
export declare const exclusiveOpen: (id: string, close: () => void
|
|
1
|
+
export declare const exclusiveOpen: (id: string, close: () => void, options?: {
|
|
2
|
+
anchor?: Node | null;
|
|
3
|
+
contains?: (node: Node) => boolean;
|
|
4
|
+
}) => void;
|
|
2
5
|
export declare const exclusiveClose: (id: string) => void;
|
|
3
6
|
/** Test-only reset — not exported from the package root. */
|
|
4
7
|
export declare const resetExclusiveOverlay: () => void;
|