@allxsmith/bestax-bulma 5.29.0 → 5.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/bestax.css +1 -1
  2. package/dist/bestax.css.map +1 -1
  3. package/dist/esm/components/ContextMenu.js +244 -0
  4. package/dist/esm/components/ContextMenu.js.map +1 -0
  5. package/dist/esm/components/Dropdown.js +37 -85
  6. package/dist/esm/components/Dropdown.js.map +1 -1
  7. package/dist/esm/components/HoverCard.js +3 -10
  8. package/dist/esm/components/HoverCard.js.map +1 -1
  9. package/dist/esm/components/Tooltip.js +88 -63
  10. package/dist/esm/components/Tooltip.js.map +1 -1
  11. package/dist/esm/elements/Button.js.map +1 -1
  12. package/dist/esm/elements/Buttons.js +2 -0
  13. package/dist/esm/elements/Buttons.js.map +1 -1
  14. package/dist/esm/elements/ToggleButton.js +68 -0
  15. package/dist/esm/elements/ToggleButton.js.map +1 -0
  16. package/dist/esm/form/DateTimeInputBase.js.map +1 -1
  17. package/dist/esm/form/TimeInputBase.js.map +1 -1
  18. package/dist/esm/form/_pickerInternals/pickerTypes.js +14 -6
  19. package/dist/esm/form/_pickerInternals/pickerTypes.js.map +1 -1
  20. package/dist/esm/helpers/useContextMenuTrigger.js +166 -0
  21. package/dist/esm/helpers/useContextMenuTrigger.js.map +1 -0
  22. package/dist/esm/helpers/useHoverOpen.js +40 -6
  23. package/dist/esm/helpers/useHoverOpen.js.map +1 -1
  24. package/dist/esm/helpers/useMenuKeys.js +182 -0
  25. package/dist/esm/helpers/useMenuKeys.js.map +1 -0
  26. package/dist/extras.css +1 -1
  27. package/dist/extras.css.map +1 -1
  28. package/dist/index.cjs +1896 -1261
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.esm.js +2 -0
  31. package/dist/index.esm.js.map +1 -1
  32. package/dist/types/components/ContextMenu.d.ts +66 -0
  33. package/dist/types/components/Tooltip.d.ts +63 -9
  34. package/dist/types/elements/Button.d.ts +1 -1
  35. package/dist/types/elements/Buttons.d.ts +1 -0
  36. package/dist/types/elements/ToggleButton.d.ts +100 -0
  37. package/dist/types/form/DateTimeInputBase.d.ts +4 -1
  38. package/dist/types/form/TimeInputBase.d.ts +5 -2
  39. package/dist/types/form/_pickerInternals/pickerTypes.d.ts +16 -1
  40. package/dist/types/helpers/useContextMenuTrigger.d.ts +67 -0
  41. package/dist/types/helpers/useHoverOpen.d.ts +19 -3
  42. package/dist/types/helpers/useMenuKeys.d.ts +57 -0
  43. package/dist/types/index.d.ts +2 -0
  44. package/dist/types-cjs/components/ContextMenu.d.ts +66 -0
  45. package/dist/types-cjs/components/Tooltip.d.ts +63 -9
  46. package/dist/types-cjs/elements/Button.d.ts +1 -1
  47. package/dist/types-cjs/elements/Buttons.d.ts +1 -0
  48. package/dist/types-cjs/elements/ToggleButton.d.ts +100 -0
  49. package/dist/types-cjs/form/DateTimeInputBase.d.ts +4 -1
  50. package/dist/types-cjs/form/TimeInputBase.d.ts +5 -2
  51. package/dist/types-cjs/form/_pickerInternals/pickerTypes.d.ts +16 -1
  52. package/dist/types-cjs/helpers/useContextMenuTrigger.d.ts +67 -0
  53. package/dist/types-cjs/helpers/useHoverOpen.d.ts +19 -3
  54. package/dist/types-cjs/helpers/useMenuKeys.d.ts +57 -0
  55. package/dist/types-cjs/index.d.ts +2 -0
  56. package/dist/versions/bestax-no-dark-mode.css +1 -1
  57. package/dist/versions/bestax-no-dark-mode.css.map +1 -1
  58. package/dist/versions/bestax-no-helpers-prefixed.css +1 -1
  59. package/dist/versions/bestax-no-helpers-prefixed.css.map +1 -1
  60. package/dist/versions/bestax-no-helpers.css +1 -1
  61. package/dist/versions/bestax-no-helpers.css.map +1 -1
  62. package/dist/versions/bestax-prefixed.css +1 -1
  63. package/dist/versions/bestax-prefixed.css.map +1 -1
  64. package/package.json +1 -1
  65. package/src/scss/components/_contextmenu.scss +50 -0
  66. package/src/scss/components/_index.scss +1 -0
  67. package/src/scss/components/_tooltip.scss +76 -1
