@asafarim/react-dropdowns 1.0.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.
@@ -0,0 +1,411 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import React, { useState, useRef, useCallback, useEffect, forwardRef } from 'react';
3
+ import { createPortal } from 'react-dom';
4
+
5
+ const useDropdown = ({ placement = 'bottom-start', offset = 8, closeOnSelect = true } = {}) => {
6
+ const [isOpen, setIsOpen] = useState(false);
7
+ const [position, setPosition] = useState({});
8
+ const triggerRef = useRef(null);
9
+ const menuRef = useRef(null);
10
+ const calculatePosition = useCallback(() => {
11
+ if (!triggerRef.current || !menuRef.current)
12
+ return;
13
+ const triggerRect = triggerRef.current.getBoundingClientRect();
14
+ const menuRect = menuRef.current.getBoundingClientRect();
15
+ const viewport = {
16
+ width: window.innerWidth,
17
+ height: window.innerHeight
18
+ };
19
+ let newPosition = {};
20
+ // Calculate base position based on placement
21
+ switch (placement) {
22
+ case 'top':
23
+ newPosition = {
24
+ bottom: viewport.height - triggerRect.top + offset,
25
+ left: triggerRect.left + (triggerRect.width - menuRect.width) / 2
26
+ };
27
+ break;
28
+ case 'top-start':
29
+ newPosition = {
30
+ bottom: viewport.height - triggerRect.top + offset,
31
+ left: triggerRect.left
32
+ };
33
+ break;
34
+ case 'top-end':
35
+ newPosition = {
36
+ bottom: viewport.height - triggerRect.top + offset,
37
+ right: viewport.width - triggerRect.right
38
+ };
39
+ break;
40
+ case 'bottom':
41
+ newPosition = {
42
+ top: triggerRect.bottom + offset,
43
+ left: triggerRect.left + (triggerRect.width - menuRect.width) / 2
44
+ };
45
+ break;
46
+ case 'bottom-start':
47
+ newPosition = {
48
+ top: triggerRect.bottom + offset,
49
+ left: triggerRect.left
50
+ };
51
+ break;
52
+ case 'bottom-end':
53
+ newPosition = {
54
+ top: triggerRect.bottom + offset,
55
+ right: viewport.width - triggerRect.right
56
+ };
57
+ break;
58
+ case 'left':
59
+ newPosition = {
60
+ top: triggerRect.top + (triggerRect.height - menuRect.height) / 2,
61
+ right: viewport.width - triggerRect.left + offset
62
+ };
63
+ break;
64
+ case 'left-start':
65
+ newPosition = {
66
+ top: triggerRect.top,
67
+ right: viewport.width - triggerRect.left + offset
68
+ };
69
+ break;
70
+ case 'left-end':
71
+ newPosition = {
72
+ bottom: viewport.height - triggerRect.bottom,
73
+ right: viewport.width - triggerRect.left + offset
74
+ };
75
+ break;
76
+ case 'right':
77
+ newPosition = {
78
+ top: triggerRect.top + (triggerRect.height - menuRect.height) / 2,
79
+ left: triggerRect.right + offset
80
+ };
81
+ break;
82
+ case 'right-start':
83
+ newPosition = {
84
+ top: triggerRect.top,
85
+ left: triggerRect.right + offset
86
+ };
87
+ break;
88
+ case 'right-end':
89
+ newPosition = {
90
+ bottom: viewport.height - triggerRect.bottom,
91
+ left: triggerRect.right + offset
92
+ };
93
+ break;
94
+ }
95
+ // Adjust for viewport boundaries
96
+ if (newPosition.left !== undefined) {
97
+ if (newPosition.left < 0) {
98
+ newPosition.left = 8;
99
+ }
100
+ else if (newPosition.left + menuRect.width > viewport.width) {
101
+ newPosition.left = viewport.width - menuRect.width - 8;
102
+ }
103
+ }
104
+ if (newPosition.right !== undefined) {
105
+ if (newPosition.right < 0) {
106
+ newPosition.right = 8;
107
+ }
108
+ }
109
+ if (newPosition.top !== undefined) {
110
+ if (newPosition.top < 0) {
111
+ newPosition.top = 8;
112
+ }
113
+ else if (newPosition.top + menuRect.height > viewport.height) {
114
+ newPosition.top = viewport.height - menuRect.height - 8;
115
+ }
116
+ }
117
+ if (newPosition.bottom !== undefined) {
118
+ if (newPosition.bottom < 0) {
119
+ newPosition.bottom = 8;
120
+ }
121
+ }
122
+ setPosition(newPosition);
123
+ }, [placement, offset]);
124
+ const toggle = useCallback(() => {
125
+ setIsOpen(prev => !prev);
126
+ }, []);
127
+ const open = useCallback(() => {
128
+ setIsOpen(true);
129
+ }, []);
130
+ const close = useCallback(() => {
131
+ setIsOpen(false);
132
+ }, []);
133
+ const handleItemClick = useCallback(() => {
134
+ if (closeOnSelect) {
135
+ close();
136
+ }
137
+ }, [closeOnSelect, close]);
138
+ // Recalculate position when opened
139
+ useEffect(() => {
140
+ if (isOpen) {
141
+ // Small delay to ensure DOM is updated
142
+ const timer = setTimeout(calculatePosition, 0);
143
+ return () => clearTimeout(timer);
144
+ }
145
+ }, [isOpen, calculatePosition]);
146
+ // Recalculate position on window resize and scroll
147
+ useEffect(() => {
148
+ if (!isOpen)
149
+ return;
150
+ const handleResize = () => calculatePosition();
151
+ const handleScroll = () => calculatePosition();
152
+ window.addEventListener('resize', handleResize);
153
+ window.addEventListener('scroll', handleScroll, { passive: true });
154
+ document.addEventListener('scroll', handleScroll, { passive: true });
155
+ return () => {
156
+ window.removeEventListener('resize', handleResize);
157
+ window.removeEventListener('scroll', handleScroll);
158
+ document.removeEventListener('scroll', handleScroll);
159
+ };
160
+ }, [isOpen, calculatePosition]);
161
+ return {
162
+ isOpen,
163
+ position,
164
+ triggerRef,
165
+ menuRef,
166
+ toggle,
167
+ open,
168
+ close,
169
+ handleItemClick
170
+ };
171
+ };
172
+
173
+ const useClickOutside = ({ ref, handler, enabled = true }) => {
174
+ useEffect(() => {
175
+ if (!enabled)
176
+ return;
177
+ const handleMouseDown = (event) => {
178
+ if (ref.current && !ref.current.contains(event.target)) {
179
+ handler();
180
+ }
181
+ };
182
+ const handleTouchStart = (event) => {
183
+ if (ref.current && !ref.current.contains(event.target)) {
184
+ handler();
185
+ }
186
+ };
187
+ // Add event listeners
188
+ document.addEventListener('mousedown', handleMouseDown);
189
+ document.addEventListener('touchstart', handleTouchStart);
190
+ return () => {
191
+ document.removeEventListener('mousedown', handleMouseDown);
192
+ document.removeEventListener('touchstart', handleTouchStart);
193
+ };
194
+ }, [ref, handler, enabled]);
195
+ };
196
+
197
+ const useKeyboardNavigation = ({ isOpen, menuRef, onClose, onSelect }) => {
198
+ const getMenuItems = useCallback(() => {
199
+ if (!menuRef.current)
200
+ return [];
201
+ return Array.from(menuRef.current.querySelectorAll('[role="menuitem"]:not([disabled])'));
202
+ }, [menuRef]);
203
+ const focusItem = useCallback((index) => {
204
+ const items = getMenuItems();
205
+ if (items[index]) {
206
+ items[index].focus();
207
+ }
208
+ }, [getMenuItems]);
209
+ const getCurrentIndex = useCallback(() => {
210
+ const items = getMenuItems();
211
+ const activeElement = document.activeElement;
212
+ return items.indexOf(activeElement);
213
+ }, [getMenuItems]);
214
+ const handleKeyDown = useCallback((event) => {
215
+ if (!isOpen)
216
+ return;
217
+ const items = getMenuItems();
218
+ const currentIndex = getCurrentIndex();
219
+ switch (event.key) {
220
+ case 'Escape':
221
+ event.preventDefault();
222
+ onClose();
223
+ break;
224
+ case 'ArrowDown':
225
+ event.preventDefault();
226
+ if (items.length > 0) {
227
+ const nextIndex = currentIndex < items.length - 1 ? currentIndex + 1 : 0;
228
+ focusItem(nextIndex);
229
+ }
230
+ break;
231
+ case 'ArrowUp':
232
+ event.preventDefault();
233
+ if (items.length > 0) {
234
+ const prevIndex = currentIndex > 0 ? currentIndex - 1 : items.length - 1;
235
+ focusItem(prevIndex);
236
+ }
237
+ break;
238
+ case 'Home':
239
+ event.preventDefault();
240
+ if (items.length > 0) {
241
+ focusItem(0);
242
+ }
243
+ break;
244
+ case 'End':
245
+ event.preventDefault();
246
+ if (items.length > 0) {
247
+ focusItem(items.length - 1);
248
+ }
249
+ break;
250
+ case 'Enter':
251
+ case ' ':
252
+ event.preventDefault();
253
+ if (currentIndex >= 0 && onSelect) {
254
+ onSelect(currentIndex);
255
+ }
256
+ break;
257
+ case 'Tab':
258
+ onClose();
259
+ break;
260
+ }
261
+ }, [isOpen, getMenuItems, getCurrentIndex, focusItem, onClose, onSelect]);
262
+ useEffect(() => {
263
+ if (!isOpen)
264
+ return;
265
+ document.addEventListener('keydown', handleKeyDown);
266
+ return () => document.removeEventListener('keydown', handleKeyDown);
267
+ }, [isOpen, handleKeyDown]);
268
+ // Focus first item when menu opens
269
+ useEffect(() => {
270
+ if (isOpen) {
271
+ const timer = setTimeout(() => {
272
+ focusItem(0);
273
+ }, 0);
274
+ return () => clearTimeout(timer);
275
+ }
276
+ }, [isOpen, focusItem]);
277
+ };
278
+
279
+ const DropdownMenu = forwardRef(({ children, isOpen, position, size = 'md', className = '', 'data-testid': testId }, ref) => {
280
+ if (!isOpen)
281
+ return null;
282
+ const positionStyles = {
283
+ position: 'fixed',
284
+ zIndex: 1000,
285
+ ...position
286
+ };
287
+ return (jsx("div", { ref: ref, className: `asm-dropdown-menu asm-dropdown-menu--${size} ${className}`, style: positionStyles, role: "menu", "aria-orientation": "vertical", "data-testid": testId, children: children }));
288
+ });
289
+ DropdownMenu.displayName = 'DropdownMenu';
290
+
291
+ const DropdownItem = ({ children, label, icon, disabled = false, danger = false, divider = false, onClick, className = '', 'data-testid': testId }) => {
292
+ if (divider) {
293
+ return jsx("div", { className: "asm-dropdown-divider", "data-testid": testId });
294
+ }
295
+ const handleClick = (event) => {
296
+ if (disabled)
297
+ return;
298
+ onClick?.(event);
299
+ };
300
+ const handleKeyDown = (event) => {
301
+ if (event.key === 'Enter' || event.key === ' ') {
302
+ event.preventDefault();
303
+ if (!disabled && onClick) {
304
+ onClick(event);
305
+ }
306
+ }
307
+ };
308
+ return (jsxs("button", { type: "button", className: `asm-dropdown-item ${danger ? 'asm-dropdown-item--danger' : ''} ${disabled ? 'asm-dropdown-item--disabled' : ''} ${className}`, onClick: handleClick, onKeyDown: handleKeyDown, disabled: disabled, role: "menuitem", tabIndex: -1, "data-testid": testId, children: [icon && (jsx("span", { className: "asm-dropdown-item__icon", children: icon })), jsx("span", { className: "asm-dropdown-item__label", children: label || children })] }));
309
+ };
310
+
311
+ var styles = {"trigger":"DropdownTrigger-module_trigger__2aFGL","sm":"DropdownTrigger-module_sm__J-u1E","md":"DropdownTrigger-module_md__9rX9v","lg":"DropdownTrigger-module_lg__Q-JAS","primary":"DropdownTrigger-module_primary__UQ1Xa","secondary":"DropdownTrigger-module_secondary__1NNLR","success":"DropdownTrigger-module_success__bHgUD","warning":"DropdownTrigger-module_warning__ifDRF","danger":"DropdownTrigger-module_danger__v-d7N","info":"DropdownTrigger-module_info__3czXi","ghost":"DropdownTrigger-module_ghost__dbCKD","outline":"DropdownTrigger-module_outline__VnDA7","link":"DropdownTrigger-module_link__BWU0o","brand":"DropdownTrigger-module_brand__SAI0y"};
312
+
313
+ const DropdownTrigger = React.forwardRef(({ children, onClick, onKeyDown, disabled = false, variant = 'primary', size = 'md', className = '', 'data-testid': testId }, ref) => {
314
+ const variantClass = styles[variant] || styles.primary;
315
+ const sizeClass = styles[size] || styles.md;
316
+ const triggerClass = `${styles.trigger} ${variantClass} ${sizeClass} ${className}`.trim();
317
+ // Check if children is already a button element
318
+ const isButtonChild = React.isValidElement(children) &&
319
+ (children.type === 'button' ||
320
+ (typeof children.type === 'string' && children.type === 'button'));
321
+ if (isButtonChild) {
322
+ // Clone the button and add our props
323
+ return React.cloneElement(children, {
324
+ className: `${children.props.className || ''} ${triggerClass}`.trim(),
325
+ onClick: (e) => {
326
+ onClick?.(e);
327
+ children.props.onClick?.(e);
328
+ },
329
+ onKeyDown: (e) => {
330
+ onKeyDown?.(e);
331
+ children.props.onKeyDown?.(e);
332
+ },
333
+ disabled: disabled || children.props.disabled,
334
+ 'aria-haspopup': 'menu',
335
+ 'aria-expanded': false,
336
+ 'data-testid': testId || children.props['data-testid'],
337
+ ref: ref
338
+ });
339
+ }
340
+ // For non-button children, wrap in a button
341
+ return (jsx("button", { ref: ref, type: "button", className: triggerClass, onClick: onClick, onKeyDown: onKeyDown, disabled: disabled, "aria-haspopup": "menu", "aria-expanded": false, "data-testid": testId, children: children }));
342
+ });
343
+
344
+ const Dropdown = ({ children, items = [], isOpen: controlledIsOpen, onToggle, placement = 'bottom-start', size = 'md', variant = 'primary', disabled = false, closeOnSelect = true, showChevron = true, className = '', 'data-testid': testId }) => {
345
+ const containerRef = useRef(null);
346
+ const { isOpen: internalIsOpen, position, triggerRef, menuRef, toggle, close, handleItemClick } = useDropdown({
347
+ placement,
348
+ closeOnSelect
349
+ });
350
+ // Use controlled or internal state
351
+ const isOpen = controlledIsOpen !== undefined ? controlledIsOpen : internalIsOpen;
352
+ const handleToggle = () => {
353
+ if (disabled)
354
+ return;
355
+ if (onToggle) {
356
+ onToggle(!isOpen);
357
+ }
358
+ else {
359
+ toggle();
360
+ }
361
+ };
362
+ const handleClose = () => {
363
+ if (onToggle) {
364
+ onToggle(false);
365
+ }
366
+ else {
367
+ close();
368
+ }
369
+ };
370
+ const handleItemSelect = (index) => {
371
+ const item = items[index];
372
+ if (item && !item.disabled && item.onClick) {
373
+ item.onClick({});
374
+ }
375
+ handleItemClick();
376
+ };
377
+ // Click outside to close
378
+ useClickOutside({
379
+ ref: containerRef,
380
+ handler: handleClose,
381
+ enabled: isOpen
382
+ });
383
+ // Keyboard navigation
384
+ useKeyboardNavigation({
385
+ isOpen,
386
+ menuRef,
387
+ onClose: handleClose,
388
+ onSelect: handleItemSelect
389
+ });
390
+ const handleKeyDown = (event) => {
391
+ if (event.key === 'Enter' || event.key === ' ') {
392
+ event.preventDefault();
393
+ handleToggle();
394
+ }
395
+ else if (event.key === 'ArrowDown') {
396
+ event.preventDefault();
397
+ if (!isOpen) {
398
+ handleToggle();
399
+ }
400
+ }
401
+ };
402
+ return (jsxs("div", { ref: containerRef, className: `asm-dropdown ${className}`, "data-testid": testId, children: [jsxs(DropdownTrigger, { ref: triggerRef, onClick: handleToggle, onKeyDown: handleKeyDown, disabled: disabled, variant: variant, size: size, children: [children, showChevron && (jsx("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "currentColor", style: { marginLeft: 'var(--asm-space-1)' }, children: jsx("path", { d: "M3 4.5L6 7.5L9 4.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", fill: "none" }) }))] }), isOpen && createPortal(jsx(DropdownMenu, { ref: menuRef, isOpen: isOpen, position: position, size: size, "data-testid": testId ? `${testId}-menu` : undefined, children: items.map((item, index) => (jsx(React.Fragment, { children: item.divider ? (jsx("div", { className: "asm-dropdown-divider" })) : (jsx(DropdownItem, { label: item.label, icon: item.icon, disabled: item.disabled, danger: item.danger, onClick: (event) => {
403
+ if (item.onClick) {
404
+ item.onClick(event);
405
+ }
406
+ handleItemClick();
407
+ }, "data-testid": item.id ? `${testId}-item-${item.id}` : undefined })) }, item.id || index))) }), document.body)] }));
408
+ };
409
+
410
+ export { Dropdown, DropdownItem, DropdownMenu, DropdownTrigger, useClickOutside, useDropdown, useKeyboardNavigation };
411
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../src/hooks/useDropdown.ts","../src/hooks/useClickOutside.ts","../src/hooks/useKeyboardNavigation.ts","../src/components/DropdownMenu.tsx","../src/components/DropdownItem.tsx","../src/components/DropdownTrigger.tsx","../src/components/Dropdown.tsx"],"sourcesContent":["import { useState, useRef, useCallback, useEffect } from 'react';\nimport { DropdownPlacement, DropdownPosition } from '../types';\n\ninterface UseDropdownProps {\n placement?: DropdownPlacement;\n offset?: number;\n closeOnSelect?: boolean;\n}\n\nexport const useDropdown = ({\n placement = 'bottom-start',\n offset = 8,\n closeOnSelect = true\n}: UseDropdownProps = {}) => {\n const [isOpen, setIsOpen] = useState(false);\n const [position, setPosition] = useState<DropdownPosition>({});\n const triggerRef = useRef<HTMLDivElement>(null);\n const menuRef = useRef<HTMLDivElement>(null);\n\n const calculatePosition = useCallback(() => {\n if (!triggerRef.current || !menuRef.current) return;\n\n const triggerRect = triggerRef.current.getBoundingClientRect();\n const menuRect = menuRef.current.getBoundingClientRect();\n const viewport = {\n width: window.innerWidth,\n height: window.innerHeight\n };\n\n let newPosition: DropdownPosition = {};\n\n // Calculate base position based on placement\n switch (placement) {\n case 'top':\n newPosition = {\n bottom: viewport.height - triggerRect.top + offset,\n left: triggerRect.left + (triggerRect.width - menuRect.width) / 2\n };\n break;\n case 'top-start':\n newPosition = {\n bottom: viewport.height - triggerRect.top + offset,\n left: triggerRect.left\n };\n break;\n case 'top-end':\n newPosition = {\n bottom: viewport.height - triggerRect.top + offset,\n right: viewport.width - triggerRect.right\n };\n break;\n case 'bottom':\n newPosition = {\n top: triggerRect.bottom + offset,\n left: triggerRect.left + (triggerRect.width - menuRect.width) / 2\n };\n break;\n case 'bottom-start':\n newPosition = {\n top: triggerRect.bottom + offset,\n left: triggerRect.left\n };\n break;\n case 'bottom-end':\n newPosition = {\n top: triggerRect.bottom + offset,\n right: viewport.width - triggerRect.right\n };\n break;\n case 'left':\n newPosition = {\n top: triggerRect.top + (triggerRect.height - menuRect.height) / 2,\n right: viewport.width - triggerRect.left + offset\n };\n break;\n case 'left-start':\n newPosition = {\n top: triggerRect.top,\n right: viewport.width - triggerRect.left + offset\n };\n break;\n case 'left-end':\n newPosition = {\n bottom: viewport.height - triggerRect.bottom,\n right: viewport.width - triggerRect.left + offset\n };\n break;\n case 'right':\n newPosition = {\n top: triggerRect.top + (triggerRect.height - menuRect.height) / 2,\n left: triggerRect.right + offset\n };\n break;\n case 'right-start':\n newPosition = {\n top: triggerRect.top,\n left: triggerRect.right + offset\n };\n break;\n case 'right-end':\n newPosition = {\n bottom: viewport.height - triggerRect.bottom,\n left: triggerRect.right + offset\n };\n break;\n }\n\n // Adjust for viewport boundaries\n if (newPosition.left !== undefined) {\n if (newPosition.left < 0) {\n newPosition.left = 8;\n } else if (newPosition.left + menuRect.width > viewport.width) {\n newPosition.left = viewport.width - menuRect.width - 8;\n }\n }\n\n if (newPosition.right !== undefined) {\n if (newPosition.right < 0) {\n newPosition.right = 8;\n }\n }\n\n if (newPosition.top !== undefined) {\n if (newPosition.top < 0) {\n newPosition.top = 8;\n } else if (newPosition.top + menuRect.height > viewport.height) {\n newPosition.top = viewport.height - menuRect.height - 8;\n }\n }\n\n if (newPosition.bottom !== undefined) {\n if (newPosition.bottom < 0) {\n newPosition.bottom = 8;\n }\n }\n\n setPosition(newPosition);\n }, [placement, offset]);\n\n const toggle = useCallback(() => {\n setIsOpen(prev => !prev);\n }, []);\n\n const open = useCallback(() => {\n setIsOpen(true);\n }, []);\n\n const close = useCallback(() => {\n setIsOpen(false);\n }, []);\n\n const handleItemClick = useCallback(() => {\n if (closeOnSelect) {\n close();\n }\n }, [closeOnSelect, close]);\n\n // Recalculate position when opened\n useEffect(() => {\n if (isOpen) {\n // Small delay to ensure DOM is updated\n const timer = setTimeout(calculatePosition, 0);\n return () => clearTimeout(timer);\n }\n }, [isOpen, calculatePosition]);\n\n // Recalculate position on window resize and scroll\n useEffect(() => {\n if (!isOpen) return;\n\n const handleResize = () => calculatePosition();\n const handleScroll = () => calculatePosition();\n \n window.addEventListener('resize', handleResize);\n window.addEventListener('scroll', handleScroll, { passive: true });\n document.addEventListener('scroll', handleScroll, { passive: true });\n \n return () => {\n window.removeEventListener('resize', handleResize);\n window.removeEventListener('scroll', handleScroll);\n document.removeEventListener('scroll', handleScroll);\n };\n }, [isOpen, calculatePosition]);\n\n return {\n isOpen,\n position,\n triggerRef,\n menuRef,\n toggle,\n open,\n close,\n handleItemClick\n };\n};\n","import { useEffect, RefObject } from 'react';\n\ninterface UseClickOutsideProps {\n ref: RefObject<HTMLDivElement>;\n handler: () => void;\n enabled?: boolean;\n}\n\nexport const useClickOutside = ({ ref, handler, enabled = true }: UseClickOutsideProps) => {\n useEffect(() => {\n if (!enabled) return;\n\n const handleMouseDown = (event: MouseEvent) => {\n if (ref.current && !ref.current.contains(event.target as Node)) {\n handler();\n }\n };\n\n const handleTouchStart = (event: TouchEvent) => {\n if (ref.current && !ref.current.contains(event.target as Node)) {\n handler();\n }\n };\n\n // Add event listeners\n document.addEventListener('mousedown', handleMouseDown);\n document.addEventListener('touchstart', handleTouchStart);\n\n return () => {\n document.removeEventListener('mousedown', handleMouseDown);\n document.removeEventListener('touchstart', handleTouchStart);\n };\n }, [ref, handler, enabled]);\n};\n","import { useEffect, useCallback, RefObject } from 'react';\n\ninterface UseKeyboardNavigationProps {\n isOpen: boolean;\n menuRef: RefObject<HTMLElement>;\n onClose: () => void;\n onSelect?: (index: number) => void;\n}\n\nexport const useKeyboardNavigation = ({\n isOpen,\n menuRef,\n onClose,\n onSelect\n}: UseKeyboardNavigationProps) => {\n const getMenuItems = useCallback(() => {\n if (!menuRef.current) return [];\n return Array.from(\n menuRef.current.querySelectorAll('[role=\"menuitem\"]:not([disabled])')\n ) as HTMLElement[];\n }, [menuRef]);\n\n const focusItem = useCallback((index: number) => {\n const items = getMenuItems();\n if (items[index]) {\n items[index].focus();\n }\n }, [getMenuItems]);\n\n const getCurrentIndex = useCallback(() => {\n const items = getMenuItems();\n const activeElement = document.activeElement as HTMLElement;\n return items.indexOf(activeElement);\n }, [getMenuItems]);\n\n const handleKeyDown = useCallback((event: KeyboardEvent) => {\n if (!isOpen) return;\n\n const items = getMenuItems();\n const currentIndex = getCurrentIndex();\n\n switch (event.key) {\n case 'Escape':\n event.preventDefault();\n onClose();\n break;\n\n case 'ArrowDown':\n event.preventDefault();\n if (items.length > 0) {\n const nextIndex = currentIndex < items.length - 1 ? currentIndex + 1 : 0;\n focusItem(nextIndex);\n }\n break;\n\n case 'ArrowUp':\n event.preventDefault();\n if (items.length > 0) {\n const prevIndex = currentIndex > 0 ? currentIndex - 1 : items.length - 1;\n focusItem(prevIndex);\n }\n break;\n\n case 'Home':\n event.preventDefault();\n if (items.length > 0) {\n focusItem(0);\n }\n break;\n\n case 'End':\n event.preventDefault();\n if (items.length > 0) {\n focusItem(items.length - 1);\n }\n break;\n\n case 'Enter':\n case ' ':\n event.preventDefault();\n if (currentIndex >= 0 && onSelect) {\n onSelect(currentIndex);\n }\n break;\n\n case 'Tab':\n onClose();\n break;\n }\n }, [isOpen, getMenuItems, getCurrentIndex, focusItem, onClose, onSelect]);\n\n useEffect(() => {\n if (!isOpen) return;\n\n document.addEventListener('keydown', handleKeyDown);\n return () => document.removeEventListener('keydown', handleKeyDown);\n }, [isOpen, handleKeyDown]);\n\n // Focus first item when menu opens\n useEffect(() => {\n if (isOpen) {\n const timer = setTimeout(() => {\n focusItem(0);\n }, 0);\n return () => clearTimeout(timer);\n }\n }, [isOpen, focusItem]);\n};\n","import React, { forwardRef } from 'react';\nimport { DropdownMenuProps } from '../types';\n\nexport const DropdownMenu = forwardRef<HTMLDivElement, DropdownMenuProps>(({\n children,\n isOpen,\n position,\n size = 'md',\n className = '',\n 'data-testid': testId\n}, ref) => {\n if (!isOpen) return null;\n\n const positionStyles: React.CSSProperties = {\n position: 'fixed',\n zIndex: 1000,\n ...position\n };\n\n return (\n <div\n ref={ref}\n className={`asm-dropdown-menu asm-dropdown-menu--${size} ${className}`}\n style={positionStyles}\n role=\"menu\"\n aria-orientation=\"vertical\"\n data-testid={testId}\n >\n {children}\n </div>\n );\n});\n\nDropdownMenu.displayName = 'DropdownMenu';\n","import React from 'react';\nimport { DropdownItemProps } from '../types';\n\nexport const DropdownItem: React.FC<DropdownItemProps> = ({\n children,\n label,\n icon,\n disabled = false,\n danger = false,\n divider = false,\n onClick,\n className = '',\n 'data-testid': testId\n}) => {\n if (divider) {\n return <div className=\"asm-dropdown-divider\" data-testid={testId} />;\n }\n\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n if (disabled) return;\n onClick?.(event);\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n if (!disabled && onClick) {\n onClick(event as any);\n }\n }\n };\n\n return (\n <button\n type=\"button\"\n className={`asm-dropdown-item ${danger ? 'asm-dropdown-item--danger' : ''} ${disabled ? 'asm-dropdown-item--disabled' : ''} ${className}`}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n disabled={disabled}\n role=\"menuitem\"\n tabIndex={-1}\n data-testid={testId}\n >\n {icon && (\n <span className=\"asm-dropdown-item__icon\">\n {icon}\n </span>\n )}\n <span className=\"asm-dropdown-item__label\">\n {label || children}\n </span>\n </button>\n );\n};\n","import React from 'react';\nimport { DropdownTriggerProps } from '../types';\nimport styles from './DropdownTrigger.module.css';\n\nexport const DropdownTrigger = React.forwardRef<HTMLElement, DropdownTriggerProps>(({\n children,\n onClick,\n onKeyDown,\n disabled = false,\n variant = 'primary',\n size = 'md',\n className = '',\n 'data-testid': testId\n}, ref) => {\n const variantClass = styles[variant] || styles.primary;\n const sizeClass = styles[size] || styles.md;\n const triggerClass = `${styles.trigger} ${variantClass} ${sizeClass} ${className}`.trim();\n\n // Check if children is already a button element\n const isButtonChild = React.isValidElement(children) && \n (children.type === 'button' || \n (typeof children.type === 'string' && children.type === 'button'));\n\n if (isButtonChild) {\n // Clone the button and add our props\n return React.cloneElement(children as React.ReactElement<any>, {\n className: `${(children as any).props.className || ''} ${triggerClass}`.trim(),\n onClick: (e: React.MouseEvent<HTMLButtonElement>) => {\n onClick?.(e);\n (children as any).props.onClick?.(e);\n },\n onKeyDown: (e: React.KeyboardEvent<HTMLButtonElement>) => {\n onKeyDown?.(e);\n (children as any).props.onKeyDown?.(e);\n },\n disabled: disabled || (children as any).props.disabled,\n 'aria-haspopup': 'menu',\n 'aria-expanded': false,\n 'data-testid': testId || (children as any).props['data-testid'],\n ref: ref\n });\n }\n\n // For non-button children, wrap in a button\n return (\n <button\n ref={ref as React.RefObject<HTMLButtonElement>}\n type=\"button\"\n className={triggerClass}\n onClick={onClick}\n onKeyDown={onKeyDown}\n disabled={disabled}\n aria-haspopup=\"menu\"\n aria-expanded={false}\n data-testid={testId}\n >\n {children}\n </button>\n );\n});\n","import React, { useRef } from 'react';\nimport { createPortal } from 'react-dom';\nimport { DropdownProps } from '../types';\nimport { useDropdown } from '../hooks/useDropdown';\nimport { useClickOutside } from '../hooks/useClickOutside';\nimport { useKeyboardNavigation } from '../hooks/useKeyboardNavigation';\nimport { DropdownMenu } from './DropdownMenu';\nimport { DropdownItem } from './DropdownItem';\nimport { DropdownTrigger } from './DropdownTrigger';\n\nexport const Dropdown: React.FC<DropdownProps> = ({\n children,\n items = [],\n isOpen: controlledIsOpen,\n onToggle,\n placement = 'bottom-start',\n size = 'md',\n variant = 'primary',\n disabled = false,\n closeOnSelect = true,\n showChevron = true,\n className = '',\n 'data-testid': testId\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n \n const {\n isOpen: internalIsOpen,\n position,\n triggerRef,\n menuRef,\n toggle,\n close,\n handleItemClick\n } = useDropdown({\n placement,\n closeOnSelect\n });\n\n // Use controlled or internal state\n const isOpen = controlledIsOpen !== undefined ? controlledIsOpen : internalIsOpen;\n \n const handleToggle = () => {\n if (disabled) return;\n \n if (onToggle) {\n onToggle(!isOpen);\n } else {\n toggle();\n }\n };\n\n const handleClose = () => {\n if (onToggle) {\n onToggle(false);\n } else {\n close();\n }\n };\n\n const handleItemSelect = (index: number) => {\n const item = items[index];\n if (item && !item.disabled && item.onClick) {\n item.onClick({} as React.MouseEvent<HTMLButtonElement>);\n }\n handleItemClick();\n };\n\n // Click outside to close\n useClickOutside({\n ref: containerRef,\n handler: handleClose,\n enabled: isOpen\n });\n\n // Keyboard navigation\n useKeyboardNavigation({\n isOpen,\n menuRef,\n onClose: handleClose,\n onSelect: handleItemSelect\n });\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n handleToggle();\n } else if (event.key === 'ArrowDown') {\n event.preventDefault();\n if (!isOpen) {\n handleToggle();\n }\n }\n };\n\n return (\n <div \n ref={containerRef}\n className={`asm-dropdown ${className}`}\n data-testid={testId}\n >\n <DropdownTrigger\n ref={triggerRef}\n onClick={handleToggle}\n onKeyDown={handleKeyDown}\n disabled={disabled}\n variant={variant}\n size={size}\n >\n {children}\n {showChevron && (\n <svg \n width=\"12\" \n height=\"12\" \n viewBox=\"0 0 12 12\" \n fill=\"currentColor\"\n style={{ marginLeft: 'var(--asm-space-1)' }}\n >\n <path d=\"M3 4.5L6 7.5L9 4.5\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" fill=\"none\"/>\n </svg>\n )}\n </DropdownTrigger>\n\n {isOpen && createPortal(\n <DropdownMenu\n ref={menuRef}\n isOpen={isOpen}\n position={position}\n size={size}\n data-testid={testId ? `${testId}-menu` : undefined}\n >\n {items.map((item, index) => (\n <React.Fragment key={item.id || index}>\n {item.divider ? (\n <div className=\"asm-dropdown-divider\" />\n ) : (\n <DropdownItem\n label={item.label}\n icon={item.icon}\n disabled={item.disabled}\n danger={item.danger}\n onClick={(event) => {\n if (item.onClick) {\n item.onClick(event);\n }\n handleItemClick();\n }}\n data-testid={item.id ? `${testId}-item-${item.id}` : undefined}\n />\n )}\n </React.Fragment>\n ))}\n </DropdownMenu>,\n document.body\n )}\n </div>\n );\n};\n"],"names":["_jsx","_jsxs"],"mappings":";;;;MASa,WAAW,GAAG,CAAC,EAC1B,SAAS,GAAG,cAAc,EAC1B,MAAM,GAAG,CAAC,EACV,aAAa,GAAG,IAAI,EAAA,GACA,EAAE,KAAI;IAC1B,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;IAC3C,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAmB,EAAE,CAAC;AAC9D,IAAA,MAAM,UAAU,GAAG,MAAM,CAAiB,IAAI,CAAC;AAC/C,IAAA,MAAM,OAAO,GAAG,MAAM,CAAiB,IAAI,CAAC;AAE5C,IAAA,MAAM,iBAAiB,GAAG,WAAW,CAAC,MAAK;QACzC,IAAI,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO;YAAE;QAE7C,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,CAAC,qBAAqB,EAAE;QAC9D,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,qBAAqB,EAAE;AACxD,QAAA,MAAM,QAAQ,GAAG;YACf,KAAK,EAAE,MAAM,CAAC,UAAU;YACxB,MAAM,EAAE,MAAM,CAAC;SAChB;QAED,IA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