@acusti/dropdown 1.0.0-alpha.1 → 1.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -5
- package/dist/Dropdown.d.ts +8 -0
- package/dist/Dropdown.js +311 -235
- package/dist/Dropdown.js.map +1 -1
- package/dist/context.d.ts +1 -0
- package/package.json +1 -1
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
|
}
|
|
@@ -360,6 +371,7 @@ var FOCUSABLE_SELECTOR = "a[href], button, input, select, textarea, [tabindex]";
|
|
|
360
371
|
var TEXT_INPUT_SELECTOR = "input:not([type=radio]):not([type=checkbox]):not([type=range]),textarea";
|
|
361
372
|
var SUBMENU_DISCLOSURE_DELAY = 200;
|
|
362
373
|
var SAFE_AREA_TIMEOUT = 300;
|
|
374
|
+
var HOVER_CLOSE_DELAY = 150;
|
|
363
375
|
function Dropdown(props) {
|
|
364
376
|
const $ = c(5);
|
|
365
377
|
const parentDropdown = useContext(DropdownContext);
|
|
@@ -385,8 +397,8 @@ function Dropdown(props) {
|
|
|
385
397
|
return t0;
|
|
386
398
|
}
|
|
387
399
|
function RootDropdown(t0) {
|
|
388
|
-
const $ = c(
|
|
389
|
-
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;
|
|
400
|
+
const $ = c(147);
|
|
401
|
+
const { allowCreate, allowEmpty: t1, children, className, disabled, hasItems: t2, isOpenOnMount, isSearchable, keepOpenOnSubmit: t3, label, name, onActiveItem, onClick, onClose, onMouseDown, onMouseUp, onOpen, onSubmitItem, openOnHover, placeholder, style: styleFromProps, tabIndex, value } = t0;
|
|
390
402
|
const allowEmpty = t1 === void 0 ? true : t1;
|
|
391
403
|
const hasItems = t2 === void 0 ? true : t2;
|
|
392
404
|
const keepOpenOnSubmit = t3 === void 0 ? !hasItems : t3;
|
|
@@ -423,6 +435,7 @@ function RootDropdown(t0) {
|
|
|
423
435
|
const safeAreaRef = useRef(null);
|
|
424
436
|
const safeAreaTimerRef = useRef(null);
|
|
425
437
|
const wasInSafeAreaRef = useRef(false);
|
|
438
|
+
const hoverCloseTimerRef = useRef(null);
|
|
426
439
|
const allowCreateRef = useRef(allowCreate);
|
|
427
440
|
const allowEmptyRef = useRef(allowEmpty);
|
|
428
441
|
const hasItemsRef = useRef(hasItems);
|
|
@@ -701,74 +714,128 @@ function RootDropdown(t0) {
|
|
|
701
714
|
let t23;
|
|
702
715
|
if ($[37] === Symbol.for("react.memo_cache_sentinel")) {
|
|
703
716
|
t23 = () => {
|
|
717
|
+
if (hoverCloseTimerRef.current != null) {
|
|
718
|
+
clearTimeout(hoverCloseTimerRef.current);
|
|
719
|
+
hoverCloseTimerRef.current = null;
|
|
720
|
+
}
|
|
721
|
+
};
|
|
722
|
+
$[37] = t23;
|
|
723
|
+
} else t23 = $[37];
|
|
724
|
+
const clearHoverCloseTimer = t23;
|
|
725
|
+
let t24;
|
|
726
|
+
let t25;
|
|
727
|
+
if ($[38] === Symbol.for("react.memo_cache_sentinel")) {
|
|
728
|
+
t24 = () => clearHoverCloseTimer;
|
|
729
|
+
t25 = [];
|
|
730
|
+
$[38] = t24;
|
|
731
|
+
$[39] = t25;
|
|
732
|
+
} else {
|
|
733
|
+
t24 = $[38];
|
|
734
|
+
t25 = $[39];
|
|
735
|
+
}
|
|
736
|
+
useEffect(t24, t25);
|
|
737
|
+
let t26;
|
|
738
|
+
if ($[40] !== dropdownElement || $[41] !== menubar) {
|
|
739
|
+
t26 = (options) => {
|
|
704
740
|
setIsOpen(false);
|
|
705
741
|
setIsOpening(false);
|
|
706
742
|
mouseDownPositionRef.current = null;
|
|
707
743
|
clearDisclosureTimer();
|
|
708
744
|
clearSafeAreaTimer();
|
|
745
|
+
clearHoverCloseTimer();
|
|
709
746
|
safeAreaRef.current = null;
|
|
710
747
|
wasInSafeAreaRef.current = false;
|
|
711
748
|
if (closingTimerRef.current != null) {
|
|
712
749
|
clearTimeout(closingTimerRef.current);
|
|
713
750
|
closingTimerRef.current = null;
|
|
714
751
|
}
|
|
752
|
+
if (menubar && dropdownElement && !options?.keepMenubarEngaged) menubar.notifyClosed(dropdownElement);
|
|
715
753
|
};
|
|
716
|
-
$[
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
754
|
+
$[40] = dropdownElement;
|
|
755
|
+
$[41] = menubar;
|
|
756
|
+
$[42] = t26;
|
|
757
|
+
} else t26 = $[42];
|
|
758
|
+
const closeDropdown = t26;
|
|
759
|
+
let t27;
|
|
760
|
+
if ($[43] !== openOnHover) {
|
|
761
|
+
t27 = () => {
|
|
762
|
+
clearHoverCloseTimer();
|
|
763
|
+
if (!openOnHover || isOpenRef.current) return;
|
|
764
|
+
setIsOpen(true);
|
|
765
|
+
setIsOpening(false);
|
|
766
|
+
};
|
|
767
|
+
$[43] = openOnHover;
|
|
768
|
+
$[44] = t27;
|
|
769
|
+
} else t27 = $[44];
|
|
770
|
+
const handleDropdownMouseEnter = t27;
|
|
771
|
+
let t28;
|
|
772
|
+
if ($[45] !== closeDropdown || $[46] !== openOnHover) {
|
|
773
|
+
t28 = () => {
|
|
774
|
+
if (!openOnHover || !isOpenRef.current || hoverCloseTimerRef.current != null) return;
|
|
775
|
+
hoverCloseTimerRef.current = setTimeout(() => {
|
|
776
|
+
hoverCloseTimerRef.current = null;
|
|
777
|
+
closeDropdown();
|
|
778
|
+
}, HOVER_CLOSE_DELAY);
|
|
779
|
+
};
|
|
780
|
+
$[45] = closeDropdown;
|
|
781
|
+
$[46] = openOnHover;
|
|
782
|
+
$[47] = t28;
|
|
783
|
+
} else t28 = $[47];
|
|
784
|
+
const handleDropdownMouseLeave = t28;
|
|
785
|
+
let t29;
|
|
786
|
+
if ($[48] !== dropdownElement?.firstElementChild) {
|
|
787
|
+
t29 = () => {
|
|
722
788
|
const firstChild = dropdownElement?.firstElementChild;
|
|
723
789
|
if (!firstChild) return;
|
|
724
790
|
(firstChild.matches(FOCUSABLE_SELECTOR) ? firstChild : firstChild.querySelector(FOCUSABLE_SELECTOR))?.focus();
|
|
725
791
|
};
|
|
726
|
-
$[
|
|
727
|
-
$[
|
|
728
|
-
} else
|
|
729
|
-
const focusTrigger =
|
|
730
|
-
let
|
|
731
|
-
if ($[
|
|
732
|
-
|
|
792
|
+
$[48] = dropdownElement?.firstElementChild;
|
|
793
|
+
$[49] = t29;
|
|
794
|
+
} else t29 = $[49];
|
|
795
|
+
const focusTrigger = t29;
|
|
796
|
+
let t30;
|
|
797
|
+
if ($[50] !== closeDropdown || $[51] !== dropdownElement || $[52] !== focusTrigger || $[53] !== menubar) {
|
|
798
|
+
t30 = () => {
|
|
733
799
|
if (!menubar || !dropdownElement) return;
|
|
734
800
|
return menubar.registerMember({
|
|
735
|
-
close: closeDropdown,
|
|
801
|
+
close: () => closeDropdown({ keepMenubarEngaged: true }),
|
|
736
802
|
element: dropdownElement,
|
|
737
803
|
focusTrigger,
|
|
738
804
|
isOpen: () => isOpenRef.current,
|
|
739
805
|
open: () => setIsOpen(true)
|
|
740
806
|
});
|
|
741
807
|
};
|
|
742
|
-
$[
|
|
743
|
-
$[
|
|
744
|
-
$[
|
|
745
|
-
$[
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
let
|
|
750
|
-
|
|
751
|
-
|
|
808
|
+
$[50] = closeDropdown;
|
|
809
|
+
$[51] = dropdownElement;
|
|
810
|
+
$[52] = focusTrigger;
|
|
811
|
+
$[53] = menubar;
|
|
812
|
+
$[54] = t30;
|
|
813
|
+
} else t30 = $[54];
|
|
814
|
+
useEffect(t30);
|
|
815
|
+
let t31;
|
|
816
|
+
let t32;
|
|
817
|
+
if ($[55] !== dropdownElement || $[56] !== isOpen || $[57] !== menubar) {
|
|
818
|
+
t31 = () => {
|
|
752
819
|
if (isOpen && menubar && dropdownElement) menubar.notifyOpened(dropdownElement);
|
|
753
820
|
};
|
|
754
|
-
|
|
821
|
+
t32 = [
|
|
755
822
|
dropdownElement,
|
|
756
823
|
isOpen,
|
|
757
824
|
menubar
|
|
758
825
|
];
|
|
759
|
-
$[
|
|
760
|
-
$[
|
|
761
|
-
$[
|
|
762
|
-
$[
|
|
763
|
-
$[
|
|
826
|
+
$[55] = dropdownElement;
|
|
827
|
+
$[56] = isOpen;
|
|
828
|
+
$[57] = menubar;
|
|
829
|
+
$[58] = t31;
|
|
830
|
+
$[59] = t32;
|
|
764
831
|
} else {
|
|
765
|
-
|
|
766
|
-
|
|
832
|
+
t31 = $[58];
|
|
833
|
+
t32 = $[59];
|
|
767
834
|
}
|
|
768
|
-
useEffect(
|
|
769
|
-
let
|
|
770
|
-
if ($[
|
|
771
|
-
|
|
835
|
+
useEffect(t31, t32);
|
|
836
|
+
let t33;
|
|
837
|
+
if ($[60] !== closeDropdown || $[61] !== dropdownElement || $[62] !== handleActiveItem) {
|
|
838
|
+
t33 = (event_1) => {
|
|
772
839
|
const element = hasItemsRef.current ? getActiveItemElement(dropdownElement) : null;
|
|
773
840
|
const submenuOfActive = element ? getSubmenuOfItem(element) : null;
|
|
774
841
|
if (element && submenuOfActive) {
|
|
@@ -823,14 +890,15 @@ function RootDropdown(t0) {
|
|
|
823
890
|
onSubmitItemRef.current?.(payload_1);
|
|
824
891
|
dispatchToSubmenus("onSubmitItem", payload_1);
|
|
825
892
|
};
|
|
826
|
-
$[
|
|
827
|
-
$[
|
|
828
|
-
$[
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
893
|
+
$[60] = closeDropdown;
|
|
894
|
+
$[61] = dropdownElement;
|
|
895
|
+
$[62] = handleActiveItem;
|
|
896
|
+
$[63] = t33;
|
|
897
|
+
} else t33 = $[63];
|
|
898
|
+
const handleSubmitItem = t33;
|
|
899
|
+
let t34;
|
|
900
|
+
if ($[64] !== trackSafeArea) {
|
|
901
|
+
t34 = (event_2) => {
|
|
834
902
|
const { clientX, clientY } = event_2;
|
|
835
903
|
currentInputMethodRef.current = "mouse";
|
|
836
904
|
trackSafeArea(event_2);
|
|
@@ -839,13 +907,13 @@ function RootDropdown(t0) {
|
|
|
839
907
|
if (Math.abs(initialPosition.clientX - clientX) < 12 && Math.abs(initialPosition.clientY - clientY) < 12) return;
|
|
840
908
|
setIsOpening(false);
|
|
841
909
|
};
|
|
842
|
-
$[
|
|
843
|
-
$[
|
|
844
|
-
} else
|
|
845
|
-
const handleMouseMove =
|
|
846
|
-
let
|
|
847
|
-
if ($[
|
|
848
|
-
|
|
910
|
+
$[64] = trackSafeArea;
|
|
911
|
+
$[65] = t34;
|
|
912
|
+
} else t34 = $[65];
|
|
913
|
+
const handleMouseMove = t34;
|
|
914
|
+
let t35;
|
|
915
|
+
if ($[66] !== dropdownElement || $[67] !== handleActiveItem || $[68] !== syncSubmenuDisclosure) {
|
|
916
|
+
t35 = (event_3) => {
|
|
849
917
|
if (!hasItemsRef.current) return;
|
|
850
918
|
if (currentInputMethodRef.current !== "mouse") return;
|
|
851
919
|
if (!dropdownElement) return;
|
|
@@ -864,15 +932,15 @@ function RootDropdown(t0) {
|
|
|
864
932
|
});
|
|
865
933
|
syncSubmenuDisclosure();
|
|
866
934
|
};
|
|
867
|
-
$[
|
|
868
|
-
$[
|
|
869
|
-
$[
|
|
870
|
-
$[
|
|
871
|
-
} else
|
|
872
|
-
const handleMouseOver =
|
|
873
|
-
let
|
|
874
|
-
if ($[
|
|
875
|
-
|
|
935
|
+
$[66] = dropdownElement;
|
|
936
|
+
$[67] = handleActiveItem;
|
|
937
|
+
$[68] = syncSubmenuDisclosure;
|
|
938
|
+
$[69] = t35;
|
|
939
|
+
} else t35 = $[69];
|
|
940
|
+
const handleMouseOver = t35;
|
|
941
|
+
let t36;
|
|
942
|
+
if ($[70] !== dropdownElement || $[71] !== syncSubmenuDisclosure) {
|
|
943
|
+
t36 = (event_4) => {
|
|
876
944
|
if (!hasItemsRef.current) return;
|
|
877
945
|
const relatedTarget = event_4.relatedTarget;
|
|
878
946
|
if (!dropdownElement?.contains(relatedTarget)) {
|
|
@@ -888,14 +956,14 @@ function RootDropdown(t0) {
|
|
|
888
956
|
delete activeItem.dataset.uktActive;
|
|
889
957
|
syncSubmenuDisclosure();
|
|
890
958
|
};
|
|
891
|
-
$[
|
|
892
|
-
$[
|
|
893
|
-
$[
|
|
894
|
-
} else
|
|
895
|
-
const handleMouseOut =
|
|
896
|
-
let
|
|
897
|
-
if ($[
|
|
898
|
-
|
|
959
|
+
$[70] = dropdownElement;
|
|
960
|
+
$[71] = syncSubmenuDisclosure;
|
|
961
|
+
$[72] = t36;
|
|
962
|
+
} else t36 = $[72];
|
|
963
|
+
const handleMouseOut = t36;
|
|
964
|
+
let t37;
|
|
965
|
+
if ($[73] !== onMouseDown) {
|
|
966
|
+
t37 = (event_5) => {
|
|
899
967
|
if (onMouseDown) onMouseDown(event_5);
|
|
900
968
|
if (isOpenRef.current) return;
|
|
901
969
|
setIsOpen(true);
|
|
@@ -909,13 +977,13 @@ function RootDropdown(t0) {
|
|
|
909
977
|
isOpeningTimerRef.current = null;
|
|
910
978
|
}, 1e3);
|
|
911
979
|
};
|
|
912
|
-
$[
|
|
913
|
-
$[
|
|
914
|
-
} else
|
|
915
|
-
const handleMouseDown =
|
|
916
|
-
let
|
|
917
|
-
if ($[
|
|
918
|
-
|
|
980
|
+
$[73] = onMouseDown;
|
|
981
|
+
$[74] = t37;
|
|
982
|
+
} else t37 = $[74];
|
|
983
|
+
const handleMouseDown = t37;
|
|
984
|
+
let t38;
|
|
985
|
+
if ($[75] !== closeDropdown || $[76] !== dropdownElement || $[77] !== handleActiveItem || $[78] !== handleSubmitItem || $[79] !== onMouseUp) {
|
|
986
|
+
t38 = (event_6) => {
|
|
919
987
|
if (onMouseUp) onMouseUp(event_6);
|
|
920
988
|
if (isOpeningRef.current || !isOpenRef.current || closingTimerRef.current != null) return;
|
|
921
989
|
const eventTarget_1 = event_6.target;
|
|
@@ -939,16 +1007,17 @@ function RootDropdown(t0) {
|
|
|
939
1007
|
}
|
|
940
1008
|
handleSubmitItem(event_6);
|
|
941
1009
|
};
|
|
942
|
-
$[
|
|
943
|
-
$[
|
|
944
|
-
$[
|
|
945
|
-
$[
|
|
946
|
-
$[
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
1010
|
+
$[75] = closeDropdown;
|
|
1011
|
+
$[76] = dropdownElement;
|
|
1012
|
+
$[77] = handleActiveItem;
|
|
1013
|
+
$[78] = handleSubmitItem;
|
|
1014
|
+
$[79] = onMouseUp;
|
|
1015
|
+
$[80] = t38;
|
|
1016
|
+
} else t38 = $[80];
|
|
1017
|
+
const handleMouseUp = t38;
|
|
1018
|
+
let t39;
|
|
1019
|
+
if ($[81] !== closeDropdown || $[82] !== dropdownElement || $[83] !== focusTrigger || $[84] !== handleActiveItem || $[85] !== handleSubmitItem || $[86] !== menubar || $[87] !== syncSubmenuDisclosure) {
|
|
1020
|
+
t39 = (event_7) => {
|
|
952
1021
|
const { altKey, ctrlKey, key: key_0, metaKey } = event_7;
|
|
953
1022
|
const eventTarget_2 = event_7.target;
|
|
954
1023
|
if (!dropdownElement) return;
|
|
@@ -1081,28 +1150,29 @@ function RootDropdown(t0) {
|
|
|
1081
1150
|
}
|
|
1082
1151
|
}
|
|
1083
1152
|
};
|
|
1084
|
-
$[
|
|
1085
|
-
$[
|
|
1086
|
-
$[
|
|
1087
|
-
$[
|
|
1088
|
-
$[
|
|
1089
|
-
$[
|
|
1090
|
-
$[
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1153
|
+
$[81] = closeDropdown;
|
|
1154
|
+
$[82] = dropdownElement;
|
|
1155
|
+
$[83] = focusTrigger;
|
|
1156
|
+
$[84] = handleActiveItem;
|
|
1157
|
+
$[85] = handleSubmitItem;
|
|
1158
|
+
$[86] = menubar;
|
|
1159
|
+
$[87] = syncSubmenuDisclosure;
|
|
1160
|
+
$[88] = t39;
|
|
1161
|
+
} else t39 = $[88];
|
|
1162
|
+
const handleKeyDown = t39;
|
|
1163
|
+
let t40;
|
|
1164
|
+
if ($[89] !== handleKeyDown) {
|
|
1165
|
+
t40 = {
|
|
1096
1166
|
ignoreUsedKeyboardEvents: false,
|
|
1097
1167
|
onKeyDown: handleKeyDown
|
|
1098
1168
|
};
|
|
1099
|
-
$[
|
|
1100
|
-
$[
|
|
1101
|
-
} else
|
|
1102
|
-
useKeyboardEvents(
|
|
1103
|
-
let
|
|
1104
|
-
if ($[
|
|
1105
|
-
|
|
1169
|
+
$[89] = handleKeyDown;
|
|
1170
|
+
$[90] = t40;
|
|
1171
|
+
} else t40 = $[90];
|
|
1172
|
+
useKeyboardEvents(t40);
|
|
1173
|
+
let t41;
|
|
1174
|
+
if ($[91] !== closeDropdown || $[92] !== handleActiveItem || $[93] !== isOpenOnMount) {
|
|
1175
|
+
t41 = (ref) => {
|
|
1106
1176
|
setDropdownElement(ref);
|
|
1107
1177
|
if (!ref) return;
|
|
1108
1178
|
const { ownerDocument } = ref;
|
|
@@ -1112,13 +1182,13 @@ function RootDropdown(t0) {
|
|
|
1112
1182
|
else inputElement = ref.firstElementChild.querySelector(TEXT_INPUT_SELECTOR);
|
|
1113
1183
|
inputElementRef.current = inputElement;
|
|
1114
1184
|
}
|
|
1115
|
-
const handleGlobalMouseDown = (
|
|
1116
|
-
const { target: target_1 } =
|
|
1185
|
+
const handleGlobalMouseDown = (t42) => {
|
|
1186
|
+
const { target: target_1 } = t42;
|
|
1117
1187
|
const eventTarget_3 = target_1;
|
|
1118
1188
|
if (!ref.contains(eventTarget_3)) closeDropdown();
|
|
1119
1189
|
};
|
|
1120
|
-
const handleGlobalMouseUp = (
|
|
1121
|
-
const { target: target_2 } =
|
|
1190
|
+
const handleGlobalMouseUp = (t43) => {
|
|
1191
|
+
const { target: target_2 } = t43;
|
|
1122
1192
|
if (!isOpenRef.current || closingTimerRef.current != null) return;
|
|
1123
1193
|
if (isOpeningRef.current) {
|
|
1124
1194
|
setIsOpening(false);
|
|
@@ -1131,12 +1201,12 @@ function RootDropdown(t0) {
|
|
|
1131
1201
|
const eventTarget_4 = target_2;
|
|
1132
1202
|
if (!ref.contains(eventTarget_4)) closeDropdown();
|
|
1133
1203
|
};
|
|
1134
|
-
const handleGlobalFocusIn = (
|
|
1135
|
-
const { target: target_3 } =
|
|
1204
|
+
const handleGlobalFocusIn = (t44) => {
|
|
1205
|
+
const { target: target_3 } = t44;
|
|
1136
1206
|
if (!isOpenRef.current) return;
|
|
1137
1207
|
const eventTarget_5 = target_3;
|
|
1138
1208
|
if (ref.contains(eventTarget_5) || eventTarget_5.contains(ref)) return;
|
|
1139
|
-
closeDropdown();
|
|
1209
|
+
closeDropdown({ keepMenubarEngaged: true });
|
|
1140
1210
|
};
|
|
1141
1211
|
document.addEventListener("focusin", handleGlobalFocusIn);
|
|
1142
1212
|
document.addEventListener("mousedown", handleGlobalMouseDown);
|
|
@@ -1174,51 +1244,52 @@ function RootDropdown(t0) {
|
|
|
1174
1244
|
if (inputElement) inputElement.removeEventListener("input", handleInput);
|
|
1175
1245
|
};
|
|
1176
1246
|
};
|
|
1177
|
-
$[
|
|
1178
|
-
$[
|
|
1179
|
-
$[
|
|
1180
|
-
|
|
1181
|
-
|
|
1247
|
+
$[91] = closeDropdown;
|
|
1248
|
+
$[92] = handleActiveItem;
|
|
1249
|
+
$[93] = isOpenOnMount;
|
|
1250
|
+
$[94] = t41;
|
|
1251
|
+
} else t41 = $[94];
|
|
1252
|
+
const handleRef = t41;
|
|
1182
1253
|
const handleBodyRef = _temp;
|
|
1183
1254
|
if (!isValidElement(trigger)) if (isSearchable) {
|
|
1184
|
-
const
|
|
1185
|
-
let
|
|
1186
|
-
if ($[
|
|
1187
|
-
|
|
1188
|
-
$[
|
|
1189
|
-
} else
|
|
1190
|
-
let
|
|
1191
|
-
if ($[
|
|
1192
|
-
|
|
1255
|
+
const t42 = value ?? "";
|
|
1256
|
+
let t43;
|
|
1257
|
+
if ($[95] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1258
|
+
t43 = () => setIsOpen(true);
|
|
1259
|
+
$[95] = t43;
|
|
1260
|
+
} else t43 = $[95];
|
|
1261
|
+
let t44;
|
|
1262
|
+
if ($[96] !== bodyId || $[97] !== disabled || $[98] !== isOpen || $[99] !== name || $[100] !== placeholder || $[101] !== popupRole || $[102] !== t42 || $[103] !== tabIndex) {
|
|
1263
|
+
t44 = /* @__PURE__ */ jsx("input", {
|
|
1193
1264
|
"aria-controls": bodyId,
|
|
1194
1265
|
"aria-expanded": isOpen,
|
|
1195
1266
|
"aria-haspopup": popupRole,
|
|
1196
1267
|
autoComplete: "off",
|
|
1197
1268
|
className: "uktdropdown-trigger",
|
|
1198
|
-
defaultValue:
|
|
1269
|
+
defaultValue: t42,
|
|
1199
1270
|
disabled,
|
|
1200
1271
|
name,
|
|
1201
|
-
onFocus:
|
|
1272
|
+
onFocus: t43,
|
|
1202
1273
|
placeholder,
|
|
1203
1274
|
ref: inputElementRef,
|
|
1204
1275
|
tabIndex,
|
|
1205
1276
|
type: "text"
|
|
1206
1277
|
});
|
|
1207
|
-
$[
|
|
1208
|
-
$[
|
|
1209
|
-
$[
|
|
1210
|
-
$[
|
|
1211
|
-
$[
|
|
1212
|
-
$[
|
|
1213
|
-
$[
|
|
1214
|
-
$[
|
|
1215
|
-
$[
|
|
1216
|
-
} else
|
|
1217
|
-
trigger =
|
|
1278
|
+
$[96] = bodyId;
|
|
1279
|
+
$[97] = disabled;
|
|
1280
|
+
$[98] = isOpen;
|
|
1281
|
+
$[99] = name;
|
|
1282
|
+
$[100] = placeholder;
|
|
1283
|
+
$[101] = popupRole;
|
|
1284
|
+
$[102] = t42;
|
|
1285
|
+
$[103] = tabIndex;
|
|
1286
|
+
$[104] = t44;
|
|
1287
|
+
} else t44 = $[104];
|
|
1288
|
+
trigger = t44;
|
|
1218
1289
|
} else {
|
|
1219
|
-
let
|
|
1220
|
-
if ($[
|
|
1221
|
-
|
|
1290
|
+
let t42;
|
|
1291
|
+
if ($[105] !== bodyId || $[106] !== isOpen || $[107] !== popupRole || $[108] !== trigger) {
|
|
1292
|
+
t42 = /* @__PURE__ */ jsx("button", {
|
|
1222
1293
|
"aria-controls": bodyId,
|
|
1223
1294
|
"aria-expanded": isOpen,
|
|
1224
1295
|
"aria-haspopup": popupRole,
|
|
@@ -1227,82 +1298,82 @@ function RootDropdown(t0) {
|
|
|
1227
1298
|
type: "button",
|
|
1228
1299
|
children: trigger
|
|
1229
1300
|
});
|
|
1230
|
-
$[
|
|
1231
|
-
$[
|
|
1232
|
-
$[
|
|
1233
|
-
$[
|
|
1234
|
-
$[
|
|
1235
|
-
} else
|
|
1236
|
-
trigger =
|
|
1301
|
+
$[105] = bodyId;
|
|
1302
|
+
$[106] = isOpen;
|
|
1303
|
+
$[107] = popupRole;
|
|
1304
|
+
$[108] = trigger;
|
|
1305
|
+
$[109] = t42;
|
|
1306
|
+
} else t42 = $[109];
|
|
1307
|
+
trigger = t42;
|
|
1237
1308
|
}
|
|
1238
1309
|
else {
|
|
1239
1310
|
const triggerProps = trigger.props;
|
|
1240
|
-
const
|
|
1241
|
-
const
|
|
1242
|
-
const
|
|
1243
|
-
const
|
|
1244
|
-
let
|
|
1245
|
-
if ($[
|
|
1246
|
-
|
|
1247
|
-
"aria-controls":
|
|
1248
|
-
"aria-expanded":
|
|
1249
|
-
"aria-haspopup":
|
|
1311
|
+
const t42 = trigger;
|
|
1312
|
+
const t43 = triggerProps["aria-controls"] ?? bodyId;
|
|
1313
|
+
const t44 = triggerProps["aria-expanded"] ?? isOpen;
|
|
1314
|
+
const t45 = triggerProps["aria-haspopup"] ?? popupRole;
|
|
1315
|
+
let t46;
|
|
1316
|
+
if ($[110] !== t42 || $[111] !== t43 || $[112] !== t44 || $[113] !== t45) {
|
|
1317
|
+
t46 = cloneElement(t42, {
|
|
1318
|
+
"aria-controls": t43,
|
|
1319
|
+
"aria-expanded": t44,
|
|
1320
|
+
"aria-haspopup": t45
|
|
1250
1321
|
});
|
|
1251
|
-
$[
|
|
1252
|
-
$[
|
|
1253
|
-
$[
|
|
1254
|
-
$[
|
|
1255
|
-
$[
|
|
1256
|
-
} else
|
|
1257
|
-
trigger =
|
|
1322
|
+
$[110] = t42;
|
|
1323
|
+
$[111] = t43;
|
|
1324
|
+
$[112] = t44;
|
|
1325
|
+
$[113] = t45;
|
|
1326
|
+
$[114] = t46;
|
|
1327
|
+
} else t46 = $[114];
|
|
1328
|
+
trigger = t46;
|
|
1258
1329
|
}
|
|
1259
1330
|
if (label != null) {
|
|
1260
|
-
let
|
|
1261
|
-
if ($[
|
|
1262
|
-
|
|
1331
|
+
let t42;
|
|
1332
|
+
if ($[115] !== label) {
|
|
1333
|
+
t42 = /* @__PURE__ */ jsx("div", {
|
|
1263
1334
|
className: "uktdropdown-label-text",
|
|
1264
1335
|
children: label
|
|
1265
1336
|
});
|
|
1266
|
-
$[
|
|
1267
|
-
$[
|
|
1268
|
-
} else
|
|
1269
|
-
let
|
|
1270
|
-
if ($[
|
|
1271
|
-
|
|
1337
|
+
$[115] = label;
|
|
1338
|
+
$[116] = t42;
|
|
1339
|
+
} else t42 = $[116];
|
|
1340
|
+
let t43;
|
|
1341
|
+
if ($[117] !== t42 || $[118] !== trigger) {
|
|
1342
|
+
t43 = /* @__PURE__ */ jsxs("label", {
|
|
1272
1343
|
className: "uktdropdown-label",
|
|
1273
|
-
children: [
|
|
1344
|
+
children: [t42, trigger]
|
|
1274
1345
|
});
|
|
1275
|
-
$[
|
|
1276
|
-
$[
|
|
1277
|
-
$[
|
|
1278
|
-
} else
|
|
1279
|
-
trigger =
|
|
1346
|
+
$[117] = t42;
|
|
1347
|
+
$[118] = trigger;
|
|
1348
|
+
$[119] = t43;
|
|
1349
|
+
} else t43 = $[119];
|
|
1350
|
+
trigger = t43;
|
|
1280
1351
|
}
|
|
1281
|
-
let
|
|
1282
|
-
if ($[
|
|
1283
|
-
|
|
1352
|
+
let t42;
|
|
1353
|
+
if ($[120] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1354
|
+
t42 = /* @__PURE__ */ jsx("style", {
|
|
1284
1355
|
href: "@acusti/dropdown/Dropdown",
|
|
1285
1356
|
precedence: "medium",
|
|
1286
1357
|
children: Dropdown_default
|
|
1287
1358
|
});
|
|
1288
|
-
$[
|
|
1289
|
-
} else
|
|
1290
|
-
let
|
|
1291
|
-
if ($[
|
|
1292
|
-
|
|
1359
|
+
$[120] = t42;
|
|
1360
|
+
} else t42 = $[120];
|
|
1361
|
+
let t43;
|
|
1362
|
+
if ($[121] !== className || $[122] !== disabled || $[123] !== isOpen || $[124] !== isSearchable) {
|
|
1363
|
+
t43 = clsx("uktdropdown", className, {
|
|
1293
1364
|
disabled,
|
|
1294
1365
|
"is-open": isOpen,
|
|
1295
1366
|
"is-searchable": isSearchable
|
|
1296
1367
|
});
|
|
1297
|
-
$[
|
|
1298
|
-
$[
|
|
1299
|
-
$[
|
|
1300
|
-
$[
|
|
1301
|
-
$[
|
|
1302
|
-
} else
|
|
1303
|
-
let
|
|
1304
|
-
if ($[
|
|
1305
|
-
|
|
1368
|
+
$[121] = className;
|
|
1369
|
+
$[122] = disabled;
|
|
1370
|
+
$[123] = isOpen;
|
|
1371
|
+
$[124] = isSearchable;
|
|
1372
|
+
$[125] = t43;
|
|
1373
|
+
} else t43 = $[125];
|
|
1374
|
+
let t44;
|
|
1375
|
+
if ($[126] !== bodyId || $[127] !== children || $[128] !== childrenCount || $[129] !== hasItems || $[130] !== isOpen || $[131] !== popupRole) {
|
|
1376
|
+
t44 = isOpen ? /* @__PURE__ */ jsx("div", {
|
|
1306
1377
|
className: clsx("uktdropdown-body", { "has-items": hasItems }),
|
|
1307
1378
|
id: bodyId,
|
|
1308
1379
|
popover: "manual",
|
|
@@ -1316,42 +1387,46 @@ function RootDropdown(t0) {
|
|
|
1316
1387
|
})
|
|
1317
1388
|
})
|
|
1318
1389
|
}) : null;
|
|
1319
|
-
$[
|
|
1320
|
-
$[
|
|
1321
|
-
$[
|
|
1322
|
-
$[
|
|
1323
|
-
$[
|
|
1324
|
-
$[
|
|
1325
|
-
$[
|
|
1326
|
-
} else
|
|
1327
|
-
let
|
|
1328
|
-
if ($[
|
|
1329
|
-
|
|
1330
|
-
className:
|
|
1390
|
+
$[126] = bodyId;
|
|
1391
|
+
$[127] = children;
|
|
1392
|
+
$[128] = childrenCount;
|
|
1393
|
+
$[129] = hasItems;
|
|
1394
|
+
$[130] = isOpen;
|
|
1395
|
+
$[131] = popupRole;
|
|
1396
|
+
$[132] = t44;
|
|
1397
|
+
} else t44 = $[132];
|
|
1398
|
+
let t45;
|
|
1399
|
+
if ($[133] !== handleDropdownMouseEnter || $[134] !== handleDropdownMouseLeave || $[135] !== handleMouseDown || $[136] !== handleMouseMove || $[137] !== handleMouseOut || $[138] !== handleMouseOver || $[139] !== handleMouseUp || $[140] !== handleRef || $[141] !== onClick || $[142] !== styleFromProps || $[143] !== t43 || $[144] !== t44 || $[145] !== trigger) {
|
|
1400
|
+
t45 = /* @__PURE__ */ jsxs(Fragment, { children: [t42, /* @__PURE__ */ jsxs("div", {
|
|
1401
|
+
className: t43,
|
|
1331
1402
|
onClick,
|
|
1332
1403
|
onMouseDown: handleMouseDown,
|
|
1404
|
+
onMouseEnter: handleDropdownMouseEnter,
|
|
1405
|
+
onMouseLeave: handleDropdownMouseLeave,
|
|
1333
1406
|
onMouseMove: handleMouseMove,
|
|
1334
1407
|
onMouseOut: handleMouseOut,
|
|
1335
1408
|
onMouseOver: handleMouseOver,
|
|
1336
1409
|
onMouseUp: handleMouseUp,
|
|
1337
1410
|
ref: handleRef,
|
|
1338
1411
|
style: styleFromProps,
|
|
1339
|
-
children: [trigger,
|
|
1412
|
+
children: [trigger, t44]
|
|
1340
1413
|
})] });
|
|
1341
|
-
$[
|
|
1342
|
-
$[
|
|
1343
|
-
$[
|
|
1344
|
-
$[
|
|
1345
|
-
$[
|
|
1346
|
-
$[
|
|
1347
|
-
$[
|
|
1348
|
-
$[
|
|
1349
|
-
$[
|
|
1350
|
-
$[
|
|
1351
|
-
$[
|
|
1352
|
-
$[
|
|
1353
|
-
|
|
1354
|
-
|
|
1414
|
+
$[133] = handleDropdownMouseEnter;
|
|
1415
|
+
$[134] = handleDropdownMouseLeave;
|
|
1416
|
+
$[135] = handleMouseDown;
|
|
1417
|
+
$[136] = handleMouseMove;
|
|
1418
|
+
$[137] = handleMouseOut;
|
|
1419
|
+
$[138] = handleMouseOver;
|
|
1420
|
+
$[139] = handleMouseUp;
|
|
1421
|
+
$[140] = handleRef;
|
|
1422
|
+
$[141] = onClick;
|
|
1423
|
+
$[142] = styleFromProps;
|
|
1424
|
+
$[143] = t43;
|
|
1425
|
+
$[144] = t44;
|
|
1426
|
+
$[145] = trigger;
|
|
1427
|
+
$[146] = t45;
|
|
1428
|
+
} else t45 = $[146];
|
|
1429
|
+
return t45;
|
|
1355
1430
|
}
|
|
1356
1431
|
function _temp(ref_0) {
|
|
1357
1432
|
if (!ref_0) return;
|
|
@@ -1365,6 +1440,7 @@ var INERT_SUBMENU_PROPS = [
|
|
|
1365
1440
|
"isSearchable",
|
|
1366
1441
|
"keepOpenOnSubmit",
|
|
1367
1442
|
"name",
|
|
1443
|
+
"openOnHover",
|
|
1368
1444
|
"placeholder",
|
|
1369
1445
|
"tabIndex",
|
|
1370
1446
|
"value"
|