@@ -0,0 +1,244 @@
1
+ /* @allxsmith/bestax-bulma — AI agents: see AGENTS.md in the package root, or https://bestax.io/llms.txt */
2
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
3
+ import { useState, useRef, useEffect, cloneElement } from 'react';
4
+ import { usePrefixedClassNames, classNames } from '../helpers/classNames.js';
5
+ import { useBulmaClasses } from '../helpers/useBulmaClasses.js';
6
+ import { withSubComponents } from '../helpers/withSubComponents.js';
7
+ import { Portal } from '../helpers/portal.js';
8
+ import { useConfig } from '../helpers/Config.js';
9
+ import { useClientLayoutEffect } from '../helpers/useClientLayoutEffect.js';
10
+ import { getDeepestActiveElement, isEventInside } from '../helpers/shadowDom.js';
11
+ import { warnOnce } from '../helpers/devWarnings.js';
12
+ import { useContextMenuTrigger } from '../helpers/useContextMenuTrigger.js';
13
+ import { useMenuKeys, enabledMenuItems, MENU_ITEM_SELECTOR, isEnabledMenuItem } from '../helpers/useMenuKeys.js';
14
+ import { DropdownDivider, DropdownItem } from './Dropdown.js';
15
+
16
+ /**
17
+ * Where the menu goes along one axis, from the point at `at`: after it when
18
+ * there's room, before it when there's room there instead, and otherwise
19
+ * moved in until it fits in `room`.
20
+ */
21
+ function placeAlong(at, size, room) {
22
+ if (at + size <= room)
23
+ return { start: at, flip: false };
24
+ if (at - size >= 0)
25
+ return { start: at, flip: true };
26
+ return { start: Math.max(0, room - size), flip: false };
27
+ }
28
+ /** Runs the trigger's own handler, then the context menu's. */
29
+ function chain(own, ours) {
30
+ return event => {
31
+ own?.(event);
32
+ ours(event);
33
+ };
34
+ }
35
+ /**
36
+ * The `ContextMenu` component opens a menu of actions where you right-click an element, such as a table row or a card, or long press it on a touch screen.
37
+ *
38
+ * Shift+F10 and the context menu key open it too, where the browser fires
39
+ * `contextmenu` for them, which Windows and Linux do. The menu is Dropdown's
40
+ * markup, portaled into the `portalContainer` a `ConfigProvider` sets, or
41
+ * the end of the trigger's own document's `<body>`, so it never has server
42
+ * markup. It opens below and to the right of the point, flips above or to
43
+ * the left where there's no room, moves in where it fits neither way, and
44
+ * scrolls inside when it's taller than the viewport. It doesn't follow the
45
+ * trigger, since scrolling closes it. Inside a `Modal` or a shadow root,
46
+ * point `portalContainer` inside it, so screen readers that honor
47
+ * `aria-modal` reach the menu and the shadow root's styles apply.
48
+ *
49
+ * Opening moves focus to the first enabled item. The arrow keys, Home, End
50
+ * and typing move between items, and Enter and Space activate one. Escape,
51
+ * Tab, an item, a press outside, scrolling, resizing and the window losing
52
+ * focus close it, handing focus back to what had it unless an item moved it
53
+ * somewhere else. For a menu opened from a button use `Dropdown`.
54
+ *
55
+ * @function
56
+ * @param {ContextMenuProps} props - Props for the ContextMenu component.
57
+ * @returns {JSX.Element} The trigger, and the menu while open.
58
+ *
59
+ * @example
60
+ * <ContextMenu
61
+ * aria-label="Actions for report.pdf"
62
+ * trigger={<Box>report.pdf</Box>}
63
+ * >
64
+ * <ContextMenu.Item as="button">Rename</ContextMenu.Item>
65
+ * <ContextMenu.Divider />
66
+ * <ContextMenu.Item as="button">Delete</ContextMenu.Item>
67
+ * </ContextMenu>
68
+ */
69
+ const ContextMenuComponent = ({ trigger, children, onOpenChange, closeOnClick = true, disabled = false, className, onKeyDown, onClick, onContextMenu, ...props }) => {
70
+ const { bulmaHelperClasses, rest } = useBulmaClasses(props);
71
+ const { portalContainer } = useConfig();
72
+ const [menu, setMenu] = useState(null);
73
+ // Turning `disabled` on closes it.
74
+ if (disabled && menu)
75
+ setMenu(null);
76
+ const open = menu !== null;
77
+ const doc = menu?.doc;
78
+ const placed = menu?.placed;
79
+ const boxRef = useRef(null);
80
+ const menuRef = useRef(null);
81
+ const openerRef = useRef(null);
82
+ const reportedRef = useRef(false);
83
+ const menuKeys = useMenuKeys();
84
+ const named = Boolean(props['aria-label'] || props['aria-labelledby']);
85
+ const handlers = useContextMenuTrigger({
86
+ disabled,
87
+ onOpen: (point, triggerNode) => {
88
+ const ownerDoc = triggerNode.ownerDocument;
89
+ openerRef.current = getDeepestActiveElement(ownerDoc);
90
+ setMenu({ point, doc: ownerDoc });
91
+ },
92
+ });
93
+ // Measured once per opening, before it paints, against what a fixed box
94
+ // resolves against: the root element's client area, which leaves out a
95
+ // classic scrollbar. `useAnchoredPosition` and Tooltip read innerWidth and
96
+ // innerHeight, which count it. A menu pinned to the viewport's edge would
97
+ // sit under the scrollbar by that much, so this reads the narrower box.
98
+ useClientLayoutEffect(() => {
99
+ const menuNode = menuRef.current;
100
+ if (!menu || menu.placed || !menuNode)
101
+ return;
102
+ const root = menuNode.ownerDocument.documentElement;
103
+ const { width, height } = menuNode.getBoundingClientRect();
104
+ const x = placeAlong(menu.point.x, width, root.clientWidth);
105
+ const y = placeAlong(menu.point.y, height, root.clientHeight);
106
+ setMenu({
107
+ ...menu,
108
+ placed: { left: x.start, top: y.start, right: x.flip, up: y.flip },
109
+ });
110
+ }, [menu]);
111
+ const isPlaced = Boolean(placed);
112
+ // What closes it while it's open, and focus back on closing. Nothing
113
+ // listens while it's closed.
114
+ useEffect(() => {
115
+ const box = boxRef.current;
116
+ const menuNode = menuRef.current;
117
+ if (!doc || !box || !menuNode)
118
+ return undefined;
119
+ const view = doc.defaultView;
120
+ // What had focus when it opened. This runs once per opening, so opening
121
+ // again at a new point while it's open keeps it.
122
+ const opener = openerRef.current;
123
+ const close = () => setMenu(null);
124
+ const closeOutside = (event) => {
125
+ if (!isEventInside(event, box))
126
+ close();
127
+ };
128
+ doc.addEventListener('pointerdown', closeOutside, true);
129
+ view.addEventListener('resize', close);
130
+ view.addEventListener('blur', close);
131
+ return () => {
132
+ doc.removeEventListener('pointerdown', closeOutside, true);
133
+ view.removeEventListener('resize', close);
134
+ view.removeEventListener('blur', close);
135
+ // Back to what had focus while the menu still has it, or it dropped to
136
+ // <body> when the menu left. An item that put it somewhere else, such
137
+ // as a Modal or a rename field, keeps it there.
138
+ const now = getDeepestActiveElement(doc);
139
+ if (!now || now === doc.body || menuNode.contains(now))
140
+ opener?.focus();
141
+ };
142
+ }, [doc]);
143
+ // Focus in, and closing on scroll, once it's placed. Placed, it's inside
144
+ // the viewport, so its first item has nothing to scroll into view, and
145
+ // `preventScroll` makes sure: a scroll the focus caused would close it as
146
+ // it opened. Opening again at a new point places it again, and leaves
147
+ // focus where it is in the menu.
148
+ useEffect(() => {
149
+ const box = boxRef.current;
150
+ const menuNode = menuRef.current;
151
+ if (!doc || !isPlaced || !box || !menuNode)
152
+ return undefined;
153
+ if (!menuNode.contains(getDeepestActiveElement(doc))) {
154
+ menuKeys.reset();
155
+ (enabledMenuItems(menuNode)[0] ?? menuNode).focus({
156
+ preventScroll: true,
157
+ });
158
+ }
159
+ const closeOutside = (event) => {
160
+ if (!isEventInside(event, box))
161
+ setMenu(null);
162
+ };
163
+ doc.addEventListener('scroll', closeOutside, true);
164
+ return () => doc.removeEventListener('scroll', closeOutside, true);
165
+ }, [doc, isPlaced, menuKeys]);
166
+ // Before paint, so what the caller does with it, such as highlighting the
167
+ // row, shows with the menu rather than a frame behind it.
168
+ useClientLayoutEffect(() => {
169
+ if (open === reportedRef.current)
170
+ return;
171
+ reportedRef.current = open;
172
+ onOpenChange?.(open);
173
+ });
174
+ useEffect(() => {
175
+ if (open && !named) {
176
+ warnOnce('ContextMenu:unnamed', '[bestax-bulma] <ContextMenu> opened a menu with no accessible ' +
177
+ 'name. Pass aria-label or aria-labelledby.');
178
+ }
179
+ }, [open, named]);
180
+ const handleKeyDown = (event) => {
181
+ onKeyDown?.(event);
182
+ // The menu has the keyboard while focus is in it. React brings its keys
183
+ // up the tree to wherever the ContextMenu sits, where a table that moves
184
+ // between rows on the arrow keys, or a Popover or a Modal waiting for
185
+ // Escape, would take them too.
186
+ event.stopPropagation();
187
+ if (event.key === 'Escape' || event.key === 'Tab') {
188
+ // Tab would go on from the end of <body>, past the rest of the page.
189
+ event.preventDefault();
190
+ setMenu(null);
191
+ return;
192
+ }
193
+ menuKeys.onKeyDown(event);
194
+ };
195
+ const handleClick = (event) => {
196
+ onClick?.(event);
197
+ if (!closeOnClick)
198
+ return;
199
+ const item = event.target.closest(MENU_ITEM_SELECTOR);
200
+ if (item && isEnabledMenuItem(item))
201
+ setMenu(null);
202
+ };
203
+ const handleContextMenu = (event) => {
204
+ onContextMenu?.(event);
205
+ // No other menu over this one: not the browser's, and not a trigger's
206
+ // that React brings the event up to.
207
+ event.preventDefault();
208
+ event.stopPropagation();
209
+ };
210
+ const own = trigger.props;
211
+ const triggerClass = usePrefixedClassNames('context-menu');
212
+ const clonedTrigger = cloneElement(trigger, {
213
+ className: classNames(own.className, !disabled && triggerClass) || undefined,
214
+ onContextMenu: chain(own.onContextMenu, handlers.onContextMenu),
215
+ onPointerDown: chain(own.onPointerDown, handlers.onPointerDown),
216
+ onPointerMove: chain(own.onPointerMove, handlers.onPointerMove),
217
+ onPointerUp: chain(own.onPointerUp, handlers.onPointerUp),
218
+ onPointerCancel: chain(own.onPointerCancel, handlers.onPointerCancel),
219
+ onTouchEnd: chain(own.onTouchEnd, handlers.onTouchEnd),
220
+ });
221
+ const boxClasses = usePrefixedClassNames('context-menu-content', 'dropdown', {
222
+ 'is-active': true,
223
+ 'is-up': placed?.up,
224
+ 'is-right': placed?.right,
225
+ });
226
+ const menuClasses = classNames(usePrefixedClassNames('dropdown-menu'), bulmaHelperClasses, className);
227
+ const contentClasses = usePrefixedClassNames('dropdown-content');
228
+ return (jsxs(Fragment, { children: [clonedTrigger, menu && (jsx(Portal, { container: portalContainer || menu.doc.body, children: jsx("div", { ref: boxRef, className: boxClasses, style: {
229
+ top: placed?.top ?? menu.point.y,
230
+ left: placed?.left ?? menu.point.x,
231
+ }, children: jsx("div", { ...rest, ref: menuRef, role: "menu", tabIndex: -1, className: menuClasses, onKeyDown: handleKeyDown, onClick: handleClick, onContextMenu: handleContextMenu, children: jsx("div", { className: contentClasses, children: children }) }) }) }))] }));
232
+ };
233
+ /**
234
+ * ContextMenu with Item and Divider sub-components, which are `Dropdown.Item`
235
+ * and `Dropdown.Divider`, so items written for a Dropdown work here
236
+ * unchanged.
237
+ */
238
+ const ContextMenu = withSubComponents(ContextMenuComponent, {
239
+ Item: DropdownItem,
240
+ Divider: DropdownDivider,
241
+ }, 'ContextMenu');
242
+
243
+ export { ContextMenu };
244
+ //# sourceMappingURL=ContextMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContextMenu.js","sources":["../../../src/components/ContextMenu.tsx"],"sourcesContent":["import React, { cloneElement, useEffect, useRef, useState } from 'react';\nimport { classNames, usePrefixedClassNames } from '../helpers/classNames';\nimport { useBulmaClasses, BulmaClassesProps } from '../helpers/useBulmaClasses';\nimport { withSubComponents } from '../helpers/withSubComponents';\nimport { Portal } from '../helpers/portal';\nimport { useConfig } from '../helpers/Config';\nimport { useClientLayoutEffect } from '../helpers/useClientLayoutEffect';\nimport { getDeepestActiveElement, isEventInside } from '../helpers/shadowDom';\nimport { warnOnce } from '../helpers/devWarnings';\nimport {\n useContextMenuTrigger,\n type ContextMenuPoint,\n type ContextMenuTriggerHandlers,\n} from '../helpers/useContextMenuTrigger';\nimport {\n enabledMenuItems,\n isEnabledMenuItem,\n MENU_ITEM_SELECTOR,\n useMenuKeys,\n} from '../helpers/useMenuKeys';\nimport { DropdownDivider, DropdownItem } from './Dropdown';\n\n/**\n * Props for the ContextMenu component. `className`, `id`, `aria-label`, the\n * other HTML attributes and the helper props land on the menu\n * (`role=\"menu\"`). The trigger keeps its own.\n * @extraProp {string} [aria-label] - The menu's accessible name, such as \"Actions for report.pdf\". There's no button to borrow a name from, so pass this or `aria-labelledby`, and a development build warns when the menu opens with neither.\n * @extraProp {string} [className] - Additional classes for the menu (`role=\"menu\"`). The trigger keeps its own.\n */\nexport interface ContextMenuProps\n extends\n Omit<React.HTMLAttributes<HTMLDivElement>, 'color' | 'children'>,\n Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {\n /**\n * The element a right-click, Shift+F10, the context menu key or a long\n * press opens the menu from: a table row, a card, an image. It's cloned,\n * not wrapped, so a row stays a row, which means it has to be a single\n * element that passes `className` and the `onContextMenu`,\n * `onPointerDown`, `onPointerMove`, `onPointerUp`, `onPointerCancel` and\n * `onTouchEnd` handlers to its DOM node. Its own handlers for those run\n * first, and one that calls `preventDefault()` on `contextmenu` keeps the\n * menu closed. A `ContextMenu` inside it opens instead of this one.\n *\n * It gets no ARIA and no tab stop, since it can be any element and a\n * right-click isn't an activation. Keyboard users reach it through\n * something focusable inside it, such as the row's own `Dropdown` button,\n * or a `tabIndex={0}` you give it, and press Shift+F10 or the context menu\n * key there. It gets `-webkit-touch-callout: none`, so iOS doesn't put its\n * own callout for a link or an image over the menu. A long press still\n * selects text the way it does anywhere, so give a region where it\n * shouldn't `interaction=\"unselectable\"`.\n */\n trigger: React.ReactElement;\n /**\n * The menu's items: `ContextMenu.Item` and `ContextMenu.Divider`, the same\n * components as `Dropdown.Item` and `Dropdown.Divider`. Every action in it\n * needs a visible way in as well, such as a `Dropdown` on the same row:\n * nothing tells a screen reader user the menu is there, and on macOS only\n * VoiceOver opens it from the keyboard.\n */\n children: React.ReactNode;\n /**\n * Called with `true` when the menu opens and `false` when it closes,\n * whatever closed it, such as for highlighting the row whose menu is open.\n * Nothing fires after ContextMenu unmounts. There's no `open` prop to go\n * with it: a menu opened from code has no point to open at.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * Close the menu when an item is clicked, or activated with Enter or\n * Space. A click on a divider or between items leaves it open either way.\n */\n closeOnClick?: boolean;\n /**\n * Leave the trigger to the browser: a right-click shows the browser's own\n * menu, a long press does what it does anywhere, and an open menu closes.\n */\n disabled?: boolean;\n}\n\n/** Where the menu goes once it's measured. */\ninterface Placement {\n /** The box's corner in the viewport, which the menu hangs from. */\n top: number;\n left: number;\n /** The menu sits above the box rather than below it. */\n up: boolean;\n /** The menu sits to the left of the box rather than to its right. */\n right: boolean;\n}\n\n/** An open menu. */\ninterface OpenMenu {\n point: ContextMenuPoint;\n /** The trigger's document, where presses and scrolling are watched. */\n doc: Document;\n /** Unset until the menu is measured, which happens before it paints. */\n placed?: Placement;\n}\n\n/**\n * Where the menu goes along one axis, from the point at `at`: after it when\n * there's room, before it when there's room there instead, and otherwise\n * moved in until it fits in `room`.\n */\nfunction placeAlong(\n at: number,\n size: number,\n room: number\n): { start: number; flip: boolean } {\n if (at + size <= room) return { start: at, flip: false };\n if (at - size >= 0) return { start: at, flip: true };\n return { start: Math.max(0, room - size), flip: false };\n}\n\n/** Runs the trigger's own handler, then the context menu's. */\nfunction chain<E>(\n own: ((event: E) => void) | undefined,\n ours: (event: E) => void\n): (event: E) => void {\n return event => {\n own?.(event);\n ours(event);\n };\n}\n\n/**\n * The `ContextMenu` component opens a menu of actions where you right-click an element, such as a table row or a card, or long press it on a touch screen.\n *\n * Shift+F10 and the context menu key open it too, where the browser fires\n * `contextmenu` for them, which Windows and Linux do. The menu is Dropdown's\n * markup, portaled into the `portalContainer` a `ConfigProvider` sets, or\n * the end of the trigger's own document's `<body>`, so it never has server\n * markup. It opens below and to the right of the point, flips above or to\n * the left where there's no room, moves in where it fits neither way, and\n * scrolls inside when it's taller than the viewport. It doesn't follow the\n * trigger, since scrolling closes it. Inside a `Modal` or a shadow root,\n * point `portalContainer` inside it, so screen readers that honor\n * `aria-modal` reach the menu and the shadow root's styles apply.\n *\n * Opening moves focus to the first enabled item. The arrow keys, Home, End\n * and typing move between items, and Enter and Space activate one. Escape,\n * Tab, an item, a press outside, scrolling, resizing and the window losing\n * focus close it, handing focus back to what had it unless an item moved it\n * somewhere else. For a menu opened from a button use `Dropdown`.\n *\n * @function\n * @param {ContextMenuProps} props - Props for the ContextMenu component.\n * @returns {JSX.Element} The trigger, and the menu while open.\n *\n * @example\n * <ContextMenu\n * aria-label=\"Actions for report.pdf\"\n * trigger={<Box>report.pdf</Box>}\n * >\n * <ContextMenu.Item as=\"button\">Rename</ContextMenu.Item>\n * <ContextMenu.Divider />\n * <ContextMenu.Item as=\"button\">Delete</ContextMenu.Item>\n * </ContextMenu>\n */\nconst ContextMenuComponent: React.FC<ContextMenuProps> = ({\n trigger,\n children,\n onOpenChange,\n closeOnClick = true,\n disabled = false,\n className,\n onKeyDown,\n onClick,\n onContextMenu,\n ...props\n}) => {\n const { bulmaHelperClasses, rest } = useBulmaClasses(props);\n const { portalContainer } = useConfig();\n const [menu, setMenu] = useState<OpenMenu | null>(null);\n // Turning `disabled` on closes it.\n if (disabled && menu) setMenu(null);\n const open = menu !== null;\n const doc = menu?.doc;\n const placed = menu?.placed;\n\n const boxRef = useRef<HTMLDivElement>(null);\n const menuRef = useRef<HTMLDivElement>(null);\n const openerRef = useRef<Element | null>(null);\n const reportedRef = useRef(false);\n const menuKeys = useMenuKeys();\n const named = Boolean(props['aria-label'] || props['aria-labelledby']);\n\n const handlers = useContextMenuTrigger({\n disabled,\n onOpen: (point, triggerNode) => {\n const ownerDoc = triggerNode.ownerDocument;\n openerRef.current = getDeepestActiveElement(ownerDoc);\n setMenu({ point, doc: ownerDoc });\n },\n });\n\n // Measured once per opening, before it paints, against what a fixed box\n // resolves against: the root element's client area, which leaves out a\n // classic scrollbar. `useAnchoredPosition` and Tooltip read innerWidth and\n // innerHeight, which count it. A menu pinned to the viewport's edge would\n // sit under the scrollbar by that much, so this reads the narrower box.\n useClientLayoutEffect(() => {\n const menuNode = menuRef.current;\n if (!menu || menu.placed || !menuNode) return;\n const root = menuNode.ownerDocument.documentElement;\n const { width, height } = menuNode.getBoundingClientRect();\n const x = placeAlong(menu.point.x, width, root.clientWidth);\n const y = placeAlong(menu.point.y, height, root.clientHeight);\n setMenu({\n ...menu,\n placed: { left: x.start, top: y.start, right: x.flip, up: y.flip },\n });\n }, [menu]);\n const isPlaced = Boolean(placed);\n\n // What closes it while it's open, and focus back on closing. Nothing\n // listens while it's closed.\n useEffect(() => {\n const box = boxRef.current;\n const menuNode = menuRef.current;\n if (!doc || !box || !menuNode) return undefined;\n const view = doc.defaultView as Window;\n // What had focus when it opened. This runs once per opening, so opening\n // again at a new point while it's open keeps it.\n const opener = openerRef.current as HTMLElement | null;\n const close = () => setMenu(null);\n const closeOutside = (event: Event) => {\n if (!isEventInside(event, box)) close();\n };\n doc.addEventListener('pointerdown', closeOutside, true);\n view.addEventListener('resize', close);\n view.addEventListener('blur', close);\n return () => {\n doc.removeEventListener('pointerdown', closeOutside, true);\n view.removeEventListener('resize', close);\n view.removeEventListener('blur', close);\n // Back to what had focus while the menu still has it, or it dropped to\n // <body> when the menu left. An item that put it somewhere else, such\n // as a Modal or a rename field, keeps it there.\n const now = getDeepestActiveElement(doc);\n if (!now || now === doc.body || menuNode.contains(now)) opener?.focus();\n };\n }, [doc]);\n\n // Focus in, and closing on scroll, once it's placed. Placed, it's inside\n // the viewport, so its first item has nothing to scroll into view, and\n // `preventScroll` makes sure: a scroll the focus caused would close it as\n // it opened. Opening again at a new point places it again, and leaves\n // focus where it is in the menu.\n useEffect(() => {\n const box = boxRef.current;\n const menuNode = menuRef.current;\n if (!doc || !isPlaced || !box || !menuNode) return undefined;\n if (!menuNode.contains(getDeepestActiveElement(doc))) {\n menuKeys.reset();\n (enabledMenuItems(menuNode)[0] ?? menuNode).focus({\n preventScroll: true,\n });\n }\n const closeOutside = (event: Event) => {\n if (!isEventInside(event, box)) setMenu(null);\n };\n doc.addEventListener('scroll', closeOutside, true);\n return () => doc.removeEventListener('scroll', closeOutside, true);\n }, [doc, isPlaced, menuKeys]);\n\n // Before paint, so what the caller does with it, such as highlighting the\n // row, shows with the menu rather than a frame behind it.\n useClientLayoutEffect(() => {\n if (open === reportedRef.current) return;\n reportedRef.current = open;\n onOpenChange?.(open);\n });\n\n useEffect(() => {\n if (open && !named) {\n warnOnce(\n 'ContextMenu:unnamed',\n '[bestax-bulma] <ContextMenu> opened a menu with no accessible ' +\n 'name. Pass aria-label or aria-labelledby.'\n );\n }\n }, [open, named]);\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(event);\n // The menu has the keyboard while focus is in it. React brings its keys\n // up the tree to wherever the ContextMenu sits, where a table that moves\n // between rows on the arrow keys, or a Popover or a Modal waiting for\n // Escape, would take them too.\n event.stopPropagation();\n if (event.key === 'Escape' || event.key === 'Tab') {\n // Tab would go on from the end of <body>, past the rest of the page.\n event.preventDefault();\n setMenu(null);\n return;\n }\n menuKeys.onKeyDown(event);\n };\n\n const handleClick = (event: React.MouseEvent<HTMLDivElement>) => {\n onClick?.(event);\n if (!closeOnClick) return;\n const item = (event.target as Element).closest(MENU_ITEM_SELECTOR);\n if (item && isEnabledMenuItem(item)) setMenu(null);\n };\n\n const handleContextMenu = (event: React.MouseEvent<HTMLDivElement>) => {\n onContextMenu?.(event);\n // No other menu over this one: not the browser's, and not a trigger's\n // that React brings the event up to.\n event.preventDefault();\n event.stopPropagation();\n };\n\n const own = trigger.props as Partial<ContextMenuTriggerHandlers> & {\n className?: string;\n };\n const triggerClass = usePrefixedClassNames('context-menu');\n const clonedTrigger = cloneElement(\n trigger as React.ReactElement<Record<string, unknown>>,\n {\n className:\n classNames(own.className, !disabled && triggerClass) || undefined,\n onContextMenu: chain(own.onContextMenu, handlers.onContextMenu),\n onPointerDown: chain(own.onPointerDown, handlers.onPointerDown),\n onPointerMove: chain(own.onPointerMove, handlers.onPointerMove),\n onPointerUp: chain(own.onPointerUp, handlers.onPointerUp),\n onPointerCancel: chain(own.onPointerCancel, handlers.onPointerCancel),\n onTouchEnd: chain(own.onTouchEnd, handlers.onTouchEnd),\n }\n );\n\n const boxClasses = usePrefixedClassNames('context-menu-content', 'dropdown', {\n 'is-active': true,\n 'is-up': placed?.up,\n 'is-right': placed?.right,\n });\n const menuClasses = classNames(\n usePrefixedClassNames('dropdown-menu'),\n bulmaHelperClasses,\n className\n );\n const contentClasses = usePrefixedClassNames('dropdown-content');\n\n return (\n <>\n {clonedTrigger}\n {menu && (\n <Portal container={portalContainer || menu.doc.body}>\n <div\n ref={boxRef}\n className={boxClasses}\n style={{\n top: placed?.top ?? menu.point.y,\n left: placed?.left ?? menu.point.x,\n }}\n >\n <div\n {...rest}\n ref={menuRef}\n role=\"menu\"\n tabIndex={-1}\n className={menuClasses}\n onKeyDown={handleKeyDown}\n onClick={handleClick}\n onContextMenu={handleContextMenu}\n >\n <div className={contentClasses}>{children}</div>\n </div>\n </div>\n </Portal>\n )}\n </>\n );\n};\n\n/**\n * ContextMenu with Item and Divider sub-components, which are `Dropdown.Item`\n * and `Dropdown.Divider`, so items written for a Dropdown work here\n * unchanged.\n */\nexport const ContextMenu = withSubComponents(\n ContextMenuComponent,\n {\n Item: DropdownItem,\n Divider: DropdownDivider,\n },\n 'ContextMenu'\n);\n\nexport default ContextMenu;\n"],"names":["_jsxs","_Fragment","_jsx"],"mappings":";;;;;;;;;;;;;;;AAoGA;;;;AAIG;AACH,SAAS,UAAU,CACjB,EAAU,EACV,IAAY,EACZ,IAAY,EAAA;AAEZ,IAAA,IAAI,EAAE,GAAG,IAAI,IAAI,IAAI;QAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;AACxD,IAAA,IAAI,EAAE,GAAG,IAAI,IAAI,CAAC;QAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;AACpD,IAAA,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE;AACzD;AAEA;AACA,SAAS,KAAK,CACZ,GAAqC,EACrC,IAAwB,EAAA;IAExB,OAAO,KAAK,IAAG;AACb,QAAA,GAAG,GAAG,KAAK,CAAC;QACZ,IAAI,CAAC,KAAK,CAAC;AACb,IAAA,CAAC;AACH;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCG;AACH,MAAM,oBAAoB,GAA+B,CAAC,EACxD,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,YAAY,GAAG,IAAI,EACnB,QAAQ,GAAG,KAAK,EAChB,SAAS,EACT,SAAS,EACT,OAAO,EACP,aAAa,EACb,GAAG,KAA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../helpers/withSubComponents.js';
7
7
  import { isEventInside, getActiveElementInTree } from '../helpers/shadowDom.js';
