@acusti/dropdown 1.0.0-alpha.1 → 1.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -2
- package/dist/Dropdown.js +172 -153
- package/dist/Dropdown.js.map +1 -1
- package/dist/context.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -766,8 +766,16 @@ Menubar behaviors:
|
|
|
766
766
|
|
|
767
767
|
- renders `role="menubar"`; each dropdown trigger is a menubar item
|
|
768
768
|
- at most one menu in the bar is open at a time
|
|
769
|
-
-
|
|
770
|
-
|
|
769
|
+
- opening a trigger’s menu (by click or keyboard) engages the bar
|
|
770
|
+
(menu-mode). While engaged, hovering or focusing another trigger switches
|
|
771
|
+
to that menu without a click, matching the macOS menu bar
|
|
772
|
+
- while engaged, hovering a non-menu control in the bar (e.g. a plain
|
|
773
|
+
button placed alongside the dropdowns) closes the open menu but keeps the
|
|
774
|
+
bar engaged, so hovering back onto a trigger reopens a menu; sliding
|
|
775
|
+
across the gaps between triggers leaves the open menu alone
|
|
776
|
+
- a deliberate dismissal — **Escape**, a click outside the bar, or
|
|
777
|
+
selecting an item — leaves menu-mode, after which hovering a trigger no
|
|
778
|
+
longer opens its menu until a menu is opened again to re-engage the bar
|
|
771
779
|
- **←/→** move between menus, wrapping at the ends: with the bar focused
|
|
772
780
|
they move focus between triggers, and while a menu is open they slide the
|
|
773
781
|
open menu to the adjacent trigger — unless the active item is a parent
|
package/dist/Dropdown.js
CHANGED
|
@@ -225,6 +225,7 @@ var compareDocumentOrder = (a, b) => {
|
|
|
225
225
|
if ((position & Node.DOCUMENT_POSITION_PRECEDING) !== 0) return 1;
|
|
226
226
|
return 0;
|
|
227
227
|
};
|
|
228
|
+
var NON_MENU_CONTROL_SELECTOR = "a[href], button, input, select, textarea, [tabindex]";
|
|
228
229
|
function Menubar(t0) {
|
|
229
230
|
const $ = c(15);
|
|
230
231
|
const { children, className, style } = t0;
|
|
@@ -234,6 +235,7 @@ function Menubar(t0) {
|
|
|
234
235
|
$[0] = t1;
|
|
235
236
|
} else t1 = $[0];
|
|
236
237
|
const membersRef = useRef(t1);
|
|
238
|
+
const engagedMemberRef = useRef(null);
|
|
237
239
|
let t2;
|
|
238
240
|
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
239
241
|
t2 = () => Array.from(membersRef.current).sort(compareDocumentOrder);
|
|
@@ -254,8 +256,12 @@ function Menubar(t0) {
|
|
|
254
256
|
members[nextIndex].open();
|
|
255
257
|
members[nextIndex].focusTrigger();
|
|
256
258
|
},
|
|
257
|
-
|
|
258
|
-
|
|
259
|
+
notifyClosed(element) {
|
|
260
|
+
if (engagedMemberRef.current === element) engagedMemberRef.current = null;
|
|
261
|
+
},
|
|
262
|
+
notifyOpened(element_0) {
|
|
263
|
+
engagedMemberRef.current = element_0;
|
|
264
|
+
for (const member_0 of membersRef.current) if (member_0.element !== element_0 && member_0.isOpen()) member_0.close();
|
|
259
265
|
},
|
|
260
266
|
registerMember(member_1) {
|
|
261
267
|
membersRef.current.add(member_1);
|
|
@@ -288,11 +294,19 @@ function Menubar(t0) {
|
|
|
288
294
|
let t5;
|
|
289
295
|
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
290
296
|
t5 = (eventTarget_0) => {
|
|
297
|
+
if (engagedMemberRef.current == null) return;
|
|
291
298
|
const members_1 = getOrderedMembers();
|
|
292
|
-
if (!members_1.some(
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
299
|
+
if (!members_1.some((m) => m.element === engagedMemberRef.current)) {
|
|
300
|
+
engagedMemberRef.current = null;
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
const member_4 = members_1.find((m_0) => m_0.element.contains(eventTarget_0));
|
|
304
|
+
if (member_4) {
|
|
305
|
+
if (!member_4.isOpen()) member_4.open();
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
if (!eventTarget_0.closest(NON_MENU_CONTROL_SELECTOR)) return;
|
|
309
|
+
for (const openMember of members_1) if (openMember.isOpen()) openMember.close();
|
|
296
310
|
};
|
|
297
311
|
$[4] = t5;
|
|
298
312
|
} else t5 = $[4];
|
|
@@ -346,9 +360,6 @@ function Menubar(t0) {
|
|
|
346
360
|
} else t10 = $[14];
|
|
347
361
|
return t10;
|
|
348
362
|
}
|
|
349
|
-
function _temp2(member_4) {
|
|
350
|
-
return member_4.isOpen();
|
|
351
|
-
}
|
|
352
363
|
function _temp$1(member_2) {
|
|
353
364
|
return member_2.isOpen();
|
|
354
365
|
}
|
|
@@ -385,7 +396,7 @@ function Dropdown(props) {
|
|
|
385
396
|
return t0;
|
|
386
397
|
}
|
|
387
398
|
function RootDropdown(t0) {
|
|
388
|
-
const $ = c(
|
|
399
|
+
const $ = c(137);
|
|
389
400
|
const { allowCreate, allowEmpty: t1, children, className, disabled, hasItems: t2, isOpenOnMount, isSearchable, keepOpenOnSubmit: t3, label, name, onActiveItem, onClick, onClose, onMouseDown, onMouseUp, onOpen, onSubmitItem, placeholder, style: styleFromProps, tabIndex, value } = t0;
|
|
390
401
|
const allowEmpty = t1 === void 0 ? true : t1;
|
|
391
402
|
const hasItems = t2 === void 0 ? true : t2;
|
|
@@ -699,8 +710,8 @@ function RootDropdown(t0) {
|
|
|
699
710
|
} else t22 = $[36];
|
|
700
711
|
const trackSafeArea = t22;
|
|
701
712
|
let t23;
|
|
702
|
-
if ($[37]
|
|
703
|
-
t23 = () => {
|
|
713
|
+
if ($[37] !== dropdownElement || $[38] !== menubar) {
|
|
714
|
+
t23 = (options) => {
|
|
704
715
|
setIsOpen(false);
|
|
705
716
|
setIsOpening(false);
|
|
706
717
|
mouseDownPositionRef.current = null;
|
|
@@ -712,42 +723,46 @@ function RootDropdown(t0) {
|
|
|
712
723
|
clearTimeout(closingTimerRef.current);
|
|
713
724
|
closingTimerRef.current = null;
|
|
714
725
|
}
|
|
726
|
+
if (menubar && dropdownElement && !options?.keepMenubarEngaged) menubar.notifyClosed(dropdownElement);
|
|
715
727
|
};
|
|
716
|
-
$[37] =
|
|
717
|
-
|
|
728
|
+
$[37] = dropdownElement;
|
|
729
|
+
$[38] = menubar;
|
|
730
|
+
$[39] = t23;
|
|
731
|
+
} else t23 = $[39];
|
|
718
732
|
const closeDropdown = t23;
|
|
719
733
|
let t24;
|
|
720
|
-
if ($[
|
|
734
|
+
if ($[40] !== dropdownElement?.firstElementChild) {
|
|
721
735
|
t24 = () => {
|
|
722
736
|
const firstChild = dropdownElement?.firstElementChild;
|
|
723
737
|
if (!firstChild) return;
|
|
724
738
|
(firstChild.matches(FOCUSABLE_SELECTOR) ? firstChild : firstChild.querySelector(FOCUSABLE_SELECTOR))?.focus();
|
|
725
739
|
};
|
|
726
|
-
$[
|
|
727
|
-
$[
|
|
728
|
-
} else t24 = $[
|
|
740
|
+
$[40] = dropdownElement?.firstElementChild;
|
|
741
|
+
$[41] = t24;
|
|
742
|
+
} else t24 = $[41];
|
|
729
743
|
const focusTrigger = t24;
|
|
730
744
|
let t25;
|
|
731
|
-
if ($[
|
|
745
|
+
if ($[42] !== closeDropdown || $[43] !== dropdownElement || $[44] !== focusTrigger || $[45] !== menubar) {
|
|
732
746
|
t25 = () => {
|
|
733
747
|
if (!menubar || !dropdownElement) return;
|
|
734
748
|
return menubar.registerMember({
|
|
735
|
-
close: closeDropdown,
|
|
749
|
+
close: () => closeDropdown({ keepMenubarEngaged: true }),
|
|
736
750
|
element: dropdownElement,
|
|
737
751
|
focusTrigger,
|
|
738
752
|
isOpen: () => isOpenRef.current,
|
|
739
753
|
open: () => setIsOpen(true)
|
|
740
754
|
});
|
|
741
755
|
};
|
|
742
|
-
$[
|
|
743
|
-
$[
|
|
744
|
-
$[
|
|
745
|
-
$[
|
|
746
|
-
|
|
756
|
+
$[42] = closeDropdown;
|
|
757
|
+
$[43] = dropdownElement;
|
|
758
|
+
$[44] = focusTrigger;
|
|
759
|
+
$[45] = menubar;
|
|
760
|
+
$[46] = t25;
|
|
761
|
+
} else t25 = $[46];
|
|
747
762
|
useEffect(t25);
|
|
748
763
|
let t26;
|
|
749
764
|
let t27;
|
|
750
|
-
if ($[
|
|
765
|
+
if ($[47] !== dropdownElement || $[48] !== isOpen || $[49] !== menubar) {
|
|
751
766
|
t26 = () => {
|
|
752
767
|
if (isOpen && menubar && dropdownElement) menubar.notifyOpened(dropdownElement);
|
|
753
768
|
};
|
|
@@ -756,18 +771,18 @@ function RootDropdown(t0) {
|
|
|
756
771
|
isOpen,
|
|
757
772
|
menubar
|
|
758
773
|
];
|
|
759
|
-
$[
|
|
760
|
-
$[
|
|
761
|
-
$[
|
|
762
|
-
$[
|
|
763
|
-
$[
|
|
774
|
+
$[47] = dropdownElement;
|
|
775
|
+
$[48] = isOpen;
|
|
776
|
+
$[49] = menubar;
|
|
777
|
+
$[50] = t26;
|
|
778
|
+
$[51] = t27;
|
|
764
779
|
} else {
|
|
765
|
-
t26 = $[
|
|
766
|
-
t27 = $[
|
|
780
|
+
t26 = $[50];
|
|
781
|
+
t27 = $[51];
|
|
767
782
|
}
|
|
768
783
|
useEffect(t26, t27);
|
|
769
784
|
let t28;
|
|
770
|
-
if ($[
|
|
785
|
+
if ($[52] !== closeDropdown || $[53] !== dropdownElement || $[54] !== handleActiveItem) {
|
|
771
786
|
t28 = (event_1) => {
|
|
772
787
|
const element = hasItemsRef.current ? getActiveItemElement(dropdownElement) : null;
|
|
773
788
|
const submenuOfActive = element ? getSubmenuOfItem(element) : null;
|
|
@@ -823,13 +838,14 @@ function RootDropdown(t0) {
|
|
|
823
838
|
onSubmitItemRef.current?.(payload_1);
|
|
824
839
|
dispatchToSubmenus("onSubmitItem", payload_1);
|
|
825
840
|
};
|
|
826
|
-
$[
|
|
827
|
-
$[
|
|
828
|
-
$[
|
|
829
|
-
|
|
841
|
+
$[52] = closeDropdown;
|
|
842
|
+
$[53] = dropdownElement;
|
|
843
|
+
$[54] = handleActiveItem;
|
|
844
|
+
$[55] = t28;
|
|
845
|
+
} else t28 = $[55];
|
|
830
846
|
const handleSubmitItem = t28;
|
|
831
847
|
let t29;
|
|
832
|
-
if ($[
|
|
848
|
+
if ($[56] !== trackSafeArea) {
|
|
833
849
|
t29 = (event_2) => {
|
|
834
850
|
const { clientX, clientY } = event_2;
|
|
835
851
|
currentInputMethodRef.current = "mouse";
|
|
@@ -839,12 +855,12 @@ function RootDropdown(t0) {
|
|
|
839
855
|
if (Math.abs(initialPosition.clientX - clientX) < 12 && Math.abs(initialPosition.clientY - clientY) < 12) return;
|
|
840
856
|
setIsOpening(false);
|
|
841
857
|
};
|
|
842
|
-
$[
|
|
843
|
-
$[
|
|
844
|
-
} else t29 = $[
|
|
858
|
+
$[56] = trackSafeArea;
|
|
859
|
+
$[57] = t29;
|
|
860
|
+
} else t29 = $[57];
|
|
845
861
|
const handleMouseMove = t29;
|
|
846
862
|
let t30;
|
|
847
|
-
if ($[
|
|
863
|
+
if ($[58] !== dropdownElement || $[59] !== handleActiveItem || $[60] !== syncSubmenuDisclosure) {
|
|
848
864
|
t30 = (event_3) => {
|
|
849
865
|
if (!hasItemsRef.current) return;
|
|
850
866
|
if (currentInputMethodRef.current !== "mouse") return;
|
|
@@ -864,14 +880,14 @@ function RootDropdown(t0) {
|
|
|
864
880
|
});
|
|
865
881
|
syncSubmenuDisclosure();
|
|
866
882
|
};
|
|
867
|
-
$[
|
|
868
|
-
$[
|
|
869
|
-
$[
|
|
870
|
-
$[
|
|
871
|
-
} else t30 = $[
|
|
883
|
+
$[58] = dropdownElement;
|
|
884
|
+
$[59] = handleActiveItem;
|
|
885
|
+
$[60] = syncSubmenuDisclosure;
|
|
886
|
+
$[61] = t30;
|
|
887
|
+
} else t30 = $[61];
|
|
872
888
|
const handleMouseOver = t30;
|
|
873
889
|
let t31;
|
|
874
|
-
if ($[
|
|
890
|
+
if ($[62] !== dropdownElement || $[63] !== syncSubmenuDisclosure) {
|
|
875
891
|
t31 = (event_4) => {
|
|
876
892
|
if (!hasItemsRef.current) return;
|
|
877
893
|
const relatedTarget = event_4.relatedTarget;
|
|
@@ -888,13 +904,13 @@ function RootDropdown(t0) {
|
|
|
888
904
|
delete activeItem.dataset.uktActive;
|
|
889
905
|
syncSubmenuDisclosure();
|
|
890
906
|
};
|
|
891
|
-
$[
|
|
892
|
-
$[
|
|
893
|
-
$[
|
|
894
|
-
} else t31 = $[
|
|
907
|
+
$[62] = dropdownElement;
|
|
908
|
+
$[63] = syncSubmenuDisclosure;
|
|
909
|
+
$[64] = t31;
|
|
910
|
+
} else t31 = $[64];
|
|
895
911
|
const handleMouseOut = t31;
|
|
896
912
|
let t32;
|
|
897
|
-
if ($[
|
|
913
|
+
if ($[65] !== onMouseDown) {
|
|
898
914
|
t32 = (event_5) => {
|
|
899
915
|
if (onMouseDown) onMouseDown(event_5);
|
|
900
916
|
if (isOpenRef.current) return;
|
|
@@ -909,12 +925,12 @@ function RootDropdown(t0) {
|
|
|
909
925
|
isOpeningTimerRef.current = null;
|
|
910
926
|
}, 1e3);
|
|
911
927
|
};
|
|
912
|
-
$[
|
|
913
|
-
$[
|
|
914
|
-
} else t32 = $[
|
|
928
|
+
$[65] = onMouseDown;
|
|
929
|
+
$[66] = t32;
|
|
930
|
+
} else t32 = $[66];
|
|
915
931
|
const handleMouseDown = t32;
|
|
916
932
|
let t33;
|
|
917
|
-
if ($[
|
|
933
|
+
if ($[67] !== closeDropdown || $[68] !== dropdownElement || $[69] !== handleActiveItem || $[70] !== handleSubmitItem || $[71] !== onMouseUp) {
|
|
918
934
|
t33 = (event_6) => {
|
|
919
935
|
if (onMouseUp) onMouseUp(event_6);
|
|
920
936
|
if (isOpeningRef.current || !isOpenRef.current || closingTimerRef.current != null) return;
|
|
@@ -939,15 +955,16 @@ function RootDropdown(t0) {
|
|
|
939
955
|
}
|
|
940
956
|
handleSubmitItem(event_6);
|
|
941
957
|
};
|
|
942
|
-
$[
|
|
943
|
-
$[
|
|
944
|
-
$[
|
|
945
|
-
$[
|
|
946
|
-
$[
|
|
947
|
-
|
|
958
|
+
$[67] = closeDropdown;
|
|
959
|
+
$[68] = dropdownElement;
|
|
960
|
+
$[69] = handleActiveItem;
|
|
961
|
+
$[70] = handleSubmitItem;
|
|
962
|
+
$[71] = onMouseUp;
|
|
963
|
+
$[72] = t33;
|
|
964
|
+
} else t33 = $[72];
|
|
948
965
|
const handleMouseUp = t33;
|
|
949
966
|
let t34;
|
|
950
|
-
if ($[
|
|
967
|
+
if ($[73] !== closeDropdown || $[74] !== dropdownElement || $[75] !== focusTrigger || $[76] !== handleActiveItem || $[77] !== handleSubmitItem || $[78] !== menubar || $[79] !== syncSubmenuDisclosure) {
|
|
951
968
|
t34 = (event_7) => {
|
|
952
969
|
const { altKey, ctrlKey, key: key_0, metaKey } = event_7;
|
|
953
970
|
const eventTarget_2 = event_7.target;
|
|
@@ -1081,27 +1098,28 @@ function RootDropdown(t0) {
|
|
|
1081
1098
|
}
|
|
1082
1099
|
}
|
|
1083
1100
|
};
|
|
1084
|
-
$[
|
|
1085
|
-
$[
|
|
1086
|
-
$[
|
|
1087
|
-
$[
|
|
1088
|
-
$[
|
|
1089
|
-
$[
|
|
1090
|
-
$[
|
|
1091
|
-
|
|
1101
|
+
$[73] = closeDropdown;
|
|
1102
|
+
$[74] = dropdownElement;
|
|
1103
|
+
$[75] = focusTrigger;
|
|
1104
|
+
$[76] = handleActiveItem;
|
|
1105
|
+
$[77] = handleSubmitItem;
|
|
1106
|
+
$[78] = menubar;
|
|
1107
|
+
$[79] = syncSubmenuDisclosure;
|
|
1108
|
+
$[80] = t34;
|
|
1109
|
+
} else t34 = $[80];
|
|
1092
1110
|
const handleKeyDown = t34;
|
|
1093
1111
|
let t35;
|
|
1094
|
-
if ($[
|
|
1112
|
+
if ($[81] !== handleKeyDown) {
|
|
1095
1113
|
t35 = {
|
|
1096
1114
|
ignoreUsedKeyboardEvents: false,
|
|
1097
1115
|
onKeyDown: handleKeyDown
|
|
1098
1116
|
};
|
|
1099
|
-
$[
|
|
1100
|
-
$[
|
|
1101
|
-
} else t35 = $[
|
|
1117
|
+
$[81] = handleKeyDown;
|
|
1118
|
+
$[82] = t35;
|
|
1119
|
+
} else t35 = $[82];
|
|
1102
1120
|
useKeyboardEvents(t35);
|
|
1103
1121
|
let t36;
|
|
1104
|
-
if ($[
|
|
1122
|
+
if ($[83] !== closeDropdown || $[84] !== handleActiveItem || $[85] !== isOpenOnMount) {
|
|
1105
1123
|
t36 = (ref) => {
|
|
1106
1124
|
setDropdownElement(ref);
|
|
1107
1125
|
if (!ref) return;
|
|
@@ -1136,7 +1154,7 @@ function RootDropdown(t0) {
|
|
|
1136
1154
|
if (!isOpenRef.current) return;
|
|
1137
1155
|
const eventTarget_5 = target_3;
|
|
1138
1156
|
if (ref.contains(eventTarget_5) || eventTarget_5.contains(ref)) return;
|
|
1139
|
-
closeDropdown();
|
|
1157
|
+
closeDropdown({ keepMenubarEngaged: true });
|
|
1140
1158
|
};
|
|
1141
1159
|
document.addEventListener("focusin", handleGlobalFocusIn);
|
|
1142
1160
|
document.addEventListener("mousedown", handleGlobalMouseDown);
|
|
@@ -1174,21 +1192,22 @@ function RootDropdown(t0) {
|
|
|
1174
1192
|
if (inputElement) inputElement.removeEventListener("input", handleInput);
|
|
1175
1193
|
};
|
|
1176
1194
|
};
|
|
1177
|
-
$[
|
|
1178
|
-
$[
|
|
1179
|
-
$[
|
|
1180
|
-
|
|
1195
|
+
$[83] = closeDropdown;
|
|
1196
|
+
$[84] = handleActiveItem;
|
|
1197
|
+
$[85] = isOpenOnMount;
|
|
1198
|
+
$[86] = t36;
|
|
1199
|
+
} else t36 = $[86];
|
|
1181
1200
|
const handleRef = t36;
|
|
1182
1201
|
const handleBodyRef = _temp;
|
|
1183
1202
|
if (!isValidElement(trigger)) if (isSearchable) {
|
|
1184
1203
|
const t37 = value ?? "";
|
|
1185
1204
|
let t38;
|
|
1186
|
-
if ($[
|
|
1205
|
+
if ($[87] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1187
1206
|
t38 = () => setIsOpen(true);
|
|
1188
|
-
$[
|
|
1189
|
-
} else t38 = $[
|
|
1207
|
+
$[87] = t38;
|
|
1208
|
+
} else t38 = $[87];
|
|
1190
1209
|
let t39;
|
|
1191
|
-
if ($[
|
|
1210
|
+
if ($[88] !== bodyId || $[89] !== disabled || $[90] !== isOpen || $[91] !== name || $[92] !== placeholder || $[93] !== popupRole || $[94] !== t37 || $[95] !== tabIndex) {
|
|
1192
1211
|
t39 = /* @__PURE__ */ jsx("input", {
|
|
1193
1212
|
"aria-controls": bodyId,
|
|
1194
1213
|
"aria-expanded": isOpen,
|
|
@@ -1204,20 +1223,20 @@ function RootDropdown(t0) {
|
|
|
1204
1223
|
tabIndex,
|
|
1205
1224
|
type: "text"
|
|
1206
1225
|
});
|
|
1207
|
-
$[
|
|
1208
|
-
$[
|
|
1209
|
-
$[
|
|
1210
|
-
$[
|
|
1211
|
-
$[
|
|
1212
|
-
$[
|
|
1213
|
-
$[
|
|
1214
|
-
$[
|
|
1215
|
-
$[
|
|
1216
|
-
} else t39 = $[
|
|
1226
|
+
$[88] = bodyId;
|
|
1227
|
+
$[89] = disabled;
|
|
1228
|
+
$[90] = isOpen;
|
|
1229
|
+
$[91] = name;
|
|
1230
|
+
$[92] = placeholder;
|
|
1231
|
+
$[93] = popupRole;
|
|
1232
|
+
$[94] = t37;
|
|
1233
|
+
$[95] = tabIndex;
|
|
1234
|
+
$[96] = t39;
|
|
1235
|
+
} else t39 = $[96];
|
|
1217
1236
|
trigger = t39;
|
|
1218
1237
|
} else {
|
|
1219
1238
|
let t37;
|
|
1220
|
-
if ($[
|
|
1239
|
+
if ($[97] !== bodyId || $[98] !== isOpen || $[99] !== popupRole || $[100] !== trigger) {
|
|
1221
1240
|
t37 = /* @__PURE__ */ jsx("button", {
|
|
1222
1241
|
"aria-controls": bodyId,
|
|
1223
1242
|
"aria-expanded": isOpen,
|
|
@@ -1227,12 +1246,12 @@ function RootDropdown(t0) {
|
|
|
1227
1246
|
type: "button",
|
|
1228
1247
|
children: trigger
|
|
1229
1248
|
});
|
|
1230
|
-
$[
|
|
1231
|
-
$[
|
|
1232
|
-
$[
|
|
1233
|
-
$[
|
|
1234
|
-
$[
|
|
1235
|
-
} else t37 = $[
|
|
1249
|
+
$[97] = bodyId;
|
|
1250
|
+
$[98] = isOpen;
|
|
1251
|
+
$[99] = popupRole;
|
|
1252
|
+
$[100] = trigger;
|
|
1253
|
+
$[101] = t37;
|
|
1254
|
+
} else t37 = $[101];
|
|
1236
1255
|
trigger = t37;
|
|
1237
1256
|
}
|
|
1238
1257
|
else {
|
|
@@ -1242,66 +1261,66 @@ function RootDropdown(t0) {
|
|
|
1242
1261
|
const t39 = triggerProps["aria-expanded"] ?? isOpen;
|
|
1243
1262
|
const t40 = triggerProps["aria-haspopup"] ?? popupRole;
|
|
1244
1263
|
let t41;
|
|
1245
|
-
if ($[
|
|
1264
|
+
if ($[102] !== t37 || $[103] !== t38 || $[104] !== t39 || $[105] !== t40) {
|
|
1246
1265
|
t41 = cloneElement(t37, {
|
|
1247
1266
|
"aria-controls": t38,
|
|
1248
1267
|
"aria-expanded": t39,
|
|
1249
1268
|
"aria-haspopup": t40
|
|
1250
1269
|
});
|
|
1251
|
-
$[
|
|
1252
|
-
$[
|
|
1253
|
-
$[
|
|
1254
|
-
$[
|
|
1255
|
-
$[
|
|
1256
|
-
} else t41 = $[
|
|
1270
|
+
$[102] = t37;
|
|
1271
|
+
$[103] = t38;
|
|
1272
|
+
$[104] = t39;
|
|
1273
|
+
$[105] = t40;
|
|
1274
|
+
$[106] = t41;
|
|
1275
|
+
} else t41 = $[106];
|
|
1257
1276
|
trigger = t41;
|
|
1258
1277
|
}
|
|
1259
1278
|
if (label != null) {
|
|
1260
1279
|
let t37;
|
|
1261
|
-
if ($[
|
|
1280
|
+
if ($[107] !== label) {
|
|
1262
1281
|
t37 = /* @__PURE__ */ jsx("div", {
|
|
1263
1282
|
className: "uktdropdown-label-text",
|
|
1264
1283
|
children: label
|
|
1265
1284
|
});
|
|
1266
|
-
$[
|
|
1267
|
-
$[
|
|
1268
|
-
} else t37 = $[
|
|
1285
|
+
$[107] = label;
|
|
1286
|
+
$[108] = t37;
|
|
1287
|
+
} else t37 = $[108];
|
|
1269
1288
|
let t38;
|
|
1270
|
-
if ($[
|
|
1289
|
+
if ($[109] !== t37 || $[110] !== trigger) {
|
|
1271
1290
|
t38 = /* @__PURE__ */ jsxs("label", {
|
|
1272
1291
|
className: "uktdropdown-label",
|
|
1273
1292
|
children: [t37, trigger]
|
|
1274
1293
|
});
|
|
1275
|
-
$[
|
|
1276
|
-
$[
|
|
1277
|
-
$[
|
|
1278
|
-
} else t38 = $[
|
|
1294
|
+
$[109] = t37;
|
|
1295
|
+
$[110] = trigger;
|
|
1296
|
+
$[111] = t38;
|
|
1297
|
+
} else t38 = $[111];
|
|
1279
1298
|
trigger = t38;
|
|
1280
1299
|
}
|
|
1281
1300
|
let t37;
|
|
1282
|
-
if ($[
|
|
1301
|
+
if ($[112] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1283
1302
|
t37 = /* @__PURE__ */ jsx("style", {
|
|
1284
1303
|
href: "@acusti/dropdown/Dropdown",
|
|
1285
1304
|
precedence: "medium",
|
|
1286
1305
|
children: Dropdown_default
|
|
1287
1306
|
});
|
|
1288
|
-
$[
|
|
1289
|
-
} else t37 = $[
|
|
1307
|
+
$[112] = t37;
|
|
1308
|
+
} else t37 = $[112];
|
|
1290
1309
|
let t38;
|
|
1291
|
-
if ($[
|
|
1310
|
+
if ($[113] !== className || $[114] !== disabled || $[115] !== isOpen || $[116] !== isSearchable) {
|
|
1292
1311
|
t38 = clsx("uktdropdown", className, {
|
|
1293
1312
|
disabled,
|
|
1294
1313
|
"is-open": isOpen,
|
|
1295
1314
|
"is-searchable": isSearchable
|
|
1296
1315
|
});
|
|
1297
|
-
$[
|
|
1298
|
-
$[
|
|
1299
|
-
$[
|
|
1300
|
-
$[
|
|
1301
|
-
$[
|
|
1302
|
-
} else t38 = $[
|
|
1316
|
+
$[113] = className;
|
|
1317
|
+
$[114] = disabled;
|
|
1318
|
+
$[115] = isOpen;
|
|
1319
|
+
$[116] = isSearchable;
|
|
1320
|
+
$[117] = t38;
|
|
1321
|
+
} else t38 = $[117];
|
|
1303
1322
|
let t39;
|
|
1304
|
-
if ($[
|
|
1323
|
+
if ($[118] !== bodyId || $[119] !== children || $[120] !== childrenCount || $[121] !== hasItems || $[122] !== isOpen || $[123] !== popupRole) {
|
|
1305
1324
|
t39 = isOpen ? /* @__PURE__ */ jsx("div", {
|
|
1306
1325
|
className: clsx("uktdropdown-body", { "has-items": hasItems }),
|
|
1307
1326
|
id: bodyId,
|
|
@@ -1316,16 +1335,16 @@ function RootDropdown(t0) {
|
|
|
1316
1335
|
})
|
|
1317
1336
|
})
|
|
1318
1337
|
}) : null;
|
|
1319
|
-
$[
|
|
1320
|
-
$[
|
|
1321
|
-
$[
|
|
1322
|
-
$[
|
|
1323
|
-
$[
|
|
1324
|
-
$[
|
|
1325
|
-
$[
|
|
1326
|
-
} else t39 = $[
|
|
1338
|
+
$[118] = bodyId;
|
|
1339
|
+
$[119] = children;
|
|
1340
|
+
$[120] = childrenCount;
|
|
1341
|
+
$[121] = hasItems;
|
|
1342
|
+
$[122] = isOpen;
|
|
1343
|
+
$[123] = popupRole;
|
|
1344
|
+
$[124] = t39;
|
|
1345
|
+
} else t39 = $[124];
|
|
1327
1346
|
let t40;
|
|
1328
|
-
if ($[
|
|
1347
|
+
if ($[125] !== handleMouseDown || $[126] !== handleMouseMove || $[127] !== handleMouseOut || $[128] !== handleMouseOver || $[129] !== handleMouseUp || $[130] !== handleRef || $[131] !== onClick || $[132] !== styleFromProps || $[133] !== t38 || $[134] !== t39 || $[135] !== trigger) {
|
|
1329
1348
|
t40 = /* @__PURE__ */ jsxs(Fragment, { children: [t37, /* @__PURE__ */ jsxs("div", {
|
|
1330
1349
|
className: t38,
|
|
1331
1350
|
onClick,
|
|
@@ -1338,19 +1357,19 @@ function RootDropdown(t0) {
|
|
|
1338
1357
|
style: styleFromProps,
|
|
1339
1358
|
children: [trigger, t39]
|
|
1340
1359
|
})] });
|
|
1341
|
-
$[
|
|
1342
|
-
$[
|
|
1343
|
-
$[
|
|
1344
|
-
$[
|
|
1345
|
-
$[
|
|
1346
|
-
$[
|
|
1347
|
-
$[
|
|
1348
|
-
$[
|
|
1349
|
-
$[
|
|
1350
|
-
$[
|
|
1351
|
-
$[
|
|
1352
|
-
$[
|
|
1353
|
-
} else t40 = $[
|
|
1360
|
+
$[125] = handleMouseDown;
|
|
1361
|
+
$[126] = handleMouseMove;
|
|
1362
|
+
$[127] = handleMouseOut;
|
|
1363
|
+
$[128] = handleMouseOver;
|
|
1364
|
+
$[129] = handleMouseUp;
|
|
1365
|
+
$[130] = handleRef;
|
|
1366
|
+
$[131] = onClick;
|
|
1367
|
+
$[132] = styleFromProps;
|
|
1368
|
+
$[133] = t38;
|
|
1369
|
+
$[134] = t39;
|
|
1370
|
+
$[135] = trigger;
|
|
1371
|
+
$[136] = t40;
|
|
1372
|
+
} else t40 = $[136];
|
|
1354
1373
|
return t40;
|
|
1355
1374
|
}
|
|
1356
1375
|
function _temp(ref_0) {
|
package/dist/Dropdown.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropdown.js","names":["createContext","Item","DropdownContextValue","registerSubmenu","registration","SubmenuRegistration","element","HTMLElement","onActiveItem","payload","onClose","onOpen","onSubmitItem","DropdownContext","MenubarContextValue","moveOpen","fromElement","direction","notifyOpened","registerMember","member","MenubarMember","close","focusTrigger","isOpen","open","MenubarContext","getBestMatch","SyntheticEvent","Item","ITEM_SELECTOR","SUBMENU_SELECTOR","DISABLED_ITEM_SELECTOR","OnToggleSubmenu","item","HTMLElement","isExpanded","MaybeHTMLElement","getBodyElement","dropdownElement","querySelector","getLevelRoot","element","closest","getSubmenuOfItem","submenu","owner","parentElement","getParentItem","levelRoot","getItemLabel","innerText","clone","cloneNode","Array","from","querySelectorAll","remove","textContent","trim","getItemPath","path","parentItem","label","unshift","value","dataset","uktValue","getItemElements","bodyElement","root","candidates","length","filter","matches","items","HTMLCollection","children","getItemForTarget","target","targetLevelRoot","contains","itemElements","find","itemElement","getActiveItemElements","actives","getActiveItemElement","getDeepestExpandedItem","expanded","isItemExpanded","getAttribute","submenuIdCounter","ensureSubmenuAria","hasAttribute","setAttribute","id","annotateParentItems","expandItem","onToggleSubmenu","collapseItem","expandedDescendants","descendant","active","uktActive","collapseItemsOutsidePath","expandedItems","reverse","clearItemElementsState","forEach","setActiveChain","chain","Set","add","has","BaseSetActiveItemPayload","event","Event","index","indexAddend","isExactMatch","onActiveItem","payload","text","setActiveItem","Omit","currentDeepest","lastIndex","currentActiveIndex","findIndex","nextActiveIndex","Math","max","min","itemTexts","map","textToCompare","toLowerCase","itemText","startsWith","bestMatch","nextActiveItem","scrollableParent","isScrollable","scrollHeight","clientHeight","parentRect","getBoundingClientRect","itemRect","isAboveTop","top","isBelowBottom","bottom","scrollTop","Point","x","y","isPointInTriangle","p","a","b","c","cross","u","v","w","d1","d2","d3","hasNegative","hasPositive","clsx","CSSProperties","FocusEvent","ReactFocusEvent","KeyboardEvent","ReactKeyboardEvent","MouseEvent","ReactMouseEvent","ReactNode","useMemo","useRef","MenubarContext","MenubarContextValue","MenubarMember","MenubarProps","children","className","style","compareDocumentOrder","a","b","element","position","compareDocumentPosition","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","Menubar","t0","$","_c","t1","Symbol","for","Set","membersRef","t2","Array","from","current","sort","getOrderedMembersRef","getOrderedMembers","t3","moveOpen","fromElement","direction","members","length","index","findIndex","member","nextIndex","close","open","focusTrigger","notifyOpened","member_0","isOpen","registerMember","member_1","add","delete","contextValue","t4","event","key","members_0","some","_temp","eventTarget","target","HTMLElement","index_0","member_3","contains","preventDefault","stopPropagation","direction_0","handleKeyDown","t5","eventTarget_0","members_1","_temp2","member_5","find","m","switchToMemberAt","t6","event_0","handleFocus","t7","event_1","handleMouseOver","t8","t9","t10","member_4","member_2","useKeyboardEvents","isEventTargetUsingKeyEvent","clsx","Children","cloneElement","CSSProperties","Fragment","isValidElement","MouseEvent","ReactMouseEvent","ReactElement","ReactNode","SyntheticEvent","useContext","useEffect","useId","useMemo","useRef","useState","DropdownContext","DropdownContextValue","MenubarContext","SubmenuRegistration","styles","annotateParentItems","collapseItem","collapseItemsOutsidePath","expandItem","getActiveItemElement","getDeepestExpandedItem","getItemElements","getItemForTarget","getItemPath","getLevelRoot","getParentItem","getSubmenuOfItem","isItemExpanded","isPointInTriangle","Point","setActiveItem","Item","element","MaybeHTMLElement","event","Event","HTMLElement","label","path","Array","ItemPathEntry","value","Props","allowCreate","allowEmpty","children","ChildrenTuple","className","disabled","hasItems","isOpenOnMount","isSearchable","keepOpenOnSubmit","name","onActiveItem","payload","onClick","onClose","onMouseDown","onMouseUp","onOpen","onSubmitItem","placeholder","style","Record","tabIndex","MousePosition","clientX","clientY","TimeoutID","ReturnType","setTimeout","CHILDREN_ERROR","CLICKABLE_SELECTOR","FOCUSABLE_SELECTOR","TEXT_INPUT_SELECTOR","SUBMENU_DISCLOSURE_DELAY","SAFE_AREA_TIMEOUT","Dropdown","props","$","_c","parentDropdown","t0","RootDropdown","t1","t2","t3","styleFromProps","undefined","childrenCount","count","Error","console","error","trigger","isOpen","setIsOpen","isOpening","setIsOpening","dropdownElement","setDropdownElement","bodyId","popupRole","menubar","inputElementRef","closingTimerRef","isOpeningTimerRef","currentInputMethodRef","clearEnteredCharactersTimerRef","enteredCharactersRef","mouseDownPositionRef","disclosureTimerRef","pendingDisclosureItemRef","t4","Symbol","for","Set","submenuRegistrationsRef","pointerRef","lastMouseEventRef","safeAreaRef","safeAreaTimerRef","wasInSafeAreaRef","allowCreateRef","allowEmptyRef","hasItemsRef","isOpenRef","isOpeningRef","keepOpenOnSubmitRef","onCloseRef","onOpenRef","onSubmitItemRef","valueRef","t5","t6","current","isMountedRef","t7","t8","t9","registerSubmenu","registration","add","delete","dropdownContextValue","t10","key","registration_0","contains","dispatchToSubmenus","t11","payload_0","handleActiveItem","t12","item","isExpanded","registration_1","handleToggleSubmenu","t13","clearTimeout","clearDisclosureTimer","t14","t15","t16","activeElement","submenu","hasAttribute","syncSubmenuDisclosure","t17","clearSafeAreaTimer","t18","t19","t20","x","y","safeArea","parent","submenu_0","submenuRect","getBoundingClientRect","parentRect","nearX","left","right","apex","top","bottom","isPointerInSafeArea","t21","targetElement","pointer","target","ownerDocument","elementFromPoint","item_0","commitPointerTarget","t22","event_0","pointer_0","nativeEvent","target_0","submenu_1","isOverParent","trackSafeArea","t23","closeDropdown","t24","firstElementChild","firstChild","focusable","matches","querySelector","focus","focusTrigger","t25","registerMember","close","open","t26","t27","notifyOpened","t28","event_1","submenuOfActive","firstItem","itemLabel","innerText","blur","nextValue","dataset","uktValue","eventTarget","click","clickableElements","querySelectorAll","length","clickableElement","payload_1","handleSubmitItem","t29","event_2","initialPosition","Math","abs","handleMouseMove","t30","event_3","eventTarget_0","closest","hoveredRoot","classList","item_1","handleMouseOver","t31","event_4","relatedTarget","Node","isLeavingDropdown","activeItem","eventRelatedTarget","uktActive","handleMouseOut","t32","event_5","handleMouseDown","t33","event_6","eventTarget_1","clickedRoot","targetBody","isInOwnBody","Boolean","clickedItem","handleMouseUp","t34","event_7","altKey","ctrlKey","key_0","metaKey","eventTarget_2","onEventHandled","stopPropagation","preventDefault","isEventTargetingDropdown","nestedRoot","isTargetUsingKeyEvents","isEditingCharacters","test","slice","isExactMatch","text","index","indexAddend","activeElement_0","submenu_2","firstItem_0","moveOpen","activeElement_1","levelRoot","parentItem","handleKeyDown","t35","ignoreUsedKeyboardEvents","onKeyDown","t36","ref","inputElement","HTMLInputElement","handleGlobalMouseDown","t37","target_1","eventTarget_3","handleGlobalMouseUp","t38","target_2","eventTarget_4","handleGlobalFocusIn","t39","target_3","eventTarget_5","document","addEventListener","handleInput","event_8","input","isDeleting","removeEventListener","handleRef","handleBodyRef","_temp","triggerProps","t40","t41","ref_0","showPopover","INERT_SUBMENU_PROPS","const","SubmenuDropdown","itemRef","warnedRef","inertProps","filter","propName","join","labelContent","body","default","Menubar","MenubarProps"],"sources":["../src/context.ts","../src/Dropdown.css?inline","../src/helpers.ts","../src/Menubar.tsx","../src/Dropdown.tsx"],"sourcesContent":["import { createContext } from 'react';\n\nimport { type Item } from './Dropdown.js';\n\nexport type DropdownContextValue = {\n registerSubmenu: (registration: SubmenuRegistration) => () => void;\n};\n\nexport type SubmenuRegistration = {\n element: HTMLElement;\n onActiveItem?: (payload: Item) => void;\n onClose?: () => unknown;\n onOpen?: () => unknown;\n onSubmitItem?: (payload: Item) => void;\n};\n\n// Provided by a menu Dropdown; a Dropdown that finds this context renders as a\n// submenu (parent item + data-ukt-submenu) instead of a root dropdown.\nexport const DropdownContext = createContext<DropdownContextValue | null>(null);\n\nexport type MenubarContextValue = {\n moveOpen: (fromElement: HTMLElement, direction: -1 | 1) => void;\n notifyOpened: (element: HTMLElement) => void;\n registerMember: (member: MenubarMember) => () => void;\n};\n\nexport type MenubarMember = {\n close: () => void;\n element: HTMLElement;\n focusTrigger: () => void;\n isOpen: () => boolean;\n open: () => void;\n};\n\nexport const MenubarContext = createContext<MenubarContextValue | null>(null);\n",":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: 0.5em;\n --uktdd-body-pad-left: 0.6875em;\n --uktdd-body-pad-right: 0.6875em;\n --uktdd-body-pad-top: 0.5em;\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 /* gap between the trigger and the body, applied as a symmetric\n margin-block so it lands on whichever side the body attaches to and\n auto-reverses when position-try flips it above/below the trigger. A\n margin establishes no containing block, so it’s safe on dropdowns with\n submenus */\n --uktdd-body-gap: 0px;\n --uktdd-body-color: canvastext;\n --uktdd-body-bg-color-path: #dcdcdc;\n --uktdd-body-color-path: currentColor;\n --uktdd-label-pad-right: 0.625em;\n --uktdd-submenu-position-area: inline-end span-block-end;\n --uktdd-submenu-position-try-fallbacks: --uktdd-submenu-inline-start;\n /* like --uktdd-body-gap but on the inline axis, since submenus open to\n the side; auto-reverses when they flip to the opposite inline edge */\n --uktdd-submenu-gap: 0px;\n --uktdd-menubar-trigger-bg-color-active: rgba(0, 0, 0, 0.12);\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 /* the body renders in the top layer via popover=\"manual\" so an ancestor’s\n transform / filter / contain can’t become its containing block, and the\n top layer handles stacking (no z-index). The UA-popover box resets that\n must beat a consumer’s global [popover] styles live in the\n div.uktdropdown-body rule below; these cosmetics stay overridable */\n color: inherit;\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 /* an active item is on the path — not deepest — while a deeper highlight\n exists or the pointer is inside its submenu; macOS mutes the parent\n even when the pointer is over a separator or disabled submenu item */\n [data-ukt-active]:has([data-ukt-submenu] [data-ukt-active]),\n [data-ukt-active]:has([data-ukt-submenu]:hover) {\n background-color: var(--uktdd-body-bg-color-path);\n color: var(--uktdd-body-color-path);\n }\n\n [data-ukt-item][aria-disabled=\"true\"] {\n opacity: 0.5;\n pointer-events: none;\n }\n\n /* the expanded parent item anchors its submenu; anchor-scope keeps each\n level’s submenu bound to its own parent item */\n [data-ukt-item] {\n anchor-scope: --uktdd-submenu-anchor;\n }\n\n /* parent items get a macOS-style disclosure chevron, right-aligned */\n :is([data-ukt-item], [data-ukt-value])[aria-haspopup=\"menu\"] {\n position: relative;\n padding-inline-end: 2em;\n\n &::after {\n content: \"\";\n position: absolute;\n inset-inline-end: 0.9em;\n inset-block-start: 50%;\n inline-size: 0.3em;\n block-size: 0.3em;\n border-block-start: 0.14em solid currentColor;\n border-inline-end: 0.14em solid currentColor;\n translate: 0 -50%;\n rotate: 45deg;\n }\n\n &:dir(rtl)::after {\n rotate: -45deg;\n }\n }\n\n [data-ukt-item][aria-expanded=\"true\"] {\n anchor-name: --uktdd-submenu-anchor;\n\n > [data-ukt-submenu] {\n display: block;\n }\n }\n\n [data-ukt-submenu] {\n box-sizing: border-box;\n display: none;\n /* an explicit color so items don’t inherit the white highlight color\n from their active parent item (the submenu is its DOM child) */\n color: var(--uktdd-body-color);\n position: fixed;\n position-anchor: --uktdd-submenu-anchor;\n position-area: var(--uktdd-submenu-position-area);\n position-try-fallbacks: var(--uktdd-submenu-position-try-fallbacks);\n z-index: 2;\n margin-block: 0;\n margin-inline: var(--uktdd-submenu-gap);\n padding: var(--uktdd-body-pad-top) var(--uktdd-body-pad-right)\n var(--uktdd-body-pad-bottom) var(--uktdd-body-pad-left);\n inline-size: max-content;\n max-inline-size: var(--uktdd-body-max-width);\n max-block-size: var(--uktdd-body-max-height);\n overflow: auto;\n overscroll-behavior: contain;\n list-style: none;\n background-color: var(--uktdd-body-bg-color);\n box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);\n }\n}\n\n/* The body is a popover, so a consumer’s global [popover] rules match it and\n tie .uktdropdown-body on specificity (both 0,1,0), letting source order\n decide — which can clobber the body’s box geometry. Reset the UA-popover box\n at div.uktdropdown-body (0,1,1): the lightest bump that still beats a bare\n [popover] (0,1,0), so the layout holds regardless of a consumer’s popover\n styles, while the body’s cosmetics stay overridable at 0,1,0. */\ndiv.uktdropdown-body {\n inset: auto;\n block-size: auto;\n margin-block: var(--uktdd-body-gap);\n margin-inline: 0;\n border: 0;\n padding: 0;\n}\n\n.uktmenubar {\n display: flex;\n align-items: stretch;\n width: max-content;\n font-family: var(--uktdd-font-family);\n\n /* the open menu’s trigger reads as active, like the highlighted item in\n the macOS menu bar; the default tints over whatever background the\n trigger already has, so it works regardless of how it’s styled */\n .uktdropdown.is-open .uktdropdown-trigger {\n box-shadow: inset 0 0 0 100vmax var(--uktdd-menubar-trigger-bg-color-active);\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\n@position-try --uktdd-submenu-inline-start {\n position-area: inline-start span-block-end;\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]';\nexport const SUBMENU_SELECTOR = '[data-ukt-submenu]';\n\nconst DISABLED_ITEM_SELECTOR = '[aria-disabled=\"true\"]';\n\nexport type OnToggleSubmenu = (item: HTMLElement, isExpanded: boolean) => void;\n\ntype MaybeHTMLElement = HTMLElement | null;\n\nconst getBodyElement = (dropdownElement: MaybeHTMLElement) =>\n (dropdownElement?.querySelector('.uktdropdown-body') ?? null) as MaybeHTMLElement;\n\n// The level root that owns an item: the closest [data-ukt-submenu] ancestor,\n// or null for items at the top level of the dropdown body\nexport const getLevelRoot = (element: HTMLElement) =>\n element.closest(SUBMENU_SELECTOR) as MaybeHTMLElement;\n\n// An item’s own submenu (a parent item), excluding submenus of descendant items\nexport const getSubmenuOfItem = (item: HTMLElement): MaybeHTMLElement => {\n const submenu = item.querySelector(SUBMENU_SELECTOR) as MaybeHTMLElement;\n if (!submenu) return null;\n const owner = submenu.parentElement?.closest(ITEM_SELECTOR);\n return owner === item ? submenu : null;\n};\n\n// The parent item that owns a submenu level\nexport const getParentItem = (levelRoot: HTMLElement) =>\n (levelRoot.parentElement?.closest(ITEM_SELECTOR) ?? null) as MaybeHTMLElement;\n\n// A parent item’s label is its text content excluding the submenu subtree\nexport const getItemLabel = (item: HTMLElement): string => {\n if (!getSubmenuOfItem(item)) return item.innerText ?? '';\n const clone = item.cloneNode(true) as HTMLElement;\n for (const submenu of Array.from(clone.querySelectorAll(SUBMENU_SELECTOR))) {\n submenu.remove();\n }\n return (clone.textContent ?? '').trim();\n};\n\n// Ancestor parent items from the root level down to the element’s immediate parent\nexport const getItemPath = (element: MaybeHTMLElement): Item['path'] => {\n const path: Item['path'] = [];\n if (!element) return path;\n let levelRoot = getLevelRoot(element);\n while (levelRoot) {\n const parentItem = getParentItem(levelRoot);\n if (!parentItem) break;\n const label = getItemLabel(parentItem);\n path.unshift({ label, value: parentItem.dataset.uktValue ?? label });\n levelRoot = getLevelRoot(parentItem);\n }\n return path;\n};\n\nexport const getItemElements = (\n dropdownElement: MaybeHTMLElement,\n levelRoot?: MaybeHTMLElement,\n): Array<HTMLElement> | null => {\n const bodyElement = getBodyElement(dropdownElement);\n if (!bodyElement) return null;\n\n const root = levelRoot ?? bodyElement;\n const candidates = Array.from(\n root.querySelectorAll(ITEM_SELECTOR),\n ) as Array<HTMLElement>;\n\n if (candidates.length) {\n return candidates.filter((item) => {\n if (item.matches(DISABLED_ITEM_SELECTOR)) return false;\n return getLevelRoot(item) === (levelRoot ?? null);\n });\n }\n\n // If no items found via [data-ukt-item] or [data-ukt-value] selector,\n // use first instance of multiple children found — flat bodies and flat\n // submenu levels alike\n let items: HTMLCollection = root.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 = root.children;\n }\n return (Array.from(items) as Array<HTMLElement>).filter(\n (item) => !item.matches(DISABLED_ITEM_SELECTOR),\n );\n};\n\n// The item an event target belongs to within its own level: the closest\n// marked item, or — when the target sits in a level with no marked items\n// (a heuristically-detected level) — the target itself if it’s one of that\n// level’s detected items. Misses (body padding, separators) and disabled\n// items resolve to null.\nexport const getItemForTarget = (\n dropdownElement: HTMLElement,\n target: HTMLElement,\n): MaybeHTMLElement => {\n let item = target.closest(ITEM_SELECTOR) as MaybeHTMLElement;\n // If nothing matched, or the target sits in a deeper level than the\n // matched item (an unmarked, heuristically-detected submenu level),\n // resolve the item within the target’s own level instead\n const targetLevelRoot = getLevelRoot(target);\n if (!item || (targetLevelRoot && item.contains(targetLevelRoot))) {\n const itemElements = getItemElements(dropdownElement, targetLevelRoot);\n item = itemElements?.find((itemElement) => itemElement === target) ?? item;\n }\n if (!item || !dropdownElement.contains(item)) return null;\n if (item.matches(DISABLED_ITEM_SELECTOR)) return null;\n return item;\n};\n\n// All active items, in document order (ancestors before descendants)\nexport const getActiveItemElements = (dropdownElement: MaybeHTMLElement) => {\n if (!dropdownElement) return null;\n const actives = dropdownElement.querySelectorAll('[data-ukt-active]');\n return actives.length ? (Array.from(actives) as Array<HTMLElement>) : null;\n};\n\n// The deepest active item — the one keyboard input operates on\nexport const getActiveItemElement = (dropdownElement: MaybeHTMLElement) => {\n const actives = getActiveItemElements(dropdownElement);\n return actives ? actives[actives.length - 1] : null;\n};\n\n// The deepest expanded parent item — the one whose submenu is the innermost\n// open one — in document order\nexport const getDeepestExpandedItem = (\n dropdownElement: MaybeHTMLElement,\n): MaybeHTMLElement => {\n if (!dropdownElement) return null;\n const expanded = (\n Array.from(\n dropdownElement.querySelectorAll('[aria-expanded=\"true\"]'),\n ) as Array<HTMLElement>\n ).filter((element) => element.matches(ITEM_SELECTOR));\n return expanded.length ? expanded[expanded.length - 1] : null;\n};\n\nexport const isItemExpanded = (item: HTMLElement) =>\n item.getAttribute('aria-expanded') === 'true';\n\nlet submenuIdCounter = 0;\n\nconst ensureSubmenuAria = (item: HTMLElement, submenu: HTMLElement) => {\n if (!submenu.hasAttribute('role')) submenu.setAttribute('role', 'menu');\n if (!submenu.id) submenu.id = `uktdd-submenu-${++submenuIdCounter}`;\n if (!item.hasAttribute('aria-haspopup')) item.setAttribute('aria-haspopup', 'menu');\n if (!item.hasAttribute('aria-expanded')) item.setAttribute('aria-expanded', 'false');\n if (!item.hasAttribute('aria-controls')) {\n item.setAttribute('aria-controls', submenu.id);\n }\n};\n\n// Fill in submenu/parent-item ARIA (only what the consumer hasn’t set)\nexport const annotateParentItems = (bodyElement: MaybeHTMLElement) => {\n if (!bodyElement) return;\n for (const submenu of Array.from(bodyElement.querySelectorAll(SUBMENU_SELECTOR))) {\n const item = getParentItem(submenu as HTMLElement);\n if (item) ensureSubmenuAria(item, submenu as HTMLElement);\n }\n};\n\nexport const expandItem = (item: HTMLElement, onToggleSubmenu?: OnToggleSubmenu) => {\n const submenu = getSubmenuOfItem(item);\n if (!submenu) return;\n ensureSubmenuAria(item, submenu);\n if (isItemExpanded(item)) return;\n item.setAttribute('aria-expanded', 'true');\n onToggleSubmenu?.(item, true);\n};\n\nexport const collapseItem = (item: HTMLElement, onToggleSubmenu?: OnToggleSubmenu) => {\n if (!isItemExpanded(item)) return;\n const submenu = getSubmenuOfItem(item);\n if (submenu) {\n // Collapse any expanded descendants first so their state can’t leak\n // into the next disclosure and their onClose callbacks fire\n // (recursion makes the collapse order deepest-first)\n const expandedDescendants = (\n Array.from(\n submenu.querySelectorAll('[aria-expanded=\"true\"]'),\n ) as Array<HTMLElement>\n ).filter((descendant) => descendant.matches(ITEM_SELECTOR));\n for (const descendant of expandedDescendants) {\n collapseItem(descendant, onToggleSubmenu);\n }\n for (const active of Array.from(submenu.querySelectorAll('[data-ukt-active]'))) {\n delete (active as HTMLElement).dataset.uktActive;\n }\n }\n item.setAttribute('aria-expanded', 'false');\n onToggleSubmenu?.(item, false);\n};\n\n// Collapse every expanded parent item that isn’t an ancestor of element\n// (element == null collapses all), deepest-first\nexport const collapseItemsOutsidePath = (\n dropdownElement: MaybeHTMLElement,\n element: MaybeHTMLElement,\n onToggleSubmenu?: OnToggleSubmenu,\n) => {\n const bodyElement = getBodyElement(dropdownElement);\n if (!bodyElement) return;\n const expandedItems = (\n Array.from(\n bodyElement.querySelectorAll('[aria-expanded=\"true\"]'),\n ) as Array<HTMLElement>\n ).filter((item) => item.matches(ITEM_SELECTOR));\n for (const item of expandedItems.reverse()) {\n if (element && item.contains(element)) continue;\n collapseItem(item, onToggleSubmenu);\n }\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 // Also clear active state in any deeper levels within this item\n for (const active of Array.from(\n itemElement.querySelectorAll('[data-ukt-active]'),\n )) {\n delete (active as HTMLElement).dataset.uktActive;\n }\n });\n};\n\n// Make the active set exactly the chain of element + its ancestor parent items\nconst setActiveChain = (dropdownElement: HTMLElement, element: HTMLElement) => {\n const chain = new Set<HTMLElement>([element]);\n let levelRoot = getLevelRoot(element);\n while (levelRoot) {\n const parentItem = getParentItem(levelRoot);\n if (!parentItem) break;\n chain.add(parentItem);\n levelRoot = getLevelRoot(parentItem);\n }\n for (const active of getActiveItemElements(dropdownElement) ?? []) {\n if (!chain.has(active)) delete active.dataset.uktActive;\n }\n for (const item of chain) {\n item.setAttribute('data-ukt-active', '');\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'>)): MaybeHTMLElement => {\n const currentDeepest = getActiveItemElement(dropdownElement);\n // Keys and text operate on the current level (the level of the deepest\n // active item); activating an element directly targets its own level\n const levelRoot = element\n ? getLevelRoot(element)\n : currentDeepest\n ? getLevelRoot(currentDeepest)\n : null;\n\n const itemElements = getItemElements(dropdownElement, levelRoot);\n if (!itemElements || itemElements.length === 0) return currentDeepest;\n\n const lastIndex = itemElements.length - 1;\n const currentActiveIndex = itemElements.findIndex(\n (itemElement) => itemElement === currentDeepest,\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 if (nextActiveIndex === -1) return currentDeepest;\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 null;\n }\n\n const itemTexts = itemElements.map(getItemLabel);\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 = itemElements[nextActiveIndex] as MaybeHTMLElement;\n if (nextActiveItem == null || nextActiveItem === currentDeepest) {\n return currentDeepest;\n }\n\n setActiveChain(dropdownElement, nextActiveItem);\n const label = getItemLabel(nextActiveItem);\n const value = nextActiveItem.dataset.uktValue ?? label;\n onActiveItem?.({\n element: nextActiveItem,\n event,\n label,\n path: getItemPath(nextActiveItem),\n value,\n });\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 return nextActiveItem;\n};\n\nexport type Point = { x: number; y: number };\n\n// Whether a point is inside (or on an edge of) triangle a-b-c, from the sign\n// of the cross product for each edge: all the same sign ⇒ inside\nexport const isPointInTriangle = (p: Point, a: Point, b: Point, c: Point): boolean => {\n const cross = (u: Point, v: Point, w: Point) =>\n (u.x - w.x) * (v.y - w.y) - (v.x - w.x) * (u.y - w.y);\n const d1 = cross(p, a, b);\n const d2 = cross(p, b, c);\n const d3 = cross(p, c, a);\n const hasNegative = d1 < 0 || d2 < 0 || d3 < 0;\n const hasPositive = d1 > 0 || d2 > 0 || d3 > 0;\n return !(hasNegative && hasPositive);\n};\n","import clsx from 'clsx';\nimport {\n type CSSProperties,\n type FocusEvent as ReactFocusEvent,\n type KeyboardEvent as ReactKeyboardEvent,\n type MouseEvent as ReactMouseEvent,\n type ReactNode,\n useMemo,\n useRef,\n} from 'react';\n\nimport {\n MenubarContext,\n type MenubarContextValue,\n type MenubarMember,\n} from './context.js';\n\nexport type MenubarProps = {\n children: ReactNode;\n className?: string;\n style?: CSSProperties;\n};\n\nconst compareDocumentOrder = (a: MenubarMember, b: MenubarMember) => {\n if (a.element === b.element) return 0;\n const position = a.element.compareDocumentPosition(b.element);\n if ((position & Node.DOCUMENT_POSITION_FOLLOWING) !== 0) return -1;\n if ((position & Node.DOCUMENT_POSITION_PRECEDING) !== 0) return 1;\n return 0;\n};\n\n// Combines sibling Dropdowns into a single menu, like the system menu in the\n// top toolbar of macOS: one menu open at a time, ←/→ move between menus, and\n// once any menu is open, hovering or focusing another trigger switches to it.\nexport default function Menubar({ children, className, style }: MenubarProps) {\n const membersRef = useRef<Set<MenubarMember>>(new Set());\n\n const getOrderedMembersRef = useRef(() =>\n Array.from(membersRef.current).sort(compareDocumentOrder),\n );\n const getOrderedMembers = getOrderedMembersRef.current;\n\n const contextValue: MenubarContextValue = useMemo(\n () => ({\n moveOpen(fromElement: HTMLElement, direction: -1 | 1) {\n const members = getOrderedMembersRef.current();\n if (members.length < 2) return;\n const index = members.findIndex(\n (member) => member.element === fromElement,\n );\n if (index === -1) return;\n const nextIndex = (index + direction + members.length) % members.length;\n members[index].close();\n members[nextIndex].open();\n members[nextIndex].focusTrigger();\n },\n notifyOpened(element: HTMLElement) {\n for (const member of membersRef.current) {\n if (member.element !== element && member.isOpen()) {\n member.close();\n }\n }\n },\n registerMember(member: MenubarMember) {\n membersRef.current.add(member);\n return () => {\n membersRef.current.delete(member);\n };\n },\n }),\n [],\n );\n\n // Rove focus between triggers with ←/→ while no menu is open (the open\n // dropdown’s own key handling slides the open menu between triggers)\n const handleKeyDown = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n const { key } = event;\n if (key !== 'ArrowLeft' && key !== 'ArrowRight') return;\n const members = getOrderedMembers();\n if (members.length < 2) return;\n if (members.some((member) => member.isOpen())) return;\n const eventTarget = event.target as HTMLElement;\n const index = members.findIndex((member) => member.element.contains(eventTarget));\n if (index === -1) return;\n event.preventDefault();\n event.stopPropagation();\n const direction = key === 'ArrowRight' ? 1 : -1;\n members[(index + direction + members.length) % members.length].focusTrigger();\n };\n\n // Once any menu is open, moving hover or focus to another member’s\n // trigger switches to it (opening notifies the menubar, which closes\n // the other open member)\n const switchToMemberAt = (eventTarget: HTMLElement) => {\n const members = getOrderedMembers();\n if (!members.some((member) => member.isOpen())) return;\n const member = members.find((m) => m.element.contains(eventTarget));\n if (!member || member.isOpen()) return;\n member.open();\n };\n\n const handleFocus = (event: ReactFocusEvent<HTMLDivElement>) => {\n switchToMemberAt(event.target as HTMLElement);\n };\n\n const handleMouseOver = (event: ReactMouseEvent<HTMLDivElement>) => {\n switchToMemberAt(event.target as HTMLElement);\n };\n\n return (\n <div\n className={clsx('uktmenubar', className)}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onMouseOver={handleMouseOver}\n role=\"menubar\"\n style={style}\n >\n <MenubarContext.Provider value={contextValue}>\n {children}\n </MenubarContext.Provider>\n </div>\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 useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport {\n DropdownContext,\n type DropdownContextValue,\n MenubarContext,\n type SubmenuRegistration,\n} from './context.js';\nimport styles from './Dropdown.css?inline';\nimport {\n annotateParentItems,\n collapseItem,\n collapseItemsOutsidePath,\n expandItem,\n getActiveItemElement,\n getDeepestExpandedItem,\n getItemElements,\n getItemForTarget,\n getItemPath,\n getLevelRoot,\n getParentItem,\n getSubmenuOfItem,\n isItemExpanded,\n isPointInTriangle,\n type Point,\n setActiveItem,\n} from './helpers.js';\n\nexport type Item = {\n element: MaybeHTMLElement;\n event: Event | SyntheticEvent<HTMLElement>;\n label: string;\n /**\n * Ancestor parent items from the root level down to the item’s\n * immediate parent. Empty for top-level items.\n */\n path: Array<ItemPathEntry>;\n value: string;\n};\n\nexport type ItemPathEntry = { label: string; value: string };\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 submitting with no item active emits an empty\n * value (i.e. clears the value). Only has an effect when the dropdown has a\n * text input to source that value from — a searchable dropdown’s search\n * input, or a text input inside a custom trigger. With no such input there\n * is no value to submit, so submitting with nothing selected is a no-op\n * regardless; clear such a dropdown with an explicit empty-valued item\n * instead. 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 hasItems?: boolean;\n isOpenOnMount?: boolean;\n isSearchable?: boolean;\n keepOpenOnSubmit?: boolean;\n /**\n * Label content for the trigger button (when using single child syntax).\n * For a nested (submenu) Dropdown, this is the parent item’s content.\n */\n label?: ReactNode;\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 /**\n * Applied to the dropdown root element. Also accepts the component’s CSS\n * custom properties (e.g. `--uktdd-body-min-width`) for per-instance\n * placement and sizing, which plain `CSSProperties` rejects.\n */\n style?: CSSProperties & Record<`--${string}`, string | number | undefined>;\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 FOCUSABLE_SELECTOR = 'a[href], button, input, select, textarea, [tabindex]';\nconst TEXT_INPUT_SELECTOR =\n 'input:not([type=radio]):not([type=checkbox]):not([type=range]),textarea';\n\n// Matches macOS: quick, natural arrowing past parent items never flashes\n// their submenus, but a brief pause discloses. Frame-stepping macOS menus\n// puts its delay around 200–250ms; anything much shorter flashes\nconst SUBMENU_DISCLOSURE_DELAY = 200;\n\n// How long the pointer can dwell inside the safe area (heading toward an open\n// submenu) before we give up and switch to whatever it’s actually over. Reset\n// on every move, so it only fires on a pause — motion keeps the submenu open\nconst SAFE_AREA_TIMEOUT = 300;\n\nexport default function Dropdown(props: Props) {\n const parentDropdown = useContext(DropdownContext);\n // A Dropdown nested inside a menu dropdown’s body renders as a submenu\n // (a parent item delegating to the root engine). A hasItems={false}\n // dropdown provides no submenu context, so a Dropdown nested inside one —\n // or a hasItems={false} Dropdown anywhere — renders independently instead.\n if (parentDropdown && props.hasItems !== false) {\n return <SubmenuDropdown {...props} parentDropdown={parentDropdown} />;\n }\n return <RootDropdown {...props} />;\n}\n\nfunction RootDropdown({\n allowCreate,\n allowEmpty = true,\n children,\n className,\n disabled,\n hasItems = true,\n isOpenOnMount,\n isSearchable,\n keepOpenOnSubmit = !hasItems,\n label,\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 menubar = useContext(MenubarContext);\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 const disclosureTimerRef = useRef<null | TimeoutID>(null);\n const pendingDisclosureItemRef = useRef<MaybeHTMLElement>(null);\n const submenuRegistrationsRef = useRef<Set<SubmenuRegistration>>(new Set());\n const pointerRef = useRef<Point | null>(null);\n const lastMouseEventRef = useRef<MouseEvent | null>(null);\n const safeAreaRef = useRef<{ apex: Point; parent: HTMLElement } | null>(null);\n const safeAreaTimerRef = useRef<null | TimeoutID>(null);\n const wasInSafeAreaRef = useRef<boolean>(false);\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 // Nested (submenu) Dropdowns register here so their scoped callbacks\n // (onActiveItem/onOpen/onClose/onSubmitItem) can be dispatched to them\n const dropdownContextValue: DropdownContextValue = useMemo(\n () => ({\n registerSubmenu(registration: SubmenuRegistration) {\n submenuRegistrationsRef.current.add(registration);\n return () => {\n submenuRegistrationsRef.current.delete(registration);\n };\n },\n }),\n [],\n );\n\n const dispatchToSubmenus = (key: 'onActiveItem' | 'onSubmitItem', payload: Item) => {\n if (!payload.element) return;\n for (const registration of submenuRegistrationsRef.current) {\n if (registration.element.contains(payload.element)) {\n registration[key]?.(payload);\n }\n }\n };\n\n const handleActiveItem = (payload: Item) => {\n onActiveItem?.(payload);\n dispatchToSubmenus('onActiveItem', payload);\n };\n\n const handleToggleSubmenu = (item: HTMLElement, isExpanded: boolean) => {\n for (const registration of submenuRegistrationsRef.current) {\n if (registration.element === item) {\n (isExpanded ? registration.onOpen : registration.onClose)?.();\n }\n }\n };\n\n const clearDisclosureTimer = () => {\n if (disclosureTimerRef.current != null) {\n clearTimeout(disclosureTimerRef.current);\n disclosureTimerRef.current = null;\n }\n pendingDisclosureItemRef.current = null;\n };\n\n // Clear the disclosure intent timer on unmount so it can’t fire against\n // unmounted DOM or dispatch submenu callbacks after teardown\n useEffect(() => clearDisclosureTimer, []);\n\n // A parent item discloses its submenu after a short intent delay whenever\n // it becomes (and stays) the deepest active item, for pointer and keyboard\n // alike; submenus off the active path collapse immediately\n const syncSubmenuDisclosure = () => {\n if (!dropdownElement) return;\n const activeElement = getActiveItemElement(dropdownElement);\n collapseItemsOutsidePath(dropdownElement, activeElement, handleToggleSubmenu);\n const submenu = activeElement ? getSubmenuOfItem(activeElement) : null;\n if (activeElement && submenu && !isItemExpanded(activeElement)) {\n // A timer already pending for this item keeps its original start time\n if (pendingDisclosureItemRef.current === activeElement) return;\n clearDisclosureTimer();\n pendingDisclosureItemRef.current = activeElement;\n disclosureTimerRef.current = setTimeout(() => {\n disclosureTimerRef.current = null;\n pendingDisclosureItemRef.current = null;\n if (!activeElement.hasAttribute('data-ukt-active')) return;\n expandItem(activeElement, handleToggleSubmenu);\n }, SUBMENU_DISCLOSURE_DELAY);\n return;\n }\n clearDisclosureTimer();\n };\n\n const clearSafeAreaTimer = () => {\n if (safeAreaTimerRef.current != null) {\n clearTimeout(safeAreaTimerRef.current);\n safeAreaTimerRef.current = null;\n }\n };\n\n // Clear the safe-area give-up timer on unmount so it can’t fire against\n // unmounted DOM\n useEffect(() => clearSafeAreaTimer, []);\n\n // The safe area is the triangle from where the pointer last sat on the\n // open submenu’s parent (the apex) to that submenu’s two near corners.\n // While the pointer is inside it, it’s traveling toward the submenu, so the\n // submenu stays open even as the pointer crosses sibling items — the macOS\n // diagonal behavior\n const isPointerInSafeArea = (x: number, y: number): boolean => {\n const safeArea = safeAreaRef.current;\n if (!safeArea || !isItemExpanded(safeArea.parent)) return false;\n const submenu = getSubmenuOfItem(safeArea.parent);\n if (!submenu) return false;\n const submenuRect = submenu.getBoundingClientRect();\n const parentRect = safeArea.parent.getBoundingClientRect();\n // Submenus can open to either side; the near edge is the one facing\n // the parent item\n const nearX =\n submenuRect.left >= parentRect.right - 1\n ? submenuRect.left\n : submenuRect.right;\n return isPointInTriangle(\n { x, y },\n safeArea.apex,\n { x: nearX, y: submenuRect.top },\n { x: nearX, y: submenuRect.bottom },\n );\n };\n\n // The pointer left the safe area (or paused in it without reaching the\n // submenu): stop protecting the submenu and switch to whatever the pointer\n // is over now. Passing the target avoids an elementFromPoint read; the\n // give-up timer has no event, so it falls back to hit-testing the pointer\n const commitPointerTarget = (targetElement?: MaybeHTMLElement) => {\n clearSafeAreaTimer();\n safeAreaRef.current = null;\n wasInSafeAreaRef.current = false;\n const pointer = pointerRef.current;\n const target =\n targetElement ??\n (pointer\n ? (dropdownElement?.ownerDocument.elementFromPoint(\n pointer.x,\n pointer.y,\n ) as MaybeHTMLElement)\n : null);\n if (!dropdownElement || !target || !dropdownElement.contains(target)) return;\n const item = getItemForTarget(dropdownElement, target);\n const event = lastMouseEventRef.current;\n // Only reachable via mouse events, so a real mouse event is on hand\n if (item && event) {\n setActiveItem({\n dropdownElement,\n element: item,\n event,\n onActiveItem: handleActiveItem,\n });\n }\n syncSubmenuDisclosure();\n };\n\n // Track the pointer against the open submenu’s safe area: anchor the apex\n // while over the parent item, and (re)arm the give-up timer while traveling\n // toward the submenu so only a pause — not motion — ends the protection\n const trackSafeArea = (event: ReactMouseEvent<HTMLElement>) => {\n // Safe-area intent only applies to an open menu with items; skip the\n // per-move DOM query otherwise (mousemove is a hot path)\n if (!dropdownElement || !isOpenRef.current || !hasItemsRef.current) return;\n const pointer = { x: event.clientX, y: event.clientY };\n pointerRef.current = pointer;\n lastMouseEventRef.current = event.nativeEvent;\n const parent = getDeepestExpandedItem(dropdownElement);\n if (!parent) {\n safeAreaRef.current = null;\n wasInSafeAreaRef.current = false;\n clearSafeAreaTimer();\n return;\n }\n const target = event.target as HTMLElement;\n const submenu = getSubmenuOfItem(parent);\n const isOverParent =\n parent.contains(target) && !(submenu?.contains(target) ?? false);\n if (isOverParent) {\n safeAreaRef.current = { apex: pointer, parent };\n wasInSafeAreaRef.current = false;\n clearSafeAreaTimer();\n return;\n }\n // A newly-open submenu we haven’t anchored an apex for yet\n if (safeAreaRef.current?.parent !== parent) {\n safeAreaRef.current = null;\n }\n clearSafeAreaTimer();\n if (isPointerInSafeArea(pointer.x, pointer.y)) {\n wasInSafeAreaRef.current = true;\n safeAreaTimerRef.current = setTimeout(commitPointerTarget, SAFE_AREA_TIMEOUT);\n } else if (wasInSafeAreaRef.current) {\n // Just crossed out of the triangle. The pointer may still be over\n // the same sibling it entered while protected, so no mouseover will\n // fire — re-evaluate and activate whatever it’s on now\n commitPointerTarget(target);\n }\n };\n\n const closeDropdown = () => {\n setIsOpen(false);\n setIsOpening(false);\n mouseDownPositionRef.current = null;\n clearDisclosureTimer();\n clearSafeAreaTimer();\n safeAreaRef.current = null;\n wasInSafeAreaRef.current = false;\n if (closingTimerRef.current != null) {\n clearTimeout(closingTimerRef.current);\n closingTimerRef.current = null;\n }\n };\n\n const focusTrigger = () => {\n const firstChild = dropdownElement?.firstElementChild as MaybeHTMLElement;\n if (!firstChild) return;\n const focusable = firstChild.matches(FOCUSABLE_SELECTOR)\n ? firstChild\n : (firstChild.querySelector(FOCUSABLE_SELECTOR) as MaybeHTMLElement);\n focusable?.focus();\n };\n\n // Register with an enclosing Menubar (one open menu at a time, ←/→\n // moves between menus, hover-to-switch once any menu is open). Closing\n // goes through closeDropdown so pending timers (submenu disclosure,\n // close delay) can’t fire against a menu the menubar already closed.\n useEffect(() => {\n if (!menubar || !dropdownElement) return;\n return menubar.registerMember({\n close: closeDropdown,\n element: dropdownElement,\n focusTrigger,\n isOpen: () => isOpenRef.current,\n open: () => setIsOpen(true),\n });\n });\n\n useEffect(() => {\n if (isOpen && menubar && dropdownElement) {\n menubar.notifyOpened(dropdownElement);\n }\n }, [dropdownElement, isOpen, menubar]);\n\n const handleSubmitItem = (event: Event | React.SyntheticEvent<HTMLElement>) => {\n const element = hasItemsRef.current\n ? getActiveItemElement(dropdownElement)\n : null;\n\n const submenuOfActive = element ? getSubmenuOfItem(element) : null;\n if (element && submenuOfActive) {\n // Parent items disclose; they never submit\n clearDisclosureTimer();\n expandItem(element, handleToggleSubmenu);\n if (currentInputMethodRef.current === 'keyboard' && dropdownElement) {\n const firstItem = getItemElements(dropdownElement, submenuOfActive)?.[0];\n if (firstItem) {\n setActiveItem({\n dropdownElement,\n element: firstItem,\n event,\n onActiveItem: handleActiveItem,\n });\n }\n }\n return;\n }\n\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 if (!element) {\n // With nothing selected, the only possible value comes from a text\n // input (a searchable dropdown’s input, or one inside a custom\n // trigger). No input means there’s no value to submit at all, so\n // bail regardless of allowCreate/allowEmpty instead of firing an\n // empty-valued onSubmitItem consumers have to defend against. (To\n // let such a dropdown clear its value, give it an explicit\n // empty-valued item, which submits as a normal active selection.)\n if (!inputElementRef.current) return;\n if (inputElementRef.current.value) {\n // Non-empty text matching no item is a created value\n if (!allowCreateRef.current) return;\n } else if (!allowEmptyRef.current) {\n // A cleared input is an empty (clearing) submit, which\n // allowEmpty gates even when allowCreate is set — “creating”\n // an empty value is clearing, not creating\n return;\n }\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 const payload: Item = {\n element,\n event,\n label: itemLabel,\n path: getItemPath(element),\n value: nextValue,\n };\n onSubmitItemRef.current?.(payload);\n dispatchToSubmenus('onSubmitItem', payload);\n };\n\n const handleMouseMove = (event: ReactMouseEvent<HTMLElement>) => {\n const { clientX, clientY } = event;\n currentInputMethodRef.current = 'mouse';\n trackSafeArea(event);\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 eventTarget = event.target as HTMLElement;\n if (!eventTarget.closest('.uktdropdown-body')) return;\n\n // Hover inside an open nested dropdown belongs to that dropdown\n const hoveredRoot = eventTarget.closest('.uktdropdown');\n if (\n hoveredRoot !== dropdownElement &&\n hoveredRoot?.classList.contains('is-open')\n ) {\n return;\n }\n\n // Heading toward an open submenu: keep it open even over sibling items\n if (isPointerInSafeArea(event.clientX, event.clientY)) return;\n\n const item = getItemForTarget(dropdownElement, eventTarget);\n if (!item) return;\n\n setActiveItem({\n dropdownElement,\n element: item,\n event,\n onActiveItem: handleActiveItem,\n });\n syncSubmenuDisclosure();\n };\n\n const handleMouseOut = (event: ReactMouseEvent<HTMLElement>) => {\n if (!hasItemsRef.current) return;\n // The pointer left the dropdown entirely: drop the safe area so its\n // give-up timer can’t later fire on a stale position, and fall through\n // to the normal collapse (mousemove has stopped, so nothing else will)\n const relatedTarget = event.relatedTarget as Node | null;\n const isLeavingDropdown = !dropdownElement?.contains(relatedTarget);\n if (isLeavingDropdown) {\n clearSafeAreaTimer();\n safeAreaRef.current = null;\n wasInSafeAreaRef.current = false;\n }\n // Heading toward an open submenu: don’t clear the active item / collapse\n if (isPointerInSafeArea(event.clientX, event.clientY)) 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 syncSubmenuDisclosure();\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\n // Clicks inside an open nested dropdown belong to that dropdown\n const clickedRoot = eventTarget.closest('.uktdropdown');\n if (\n clickedRoot !== dropdownElement &&\n clickedRoot?.classList.contains('is-open') &&\n dropdownElement?.contains(clickedRoot)\n ) {\n return;\n }\n\n // A click only counts as inside the body if the closest body element\n // belongs to this dropdown (a nested dropdown’s trigger sits inside\n // the outer body, but the outer body isn’t the nested one’s own)\n const targetBody = eventTarget.closest('.uktdropdown-body');\n const isInOwnBody = Boolean(\n targetBody && targetBody.closest('.uktdropdown') === dropdownElement,\n );\n // If click was outside dropdown body, don’t trigger submit\n if (!isInOwnBody) {\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 if (dropdownElement) {\n const clickedItem = getItemForTarget(dropdownElement, eventTarget);\n if (clickedItem) {\n // Submit the item the click actually landed on: sync the\n // active item to it in case they diverge (e.g. active was\n // set via keyboard, then user clicked elsewhere)\n setActiveItem({\n dropdownElement,\n element: clickedItem,\n event,\n onActiveItem: handleActiveItem,\n });\n } else if (getActiveItemElement(dropdownElement)) {\n // A click that doesn’t land on an item — body padding, a\n // separator, or a disabled item (pointer-events: none\n // retargets its clicks to the container) — must not submit\n // the previously active item: like macOS, it does nothing.\n // With no active item it falls through, so a body click\n // can still submit an input-sourced value\n return;\n }\n }\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 // Key events originating inside an open nested dropdown are that\n // dropdown’s business (e.g. an info popover nested in this body)\n const nestedRoot = eventTarget.closest?.('.uktdropdown');\n if (\n nestedRoot &&\n nestedRoot !== dropdownElement &&\n dropdownElement.contains(nestedRoot) &&\n nestedRoot.classList.contains('is-open')\n ) {\n return;\n }\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: handleActiveItem,\n text: enteredCharactersRef.current,\n });\n syncSubmenuDisclosure();\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 // Escape closes the whole menu — submenus included — and\n // returns focus to the element that opened it. Focus before\n // closing: a searchable trigger input opens the dropdown on\n // focus, so its synchronous onFocus must land before the\n // close state update for the close to win the batch\n focusTrigger();\n closeDropdown();\n }\n return;\n }\n\n // Handle arrow keys\n if (hasItemsRef.current) {\n if (key === 'ArrowUp') {\n onEventHandled();\n if (altKey || metaKey) {\n setActiveItem({\n dropdownElement,\n event,\n index: 0,\n onActiveItem: handleActiveItem,\n });\n } else {\n setActiveItem({\n dropdownElement,\n event,\n indexAddend: -1,\n onActiveItem: handleActiveItem,\n });\n }\n syncSubmenuDisclosure();\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({\n dropdownElement,\n event,\n index: -1,\n onActiveItem: handleActiveItem,\n });\n } else {\n setActiveItem({\n dropdownElement,\n event,\n indexAddend: 1,\n onActiveItem: handleActiveItem,\n });\n }\n syncSubmenuDisclosure();\n return;\n }\n // ←/→ dive into and surface out of submenus (and move between\n // menus in a menubar); leave them alone when a text input has focus\n if (!isTargetUsingKeyEvents) {\n if (key === 'ArrowRight') {\n const activeElement = getActiveItemElement(dropdownElement);\n const submenu = activeElement\n ? getSubmenuOfItem(activeElement)\n : null;\n if (activeElement && submenu) {\n onEventHandled();\n clearDisclosureTimer();\n expandItem(activeElement, handleToggleSubmenu);\n const firstItem = getItemElements(dropdownElement, submenu)?.[0];\n if (firstItem) {\n setActiveItem({\n dropdownElement,\n element: firstItem,\n event,\n onActiveItem: handleActiveItem,\n });\n }\n return;\n }\n if (menubar) {\n onEventHandled();\n menubar.moveOpen(dropdownElement, 1);\n }\n return;\n }\n if (key === 'ArrowLeft') {\n const activeElement = getActiveItemElement(dropdownElement);\n const levelRoot = activeElement ? getLevelRoot(activeElement) : null;\n if (levelRoot) {\n onEventHandled();\n clearDisclosureTimer();\n const parentItem = getParentItem(levelRoot);\n if (parentItem) {\n collapseItem(parentItem, handleToggleSubmenu);\n }\n return;\n }\n if (menubar) {\n onEventHandled();\n menubar.moveOpen(dropdownElement, -1);\n }\n return;\n }\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: handleActiveItem,\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 // When the body mounts (open): fill in parent-item/submenu ARIA, and\n // render it in the top layer via popover so an ancestor’s transform /\n // filter / contain can’t become the containing block for the fixed body\n // and break its anchor positioning + fallbacks. popover=\"manual\" keeps\n // dismissal under this component’s own listeners (see handleRef), which\n // preserves iframe support and searchable/text-input triggers that native\n // light-dismiss would close on any outside pointerdown.\n const handleBodyRef = (ref: HTMLDivElement | null) => {\n if (!ref) return;\n annotateParentItems(ref);\n // The Popover API is Baseline 2024, so showPopover() needs no feature\n // detection; the body is mounted only while open, so this runs once\n // per open and won’t throw on an already-open body.\n ref.showPopover();\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 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={styleFromProps}\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 popover=\"manual\"\n ref={handleBodyRef}\n role={popupRole}\n >\n <div className=\"uktdropdown-content\">\n <DropdownContext.Provider\n value={hasItems ? dropdownContextValue : null}\n >\n {childrenCount > 1\n ? (children as ChildrenTuple)[1]\n : children}\n </DropdownContext.Provider>\n </div>\n </div>\n ) : null}\n </div>\n </Fragment>\n );\n}\n\nconst INERT_SUBMENU_PROPS = [\n 'allowCreate',\n 'allowEmpty',\n 'isOpenOnMount',\n 'isSearchable',\n 'keepOpenOnSubmit',\n 'name',\n 'placeholder',\n 'tabIndex',\n 'value',\n] as const;\n\n// The nested (submenu) rendering of Dropdown: a parent item that discloses a\n// child menu. It renders the data-ukt-submenu protocol and registers with the\n// root dropdown, whose engine handles all interaction.\nfunction SubmenuDropdown(props: Props & { parentDropdown: DropdownContextValue }) {\n const {\n children,\n className,\n disabled,\n label,\n onActiveItem,\n onClose,\n onOpen,\n onSubmitItem,\n parentDropdown,\n style,\n } = props;\n\n const itemRef = useRef<HTMLLIElement | null>(null);\n\n useEffect(() => {\n const element = itemRef.current;\n if (!element) return;\n return parentDropdown.registerSubmenu({\n element,\n onActiveItem,\n onClose,\n onOpen,\n onSubmitItem,\n });\n }, [onActiveItem, onClose, onOpen, onSubmitItem, parentDropdown]);\n\n // Misuse feedback is unconditional, like the children-count error above\n const warnedRef = useRef(false);\n useEffect(() => {\n if (warnedRef.current) return;\n const inertProps = INERT_SUBMENU_PROPS.filter(\n (propName) => props[propName] !== undefined,\n );\n if (!inertProps.length) return;\n warnedRef.current = true;\n console.error(\n `@acusti/dropdown: ${inertProps.join(', ')} only apply to a top-level Dropdown and are ignored on a nested (submenu) Dropdown.`,\n );\n });\n\n const childrenCount = Children.count(children);\n let labelContent: ReactNode = label;\n let body: ReactNode = children;\n if (childrenCount > 1) {\n labelContent = (children as ChildrenTuple)[0];\n body = (children as ChildrenTuple)[1];\n }\n\n const submenu = isValidElement(body) ? (\n cloneElement(body as ReactElement<Record<string, unknown>>, {\n 'data-ukt-submenu': '',\n })\n ) : (\n <div data-ukt-submenu=\"\">{body}</div>\n );\n\n return (\n <li\n aria-disabled={disabled || undefined}\n className={className}\n data-ukt-item=\"\"\n ref={itemRef}\n style={style}\n >\n {labelContent}\n {submenu}\n </li>\n );\n}\n\nexport { default as Menubar, type MenubarProps } from './Menubar.js';\n"],"mappings":";;;;;;;AAkBA,IAAaa,kBAAkBb,cAA2C,IAAI;AAgB9E,IAAa0B,iBAAiB1B,cAA0C,IAAI;;;;;;AE7B5E,IAAa8B,gBAAgB;AAC7B,IAAaC,mBAAmB;AAEhC,IAAMC,yBAAyB;AAM/B,IAAMM,kBAAkBC,oBACnBA,iBAAiBC,cAAc,mBAAmB,KAAK;AAI5D,IAAaC,gBAAgBC,YACzBA,QAAQC,Q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oBAAA;aAAIA;EAAW,CAAA;EACxC3Q,EAAA,KAAA2Q;EAAA3Q,EAAA,MAAAO;CAAA,OAAAA,KAAAP,EAAA;CAND,MAAAsF,UAAgB/E;CAUO,MAAA2B,KAAAlE,YAAAyC,KAAAA;CAAqB,IAAA6C;CAAA,IAAAtD,EAAA,QAAAjC,aAAAiC,EAAA,QAAA0Q,gBAAA1Q,EAAA,QAAAjB,SAAAiB,EAAA,QAAAsF,WAAAtF,EAAA,QAAAkC,IAAA;EADxCoB,KAAA,qBAAA,MAAA;GACmB,iBAAApB;GACJnE;GACG,iBAAA;GACTqS,KAAAA;GACErR;aALX,CAOK2R,cACApL,OACA;;EAAAtF,EAAA,MAAAjC;EAAAiC,EAAA,MAAA0Q;EAAA1Q,EAAA,MAAAjB;EAAAiB,EAAA,MAAAsF;EAAAtF,EAAA,MAAAkC;EAAAlC,EAAA,MAAAsD;CAAA,OAAAA,KAAAtD,EAAA;CAAA,OATLsD;AASK"}
|
|
1
|
+
{"version":3,"file":"Dropdown.js","names":["createContext","Item","DropdownContextValue","registerSubmenu","registration","SubmenuRegistration","element","HTMLElement","onActiveItem","payload","onClose","onOpen","onSubmitItem","DropdownContext","MenubarContextValue","moveOpen","fromElement","direction","notifyClosed","notifyOpened","registerMember","member","MenubarMember","close","focusTrigger","isOpen","open","MenubarContext","getBestMatch","SyntheticEvent","Item","ITEM_SELECTOR","SUBMENU_SELECTOR","DISABLED_ITEM_SELECTOR","OnToggleSubmenu","item","HTMLElement","isExpanded","MaybeHTMLElement","getBodyElement","dropdownElement","querySelector","getLevelRoot","element","closest","getSubmenuOfItem","submenu","owner","parentElement","getParentItem","levelRoot","getItemLabel","innerText","clone","cloneNode","Array","from","querySelectorAll","remove","textContent","trim","getItemPath","path","parentItem","label","unshift","value","dataset","uktValue","getItemElements","bodyElement","root","candidates","length","filter","matches","items","HTMLCollection","children","getItemForTarget","target","targetLevelRoot","contains","itemElements","find","itemElement","getActiveItemElements","actives","getActiveItemElement","getDeepestExpandedItem","expanded","isItemExpanded","getAttribute","submenuIdCounter","ensureSubmenuAria","hasAttribute","setAttribute","id","annotateParentItems","expandItem","onToggleSubmenu","collapseItem","expandedDescendants","descendant","active","uktActive","collapseItemsOutsidePath","expandedItems","reverse","clearItemElementsState","forEach","setActiveChain","chain","Set","add","has","BaseSetActiveItemPayload","event","Event","index","indexAddend","isExactMatch","onActiveItem","payload","text","setActiveItem","Omit","currentDeepest","lastIndex","currentActiveIndex","findIndex","nextActiveIndex","Math","max","min","itemTexts","map","textToCompare","toLowerCase","itemText","startsWith","bestMatch","nextActiveItem","scrollableParent","isScrollable","scrollHeight","clientHeight","parentRect","getBoundingClientRect","itemRect","isAboveTop","top","isBelowBottom","bottom","scrollTop","Point","x","y","isPointInTriangle","p","a","b","c","cross","u","v","w","d1","d2","d3","hasNegative","hasPositive","clsx","CSSProperties","FocusEvent","ReactFocusEvent","KeyboardEvent","ReactKeyboardEvent","MouseEvent","ReactMouseEvent","ReactNode","useMemo","useRef","MenubarContext","MenubarContextValue","MenubarMember","MenubarProps","children","className","style","compareDocumentOrder","a","b","element","position","compareDocumentPosition","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","NON_MENU_CONTROL_SELECTOR","Menubar","t0","$","_c","t1","Symbol","for","Set","membersRef","engagedMemberRef","t2","Array","from","current","sort","getOrderedMembersRef","getOrderedMembers","t3","moveOpen","fromElement","direction","members","length","index","findIndex","member","nextIndex","close","open","focusTrigger","notifyClosed","notifyOpened","element_0","member_0","isOpen","registerMember","member_1","add","delete","contextValue","t4","event","key","members_0","some","_temp","eventTarget","target","HTMLElement","index_0","member_3","contains","preventDefault","stopPropagation","direction_0","handleKeyDown","t5","eventTarget_0","members_1","m","member_4","find","m_0","closest","openMember","switchToMemberAt","t6","event_0","handleFocus","t7","event_1","handleMouseOver","t8","t9","t10","member_2","useKeyboardEvents","isEventTargetUsingKeyEvent","clsx","Children","cloneElement","CSSProperties","Fragment","isValidElement","MouseEvent","ReactMouseEvent","ReactElement","ReactNode","SyntheticEvent","useContext","useEffect","useId","useMemo","useRef","useState","DropdownContext","DropdownContextValue","MenubarContext","SubmenuRegistration","styles","annotateParentItems","collapseItem","collapseItemsOutsidePath","expandItem","getActiveItemElement","getDeepestExpandedItem","getItemElements","getItemForTarget","getItemPath","getLevelRoot","getParentItem","getSubmenuOfItem","isItemExpanded","isPointInTriangle","Point","setActiveItem","Item","element","MaybeHTMLElement","event","Event","HTMLElement","label","path","Array","ItemPathEntry","value","Props","allowCreate","allowEmpty","children","ChildrenTuple","className","disabled","hasItems","isOpenOnMount","isSearchable","keepOpenOnSubmit","name","onActiveItem","payload","onClick","onClose","onMouseDown","onMouseUp","onOpen","onSubmitItem","placeholder","style","Record","tabIndex","MousePosition","clientX","clientY","TimeoutID","ReturnType","setTimeout","CHILDREN_ERROR","CLICKABLE_SELECTOR","FOCUSABLE_SELECTOR","TEXT_INPUT_SELECTOR","SUBMENU_DISCLOSURE_DELAY","SAFE_AREA_TIMEOUT","Dropdown","props","$","_c","parentDropdown","t0","RootDropdown","t1","t2","t3","styleFromProps","undefined","childrenCount","count","Error","console","error","trigger","isOpen","setIsOpen","isOpening","setIsOpening","dropdownElement","setDropdownElement","bodyId","popupRole","menubar","inputElementRef","closingTimerRef","isOpeningTimerRef","currentInputMethodRef","clearEnteredCharactersTimerRef","enteredCharactersRef","mouseDownPositionRef","disclosureTimerRef","pendingDisclosureItemRef","t4","Symbol","for","Set","submenuRegistrationsRef","pointerRef","lastMouseEventRef","safeAreaRef","safeAreaTimerRef","wasInSafeAreaRef","allowCreateRef","allowEmptyRef","hasItemsRef","isOpenRef","isOpeningRef","keepOpenOnSubmitRef","onCloseRef","onOpenRef","onSubmitItemRef","valueRef","t5","t6","current","isMountedRef","t7","t8","t9","registerSubmenu","registration","add","delete","dropdownContextValue","t10","key","registration_0","contains","dispatchToSubmenus","t11","payload_0","handleActiveItem","t12","item","isExpanded","registration_1","handleToggleSubmenu","t13","clearTimeout","clearDisclosureTimer","t14","t15","t16","activeElement","submenu","hasAttribute","syncSubmenuDisclosure","t17","clearSafeAreaTimer","t18","t19","t20","x","y","safeArea","parent","submenu_0","submenuRect","getBoundingClientRect","parentRect","nearX","left","right","apex","top","bottom","isPointerInSafeArea","t21","targetElement","pointer","target","ownerDocument","elementFromPoint","item_0","commitPointerTarget","t22","event_0","pointer_0","nativeEvent","target_0","submenu_1","isOverParent","trackSafeArea","t23","options","keepMenubarEngaged","notifyClosed","closeDropdown","t24","firstElementChild","firstChild","focusable","matches","querySelector","focus","focusTrigger","t25","registerMember","close","open","t26","t27","notifyOpened","t28","event_1","submenuOfActive","firstItem","itemLabel","innerText","blur","nextValue","dataset","uktValue","eventTarget","click","clickableElements","querySelectorAll","length","clickableElement","payload_1","handleSubmitItem","t29","event_2","initialPosition","Math","abs","handleMouseMove","t30","event_3","eventTarget_0","closest","hoveredRoot","classList","item_1","handleMouseOver","t31","event_4","relatedTarget","Node","isLeavingDropdown","activeItem","eventRelatedTarget","uktActive","handleMouseOut","t32","event_5","handleMouseDown","t33","event_6","eventTarget_1","clickedRoot","targetBody","isInOwnBody","Boolean","clickedItem","handleMouseUp","t34","event_7","altKey","ctrlKey","key_0","metaKey","eventTarget_2","onEventHandled","stopPropagation","preventDefault","isEventTargetingDropdown","nestedRoot","isTargetUsingKeyEvents","isEditingCharacters","test","slice","isExactMatch","text","index","indexAddend","activeElement_0","submenu_2","firstItem_0","moveOpen","activeElement_1","levelRoot","parentItem","handleKeyDown","t35","ignoreUsedKeyboardEvents","onKeyDown","t36","ref","inputElement","HTMLInputElement","handleGlobalMouseDown","t37","target_1","eventTarget_3","handleGlobalMouseUp","t38","target_2","eventTarget_4","handleGlobalFocusIn","t39","target_3","eventTarget_5","document","addEventListener","handleInput","event_8","input","isDeleting","removeEventListener","handleRef","handleBodyRef","_temp","triggerProps","t40","t41","ref_0","showPopover","INERT_SUBMENU_PROPS","const","SubmenuDropdown","itemRef","warnedRef","inertProps","filter","propName","join","labelContent","body","default","Menubar","MenubarProps"],"sources":["../src/context.ts","../src/Dropdown.css?inline","../src/helpers.ts","../src/Menubar.tsx","../src/Dropdown.tsx"],"sourcesContent":["import { createContext } from 'react';\n\nimport { type Item } from './Dropdown.js';\n\nexport type DropdownContextValue = {\n registerSubmenu: (registration: SubmenuRegistration) => () => void;\n};\n\nexport type SubmenuRegistration = {\n element: HTMLElement;\n onActiveItem?: (payload: Item) => void;\n onClose?: () => unknown;\n onOpen?: () => unknown;\n onSubmitItem?: (payload: Item) => void;\n};\n\n// Provided by a menu Dropdown; a Dropdown that finds this context renders as a\n// submenu (parent item + data-ukt-submenu) instead of a root dropdown.\nexport const DropdownContext = createContext<DropdownContextValue | null>(null);\n\nexport type MenubarContextValue = {\n moveOpen: (fromElement: HTMLElement, direction: -1 | 1) => void;\n notifyClosed: (element: HTMLElement) => void;\n notifyOpened: (element: HTMLElement) => void;\n registerMember: (member: MenubarMember) => () => void;\n};\n\nexport type MenubarMember = {\n close: () => void;\n element: HTMLElement;\n focusTrigger: () => void;\n isOpen: () => boolean;\n open: () => void;\n};\n\nexport const MenubarContext = createContext<MenubarContextValue | null>(null);\n",":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: 0.5em;\n --uktdd-body-pad-left: 0.6875em;\n --uktdd-body-pad-right: 0.6875em;\n --uktdd-body-pad-top: 0.5em;\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 /* gap between the trigger and the body, applied as a symmetric\n margin-block so it lands on whichever side the body attaches to and\n auto-reverses when position-try flips it above/below the trigger. A\n margin establishes no containing block, so it’s safe on dropdowns with\n submenus */\n --uktdd-body-gap: 0px;\n --uktdd-body-color: canvastext;\n --uktdd-body-bg-color-path: #dcdcdc;\n --uktdd-body-color-path: currentColor;\n --uktdd-label-pad-right: 0.625em;\n --uktdd-submenu-position-area: inline-end span-block-end;\n --uktdd-submenu-position-try-fallbacks: --uktdd-submenu-inline-start;\n /* like --uktdd-body-gap but on the inline axis, since submenus open to\n the side; auto-reverses when they flip to the opposite inline edge */\n --uktdd-submenu-gap: 0px;\n --uktdd-menubar-trigger-bg-color-active: rgba(0, 0, 0, 0.12);\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 /* the body renders in the top layer via popover=\"manual\" so an ancestor’s\n transform / filter / contain can’t become its containing block, and the\n top layer handles stacking (no z-index). The UA-popover box resets that\n must beat a consumer’s global [popover] styles live in the\n div.uktdropdown-body rule below; these cosmetics stay overridable */\n color: inherit;\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 /* an active item is on the path — not deepest — while a deeper highlight\n exists or the pointer is inside its submenu; macOS mutes the parent\n even when the pointer is over a separator or disabled submenu item */\n [data-ukt-active]:has([data-ukt-submenu] [data-ukt-active]),\n [data-ukt-active]:has([data-ukt-submenu]:hover) {\n background-color: var(--uktdd-body-bg-color-path);\n color: var(--uktdd-body-color-path);\n }\n\n [data-ukt-item][aria-disabled=\"true\"] {\n opacity: 0.5;\n pointer-events: none;\n }\n\n /* the expanded parent item anchors its submenu; anchor-scope keeps each\n level’s submenu bound to its own parent item */\n [data-ukt-item] {\n anchor-scope: --uktdd-submenu-anchor;\n }\n\n /* parent items get a macOS-style disclosure chevron, right-aligned */\n :is([data-ukt-item], [data-ukt-value])[aria-haspopup=\"menu\"] {\n position: relative;\n padding-inline-end: 2em;\n\n &::after {\n content: \"\";\n position: absolute;\n inset-inline-end: 0.9em;\n inset-block-start: 50%;\n inline-size: 0.3em;\n block-size: 0.3em;\n border-block-start: 0.14em solid currentColor;\n border-inline-end: 0.14em solid currentColor;\n translate: 0 -50%;\n rotate: 45deg;\n }\n\n &:dir(rtl)::after {\n rotate: -45deg;\n }\n }\n\n [data-ukt-item][aria-expanded=\"true\"] {\n anchor-name: --uktdd-submenu-anchor;\n\n > [data-ukt-submenu] {\n display: block;\n }\n }\n\n [data-ukt-submenu] {\n box-sizing: border-box;\n display: none;\n /* an explicit color so items don’t inherit the white highlight color\n from their active parent item (the submenu is its DOM child) */\n color: var(--uktdd-body-color);\n position: fixed;\n position-anchor: --uktdd-submenu-anchor;\n position-area: var(--uktdd-submenu-position-area);\n position-try-fallbacks: var(--uktdd-submenu-position-try-fallbacks);\n z-index: 2;\n margin-block: 0;\n margin-inline: var(--uktdd-submenu-gap);\n padding: var(--uktdd-body-pad-top) var(--uktdd-body-pad-right)\n var(--uktdd-body-pad-bottom) var(--uktdd-body-pad-left);\n inline-size: max-content;\n max-inline-size: var(--uktdd-body-max-width);\n max-block-size: var(--uktdd-body-max-height);\n overflow: auto;\n overscroll-behavior: contain;\n list-style: none;\n background-color: var(--uktdd-body-bg-color);\n box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);\n }\n}\n\n/* The body is a popover, so a consumer’s global [popover] rules match it and\n tie .uktdropdown-body on specificity (both 0,1,0), letting source order\n decide — which can clobber the body’s box geometry. Reset the UA-popover box\n at div.uktdropdown-body (0,1,1): the lightest bump that still beats a bare\n [popover] (0,1,0), so the layout holds regardless of a consumer’s popover\n styles, while the body’s cosmetics stay overridable at 0,1,0. */\ndiv.uktdropdown-body {\n inset: auto;\n block-size: auto;\n margin-block: var(--uktdd-body-gap);\n margin-inline: 0;\n border: 0;\n padding: 0;\n}\n\n.uktmenubar {\n display: flex;\n align-items: stretch;\n width: max-content;\n font-family: var(--uktdd-font-family);\n\n /* the open menu’s trigger reads as active, like the highlighted item in\n the macOS menu bar; the default tints over whatever background the\n trigger already has, so it works regardless of how it’s styled */\n .uktdropdown.is-open .uktdropdown-trigger {\n box-shadow: inset 0 0 0 100vmax var(--uktdd-menubar-trigger-bg-color-active);\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\n@position-try --uktdd-submenu-inline-start {\n position-area: inline-start span-block-end;\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]';\nexport const SUBMENU_SELECTOR = '[data-ukt-submenu]';\n\nconst DISABLED_ITEM_SELECTOR = '[aria-disabled=\"true\"]';\n\nexport type OnToggleSubmenu = (item: HTMLElement, isExpanded: boolean) => void;\n\ntype MaybeHTMLElement = HTMLElement | null;\n\nconst getBodyElement = (dropdownElement: MaybeHTMLElement) =>\n (dropdownElement?.querySelector('.uktdropdown-body') ?? null) as MaybeHTMLElement;\n\n// The level root that owns an item: the closest [data-ukt-submenu] ancestor,\n// or null for items at the top level of the dropdown body\nexport const getLevelRoot = (element: HTMLElement) =>\n element.closest(SUBMENU_SELECTOR) as MaybeHTMLElement;\n\n// An item’s own submenu (a parent item), excluding submenus of descendant items\nexport const getSubmenuOfItem = (item: HTMLElement): MaybeHTMLElement => {\n const submenu = item.querySelector(SUBMENU_SELECTOR) as MaybeHTMLElement;\n if (!submenu) return null;\n const owner = submenu.parentElement?.closest(ITEM_SELECTOR);\n return owner === item ? submenu : null;\n};\n\n// The parent item that owns a submenu level\nexport const getParentItem = (levelRoot: HTMLElement) =>\n (levelRoot.parentElement?.closest(ITEM_SELECTOR) ?? null) as MaybeHTMLElement;\n\n// A parent item’s label is its text content excluding the submenu subtree\nexport const getItemLabel = (item: HTMLElement): string => {\n if (!getSubmenuOfItem(item)) return item.innerText ?? '';\n const clone = item.cloneNode(true) as HTMLElement;\n for (const submenu of Array.from(clone.querySelectorAll(SUBMENU_SELECTOR))) {\n submenu.remove();\n }\n return (clone.textContent ?? '').trim();\n};\n\n// Ancestor parent items from the root level down to the element’s immediate parent\nexport const getItemPath = (element: MaybeHTMLElement): Item['path'] => {\n const path: Item['path'] = [];\n if (!element) return path;\n let levelRoot = getLevelRoot(element);\n while (levelRoot) {\n const parentItem = getParentItem(levelRoot);\n if (!parentItem) break;\n const label = getItemLabel(parentItem);\n path.unshift({ label, value: parentItem.dataset.uktValue ?? label });\n levelRoot = getLevelRoot(parentItem);\n }\n return path;\n};\n\nexport const getItemElements = (\n dropdownElement: MaybeHTMLElement,\n levelRoot?: MaybeHTMLElement,\n): Array<HTMLElement> | null => {\n const bodyElement = getBodyElement(dropdownElement);\n if (!bodyElement) return null;\n\n const root = levelRoot ?? bodyElement;\n const candidates = Array.from(\n root.querySelectorAll(ITEM_SELECTOR),\n ) as Array<HTMLElement>;\n\n if (candidates.length) {\n return candidates.filter((item) => {\n if (item.matches(DISABLED_ITEM_SELECTOR)) return false;\n return getLevelRoot(item) === (levelRoot ?? null);\n });\n }\n\n // If no items found via [data-ukt-item] or [data-ukt-value] selector,\n // use first instance of multiple children found — flat bodies and flat\n // submenu levels alike\n let items: HTMLCollection = root.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 = root.children;\n }\n return (Array.from(items) as Array<HTMLElement>).filter(\n (item) => !item.matches(DISABLED_ITEM_SELECTOR),\n );\n};\n\n// The item an event target belongs to within its own level: the closest\n// marked item, or — when the target sits in a level with no marked items\n// (a heuristically-detected level) — the target itself if it’s one of that\n// level’s detected items. Misses (body padding, separators) and disabled\n// items resolve to null.\nexport const getItemForTarget = (\n dropdownElement: HTMLElement,\n target: HTMLElement,\n): MaybeHTMLElement => {\n let item = target.closest(ITEM_SELECTOR) as MaybeHTMLElement;\n // If nothing matched, or the target sits in a deeper level than the\n // matched item (an unmarked, heuristically-detected submenu level),\n // resolve the item within the target’s own level instead\n const targetLevelRoot = getLevelRoot(target);\n if (!item || (targetLevelRoot && item.contains(targetLevelRoot))) {\n const itemElements = getItemElements(dropdownElement, targetLevelRoot);\n item = itemElements?.find((itemElement) => itemElement === target) ?? item;\n }\n if (!item || !dropdownElement.contains(item)) return null;\n if (item.matches(DISABLED_ITEM_SELECTOR)) return null;\n return item;\n};\n\n// All active items, in document order (ancestors before descendants)\nexport const getActiveItemElements = (dropdownElement: MaybeHTMLElement) => {\n if (!dropdownElement) return null;\n const actives = dropdownElement.querySelectorAll('[data-ukt-active]');\n return actives.length ? (Array.from(actives) as Array<HTMLElement>) : null;\n};\n\n// The deepest active item — the one keyboard input operates on\nexport const getActiveItemElement = (dropdownElement: MaybeHTMLElement) => {\n const actives = getActiveItemElements(dropdownElement);\n return actives ? actives[actives.length - 1] : null;\n};\n\n// The deepest expanded parent item — the one whose submenu is the innermost\n// open one — in document order\nexport const getDeepestExpandedItem = (\n dropdownElement: MaybeHTMLElement,\n): MaybeHTMLElement => {\n if (!dropdownElement) return null;\n const expanded = (\n Array.from(\n dropdownElement.querySelectorAll('[aria-expanded=\"true\"]'),\n ) as Array<HTMLElement>\n ).filter((element) => element.matches(ITEM_SELECTOR));\n return expanded.length ? expanded[expanded.length - 1] : null;\n};\n\nexport const isItemExpanded = (item: HTMLElement) =>\n item.getAttribute('aria-expanded') === 'true';\n\nlet submenuIdCounter = 0;\n\nconst ensureSubmenuAria = (item: HTMLElement, submenu: HTMLElement) => {\n if (!submenu.hasAttribute('role')) submenu.setAttribute('role', 'menu');\n if (!submenu.id) submenu.id = `uktdd-submenu-${++submenuIdCounter}`;\n if (!item.hasAttribute('aria-haspopup')) item.setAttribute('aria-haspopup', 'menu');\n if (!item.hasAttribute('aria-expanded')) item.setAttribute('aria-expanded', 'false');\n if (!item.hasAttribute('aria-controls')) {\n item.setAttribute('aria-controls', submenu.id);\n }\n};\n\n// Fill in submenu/parent-item ARIA (only what the consumer hasn’t set)\nexport const annotateParentItems = (bodyElement: MaybeHTMLElement) => {\n if (!bodyElement) return;\n for (const submenu of Array.from(bodyElement.querySelectorAll(SUBMENU_SELECTOR))) {\n const item = getParentItem(submenu as HTMLElement);\n if (item) ensureSubmenuAria(item, submenu as HTMLElement);\n }\n};\n\nexport const expandItem = (item: HTMLElement, onToggleSubmenu?: OnToggleSubmenu) => {\n const submenu = getSubmenuOfItem(item);\n if (!submenu) return;\n ensureSubmenuAria(item, submenu);\n if (isItemExpanded(item)) return;\n item.setAttribute('aria-expanded', 'true');\n onToggleSubmenu?.(item, true);\n};\n\nexport const collapseItem = (item: HTMLElement, onToggleSubmenu?: OnToggleSubmenu) => {\n if (!isItemExpanded(item)) return;\n const submenu = getSubmenuOfItem(item);\n if (submenu) {\n // Collapse any expanded descendants first so their state can’t leak\n // into the next disclosure and their onClose callbacks fire\n // (recursion makes the collapse order deepest-first)\n const expandedDescendants = (\n Array.from(\n submenu.querySelectorAll('[aria-expanded=\"true\"]'),\n ) as Array<HTMLElement>\n ).filter((descendant) => descendant.matches(ITEM_SELECTOR));\n for (const descendant of expandedDescendants) {\n collapseItem(descendant, onToggleSubmenu);\n }\n for (const active of Array.from(submenu.querySelectorAll('[data-ukt-active]'))) {\n delete (active as HTMLElement).dataset.uktActive;\n }\n }\n item.setAttribute('aria-expanded', 'false');\n onToggleSubmenu?.(item, false);\n};\n\n// Collapse every expanded parent item that isn’t an ancestor of element\n// (element == null collapses all), deepest-first\nexport const collapseItemsOutsidePath = (\n dropdownElement: MaybeHTMLElement,\n element: MaybeHTMLElement,\n onToggleSubmenu?: OnToggleSubmenu,\n) => {\n const bodyElement = getBodyElement(dropdownElement);\n if (!bodyElement) return;\n const expandedItems = (\n Array.from(\n bodyElement.querySelectorAll('[aria-expanded=\"true\"]'),\n ) as Array<HTMLElement>\n ).filter((item) => item.matches(ITEM_SELECTOR));\n for (const item of expandedItems.reverse()) {\n if (element && item.contains(element)) continue;\n collapseItem(item, onToggleSubmenu);\n }\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 // Also clear active state in any deeper levels within this item\n for (const active of Array.from(\n itemElement.querySelectorAll('[data-ukt-active]'),\n )) {\n delete (active as HTMLElement).dataset.uktActive;\n }\n });\n};\n\n// Make the active set exactly the chain of element + its ancestor parent items\nconst setActiveChain = (dropdownElement: HTMLElement, element: HTMLElement) => {\n const chain = new Set<HTMLElement>([element]);\n let levelRoot = getLevelRoot(element);\n while (levelRoot) {\n const parentItem = getParentItem(levelRoot);\n if (!parentItem) break;\n chain.add(parentItem);\n levelRoot = getLevelRoot(parentItem);\n }\n for (const active of getActiveItemElements(dropdownElement) ?? []) {\n if (!chain.has(active)) delete active.dataset.uktActive;\n }\n for (const item of chain) {\n item.setAttribute('data-ukt-active', '');\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'>)): MaybeHTMLElement => {\n const currentDeepest = getActiveItemElement(dropdownElement);\n // Keys and text operate on the current level (the level of the deepest\n // active item); activating an element directly targets its own level\n const levelRoot = element\n ? getLevelRoot(element)\n : currentDeepest\n ? getLevelRoot(currentDeepest)\n : null;\n\n const itemElements = getItemElements(dropdownElement, levelRoot);\n if (!itemElements || itemElements.length === 0) return currentDeepest;\n\n const lastIndex = itemElements.length - 1;\n const currentActiveIndex = itemElements.findIndex(\n (itemElement) => itemElement === currentDeepest,\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 if (nextActiveIndex === -1) return currentDeepest;\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 null;\n }\n\n const itemTexts = itemElements.map(getItemLabel);\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 = itemElements[nextActiveIndex] as MaybeHTMLElement;\n if (nextActiveItem == null || nextActiveItem === currentDeepest) {\n return currentDeepest;\n }\n\n setActiveChain(dropdownElement, nextActiveItem);\n const label = getItemLabel(nextActiveItem);\n const value = nextActiveItem.dataset.uktValue ?? label;\n onActiveItem?.({\n element: nextActiveItem,\n event,\n label,\n path: getItemPath(nextActiveItem),\n value,\n });\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 return nextActiveItem;\n};\n\nexport type Point = { x: number; y: number };\n\n// Whether a point is inside (or on an edge of) triangle a-b-c, from the sign\n// of the cross product for each edge: all the same sign ⇒ inside\nexport const isPointInTriangle = (p: Point, a: Point, b: Point, c: Point): boolean => {\n const cross = (u: Point, v: Point, w: Point) =>\n (u.x - w.x) * (v.y - w.y) - (v.x - w.x) * (u.y - w.y);\n const d1 = cross(p, a, b);\n const d2 = cross(p, b, c);\n const d3 = cross(p, c, a);\n const hasNegative = d1 < 0 || d2 < 0 || d3 < 0;\n const hasPositive = d1 > 0 || d2 > 0 || d3 > 0;\n return !(hasNegative && hasPositive);\n};\n","import clsx from 'clsx';\nimport {\n type CSSProperties,\n type FocusEvent as ReactFocusEvent,\n type KeyboardEvent as ReactKeyboardEvent,\n type MouseEvent as ReactMouseEvent,\n type ReactNode,\n useMemo,\n useRef,\n} from 'react';\n\nimport {\n MenubarContext,\n type MenubarContextValue,\n type MenubarMember,\n} from './context.js';\n\nexport type MenubarProps = {\n children: ReactNode;\n className?: string;\n style?: CSSProperties;\n};\n\nconst compareDocumentOrder = (a: MenubarMember, b: MenubarMember) => {\n if (a.element === b.element) return 0;\n const position = a.element.compareDocumentPosition(b.element);\n if ((position & Node.DOCUMENT_POSITION_FOLLOWING) !== 0) return -1;\n if ((position & Node.DOCUMENT_POSITION_PRECEDING) !== 0) return 1;\n return 0;\n};\n\n// Matches interactive controls that live in the menubar without being dropdown\n// triggers (e.g. a plain button). Hovering one clears the open menu without\n// disengaging the menubar.\nconst NON_MENU_CONTROL_SELECTOR = 'a[href], button, input, select, textarea, [tabindex]';\n\n// Combines sibling Dropdowns into a single menu, like the system menu in the\n// top toolbar of macOS: one menu open at a time, ←/→ move between menus, and\n// once any menu is open, hovering or focusing another trigger switches to it.\nexport default function Menubar({ children, className, style }: MenubarProps) {\n const membersRef = useRef<Set<MenubarMember>>(new Set());\n // The member that engaged the bar (menu-mode). It keeps pointing at that\n // member even if that member’s menu was closed by hovering a non-menu\n // control, which allows the bar to stay engaged even with nothing open.\n const engagedMemberRef = useRef<HTMLElement | null>(null);\n\n const getOrderedMembersRef = useRef(() =>\n Array.from(membersRef.current).sort(compareDocumentOrder),\n );\n const getOrderedMembers = getOrderedMembersRef.current;\n\n const contextValue: MenubarContextValue = useMemo(\n () => ({\n moveOpen(fromElement: HTMLElement, direction: -1 | 1) {\n const members = getOrderedMembersRef.current();\n if (members.length < 2) return;\n const index = members.findIndex(\n (member) => member.element === fromElement,\n );\n if (index === -1) return;\n const nextIndex = (index + direction + members.length) % members.length;\n members[index].close();\n members[nextIndex].open();\n members[nextIndex].focusTrigger();\n },\n notifyClosed(element: HTMLElement) {\n // Only a dismissal of the member that engaged the bar ends\n // menu-mode. Outside-click handling closes every mounted\n // dropdown, so ignore the closes reported for the rest.\n if (engagedMemberRef.current === element) {\n engagedMemberRef.current = null;\n }\n },\n notifyOpened(element: HTMLElement) {\n engagedMemberRef.current = element;\n for (const member of membersRef.current) {\n if (member.element !== element && member.isOpen()) {\n member.close();\n }\n }\n },\n registerMember(member: MenubarMember) {\n membersRef.current.add(member);\n return () => {\n membersRef.current.delete(member);\n };\n },\n }),\n [],\n );\n\n // Rove focus between triggers with ←/→ while no menu is open (the open\n // dropdown’s own key handling slides the open menu between triggers)\n const handleKeyDown = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n const { key } = event;\n if (key !== 'ArrowLeft' && key !== 'ArrowRight') return;\n const members = getOrderedMembers();\n if (members.length < 2) return;\n if (members.some((member) => member.isOpen())) return;\n const eventTarget = event.target as HTMLElement;\n const index = members.findIndex((member) => member.element.contains(eventTarget));\n if (index === -1) return;\n event.preventDefault();\n event.stopPropagation();\n const direction = key === 'ArrowRight' ? 1 : -1;\n members[(index + direction + members.length) % members.length].focusTrigger();\n };\n\n // Once the bar is engaged, moving hover or focus onto another member’s\n // trigger switches to it (opening notifies the menubar, which closes the\n // other open member), while moving onto a non-menu control clears the open\n // menu but keeps the bar engaged.\n const switchToMemberAt = (eventTarget: HTMLElement) => {\n if (engagedMemberRef.current == null) return;\n const members = getOrderedMembers();\n // If the member that engaged the bar is gone (e.g. it unmounted while\n // engaged) the bar is no longer engaged, so hover can’t reopen menus\n if (!members.some((m) => m.element === engagedMemberRef.current)) {\n engagedMemberRef.current = null;\n return;\n }\n const member = members.find((m) => m.element.contains(eventTarget));\n if (member) {\n if (!member.isOpen()) member.open();\n return;\n }\n // Not over a menu trigger: only a real non-menu control (not the bar’s\n // padding or the gaps between triggers) clears the open menu — this is\n // a menubar-driven close, so the members stay engaged.\n if (!eventTarget.closest(NON_MENU_CONTROL_SELECTOR)) return;\n for (const openMember of members) {\n if (openMember.isOpen()) openMember.close();\n }\n };\n\n const handleFocus = (event: ReactFocusEvent<HTMLDivElement>) => {\n switchToMemberAt(event.target as HTMLElement);\n };\n\n const handleMouseOver = (event: ReactMouseEvent<HTMLDivElement>) => {\n switchToMemberAt(event.target as HTMLElement);\n };\n\n return (\n <div\n className={clsx('uktmenubar', className)}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onMouseOver={handleMouseOver}\n role=\"menubar\"\n style={style}\n >\n <MenubarContext.Provider value={contextValue}>\n {children}\n </MenubarContext.Provider>\n </div>\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 useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport {\n DropdownContext,\n type DropdownContextValue,\n MenubarContext,\n type SubmenuRegistration,\n} from './context.js';\nimport styles from './Dropdown.css?inline';\nimport {\n annotateParentItems,\n collapseItem,\n collapseItemsOutsidePath,\n expandItem,\n getActiveItemElement,\n getDeepestExpandedItem,\n getItemElements,\n getItemForTarget,\n getItemPath,\n getLevelRoot,\n getParentItem,\n getSubmenuOfItem,\n isItemExpanded,\n isPointInTriangle,\n type Point,\n setActiveItem,\n} from './helpers.js';\n\nexport type Item = {\n element: MaybeHTMLElement;\n event: Event | SyntheticEvent<HTMLElement>;\n label: string;\n /**\n * Ancestor parent items from the root level down to the item’s\n * immediate parent. Empty for top-level items.\n */\n path: Array<ItemPathEntry>;\n value: string;\n};\n\nexport type ItemPathEntry = { label: string; value: string };\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 submitting with no item active emits an empty\n * value (i.e. clears the value). Only has an effect when the dropdown has a\n * text input to source that value from — a searchable dropdown’s search\n * input, or a text input inside a custom trigger. With no such input there\n * is no value to submit, so submitting with nothing selected is a no-op\n * regardless; clear such a dropdown with an explicit empty-valued item\n * instead. 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 hasItems?: boolean;\n isOpenOnMount?: boolean;\n isSearchable?: boolean;\n keepOpenOnSubmit?: boolean;\n /**\n * Label content for the trigger button (when using single child syntax).\n * For a nested (submenu) Dropdown, this is the parent item’s content.\n */\n label?: ReactNode;\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 /**\n * Applied to the dropdown root element. Also accepts the component’s CSS\n * custom properties (e.g. `--uktdd-body-min-width`) for per-instance\n * placement and sizing, which plain `CSSProperties` rejects.\n */\n style?: CSSProperties & Record<`--${string}`, string | number | undefined>;\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 FOCUSABLE_SELECTOR = 'a[href], button, input, select, textarea, [tabindex]';\nconst TEXT_INPUT_SELECTOR =\n 'input:not([type=radio]):not([type=checkbox]):not([type=range]),textarea';\n\n// Matches macOS: quick, natural arrowing past parent items never flashes\n// their submenus, but a brief pause discloses. Frame-stepping macOS menus\n// puts its delay around 200–250ms; anything much shorter flashes\nconst SUBMENU_DISCLOSURE_DELAY = 200;\n\n// How long the pointer can dwell inside the safe area (heading toward an open\n// submenu) before we give up and switch to whatever it’s actually over. Reset\n// on every move, so it only fires on a pause — motion keeps the submenu open\nconst SAFE_AREA_TIMEOUT = 300;\n\nexport default function Dropdown(props: Props) {\n const parentDropdown = useContext(DropdownContext);\n // A Dropdown nested inside a menu dropdown’s body renders as a submenu\n // (a parent item delegating to the root engine). A hasItems={false}\n // dropdown provides no submenu context, so a Dropdown nested inside one —\n // or a hasItems={false} Dropdown anywhere — renders independently instead.\n if (parentDropdown && props.hasItems !== false) {\n return <SubmenuDropdown {...props} parentDropdown={parentDropdown} />;\n }\n return <RootDropdown {...props} />;\n}\n\nfunction RootDropdown({\n allowCreate,\n allowEmpty = true,\n children,\n className,\n disabled,\n hasItems = true,\n isOpenOnMount,\n isSearchable,\n keepOpenOnSubmit = !hasItems,\n label,\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 menubar = useContext(MenubarContext);\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 const disclosureTimerRef = useRef<null | TimeoutID>(null);\n const pendingDisclosureItemRef = useRef<MaybeHTMLElement>(null);\n const submenuRegistrationsRef = useRef<Set<SubmenuRegistration>>(new Set());\n const pointerRef = useRef<Point | null>(null);\n const lastMouseEventRef = useRef<MouseEvent | null>(null);\n const safeAreaRef = useRef<{ apex: Point; parent: HTMLElement } | null>(null);\n const safeAreaTimerRef = useRef<null | TimeoutID>(null);\n const wasInSafeAreaRef = useRef<boolean>(false);\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 // Nested (submenu) Dropdowns register here so their scoped callbacks\n // (onActiveItem/onOpen/onClose/onSubmitItem) can be dispatched to them\n const dropdownContextValue: DropdownContextValue = useMemo(\n () => ({\n registerSubmenu(registration: SubmenuRegistration) {\n submenuRegistrationsRef.current.add(registration);\n return () => {\n submenuRegistrationsRef.current.delete(registration);\n };\n },\n }),\n [],\n );\n\n const dispatchToSubmenus = (key: 'onActiveItem' | 'onSubmitItem', payload: Item) => {\n if (!payload.element) return;\n for (const registration of submenuRegistrationsRef.current) {\n if (registration.element.contains(payload.element)) {\n registration[key]?.(payload);\n }\n }\n };\n\n const handleActiveItem = (payload: Item) => {\n onActiveItem?.(payload);\n dispatchToSubmenus('onActiveItem', payload);\n };\n\n const handleToggleSubmenu = (item: HTMLElement, isExpanded: boolean) => {\n for (const registration of submenuRegistrationsRef.current) {\n if (registration.element === item) {\n (isExpanded ? registration.onOpen : registration.onClose)?.();\n }\n }\n };\n\n const clearDisclosureTimer = () => {\n if (disclosureTimerRef.current != null) {\n clearTimeout(disclosureTimerRef.current);\n disclosureTimerRef.current = null;\n }\n pendingDisclosureItemRef.current = null;\n };\n\n // Clear the disclosure intent timer on unmount so it can’t fire against\n // unmounted DOM or dispatch submenu callbacks after teardown\n useEffect(() => clearDisclosureTimer, []);\n\n // A parent item discloses its submenu after a short intent delay whenever\n // it becomes (and stays) the deepest active item, for pointer and keyboard\n // alike; submenus off the active path collapse immediately\n const syncSubmenuDisclosure = () => {\n if (!dropdownElement) return;\n const activeElement = getActiveItemElement(dropdownElement);\n collapseItemsOutsidePath(dropdownElement, activeElement, handleToggleSubmenu);\n const submenu = activeElement ? getSubmenuOfItem(activeElement) : null;\n if (activeElement && submenu && !isItemExpanded(activeElement)) {\n // A timer already pending for this item keeps its original start time\n if (pendingDisclosureItemRef.current === activeElement) return;\n clearDisclosureTimer();\n pendingDisclosureItemRef.current = activeElement;\n disclosureTimerRef.current = setTimeout(() => {\n disclosureTimerRef.current = null;\n pendingDisclosureItemRef.current = null;\n if (!activeElement.hasAttribute('data-ukt-active')) return;\n expandItem(activeElement, handleToggleSubmenu);\n }, SUBMENU_DISCLOSURE_DELAY);\n return;\n }\n clearDisclosureTimer();\n };\n\n const clearSafeAreaTimer = () => {\n if (safeAreaTimerRef.current != null) {\n clearTimeout(safeAreaTimerRef.current);\n safeAreaTimerRef.current = null;\n }\n };\n\n // Clear the safe-area give-up timer on unmount so it can’t fire against\n // unmounted DOM\n useEffect(() => clearSafeAreaTimer, []);\n\n // The safe area is the triangle from where the pointer last sat on the\n // open submenu’s parent (the apex) to that submenu’s two near corners.\n // While the pointer is inside it, it’s traveling toward the submenu, so the\n // submenu stays open even as the pointer crosses sibling items — the macOS\n // diagonal behavior\n const isPointerInSafeArea = (x: number, y: number): boolean => {\n const safeArea = safeAreaRef.current;\n if (!safeArea || !isItemExpanded(safeArea.parent)) return false;\n const submenu = getSubmenuOfItem(safeArea.parent);\n if (!submenu) return false;\n const submenuRect = submenu.getBoundingClientRect();\n const parentRect = safeArea.parent.getBoundingClientRect();\n // Submenus can open to either side; the near edge is the one facing\n // the parent item\n const nearX =\n submenuRect.left >= parentRect.right - 1\n ? submenuRect.left\n : submenuRect.right;\n return isPointInTriangle(\n { x, y },\n safeArea.apex,\n { x: nearX, y: submenuRect.top },\n { x: nearX, y: submenuRect.bottom },\n );\n };\n\n // The pointer left the safe area (or paused in it without reaching the\n // submenu): stop protecting the submenu and switch to whatever the pointer\n // is over now. Passing the target avoids an elementFromPoint read; the\n // give-up timer has no event, so it falls back to hit-testing the pointer\n const commitPointerTarget = (targetElement?: MaybeHTMLElement) => {\n clearSafeAreaTimer();\n safeAreaRef.current = null;\n wasInSafeAreaRef.current = false;\n const pointer = pointerRef.current;\n const target =\n targetElement ??\n (pointer\n ? (dropdownElement?.ownerDocument.elementFromPoint(\n pointer.x,\n pointer.y,\n ) as MaybeHTMLElement)\n : null);\n if (!dropdownElement || !target || !dropdownElement.contains(target)) return;\n const item = getItemForTarget(dropdownElement, target);\n const event = lastMouseEventRef.current;\n // Only reachable via mouse events, so a real mouse event is on hand\n if (item && event) {\n setActiveItem({\n dropdownElement,\n element: item,\n event,\n onActiveItem: handleActiveItem,\n });\n }\n syncSubmenuDisclosure();\n };\n\n // Track the pointer against the open submenu’s safe area: anchor the apex\n // while over the parent item, and (re)arm the give-up timer while traveling\n // toward the submenu so only a pause — not motion — ends the protection\n const trackSafeArea = (event: ReactMouseEvent<HTMLElement>) => {\n // Safe-area intent only applies to an open menu with items; skip the\n // per-move DOM query otherwise (mousemove is a hot path)\n if (!dropdownElement || !isOpenRef.current || !hasItemsRef.current) return;\n const pointer = { x: event.clientX, y: event.clientY };\n pointerRef.current = pointer;\n lastMouseEventRef.current = event.nativeEvent;\n const parent = getDeepestExpandedItem(dropdownElement);\n if (!parent) {\n safeAreaRef.current = null;\n wasInSafeAreaRef.current = false;\n clearSafeAreaTimer();\n return;\n }\n const target = event.target as HTMLElement;\n const submenu = getSubmenuOfItem(parent);\n const isOverParent =\n parent.contains(target) && !(submenu?.contains(target) ?? false);\n if (isOverParent) {\n safeAreaRef.current = { apex: pointer, parent };\n wasInSafeAreaRef.current = false;\n clearSafeAreaTimer();\n return;\n }\n // A newly-open submenu we haven’t anchored an apex for yet\n if (safeAreaRef.current?.parent !== parent) {\n safeAreaRef.current = null;\n }\n clearSafeAreaTimer();\n if (isPointerInSafeArea(pointer.x, pointer.y)) {\n wasInSafeAreaRef.current = true;\n safeAreaTimerRef.current = setTimeout(commitPointerTarget, SAFE_AREA_TIMEOUT);\n } else if (wasInSafeAreaRef.current) {\n // Just crossed out of the triangle. The pointer may still be over\n // the same sibling it entered while protected, so no mouseover will\n // fire — re-evaluate and activate whatever it’s on now\n commitPointerTarget(target);\n }\n };\n\n const closeDropdown = (options?: { keepMenubarEngaged?: boolean }) => {\n setIsOpen(false);\n setIsOpening(false);\n mouseDownPositionRef.current = null;\n clearDisclosureTimer();\n clearSafeAreaTimer();\n safeAreaRef.current = null;\n wasInSafeAreaRef.current = false;\n if (closingTimerRef.current != null) {\n clearTimeout(closingTimerRef.current);\n closingTimerRef.current = null;\n }\n // A self-dismissal — Escape, an outside click, or an item selection —\n // takes an enclosing menubar out of menu-mode. Switching menus,\n // clearing the open menu on hover, and focus changes pass\n // keepMenubarEngaged to stay in menu-mode.\n if (menubar && dropdownElement && !options?.keepMenubarEngaged) {\n menubar.notifyClosed(dropdownElement);\n }\n };\n\n const focusTrigger = () => {\n const firstChild = dropdownElement?.firstElementChild as MaybeHTMLElement;\n if (!firstChild) return;\n const focusable = firstChild.matches(FOCUSABLE_SELECTOR)\n ? firstChild\n : (firstChild.querySelector(FOCUSABLE_SELECTOR) as MaybeHTMLElement);\n focusable?.focus();\n };\n\n // Register with an enclosing Menubar (one open menu at a time, ←/→\n // moves between menus, hover-to-switch once any menu is open). Closing\n // goes through closeDropdown so pending timers (submenu disclosure,\n // close delay) can’t fire against a menu the menubar already closed.\n useEffect(() => {\n if (!menubar || !dropdownElement) return;\n return menubar.registerMember({\n close: () => closeDropdown({ keepMenubarEngaged: true }),\n element: dropdownElement,\n focusTrigger,\n isOpen: () => isOpenRef.current,\n open: () => setIsOpen(true),\n });\n });\n\n useEffect(() => {\n if (isOpen && menubar && dropdownElement) {\n menubar.notifyOpened(dropdownElement);\n }\n }, [dropdownElement, isOpen, menubar]);\n\n const handleSubmitItem = (event: Event | React.SyntheticEvent<HTMLElement>) => {\n const element = hasItemsRef.current\n ? getActiveItemElement(dropdownElement)\n : null;\n\n const submenuOfActive = element ? getSubmenuOfItem(element) : null;\n if (element && submenuOfActive) {\n // Parent items disclose; they never submit\n clearDisclosureTimer();\n expandItem(element, handleToggleSubmenu);\n if (currentInputMethodRef.current === 'keyboard' && dropdownElement) {\n const firstItem = getItemElements(dropdownElement, submenuOfActive)?.[0];\n if (firstItem) {\n setActiveItem({\n dropdownElement,\n element: firstItem,\n event,\n onActiveItem: handleActiveItem,\n });\n }\n }\n return;\n }\n\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 if (!element) {\n // With nothing selected, the only possible value comes from a text\n // input (a searchable dropdown’s input, or one inside a custom\n // trigger). No input means there’s no value to submit at all, so\n // bail regardless of allowCreate/allowEmpty instead of firing an\n // empty-valued onSubmitItem consumers have to defend against. (To\n // let such a dropdown clear its value, give it an explicit\n // empty-valued item, which submits as a normal active selection.)\n if (!inputElementRef.current) return;\n if (inputElementRef.current.value) {\n // Non-empty text matching no item is a created value\n if (!allowCreateRef.current) return;\n } else if (!allowEmptyRef.current) {\n // A cleared input is an empty (clearing) submit, which\n // allowEmpty gates even when allowCreate is set — “creating”\n // an empty value is clearing, not creating\n return;\n }\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 const payload: Item = {\n element,\n event,\n label: itemLabel,\n path: getItemPath(element),\n value: nextValue,\n };\n onSubmitItemRef.current?.(payload);\n dispatchToSubmenus('onSubmitItem', payload);\n };\n\n const handleMouseMove = (event: ReactMouseEvent<HTMLElement>) => {\n const { clientX, clientY } = event;\n currentInputMethodRef.current = 'mouse';\n trackSafeArea(event);\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 eventTarget = event.target as HTMLElement;\n if (!eventTarget.closest('.uktdropdown-body')) return;\n\n // Hover inside an open nested dropdown belongs to that dropdown\n const hoveredRoot = eventTarget.closest('.uktdropdown');\n if (\n hoveredRoot !== dropdownElement &&\n hoveredRoot?.classList.contains('is-open')\n ) {\n return;\n }\n\n // Heading toward an open submenu: keep it open even over sibling items\n if (isPointerInSafeArea(event.clientX, event.clientY)) return;\n\n const item = getItemForTarget(dropdownElement, eventTarget);\n if (!item) return;\n\n setActiveItem({\n dropdownElement,\n element: item,\n event,\n onActiveItem: handleActiveItem,\n });\n syncSubmenuDisclosure();\n };\n\n const handleMouseOut = (event: ReactMouseEvent<HTMLElement>) => {\n if (!hasItemsRef.current) return;\n // The pointer left the dropdown entirely: drop the safe area so its\n // give-up timer can’t later fire on a stale position, and fall through\n // to the normal collapse (mousemove has stopped, so nothing else will)\n const relatedTarget = event.relatedTarget as Node | null;\n const isLeavingDropdown = !dropdownElement?.contains(relatedTarget);\n if (isLeavingDropdown) {\n clearSafeAreaTimer();\n safeAreaRef.current = null;\n wasInSafeAreaRef.current = false;\n }\n // Heading toward an open submenu: don’t clear the active item / collapse\n if (isPointerInSafeArea(event.clientX, event.clientY)) 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 syncSubmenuDisclosure();\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\n // Clicks inside an open nested dropdown belong to that dropdown\n const clickedRoot = eventTarget.closest('.uktdropdown');\n if (\n clickedRoot !== dropdownElement &&\n clickedRoot?.classList.contains('is-open') &&\n dropdownElement?.contains(clickedRoot)\n ) {\n return;\n }\n\n // A click only counts as inside the body if the closest body element\n // belongs to this dropdown (a nested dropdown’s trigger sits inside\n // the outer body, but the outer body isn’t the nested one’s own)\n const targetBody = eventTarget.closest('.uktdropdown-body');\n const isInOwnBody = Boolean(\n targetBody && targetBody.closest('.uktdropdown') === dropdownElement,\n );\n // If click was outside dropdown body, don’t trigger submit\n if (!isInOwnBody) {\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 if (dropdownElement) {\n const clickedItem = getItemForTarget(dropdownElement, eventTarget);\n if (clickedItem) {\n // Submit the item the click actually landed on: sync the\n // active item to it in case they diverge (e.g. active was\n // set via keyboard, then user clicked elsewhere)\n setActiveItem({\n dropdownElement,\n element: clickedItem,\n event,\n onActiveItem: handleActiveItem,\n });\n } else if (getActiveItemElement(dropdownElement)) {\n // A click that doesn’t land on an item — body padding, a\n // separator, or a disabled item (pointer-events: none\n // retargets its clicks to the container) — must not submit\n // the previously active item: like macOS, it does nothing.\n // With no active item it falls through, so a body click\n // can still submit an input-sourced value\n return;\n }\n }\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 // Key events originating inside an open nested dropdown are that\n // dropdown’s business (e.g. an info popover nested in this body)\n const nestedRoot = eventTarget.closest?.('.uktdropdown');\n if (\n nestedRoot &&\n nestedRoot !== dropdownElement &&\n dropdownElement.contains(nestedRoot) &&\n nestedRoot.classList.contains('is-open')\n ) {\n return;\n }\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: handleActiveItem,\n text: enteredCharactersRef.current,\n });\n syncSubmenuDisclosure();\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 // Escape closes the whole menu — submenus included — and\n // returns focus to the element that opened it. Focus before\n // closing: a searchable trigger input opens the dropdown on\n // focus, so its synchronous onFocus must land before the\n // close state update for the close to win the batch\n focusTrigger();\n closeDropdown();\n }\n return;\n }\n\n // Handle arrow keys\n if (hasItemsRef.current) {\n if (key === 'ArrowUp') {\n onEventHandled();\n if (altKey || metaKey) {\n setActiveItem({\n dropdownElement,\n event,\n index: 0,\n onActiveItem: handleActiveItem,\n });\n } else {\n setActiveItem({\n dropdownElement,\n event,\n indexAddend: -1,\n onActiveItem: handleActiveItem,\n });\n }\n syncSubmenuDisclosure();\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({\n dropdownElement,\n event,\n index: -1,\n onActiveItem: handleActiveItem,\n });\n } else {\n setActiveItem({\n dropdownElement,\n event,\n indexAddend: 1,\n onActiveItem: handleActiveItem,\n });\n }\n syncSubmenuDisclosure();\n return;\n }\n // ←/→ dive into and surface out of submenus (and move between\n // menus in a menubar); leave them alone when a text input has focus\n if (!isTargetUsingKeyEvents) {\n if (key === 'ArrowRight') {\n const activeElement = getActiveItemElement(dropdownElement);\n const submenu = activeElement\n ? getSubmenuOfItem(activeElement)\n : null;\n if (activeElement && submenu) {\n onEventHandled();\n clearDisclosureTimer();\n expandItem(activeElement, handleToggleSubmenu);\n const firstItem = getItemElements(dropdownElement, submenu)?.[0];\n if (firstItem) {\n setActiveItem({\n dropdownElement,\n element: firstItem,\n event,\n onActiveItem: handleActiveItem,\n });\n }\n return;\n }\n if (menubar) {\n onEventHandled();\n menubar.moveOpen(dropdownElement, 1);\n }\n return;\n }\n if (key === 'ArrowLeft') {\n const activeElement = getActiveItemElement(dropdownElement);\n const levelRoot = activeElement ? getLevelRoot(activeElement) : null;\n if (levelRoot) {\n onEventHandled();\n clearDisclosureTimer();\n const parentItem = getParentItem(levelRoot);\n if (parentItem) {\n collapseItem(parentItem, handleToggleSubmenu);\n }\n return;\n }\n if (menubar) {\n onEventHandled();\n menubar.moveOpen(dropdownElement, -1);\n }\n return;\n }\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 // Losing focus — including the focus shift when the body unmounts\n // on close — doesn’t end a menubar’s menu-mode; that takes a\n // deliberate dismissal (Escape, outside click, item select).\n closeDropdown({ keepMenubarEngaged: true });\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: handleActiveItem,\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 // When the body mounts (open): fill in parent-item/submenu ARIA, and\n // render it in the top layer via popover so an ancestor’s transform /\n // filter / contain can’t become the containing block for the fixed body\n // and break its anchor positioning + fallbacks. popover=\"manual\" keeps\n // dismissal under this component’s own listeners (see handleRef), which\n // preserves iframe support and searchable/text-input triggers that native\n // light-dismiss would close on any outside pointerdown.\n const handleBodyRef = (ref: HTMLDivElement | null) => {\n if (!ref) return;\n annotateParentItems(ref);\n // The Popover API is Baseline 2024, so showPopover() needs no feature\n // detection; the body is mounted only while open, so this runs once\n // per open and won’t throw on an already-open body.\n ref.showPopover();\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 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={styleFromProps}\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 popover=\"manual\"\n ref={handleBodyRef}\n role={popupRole}\n >\n <div className=\"uktdropdown-content\">\n <DropdownContext.Provider\n value={hasItems ? dropdownContextValue : null}\n >\n {childrenCount > 1\n ? (children as ChildrenTuple)[1]\n : children}\n </DropdownContext.Provider>\n </div>\n </div>\n ) : null}\n </div>\n </Fragment>\n );\n}\n\nconst INERT_SUBMENU_PROPS = [\n 'allowCreate',\n 'allowEmpty',\n 'isOpenOnMount',\n 'isSearchable',\n 'keepOpenOnSubmit',\n 'name',\n 'placeholder',\n 'tabIndex',\n 'value',\n] as const;\n\n// The nested (submenu) rendering of Dropdown: a parent item that discloses a\n// child menu. It renders the data-ukt-submenu protocol and registers with the\n// root dropdown, whose engine handles all interaction.\nfunction SubmenuDropdown(props: Props & { parentDropdown: DropdownContextValue }) {\n const {\n children,\n className,\n disabled,\n label,\n onActiveItem,\n onClose,\n onOpen,\n onSubmitItem,\n parentDropdown,\n style,\n } = props;\n\n const itemRef = useRef<HTMLLIElement | null>(null);\n\n useEffect(() => {\n const element = itemRef.current;\n if (!element) return;\n return parentDropdown.registerSubmenu({\n element,\n onActiveItem,\n onClose,\n onOpen,\n onSubmitItem,\n });\n }, [onActiveItem, onClose, onOpen, onSubmitItem, parentDropdown]);\n\n // Misuse feedback is unconditional, like the children-count error above\n const warnedRef = useRef(false);\n useEffect(() => {\n if (warnedRef.current) return;\n const inertProps = INERT_SUBMENU_PROPS.filter(\n (propName) => props[propName] !== undefined,\n );\n if (!inertProps.length) return;\n warnedRef.current = true;\n console.error(\n `@acusti/dropdown: ${inertProps.join(', ')} only apply to a top-level Dropdown and are ignored on a nested (submenu) Dropdown.`,\n );\n });\n\n const childrenCount = Children.count(children);\n let labelContent: ReactNode = label;\n let body: ReactNode = children;\n if (childrenCount > 1) {\n labelContent = (children as ChildrenTuple)[0];\n body = (children as ChildrenTuple)[1];\n }\n\n const submenu = isValidElement(body) ? (\n cloneElement(body as ReactElement<Record<string, unknown>>, {\n 'data-ukt-submenu': '',\n })\n ) : (\n <div data-ukt-submenu=\"\">{body}</div>\n );\n\n return (\n <li\n aria-disabled={disabled || undefined}\n className={className}\n data-ukt-item=\"\"\n ref={itemRef}\n style={style}\n >\n {labelContent}\n {submenu}\n </li>\n );\n}\n\nexport { default as Menubar, type MenubarProps } from './Menubar.js';\n"],"mappings":";;;;;;;AAkBA,IAAaa,kBAAkBb,cAA2C,IAAI;AAiB9E,IAAa2B,iBAAiB3B,cAA0C,IAAI;;;;;;AE9B5E,IAAa+B,gBAAgB;AAC7B,IAAaC,mBAAmB;AAEhC,IAAMC,yBAAyB;AAM/B,IAAMM,kBAAkBC,oBACnBA,iBAAiBC,cAAc,mBAAmB,KAAK;AAI5D,IAAaC,gBAAgBC,YACzBA,QAAQC,QAAQZ,gBAAgB;AAGpC,IAAaa,oBAAoBV,SAAwC;CACrE,MAAMW,UAAUX,KAAKM,cAAcT,gBAAgB;CACnD,IAAI,CAACc,SAAS,OAAO;CAErB,OADcA,QAAQE,eAAeJ,QAAAA,mCAAqB,MAC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AAA;CAAA,OATLsD;AASK"}
|
package/dist/context.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export type SubmenuRegistration = {
|
|
|
12
12
|
export declare const DropdownContext: import("react").Context<DropdownContextValue | null>;
|
|
13
13
|
export type MenubarContextValue = {
|
|
14
14
|
moveOpen: (fromElement: HTMLElement, direction: -1 | 1) => void;
|
|
15
|
+
notifyClosed: (element: HTMLElement) => void;
|
|
15
16
|
notifyOpened: (element: HTMLElement) => void;
|
|
16
17
|
registerMember: (member: MenubarMember) => () => void;
|
|
17
18
|
};
|
package/package.json
CHANGED