@xsolla/xui-dropdown 0.93.0 → 0.94.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,20 +1,23 @@
1
1
  {
2
2
  "name": "@xsolla/xui-dropdown",
3
- "version": "0.93.0",
3
+ "version": "0.94.0",
4
4
  "main": "./web/index.js",
5
5
  "module": "./web/index.mjs",
6
6
  "types": "./web/index.d.ts",
7
7
  "scripts": {
8
8
  "build": "yarn build:web && yarn build:native",
9
9
  "build:web": "PLATFORM=web tsup",
10
- "build:native": "PLATFORM=native tsup"
10
+ "build:native": "PLATFORM=native tsup",
11
+ "test": "vitest",
12
+ "test:run": "vitest run",
13
+ "test:coverage": "vitest run --coverage"
11
14
  },
12
15
  "dependencies": {
13
- "@xsolla/xui-button": "0.93.0",
14
- "@xsolla/xui-core": "0.93.0",
15
- "@xsolla/xui-divider": "0.93.0",
16
- "@xsolla/xui-icons": "0.93.0",
17
- "@xsolla/xui-primitives-core": "0.93.0"
16
+ "@xsolla/xui-button": "0.94.0",
17
+ "@xsolla/xui-core": "0.94.0",
18
+ "@xsolla/xui-divider": "0.94.0",
19
+ "@xsolla/xui-icons": "0.94.0",
20
+ "@xsolla/xui-primitives-core": "0.94.0"
18
21
  },
19
22
  "peerDependencies": {
20
23
  "react": ">=16.8.0",
package/web/index.d.mts CHANGED
@@ -5,7 +5,14 @@ interface DropdownProps {
5
5
  children: React.ReactNode;
6
6
  isOpen?: boolean;
7
7
  onOpenChange?: (open: boolean) => void;
8
+ /** Width of the dropdown menu (does not affect trigger width) */
8
9
  width?: string | number;
10
+ /** Horizontal alignment of dropdown menu relative to trigger. Default: "start" */
11
+ align?: "start" | "end";
12
+ /** Accessible label for the dropdown menu */
13
+ "aria-label"?: string;
14
+ /** Test ID for testing frameworks */
15
+ testID?: string;
9
16
  }
10
17
  declare const Dropdown: React.FC<DropdownProps>;
11
18
  interface DropdownItemProps {
@@ -16,6 +23,8 @@ interface DropdownItemProps {
16
23
  selected?: boolean;
17
24
  disabled?: boolean;
18
25
  icon?: React.ReactNode;
26
+ /** Test ID for testing frameworks */
27
+ testID?: string;
19
28
  }
20
29
  declare const DropdownItem: React.FC<DropdownItemProps>;
21
30
 
package/web/index.d.ts CHANGED
@@ -5,7 +5,14 @@ interface DropdownProps {
5
5
  children: React.ReactNode;
6
6
  isOpen?: boolean;
7
7
  onOpenChange?: (open: boolean) => void;
8
+ /** Width of the dropdown menu (does not affect trigger width) */
8
9
  width?: string | number;
10
+ /** Horizontal alignment of dropdown menu relative to trigger. Default: "start" */
11
+ align?: "start" | "end";
12
+ /** Accessible label for the dropdown menu */
13
+ "aria-label"?: string;
14
+ /** Test ID for testing frameworks */
15
+ testID?: string;
9
16
  }
10
17
  declare const Dropdown: React.FC<DropdownProps>;
11
18
  interface DropdownItemProps {
@@ -16,6 +23,8 @@ interface DropdownItemProps {
16
23
  selected?: boolean;
17
24
  disabled?: boolean;
18
25
  icon?: React.ReactNode;
26
+ /** Test ID for testing frameworks */
27
+ testID?: string;
19
28
  }
20
29
  declare const DropdownItem: React.FC<DropdownItemProps>;
21
30
 
package/web/index.js CHANGED
@@ -247,63 +247,126 @@ var Dropdown = ({
247
247
  children,
248
248
  isOpen: propIsOpen,
249
249
  onOpenChange,
250
- width = "auto"
250
+ width = "auto",
251
+ align = "start",
252
+ "aria-label": ariaLabel,
253
+ testID
251
254
  }) => {
252
255
  const [internalIsOpen, setInternalIsOpen] = (0, import_react2.useState)(false);
253
256
  const isOpen = propIsOpen !== void 0 ? propIsOpen : internalIsOpen;
254
257
  const containerRef = (0, import_react2.useRef)(null);
258
+ const triggerRef = (0, import_react2.useRef)(null);
259
+ const menuRef = (0, import_react2.useRef)(null);
255
260
  const { theme } = (0, import_xui_core.useDesignSystem)();
256
- const toggleOpen = () => {
261
+ const closeMenu = (0, import_react2.useCallback)(() => {
262
+ if (propIsOpen === void 0) {
263
+ setInternalIsOpen(false);
264
+ }
265
+ if (onOpenChange) onOpenChange(false);
266
+ }, [propIsOpen, onOpenChange]);
267
+ const toggleOpen = (0, import_react2.useCallback)(() => {
257
268
  const nextOpen = !isOpen;
258
269
  if (propIsOpen === void 0) {
259
270
  setInternalIsOpen(nextOpen);
260
271
  }
261
272
  if (onOpenChange) onOpenChange(nextOpen);
262
- };
273
+ }, [isOpen, propIsOpen, onOpenChange]);
274
+ const focusTrigger = (0, import_react2.useCallback)(() => {
275
+ if (typeof document !== "undefined" && triggerRef.current) {
276
+ const focusable = triggerRef.current.querySelector(
277
+ 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
278
+ );
279
+ if (focusable) {
280
+ focusable.focus();
281
+ }
282
+ }
283
+ }, []);
284
+ const handleKeyDown = (0, import_react2.useCallback)(
285
+ (event) => {
286
+ if (event.key === "Escape" && isOpen) {
287
+ event.preventDefault();
288
+ closeMenu();
289
+ focusTrigger();
290
+ } else if (event.key === "Tab" && isOpen) {
291
+ closeMenu();
292
+ focusTrigger();
293
+ }
294
+ },
295
+ [isOpen, closeMenu, focusTrigger]
296
+ );
297
+ const handleTriggerKeyDown = (0, import_react2.useCallback)(
298
+ (event) => {
299
+ if (event.key === "Enter" || event.key === " ") {
300
+ event.preventDefault();
301
+ toggleOpen();
302
+ } else if (event.key === "ArrowDown" && !isOpen) {
303
+ event.preventDefault();
304
+ if (propIsOpen === void 0) {
305
+ setInternalIsOpen(true);
306
+ }
307
+ if (onOpenChange) onOpenChange(true);
308
+ }
309
+ },
310
+ [isOpen, toggleOpen, propIsOpen, onOpenChange]
311
+ );
263
312
  (0, import_react2.useEffect)(() => {
264
313
  const handleClickOutside = (event) => {
265
314
  if (containerRef.current && !containerRef.current.contains(event.target)) {
266
- if (propIsOpen === void 0) {
267
- setInternalIsOpen(false);
268
- }
269
- if (onOpenChange) onOpenChange(false);
315
+ closeMenu();
270
316
  }
271
317
  };
272
- if (isOpen) {
318
+ if (isOpen && typeof document !== "undefined") {
273
319
  document.addEventListener("mousedown", handleClickOutside);
274
320
  }
275
321
  return () => {
276
- document.removeEventListener("mousedown", handleClickOutside);
322
+ if (typeof document !== "undefined") {
323
+ document.removeEventListener("mousedown", handleClickOutside);
324
+ }
277
325
  };
278
- }, [isOpen, propIsOpen, onOpenChange]);
326
+ }, [isOpen, closeMenu]);
279
327
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
280
328
  "div",
281
329
  {
282
330
  ref: containerRef,
283
331
  style: {
284
332
  position: "relative",
285
- width: width === "auto" ? "fit-content" : width,
333
+ width: "fit-content",
286
334
  alignSelf: "flex-start",
287
335
  height: "fit-content"
288
336
  },
337
+ onKeyDown: handleKeyDown,
338
+ "data-testid": testID,
289
339
  children: [
290
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { onClick: toggleOpen, style: { cursor: "pointer" }, children: trigger }),
340
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
341
+ "div",
342
+ {
343
+ ref: triggerRef,
344
+ onClick: toggleOpen,
345
+ onKeyDown: handleTriggerKeyDown,
346
+ "aria-haspopup": "menu",
347
+ "aria-expanded": isOpen,
348
+ children: trigger
349
+ }
350
+ ),
291
351
  isOpen && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
292
352
  Box,
293
353
  {
354
+ ref: menuRef,
294
355
  position: "absolute",
295
356
  top: "100%",
296
- left: 0,
357
+ ...align === "end" ? { right: 0 } : { left: 0 },
297
358
  marginTop: 4,
298
359
  backgroundColor: theme.colors.background.secondary,
299
360
  borderColor: theme.colors.border.secondary,
300
361
  borderWidth: 1,
301
362
  borderRadius: theme.radius.button,
302
363
  paddingVertical: 4,
364
+ role: "menu",
365
+ ...ariaLabel ? { "aria-label": ariaLabel } : {},
303
366
  style: {
304
367
  zIndex: 1e3,
305
368
  boxShadow: "0 4px 12px rgba(0,0,0,0.1)",
306
- minWidth: "100%"
369
+ ...width === "auto" ? { minWidth: "100%" } : { width }
307
370
  },
308
371
  children
309
372
  }
@@ -318,7 +381,8 @@ var DropdownItem = ({
318
381
  active,
319
382
  selected,
320
383
  disabled,
321
- icon
384
+ icon,
385
+ testID
322
386
  }) => {
323
387
  const { theme } = (0, import_xui_core.useDesignSystem)();
324
388
  const brandColors = theme.colors.control.brand.primary;
@@ -338,6 +402,12 @@ var DropdownItem = ({
338
402
  }
339
403
  return theme.colors.content.secondary;
340
404
  };
405
+ const handleKeyDown = (event) => {
406
+ if ((event.key === "Enter" || event.key === " ") && !disabled && onPress) {
407
+ event.preventDefault();
408
+ onPress();
409
+ }
410
+ };
341
411
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
342
412
  Box,
343
413
  {
@@ -350,6 +420,11 @@ var DropdownItem = ({
350
420
  hoverStyle: !disabled && !selected ? {
351
421
  backgroundColor: theme.colors.control.input.bgHover
352
422
  } : void 0,
423
+ role: "menuitem",
424
+ tabIndex: disabled ? -1 : 0,
425
+ "aria-disabled": disabled,
426
+ onKeyDown: handleKeyDown,
427
+ testID,
353
428
  style: {
354
429
  opacity: disabled ? 0.5 : 1,
355
430
  cursor: disabled ? "not-allowed" : "pointer"
@@ -361,6 +436,8 @@ var DropdownItem = ({
361
436
  }
362
437
  );
363
438
  };
439
+ Dropdown.displayName = "Dropdown";
440
+ DropdownItem.displayName = "DropdownItem";
364
441
  // Annotate the CommonJS export names for ESM import in node:
365
442
  0 && (module.exports = {
366
443
  Dropdown,
package/web/index.js.flow CHANGED
@@ -11,7 +11,26 @@ declare interface DropdownProps {
11
11
  children: React.ReactNode;
12
12
  isOpen?: boolean;
13
13
  onOpenChange?: (open: boolean) => void;
14
+
15
+ /**
16
+ * Width of the dropdown menu (does not affect trigger width)
17
+ */
14
18
  width?: string | number;
19
+
20
+ /**
21
+ * Horizontal alignment of dropdown menu relative to trigger. Default: "start"
22
+ */
23
+ align?: "start" | "end";
24
+
25
+ /**
26
+ * Accessible label for the dropdown menu
27
+ */
28
+ "aria-label"?: string;
29
+
30
+ /**
31
+ * Test ID for testing frameworks
32
+ */
33
+ testID?: string;
15
34
  }
16
35
  declare var Dropdown: React.FC<DropdownProps>;
17
36
  declare interface DropdownItemProps {
@@ -25,6 +44,11 @@ declare interface DropdownItemProps {
25
44
  selected?: boolean;
26
45
  disabled?: boolean;
27
46
  icon?: React.ReactNode;
47
+
48
+ /**
49
+ * Test ID for testing frameworks
50
+ */
51
+ testID?: string;
28
52
  }
29
53
  declare var DropdownItem: React.FC<DropdownItemProps>;
30
54
  export type { DropdownItemProps, DropdownProps };
package/web/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.tsx","../../src/Dropdown.tsx","../../../primitives-web/src/Box.tsx","../../../primitives-web/src/Text.tsx"],"sourcesContent":["export * from \"./Dropdown\";\n","import React, { useState, useRef, useEffect } from \"react\";\n// @ts-expect-error - this will be resolved at build time\nimport { Box, Text } from \"@xsolla/xui-primitives\";\nimport { useDesignSystem } from \"@xsolla/xui-core\";\n\nexport interface DropdownProps {\n trigger: React.ReactNode;\n children: React.ReactNode;\n isOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n width?: string | number;\n}\n\nexport const Dropdown: React.FC<DropdownProps> = ({\n trigger,\n children,\n isOpen: propIsOpen,\n onOpenChange,\n width = \"auto\",\n}) => {\n const [internalIsOpen, setInternalIsOpen] = useState(false);\n const isOpen = propIsOpen !== undefined ? propIsOpen : internalIsOpen;\n const containerRef = useRef<any>(null);\n const { theme } = useDesignSystem();\n\n const toggleOpen = () => {\n const nextOpen = !isOpen;\n if (propIsOpen === undefined) {\n setInternalIsOpen(nextOpen);\n }\n if (onOpenChange) onOpenChange(nextOpen);\n };\n\n useEffect(() => {\n const handleClickOutside = (event: MouseEvent) => {\n if (\n containerRef.current &&\n !containerRef.current.contains(event.target)\n ) {\n if (propIsOpen === undefined) {\n setInternalIsOpen(false);\n }\n if (onOpenChange) onOpenChange(false);\n }\n };\n\n if (isOpen) {\n document.addEventListener(\"mousedown\", handleClickOutside);\n }\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n };\n }, [isOpen, propIsOpen, onOpenChange]);\n\n return (\n <div\n ref={containerRef}\n style={{\n position: \"relative\",\n width: width === \"auto\" ? \"fit-content\" : width,\n alignSelf: \"flex-start\",\n height: \"fit-content\",\n }}\n >\n <div onClick={toggleOpen} style={{ cursor: \"pointer\" }}>\n {trigger}\n </div>\n {isOpen && (\n <Box\n position=\"absolute\"\n top=\"100%\"\n left={0}\n marginTop={4}\n backgroundColor={theme.colors.background.secondary}\n borderColor={theme.colors.border.secondary}\n borderWidth={1}\n borderRadius={theme.radius.button}\n paddingVertical={4}\n style={{\n zIndex: 1000,\n boxShadow: \"0 4px 12px rgba(0,0,0,0.1)\",\n minWidth: \"100%\",\n }}\n >\n {children}\n </Box>\n )}\n </div>\n );\n};\n\nexport interface DropdownItemProps {\n children: React.ReactNode;\n onPress?: () => void;\n active?: boolean;\n /** Whether this item is selected (shows trailing checkmark with control/check/bg color) */\n selected?: boolean;\n disabled?: boolean;\n icon?: React.ReactNode;\n}\n\nexport const DropdownItem: React.FC<DropdownItemProps> = ({\n children,\n onPress,\n active,\n selected,\n disabled,\n icon,\n}) => {\n const { theme } = useDesignSystem();\n const brandColors = theme.colors.control.brand.primary;\n const contentColors = theme.colors.content;\n\n // Determine background color\n const getBackgroundColor = () => {\n if (selected) {\n return brandColors?.bg || theme.colors.control.input.bg; // Cyan background for selected items\n }\n if (active) {\n return theme.colors.control.input.bgHover;\n }\n return \"transparent\";\n };\n\n // Determine text/icon color\n const getContentColor = () => {\n if (selected) {\n return contentColors?.on?.brand || theme.colors.content.primary; // Black text on cyan background\n }\n return theme.colors.content.secondary;\n };\n\n return (\n <Box\n onPress={!disabled ? onPress : undefined}\n paddingHorizontal={16}\n paddingVertical={8}\n flexDirection=\"row\"\n alignItems=\"center\"\n backgroundColor={getBackgroundColor()}\n hoverStyle={\n !disabled && !selected\n ? {\n backgroundColor: theme.colors.control.input.bgHover,\n }\n : undefined\n }\n style={{\n opacity: disabled ? 0.5 : 1,\n cursor: disabled ? \"not-allowed\" : \"pointer\",\n }}\n >\n {icon && (\n <Box marginRight={12} alignItems=\"center\" justifyContent=\"center\">\n {icon}\n </Box>\n )}\n <Box flex={1}>\n <Text color={getContentColor()} fontSize={14} fontWeight=\"400\">\n {children}\n </Text>\n </Box>\n </Box>\n );\n};\n","import React from \"react\";\nimport styled from \"styled-components\";\nimport type { BoxProps } from \"@xsolla/xui-primitives-core\";\n\nconst StyledBox = styled.div<BoxProps>`\n display: flex;\n box-sizing: border-box;\n background-color: ${(props) => props.backgroundColor || \"transparent\"};\n border-color: ${(props) => props.borderColor || \"transparent\"};\n border-width: ${(props) =>\n typeof props.borderWidth === \"number\"\n ? `${props.borderWidth}px`\n : props.borderWidth || 0};\n\n ${(props) =>\n props.borderBottomWidth !== undefined &&\n `\n border-bottom-width: ${typeof props.borderBottomWidth === \"number\" ? `${props.borderBottomWidth}px` : props.borderBottomWidth};\n border-bottom-color: ${props.borderBottomColor || props.borderColor || \"transparent\"};\n border-bottom-style: solid;\n `}\n ${(props) =>\n props.borderTopWidth !== undefined &&\n `\n border-top-width: ${typeof props.borderTopWidth === \"number\" ? `${props.borderTopWidth}px` : props.borderTopWidth};\n border-top-color: ${props.borderTopColor || props.borderColor || \"transparent\"};\n border-top-style: solid;\n `}\n ${(props) =>\n props.borderLeftWidth !== undefined &&\n `\n border-left-width: ${typeof props.borderLeftWidth === \"number\" ? `${props.borderLeftWidth}px` : props.borderLeftWidth};\n border-left-color: ${props.borderLeftColor || props.borderColor || \"transparent\"};\n border-left-style: solid;\n `}\n ${(props) =>\n props.borderRightWidth !== undefined &&\n `\n border-right-width: ${typeof props.borderRightWidth === \"number\" ? `${props.borderRightWidth}px` : props.borderRightWidth};\n border-right-color: ${props.borderRightColor || props.borderColor || \"transparent\"};\n border-right-style: solid;\n `}\n\n border-style: ${(props) =>\n props.borderStyle ||\n (props.borderWidth ||\n props.borderBottomWidth ||\n props.borderTopWidth ||\n props.borderLeftWidth ||\n props.borderRightWidth\n ? \"solid\"\n : \"none\")};\n border-radius: ${(props) =>\n typeof props.borderRadius === \"number\"\n ? `${props.borderRadius}px`\n : props.borderRadius || 0};\n height: ${(props) =>\n typeof props.height === \"number\"\n ? `${props.height}px`\n : props.height || \"auto\"};\n width: ${(props) =>\n typeof props.width === \"number\"\n ? `${props.width}px`\n : props.width || \"auto\"};\n min-width: ${(props) =>\n typeof props.minWidth === \"number\"\n ? `${props.minWidth}px`\n : props.minWidth || \"auto\"};\n min-height: ${(props) =>\n typeof props.minHeight === \"number\"\n ? `${props.minHeight}px`\n : props.minHeight || \"auto\"};\n\n padding: ${(props) =>\n typeof props.padding === \"number\"\n ? `${props.padding}px`\n : props.padding || 0};\n ${(props) =>\n props.paddingHorizontal &&\n `\n padding-left: ${typeof props.paddingHorizontal === \"number\" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};\n padding-right: ${typeof props.paddingHorizontal === \"number\" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};\n `}\n ${(props) =>\n props.paddingVertical &&\n `\n padding-top: ${typeof props.paddingVertical === \"number\" ? `${props.paddingVertical}px` : props.paddingVertical};\n padding-bottom: ${typeof props.paddingVertical === \"number\" ? `${props.paddingVertical}px` : props.paddingVertical};\n `}\n ${(props) =>\n props.paddingTop !== undefined &&\n `padding-top: ${typeof props.paddingTop === \"number\" ? `${props.paddingTop}px` : props.paddingTop};`}\n ${(props) =>\n props.paddingBottom !== undefined &&\n `padding-bottom: ${typeof props.paddingBottom === \"number\" ? `${props.paddingBottom}px` : props.paddingBottom};`}\n ${(props) =>\n props.paddingLeft !== undefined &&\n `padding-left: ${typeof props.paddingLeft === \"number\" ? `${props.paddingLeft}px` : props.paddingLeft};`}\n ${(props) =>\n props.paddingRight !== undefined &&\n `padding-right: ${typeof props.paddingRight === \"number\" ? `${props.paddingRight}px` : props.paddingRight};`}\n\n margin: ${(props) =>\n typeof props.margin === \"number\" ? `${props.margin}px` : props.margin || 0};\n ${(props) =>\n props.marginTop !== undefined &&\n `margin-top: ${typeof props.marginTop === \"number\" ? `${props.marginTop}px` : props.marginTop};`}\n ${(props) =>\n props.marginBottom !== undefined &&\n `margin-bottom: ${typeof props.marginBottom === \"number\" ? `${props.marginBottom}px` : props.marginBottom};`}\n ${(props) =>\n props.marginLeft !== undefined &&\n `margin-left: ${typeof props.marginLeft === \"number\" ? `${props.marginLeft}px` : props.marginLeft};`}\n ${(props) =>\n props.marginRight !== undefined &&\n `margin-right: ${typeof props.marginRight === \"number\" ? `${props.marginRight}px` : props.marginRight};`}\n\n flex-direction: ${(props) => props.flexDirection || \"column\"};\n flex-wrap: ${(props) => props.flexWrap || \"nowrap\"};\n align-items: ${(props) => props.alignItems || \"stretch\"};\n justify-content: ${(props) => props.justifyContent || \"flex-start\"};\n cursor: ${(props) =>\n props.cursor\n ? props.cursor\n : props.onClick || props.onPress\n ? \"pointer\"\n : \"inherit\"};\n position: ${(props) => props.position || \"static\"};\n top: ${(props) =>\n typeof props.top === \"number\" ? `${props.top}px` : props.top};\n bottom: ${(props) =>\n typeof props.bottom === \"number\" ? `${props.bottom}px` : props.bottom};\n left: ${(props) =>\n typeof props.left === \"number\" ? `${props.left}px` : props.left};\n right: ${(props) =>\n typeof props.right === \"number\" ? `${props.right}px` : props.right};\n flex: ${(props) => props.flex};\n flex-shrink: ${(props) => props.flexShrink ?? 1};\n gap: ${(props) =>\n typeof props.gap === \"number\" ? `${props.gap}px` : props.gap || 0};\n align-self: ${(props) => props.alignSelf || \"auto\"};\n overflow: ${(props) => props.overflow || \"visible\"};\n overflow-x: ${(props) => props.overflowX || \"visible\"};\n overflow-y: ${(props) => props.overflowY || \"visible\"};\n z-index: ${(props) => props.zIndex};\n opacity: ${(props) => (props.disabled ? 0.5 : 1)};\n pointer-events: ${(props) => (props.disabled ? \"none\" : \"auto\")};\n\n &:hover {\n ${(props) =>\n props.hoverStyle?.backgroundColor &&\n `background-color: ${props.hoverStyle.backgroundColor};`}\n ${(props) =>\n props.hoverStyle?.borderColor &&\n `border-color: ${props.hoverStyle.borderColor};`}\n }\n\n &:active {\n ${(props) =>\n props.pressStyle?.backgroundColor &&\n `background-color: ${props.pressStyle.backgroundColor};`}\n }\n`;\n\nexport const Box = React.forwardRef<\n HTMLDivElement | HTMLButtonElement,\n BoxProps\n>(\n (\n {\n children,\n onPress,\n onKeyDown,\n onKeyUp,\n role,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-current\": ariaCurrent,\n \"aria-disabled\": ariaDisabled,\n \"aria-live\": ariaLive,\n \"aria-busy\": ariaBusy,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-expanded\": ariaExpanded,\n \"aria-haspopup\": ariaHasPopup,\n \"aria-pressed\": ariaPressed,\n \"aria-controls\": ariaControls,\n tabIndex,\n as,\n src,\n alt,\n type,\n disabled,\n id,\n ...props\n },\n ref\n ) => {\n // Handle as=\"img\" for rendering images with proper border-radius\n if (as === \"img\" && src) {\n return (\n <img\n src={src}\n alt={alt || \"\"}\n style={{\n display: \"block\",\n objectFit: \"cover\",\n width:\n typeof props.width === \"number\"\n ? `${props.width}px`\n : props.width,\n height:\n typeof props.height === \"number\"\n ? `${props.height}px`\n : props.height,\n borderRadius:\n typeof props.borderRadius === \"number\"\n ? `${props.borderRadius}px`\n : props.borderRadius,\n position: props.position,\n top: typeof props.top === \"number\" ? `${props.top}px` : props.top,\n left:\n typeof props.left === \"number\" ? `${props.left}px` : props.left,\n right:\n typeof props.right === \"number\"\n ? `${props.right}px`\n : props.right,\n bottom:\n typeof props.bottom === \"number\"\n ? `${props.bottom}px`\n : props.bottom,\n }}\n />\n );\n }\n\n return (\n <StyledBox\n ref={ref}\n as={as}\n id={id}\n type={as === \"button\" ? type || \"button\" : undefined}\n disabled={as === \"button\" ? disabled : undefined}\n onClick={onPress}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n role={role}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-current={ariaCurrent}\n aria-disabled={ariaDisabled}\n aria-busy={ariaBusy}\n aria-describedby={ariaDescribedBy}\n aria-expanded={ariaExpanded}\n aria-haspopup={ariaHasPopup}\n aria-pressed={ariaPressed}\n aria-controls={ariaControls}\n aria-live={ariaLive}\n tabIndex={tabIndex !== undefined ? tabIndex : undefined}\n {...props}\n >\n {children}\n </StyledBox>\n );\n }\n);\n\nBox.displayName = \"Box\";\n","import React from \"react\";\nimport styled from \"styled-components\";\nimport { TextProps } from \"@xsolla/xui-primitives-core\";\n\nconst StyledText = styled.span<TextProps>`\n color: ${(props) => props.color || \"inherit\"};\n font-size: ${(props) =>\n typeof props.fontSize === \"number\"\n ? `${props.fontSize}px`\n : props.fontSize || \"inherit\"};\n font-weight: ${(props) => props.fontWeight || \"normal\"};\n font-family: ${(props) =>\n props.fontFamily ||\n '\"Pilat Wide Bold\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif !important'};\n line-height: ${(props) =>\n typeof props.lineHeight === \"number\"\n ? `${props.lineHeight}px`\n : props.lineHeight || \"inherit\"};\n white-space: ${(props) => props.whiteSpace || \"normal\"};\n text-align: ${(props) => props.textAlign || \"inherit\"};\n text-decoration: ${(props) => props.textDecoration || \"none\"};\n`;\n\nexport const Text: React.FC<TextProps> = ({\n style,\n className,\n id,\n role,\n ...props\n}) => {\n return (\n <StyledText\n {...props}\n style={style}\n className={className}\n id={id}\n role={role}\n />\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAAmD;;;ACAnD,mBAAkB;AAClB,+BAAmB;AAuMX;AApMR,IAAM,YAAY,yBAAAC,QAAO;AAAA;AAAA;AAAA,sBAGH,CAAC,UAAU,MAAM,mBAAmB,aAAa;AAAA,kBACrD,CAAC,UAAU,MAAM,eAAe,aAAa;AAAA,kBAC7C,CAAC,UACf,OAAO,MAAM,gBAAgB,WACzB,GAAG,MAAM,WAAW,OACpB,MAAM,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,aAAO,eAAe,IAAI,SAAS,MAAM,OAAO,QAAQ;AAAA,IAC1D;AACA,WAAO,MAAM,OAAO,QAAQ;AAAA,EAC9B;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAS,CAAC,WAAW,UAAU;AAAA,MAC/B,mBAAmB;AAAA,MACnB,iBAAiB;AAAA,MACjB,eAAc;AAAA,MACd,YAAW;AAAA,MACX,iBAAiB,mBAAmB;AAAA,MACpC,YACE,CAAC,YAAY,CAAC,WACV;AAAA,QACE,iBAAiB,MAAM,OAAO,QAAQ,MAAM;AAAA,MAC9C,IACA;AAAA,MAEN,OAAO;AAAA,QACL,SAAS,WAAW,MAAM;AAAA,QAC1B,QAAQ,WAAW,gBAAgB;AAAA,MACrC;AAAA,MAEC;AAAA,gBACC,6CAAC,OAAI,aAAa,IAAI,YAAW,UAAS,gBAAe,UACtD,gBACH;AAAA,QAEF,6CAAC,OAAI,MAAM,GACT,uDAAC,QAAK,OAAO,gBAAgB,GAAG,UAAU,IAAI,YAAW,OACtD,UACH,GACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["import_react","styled","React","import_styled_components","import_jsx_runtime","styled","import_jsx_runtime"]}
1
+ {"version":3,"sources":["../../src/index.tsx","../../src/Dropdown.tsx","../../../primitives-web/src/Box.tsx","../../../primitives-web/src/Text.tsx"],"sourcesContent":["export * from \"./Dropdown\";\n","import React, { useState, useRef, useEffect, useCallback } from \"react\";\n// @ts-expect-error - this will be resolved at build time\nimport { Box, Text } from \"@xsolla/xui-primitives\";\nimport { useDesignSystem } from \"@xsolla/xui-core\";\n\nexport interface DropdownProps {\n trigger: React.ReactNode;\n children: React.ReactNode;\n isOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n /** Width of the dropdown menu (does not affect trigger width) */\n width?: string | number;\n /** Horizontal alignment of dropdown menu relative to trigger. Default: \"start\" */\n align?: \"start\" | \"end\";\n /** Accessible label for the dropdown menu */\n \"aria-label\"?: string;\n /** Test ID for testing frameworks */\n testID?: string;\n}\n\nexport const Dropdown: React.FC<DropdownProps> = ({\n trigger,\n children,\n isOpen: propIsOpen,\n onOpenChange,\n width = \"auto\",\n align = \"start\",\n \"aria-label\": ariaLabel,\n testID,\n}) => {\n const [internalIsOpen, setInternalIsOpen] = useState(false);\n const isOpen = propIsOpen !== undefined ? propIsOpen : internalIsOpen;\n const containerRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLDivElement>(null);\n const menuRef = useRef<HTMLDivElement>(null);\n const { theme } = useDesignSystem();\n\n const closeMenu = useCallback(() => {\n if (propIsOpen === undefined) {\n setInternalIsOpen(false);\n }\n if (onOpenChange) onOpenChange(false);\n }, [propIsOpen, onOpenChange]);\n\n const toggleOpen = useCallback(() => {\n const nextOpen = !isOpen;\n if (propIsOpen === undefined) {\n setInternalIsOpen(nextOpen);\n }\n if (onOpenChange) onOpenChange(nextOpen);\n }, [isOpen, propIsOpen, onOpenChange]);\n\n // Safe focus helper for cross-platform compatibility\n const focusTrigger = useCallback(() => {\n if (typeof document !== \"undefined\" && triggerRef.current) {\n // Find the first focusable element within the trigger wrapper\n const focusable = triggerRef.current.querySelector<HTMLElement>(\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])'\n );\n if (focusable) {\n focusable.focus();\n }\n }\n }, []);\n\n // Handle keyboard navigation\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n if (event.key === \"Escape\" && isOpen) {\n event.preventDefault();\n closeMenu();\n focusTrigger();\n } else if (event.key === \"Tab\" && isOpen) {\n closeMenu();\n // Also restore focus on Tab for consistent keyboard navigation\n focusTrigger();\n }\n },\n [isOpen, closeMenu, focusTrigger]\n );\n\n // Handle trigger keyboard events\n const handleTriggerKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n toggleOpen();\n } else if (event.key === \"ArrowDown\" && !isOpen) {\n event.preventDefault();\n if (propIsOpen === undefined) {\n setInternalIsOpen(true);\n }\n if (onOpenChange) onOpenChange(true);\n }\n },\n [isOpen, toggleOpen, propIsOpen, onOpenChange]\n );\n\n useEffect(() => {\n const handleClickOutside = (event: MouseEvent) => {\n if (\n containerRef.current &&\n !containerRef.current.contains(event.target as Node)\n ) {\n closeMenu();\n }\n };\n\n if (isOpen && typeof document !== \"undefined\") {\n document.addEventListener(\"mousedown\", handleClickOutside);\n }\n return () => {\n if (typeof document !== \"undefined\") {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n }\n };\n }, [isOpen, closeMenu]);\n\n return (\n <div\n ref={containerRef}\n style={{\n position: \"relative\",\n width: \"fit-content\",\n alignSelf: \"flex-start\",\n height: \"fit-content\",\n }}\n onKeyDown={handleKeyDown}\n data-testid={testID}\n >\n <div\n ref={triggerRef}\n onClick={toggleOpen}\n onKeyDown={handleTriggerKeyDown}\n aria-haspopup=\"menu\"\n aria-expanded={isOpen}\n >\n {trigger}\n </div>\n {isOpen && (\n <Box\n ref={menuRef}\n position=\"absolute\"\n top=\"100%\"\n {...(align === \"end\" ? { right: 0 } : { left: 0 })}\n marginTop={4}\n backgroundColor={theme.colors.background.secondary}\n borderColor={theme.colors.border.secondary}\n borderWidth={1}\n borderRadius={theme.radius.button}\n paddingVertical={4}\n role=\"menu\"\n {...(ariaLabel ? { \"aria-label\": ariaLabel } : {})}\n style={{\n zIndex: 1000,\n boxShadow: \"0 4px 12px rgba(0,0,0,0.1)\",\n ...(width === \"auto\" ? { minWidth: \"100%\" } : { width }),\n }}\n >\n {children}\n </Box>\n )}\n </div>\n );\n};\n\nexport interface DropdownItemProps {\n children: React.ReactNode;\n onPress?: () => void;\n active?: boolean;\n /** Whether this item is selected (shows trailing checkmark with control/check/bg color) */\n selected?: boolean;\n disabled?: boolean;\n icon?: React.ReactNode;\n /** Test ID for testing frameworks */\n testID?: string;\n}\n\nexport const DropdownItem: React.FC<DropdownItemProps> = ({\n children,\n onPress,\n active,\n selected,\n disabled,\n icon,\n testID,\n}) => {\n const { theme } = useDesignSystem();\n const brandColors = theme.colors.control.brand.primary;\n const contentColors = theme.colors.content;\n\n // Determine background color\n const getBackgroundColor = () => {\n if (selected) {\n return brandColors?.bg || theme.colors.control.input.bg; // Cyan background for selected items\n }\n if (active) {\n return theme.colors.control.input.bgHover;\n }\n return \"transparent\";\n };\n\n // Determine text/icon color\n const getContentColor = () => {\n if (selected) {\n return contentColors?.on?.brand || theme.colors.content.primary; // Black text on cyan background\n }\n return theme.colors.content.secondary;\n };\n\n // Handle keyboard activation\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if ((event.key === \"Enter\" || event.key === \" \") && !disabled && onPress) {\n event.preventDefault();\n onPress();\n }\n };\n\n return (\n <Box\n onPress={!disabled ? onPress : undefined}\n paddingHorizontal={16}\n paddingVertical={8}\n flexDirection=\"row\"\n alignItems=\"center\"\n backgroundColor={getBackgroundColor()}\n hoverStyle={\n !disabled && !selected\n ? {\n backgroundColor: theme.colors.control.input.bgHover,\n }\n : undefined\n }\n role=\"menuitem\"\n tabIndex={disabled ? -1 : 0}\n aria-disabled={disabled}\n onKeyDown={handleKeyDown}\n testID={testID}\n style={{\n opacity: disabled ? 0.5 : 1,\n cursor: disabled ? \"not-allowed\" : \"pointer\",\n }}\n >\n {icon && (\n <Box marginRight={12} alignItems=\"center\" justifyContent=\"center\">\n {icon}\n </Box>\n )}\n <Box flex={1}>\n <Text color={getContentColor()} fontSize={14} fontWeight=\"400\">\n {children}\n </Text>\n </Box>\n </Box>\n );\n};\n\nDropdown.displayName = \"Dropdown\";\nDropdownItem.displayName = \"DropdownItem\";\n","import React from \"react\";\nimport styled from \"styled-components\";\nimport type { BoxProps } from \"@xsolla/xui-primitives-core\";\n\nconst StyledBox = styled.div<BoxProps>`\n display: flex;\n box-sizing: border-box;\n background-color: ${(props) => props.backgroundColor || \"transparent\"};\n border-color: ${(props) => props.borderColor || \"transparent\"};\n border-width: ${(props) =>\n typeof props.borderWidth === \"number\"\n ? `${props.borderWidth}px`\n : props.borderWidth || 0};\n\n ${(props) =>\n props.borderBottomWidth !== undefined &&\n `\n border-bottom-width: ${typeof props.borderBottomWidth === \"number\" ? `${props.borderBottomWidth}px` : props.borderBottomWidth};\n border-bottom-color: ${props.borderBottomColor || props.borderColor || \"transparent\"};\n border-bottom-style: solid;\n `}\n ${(props) =>\n props.borderTopWidth !== undefined &&\n `\n border-top-width: ${typeof props.borderTopWidth === \"number\" ? `${props.borderTopWidth}px` : props.borderTopWidth};\n border-top-color: ${props.borderTopColor || props.borderColor || \"transparent\"};\n border-top-style: solid;\n `}\n ${(props) =>\n props.borderLeftWidth !== undefined &&\n `\n border-left-width: ${typeof props.borderLeftWidth === \"number\" ? `${props.borderLeftWidth}px` : props.borderLeftWidth};\n border-left-color: ${props.borderLeftColor || props.borderColor || \"transparent\"};\n border-left-style: solid;\n `}\n ${(props) =>\n props.borderRightWidth !== undefined &&\n `\n border-right-width: ${typeof props.borderRightWidth === \"number\" ? `${props.borderRightWidth}px` : props.borderRightWidth};\n border-right-color: ${props.borderRightColor || props.borderColor || \"transparent\"};\n border-right-style: solid;\n `}\n\n border-style: ${(props) =>\n props.borderStyle ||\n (props.borderWidth ||\n props.borderBottomWidth ||\n props.borderTopWidth ||\n props.borderLeftWidth ||\n props.borderRightWidth\n ? \"solid\"\n : \"none\")};\n border-radius: ${(props) =>\n typeof props.borderRadius === \"number\"\n ? `${props.borderRadius}px`\n : props.borderRadius || 0};\n height: ${(props) =>\n typeof props.height === \"number\"\n ? `${props.height}px`\n : props.height || \"auto\"};\n width: ${(props) =>\n typeof props.width === \"number\"\n ? `${props.width}px`\n : props.width || \"auto\"};\n min-width: ${(props) =>\n typeof props.minWidth === \"number\"\n ? `${props.minWidth}px`\n : props.minWidth || \"auto\"};\n min-height: ${(props) =>\n typeof props.minHeight === \"number\"\n ? `${props.minHeight}px`\n : props.minHeight || \"auto\"};\n\n padding: ${(props) =>\n typeof props.padding === \"number\"\n ? `${props.padding}px`\n : props.padding || 0};\n ${(props) =>\n props.paddingHorizontal &&\n `\n padding-left: ${typeof props.paddingHorizontal === \"number\" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};\n padding-right: ${typeof props.paddingHorizontal === \"number\" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};\n `}\n ${(props) =>\n props.paddingVertical &&\n `\n padding-top: ${typeof props.paddingVertical === \"number\" ? `${props.paddingVertical}px` : props.paddingVertical};\n padding-bottom: ${typeof props.paddingVertical === \"number\" ? `${props.paddingVertical}px` : props.paddingVertical};\n `}\n ${(props) =>\n props.paddingTop !== undefined &&\n `padding-top: ${typeof props.paddingTop === \"number\" ? `${props.paddingTop}px` : props.paddingTop};`}\n ${(props) =>\n props.paddingBottom !== undefined &&\n `padding-bottom: ${typeof props.paddingBottom === \"number\" ? `${props.paddingBottom}px` : props.paddingBottom};`}\n ${(props) =>\n props.paddingLeft !== undefined &&\n `padding-left: ${typeof props.paddingLeft === \"number\" ? `${props.paddingLeft}px` : props.paddingLeft};`}\n ${(props) =>\n props.paddingRight !== undefined &&\n `padding-right: ${typeof props.paddingRight === \"number\" ? `${props.paddingRight}px` : props.paddingRight};`}\n\n margin: ${(props) =>\n typeof props.margin === \"number\" ? `${props.margin}px` : props.margin || 0};\n ${(props) =>\n props.marginTop !== undefined &&\n `margin-top: ${typeof props.marginTop === \"number\" ? `${props.marginTop}px` : props.marginTop};`}\n ${(props) =>\n props.marginBottom !== undefined &&\n `margin-bottom: ${typeof props.marginBottom === \"number\" ? `${props.marginBottom}px` : props.marginBottom};`}\n ${(props) =>\n props.marginLeft !== undefined &&\n `margin-left: ${typeof props.marginLeft === \"number\" ? `${props.marginLeft}px` : props.marginLeft};`}\n ${(props) =>\n props.marginRight !== undefined &&\n `margin-right: ${typeof props.marginRight === \"number\" ? `${props.marginRight}px` : props.marginRight};`}\n\n flex-direction: ${(props) => props.flexDirection || \"column\"};\n flex-wrap: ${(props) => props.flexWrap || \"nowrap\"};\n align-items: ${(props) => props.alignItems || \"stretch\"};\n justify-content: ${(props) => props.justifyContent || \"flex-start\"};\n cursor: ${(props) =>\n props.cursor\n ? props.cursor\n : props.onClick || props.onPress\n ? \"pointer\"\n : \"inherit\"};\n position: ${(props) => props.position || \"static\"};\n top: ${(props) =>\n typeof props.top === \"number\" ? `${props.top}px` : props.top};\n bottom: ${(props) =>\n typeof props.bottom === \"number\" ? `${props.bottom}px` : props.bottom};\n left: ${(props) =>\n typeof props.left === \"number\" ? `${props.left}px` : props.left};\n right: ${(props) =>\n typeof props.right === \"number\" ? `${props.right}px` : props.right};\n flex: ${(props) => props.flex};\n flex-shrink: ${(props) => props.flexShrink ?? 1};\n gap: ${(props) =>\n typeof props.gap === \"number\" ? `${props.gap}px` : props.gap || 0};\n align-self: ${(props) => props.alignSelf || \"auto\"};\n overflow: ${(props) => props.overflow || \"visible\"};\n overflow-x: ${(props) => props.overflowX || \"visible\"};\n overflow-y: ${(props) => props.overflowY || \"visible\"};\n z-index: ${(props) => props.zIndex};\n opacity: ${(props) => (props.disabled ? 0.5 : 1)};\n pointer-events: ${(props) => (props.disabled ? \"none\" : \"auto\")};\n\n &:hover {\n ${(props) =>\n props.hoverStyle?.backgroundColor &&\n `background-color: ${props.hoverStyle.backgroundColor};`}\n ${(props) =>\n props.hoverStyle?.borderColor &&\n `border-color: ${props.hoverStyle.borderColor};`}\n }\n\n &:active {\n ${(props) =>\n props.pressStyle?.backgroundColor &&\n `background-color: ${props.pressStyle.backgroundColor};`}\n }\n`;\n\nexport const Box = React.forwardRef<\n HTMLDivElement | HTMLButtonElement,\n BoxProps\n>(\n (\n {\n children,\n onPress,\n onKeyDown,\n onKeyUp,\n role,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-current\": ariaCurrent,\n \"aria-disabled\": ariaDisabled,\n \"aria-live\": ariaLive,\n \"aria-busy\": ariaBusy,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-expanded\": ariaExpanded,\n \"aria-haspopup\": ariaHasPopup,\n \"aria-pressed\": ariaPressed,\n \"aria-controls\": ariaControls,\n tabIndex,\n as,\n src,\n alt,\n type,\n disabled,\n id,\n ...props\n },\n ref\n ) => {\n // Handle as=\"img\" for rendering images with proper border-radius\n if (as === \"img\" && src) {\n return (\n <img\n src={src}\n alt={alt || \"\"}\n style={{\n display: \"block\",\n objectFit: \"cover\",\n width:\n typeof props.width === \"number\"\n ? `${props.width}px`\n : props.width,\n height:\n typeof props.height === \"number\"\n ? `${props.height}px`\n : props.height,\n borderRadius:\n typeof props.borderRadius === \"number\"\n ? `${props.borderRadius}px`\n : props.borderRadius,\n position: props.position,\n top: typeof props.top === \"number\" ? `${props.top}px` : props.top,\n left:\n typeof props.left === \"number\" ? `${props.left}px` : props.left,\n right:\n typeof props.right === \"number\"\n ? `${props.right}px`\n : props.right,\n bottom:\n typeof props.bottom === \"number\"\n ? `${props.bottom}px`\n : props.bottom,\n }}\n />\n );\n }\n\n return (\n <StyledBox\n ref={ref}\n as={as}\n id={id}\n type={as === \"button\" ? type || \"button\" : undefined}\n disabled={as === \"button\" ? disabled : undefined}\n onClick={onPress}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n role={role}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-current={ariaCurrent}\n aria-disabled={ariaDisabled}\n aria-busy={ariaBusy}\n aria-describedby={ariaDescribedBy}\n aria-expanded={ariaExpanded}\n aria-haspopup={ariaHasPopup}\n aria-pressed={ariaPressed}\n aria-controls={ariaControls}\n aria-live={ariaLive}\n tabIndex={tabIndex !== undefined ? tabIndex : undefined}\n {...props}\n >\n {children}\n </StyledBox>\n );\n }\n);\n\nBox.displayName = \"Box\";\n","import React from \"react\";\nimport styled from \"styled-components\";\nimport { TextProps } from \"@xsolla/xui-primitives-core\";\n\nconst StyledText = styled.span<TextProps>`\n color: ${(props) => props.color || \"inherit\"};\n font-size: ${(props) =>\n typeof props.fontSize === \"number\"\n ? `${props.fontSize}px`\n : props.fontSize || \"inherit\"};\n font-weight: ${(props) => props.fontWeight || \"normal\"};\n font-family: ${(props) =>\n props.fontFamily ||\n '\"Pilat Wide Bold\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif !important'};\n line-height: ${(props) =>\n typeof props.lineHeight === \"number\"\n ? `${props.lineHeight}px`\n : props.lineHeight || \"inherit\"};\n white-space: ${(props) => props.whiteSpace || \"normal\"};\n text-align: ${(props) => props.textAlign || \"inherit\"};\n text-decoration: ${(props) => props.textDecoration || \"none\"};\n`;\n\nexport const Text: React.FC<TextProps> = ({\n style,\n className,\n id,\n role,\n ...props\n}) => {\n return (\n <StyledText\n {...props}\n style={style}\n className={className}\n id={id}\n role={role}\n />\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAAgE;;;ACAhE,mBAAkB;AAClB,+BAAmB;AAuMX;AApMR,IAAM,YAAY,yBAAAC,QAAO;AAAA;AAAA;AAAA,sBAGH,CAAC,UAAU,MAAM,mBAAmB,aAAa;AAAA,kBACrD,CAAC,UAAU,MAAM,eAAe,aAAa;AAAA,kBAC7C,CAAC,UACf,OAAO,MAAM,gBAAgB,WACzB,GAAG,MAAM,WAAW,OACpB,MAAM,eAAe,CAAC;AAAA;AAAA,IAE1B,CAAC,UACD,MAAM,sBAAsB,UAC5B;AAAA,2BACuB,OAAO,MAAM,sBAAsB,WAAW,GAAG,MAAM,iBAAiB,OAAO,MAAM,iBAAiB;AAAA,2BACtG,MAAM,qBAAqB,MAAM,eAAe,aAAa;AAAA;AAAA,GAErF;AAAA,IACC,CAAC,UACD,MAAM,mBAAmB,UACzB;AAAA,wBACoB,OAAO,MAAM,mBAAmB,WAAW,GAAG,MAAM,cAAc,OAAO,MAAM,cAAc;AAAA,wBAC7F,MAAM,kBAAkB,MAAM,eAAe,aAAa;AAAA;AAAA,GAE/E;AAAA,IACC,CAAC,UACD,MAAM,oBAAoB,UAC1B;AA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,cAAQ;AAAA,IACV;AAAA,EACF;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAS,CAAC,WAAW,UAAU;AAAA,MAC/B,mBAAmB;AAAA,MACnB,iBAAiB;AAAA,MACjB,eAAc;AAAA,MACd,YAAW;AAAA,MACX,iBAAiB,mBAAmB;AAAA,MACpC,YACE,CAAC,YAAY,CAAC,WACV;AAAA,QACE,iBAAiB,MAAM,OAAO,QAAQ,MAAM;AAAA,MAC9C,IACA;AAAA,MAEN,MAAK;AAAA,MACL,UAAU,WAAW,KAAK;AAAA,MAC1B,iBAAe;AAAA,MACf,WAAW;AAAA,MACX;AAAA,MACA,OAAO;AAAA,QACL,SAAS,WAAW,MAAM;AAAA,QAC1B,QAAQ,WAAW,gBAAgB;AAAA,MACrC;AAAA,MAEC;AAAA,gBACC,6CAAC,OAAI,aAAa,IAAI,YAAW,UAAS,gBAAe,UACtD,gBACH;AAAA,QAEF,6CAAC,OAAI,MAAM,GACT,uDAAC,QAAK,OAAO,gBAAgB,GAAG,UAAU,IAAI,YAAW,OACtD,UACH,GACF;AAAA;AAAA;AAAA,EACF;AAEJ;AAEA,SAAS,cAAc;AACvB,aAAa,cAAc;","names":["import_react","styled","React","import_styled_components","import_jsx_runtime","styled","import_jsx_runtime"]}
package/web/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/Dropdown.tsx
2
- import { useState, useRef, useEffect } from "react";
2
+ import { useState, useRef, useEffect, useCallback } from "react";
3
3
 
4
4
  // ../primitives-web/src/Box.tsx
5
5
  import React from "react";
@@ -210,63 +210,126 @@ var Dropdown = ({
210
210
  children,
211
211
  isOpen: propIsOpen,
212
212
  onOpenChange,
213
- width = "auto"
213
+ width = "auto",
214
+ align = "start",
215
+ "aria-label": ariaLabel,
216
+ testID
214
217
  }) => {
215
218
  const [internalIsOpen, setInternalIsOpen] = useState(false);
216
219
  const isOpen = propIsOpen !== void 0 ? propIsOpen : internalIsOpen;
217
220
  const containerRef = useRef(null);
221
+ const triggerRef = useRef(null);
222
+ const menuRef = useRef(null);
218
223
  const { theme } = useDesignSystem();
219
- const toggleOpen = () => {
224
+ const closeMenu = useCallback(() => {
225
+ if (propIsOpen === void 0) {
226
+ setInternalIsOpen(false);
227
+ }
228
+ if (onOpenChange) onOpenChange(false);
229
+ }, [propIsOpen, onOpenChange]);
230
+ const toggleOpen = useCallback(() => {
220
231
  const nextOpen = !isOpen;
221
232
  if (propIsOpen === void 0) {
222
233
  setInternalIsOpen(nextOpen);
223
234
  }
224
235
  if (onOpenChange) onOpenChange(nextOpen);
225
- };
236
+ }, [isOpen, propIsOpen, onOpenChange]);
237
+ const focusTrigger = useCallback(() => {
238
+ if (typeof document !== "undefined" && triggerRef.current) {
239
+ const focusable = triggerRef.current.querySelector(
240
+ 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
241
+ );
242
+ if (focusable) {
243
+ focusable.focus();
244
+ }
245
+ }
246
+ }, []);
247
+ const handleKeyDown = useCallback(
248
+ (event) => {
249
+ if (event.key === "Escape" && isOpen) {
250
+ event.preventDefault();
251
+ closeMenu();
252
+ focusTrigger();
253
+ } else if (event.key === "Tab" && isOpen) {
254
+ closeMenu();
255
+ focusTrigger();
256
+ }
257
+ },
258
+ [isOpen, closeMenu, focusTrigger]
259
+ );
260
+ const handleTriggerKeyDown = useCallback(
261
+ (event) => {
262
+ if (event.key === "Enter" || event.key === " ") {
263
+ event.preventDefault();
264
+ toggleOpen();
265
+ } else if (event.key === "ArrowDown" && !isOpen) {
266
+ event.preventDefault();
267
+ if (propIsOpen === void 0) {
268
+ setInternalIsOpen(true);
269
+ }
270
+ if (onOpenChange) onOpenChange(true);
271
+ }
272
+ },
273
+ [isOpen, toggleOpen, propIsOpen, onOpenChange]
274
+ );
226
275
  useEffect(() => {
227
276
  const handleClickOutside = (event) => {
228
277
  if (containerRef.current && !containerRef.current.contains(event.target)) {
229
- if (propIsOpen === void 0) {
230
- setInternalIsOpen(false);
231
- }
232
- if (onOpenChange) onOpenChange(false);
278
+ closeMenu();
233
279
  }
234
280
  };
235
- if (isOpen) {
281
+ if (isOpen && typeof document !== "undefined") {
236
282
  document.addEventListener("mousedown", handleClickOutside);
237
283
  }
238
284
  return () => {
239
- document.removeEventListener("mousedown", handleClickOutside);
285
+ if (typeof document !== "undefined") {
286
+ document.removeEventListener("mousedown", handleClickOutside);
287
+ }
240
288
  };
241
- }, [isOpen, propIsOpen, onOpenChange]);
289
+ }, [isOpen, closeMenu]);
242
290
  return /* @__PURE__ */ jsxs(
243
291
  "div",
244
292
  {
245
293
  ref: containerRef,
246
294
  style: {
247
295
  position: "relative",
248
- width: width === "auto" ? "fit-content" : width,
296
+ width: "fit-content",
249
297
  alignSelf: "flex-start",
250
298
  height: "fit-content"
251
299
  },
300
+ onKeyDown: handleKeyDown,
301
+ "data-testid": testID,
252
302
  children: [
253
- /* @__PURE__ */ jsx3("div", { onClick: toggleOpen, style: { cursor: "pointer" }, children: trigger }),
303
+ /* @__PURE__ */ jsx3(
304
+ "div",
305
+ {
306
+ ref: triggerRef,
307
+ onClick: toggleOpen,
308
+ onKeyDown: handleTriggerKeyDown,
309
+ "aria-haspopup": "menu",
310
+ "aria-expanded": isOpen,
311
+ children: trigger
312
+ }
313
+ ),
254
314
  isOpen && /* @__PURE__ */ jsx3(
255
315
  Box,
256
316
  {
317
+ ref: menuRef,
257
318
  position: "absolute",
258
319
  top: "100%",
259
- left: 0,
320
+ ...align === "end" ? { right: 0 } : { left: 0 },
260
321
  marginTop: 4,
261
322
  backgroundColor: theme.colors.background.secondary,
262
323
  borderColor: theme.colors.border.secondary,
263
324
  borderWidth: 1,
264
325
  borderRadius: theme.radius.button,
265
326
  paddingVertical: 4,
327
+ role: "menu",
328
+ ...ariaLabel ? { "aria-label": ariaLabel } : {},
266
329
  style: {
267
330
  zIndex: 1e3,
268
331
  boxShadow: "0 4px 12px rgba(0,0,0,0.1)",
269
- minWidth: "100%"
332
+ ...width === "auto" ? { minWidth: "100%" } : { width }
270
333
  },
271
334
  children
272
335
  }
@@ -281,7 +344,8 @@ var DropdownItem = ({
281
344
  active,
282
345
  selected,
283
346
  disabled,
284
- icon
347
+ icon,
348
+ testID
285
349
  }) => {
286
350
  const { theme } = useDesignSystem();
287
351
  const brandColors = theme.colors.control.brand.primary;
@@ -301,6 +365,12 @@ var DropdownItem = ({
301
365
  }
302
366
  return theme.colors.content.secondary;
303
367
  };
368
+ const handleKeyDown = (event) => {
369
+ if ((event.key === "Enter" || event.key === " ") && !disabled && onPress) {
370
+ event.preventDefault();
371
+ onPress();
372
+ }
373
+ };
304
374
  return /* @__PURE__ */ jsxs(
305
375
  Box,
306
376
  {
@@ -313,6 +383,11 @@ var DropdownItem = ({
313
383
  hoverStyle: !disabled && !selected ? {
314
384
  backgroundColor: theme.colors.control.input.bgHover
315
385
  } : void 0,
386
+ role: "menuitem",
387
+ tabIndex: disabled ? -1 : 0,
388
+ "aria-disabled": disabled,
389
+ onKeyDown: handleKeyDown,
390
+ testID,
316
391
  style: {
317
392
  opacity: disabled ? 0.5 : 1,
318
393
  cursor: disabled ? "not-allowed" : "pointer"
@@ -324,6 +399,8 @@ var DropdownItem = ({
324
399
  }
325
400
  );
326
401
  };
402
+ Dropdown.displayName = "Dropdown";
403
+ DropdownItem.displayName = "DropdownItem";
327
404
  export {
328
405
  Dropdown,
329
406
  DropdownItem