8
8
  import { omitAttrs, ANCHOR_ONLY_ATTRS } from '../helpers/anchorAttrs.js';
9
9
  import { buttonType } from '../helpers/buttonType.js';
10
+ import { useMenuKeys, enabledMenuItems } from '../helpers/useMenuKeys.js';
10
11
 
11
12
  /**
12
13
  * Checks if code is running in a browser environment.
@@ -21,6 +22,19 @@ const isBrowser$1 = (win, doc) => typeof win !== 'undefined' && typeof doc !== '
21
22
  /**
22
23
  * The `Dropdown` component provides Bulma's versatile dropdown menu for your Bulma React UI.
23
24
  *
25
+ * Down, Enter and Space on the trigger open the menu on its first enabled
26
+ * item, and Up opens it on its last. On the trigger of a menu that's already
27
+ * open, Down and Up move focus to its first and last item. In the menu, the
28
+ * arrow keys, Home and End move between the items, and Enter and Space run
29
+ * the focused one the way a click does. Typing a letter moves to the next
30
+ * item whose text starts with it, skipping disabled ones, and letters typed
31
+ * in quick succession add up to one search. Typing searches once focus is in
32
+ * the menu, so a letter typed on the trigger does nothing. Escape closes the
33
+ * menu and focuses the trigger, and Tab closes it and lets focus move on.
34
+ * Anything focusable in the menu that isn't an item, such as a field, keeps
35
+ * its own keys apart from Escape and Tab. For a panel built around fields,
36
+ * use `Popover`.
37
+ *
24
38
  * @function
25
39
  * @param {DropdownProps} props - Props for the Dropdown component.
26
40
  * @param {React.Ref<HTMLDivElement>} ref - Forwarded ref to the root dropdown element.
@@ -31,6 +45,8 @@ const DropdownComponent = forwardRef(function DropdownComponent({ label, childre
31
45
  const [active, setActive] = useState(!!activeProp);
32
46
  const dropdownRef = useRef(null);
33
47
  const triggerRef = useRef(null);
48
+ const menuRef = useRef(null);
49
+ const menuKeys = useMenuKeys();
34
50
  const pendingFocusRef = useRef(null);
35
51
  // Cleanup returned by a consumer's callback ref on attach, held until detach.
36
52
  const consumerCleanupRef = useRef(null);
@@ -118,29 +134,23 @@ const DropdownComponent = forwardRef(function DropdownComponent({ label, childre
118
134
  }
119
135
  }
120
136
  };
121
- const getMenuItems = () => {
122
- /* istanbul ignore next: dropdownRef.current is never null once mounted */
123
- if (!dropdownRef.current)
124
- return [];
125
- return Array.from(
126
- // Every menu-item role, so an item a caller gives `menuitemcheckbox`
127
- // or `menuitemradio` (a filter or sort menu) stays reachable.
128
- dropdownRef.current.querySelectorAll('[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]')).filter(el => !el.hasAttribute('disabled') &&
129
- el.getAttribute('aria-disabled') !== 'true');
137
+ const focusEdgeItem = (edge) => {
138
+ const items = enabledMenuItems(menuRef.current);
139
+ items[edge === 'first' ? 0 : items.length - 1]?.focus();
130
140
  };
