@acusti/dropdown 0.55.1 → 0.56.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/README.md +44 -4
- package/dist/Dropdown.d.ts +2 -2
- package/dist/Dropdown.js +106 -67
- package/dist/Dropdown.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -98,10 +98,24 @@ This means the dropdown tends to:
|
|
|
98
98
|
Internally, the dropdown renders:
|
|
99
99
|
|
|
100
100
|
- `.uktdropdown-body` as the anchored outer shell
|
|
101
|
-
- `.uktdropdown-content` as the scrollable inner region
|
|
101
|
+
- `.uktdropdown-content` as the scrollable inner region with default
|
|
102
|
+
padding
|
|
102
103
|
|
|
103
|
-
Custom padding and overflow styling
|
|
104
|
-
|
|
104
|
+
Custom padding and overflow styling belongs on the content region, not the
|
|
105
|
+
outer shell. Note that `.uktdropdown-content` already applies default
|
|
106
|
+
padding (see the `--uktdd-body-pad-*` variables below), so your body
|
|
107
|
+
element does **not** need its own padding:
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
// ✗ Don’t double-pad — the content region already has padding
|
|
111
|
+
<Dropdown>
|
|
112
|
+
<button>Open</button>
|
|
113
|
+
<div style={{ padding: 16 }}>…</div>
|
|
114
|
+
</Dropdown>
|
|
115
|
+
|
|
116
|
+
// ✓ Override default padding via CSS variables if needed
|
|
117
|
+
// .my-dropdown { --uktdd-body-pad-top: 16px; /* etc */ }
|
|
118
|
+
```
|
|
105
119
|
|
|
106
120
|
For the most reliable anchor-positioning behavior:
|
|
107
121
|
|
|
@@ -111,6 +125,12 @@ For the most reliable anchor-positioning behavior:
|
|
|
111
125
|
- prefer CSS variable overrides over custom `top`/`left`/`right` inset
|
|
112
126
|
rules
|
|
113
127
|
|
|
128
|
+
For placement recipes, see
|
|
129
|
+
[Placement Customization](#placement-customization-with-css-variables)
|
|
130
|
+
below. If your trigger sits near the right edge of the viewport, the
|
|
131
|
+
[End-Aligned, Content-Sized Menu](#end-aligned-content-sized-menu) example
|
|
132
|
+
is the one you want.
|
|
133
|
+
|
|
114
134
|
## API Reference
|
|
115
135
|
|
|
116
136
|
### Props
|
|
@@ -337,12 +357,17 @@ function MultiSelectDropdown() {
|
|
|
337
357
|
|
|
338
358
|
### Dropdown with Interactive Content
|
|
339
359
|
|
|
360
|
+
For dropdowns whose body is a form (inputs, date pickers, buttons that
|
|
361
|
+
aren’t meant to submit a value), pass `hasItems={false}`. This disables the
|
|
362
|
+
item-selection keyboard model and, importantly, prevents clicks inside the
|
|
363
|
+
body from closing the dropdown via `onSubmitItem`.
|
|
364
|
+
|
|
340
365
|
```tsx
|
|
341
366
|
function InteractiveDropdown() {
|
|
342
367
|
return (
|
|
343
368
|
<Dropdown hasItems={false}>
|
|
344
369
|
<button>Settings</button>
|
|
345
|
-
<div
|
|
370
|
+
<div>
|
|
346
371
|
<label>
|
|
347
372
|
Full name:{' '}
|
|
348
373
|
<input
|
|
@@ -437,3 +462,18 @@ For accessibility, the component focuses on semantic HTML structure and
|
|
|
437
462
|
keyboard navigation. It works best when you use appropriate HTML elements
|
|
438
463
|
in your dropdown content (like `<ul>` and `<li>` for lists, `<button>`
|
|
439
464
|
elements for actions, etc.).
|
|
465
|
+
|
|
466
|
+
### ARIA attributes
|
|
467
|
+
|
|
468
|
+
The trigger automatically receives `aria-haspopup`, `aria-expanded`, and
|
|
469
|
+
`aria-controls` pointing to the open body. The popup role is chosen based
|
|
470
|
+
on the dropdown’s mode:
|
|
471
|
+
|
|
472
|
+
- `aria-haspopup="listbox"` when `isSearchable` is true (combobox pattern)
|
|
473
|
+
- `aria-haspopup="menu"` when `hasItems` is true (the default)
|
|
474
|
+
- `aria-haspopup="dialog"` when `hasItems={false}` (interactive content)
|
|
475
|
+
|
|
476
|
+
The open body element also receives a matching `role` and an `id` so screen
|
|
477
|
+
readers can associate the trigger with its popup. If your custom trigger
|
|
478
|
+
already specifies any of these ARIA props, your values win — the component
|
|
479
|
+
only fills in what you haven’t set.
|
package/dist/Dropdown.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CSSProperties,
|
|
1
|
+
import { CSSProperties, MouseEvent as ReactMouseEvent, ReactElement, ReactNode, SyntheticEvent } from 'react';
|
|
2
2
|
export type Item = {
|
|
3
3
|
element: MaybeHTMLElement;
|
|
4
4
|
event: Event | SyntheticEvent<HTMLElement>;
|
|
@@ -19,7 +19,7 @@ export type Props = {
|
|
|
19
19
|
/**
|
|
20
20
|
* Can take a single React element or exactly two renderable children.
|
|
21
21
|
*/
|
|
22
|
-
children: ChildrenTuple |
|
|
22
|
+
children: ChildrenTuple | ReactElement;
|
|
23
23
|
className?: string;
|
|
24
24
|
disabled?: boolean;
|
|
25
25
|
/**
|
package/dist/Dropdown.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c } from "react/compiler-runtime";
|
|
2
2
|
import useKeyboardEvents, { isEventTargetUsingKeyEvent } from "@acusti/use-keyboard-events";
|
|
3
3
|
import clsx from "clsx";
|
|
4
|
-
import { Children, Fragment, isValidElement, useEffect, useRef, useState } from "react";
|
|
4
|
+
import { Children, Fragment, cloneElement, isValidElement, useEffect, useId, useRef, useState } from "react";
|
|
5
5
|
import { getBestMatch } from "@acusti/matchmaking";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
//#region src/Dropdown.css?inline
|
|
@@ -99,7 +99,7 @@ var CHILDREN_ERROR = "@acusti/dropdown requires either 1 child (the dropdown bod
|
|
|
99
99
|
var CLICKABLE_SELECTOR = "button, a[href], input[type=\"button\"], input[type=\"submit\"]";
|
|
100
100
|
var TEXT_INPUT_SELECTOR = "input:not([type=radio]):not([type=checkbox]):not([type=range]),textarea";
|
|
101
101
|
function Dropdown(t0) {
|
|
102
|
-
const $ = c(
|
|
102
|
+
const $ = c(95);
|
|
103
103
|
const { allowCreate, allowEmpty: t1, children, className, disabled, hasItems: t2, isOpenOnMount, isSearchable, keepOpenOnSubmit: t3, label, minHeightBody, minWidthBody, name, onActiveItem, onClick, onClose, onMouseDown, onMouseUp, onOpen, onSubmitItem, placeholder, style: styleFromProps, tabIndex, value } = t0;
|
|
104
104
|
const allowEmpty = t1 === void 0 ? true : t1;
|
|
105
105
|
const hasItems = t2 === void 0 ? true : t2;
|
|
@@ -114,6 +114,8 @@ function Dropdown(t0) {
|
|
|
114
114
|
const [isOpen, setIsOpen] = useState(isOpenOnMount ?? false);
|
|
115
115
|
const [isOpening, setIsOpening] = useState(!isOpenOnMount);
|
|
116
116
|
const [dropdownElement, setDropdownElement] = useState(null);
|
|
117
|
+
const bodyId = useId();
|
|
118
|
+
const popupRole = isSearchable ? "listbox" : hasItems ? "menu" : "dialog";
|
|
117
119
|
const inputElementRef = useRef(null);
|
|
118
120
|
const closingTimerRef = useRef(null);
|
|
119
121
|
const isOpeningTimerRef = useRef(null);
|
|
@@ -532,8 +534,11 @@ function Dropdown(t0) {
|
|
|
532
534
|
$[38] = t19;
|
|
533
535
|
} else t19 = $[38];
|
|
534
536
|
let t20;
|
|
535
|
-
if ($[39] !==
|
|
537
|
+
if ($[39] !== bodyId || $[40] !== disabled || $[41] !== isOpen || $[42] !== name || $[43] !== placeholder || $[44] !== popupRole || $[45] !== t18 || $[46] !== tabIndex) {
|
|
536
538
|
t20 = /* @__PURE__ */ jsx("input", {
|
|
539
|
+
"aria-controls": bodyId,
|
|
540
|
+
"aria-expanded": isOpen,
|
|
541
|
+
"aria-haspopup": popupRole,
|
|
537
542
|
autoComplete: "off",
|
|
538
543
|
className: "uktdropdown-trigger",
|
|
539
544
|
defaultValue: t18,
|
|
@@ -545,114 +550,148 @@ function Dropdown(t0) {
|
|
|
545
550
|
tabIndex,
|
|
546
551
|
type: "text"
|
|
547
552
|
});
|
|
548
|
-
$[39] =
|
|
549
|
-
$[40] =
|
|
550
|
-
$[41] =
|
|
551
|
-
$[42] =
|
|
552
|
-
$[43] =
|
|
553
|
-
$[44] =
|
|
554
|
-
|
|
553
|
+
$[39] = bodyId;
|
|
554
|
+
$[40] = disabled;
|
|
555
|
+
$[41] = isOpen;
|
|
556
|
+
$[42] = name;
|
|
557
|
+
$[43] = placeholder;
|
|
558
|
+
$[44] = popupRole;
|
|
559
|
+
$[45] = t18;
|
|
560
|
+
$[46] = tabIndex;
|
|
561
|
+
$[47] = t20;
|
|
562
|
+
} else t20 = $[47];
|
|
555
563
|
trigger = t20;
|
|
556
564
|
} else {
|
|
557
565
|
let t18;
|
|
558
|
-
if ($[
|
|
566
|
+
if ($[48] !== bodyId || $[49] !== isOpen || $[50] !== popupRole || $[51] !== trigger) {
|
|
559
567
|
t18 = /* @__PURE__ */ jsx("button", {
|
|
568
|
+
"aria-controls": bodyId,
|
|
569
|
+
"aria-expanded": isOpen,
|
|
570
|
+
"aria-haspopup": popupRole,
|
|
560
571
|
className: "uktdropdown-trigger",
|
|
561
572
|
tabIndex: 0,
|
|
562
573
|
type: "button",
|
|
563
574
|
children: trigger
|
|
564
575
|
});
|
|
565
|
-
$[
|
|
566
|
-
$[
|
|
567
|
-
|
|
576
|
+
$[48] = bodyId;
|
|
577
|
+
$[49] = isOpen;
|
|
578
|
+
$[50] = popupRole;
|
|
579
|
+
$[51] = trigger;
|
|
580
|
+
$[52] = t18;
|
|
581
|
+
} else t18 = $[52];
|
|
568
582
|
trigger = t18;
|
|
569
583
|
}
|
|
584
|
+
else {
|
|
585
|
+
const triggerProps = trigger.props;
|
|
586
|
+
const t18 = trigger;
|
|
587
|
+
const t19 = triggerProps["aria-controls"] ?? bodyId;
|
|
588
|
+
const t20 = triggerProps["aria-expanded"] ?? isOpen;
|
|
589
|
+
const t21 = triggerProps["aria-haspopup"] ?? popupRole;
|
|
590
|
+
let t22;
|
|
591
|
+
if ($[53] !== t18 || $[54] !== t19 || $[55] !== t20 || $[56] !== t21) {
|
|
592
|
+
t22 = cloneElement(t18, {
|
|
593
|
+
"aria-controls": t19,
|
|
594
|
+
"aria-expanded": t20,
|
|
595
|
+
"aria-haspopup": t21
|
|
596
|
+
});
|
|
597
|
+
$[53] = t18;
|
|
598
|
+
$[54] = t19;
|
|
599
|
+
$[55] = t20;
|
|
600
|
+
$[56] = t21;
|
|
601
|
+
$[57] = t22;
|
|
602
|
+
} else t22 = $[57];
|
|
603
|
+
trigger = t22;
|
|
604
|
+
}
|
|
570
605
|
if (label != null) {
|
|
571
606
|
let t18;
|
|
572
|
-
if ($[
|
|
607
|
+
if ($[58] !== label) {
|
|
573
608
|
t18 = /* @__PURE__ */ jsx("div", {
|
|
574
609
|
className: "uktdropdown-label-text",
|
|
575
610
|
children: label
|
|
576
611
|
});
|
|
577
|
-
$[
|
|
578
|
-
$[
|
|
579
|
-
} else t18 = $[
|
|
612
|
+
$[58] = label;
|
|
613
|
+
$[59] = t18;
|
|
614
|
+
} else t18 = $[59];
|
|
580
615
|
let t19;
|
|
581
|
-
if ($[
|
|
616
|
+
if ($[60] !== t18 || $[61] !== trigger) {
|
|
582
617
|
t19 = /* @__PURE__ */ jsxs("label", {
|
|
583
618
|
className: "uktdropdown-label",
|
|
584
619
|
children: [t18, trigger]
|
|
585
620
|
});
|
|
586
|
-
$[
|
|
587
|
-
$[
|
|
588
|
-
$[
|
|
589
|
-
} else t19 = $[
|
|
621
|
+
$[60] = t18;
|
|
622
|
+
$[61] = trigger;
|
|
623
|
+
$[62] = t19;
|
|
624
|
+
} else t19 = $[62];
|
|
590
625
|
trigger = t19;
|
|
591
626
|
}
|
|
592
627
|
let t18;
|
|
593
|
-
if ($[
|
|
628
|
+
if ($[63] !== minHeightBody) {
|
|
594
629
|
t18 = minHeightBody != null && minHeightBody > 0 ? { "--uktdd-body-min-height": `${minHeightBody}px` } : null;
|
|
595
|
-
$[
|
|
596
|
-
$[
|
|
597
|
-
} else t18 = $[
|
|
630
|
+
$[63] = minHeightBody;
|
|
631
|
+
$[64] = t18;
|
|
632
|
+
} else t18 = $[64];
|
|
598
633
|
let t19;
|
|
599
|
-
if ($[
|
|
634
|
+
if ($[65] !== minWidthBody) {
|
|
600
635
|
t19 = minWidthBody != null && minWidthBody > 0 ? { "--uktdd-body-min-width": `${minWidthBody}px` } : null;
|
|
601
|
-
$[
|
|
602
|
-
$[
|
|
603
|
-
} else t19 = $[
|
|
636
|
+
$[65] = minWidthBody;
|
|
637
|
+
$[66] = t19;
|
|
638
|
+
} else t19 = $[66];
|
|
604
639
|
let t20;
|
|
605
|
-
if ($[
|
|
640
|
+
if ($[67] !== styleFromProps || $[68] !== t18 || $[69] !== t19) {
|
|
606
641
|
t20 = {
|
|
607
642
|
...styleFromProps,
|
|
608
643
|
...t18,
|
|
609
644
|
...t19
|
|
610
645
|
};
|
|
611
|
-
$[
|
|
612
|
-
$[
|
|
613
|
-
$[
|
|
614
|
-
$[
|
|
615
|
-
} else t20 = $[
|
|
646
|
+
$[67] = styleFromProps;
|
|
647
|
+
$[68] = t18;
|
|
648
|
+
$[69] = t19;
|
|
649
|
+
$[70] = t20;
|
|
650
|
+
} else t20 = $[70];
|
|
616
651
|
const style = t20;
|
|
617
652
|
let t21;
|
|
618
|
-
if ($[
|
|
653
|
+
if ($[71] === Symbol.for("react.memo_cache_sentinel")) {
|
|
619
654
|
t21 = /* @__PURE__ */ jsx("style", {
|
|
620
655
|
href: "@acusti/dropdown/Dropdown",
|
|
621
656
|
precedence: "medium",
|
|
622
657
|
children: Dropdown_default
|
|
623
658
|
});
|
|
624
|
-
$[
|
|
625
|
-
} else t21 = $[
|
|
659
|
+
$[71] = t21;
|
|
660
|
+
} else t21 = $[71];
|
|
626
661
|
let t22;
|
|
627
|
-
if ($[
|
|
662
|
+
if ($[72] !== className || $[73] !== disabled || $[74] !== isOpen || $[75] !== isSearchable) {
|
|
628
663
|
t22 = clsx("uktdropdown", className, {
|
|
629
664
|
disabled,
|
|
630
665
|
"is-open": isOpen,
|
|
631
666
|
"is-searchable": isSearchable
|
|
632
667
|
});
|
|
633
|
-
$[
|
|
634
|
-
$[
|
|
635
|
-
$[
|
|
636
|
-
$[
|
|
637
|
-
$[
|
|
638
|
-
} else t22 = $[
|
|
668
|
+
$[72] = className;
|
|
669
|
+
$[73] = disabled;
|
|
670
|
+
$[74] = isOpen;
|
|
671
|
+
$[75] = isSearchable;
|
|
672
|
+
$[76] = t22;
|
|
673
|
+
} else t22 = $[76];
|
|
639
674
|
let t23;
|
|
640
|
-
if ($[
|
|
675
|
+
if ($[77] !== bodyId || $[78] !== children || $[79] !== childrenCount || $[80] !== hasItems || $[81] !== isOpen || $[82] !== popupRole) {
|
|
641
676
|
t23 = isOpen ? /* @__PURE__ */ jsx("div", {
|
|
642
677
|
className: clsx("uktdropdown-body", { "has-items": hasItems }),
|
|
678
|
+
id: bodyId,
|
|
679
|
+
role: popupRole,
|
|
643
680
|
children: /* @__PURE__ */ jsx("div", {
|
|
644
681
|
className: "uktdropdown-content",
|
|
645
682
|
children: childrenCount > 1 ? children[1] : children
|
|
646
683
|
})
|
|
647
684
|
}) : null;
|
|
648
|
-
$[
|
|
649
|
-
$[
|
|
650
|
-
$[
|
|
651
|
-
$[
|
|
652
|
-
$[
|
|
653
|
-
|
|
685
|
+
$[77] = bodyId;
|
|
686
|
+
$[78] = children;
|
|
687
|
+
$[79] = childrenCount;
|
|
688
|
+
$[80] = hasItems;
|
|
689
|
+
$[81] = isOpen;
|
|
690
|
+
$[82] = popupRole;
|
|
691
|
+
$[83] = t23;
|
|
692
|
+
} else t23 = $[83];
|
|
654
693
|
let t24;
|
|
655
|
-
if ($[
|
|
694
|
+
if ($[84] !== handleMouseDown || $[85] !== handleMouseOut || $[86] !== handleMouseOver || $[87] !== handleMouseUp || $[88] !== handleRef || $[89] !== onClick || $[90] !== style || $[91] !== t22 || $[92] !== t23 || $[93] !== trigger) {
|
|
656
695
|
t24 = /* @__PURE__ */ jsxs(Fragment, { children: [t21, /* @__PURE__ */ jsxs("div", {
|
|
657
696
|
className: t22,
|
|
658
697
|
onClick,
|
|
@@ -665,18 +704,18 @@ function Dropdown(t0) {
|
|
|
665
704
|
style,
|
|
666
705
|
children: [trigger, t23]
|
|
667
706
|
})] });
|
|
668
|
-
$[
|
|
669
|
-
$[
|
|
670
|
-
$[
|
|
671
|
-
$[
|
|
672
|
-
$[
|
|
673
|
-
$[
|
|
674
|
-
$[
|
|
675
|
-
$[
|
|
676
|
-
$[
|
|
677
|
-
$[
|
|
678
|
-
$[
|
|
679
|
-
} else t24 = $[
|
|
707
|
+
$[84] = handleMouseDown;
|
|
708
|
+
$[85] = handleMouseOut;
|
|
709
|
+
$[86] = handleMouseOver;
|
|
710
|
+
$[87] = handleMouseUp;
|
|
711
|
+
$[88] = handleRef;
|
|
712
|
+
$[89] = onClick;
|
|
713
|
+
$[90] = style;
|
|
714
|
+
$[91] = t22;
|
|
715
|
+
$[92] = t23;
|
|
716
|
+
$[93] = trigger;
|
|
717
|
+
$[94] = t24;
|
|
718
|
+
} else t24 = $[94];
|
|
680
719
|
return t24;
|
|
681
720
|
}
|
|
682
721
|
//#endregion
|
package/dist/Dropdown.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropdown.js","names":["getBestMatch","SyntheticEvent","Item","ITEM_SELECTOR","getItemElements","dropdownElement","HTMLElement","bodyElement","querySelector","items","HTMLCollection","NodeListOf","Element","querySelectorAll","length","children","getActiveItemElement","clearItemElementsState","itemElements","Array","forEach","itemElement","hasAttribute","dataset","uktActive","BaseSetActiveItemPayload","element","event","Event","index","indexAddend","isExactMatch","onActiveItem","payload","text","setActiveItem","Omit","from","lastIndex","currentActiveIndex","findIndex","nextActiveIndex","Math","max","min","itemTexts","map","innerText","textToCompare","toLowerCase","itemText","startsWith","bestMatch","nextActiveItem","setAttribute","label","value","uktValue","parentElement","scrollableParent","isScrollable","scrollHeight","clientHeight","parentRect","getBoundingClientRect","itemRect","isAboveTop","top","isBelowBottom","bottom","scrollTop","useKeyboardEvents","isEventTargetUsingKeyEvent","clsx","Children","CSSProperties","Fragment","isValidElement","JSX","MouseEvent","ReactMouseEvent","ReactNode","SyntheticEvent","useEffect","useRef","useState","styles","getActiveItemElement","getItemElements","ITEM_SELECTOR","setActiveItem","Item","element","MaybeHTMLElement","event","Event","HTMLElement","label","value","Props","allowCreate","allowEmpty","children","ChildrenTuple","Element","className","disabled","group","hasItems","isOpenOnMount","isSearchable","keepOpenOnSubmit","minHeightBody","minWidthBody","name","onActiveItem","payload","onClick","onClose","onMouseDown","onMouseUp","onOpen","onSubmitItem","placeholder","style","tabIndex","MousePosition","clientX","clientY","TimeoutID","ReturnType","setTimeout","CHILDREN_ERROR","CLICKABLE_SELECTOR","TEXT_INPUT_SELECTOR","Dropdown","t0","$","_c","t1","t2","t3","styleFromProps","undefined","childrenCount","count","Error","console","error","trigger","isOpen","setIsOpen","isOpening","setIsOpening","dropdownElement","setDropdownElement","inputElementRef","closingTimerRef","isOpeningTimerRef","currentInputMethodRef","clearEnteredCharactersTimerRef","enteredCharactersRef","mouseDownPositionRef","allowCreateRef","allowEmptyRef","hasItemsRef","isOpenRef","isOpeningRef","keepOpenOnSubmitRef","onCloseRef","onOpenRef","onSubmitItemRef","valueRef","t4","t5","current","isMountedRef","t6","t7","t8","Symbol","for","clearTimeout","closeDropdown","t9","itemLabel","innerText","ownerDocument","activeElement","blur","nextValue","dataset","uktValue","eventTarget","target","matches","contains","click","clickableElements","querySelectorAll","length","clickableElement","handleSubmitItem","t10","t11","initialPosition","Math","abs","handleMouseMove","event_0","itemElements","eventTarget_0","item","closest","element_0","itemElement","handleMouseOver","t12","event_1","activeItem","eventRelatedTarget","relatedTarget","uktActive","handleMouseOut","t13","event_2","handleMouseDown","t14","event_3","eventTarget_1","handleMouseUp","t15","event_4","altKey","ctrlKey","key","metaKey","eventTarget_2","onEventHandled","stopPropagation","preventDefault","isEventTargetingDropdown","isTargetUsingKeyEvents","isEditingCharacters","test","slice","isExactMatch","text","index","indexAddend","handleKeyDown","t16","ignoreUsedKeyboardEvents","onKeyDown","t17","ref","inputElement","firstElementChild","HTMLInputElement","querySelector","handleGlobalMouseDown","t18","eventTarget_3","handleGlobalMouseUp","t19","target_0","eventTarget_4","handleGlobalFocusIn","t20","target_1","eventTarget_5","document","addEventListener","focus","handleInput","event_5","input","isDeleting","removeEventListener","handleRef","t21","t22","t23","t24"],"sources":["../src/Dropdown.css?inline","../src/helpers.ts","../src/Dropdown.tsx"],"sourcesContent":[":root {\n --uktdd-font-family:\n system-ui, Segoe UI, Roboto, Oxygen-Sans, Ubuntu, Cantarell, Helvetica Neue,\n Helvetica, Arial, sans-serif;\n --uktdd-body-bg-color: #fff;\n --uktdd-body-bg-color-hover: rgb(105, 162, 249);\n --uktdd-body-color-hover: #fff;\n --uktdd-body-buffer: 10px;\n --uktdd-body-max-height: calc(100dvh - var(--uktdd-body-buffer));\n --uktdd-body-max-width: calc(100dvw - var(--uktdd-body-buffer));\n --uktdd-body-min-height: 30px;\n --uktdd-body-pad-bottom: 9px;\n --uktdd-body-pad-left: 12px;\n --uktdd-body-pad-right: 12px;\n --uktdd-body-pad-top: 9px;\n --uktdd-body-min-width: min(50px, 100%);\n --uktdd-body-position-area: bottom span-right;\n --uktdd-body-position-try-fallbacks:\n --uktdd-top-left, --uktdd-bottom-right, --uktdd-top-right;\n --uktdd-body-translate: 0 0;\n --uktdd-label-pad-right: 10px;\n}\n\n.uktdropdown,\n.uktdropdown-trigger {\n font-family: var(--uktdd-font-family);\n}\n\n.uktdropdown {\n width: max-content;\n anchor-scope: --uktdd-anchor;\n\n &.disabled {\n pointer-events: none;\n }\n\n > * {\n cursor: default;\n }\n\n > :first-child {\n anchor-name: --uktdd-anchor;\n }\n}\n\n.uktdropdown-label {\n display: flex;\n align-items: center;\n}\n\n.uktdropdown-label-text {\n padding-right: var(--uktdd-label-pad-right);\n}\n\n.uktdropdown-body {\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n position: fixed;\n position-anchor: --uktdd-anchor;\n position-area: var(--uktdd-body-position-area);\n position-try-order: most-height;\n position-try-fallbacks: var(--uktdd-body-position-try-fallbacks);\n min-block-size: min(var(--uktdd-body-min-height), var(--uktdd-body-max-height));\n max-block-size: min(var(--uktdd-body-max-height), 100%);\n min-inline-size: min(var(--uktdd-body-min-width), var(--uktdd-body-max-width));\n max-inline-size: var(--uktdd-body-max-width);\n inline-size: max-content;\n overflow: hidden;\n translate: var(--uktdd-body-translate);\n z-index: 2;\n background-color: var(--uktdd-body-bg-color);\n box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);\n\n &.has-items {\n user-select: none;\n }\n\n [data-ukt-active] {\n background-color: var(--uktdd-body-bg-color-hover);\n color: var(--uktdd-body-color-hover);\n }\n}\n\n.uktdropdown-content {\n box-sizing: border-box;\n min-block-size: 0;\n overflow: auto;\n overscroll-behavior: contain;\n padding: var(--uktdd-body-pad-top) var(--uktdd-body-pad-right)\n var(--uktdd-body-pad-bottom) var(--uktdd-body-pad-left);\n}\n\n@position-try --uktdd-top-left {\n position-area: top span-right;\n}\n\n@position-try --uktdd-bottom-left {\n position-area: bottom span-right;\n}\n\n@position-try --uktdd-bottom-right {\n position-area: bottom span-left;\n}\n\n@position-try --uktdd-top-right {\n position-area: top span-left;\n}\n","import { getBestMatch } from '@acusti/matchmaking';\nimport { type SyntheticEvent } from 'react';\n\nimport { type Item } from './Dropdown.js';\n\nexport const ITEM_SELECTOR = `[data-ukt-item], [data-ukt-value]`;\n\nexport const getItemElements = (dropdownElement: HTMLElement | null) => {\n if (!dropdownElement) return null;\n\n const bodyElement = dropdownElement.querySelector('.uktdropdown-body');\n if (!bodyElement) return null;\n\n let items: HTMLCollection | NodeListOf<Element> =\n bodyElement.querySelectorAll(ITEM_SELECTOR);\n\n if (items.length) return items;\n // If no items found via [data-ukt-item] or [data-ukt-value] selector,\n // use first instance of multiple children found\n items = bodyElement.children;\n while (items.length === 1) {\n if (items[0].children == null) break;\n items = items[0].children;\n }\n // If unable to find an element with more than one child, treat direct child as items\n if (items.length === 1) {\n items = bodyElement.children;\n }\n return items;\n};\n\nexport const getActiveItemElement = (dropdownElement: HTMLElement | null) => {\n if (!dropdownElement) return null;\n return dropdownElement.querySelector('[data-ukt-active]') as HTMLElement | null;\n};\n\nconst clearItemElementsState = (itemElements: Array<HTMLElement>) => {\n itemElements.forEach((itemElement) => {\n if (itemElement.hasAttribute('data-ukt-active')) {\n delete itemElement.dataset.uktActive;\n }\n });\n};\n\ntype BaseSetActiveItemPayload = {\n dropdownElement: HTMLElement;\n element?: null;\n event: Event | SyntheticEvent<HTMLElement>;\n index?: null;\n indexAddend?: null;\n isExactMatch?: null;\n onActiveItem?: (payload: Item) => void;\n text?: null;\n};\n\nexport const setActiveItem = ({\n dropdownElement,\n element,\n event,\n index,\n indexAddend,\n isExactMatch,\n onActiveItem,\n text,\n}:\n | ({\n element: HTMLElement;\n } & Omit<BaseSetActiveItemPayload, 'element'>)\n | ({\n index: number;\n } & Omit<BaseSetActiveItemPayload, 'index'>)\n | ({\n indexAddend: number;\n } & Omit<BaseSetActiveItemPayload, 'indexAddend'>)\n | ({\n isExactMatch?: boolean;\n text: string;\n } & Omit<BaseSetActiveItemPayload, 'isExactMatch' | 'text'>)) => {\n const items = getItemElements(dropdownElement);\n if (!items) return;\n\n const itemElements = Array.from(items) as Array<HTMLElement>;\n if (!itemElements.length) return;\n\n const lastIndex = itemElements.length - 1;\n const currentActiveIndex = itemElements.findIndex((itemElement) =>\n itemElement.hasAttribute('data-ukt-active'),\n );\n\n let nextActiveIndex = currentActiveIndex;\n if (typeof index === 'number') {\n // Negative index means count back from the end\n nextActiveIndex = index < 0 ? itemElements.length + index : index;\n }\n\n if (element) {\n nextActiveIndex = itemElements.findIndex(\n (itemElement) => itemElement === element,\n );\n } else if (typeof indexAddend === 'number') {\n // If there’s no currentActiveIndex and we are handling -1, start at lastIndex\n if (currentActiveIndex === -1 && indexAddend === -1) {\n nextActiveIndex = lastIndex;\n } else {\n nextActiveIndex += indexAddend;\n }\n // Keep it within the bounds of the items list\n nextActiveIndex = Math.max(0, Math.min(nextActiveIndex, lastIndex));\n } else if (typeof text === 'string') {\n // If text is empty, clear existing active items and early return\n if (!text) {\n clearItemElementsState(itemElements);\n return;\n }\n\n const itemTexts = itemElements.map((itemElement) => itemElement.innerText);\n if (isExactMatch) {\n const textToCompare = text.toLowerCase();\n nextActiveIndex = itemTexts.findIndex((itemText) =>\n itemText.toLowerCase().startsWith(textToCompare),\n );\n // If isExactMatch is required and no exact match was found, clear active items\n if (nextActiveIndex === -1) {\n clearItemElementsState(itemElements);\n }\n } else {\n const bestMatch = getBestMatch({ items: itemTexts, text });\n nextActiveIndex = itemTexts.findIndex((itemText) => itemText === bestMatch);\n }\n }\n\n const nextActiveItem = items[nextActiveIndex] as HTMLElement | null;\n if (nextActiveItem == null || nextActiveIndex === currentActiveIndex) return;\n\n // Clear any existing active dropdown body item state\n clearItemElementsState(itemElements);\n nextActiveItem.setAttribute('data-ukt-active', '');\n const label = nextActiveItem.innerText;\n const value = nextActiveItem.dataset.uktValue ?? label;\n onActiveItem?.({ element: nextActiveItem, event, label, value });\n // Find closest scrollable parent and ensure that next active item is visible\n let { parentElement } = nextActiveItem;\n let scrollableParent = null;\n while (!scrollableParent && parentElement && parentElement !== dropdownElement) {\n const isScrollable = parentElement.scrollHeight > parentElement.clientHeight + 15;\n if (isScrollable) {\n scrollableParent = parentElement;\n } else {\n parentElement = parentElement.parentElement;\n }\n }\n\n if (scrollableParent) {\n const parentRect = scrollableParent.getBoundingClientRect();\n const itemRect = nextActiveItem.getBoundingClientRect();\n const isAboveTop = itemRect.top < parentRect.top;\n const isBelowBottom = itemRect.bottom > parentRect.bottom;\n if (isAboveTop || isBelowBottom) {\n let { scrollTop } = scrollableParent;\n // Item isn’t fully visible; adjust scrollTop to put item within closest edge\n if (isAboveTop) {\n scrollTop -= parentRect.top - itemRect.top;\n } else {\n scrollTop += itemRect.bottom - parentRect.bottom;\n }\n scrollableParent.scrollTop = scrollTop;\n }\n }\n};\n","/* eslint-disable jsx-a11y/click-events-have-key-events, jsx-a11y/mouse-events-have-key-events, jsx-a11y/no-static-element-interactions */\nimport useKeyboardEvents, {\n isEventTargetUsingKeyEvent,\n} from '@acusti/use-keyboard-events';\nimport clsx from 'clsx';\nimport {\n Children,\n type CSSProperties,\n Fragment,\n isValidElement,\n type JSX,\n type MouseEvent as ReactMouseEvent,\n type ReactNode,\n type SyntheticEvent,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport styles from './Dropdown.css?inline';\nimport {\n getActiveItemElement,\n getItemElements,\n ITEM_SELECTOR,\n setActiveItem,\n} from './helpers.js';\n\nexport type Item = {\n element: MaybeHTMLElement;\n event: Event | SyntheticEvent<HTMLElement>;\n label: string;\n value: string;\n};\n\nexport type Props = {\n /**\n * Boolean indicating if the user can submit a value not already in the\n * dropdown.\n */\n allowCreate?: boolean;\n /**\n * Boolean indicating if the user can submit an empty value (i.e. clear\n * the value). Defaults to true.\n */\n allowEmpty?: boolean;\n /**\n * Can take a single React element or exactly two renderable children.\n */\n children: ChildrenTuple | JSX.Element;\n className?: string;\n disabled?: boolean;\n /**\n * Group identifier string links dropdowns together into a menu\n * (like macOS top menubar).\n */\n group?: string;\n hasItems?: boolean;\n isOpenOnMount?: boolean;\n isSearchable?: boolean;\n keepOpenOnSubmit?: boolean;\n label?: ReactNode;\n minHeightBody?: number;\n minWidthBody?: number;\n /**\n * Only usable in conjunction with {isSearchable: true}.\n * Used as search input’s name.\n */\n name?: string;\n onActiveItem?: (payload: Item) => void;\n onClick?: (event: ReactMouseEvent<HTMLElement>) => unknown;\n onClose?: () => unknown;\n onMouseDown?: (event: ReactMouseEvent<HTMLElement>) => unknown;\n onMouseUp?: (event: ReactMouseEvent<HTMLElement>) => unknown;\n onOpen?: () => unknown;\n onSubmitItem?: (payload: Item) => void;\n /**\n * Only usable in conjunction with {isSearchable: true}.\n * Used as search input’s placeholder.\n */\n placeholder?: string;\n style?: CSSProperties;\n /**\n * Only usable in conjunction with {isSearchable: true}.\n * Used as search input’s tabIndex.\n */\n tabIndex?: number;\n /**\n * Used as search input’s value if props.isSearchable === true\n * Used to determine if value has changed to avoid triggering onSubmitItem if not\n */\n value?: string;\n};\n\ntype ChildrenTuple = [ReactNode, ReactNode] | readonly [ReactNode, ReactNode];\n\ntype MaybeHTMLElement = HTMLElement | null;\n\ntype MousePosition = { clientX: number; clientY: number };\n\ntype TimeoutID = ReturnType<typeof setTimeout>;\n\nconst CHILDREN_ERROR =\n '@acusti/dropdown requires either 1 child (the dropdown body) or 2 children: the dropdown trigger and the dropdown body.';\nconst CLICKABLE_SELECTOR = 'button, a[href], input[type=\"button\"], input[type=\"submit\"]';\nconst TEXT_INPUT_SELECTOR =\n 'input:not([type=radio]):not([type=checkbox]):not([type=range]),textarea';\n\nexport default function Dropdown({\n allowCreate,\n allowEmpty = true,\n children,\n className,\n disabled,\n hasItems = true,\n isOpenOnMount,\n isSearchable,\n keepOpenOnSubmit = !hasItems,\n label,\n minHeightBody,\n minWidthBody,\n name,\n onActiveItem,\n onClick,\n onClose,\n onMouseDown,\n onMouseUp,\n onOpen,\n onSubmitItem,\n placeholder,\n style: styleFromProps,\n tabIndex,\n value,\n}: Props) {\n const childrenCount = Children.count(children);\n if (childrenCount !== 1 && childrenCount !== 2) {\n if (childrenCount === 0) {\n throw new Error(CHILDREN_ERROR + ' Received no children.');\n }\n console.error(`${CHILDREN_ERROR} Received ${childrenCount} children.`);\n }\n\n let trigger: React.ReactNode;\n if (childrenCount > 1) {\n trigger = (children as ChildrenTuple)[0];\n }\n\n const [isOpen, setIsOpen] = useState<boolean>(isOpenOnMount ?? false);\n const [isOpening, setIsOpening] = useState<boolean>(!isOpenOnMount);\n const [dropdownElement, setDropdownElement] = useState<MaybeHTMLElement>(null);\n const inputElementRef = useRef<HTMLInputElement | null>(null);\n const closingTimerRef = useRef<null | TimeoutID>(null);\n const isOpeningTimerRef = useRef<null | TimeoutID>(null);\n const currentInputMethodRef = useRef<'keyboard' | 'mouse'>('mouse');\n const clearEnteredCharactersTimerRef = useRef<null | TimeoutID>(null);\n const enteredCharactersRef = useRef<string>('');\n const mouseDownPositionRef = useRef<MousePosition | null>(null);\n\n const allowCreateRef = useRef(allowCreate);\n const allowEmptyRef = useRef(allowEmpty);\n const hasItemsRef = useRef(hasItems);\n const isOpenRef = useRef(isOpen);\n const isOpeningRef = useRef(isOpening);\n const keepOpenOnSubmitRef = useRef(keepOpenOnSubmit);\n const onCloseRef = useRef(onClose);\n const onOpenRef = useRef(onOpen);\n const onSubmitItemRef = useRef(onSubmitItem);\n const valueRef = useRef(value);\n\n useEffect(() => {\n allowCreateRef.current = allowCreate;\n allowEmptyRef.current = allowEmpty;\n hasItemsRef.current = hasItems;\n isOpenRef.current = isOpen;\n isOpeningRef.current = isOpening;\n keepOpenOnSubmitRef.current = keepOpenOnSubmit;\n onCloseRef.current = onClose;\n onOpenRef.current = onOpen;\n onSubmitItemRef.current = onSubmitItem;\n valueRef.current = value;\n }, [\n allowCreate,\n allowEmpty,\n hasItems,\n isOpen,\n isOpening,\n keepOpenOnSubmit,\n onClose,\n onOpen,\n onSubmitItem,\n value,\n ]);\n\n const isMountedRef = useRef(false);\n\n useEffect(() => {\n if (!isMountedRef.current) {\n isMountedRef.current = true;\n // If isOpenOnMount, trigger onOpen right away\n if (isOpenRef.current && onOpenRef.current) {\n onOpenRef.current();\n }\n return;\n }\n\n if (isOpen && onOpenRef.current) {\n onOpenRef.current();\n } else if (!isOpen && onCloseRef.current) {\n onCloseRef.current();\n }\n }, [isOpen]);\n\n const closeDropdown = () => {\n setIsOpen(false);\n setIsOpening(false);\n mouseDownPositionRef.current = null;\n if (closingTimerRef.current != null) {\n clearTimeout(closingTimerRef.current);\n closingTimerRef.current = null;\n }\n };\n\n const handleSubmitItem = (event: Event | React.SyntheticEvent<HTMLElement>) => {\n if (isOpenRef.current && !keepOpenOnSubmitRef.current) {\n // A short timeout before closing is better UX when user selects an item so dropdown\n // doesn’t close before expected. It also enables using <Link />s in the dropdown body.\n closingTimerRef.current = setTimeout(closeDropdown, 90);\n }\n\n if (!hasItemsRef.current) return;\n\n const element = getActiveItemElement(dropdownElement);\n if (!element && !allowCreateRef.current) {\n // If not allowEmpty, don’t allow submitting an empty item\n if (!allowEmptyRef.current) return;\n // If we have an input element as trigger & the user didn’t clear the text, do nothing\n if (inputElementRef.current?.value) return;\n }\n\n let itemLabel = element?.innerText ?? '';\n if (inputElementRef.current) {\n if (!element) {\n itemLabel = inputElementRef.current.value;\n } else {\n inputElementRef.current.value = itemLabel;\n }\n\n if (\n inputElementRef.current ===\n inputElementRef.current.ownerDocument.activeElement\n ) {\n inputElementRef.current.blur();\n }\n }\n\n const nextValue = element?.dataset.uktValue ?? itemLabel;\n // If parent is controlling Dropdown via props.value and nextValue is the same, do nothing\n if (valueRef.current && valueRef.current === nextValue) return;\n\n // If the item is clickable or contains exactly one clickable element, invoke it\n // (but only if the event didn’t already originate from that element)\n if (element) {\n const eventTarget = event.target as HTMLElement;\n\n if (element.matches(CLICKABLE_SELECTOR)) {\n // The item element itself is clickable (e.g., <button data-ukt-value=\"…\">)\n if (element !== eventTarget && !element.contains(eventTarget)) {\n element.click();\n }\n } else {\n // Check if item contains exactly one clickable child element\n const clickableElements = element.querySelectorAll(CLICKABLE_SELECTOR);\n if (clickableElements.length === 1) {\n const clickableElement = clickableElements[0] as HTMLElement;\n if (\n clickableElement !== eventTarget &&\n !clickableElement.contains(eventTarget)\n ) {\n clickableElement.click();\n }\n }\n }\n }\n\n onSubmitItemRef.current?.({\n element,\n event,\n label: itemLabel,\n value: nextValue,\n });\n };\n\n const handleMouseMove = ({ clientX, clientY }: ReactMouseEvent<HTMLElement>) => {\n currentInputMethodRef.current = 'mouse';\n const initialPosition = mouseDownPositionRef.current;\n if (!initialPosition) return;\n if (\n Math.abs(initialPosition.clientX - clientX) < 12 &&\n Math.abs(initialPosition.clientY - clientY) < 12\n ) {\n return;\n }\n setIsOpening(false);\n };\n\n const handleMouseOver = (event: ReactMouseEvent<HTMLElement>) => {\n if (!hasItemsRef.current) return;\n\n // If user isn’t currently using the mouse to navigate the dropdown, do nothing\n if (currentInputMethodRef.current !== 'mouse') return;\n\n // Ensure we have the dropdown root HTMLElement\n if (!dropdownElement) return;\n\n const itemElements = getItemElements(dropdownElement);\n if (!itemElements) return;\n\n const eventTarget = event.target as HTMLElement;\n const item = eventTarget.closest(ITEM_SELECTOR) as MaybeHTMLElement;\n const element = item ?? eventTarget;\n for (const itemElement of itemElements) {\n if (itemElement === element) {\n setActiveItem({ dropdownElement, element, event, onActiveItem });\n return;\n }\n }\n };\n\n const handleMouseOut = (event: ReactMouseEvent<HTMLElement>) => {\n if (!hasItemsRef.current) return;\n const activeItem = getActiveItemElement(dropdownElement);\n if (!activeItem) return;\n const eventRelatedTarget = event.relatedTarget as HTMLElement;\n if (activeItem !== event.target || activeItem.contains(eventRelatedTarget)) {\n return;\n }\n // If user moused out of activeItem (not into a descendant), it’s no longer active\n delete activeItem.dataset.uktActive;\n };\n\n const handleMouseDown = (event: ReactMouseEvent<HTMLElement>) => {\n if (onMouseDown) onMouseDown(event);\n if (isOpenRef.current) return;\n\n setIsOpen(true);\n setIsOpening(true);\n mouseDownPositionRef.current = {\n clientX: event.clientX,\n clientY: event.clientY,\n };\n isOpeningTimerRef.current = setTimeout(() => {\n setIsOpening(false);\n isOpeningTimerRef.current = null;\n }, 1000);\n };\n\n const handleMouseUp = (event: ReactMouseEvent<HTMLElement>) => {\n if (onMouseUp) onMouseUp(event);\n // If dropdown is still opening or isn’t open or is closing, do nothing\n if (\n isOpeningRef.current ||\n !isOpenRef.current ||\n closingTimerRef.current != null\n ) {\n return;\n }\n\n const eventTarget = event.target as HTMLElement;\n // If click was outside dropdown body, don’t trigger submit\n if (!eventTarget.closest('.uktdropdown-body')) {\n // Don’t close dropdown if isOpening or search input is focused\n if (\n !isOpeningRef.current &&\n inputElementRef.current !== eventTarget.ownerDocument.activeElement\n ) {\n closeDropdown();\n }\n return;\n }\n\n // If dropdown has no items and click was within dropdown body, do nothing\n if (!hasItemsRef.current) return;\n\n handleSubmitItem(event);\n };\n\n const handleKeyDown = (event: KeyboardEvent) => {\n const { altKey, ctrlKey, key, metaKey } = event;\n const eventTarget = event.target as HTMLElement;\n if (!dropdownElement) return;\n\n const onEventHandled = () => {\n event.stopPropagation();\n event.preventDefault();\n currentInputMethodRef.current = 'keyboard';\n };\n\n const isEventTargetingDropdown = dropdownElement.contains(eventTarget);\n\n if (!isOpenRef.current) {\n // If dropdown is closed, don’t handle key events if event target isn’t within dropdown\n if (!isEventTargetingDropdown) return;\n // Open the dropdown on spacebar, enter, or if isSearchable and user hits the ↑/↓ arrows\n if (\n key === ' ' ||\n key === 'Enter' ||\n (hasItemsRef.current && (key === 'ArrowUp' || key === 'ArrowDown'))\n ) {\n onEventHandled();\n setIsOpen(true);\n }\n return;\n }\n\n const isTargetUsingKeyEvents = isEventTargetUsingKeyEvent(event);\n\n // If dropdown isOpen + hasItems & eventTargetNotUsingKeyEvents, handle characters\n if (hasItemsRef.current && !isTargetUsingKeyEvents) {\n let isEditingCharacters = !ctrlKey && !metaKey && /^[A-Za-z0-9]$/.test(key);\n // User could also be editing characters if there are already characters entered\n // and they are hitting delete or spacebar\n if (!isEditingCharacters && enteredCharactersRef.current) {\n isEditingCharacters = key === ' ' || key === 'Backspace';\n }\n\n if (isEditingCharacters) {\n onEventHandled();\n if (key === 'Backspace') {\n enteredCharactersRef.current = enteredCharactersRef.current.slice(\n 0,\n -1,\n );\n } else {\n enteredCharactersRef.current += key;\n }\n\n setActiveItem({\n dropdownElement,\n event,\n // If props.allowCreate, only override the input’s value with an\n // exact text match so user can enter a value not in items\n isExactMatch: allowCreateRef.current,\n onActiveItem,\n text: enteredCharactersRef.current,\n });\n\n if (clearEnteredCharactersTimerRef.current != null) {\n clearTimeout(clearEnteredCharactersTimerRef.current);\n }\n\n clearEnteredCharactersTimerRef.current = setTimeout(() => {\n enteredCharactersRef.current = '';\n clearEnteredCharactersTimerRef.current = null;\n }, 1500);\n\n return;\n }\n }\n\n // If dropdown isOpen, handle submitting the value\n if (key === 'Enter' || (key === ' ' && !inputElementRef.current)) {\n onEventHandled();\n handleSubmitItem(event);\n return;\n }\n\n // If dropdown isOpen, handle closing it on escape or spacebar if !hasItems\n if (\n key === 'Escape' ||\n (isEventTargetingDropdown && key === ' ' && !hasItemsRef.current)\n ) {\n // Close dropdown if hasItems or event target not using key events\n if (hasItemsRef.current || !isTargetUsingKeyEvents) {\n closeDropdown();\n }\n return;\n }\n\n // Handle ↑/↓ arrows\n if (hasItemsRef.current) {\n if (key === 'ArrowUp') {\n onEventHandled();\n if (altKey || metaKey) {\n setActiveItem({ dropdownElement, event, index: 0, onActiveItem });\n } else {\n setActiveItem({\n dropdownElement,\n event,\n indexAddend: -1,\n onActiveItem,\n });\n }\n return;\n }\n if (key === 'ArrowDown') {\n onEventHandled();\n if (altKey || metaKey) {\n // Using a negative index counts back from the end\n setActiveItem({ dropdownElement, event, index: -1, onActiveItem });\n } else {\n setActiveItem({\n dropdownElement,\n event,\n indexAddend: 1,\n onActiveItem,\n });\n }\n return;\n }\n }\n };\n\n useKeyboardEvents({ ignoreUsedKeyboardEvents: false, onKeyDown: handleKeyDown });\n\n const handleRef = (ref: HTMLDivElement | null): (() => void) | void => {\n setDropdownElement(ref);\n if (!ref) return;\n\n const { ownerDocument } = ref;\n let inputElement = inputElementRef.current;\n // Check if trigger is a textual input or textarea element\n if (!inputElement && ref.firstElementChild) {\n if (ref.firstElementChild.matches(TEXT_INPUT_SELECTOR)) {\n inputElement = ref.firstElementChild as HTMLInputElement;\n } else {\n inputElement = ref.firstElementChild.querySelector(TEXT_INPUT_SELECTOR);\n }\n inputElementRef.current = inputElement;\n }\n\n const handleGlobalMouseDown = ({ target }: MouseEvent) => {\n const eventTarget = target as HTMLElement;\n if (!ref.contains(eventTarget)) {\n // Close dropdown on an outside click\n closeDropdown();\n }\n };\n\n const handleGlobalMouseUp = ({ target }: MouseEvent) => {\n if (!isOpenRef.current || closingTimerRef.current != null) return;\n\n // If still isOpening (gets set false 1s after open triggers), set it to false onMouseUp\n if (isOpeningRef.current) {\n setIsOpening(false);\n if (isOpeningTimerRef.current != null) {\n clearTimeout(isOpeningTimerRef.current);\n isOpeningTimerRef.current = null;\n }\n return;\n }\n\n const eventTarget = target as HTMLElement;\n // Only handle mouseup events from outside the dropdown here\n if (!ref.contains(eventTarget)) {\n closeDropdown();\n }\n };\n\n // Close dropdown if any element is focused outside of this dropdown\n const handleGlobalFocusIn = ({ target }: Event) => {\n if (!isOpenRef.current) return;\n\n const eventTarget = target as HTMLElement;\n // If focused element is a descendant or a parent of the dropdown, do nothing\n if (ref.contains(eventTarget) || eventTarget.contains(ref)) {\n return;\n }\n\n closeDropdown();\n };\n\n document.addEventListener('focusin', handleGlobalFocusIn);\n document.addEventListener('mousedown', handleGlobalMouseDown);\n document.addEventListener('mouseup', handleGlobalMouseUp);\n\n if (ownerDocument !== document) {\n ownerDocument.addEventListener('focusin', handleGlobalFocusIn);\n ownerDocument.addEventListener('mousedown', handleGlobalMouseDown);\n ownerDocument.addEventListener('mouseup', handleGlobalMouseUp);\n }\n\n // If dropdown should be open on mount, focus it\n if (isOpenOnMount) {\n ref.focus();\n }\n\n const handleInput = (event: Event) => {\n if (!isOpenRef.current) setIsOpen(true);\n\n const input = event.target as HTMLInputElement;\n const isDeleting = enteredCharactersRef.current.length > input.value.length;\n enteredCharactersRef.current = input.value;\n // When deleting text, if there’s already an active item and\n // input isn’t empty, preserve the active item, else update it\n if (isDeleting && input.value.length && getActiveItemElement(ref)) {\n return;\n }\n\n setActiveItem({\n dropdownElement: ref,\n event,\n // If props.allowCreate, only override the input’s value with an\n // exact text match so user can enter a value not in items\n isExactMatch: allowCreateRef.current,\n onActiveItem,\n text: enteredCharactersRef.current,\n });\n };\n\n if (inputElement) {\n inputElement.addEventListener('input', handleInput);\n }\n\n return () => {\n document.removeEventListener('focusin', handleGlobalFocusIn);\n document.removeEventListener('mousedown', handleGlobalMouseDown);\n document.removeEventListener('mouseup', handleGlobalMouseUp);\n\n if (ownerDocument !== document) {\n ownerDocument.removeEventListener('focusin', handleGlobalFocusIn);\n ownerDocument.removeEventListener('mousedown', handleGlobalMouseDown);\n ownerDocument.removeEventListener('mouseup', handleGlobalMouseUp);\n }\n\n if (inputElement) {\n inputElement.removeEventListener('input', handleInput);\n }\n };\n };\n\n if (!isValidElement(trigger)) {\n if (isSearchable) {\n trigger = (\n <input\n autoComplete=\"off\"\n className=\"uktdropdown-trigger\"\n defaultValue={value ?? ''}\n disabled={disabled}\n name={name}\n onFocus={() => setIsOpen(true)}\n placeholder={placeholder}\n ref={inputElementRef}\n tabIndex={tabIndex}\n type=\"text\"\n />\n );\n } else {\n trigger = (\n <button className=\"uktdropdown-trigger\" tabIndex={0} type=\"button\">\n {trigger}\n </button>\n );\n }\n }\n\n if (label != null) {\n trigger = (\n <label className=\"uktdropdown-label\">\n <div className=\"uktdropdown-label-text\">{label}</div>\n {trigger}\n </label>\n );\n }\n\n const style = {\n ...styleFromProps,\n ...(minHeightBody != null && minHeightBody > 0\n ? { '--uktdd-body-min-height': `${minHeightBody}px` }\n : null),\n ...(minWidthBody != null && minWidthBody > 0\n ? { '--uktdd-body-min-width': `${minWidthBody}px` }\n : null),\n };\n\n return (\n <Fragment>\n <style href=\"@acusti/dropdown/Dropdown\" precedence=\"medium\">\n {styles}\n </style>\n <div\n className={clsx('uktdropdown', className, {\n disabled,\n 'is-open': isOpen,\n 'is-searchable': isSearchable,\n })}\n onClick={onClick}\n onMouseDown={handleMouseDown}\n onMouseMove={handleMouseMove}\n onMouseOut={handleMouseOut}\n onMouseOver={handleMouseOver}\n onMouseUp={handleMouseUp}\n ref={handleRef}\n style={style}\n >\n {trigger}\n {/* TODO next version of Dropdown should use <Activity> for body https://react.dev/reference/react/Activity */}\n {isOpen ? (\n <div\n className={clsx('uktdropdown-body', {\n 'has-items': hasItems,\n })}\n >\n <div className=\"uktdropdown-content\">\n {childrenCount > 1\n ? (children as ChildrenTuple)[1]\n : children}\n </div>\n </div>\n ) : null}\n </div>\n </Fragment>\n );\n}\n"],"mappings":";;;;;;;;;;ACKA,IA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A;IAIT,CAAA;GACI,CAAA,GAZP;AAYOmC,IAAA,MAAAnC;AAAAmC,IAAA,MAAAO;AAAAP,IAAA,MAAA7B;AAAA6B,IAAA,MAAAa;AAAAb,IAAA,MAAAiJ;OAAAA,OAAAjJ,EAAA;CAAA,IAAAkJ;AAAA,KAAAlJ,EAAA,QAAAyF,mBAAAzF,EAAA,QAAAsF,kBAAAtF,EAAA,QAAA+E,mBAAA/E,EAAA,QAAA6F,iBAAA7F,EAAA,QAAA8I,aAAA9I,EAAA,QAAApB,WAAAoB,EAAA,QAAAb,SAAAa,EAAA,QAAAgJ,OAAAhJ,EAAA,QAAAiJ,OAAAjJ,EAAA,QAAAY,SAAA;AAjChBsI,QAAA,qBAAC,UAAD,EAAA,UAAA,CACIH,KAGA,qBAAA,OAAA;GACe,WAAAC;GAKFpK;GACI6G,aAAAA;GACAlB,aAAAA;GACDe,YAAAA;GACCP,aAAAA;GACFc,WAAAA;GACNiD,KAAAA;GACE3J;aAbX,CAeKyB,SAEAqI,IAcT;KAAW,EAAA,CAAA;AAAAjJ,IAAA,MAAAyF;AAAAzF,IAAA,MAAAsF;AAAAtF,IAAA,MAAA+E;AAAA/E,IAAA,MAAA6F;AAAA7F,IAAA,MAAA8I;AAAA9I,IAAA,MAAApB;AAAAoB,IAAA,MAAAb;AAAAa,IAAA,MAAAgJ;AAAAhJ,IAAA,MAAAiJ;AAAAjJ,IAAA,MAAAY;AAAAZ,IAAA,MAAAkJ;OAAAA,OAAAlJ,EAAA;AAAA,QAnCXkJ"}
|
|
1
|
+
{"version":3,"file":"Dropdown.js","names":["getBestMatch","SyntheticEvent","Item","ITEM_SELECTOR","getItemElements","dropdownElement","HTMLElement","bodyElement","querySelector","items","HTMLCollection","NodeListOf","Element","querySelectorAll","length","children","getActiveItemElement","clearItemElementsState","itemElements","Array","forEach","itemElement","hasAttribute","dataset","uktActive","BaseSetActiveItemPayload","element","event","Event","index","indexAddend","isExactMatch","onActiveItem","payload","text","setActiveItem","Omit","from","lastIndex","currentActiveIndex","findIndex","nextActiveIndex","Math","max","min","itemTexts","map","innerText","textToCompare","toLowerCase","itemText","startsWith","bestMatch","nextActiveItem","setAttribute","label","value","uktValue","parentElement","scrollableParent","isScrollable","scrollHeight","clientHeight","parentRect","getBoundingClientRect","itemRect","isAboveTop","top","isBelowBottom","bottom","scrollTop","useKeyboardEvents","isEventTargetUsingKeyEvent","clsx","Children","cloneElement","CSSProperties","Fragment","isValidElement","MouseEvent","ReactMouseEvent","ReactElement","ReactNode","SyntheticEvent","useEffect","useId","useRef","useState","styles","getActiveItemElement","getItemElements","ITEM_SELECTOR","setActiveItem","Item","element","MaybeHTMLElement","event","Event","HTMLElement","label","value","Props","allowCreate","allowEmpty","children","ChildrenTuple","className","disabled","group","hasItems","isOpenOnMount","isSearchable","keepOpenOnSubmit","minHeightBody","minWidthBody","name","onActiveItem","payload","onClick","onClose","onMouseDown","onMouseUp","onOpen","onSubmitItem","placeholder","style","tabIndex","MousePosition","clientX","clientY","TimeoutID","ReturnType","setTimeout","CHILDREN_ERROR","CLICKABLE_SELECTOR","TEXT_INPUT_SELECTOR","Dropdown","t0","$","_c","t1","t2","t3","styleFromProps","undefined","childrenCount","count","Error","console","error","trigger","isOpen","setIsOpen","isOpening","setIsOpening","dropdownElement","setDropdownElement","bodyId","popupRole","inputElementRef","closingTimerRef","isOpeningTimerRef","currentInputMethodRef","clearEnteredCharactersTimerRef","enteredCharactersRef","mouseDownPositionRef","allowCreateRef","allowEmptyRef","hasItemsRef","isOpenRef","isOpeningRef","keepOpenOnSubmitRef","onCloseRef","onOpenRef","onSubmitItemRef","valueRef","t4","t5","current","isMountedRef","t6","t7","t8","Symbol","for","clearTimeout","closeDropdown","t9","itemLabel","innerText","ownerDocument","activeElement","blur","nextValue","dataset","uktValue","eventTarget","target","matches","contains","click","clickableElements","querySelectorAll","length","clickableElement","handleSubmitItem","t10","t11","initialPosition","Math","abs","handleMouseMove","event_0","itemElements","eventTarget_0","item","closest","element_0","itemElement","handleMouseOver","t12","event_1","activeItem","eventRelatedTarget","relatedTarget","uktActive","handleMouseOut","t13","event_2","handleMouseDown","t14","event_3","eventTarget_1","handleMouseUp","t15","event_4","altKey","ctrlKey","key","metaKey","eventTarget_2","onEventHandled","stopPropagation","preventDefault","isEventTargetingDropdown","isTargetUsingKeyEvents","isEditingCharacters","test","slice","isExactMatch","text","index","indexAddend","handleKeyDown","t16","ignoreUsedKeyboardEvents","onKeyDown","t17","ref","inputElement","firstElementChild","HTMLInputElement","querySelector","handleGlobalMouseDown","t18","eventTarget_3","handleGlobalMouseUp","t19","target_0","eventTarget_4","handleGlobalFocusIn","t20","target_1","eventTarget_5","document","addEventListener","focus","handleInput","event_5","input","isDeleting","removeEventListener","handleRef","triggerProps","props","Record","t21","t22","t23","t24"],"sources":["../src/Dropdown.css?inline","../src/helpers.ts","../src/Dropdown.tsx"],"sourcesContent":[":root {\n --uktdd-font-family:\n system-ui, Segoe UI, Roboto, Oxygen-Sans, Ubuntu, Cantarell, Helvetica Neue,\n Helvetica, Arial, sans-serif;\n --uktdd-body-bg-color: #fff;\n --uktdd-body-bg-color-hover: rgb(105, 162, 249);\n --uktdd-body-color-hover: #fff;\n --uktdd-body-buffer: 10px;\n --uktdd-body-max-height: calc(100dvh - var(--uktdd-body-buffer));\n --uktdd-body-max-width: calc(100dvw - var(--uktdd-body-buffer));\n --uktdd-body-min-height: 30px;\n --uktdd-body-pad-bottom: 9px;\n --uktdd-body-pad-left: 12px;\n --uktdd-body-pad-right: 12px;\n --uktdd-body-pad-top: 9px;\n --uktdd-body-min-width: min(50px, 100%);\n --uktdd-body-position-area: bottom span-right;\n --uktdd-body-position-try-fallbacks:\n --uktdd-top-left, --uktdd-bottom-right, --uktdd-top-right;\n --uktdd-body-translate: 0 0;\n --uktdd-label-pad-right: 10px;\n}\n\n.uktdropdown,\n.uktdropdown-trigger {\n font-family: var(--uktdd-font-family);\n}\n\n.uktdropdown {\n width: max-content;\n anchor-scope: --uktdd-anchor;\n\n &.disabled {\n pointer-events: none;\n }\n\n > * {\n cursor: default;\n }\n\n > :first-child {\n anchor-name: --uktdd-anchor;\n }\n}\n\n.uktdropdown-label {\n display: flex;\n align-items: center;\n}\n\n.uktdropdown-label-text {\n padding-right: var(--uktdd-label-pad-right);\n}\n\n.uktdropdown-body {\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n position: fixed;\n position-anchor: --uktdd-anchor;\n position-area: var(--uktdd-body-position-area);\n position-try-order: most-height;\n position-try-fallbacks: var(--uktdd-body-position-try-fallbacks);\n min-block-size: min(var(--uktdd-body-min-height), var(--uktdd-body-max-height));\n max-block-size: min(var(--uktdd-body-max-height), 100%);\n min-inline-size: min(var(--uktdd-body-min-width), var(--uktdd-body-max-width));\n max-inline-size: var(--uktdd-body-max-width);\n inline-size: max-content;\n overflow: hidden;\n translate: var(--uktdd-body-translate);\n z-index: 2;\n background-color: var(--uktdd-body-bg-color);\n box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);\n\n &.has-items {\n user-select: none;\n }\n\n [data-ukt-active] {\n background-color: var(--uktdd-body-bg-color-hover);\n color: var(--uktdd-body-color-hover);\n }\n}\n\n.uktdropdown-content {\n box-sizing: border-box;\n min-block-size: 0;\n overflow: auto;\n overscroll-behavior: contain;\n padding: var(--uktdd-body-pad-top) var(--uktdd-body-pad-right)\n var(--uktdd-body-pad-bottom) var(--uktdd-body-pad-left);\n}\n\n@position-try --uktdd-top-left {\n position-area: top span-right;\n}\n\n@position-try --uktdd-bottom-left {\n position-area: bottom span-right;\n}\n\n@position-try --uktdd-bottom-right {\n position-area: bottom span-left;\n}\n\n@position-try --uktdd-top-right {\n position-area: top span-left;\n}\n","import { getBestMatch } from '@acusti/matchmaking';\nimport { type SyntheticEvent } from 'react';\n\nimport { type Item } from './Dropdown.js';\n\nexport const ITEM_SELECTOR = `[data-ukt-item], [data-ukt-value]`;\n\nexport const getItemElements = (dropdownElement: HTMLElement | null) => {\n if (!dropdownElement) return null;\n\n const bodyElement = dropdownElement.querySelector('.uktdropdown-body');\n if (!bodyElement) return null;\n\n let items: HTMLCollection | NodeListOf<Element> =\n bodyElement.querySelectorAll(ITEM_SELECTOR);\n\n if (items.length) return items;\n // If no items found via [data-ukt-item] or [data-ukt-value] selector,\n // use first instance of multiple children found\n items = bodyElement.children;\n while (items.length === 1) {\n if (items[0].children == null) break;\n items = items[0].children;\n }\n // If unable to find an element with more than one child, treat direct child as items\n if (items.length === 1) {\n items = bodyElement.children;\n }\n return items;\n};\n\nexport const getActiveItemElement = (dropdownElement: HTMLElement | null) => {\n if (!dropdownElement) return null;\n return dropdownElement.querySelector('[data-ukt-active]') as HTMLElement | null;\n};\n\nconst clearItemElementsState = (itemElements: Array<HTMLElement>) => {\n itemElements.forEach((itemElement) => {\n if (itemElement.hasAttribute('data-ukt-active')) {\n delete itemElement.dataset.uktActive;\n }\n });\n};\n\ntype BaseSetActiveItemPayload = {\n dropdownElement: HTMLElement;\n element?: null;\n event: Event | SyntheticEvent<HTMLElement>;\n index?: null;\n indexAddend?: null;\n isExactMatch?: null;\n onActiveItem?: (payload: Item) => void;\n text?: null;\n};\n\nexport const setActiveItem = ({\n dropdownElement,\n element,\n event,\n index,\n indexAddend,\n isExactMatch,\n onActiveItem,\n text,\n}:\n | ({\n element: HTMLElement;\n } & Omit<BaseSetActiveItemPayload, 'element'>)\n | ({\n index: number;\n } & Omit<BaseSetActiveItemPayload, 'index'>)\n | ({\n indexAddend: number;\n } & Omit<BaseSetActiveItemPayload, 'indexAddend'>)\n | ({\n isExactMatch?: boolean;\n text: string;\n } & Omit<BaseSetActiveItemPayload, 'isExactMatch' | 'text'>)) => {\n const items = getItemElements(dropdownElement);\n if (!items) return;\n\n const itemElements = Array.from(items) as Array<HTMLElement>;\n if (!itemElements.length) return;\n\n const lastIndex = itemElements.length - 1;\n const currentActiveIndex = itemElements.findIndex((itemElement) =>\n itemElement.hasAttribute('data-ukt-active'),\n );\n\n let nextActiveIndex = currentActiveIndex;\n if (typeof index === 'number') {\n // Negative index means count back from the end\n nextActiveIndex = index < 0 ? itemElements.length + index : index;\n }\n\n if (element) {\n nextActiveIndex = itemElements.findIndex(\n (itemElement) => itemElement === element,\n );\n } else if (typeof indexAddend === 'number') {\n // If there’s no currentActiveIndex and we are handling -1, start at lastIndex\n if (currentActiveIndex === -1 && indexAddend === -1) {\n nextActiveIndex = lastIndex;\n } else {\n nextActiveIndex += indexAddend;\n }\n // Keep it within the bounds of the items list\n nextActiveIndex = Math.max(0, Math.min(nextActiveIndex, lastIndex));\n } else if (typeof text === 'string') {\n // If text is empty, clear existing active items and early return\n if (!text) {\n clearItemElementsState(itemElements);\n return;\n }\n\n const itemTexts = itemElements.map((itemElement) => itemElement.innerText);\n if (isExactMatch) {\n const textToCompare = text.toLowerCase();\n nextActiveIndex = itemTexts.findIndex((itemText) =>\n itemText.toLowerCase().startsWith(textToCompare),\n );\n // If isExactMatch is required and no exact match was found, clear active items\n if (nextActiveIndex === -1) {\n clearItemElementsState(itemElements);\n }\n } else {\n const bestMatch = getBestMatch({ items: itemTexts, text });\n nextActiveIndex = itemTexts.findIndex((itemText) => itemText === bestMatch);\n }\n }\n\n const nextActiveItem = items[nextActiveIndex] as HTMLElement | null;\n if (nextActiveItem == null || nextActiveIndex === currentActiveIndex) return;\n\n // Clear any existing active dropdown body item state\n clearItemElementsState(itemElements);\n nextActiveItem.setAttribute('data-ukt-active', '');\n const label = nextActiveItem.innerText;\n const value = nextActiveItem.dataset.uktValue ?? label;\n onActiveItem?.({ element: nextActiveItem, event, label, value });\n // Find closest scrollable parent and ensure that next active item is visible\n let { parentElement } = nextActiveItem;\n let scrollableParent = null;\n while (!scrollableParent && parentElement && parentElement !== dropdownElement) {\n const isScrollable = parentElement.scrollHeight > parentElement.clientHeight + 15;\n if (isScrollable) {\n scrollableParent = parentElement;\n } else {\n parentElement = parentElement.parentElement;\n }\n }\n\n if (scrollableParent) {\n const parentRect = scrollableParent.getBoundingClientRect();\n const itemRect = nextActiveItem.getBoundingClientRect();\n const isAboveTop = itemRect.top < parentRect.top;\n const isBelowBottom = itemRect.bottom > parentRect.bottom;\n if (isAboveTop || isBelowBottom) {\n let { scrollTop } = scrollableParent;\n // Item isn’t fully visible; adjust scrollTop to put item within closest edge\n if (isAboveTop) {\n scrollTop -= parentRect.top - itemRect.top;\n } else {\n scrollTop += itemRect.bottom - parentRect.bottom;\n }\n scrollableParent.scrollTop = scrollTop;\n }\n }\n};\n","/* eslint-disable jsx-a11y/click-events-have-key-events, jsx-a11y/mouse-events-have-key-events, jsx-a11y/no-static-element-interactions */\nimport useKeyboardEvents, {\n isEventTargetUsingKeyEvent,\n} from '@acusti/use-keyboard-events';\nimport clsx from 'clsx';\nimport {\n Children,\n cloneElement,\n type CSSProperties,\n Fragment,\n isValidElement,\n type MouseEvent as ReactMouseEvent,\n type ReactElement,\n type ReactNode,\n type SyntheticEvent,\n useEffect,\n useId,\n useRef,\n useState,\n} from 'react';\n\nimport styles from './Dropdown.css?inline';\nimport {\n getActiveItemElement,\n getItemElements,\n ITEM_SELECTOR,\n setActiveItem,\n} from './helpers.js';\n\nexport type Item = {\n element: MaybeHTMLElement;\n event: Event | SyntheticEvent<HTMLElement>;\n label: string;\n value: string;\n};\n\nexport type Props = {\n /**\n * Boolean indicating if the user can submit a value not already in the\n * dropdown.\n */\n allowCreate?: boolean;\n /**\n * Boolean indicating if the user can submit an empty value (i.e. clear\n * the value). Defaults to true.\n */\n allowEmpty?: boolean;\n /**\n * Can take a single React element or exactly two renderable children.\n */\n children: ChildrenTuple | ReactElement;\n className?: string;\n disabled?: boolean;\n /**\n * Group identifier string links dropdowns together into a menu\n * (like macOS top menubar).\n */\n group?: string;\n hasItems?: boolean;\n isOpenOnMount?: boolean;\n isSearchable?: boolean;\n keepOpenOnSubmit?: boolean;\n label?: ReactNode;\n minHeightBody?: number;\n minWidthBody?: number;\n /**\n * Only usable in conjunction with {isSearchable: true}.\n * Used as search input’s name.\n */\n name?: string;\n onActiveItem?: (payload: Item) => void;\n onClick?: (event: ReactMouseEvent<HTMLElement>) => unknown;\n onClose?: () => unknown;\n onMouseDown?: (event: ReactMouseEvent<HTMLElement>) => unknown;\n onMouseUp?: (event: ReactMouseEvent<HTMLElement>) => unknown;\n onOpen?: () => unknown;\n onSubmitItem?: (payload: Item) => void;\n /**\n * Only usable in conjunction with {isSearchable: true}.\n * Used as search input’s placeholder.\n */\n placeholder?: string;\n style?: CSSProperties;\n /**\n * Only usable in conjunction with {isSearchable: true}.\n * Used as search input’s tabIndex.\n */\n tabIndex?: number;\n /**\n * Used as search input’s value if props.isSearchable === true\n * Used to determine if value has changed to avoid triggering onSubmitItem if not\n */\n value?: string;\n};\n\ntype ChildrenTuple = [ReactNode, ReactNode] | readonly [ReactNode, ReactNode];\n\ntype MaybeHTMLElement = HTMLElement | null;\n\ntype MousePosition = { clientX: number; clientY: number };\n\ntype TimeoutID = ReturnType<typeof setTimeout>;\n\nconst CHILDREN_ERROR =\n '@acusti/dropdown requires either 1 child (the dropdown body) or 2 children: the dropdown trigger and the dropdown body.';\nconst CLICKABLE_SELECTOR = 'button, a[href], input[type=\"button\"], input[type=\"submit\"]';\nconst TEXT_INPUT_SELECTOR =\n 'input:not([type=radio]):not([type=checkbox]):not([type=range]),textarea';\n\nexport default function Dropdown({\n allowCreate,\n allowEmpty = true,\n children,\n className,\n disabled,\n hasItems = true,\n isOpenOnMount,\n isSearchable,\n keepOpenOnSubmit = !hasItems,\n label,\n minHeightBody,\n minWidthBody,\n name,\n onActiveItem,\n onClick,\n onClose,\n onMouseDown,\n onMouseUp,\n onOpen,\n onSubmitItem,\n placeholder,\n style: styleFromProps,\n tabIndex,\n value,\n}: Props) {\n const childrenCount = Children.count(children);\n if (childrenCount !== 1 && childrenCount !== 2) {\n if (childrenCount === 0) {\n throw new Error(CHILDREN_ERROR + ' Received no children.');\n }\n console.error(`${CHILDREN_ERROR} Received ${childrenCount} children.`);\n }\n\n let trigger: React.ReactNode;\n if (childrenCount > 1) {\n trigger = (children as ChildrenTuple)[0];\n }\n\n const [isOpen, setIsOpen] = useState<boolean>(isOpenOnMount ?? false);\n const [isOpening, setIsOpening] = useState<boolean>(!isOpenOnMount);\n const [dropdownElement, setDropdownElement] = useState<MaybeHTMLElement>(null);\n const bodyId = useId();\n const popupRole = isSearchable ? 'listbox' : hasItems ? 'menu' : 'dialog';\n const inputElementRef = useRef<HTMLInputElement | null>(null);\n const closingTimerRef = useRef<null | TimeoutID>(null);\n const isOpeningTimerRef = useRef<null | TimeoutID>(null);\n const currentInputMethodRef = useRef<'keyboard' | 'mouse'>('mouse');\n const clearEnteredCharactersTimerRef = useRef<null | TimeoutID>(null);\n const enteredCharactersRef = useRef<string>('');\n const mouseDownPositionRef = useRef<MousePosition | null>(null);\n\n const allowCreateRef = useRef(allowCreate);\n const allowEmptyRef = useRef(allowEmpty);\n const hasItemsRef = useRef(hasItems);\n const isOpenRef = useRef(isOpen);\n const isOpeningRef = useRef(isOpening);\n const keepOpenOnSubmitRef = useRef(keepOpenOnSubmit);\n const onCloseRef = useRef(onClose);\n const onOpenRef = useRef(onOpen);\n const onSubmitItemRef = useRef(onSubmitItem);\n const valueRef = useRef(value);\n\n useEffect(() => {\n allowCreateRef.current = allowCreate;\n allowEmptyRef.current = allowEmpty;\n hasItemsRef.current = hasItems;\n isOpenRef.current = isOpen;\n isOpeningRef.current = isOpening;\n keepOpenOnSubmitRef.current = keepOpenOnSubmit;\n onCloseRef.current = onClose;\n onOpenRef.current = onOpen;\n onSubmitItemRef.current = onSubmitItem;\n valueRef.current = value;\n }, [\n allowCreate,\n allowEmpty,\n hasItems,\n isOpen,\n isOpening,\n keepOpenOnSubmit,\n onClose,\n onOpen,\n onSubmitItem,\n value,\n ]);\n\n const isMountedRef = useRef(false);\n\n useEffect(() => {\n if (!isMountedRef.current) {\n isMountedRef.current = true;\n // If isOpenOnMount, trigger onOpen right away\n if (isOpenRef.current && onOpenRef.current) {\n onOpenRef.current();\n }\n return;\n }\n\n if (isOpen && onOpenRef.current) {\n onOpenRef.current();\n } else if (!isOpen && onCloseRef.current) {\n onCloseRef.current();\n }\n }, [isOpen]);\n\n const closeDropdown = () => {\n setIsOpen(false);\n setIsOpening(false);\n mouseDownPositionRef.current = null;\n if (closingTimerRef.current != null) {\n clearTimeout(closingTimerRef.current);\n closingTimerRef.current = null;\n }\n };\n\n const handleSubmitItem = (event: Event | React.SyntheticEvent<HTMLElement>) => {\n if (isOpenRef.current && !keepOpenOnSubmitRef.current) {\n // A short timeout before closing is better UX when user selects an item so dropdown\n // doesn’t close before expected. It also enables using <Link />s in the dropdown body.\n closingTimerRef.current = setTimeout(closeDropdown, 90);\n }\n\n if (!hasItemsRef.current) return;\n\n const element = getActiveItemElement(dropdownElement);\n if (!element && !allowCreateRef.current) {\n // If not allowEmpty, don’t allow submitting an empty item\n if (!allowEmptyRef.current) return;\n // If we have an input element as trigger & the user didn’t clear the text, do nothing\n if (inputElementRef.current?.value) return;\n }\n\n let itemLabel = element?.innerText ?? '';\n if (inputElementRef.current) {\n if (!element) {\n itemLabel = inputElementRef.current.value;\n } else {\n inputElementRef.current.value = itemLabel;\n }\n\n if (\n inputElementRef.current ===\n inputElementRef.current.ownerDocument.activeElement\n ) {\n inputElementRef.current.blur();\n }\n }\n\n const nextValue = element?.dataset.uktValue ?? itemLabel;\n // If parent is controlling Dropdown via props.value and nextValue is the same, do nothing\n if (valueRef.current && valueRef.current === nextValue) return;\n\n // If the item is clickable or contains exactly one clickable element, invoke it\n // (but only if the event didn’t already originate from that element)\n if (element) {\n const eventTarget = event.target as HTMLElement;\n\n if (element.matches(CLICKABLE_SELECTOR)) {\n // The item element itself is clickable (e.g., <button data-ukt-value=\"…\">)\n if (element !== eventTarget && !element.contains(eventTarget)) {\n element.click();\n }\n } else {\n // Check if item contains exactly one clickable child element\n const clickableElements = element.querySelectorAll(CLICKABLE_SELECTOR);\n if (clickableElements.length === 1) {\n const clickableElement = clickableElements[0] as HTMLElement;\n if (\n clickableElement !== eventTarget &&\n !clickableElement.contains(eventTarget)\n ) {\n clickableElement.click();\n }\n }\n }\n }\n\n onSubmitItemRef.current?.({\n element,\n event,\n label: itemLabel,\n value: nextValue,\n });\n };\n\n const handleMouseMove = ({ clientX, clientY }: ReactMouseEvent<HTMLElement>) => {\n currentInputMethodRef.current = 'mouse';\n const initialPosition = mouseDownPositionRef.current;\n if (!initialPosition) return;\n if (\n Math.abs(initialPosition.clientX - clientX) < 12 &&\n Math.abs(initialPosition.clientY - clientY) < 12\n ) {\n return;\n }\n setIsOpening(false);\n };\n\n const handleMouseOver = (event: ReactMouseEvent<HTMLElement>) => {\n if (!hasItemsRef.current) return;\n\n // If user isn’t currently using the mouse to navigate the dropdown, do nothing\n if (currentInputMethodRef.current !== 'mouse') return;\n\n // Ensure we have the dropdown root HTMLElement\n if (!dropdownElement) return;\n\n const itemElements = getItemElements(dropdownElement);\n if (!itemElements) return;\n\n const eventTarget = event.target as HTMLElement;\n const item = eventTarget.closest(ITEM_SELECTOR) as MaybeHTMLElement;\n const element = item ?? eventTarget;\n for (const itemElement of itemElements) {\n if (itemElement === element) {\n setActiveItem({ dropdownElement, element, event, onActiveItem });\n return;\n }\n }\n };\n\n const handleMouseOut = (event: ReactMouseEvent<HTMLElement>) => {\n if (!hasItemsRef.current) return;\n const activeItem = getActiveItemElement(dropdownElement);\n if (!activeItem) return;\n const eventRelatedTarget = event.relatedTarget as HTMLElement;\n if (activeItem !== event.target || activeItem.contains(eventRelatedTarget)) {\n return;\n }\n // If user moused out of activeItem (not into a descendant), it’s no longer active\n delete activeItem.dataset.uktActive;\n };\n\n const handleMouseDown = (event: ReactMouseEvent<HTMLElement>) => {\n if (onMouseDown) onMouseDown(event);\n if (isOpenRef.current) return;\n\n setIsOpen(true);\n setIsOpening(true);\n mouseDownPositionRef.current = {\n clientX: event.clientX,\n clientY: event.clientY,\n };\n isOpeningTimerRef.current = setTimeout(() => {\n setIsOpening(false);\n isOpeningTimerRef.current = null;\n }, 1000);\n };\n\n const handleMouseUp = (event: ReactMouseEvent<HTMLElement>) => {\n if (onMouseUp) onMouseUp(event);\n // If dropdown is still opening or isn’t open or is closing, do nothing\n if (\n isOpeningRef.current ||\n !isOpenRef.current ||\n closingTimerRef.current != null\n ) {\n return;\n }\n\n const eventTarget = event.target as HTMLElement;\n // If click was outside dropdown body, don’t trigger submit\n if (!eventTarget.closest('.uktdropdown-body')) {\n // Don’t close dropdown if isOpening or search input is focused\n if (\n !isOpeningRef.current &&\n inputElementRef.current !== eventTarget.ownerDocument.activeElement\n ) {\n closeDropdown();\n }\n return;\n }\n\n // If dropdown has no items and click was within dropdown body, do nothing\n if (!hasItemsRef.current) return;\n\n handleSubmitItem(event);\n };\n\n const handleKeyDown = (event: KeyboardEvent) => {\n const { altKey, ctrlKey, key, metaKey } = event;\n const eventTarget = event.target as HTMLElement;\n if (!dropdownElement) return;\n\n const onEventHandled = () => {\n event.stopPropagation();\n event.preventDefault();\n currentInputMethodRef.current = 'keyboard';\n };\n\n const isEventTargetingDropdown = dropdownElement.contains(eventTarget);\n\n if (!isOpenRef.current) {\n // If dropdown is closed, don’t handle key events if event target isn’t within dropdown\n if (!isEventTargetingDropdown) return;\n // Open the dropdown on spacebar, enter, or if isSearchable and user hits the ↑/↓ arrows\n if (\n key === ' ' ||\n key === 'Enter' ||\n (hasItemsRef.current && (key === 'ArrowUp' || key === 'ArrowDown'))\n ) {\n onEventHandled();\n setIsOpen(true);\n }\n return;\n }\n\n const isTargetUsingKeyEvents = isEventTargetUsingKeyEvent(event);\n\n // If dropdown isOpen + hasItems & eventTargetNotUsingKeyEvents, handle characters\n if (hasItemsRef.current && !isTargetUsingKeyEvents) {\n let isEditingCharacters = !ctrlKey && !metaKey && /^[A-Za-z0-9]$/.test(key);\n // User could also be editing characters if there are already characters entered\n // and they are hitting delete or spacebar\n if (!isEditingCharacters && enteredCharactersRef.current) {\n isEditingCharacters = key === ' ' || key === 'Backspace';\n }\n\n if (isEditingCharacters) {\n onEventHandled();\n if (key === 'Backspace') {\n enteredCharactersRef.current = enteredCharactersRef.current.slice(\n 0,\n -1,\n );\n } else {\n enteredCharactersRef.current += key;\n }\n\n setActiveItem({\n dropdownElement,\n event,\n // If props.allowCreate, only override the input’s value with an\n // exact text match so user can enter a value not in items\n isExactMatch: allowCreateRef.current,\n onActiveItem,\n text: enteredCharactersRef.current,\n });\n\n if (clearEnteredCharactersTimerRef.current != null) {\n clearTimeout(clearEnteredCharactersTimerRef.current);\n }\n\n clearEnteredCharactersTimerRef.current = setTimeout(() => {\n enteredCharactersRef.current = '';\n clearEnteredCharactersTimerRef.current = null;\n }, 1500);\n\n return;\n }\n }\n\n // If dropdown isOpen, handle submitting the value\n if (key === 'Enter' || (key === ' ' && !inputElementRef.current)) {\n onEventHandled();\n handleSubmitItem(event);\n return;\n }\n\n // If dropdown isOpen, handle closing it on escape or spacebar if !hasItems\n if (\n key === 'Escape' ||\n (isEventTargetingDropdown && key === ' ' && !hasItemsRef.current)\n ) {\n // Close dropdown if hasItems or event target not using key events\n if (hasItemsRef.current || !isTargetUsingKeyEvents) {\n closeDropdown();\n }\n return;\n }\n\n // Handle ↑/↓ arrows\n if (hasItemsRef.current) {\n if (key === 'ArrowUp') {\n onEventHandled();\n if (altKey || metaKey) {\n setActiveItem({ dropdownElement, event, index: 0, onActiveItem });\n } else {\n setActiveItem({\n dropdownElement,\n event,\n indexAddend: -1,\n onActiveItem,\n });\n }\n return;\n }\n if (key === 'ArrowDown') {\n onEventHandled();\n if (altKey || metaKey) {\n // Using a negative index counts back from the end\n setActiveItem({ dropdownElement, event, index: -1, onActiveItem });\n } else {\n setActiveItem({\n dropdownElement,\n event,\n indexAddend: 1,\n onActiveItem,\n });\n }\n return;\n }\n }\n };\n\n useKeyboardEvents({ ignoreUsedKeyboardEvents: false, onKeyDown: handleKeyDown });\n\n const handleRef = (ref: HTMLDivElement | null): (() => void) | void => {\n setDropdownElement(ref);\n if (!ref) return;\n\n const { ownerDocument } = ref;\n let inputElement = inputElementRef.current;\n // Check if trigger is a textual input or textarea element\n if (!inputElement && ref.firstElementChild) {\n if (ref.firstElementChild.matches(TEXT_INPUT_SELECTOR)) {\n inputElement = ref.firstElementChild as HTMLInputElement;\n } else {\n inputElement = ref.firstElementChild.querySelector(TEXT_INPUT_SELECTOR);\n }\n inputElementRef.current = inputElement;\n }\n\n const handleGlobalMouseDown = ({ target }: MouseEvent) => {\n const eventTarget = target as HTMLElement;\n if (!ref.contains(eventTarget)) {\n // Close dropdown on an outside click\n closeDropdown();\n }\n };\n\n const handleGlobalMouseUp = ({ target }: MouseEvent) => {\n if (!isOpenRef.current || closingTimerRef.current != null) return;\n\n // If still isOpening (gets set false 1s after open triggers), set it to false onMouseUp\n if (isOpeningRef.current) {\n setIsOpening(false);\n if (isOpeningTimerRef.current != null) {\n clearTimeout(isOpeningTimerRef.current);\n isOpeningTimerRef.current = null;\n }\n return;\n }\n\n const eventTarget = target as HTMLElement;\n // Only handle mouseup events from outside the dropdown here\n if (!ref.contains(eventTarget)) {\n closeDropdown();\n }\n };\n\n // Close dropdown if any element is focused outside of this dropdown\n const handleGlobalFocusIn = ({ target }: Event) => {\n if (!isOpenRef.current) return;\n\n const eventTarget = target as HTMLElement;\n // If focused element is a descendant or a parent of the dropdown, do nothing\n if (ref.contains(eventTarget) || eventTarget.contains(ref)) {\n return;\n }\n\n closeDropdown();\n };\n\n document.addEventListener('focusin', handleGlobalFocusIn);\n document.addEventListener('mousedown', handleGlobalMouseDown);\n document.addEventListener('mouseup', handleGlobalMouseUp);\n\n if (ownerDocument !== document) {\n ownerDocument.addEventListener('focusin', handleGlobalFocusIn);\n ownerDocument.addEventListener('mousedown', handleGlobalMouseDown);\n ownerDocument.addEventListener('mouseup', handleGlobalMouseUp);\n }\n\n // If dropdown should be open on mount, focus it\n if (isOpenOnMount) {\n ref.focus();\n }\n\n const handleInput = (event: Event) => {\n if (!isOpenRef.current) setIsOpen(true);\n\n const input = event.target as HTMLInputElement;\n const isDeleting = enteredCharactersRef.current.length > input.value.length;\n enteredCharactersRef.current = input.value;\n // When deleting text, if there’s already an active item and\n // input isn’t empty, preserve the active item, else update it\n if (isDeleting && input.value.length && getActiveItemElement(ref)) {\n return;\n }\n\n setActiveItem({\n dropdownElement: ref,\n event,\n // If props.allowCreate, only override the input’s value with an\n // exact text match so user can enter a value not in items\n isExactMatch: allowCreateRef.current,\n onActiveItem,\n text: enteredCharactersRef.current,\n });\n };\n\n if (inputElement) {\n inputElement.addEventListener('input', handleInput);\n }\n\n return () => {\n document.removeEventListener('focusin', handleGlobalFocusIn);\n document.removeEventListener('mousedown', handleGlobalMouseDown);\n document.removeEventListener('mouseup', handleGlobalMouseUp);\n\n if (ownerDocument !== document) {\n ownerDocument.removeEventListener('focusin', handleGlobalFocusIn);\n ownerDocument.removeEventListener('mousedown', handleGlobalMouseDown);\n ownerDocument.removeEventListener('mouseup', handleGlobalMouseUp);\n }\n\n if (inputElement) {\n inputElement.removeEventListener('input', handleInput);\n }\n };\n };\n\n if (!isValidElement(trigger)) {\n if (isSearchable) {\n trigger = (\n <input\n aria-controls={bodyId}\n aria-expanded={isOpen}\n aria-haspopup={popupRole}\n autoComplete=\"off\"\n className=\"uktdropdown-trigger\"\n defaultValue={value ?? ''}\n disabled={disabled}\n name={name}\n onFocus={() => setIsOpen(true)}\n placeholder={placeholder}\n ref={inputElementRef}\n tabIndex={tabIndex}\n type=\"text\"\n />\n );\n } else {\n trigger = (\n <button\n aria-controls={bodyId}\n aria-expanded={isOpen}\n aria-haspopup={popupRole}\n className=\"uktdropdown-trigger\"\n tabIndex={0}\n type=\"button\"\n >\n {trigger}\n </button>\n );\n }\n } else {\n // For a consumer-provided trigger, add ARIA props (letting the consumer\n // override by specifying their own).\n const triggerProps = trigger.props as Record<string, unknown>;\n trigger = cloneElement(trigger as ReactElement<Record<string, unknown>>, {\n 'aria-controls': triggerProps['aria-controls'] ?? bodyId,\n 'aria-expanded': triggerProps['aria-expanded'] ?? isOpen,\n 'aria-haspopup': triggerProps['aria-haspopup'] ?? popupRole,\n });\n }\n\n if (label != null) {\n trigger = (\n <label className=\"uktdropdown-label\">\n <div className=\"uktdropdown-label-text\">{label}</div>\n {trigger}\n </label>\n );\n }\n\n const style = {\n ...styleFromProps,\n ...(minHeightBody != null && minHeightBody > 0\n ? { '--uktdd-body-min-height': `${minHeightBody}px` }\n : null),\n ...(minWidthBody != null && minWidthBody > 0\n ? { '--uktdd-body-min-width': `${minWidthBody}px` }\n : null),\n };\n\n return (\n <Fragment>\n <style href=\"@acusti/dropdown/Dropdown\" precedence=\"medium\">\n {styles}\n </style>\n <div\n className={clsx('uktdropdown', className, {\n disabled,\n 'is-open': isOpen,\n 'is-searchable': isSearchable,\n })}\n onClick={onClick}\n onMouseDown={handleMouseDown}\n onMouseMove={handleMouseMove}\n onMouseOut={handleMouseOut}\n onMouseOver={handleMouseOver}\n onMouseUp={handleMouseUp}\n ref={handleRef}\n style={style}\n >\n {trigger}\n {/* TODO next version of Dropdown should use <Activity> for body https://react.dev/reference/react/Activity */}\n {isOpen ? (\n <div\n className={clsx('uktdropdown-body', {\n 'has-items': hasItems,\n })}\n id={bodyId}\n role={popupRole}\n >\n <div className=\"uktdropdown-content\">\n {childrenCount > 1\n ? (children as ChildrenTuple)[1]\n : children}\n </div>\n </div>\n ) : null}\n </div>\n </Fragment>\n );\n}\n"],"mappings":";;;;;;;;;;ACKA,IAAaG,gBAAgB;AAE7B,IAAaC,mBAAmBC,oBAAwC;AACpE,KAAI,CAACA,gBAAiB,QAAO;CAE7B,MAAME,cAAcF,gBAAgBG,cAAc,oBAAoB;AACtE,KAAI,CAACD,YAAa,QAAO;CAEzB,IAAIE,QACAF,YAAYM,iBAAiBV,cAAc;AAE/C,KAAIM,MAAMK,OAAQ,QAAOL;AAGzBA,SAAQF,YAAYQ;AACpB,QAAON,MAAMK,WAAW,GAAG;AACvB,MAAIL,MAAM,GAAGM,YAAY,KAAM;AAC/BN,UAAQA,MAAM,GAAGM;;AAGrB,KAAIN,MAAMK,WAAW,EACjBL,SAAQF,YAAYQ;AAExB,QAA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