131
- // Focus the pending menu item once the menu becomes visible; the item is
132
- // unfocusable while `display: none` applies, so this must wait for the
133
- // `is-active` class to actually land in the DOM.
141
+ // Once the menu shows, forget a search typed just before it last closed,
142
+ // and focus the pending item. The item is unfocusable while
143
+ // `display: none` applies, so this must wait for the `is-active` class to
144
+ // actually land in the DOM.
134
145
  useEffect(() => {
135
- if (!active || !pendingFocusRef.current)
146
+ if (!active)
136
147
  return;
137
- const items = getMenuItems();
138
- if (items.length) {
139
- const index = pendingFocusRef.current === 'first' ? 0 : items.length - 1;
140
- items[index].focus();
141
- }
148
+ menuKeys.reset();
149
+ if (!pendingFocusRef.current)
150
+ return;
151
+ focusEdgeItem(pendingFocusRef.current);
142
152
  pendingFocusRef.current = null;
143
- }, [active]);
153
+ }, [active, menuKeys]);
144
154
  const handleTriggerKeyDown = (e) => {
145
155
  if (disabled)
146
156
  return;
@@ -153,9 +163,7 @@ const DropdownComponent = forwardRef(function DropdownComponent({ label, childre
153
163
  onActiveChange?.(true);
154
164
  }
155
165
  else {
156
- const items = getMenuItems();
157
- if (items.length)
158
- items[0].focus();
166
+ focusEdgeItem('first');
159
167
  pendingFocusRef.current = null;
160
168
  }
161
169
  break;
@@ -167,9 +175,7 @@ const DropdownComponent = forwardRef(function DropdownComponent({ label, childre
167
175
  onActiveChange?.(true);
168
176
  }
169
177
  else {
170
- const items = getMenuItems();
171
- if (items.length)
172
- items[items.length - 1].focus();
178
+ focusEdgeItem('last');
173
179
  pendingFocusRef.current = null;
174
180
  }
175
181
  break;
@@ -201,8 +207,10 @@ const DropdownComponent = forwardRef(function DropdownComponent({ label, childre
201
207
  }
202
208
  };
203
209
  const handleMenuKeyDown = (e) => {
204
- // Escape and Tab close the menu regardless of whether it has any focusable
205
- // items — an empty or all-disabled menu must still honor the close contract.
210
+ // Closing is Dropdown's: Escape and Tab close the menu from anywhere in
211
+ // it, a field included, and an empty or all-disabled menu too. Moving
212
+ // between the items, running them and typeahead are the hook's, which
213
+ // acts only while focus is on the menu or one of its items.
206
214
  if (e.key === 'Escape') {
207
215
  e.preventDefault();
208
216
  setActive(false);
@@ -215,66 +223,10 @@ const DropdownComponent = forwardRef(function DropdownComponent({ label, childre
215
223
  onActiveChange?.(false);
216
224
  return;
217
225
  }
218
- const items = getMenuItems();
219
- if (!items.length)
220
- return;
221
- const currentIndex = items.indexOf(getActiveElementInTree(e.currentTarget));
222
- switch (e.key) {
223
- case 'ArrowDown': {
224
- e.preventDefault();
225
- const next = currentIndex >= 0 ? (currentIndex + 1) % items.length : 0;
226
- items[next].focus();
227
- break;
228
- }
229
- case 'ArrowUp': {
230
- e.preventDefault();
231
- const prev = currentIndex >= 0
232
- ? (currentIndex - 1 + items.length) % items.length
233
- : items.length - 1;
234
- items[prev].focus();
235
- break;
236
- }
237
- case 'Home':
238
- e.preventDefault();
239
- items[0].focus();
240
- break;
241
- case 'End':
242
- e.preventDefault();
243
- items[items.length - 1].focus();
244
- break;
245
- case 'Enter':
246
- case ' ': {
247
- // Activate the focused item by clicking it, so its `onClick` runs and
248
- // closing follows `closeOnClick` as it does for the mouse. A caller's
249
- // own key handler that prevented the default has claimed the key, and
250
- // is left to it rather than followed by a second activation.
251
- if (currentIndex < 0 || e.defaultPrevented)
252
- break;
253
- const item = items[currentIndex];
254
- // Leave the browser's own activation alone, or the item runs twice: a
255
- // `<button>` answers both keys, and a link with an `href` answers
256
- // Enter. A link does not answer Space, so Space on a link is handled
257
- // here too, which also keeps the page from scrolling.
258
- if (item.tagName === 'BUTTON')
259
- break;
260
- if (e.key === 'Enter' &&
261
- item.tagName === 'A' &&
262
- item.hasAttribute('href')) {
263
- break;
264
- }
265
- e.preventDefault();
266
- // A held key sends a keydown per auto-repeat. Clicking on each would
267
- // toggle a checkbox item over and over while `closeOnClick` is off,
268
- // so only the first press activates. The default is still prevented
269
- // on the repeats above, so a held Space does not scroll the page.
270
- if (!e.repeat)
271
- item.click();
272
- break;
273
- }
274
- }
226
+ menuKeys.onKeyDown(e);
275
227
  };
276
228
  const dropdownClasses = classNames(bulmaClasses, bulmaHelperClasses, className);
277
- return (jsxs("div", { className: dropdownClasses, ref: setRefs, id: id, "data-testid": "dropdown-root", ...rest, children: [jsx("div", { className: usePrefixedClassNames('dropdown-trigger'), children: jsxs("button", { ref: triggerRef, className: buttonClass, "aria-haspopup": "true", "aria-controls": id ? `${id}-menu` : undefined, "aria-expanded": active, onClick: handleToggle, onKeyDown: handleTriggerKeyDown, disabled: disabled, type: "button", children: [jsx("span", { children: label }), jsx("span", { className: usePrefixedClassNames('icon', 'is-small'), "aria-hidden": "true", children: jsx("i", { className: "fas fa-angle-down" }) })] }) }), jsx("div", { className: classNames(usePrefixedClassNames('dropdown-menu'), menuClassName), id: id ? `${id}-menu` : undefined, role: "menu", "data-testid": "dropdown-menu", onKeyDown: handleMenuKeyDown,
229
+ return (jsxs("div", { className: dropdownClasses, ref: setRefs, id: id, "data-testid": "dropdown-root", ...rest, children: [jsx("div", { className: usePrefixedClassNames('dropdown-trigger'), children: jsxs("button", { ref: triggerRef, className: buttonClass, "aria-haspopup": "true", "aria-controls": id ? `${id}-menu` : undefined, "aria-expanded": active, onClick: handleToggle, onKeyDown: handleTriggerKeyDown, disabled: disabled, type: "button", children: [jsx("span", { children: label }), jsx("span", { className: usePrefixedClassNames('icon', 'is-small'), "aria-hidden": "true", children: jsx("i", { className: "fas fa-angle-down" }) })] }) }), jsx("div", { className: classNames(usePrefixedClassNames('dropdown-menu'), menuClassName), id: id ? `${id}-menu` : undefined, ref: menuRef, role: "menu", "data-testid": "dropdown-menu", onKeyDown: handleMenuKeyDown,
278
230
  // The menu, not its content, takes focus from a click between items,
279
231
  // so the menu owns nothing focusable but its items.
280
232
  tabIndex: -1, children: jsx("div", { className: usePrefixedClassNames('dropdown-content'), onClick: handleMenuClick, children: children }) })] }));
@@ -1 +1 @@
1
- {"version":3,"file":"Dropdown.js","sources":["../../../src/components/Dropdown.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useState,\n useRef,\n useEffect,\n} from 'react';\nimport { classNames, usePrefixedClassNames } from '../helpers/classNames';\nimport { useBulmaClasses, BulmaClassesProps } from '../helpers/useBulmaClasses';\nimport { withSubComponents } from '../helpers/withSubComponents';\nimport { getActiveElementInTree, isEventInside } from '../helpers/shadowDom';\nimport type { ConstrainedPolymorphicComponentWithoutRef } from '../helpers/polymorphic';\nimport {\n type AnchorOnlyAttributes,\n ANCHOR_ONLY_ATTRS,\n omitAttrs,\n} from '../helpers/anchorAttrs';\nimport { buttonType } from '../helpers/buttonType';\n\n/**\n * Checks if code is running in a browser environment.\n * @deprecated Dropdown's internal SSR guard, exported by accident; it will\n * be removed in the next major. Check `typeof window !== 'undefined' &&\n * typeof document !== 'undefined'` instead.\n * @param win - Window object.\n * @param doc - Document object.\n * @returns {boolean} True if in browser, false otherwise.\n */\nexport const isBrowser = (win?: typeof window, doc?: typeof document) =>\n typeof win !== 'undefined' && typeof doc !== 'undefined';\n\n/**\n * Props for the Dropdown component.\n * @extraProp {React.Ref<HTMLDivElement>} [ref] - Ref forwarded to the root dropdown element.\n */\nexport interface DropdownProps\n extends\n Omit<React.HTMLAttributes<HTMLDivElement>, keyof BulmaClassesProps>,\n BulmaClassesProps {\n /** The dropdown button/trigger content. */\n label: React.ReactNode;\n /** Dropdown menu items and dividers. */\n children: React.ReactNode;\n /** Additional CSS classes for root. */\n className?: string;\n /** Additional CSS classes for the dropdown menu. */\n menuClassName?: string;\n /** Whether the dropdown is open (controlled). */\n active?: boolean;\n /** Dropdown menu opens upward. */\n up?: boolean;\n /** Menu is right-aligned. */\n right?: boolean;\n /** Open on hover instead of click. */\n hoverable?: boolean;\n /** Disables the dropdown trigger. */\n disabled?: boolean;\n /** Callback when dropdown active state changes. */\n onActiveChange?: (active: boolean) => void;\n /** Close dropdown when a menu item is clicked, or activated with Enter or Space. */\n closeOnClick?: boolean;\n /** Root element ID (for aria-controls, etc). */\n id?: string;\n}\n\n/**\n * The `Dropdown` component provides Bulma's versatile dropdown menu for your Bulma React UI.\n *\n * @function\n * @param {DropdownProps} props - Props for the Dropdown component.\n * @param {React.Ref<HTMLDivElement>} ref - Forwarded ref to the root dropdown element.\n * @returns {JSX.Element} The rendered dropdown.\n * @see {@link https://bulma.io/documentation/components/dropdown/ | Bulma Dropdown documentation}\n */\nconst DropdownComponent = forwardRef<HTMLDivElement, DropdownProps>(\n function DropdownComponent(\n {\n label,\n children,\n className,\n menuClassName,\n active: activeProp,\n up,\n right,\n hoverable,\n disabled,\n onActiveChange,\n closeOnClick = true,\n id,\n ...props\n },\n ref\n ) {\n const [active, setActive] = useState<boolean>(!!activeProp);\n const dropdownRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const pendingFocusRef = useRef<'first' | 'last' | null>(null);\n\n // Cleanup returned by a consumer's callback ref on attach, held until detach.\n const consumerCleanupRef = useRef<(() => void) | null>(null);\n\n const setRefs = useCallback(\n (node: HTMLDivElement | null) => {\n (dropdownRef as React.MutableRefObject<HTMLDivElement | null>).current =\n node;\n if (typeof ref === 'function') {\n // React 19 lets a callback ref return a cleanup function and detaches\n // by running it instead of calling the ref with `null`; React 18\n // discards the return value entirely. Returning it from here would be\n // a React-19-only contract, so instead we hold the cleanup and run it\n // ourselves on detach — a consumer's cleanup ref then behaves the same\n // on both majors of the CI matrix.\n if (node === null) {\n const consumerCleanup = consumerCleanupRef.current;\n consumerCleanupRef.current = null;\n if (consumerCleanup) {\n consumerCleanup();\n } else {\n ref(null);\n }\n return;\n }\n const cleanup: unknown = ref(node);\n consumerCleanupRef.current =\n typeof cleanup === 'function' ? (cleanup as () => void) : null;\n } else if (ref) {\n (ref as React.MutableRefObject<HTMLDivElement | null>).current = node;\n }\n },\n [ref]\n );\n\n const { bulmaHelperClasses, rest } = useBulmaClasses(props);\n\n // Generate Bulma classes with prefix\n const bulmaClasses = usePrefixedClassNames('dropdown', {\n 'is-active': active,\n 'is-up': up,\n 'is-right': right,\n 'is-hoverable': hoverable,\n 'is-disabled': disabled,\n });\n\n const buttonClass = usePrefixedClassNames('button');\n\n // Controlled mode support: mirror the controlled `active` prop into local\n // state. This is an intentional external-prop sync (controlled/uncontrolled\n // hybrid); behavior is covered by tests and certified in-browser.\n useEffect(() => {\n // eslint-disable-next-line react-hooks/set-state-in-effect -- syncing to controlled prop\n if (typeof activeProp === 'boolean') setActive(activeProp);\n }, [activeProp]);\n\n // SSR-safe outside click\n useEffect(() => {\n if (!active) return;\n\n if (!isBrowser(window, document)) return;\n\n const handleClick = (e: MouseEvent) => {\n if (!isEventInside(e, dropdownRef.current)) {\n setActive(false);\n onActiveChange?.(false);\n }\n };\n document.addEventListener('mousedown', handleClick);\n return () => document.removeEventListener('mousedown', handleClick);\n }, [active, onActiveChange]);\n\n const handleToggle = () => {\n /* istanbul ignore next: guard is enforced by button[disabled] at the DOM level */\n if (disabled) return;\n\n const newActive = !active;\n setActive(newActive);\n onActiveChange?.(newActive);\n };\n\n const handleMenuClick = (e: React.MouseEvent<HTMLDivElement>) => {\n if (closeOnClick) {\n setActive(false);\n onActiveChange?.(false);\n // Closing hides the item that has focus, and the browser drops focus\n // to the page when that happens. Hand it back to the trigger, as\n // Escape does. An item that moved focus somewhere else keeps it there.\n // The menu around this content is what a click between items focuses.\n const menu = e.currentTarget.parentElement as HTMLElement;\n if (menu.contains(getActiveElementInTree(e.currentTarget))) {\n triggerRef.current?.focus();\n }\n }\n };\n\n const getMenuItems = (): HTMLElement[] => {\n /* istanbul ignore next: dropdownRef.current is never null once mounted */\n if (!dropdownRef.current) return [];\n return Array.from(\n // Every menu-item role, so an item a caller gives `menuitemcheckbox`\n // or `menuitemradio` (a filter or sort menu) stays reachable.\n dropdownRef.current.querySelectorAll<HTMLElement>(\n '[role=\"menuitem\"], [role=\"menuitemcheckbox\"], [role=\"menuitemradio\"]'\n )\n ).filter(\n el =>\n !el.hasAttribute('disabled') &&\n el.getAttribute('aria-disabled') !== 'true'\n );\n };\n\n // Focus the pending menu item once the menu becomes visible; the item is\n // unfocusable while `display: none` applies, so this must wait for the\n // `is-active` class to actually land in the DOM.\n useEffect(() => {\n if (!active || !pendingFocusRef.current) return;\n const items = getMenuItems();\n if (items.length) {\n const index =\n pendingFocusRef.current === 'first' ? 0 : items.length - 1;\n items[index].focus();\n }\n pendingFocusRef.current = null;\n }, [active]);\n\n const handleTriggerKeyDown = (\n e: React.KeyboardEvent<HTMLButtonElement>\n ) => {\n if (disabled) return;\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n pendingFocusRef.current = 'first';\n if (!active) {\n setActive(true);\n onActiveChange?.(true);\n } else {\n const items = getMenuItems();\n if (items.length) items[0].focus();\n pendingFocusRef.current = null;\n }\n break;\n case 'ArrowUp':\n e.preventDefault();\n pendingFocusRef.current = 'last';\n if (!active) {\n setActive(true);\n onActiveChange?.(true);\n } else {\n const items = getMenuItems();\n if (items.length) items[items.length - 1].focus();\n pendingFocusRef.current = null;\n }\n break;\n case 'Enter':\n case ' ':\n e.preventDefault();\n // A held key sends a keydown per auto-repeat. Running an item hands\n // focus back here, so without this a held Enter would reopen the\n // menu and run whichever item it focused next.\n if (e.repeat) break;\n if (!active) {\n pendingFocusRef.current = 'first';\n setActive(true);\n onActiveChange?.(true);\n } else {\n setActive(false);\n onActiveChange?.(false);\n }\n break;\n case 'Escape':\n if (active) {\n e.preventDefault();\n setActive(false);\n onActiveChange?.(false);\n }\n break;\n default:\n break;\n }\n };\n\n const handleMenuKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n // Escape and Tab close the menu regardless of whether it has any focusable\n // items — an empty or all-disabled menu must still honor the close contract.\n if (e.key === 'Escape') {\n e.preventDefault();\n setActive(false);\n onActiveChange?.(false);\n triggerRef.current?.focus();\n return;\n }\n if (e.key === 'Tab') {\n setActive(false);\n onActiveChange?.(false);\n return;\n }\n\n const items = getMenuItems();\n if (!items.length) return;\n const currentIndex = items.indexOf(\n getActiveElementInTree(e.currentTarget) as HTMLElement\n );\n switch (e.key) {\n case 'ArrowDown': {\n e.preventDefault();\n const next =\n currentIndex >= 0 ? (currentIndex + 1) % items.length : 0;\n items[next].focus();\n break;\n }\n case 'ArrowUp': {\n e.preventDefault();\n const prev =\n currentIndex >= 0\n ? (currentIndex - 1 + items.length) % items.length\n : items.length - 1;\n items[prev].focus();\n break;\n }\n case 'Home':\n e.preventDefault();\n items[0].focus();\n break;\n case 'End':\n e.preventDefault();\n items[items.length - 1].focus();\n break;\n case 'Enter':\n case ' ': {\n // Activate the focused item by clicking it, so its `onClick` runs and\n // closing follows `closeOnClick` as it does for the mouse. A caller's\n // own key handler that prevented the default has claimed the key, and\n // is left to it rather than followed by a second activation.\n if (currentIndex < 0 || e.defaultPrevented) break;\n const item = items[currentIndex];\n // Leave the browser's own activation alone, or the item runs twice: a\n // `<button>` answers both keys, and a link with an `href` answers\n // Enter. A link does not answer Space, so Space on a link is handled\n // here too, which also keeps the page from scrolling.\n if (item.tagName === 'BUTTON') break;\n if (\n e.key === 'Enter' &&\n item.tagName === 'A' &&\n item.hasAttribute('href')\n ) {\n break;\n }\n e.preventDefault();\n // A held key sends a keydown per auto-repeat. Clicking on each would\n // toggle a checkbox item over and over while `closeOnClick` is off,\n // so only the first press activates. The default is still prevented\n // on the repeats above, so a held Space does not scroll the page.\n if (!e.repeat) item.click();\n break;\n }\n default:\n break;\n }\n };\n\n const dropdownClasses = classNames(\n bulmaClasses,\n bulmaHelperClasses,\n className\n );\n\n return (\n <div\n className={dropdownClasses}\n ref={setRefs}\n id={id}\n data-testid=\"dropdown-root\"\n {...rest}\n >\n <div className={usePrefixedClassNames('dropdown-trigger')}>\n <button\n ref={triggerRef}\n className={buttonClass}\n aria-haspopup=\"true\"\n aria-controls={id ? `${id}-menu` : undefined}\n aria-expanded={active}\n onClick={handleToggle}\n onKeyDown={handleTriggerKeyDown}\n disabled={disabled}\n type=\"button\"\n >\n <span>{label}</span>\n <span\n className={usePrefixedClassNames('icon', 'is-small')}\n aria-hidden=\"true\"\n >\n <i className=\"fas fa-angle-down\" />\n </span>\n </button>\n </div>\n <div\n className={classNames(\n usePrefixedClassNames('dropdown-menu'),\n menuClassName\n )}\n id={id ? `${id}-menu` : undefined}\n role=\"menu\"\n data-testid=\"dropdown-menu\"\n onKeyDown={handleMenuKeyDown}\n // The menu, not its content, takes focus from a click between items,\n // so the menu owns nothing focusable but its items.\n tabIndex={-1}\n >\n <div\n className={usePrefixedClassNames('dropdown-content')}\n onClick={handleMenuClick}\n >\n {children}\n </div>\n </div>\n </div>\n );\n }\n);\n\n/**\n * The elements a dropdown item may render as. Bulma's dropdown markup names\n * these three and no others, so `as` is a closed set rather than an open\n * `React.ElementType`.\n */\nexport type DropdownItemElement = 'a' | 'div' | 'button';\n\n/**\n * The DropdownItem component's own props.\n */\nexport interface DropdownItemOwnProps extends BulmaClassesProps {\n /** Whether the item is active. */\n active?: boolean;\n /** Additional CSS classes. */\n className?: string;\n /** Marks the item as disabled; disabled items are skipped during keyboard navigation. Use with `as=\"button\"` for a native disabled control, or pair with `aria-disabled` on a link. */\n disabled?: boolean;\n /** Item content. */\n children?: React.ReactNode;\n}\n\n/**\n * Props for the DropdownItem component. Everything the item does not own\n * follows `as`: `href`, `target` and `rel` under the default `'a'`, `type` and\n * `form` under `'button'`, and the shared HTML attributes under any of them.\n *\n * Pinning these to `React.HTMLAttributes<HTMLElement>` instead — which is what\n * this type did before — rejected `href` on an anchor and `type` on a button,\n * both of which have always worked at runtime. Same defect as #641, in the\n * narrower shape a constrained `as` takes.\n *\n * **Name the tag you mean.** The type parameter defaults to the whole union, not\n * to the rendered element, so bare `DropdownItemProps` keeps accepting\n * `{ as: 'div' }` the way it always has. The cost is that it is not\n * distributive: `Omit` over a union keeps only the shared keys, so the bare\n * alias carries no `href` even though the component takes one under `as=\"a\"`.\n * Write `DropdownItemProps<'a'>` for the anchor's props. That is the #667 alias\n * limitation Button carries, labelled next-major because closing it is\n * source-breaking, and pinned for this component in\n * `__typetests__/polymorphic.tsx`; the component itself is unaffected.\n */\nexport type DropdownItemProps<\n T extends DropdownItemElement = DropdownItemElement,\n> = DropdownItemOwnProps &\n Omit<React.ComponentPropsWithoutRef<T>, keyof DropdownItemOwnProps | 'as'> & {\n /**\n * The element type to render.\n *\n * `'button'` renders `type=\"button\"` unless you pass `type=\"submit\"` or `type=\"reset\"`, so\n * an item inside a form does not submit it.\n */\n as?: T;\n };\n\n/**\n * The anchor's attributes, minus the one a `<button>` legitimately takes.\n *\n * `type` stays: `as=\"button\"` is a supported form and `type=\"submit\"` is valid\n * there, so stripping it would remove a working attribute. A `<div>` takes no\n * `type`, so it gets the whole `ANCHOR_ONLY_ATTRS` set instead. The set is\n * chosen by the rendered tag because that is where the reason lives (#692).\n *\n * Neither set withholds `rel`, which `Level.Item` does: React declares `rel` on\n * `HTMLAttributes` for every element, so withholding it would diverge from\n * React's own typing, the call #641 recorded for `Navbar.Link`. Level\n * withholds it anyway, because it always has.\n */\nconst STRIP_FROM_BUTTON: Readonly<\n Record<Exclude<keyof AnchorOnlyAttributes, 'type'>, true>\n> = (() => {\n const { type: _type, ...rest } = ANCHOR_ONLY_ATTRS;\n return rest;\n})();\n\n/**\n * The shape the implementation destructures. The public contract is the generic\n * `DropdownItemProps<T>` above — the body cannot see through `T`.\n */\ntype DropdownItemImplProps = DropdownItemOwnProps & {\n as?: DropdownItemElement;\n};\n\n/**\n * Bulma Dropdown item.\n *\n * @function\n * @param {DropdownItemProps} props - Props for the DropdownItem component.\n * @returns {JSX.Element} The rendered dropdown item.\n */\nexport const DropdownItem = ((itemProps: DropdownItemProps) => {\n const {\n children,\n active,\n className,\n as: Component = 'a',\n ...props\n } = itemProps as DropdownItemImplProps;\n const { bulmaHelperClasses, rest } = useBulmaClasses(props);\n // The anchor's attributes reach an anchor and nothing else — `<div href>` and\n // `<button target>` are invalid HTML. The same rule Menu applies, for the same\n // reason: the type now derives these from `as`, and deriving them must not\n // quietly widen where they land. The type stops a direct caller; this stops a\n // plain-JS one, a loose `{...props}` spread, and the genericity a wrapping HOC\n // erases.\n //\n // The whole link set, not `href` alone: they all arrive together under\n // `as=\"a\"`. Menu strips `href` only, because its `as` is open and a flat set\n // would delete attributes legal on the element a caller named.\n //\n // `bestax-migrate` tracks the same question from the other side, per attribute\n // per element (`LINK_ATTR_ELEMENTS`) rather than as one set — so the two lists\n // are not interchangeable and neither derives from the other.\n //\n // Menu's condition also admits a custom component and a custom element, which\n // own their prop contracts. Here the set follows the tag: an `<a>` keeps all\n // of them, a `<button>` keeps `type`, and any other `as` keeps none of them.\n const forwarded =\n Component === 'a'\n ? rest\n : Component === 'button'\n ? omitAttrs(rest, STRIP_FROM_BUTTON)\n : omitAttrs(rest, ANCHOR_ONLY_ATTRS);\n return (\n <Component\n className={classNames(\n usePrefixedClassNames('dropdown-item', {\n 'is-active': active,\n }),\n bulmaHelperClasses,\n className\n )}\n data-testid=\"dropdown-item\"\n {...forwarded}\n // After `forwarded` for the same reason as `role` and `type` below: a\n // spread carrying `tabIndex: undefined` would otherwise erase the\n // default. The item keeps its menu role and its place in the arrow-key\n // order, but a `<div>` or an anchor without an `href` cannot take focus\n // without a tabindex, so the arrow keys stall on it.\n tabIndex={(forwarded as { tabIndex?: number }).tabIndex ?? 0}\n // After `forwarded` for the same reason as `type` below: a spread\n // carrying `role: undefined` would otherwise erase the default, and an\n // item with no role drops out of the menu and its arrow-key order.\n role={(forwarded as { role?: React.AriaRole }).role ?? 'menuitem'}\n // A menu item inside a form must not submit it. `<button>` defaults to\n // type=\"submit\", and a filter or sort menu sitting in a form is ordinary.\n // Dropdown's own trigger sets it, and `Avatar` and `Menu.Item` default it\n // the same way. A caller's `submit` or `reset` still wins, and anything\n // else becomes `button`, since HTML reads a value it does not define for\n // a button as submit too; `buttonType` says more.\n //\n // After `forwarded`, reading through it rather than before it: React\n // treats `type={undefined}` as \"remove the attribute\", and a spread\n // carrying an absent key is how that arrives. Spreading the default first\n // let such a spread erase it and restore the submit behaviour, so the\n // guard only held for callers who passed nothing.\n {...(Component === 'button'\n ? { type: buttonType((forwarded as { type?: unknown }).type) }\n : {})}\n >\n {children}\n </Component>\n );\n}) as ConstrainedPolymorphicComponentWithoutRef<\n DropdownItemOwnProps,\n DropdownItemElement,\n 'a'\n>;\n\n/**\n * Bulma Dropdown divider.\n *\n * @function\n * @returns {JSX.Element} The rendered divider element.\n */\nexport const DropdownDivider: React.FC = () => (\n <hr className={usePrefixedClassNames('dropdown-divider')} />\n);\n\n/** Bulma Dropdown component with Item and Divider sub-components. */\nexport const Dropdown = withSubComponents(\n DropdownComponent,\n {\n Item: DropdownItem,\n Divider: DropdownDivider,\n },\n 'Dropdown'\n);\n\nexport default Dropdown;\n"],"names":["isBrowser","_jsxs","_jsx"],"mappings":";;;;;;;;;;AAmBA;;;;;;;;AAQG;MACUA,WAAS,GAAG,CAAC,GAAmB,EAAE,GAAqB,KAClE,OAAO,GAAG,KAAK,WAAW,IAAI,OAAO,GAAG,KAAK;AAoC/C;;;;;;;;AAQG;AACH,MAAM,iBAAiB,GAAG,UAAU,CAClC,SAAS,iBAAiB,CACxB,EACE,KAAK,EACL,QAAQ,EACR,SAAS,EACT,aAAa,EACb,MAAM,EAAE,UAAU,EAClB,EAAE,EACF,KAAK,EACL,SAAS,EACT,QAAQ,EACR,cAAc,EACd,YAAY,GAAG,IAAI,EACnB,EAAE,EACF,GAAG,KAAK,EACT,EACD,GAAG,EAAA;A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;;;;;;;;;;;AAmB3D,IAAA,MAAM,SAAS,GACb,SAAS,KAAK;AACZ,UAAE;UACA,SAAS,KAAK;AACd,cAAE,SAAS,CAAC,IAAI,EAAE,iBAAiB;AACnC,cAAE,SAAS,CAAC,IAAI,EAAE,iBAAiB,CAAC;IAC1C,QACEA,GAAA,CAAC,SAAS,EAAA,EACR,SAAS,EAAE,UAAU,CACnB,qBAAqB,CAAC,eAAe,EAAE;AACrC,YAAA,WAAW,EAAE,MAAM;SACpB,CAAC,EACF,kBAAkB,EAClB,SAAS,CACV,EAAA,aAAA,EACW,eAAe,KACvB,SAAS;;;;;;AAMb,QAAA,QAAQ,EAAG,SAAmC,CAAC,QAAQ,IAAI,CAAC;;;;QAI5D,IAAI,EAAG,SAAuC,CAAC,IAAI,IAAI,UAAU,EAAA,IAa5D,SAAS,KAAK;cACf,EAAE,IAAI,EAAE,UAAU,CAAE,SAAgC,CAAC,IAAI,CAAC;AAC5D,cAAE,EAAE,CAAC,YAEN,QAAQ,EAAA,CACC;AAEhB,CAAC;AAMD;;;;;AAKG;AACI,MAAM,eAAe,GAAa,OACvCA,GAAA,CAAA,IAAA,EAAA,EAAI,SAAS,EAAE,qBAAqB,CAAC,kBAAkB,CAAC,EAAA,CAAI;AAG9D;AACO,MAAM,QAAQ,GAAG,iBAAiB,CACvC,iBAAiB,EACjB;AACE,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,OAAO,EAAE,eAAe;CACzB,EACD,UAAU;;"}
1
+ {"version":3,"file":"Dropdown.js","sources":["../../../src/components/Dropdown.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useState,\n useRef,\n useEffect,\n} from 'react';\nimport { classNames, usePrefixedClassNames } from '../helpers/classNames';\nimport { useBulmaClasses, BulmaClassesProps } from '../helpers/useBulmaClasses';\nimport { withSubComponents } from '../helpers/withSubComponents';\nimport { getActiveElementInTree, isEventInside } from '../helpers/shadowDom';\nimport type { ConstrainedPolymorphicComponentWithoutRef } from '../helpers/polymorphic';\nimport {\n type AnchorOnlyAttributes,\n ANCHOR_ONLY_ATTRS,\n omitAttrs,\n} from '../helpers/anchorAttrs';\nimport { buttonType } from '../helpers/buttonType';\nimport { enabledMenuItems, useMenuKeys } from '../helpers/useMenuKeys';\n\n/**\n * Checks if code is running in a browser environment.\n * @deprecated Dropdown's internal SSR guard, exported by accident; it will\n * be removed in the next major. Check `typeof window !== 'undefined' &&\n * typeof document !== 'undefined'` instead.\n * @param win - Window object.\n * @param doc - Document object.\n * @returns {boolean} True if in browser, false otherwise.\n */\nexport const isBrowser = (win?: typeof window, doc?: typeof document) =>\n typeof win !== 'undefined' && typeof doc !== 'undefined';\n\n/**\n * Props for the Dropdown component.\n * @extraProp {React.Ref<HTMLDivElement>} [ref] - Ref forwarded to the root dropdown element.\n */\nexport interface DropdownProps\n extends\n Omit<React.HTMLAttributes<HTMLDivElement>, keyof BulmaClassesProps>,\n BulmaClassesProps {\n /** The dropdown button/trigger content. */\n label: React.ReactNode;\n /** Dropdown menu items and dividers. */\n children: React.ReactNode;\n /** Additional CSS classes for root. */\n className?: string;\n /** Additional CSS classes for the dropdown menu. */\n menuClassName?: string;\n /** Whether the dropdown is open (controlled). */\n active?: boolean;\n /** Dropdown menu opens upward. */\n up?: boolean;\n /** Menu is right-aligned. */\n right?: boolean;\n /** Open on hover instead of click. */\n hoverable?: boolean;\n /** Disables the dropdown trigger. */\n disabled?: boolean;\n /** Callback when dropdown active state changes. */\n onActiveChange?: (active: boolean) => void;\n /** Close dropdown when a menu item is clicked, or activated with Enter or Space. */\n closeOnClick?: boolean;\n /** Root element ID (for aria-controls, etc). */\n id?: string;\n}\n\n/**\n * The `Dropdown` component provides Bulma's versatile dropdown menu for your Bulma React UI.\n *\n * Down, Enter and Space on the trigger open the menu on its first enabled\n * item, and Up opens it on its last. On the trigger of a menu that's already\n * open, Down and Up move focus to its first and last item. In the menu, the\n * arrow keys, Home and End move between the items, and Enter and Space run\n * the focused one the way a click does. Typing a letter moves to the next\n * item whose text starts with it, skipping disabled ones, and letters typed\n * in quick succession add up to one search. Typing searches once focus is in\n * the menu, so a letter typed on the trigger does nothing. Escape closes the\n * menu and focuses the trigger, and Tab closes it and lets focus move on.\n * Anything focusable in the menu that isn't an item, such as a field, keeps\n * its own keys apart from Escape and Tab. For a panel built around fields,\n * use `Popover`.\n *\n * @function\n * @param {DropdownProps} props - Props for the Dropdown component.\n * @param {React.Ref<HTMLDivElement>} ref - Forwarded ref to the root dropdown element.\n * @returns {JSX.Element} The rendered dropdown.\n * @see {@link https://bulma.io/documentation/components/dropdown/ | Bulma Dropdown documentation}\n */\nconst DropdownComponent = forwardRef<HTMLDivElement, DropdownProps>(\n function DropdownComponent(\n {\n label,\n children,\n className,\n menuClassName,\n active: activeProp,\n up,\n right,\n hoverable,\n disabled,\n onActiveChange,\n closeOnClick = true,\n id,\n ...props\n },\n ref\n ) {\n const [active, setActive] = useState<boolean>(!!activeProp);\n const dropdownRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const menuRef = useRef<HTMLDivElement>(null);\n const menuKeys = useMenuKeys();\n const pendingFocusRef = useRef<'first' | 'last' | null>(null);\n\n // Cleanup returned by a consumer's callback ref on attach, held until detach.\n const consumerCleanupRef = useRef<(() => void) | null>(null);\n\n const setRefs = useCallback(\n (node: HTMLDivElement | null) => {\n (dropdownRef as React.MutableRefObject<HTMLDivElement | null>).current =\n node;\n if (typeof ref === 'function') {\n // React 19 lets a callback ref return a cleanup function and detaches\n // by running it instead of calling the ref with `null`; React 18\n // discards the return value entirely. Returning it from here would be\n // a React-19-only contract, so instead we hold the cleanup and run it\n // ourselves on detach — a consumer's cleanup ref then behaves the same\n // on both majors of the CI matrix.\n if (node === null) {\n const consumerCleanup = consumerCleanupRef.current;\n consumerCleanupRef.current = null;\n if (consumerCleanup) {\n consumerCleanup();\n } else {\n ref(null);\n }\n return;\n }\n const cleanup: unknown = ref(node);\n consumerCleanupRef.current =\n typeof cleanup === 'function' ? (cleanup as () => void) : null;\n } else if (ref) {\n (ref as React.MutableRefObject<HTMLDivElement | null>).current = node;\n }\n },\n [ref]\n );\n\n const { bulmaHelperClasses, rest } = useBulmaClasses(props);\n\n // Generate Bulma classes with prefix\n const bulmaClasses = usePrefixedClassNames('dropdown', {\n 'is-active': active,\n 'is-up': up,\n 'is-right': right,\n 'is-hoverable': hoverable,\n 'is-disabled': disabled,\n });\n\n const buttonClass = usePrefixedClassNames('button');\n\n // Controlled mode support: mirror the controlled `active` prop into local\n // state. This is an intentional external-prop sync (controlled/uncontrolled\n // hybrid); behavior is covered by tests and certified in-browser.\n useEffect(() => {\n // eslint-disable-next-line react-hooks/set-state-in-effect -- syncing to controlled prop\n if (typeof activeProp === 'boolean') setActive(activeProp);\n }, [activeProp]);\n\n // SSR-safe outside click\n useEffect(() => {\n if (!active) return;\n\n if (!isBrowser(window, document)) return;\n\n const handleClick = (e: MouseEvent) => {\n if (!isEventInside(e, dropdownRef.current)) {\n setActive(false);\n onActiveChange?.(false);\n }\n };\n document.addEventListener('mousedown', handleClick);\n return () => document.removeEventListener('mousedown', handleClick);\n }, [active, onActiveChange]);\n\n const handleToggle = () => {\n /* istanbul ignore next: guard is enforced by button[disabled] at the DOM level */\n if (disabled) return;\n\n const newActive = !active;\n setActive(newActive);\n onActiveChange?.(newActive);\n };\n\n const handleMenuClick = (e: React.MouseEvent<HTMLDivElement>) => {\n if (closeOnClick) {\n setActive(false);\n onActiveChange?.(false);\n // Closing hides the item that has focus, and the browser drops focus\n // to the page when that happens. Hand it back to the trigger, as\n // Escape does. An item that moved focus somewhere else keeps it there.\n // The menu around this content is what a click between items focuses.\n const menu = e.currentTarget.parentElement as HTMLElement;\n if (menu.contains(getActiveElementInTree(e.currentTarget))) {\n triggerRef.current?.focus();\n }\n }\n };\n\n const focusEdgeItem = (edge: 'first' | 'last') => {\n const items = enabledMenuItems(menuRef.current as HTMLElement);\n items[edge === 'first' ? 0 : items.length - 1]?.focus();\n };\n\n // Once the menu shows, forget a search typed just before it last closed,\n // and focus the pending item. The item is unfocusable while\n // `display: none` applies, so this must wait for the `is-active` class to\n // actually land in the DOM.\n useEffect(() => {\n if (!active) return;\n menuKeys.reset();\n if (!pendingFocusRef.current) return;\n focusEdgeItem(pendingFocusRef.current);\n pendingFocusRef.current = null;\n }, [active, menuKeys]);\n\n const handleTriggerKeyDown = (\n e: React.KeyboardEvent<HTMLButtonElement>\n ) => {\n if (disabled) return;\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n pendingFocusRef.current = 'first';\n if (!active) {\n setActive(true);\n onActiveChange?.(true);\n } else {\n focusEdgeItem('first');\n pendingFocusRef.current = null;\n }\n break;\n case 'ArrowUp':\n e.preventDefault();\n pendingFocusRef.current = 'last';\n if (!active) {\n setActive(true);\n onActiveChange?.(true);\n } else {\n focusEdgeItem('last');\n pendingFocusRef.current = null;\n }\n break;\n case 'Enter':\n case ' ':\n e.preventDefault();\n // A held key sends a keydown per auto-repeat. Running an item hands\n // focus back here, so without this a held Enter would reopen the\n // menu and run whichever item it focused next.\n if (e.repeat) break;\n if (!active) {\n pendingFocusRef.current = 'first';\n setActive(true);\n onActiveChange?.(true);\n } else {\n setActive(false);\n onActiveChange?.(false);\n }\n break;\n case 'Escape':\n if (active) {\n e.preventDefault();\n setActive(false);\n onActiveChange?.(false);\n }\n break;\n default:\n break;\n }\n };\n\n const handleMenuKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n // Closing is Dropdown's: Escape and Tab close the menu from anywhere in\n // it, a field included, and an empty or all-disabled menu too. Moving\n // between the items, running them and typeahead are the hook's, which\n // acts only while focus is on the menu or one of its items.\n if (e.key === 'Escape') {\n e.preventDefault();\n setActive(false);\n onActiveChange?.(false);\n triggerRef.current?.focus();\n return;\n }\n if (e.key === 'Tab') {\n setActive(false);\n onActiveChange?.(false);\n return;\n }\n\n menuKeys.onKeyDown(e);\n };\n\n const dropdownClasses = classNames(\n bulmaClasses,\n bulmaHelperClasses,\n className\n );\n\n return (\n <div\n className={dropdownClasses}\n ref={setRefs}\n id={id}\n data-testid=\"dropdown-root\"\n {...rest}\n >\n <div className={usePrefixedClassNames('dropdown-trigger')}>\n <button\n ref={triggerRef}\n className={buttonClass}\n aria-haspopup=\"true\"\n aria-controls={id ? `${id}-menu` : undefined}\n aria-expanded={active}\n onClick={handleToggle}\n onKeyDown={handleTriggerKeyDown}\n disabled={disabled}\n type=\"button\"\n >\n <span>{label}</span>\n <span\n className={usePrefixedClassNames('icon', 'is-small')}\n aria-hidden=\"true\"\n >\n <i className=\"fas fa-angle-down\" />\n </span>\n </button>\n </div>\n <div\n className={classNames(\n usePrefixedClassNames('dropdown-menu'),\n menuClassName\n )}\n id={id ? `${id}-menu` : undefined}\n ref={menuRef}\n role=\"menu\"\n data-testid=\"dropdown-menu\"\n onKeyDown={handleMenuKeyDown}\n // The menu, not its content, takes focus from a click between items,\n // so the menu owns nothing focusable but its items.\n tabIndex={-1}\n >\n <div\n className={usePrefixedClassNames('dropdown-content')}\n onClick={handleMenuClick}\n >\n {children}\n </div>\n </div>\n </div>\n );\n }\n);\n\n/**\n * The elements a dropdown item may render as. Bulma's dropdown markup names\n * these three and no others, so `as` is a closed set rather than an open\n * `React.ElementType`.\n */\nexport type DropdownItemElement = 'a' | 'div' | 'button';\n\n/**\n * The DropdownItem component's own props.\n */\nexport interface DropdownItemOwnProps extends BulmaClassesProps {\n /** Whether the item is active. */\n active?: boolean;\n /** Additional CSS classes. */\n className?: string;\n /** Marks the item as disabled; disabled items are skipped during keyboard navigation. Use with `as=\"button\"` for a native disabled control, or pair with `aria-disabled` on a link. */\n disabled?: boolean;\n /** Item content. */\n children?: React.ReactNode;\n}\n\n/**\n * Props for the DropdownItem component. Everything the item does not own\n * follows `as`: `href`, `target` and `rel` under the default `'a'`, `type` and\n * `form` under `'button'`, and the shared HTML attributes under any of them.\n *\n * Pinning these to `React.HTMLAttributes<HTMLElement>` instead — which is what\n * this type did before — rejected `href` on an anchor and `type` on a button,\n * both of which have always worked at runtime. Same defect as #641, in the\n * narrower shape a constrained `as` takes.\n *\n * **Name the tag you mean.** The type parameter defaults to the whole union, not\n * to the rendered element, so bare `DropdownItemProps` keeps accepting\n * `{ as: 'div' }` the way it always has. The cost is that it is not\n * distributive: `Omit` over a union keeps only the shared keys, so the bare\n * alias carries no `href` even though the component takes one under `as=\"a\"`.\n * Write `DropdownItemProps<'a'>` for the anchor's props. That is the #667 alias\n * limitation Button carries, labelled next-major because closing it is\n * source-breaking, and pinned for this component in\n * `__typetests__/polymorphic.tsx`; the component itself is unaffected.\n */\nexport type DropdownItemProps<\n T extends DropdownItemElement = DropdownItemElement,\n> = DropdownItemOwnProps &\n Omit<React.ComponentPropsWithoutRef<T>, keyof DropdownItemOwnProps | 'as'> & {\n /**\n * The element type to render.\n *\n * `'button'` renders `type=\"button\"` unless you pass `type=\"submit\"` or `type=\"reset\"`, so\n * an item inside a form does not submit it.\n */\n as?: T;\n };\n\n/**\n * The anchor's attributes, minus the one a `<button>` legitimately takes.\n *\n * `type` stays: `as=\"button\"` is a supported form and `type=\"submit\"` is valid\n * there, so stripping it would remove a working attribute. A `<div>` takes no\n * `type`, so it gets the whole `ANCHOR_ONLY_ATTRS` set instead. The set is\n * chosen by the rendered tag because that is where the reason lives (#692).\n *\n * Neither set withholds `rel`, which `Level.Item` does: React declares `rel` on\n * `HTMLAttributes` for every element, so withholding it would diverge from\n * React's own typing, the call #641 recorded for `Navbar.Link`. Level\n * withholds it anyway, because it always has.\n */\nconst STRIP_FROM_BUTTON: Readonly<\n Record<Exclude<keyof AnchorOnlyAttributes, 'type'>, true>\n> = (() => {\n const { type: _type, ...rest } = ANCHOR_ONLY_ATTRS;\n return rest;\n})();\n\n/**\n * The shape the implementation destructures. The public contract is the generic\n * `DropdownItemProps<T>` above — the body cannot see through `T`.\n */\ntype DropdownItemImplProps = DropdownItemOwnProps & {\n as?: DropdownItemElement;\n};\n\n/**\n * Bulma Dropdown item.\n *\n * @function\n * @param {DropdownItemProps} props - Props for the DropdownItem component.\n * @returns {JSX.Element} The rendered dropdown item.\n */\nexport const DropdownItem = ((itemProps: DropdownItemProps) => {\n const {\n children,\n active,\n className,\n as: Component = 'a',\n ...props\n } = itemProps as DropdownItemImplProps;\n const { bulmaHelperClasses, rest } = useBulmaClasses(props);\n // The anchor's attributes reach an anchor and nothing else — `<div href>` and\n // `<button target>` are invalid HTML. The same rule Menu applies, for the same\n // reason: the type now derives these from `as`, and deriving them must not\n // quietly widen where they land. The type stops a direct caller; this stops a\n // plain-JS one, a loose `{...props}` spread, and the genericity a wrapping HOC\n // erases.\n //\n // The whole link set, not `href` alone: they all arrive together under\n // `as=\"a\"`. Menu strips `href` only, because its `as` is open and a flat set\n // would delete attributes legal on the element a caller named.\n //\n // `bestax-migrate` tracks the same question from the other side, per attribute\n // per element (`LINK_ATTR_ELEMENTS`) rather than as one set — so the two lists\n // are not interchangeable and neither derives from the other.\n //\n // Menu's condition also admits a custom component and a custom element, which\n // own their prop contracts. Here the set follows the tag: an `<a>` keeps all\n // of them, a `<button>` keeps `type`, and any other `as` keeps none of them.\n const forwarded =\n Component === 'a'\n ? rest\n : Component === 'button'\n ? omitAttrs(rest, STRIP_FROM_BUTTON)\n : omitAttrs(rest, ANCHOR_ONLY_ATTRS);\n return (\n <Component\n className={classNames(\n usePrefixedClassNames('dropdown-item', {\n 'is-active': active,\n }),\n bulmaHelperClasses,\n className\n )}\n data-testid=\"dropdown-item\"\n {...forwarded}\n // After `forwarded` for the same reason as `role` and `type` below: a\n // spread carrying `tabIndex: undefined` would otherwise erase the\n // default. The item keeps its menu role and its place in the arrow-key\n // order, but a `<div>` or an anchor without an `href` cannot take focus\n // without a tabindex, so the arrow keys stall on it.\n tabIndex={(forwarded as { tabIndex?: number }).tabIndex ?? 0}\n // After `forwarded` for the same reason as `type` below: a spread\n // carrying `role: undefined` would otherwise erase the default, and an\n // item with no role drops out of the menu and its arrow-key order.\n role={(forwarded as { role?: React.AriaRole }).role ?? 'menuitem'}\n // A menu item inside a form must not submit it. `<button>` defaults to\n // type=\"submit\", and a filter or sort menu sitting in a form is ordinary.\n // Dropdown's own trigger sets it, and `Avatar` and `Menu.Item` default it\n // the same way. A caller's `submit` or `reset` still wins, and anything\n // else becomes `button`, since HTML reads a value it does not define for\n // a button as submit too; `buttonType` says more.\n //\n // After `forwarded`, reading through it rather than before it: React\n // treats `type={undefined}` as \"remove the attribute\", and a spread\n // carrying an absent key is how that arrives. Spreading the default first\n // let such a spread erase it and restore the submit behaviour, so the\n // guard only held for callers who passed nothing.\n {...(Component === 'button'\n ? { type: buttonType((forwarded as { type?: unknown }).type) }\n : {})}\n >\n {children}\n </Component>\n );\n}) as ConstrainedPolymorphicComponentWithoutRef<\n DropdownItemOwnProps,\n DropdownItemElement,\n 'a'\n>;\n\n/**\n * Bulma Dropdown divider.\n *\n * @function\n * @returns {JSX.Element} The rendered divider element.\n */\nexport const DropdownDivider: React.FC = () => (\n <hr className={usePrefixedClassNames('dropdown-divider')} />\n);\n\n/** Bulma Dropdown component with Item and Divider sub-components. */\nexport const Dropdown = withSubComponents(\n DropdownComponent,\n {\n Item: DropdownItem,\n Divider: DropdownDivider,\n },\n 'Dropdown'\n);\n\nexport default Dropdown;\n"],"names":["isBrowser","_jsxs","_jsx"],"mappings":";;;;;;;;;;;AAoBA;;;;;;;;AAQG;MACUA,WAAS,GAAG,CAAC,GAAmB,EAAE,GAAqB,KAClE,OAAO,GAAG,KAAK,WAAW,IAAI,OAAO,GAAG,KAAK;AAoC/C;;;;;;;;;;;;;;;;;;;;;AAqBG;AACH,MAAM,iBAAiB,GAAG,UAAU,CAClC,SAAS,iBAAiB,CACxB,EACE,KAAK,EACL,QAAQ,EACR,SAAS,EACT,aAAa,EACb,MAAM,EAAE,UAAU,EAClB,EAAE,EACF,KAAK,EACL,SAAS,EACT,QAAQ,EACR,cAAc,EACd,YAAY,GAAG,IAAI,EACnB,EAAE,EACF,GAAG,KAAK,EACT,EACD,GAAG,EAAA;AAEH,IAAA,MAAM,C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