@designa8/vibedesign-v6 1.15.3 → 1.20.13

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 (65) hide show
  1. package/README.md +6 -32
  2. package/dist/index.cjs +3232 -2143
  3. package/dist/index.js +3242 -2153
  4. package/dist/styles.css +266 -28
  5. package/package.json +52 -2
  6. package/src/atoms/AppLayout/AppLayout.tsx +401 -395
  7. package/src/atoms/AppLayout/preview.tsx +29 -0
  8. package/src/atoms/AppSidebar/AppSidebar.tsx +182 -94
  9. package/src/atoms/AppSidebar/preview.tsx +20 -59
  10. package/src/atoms/AppSidebarMobile/AppSidebarMobile.tsx +27 -73
  11. package/src/atoms/AppSidebarMobile/preview.tsx +18 -18
  12. package/src/atoms/AuthLogin/AuthLogin.tsx +200 -0
  13. package/src/atoms/AuthLogin/index.ts +2 -0
  14. package/src/atoms/AuthLogin/preview.tsx +22 -0
  15. package/src/atoms/AuthScreen/AuthScreen.tsx +7 -7
  16. package/src/atoms/AuthSignUp/AuthSignUp.tsx +243 -0
  17. package/src/atoms/AuthSignUp/index.ts +2 -0
  18. package/src/atoms/AuthSignUp/preview.tsx +22 -0
  19. package/src/atoms/BillingToggle/BillingToggle.tsx +65 -0
  20. package/src/atoms/BillingToggle/index.ts +2 -0
  21. package/src/atoms/BillingToggle/preview.tsx +23 -0
  22. package/src/atoms/Button/Button.tsx +33 -17
  23. package/src/atoms/Button/preview.tsx +16 -0
  24. package/src/atoms/ChatHistorySidebar/ChatHistorySidebar.tsx +370 -0
  25. package/src/atoms/ChatHistorySidebar/index.ts +2 -0
  26. package/src/atoms/ChatHistorySidebar/preview.tsx +60 -0
  27. package/src/atoms/ChatScreen/ChatScreen.tsx +331 -134
  28. package/src/atoms/ChatScreen/preview.tsx +123 -2
  29. package/src/atoms/Checkbox/Checkbox.tsx +89 -0
  30. package/src/atoms/Checkbox/index.ts +2 -0
  31. package/src/atoms/Checkbox/preview.tsx +60 -0
  32. package/src/atoms/Dropdown/Dropdown.tsx +195 -0
  33. package/src/atoms/Dropdown/index.ts +2 -0
  34. package/src/atoms/Dropdown/preview.tsx +56 -0
  35. package/src/atoms/ExportDesignMdModal/ExportDesignMdModal.tsx +46 -185
  36. package/src/atoms/ExportDesignMdModal/preview.tsx +24 -8
  37. package/src/atoms/FaqAccordionItem/FaqAccordionItem.tsx +60 -0
  38. package/src/atoms/FaqAccordionItem/index.ts +2 -0
  39. package/src/atoms/FaqAccordionItem/preview.tsx +26 -0
  40. package/src/atoms/FilterTabBar/FilterTabBar.tsx +8 -22
  41. package/src/atoms/HomePageTemplate/HomePageTemplate.tsx +20 -33
  42. package/src/atoms/HomePageTemplate/preview.tsx +2 -2
  43. package/src/atoms/Icon/Icon.tsx +7 -5
  44. package/src/atoms/Icon/icons.data.ts +53 -0
  45. package/src/atoms/Input/Input.tsx +17 -9
  46. package/src/atoms/Input/preview.tsx +24 -25
  47. package/src/atoms/Menu/Menu.tsx +320 -0
  48. package/src/atoms/Menu/index.ts +2 -0
  49. package/src/atoms/Menu/preview.tsx +63 -0
  50. package/src/atoms/Modal/Modal.tsx +43 -37
  51. package/src/atoms/Modal/preview.tsx +13 -0
  52. package/src/atoms/NavItem/NavItem.tsx +33 -45
  53. package/src/atoms/NavItem/preview.tsx +21 -26
  54. package/src/atoms/PreviewToolbar/PreviewToolbar.tsx +144 -192
  55. package/src/atoms/PreviewToolbar/preview.tsx +24 -4
  56. package/src/atoms/PricingCard/PricingCard.tsx +164 -0
  57. package/src/atoms/PricingCard/index.ts +2 -0
  58. package/src/atoms/PricingCard/preview.tsx +45 -0
  59. package/src/atoms/PricingPageTemplate/PricingPageTemplate.tsx +219 -0
  60. package/src/atoms/PricingPageTemplate/index.ts +2 -0
  61. package/src/atoms/PricingPageTemplate/preview.tsx +10 -0
  62. package/src/atoms/PromptInputBar/PromptInputBar.tsx +117 -158
  63. package/src/atoms/WorkspaceMenu/WorkspaceMenu.tsx +41 -167
  64. package/src/index.ts +10 -0
  65. package/src/tokens.css +5 -0
@@ -10,17 +10,19 @@ export interface IconProps extends React.SVGProps<SVGSVGElement> {
10
10
  export const Icon = React.forwardRef<SVGSVGElement, IconProps>(
11
11
  ({ name, size = 20, strokeWidth = 2, className, ...props }, ref) => {
12
12
  const glyph = ICON_REGISTRY[name];
13
+ const isFill = "type" in glyph && glyph.type === "fill";
14
+
13
15
  return (
14
16
  <svg
15
17
  ref={ref}
16
18
  viewBox={glyph.viewBox}
17
19
  width={size}
18
20
  height={size}
19
- fill="none"
20
- stroke="currentColor"
21
- strokeWidth={strokeWidth}
22
- strokeLinecap="round"
23
- strokeLinejoin="round"
21
+ fill={isFill ? "currentColor" : "none"}
22
+ stroke={isFill ? "none" : "currentColor"}
23
+ strokeWidth={isFill ? undefined : strokeWidth}
24
+ strokeLinecap={isFill ? undefined : "round"}
25
+ strokeLinejoin={isFill ? undefined : "round"}
24
26
  className={className}
25
27
  aria-hidden="true"
26
28
  {...props}
@@ -9,6 +9,59 @@ export const ICON_REGISTRY = {
9
9
  "star": { viewBox: "0 0 24 24", paths: ["M12 3l2.6 5.6 6.1.7-4.5 4.2 1.2 6-5.4-3-5.4 3 1.2-6-4.5-4.2 6.1-.7L12 3z"] },
10
10
  "archive": { viewBox: "0 0 24 24", paths: ["M3 4h18v4H3z", "M4.5 8v11a1 1 0 0 0 1 1h13a1 1 0 0 0 1-1V8", "M10 12.5h4"] },
11
11
  "list-view": { viewBox: "0 0 24 24", paths: ["M4 6h16", "M4 12h16", "M4 18h16"] },
12
+ "google": { viewBox: "0 0 24 24", paths: ["M21.35 11.1h-9.17v2.98h5.27c-.23 1.4-1.6 4.1-5.27 4.1-3.17 0-5.76-2.62-5.76-5.86s2.59-5.86 5.76-5.86c1.8 0 3.01.77 3.7 1.43l2.52-2.43C16.95 3.61 14.68 2.6 12 2.6 6.98 2.6 2.9 6.7 2.9 11.72s4.08 9.12 9.1 9.12c5.25 0 8.73-3.69 8.73-8.89 0-.6-.06-1.05-.14-1.85z"] },
13
+ "pencil-edit": { viewBox: "0 0 24 24", paths: ["M12 20h9", "M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"] },
14
+ "trash-delete": { viewBox: "0 0 24 24", paths: ["M3 6h18", "M19 6l-1 14H6L5 6", "M10 11v6", "M14 11v6", "M9 6V4h6v2"] },
15
+ "desktop-monitor": { viewBox: "0 0 24 24", paths: ["M2 3h20v14H2z", "M8 21h8M12 17v4"] },
16
+ "mobile-phone": { viewBox: "0 0 24 24", paths: ["M5 2h14v20H5z", "M12 17h.01"] },
17
+ "expand-diagonal-arrows": { viewBox: "0 0 24 24", paths: ["M15 3h6v6", "M9 21H3v-6", "M21 3l-7 7", "M3 21l7-7"] },
18
+ "inspect-target-crosshair": { viewBox: "0 0 24 24", paths: ["M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0", "M12 8v4l3 3", "M12 12h.01"] },
19
+ "moon-dark-mode": { viewBox: "0 0 24 24", paths: ["M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"] },
20
+ "fullscreen-corners-expand": { viewBox: "0 0 24 24", paths: ["M15 3h6v6", "M9 21H3v-6", "M21 3l-7 7", "M3 21l7-7"] },
21
+ "more-options-vertical-dots": { viewBox: "0 0 24 24", paths: ["M12 5m-1.6 0a1.6 1.6 0 1 0 3.2 0a1.6 1.6 0 1 0 -3.2 0", "M12 12m-1.6 0a1.6 1.6 0 1 0 3.2 0a1.6 1.6 0 1 0 -3.2 0", "M12 19m-1.6 0a1.6 1.6 0 1 0 3.2 0a1.6 1.6 0 1 0 -3.2 0"] },
22
+ "logout-sign-out": { viewBox: "0 0 24 24", paths: ["M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4", "M16 17l5-5-5-5", "M21 12H9"] },
23
+ "gift-present": { viewBox: "0 0 24 24", paths: ["M20 12v10H4V12", "M2 7h20v5H2z", "M12 22V7", "M12 7H7.5a2.5 2.5 0 0 1 0-5C11 2 12 7 12 7z", "M12 7h4.5a2.5 2.5 0 0 0 0-5C13 2 12 7 12 7z"] },
24
+ "inbox-mail-tray": { viewBox: "0 0 24 24", paths: ["M22 12h-6l-2 3h-4l-2-3H2", "M5.45 5.11L2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"] },
25
+ "sidebar-panel-toggle": { viewBox: "0 0 24 24", paths: ["M3 3h18v18H3z", "M9 3v18"] },
26
+ "sun-light-mode": { viewBox: "0 0 24 24", paths: ["M12 17a5 5 0 1 0 0-10 5 5 0 0 0 0 10z", "M12 1v2", "M12 21v2", "M4.22 4.22l1.42 1.42", "M18.36 18.36l1.42 1.42", "M1 12h2", "M21 12h2", "M4.22 19.78l1.42-1.42", "M18.36 5.64l1.42-1.42"] },
27
+ "home": { viewBox: "0 0 24 24", paths: ["M3 9.75L12 3l9 6.75V20a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V9.75z", "M9 21V12h6v9"] },
28
+ "search-magnifier": { viewBox: "0 0 24 24", paths: ["M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16z", "M21 21l-4.35-4.35"] },
29
+ "folder": { viewBox: "0 0 24 24", paths: ["M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"] },
30
+ "settings-gear": { viewBox: "0 0 24 24", paths: ["M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z", "M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"] },
31
+ "file-document": { viewBox: "0 0 24 24", paths: ["M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z", "M14 2v6h6"] },
32
+ "sparkle": { viewBox: "0 0 24 24", paths: ["M12 2l2.4 7.4H22l-6.2 4.5 2.4 7.4L12 17 5.8 21.3l2.4-7.4L2 9.4h7.6z"] },
33
+ "lock-padlock": { viewBox: "0 0 24 24", paths: ["M6 11V8a6 6 0 1112 0v3", "M5 11h14a1 1 0 011 1v8a2 2 0 01-2 2H6a2 2 0 01-2-2v-8a1 1 0 011-1z"] },
34
+ "eye-show-password": { viewBox: "0 0 24 24", paths: ["M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z", "M12 15a3 3 0 100-6 3 3 0 000 6z"] },
35
+ "eye-off-hide-password": { viewBox: "0 0 24 24", paths: ["M3 3l18 18", "M10.58 10.58a3 3 0 004.24 4.24", "M9.88 5.09A9.77 9.77 0 0112 5c6.5 0 10 7 10 7a17.3 17.3 0 01-3.16 4.19M6.5 6.61C4.13 8.14 2 12 2 12a17.19 17.19 0 004.06 5.06A9.77 9.77 0 0012 19c1 0 1.96-.14 2.85-.4"] },
36
+ "loading-spinner": { viewBox: "0 0 24 24", paths: ["M12 3v3", "M12 18v3", "M5.636 5.636l2.121 2.121", "M16.243 16.243l2.121 2.121", "M3 12h3", "M18 12h3", "M5.636 18.364l2.121-2.121", "M16.243 7.757l2.121-2.121"] },
37
+ "hamburger-menu": { viewBox: "0 0 24 24", paths: ["M3 6h18", "M3 12h18", "M3 18h18"] },
38
+ "plus-add": { viewBox: "0 0 24 24", paths: ["M12 5v14", "M5 12h14"] },
39
+ "visual-edits-swap-arrows": { viewBox: "0 0 24 24", paths: ["M17 1l4 4-4 4", "M3 11V9a4 4 0 0 1 4-4h14", "M7 23l-4-4 4-4", "M21 13v2a4 4 0 0 1-4 4H3"] },
40
+ "microphone": {
41
+ viewBox: "-3 0 19 19",
42
+ type: "fill",
43
+ paths: [
44
+ "M11.665 7.915v1.31a5.257 5.257 0 0 1-1.514 3.694 5.174 5.174 0 0 1-1.641 1.126 5.04 5.04 0 0 1-1.456.384v1.899h2.312a.554.554 0 0 1 0 1.108H3.634a.554.554 0 0 1 0-1.108h2.312v-1.899a5.045 5.045 0 0 1-1.456-.384 5.174 5.174 0 0 1-1.641-1.126 5.257 5.257 0 0 1-1.514-3.695v-1.31a.554.554 0 1 1 1.109 0v1.31a4.131 4.131 0 0 0 1.195 2.917 3.989 3.989 0 0 0 5.722 0 4.133 4.133 0 0 0 1.195-2.917v-1.31a.554.554 0 1 1 1.109 0zM3.77 10.37a2.875 2.875 0 0 1-.233-1.146V4.738A2.905 2.905 0 0 1 3.77 3.58a3 3 0 0 1 1.59-1.59 2.902 2.902 0 0 1 1.158-.233 2.865 2.865 0 0 1 1.152.233 2.977 2.977 0 0 1 1.793 2.748l-.012 4.487a2.958 2.958 0 0 1-.856 2.09 3.025 3.025 0 0 1-.937.634 2.865 2.865 0 0 1-1.152.233 2.905 2.905 0 0 1-1.158-.233A2.957 2.957 0 0 1 3.77 10.37z",
45
+ ],
46
+ },
47
+ "stop-square": { viewBox: "0 0 24 24", paths: ["M5 5h14v14H5z"] },
48
+ "arrow-up-send": { viewBox: "0 0 24 24", paths: ["M12 19V5", "M5 12l7-7 7 7"] },
49
+ "clock-thinking": { viewBox: "0 0 24 24", paths: ["M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20z", "M12 8v4l2 2"] },
50
+ "read-open-book-document": { viewBox: "0 0 24 24", paths: ["M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z", "M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"] },
51
+ "wrench-tool": { viewBox: "0 0 24 24", paths: ["M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"] },
52
+ "two-people-users-group": { viewBox: "0 0 24 24", paths: ["M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2", "M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8z", "M23 21v-2a4 4 0 0 0-3-3.87", "M16 3.13a4 4 0 0 1 0 7.75"] },
53
+ "soft-organic-blob-decorative-background-": { viewBox: "0 0 160 140", paths: ["M78 8c28-6 52 10 58 34 6 24-6 44-4 62 2 16-14 30-36 32-26 2-48-8-62-28-12-18-22-42-10-58C36 30 52 14 78 8z"] },
54
+ "help-question-circle": { viewBox: "0 0 24 24", paths: ["M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0", "M9.5 9a2.5 2.5 0 0 1 4.6-1.35c.4.66.4 1.5-.1 2.1-.6.75-1.5 1-1.9 1.75-.2.35-.1.9-.1.9", "M12 17h.01"] },
55
+ "external-link-arrow-up-right": { viewBox: "0 0 24 24", paths: ["M7 17L17 7", "M8 7h9v9"] },
56
+ "arrow-left": { viewBox: "0 0 24 24", paths: ["M19 12H5", "m12 19-7-7 7-7"] },
57
+ "chat-bubble": { viewBox: "0 0 24 24", paths: ["M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"] },
58
+ "eye-view": { viewBox: "0 0 24 24", paths: ["M2 12s4-7 10-7 10 7 10 7-4 7-10 7-10-7-10-7z", "M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z"] },
59
+ "image-placeholder-dashed-frame": { viewBox: "0 0 72 72", paths: ["M4 4h64v64H4z", "M14 14h20v20H14z", "M38 14h20v20H38z", "M14 38h44v12H14z"] },
60
+ "image-photo-picture": { viewBox: "0 0 24 24", paths: ["M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2Z", "M11 9a2 2 0 1 1-4 0 2 2 0 0 1 4 0Z", "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"] },
61
+ "video-film-clapperboard": { viewBox: "0 0 24 24", paths: ["M4 6h10a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2Z", "m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5"] },
62
+ "minus-indeterminate": { viewBox: "0 0 24 24", paths: ["M5 12h14"] },
63
+ "cloud": { viewBox: "0 0 24 24", paths: ["M17.5 19a4.5 4.5 0 0 0 0-9 5.5 5.5 0 0 0-10.8-1.5A4 4 0 0 0 6.5 16", "M8 19h9.5"] },
64
+ "download": { viewBox: "0 0 24 24", paths: ["M12 3v12", "M7 10l5 5 5-5", "M5 21h14"] },
12
65
  } as const;
13
66
 
14
67
  export type IconName = keyof typeof ICON_REGISTRY;
@@ -12,29 +12,35 @@ export interface InputProps
12
12
  error?: string;
13
13
  /** Size variant */
14
14
  size?: InputSize;
15
- /** Leading icon (any inline SVG or element) */
15
+ /** Leading icon (any inline SVG or element) — decorative only */
16
16
  leadingIcon?: React.ReactNode;
17
- /** Trailing icon / adornment */
17
+ /** Trailing icon / adornment — may contain an interactive element (e.g. a password-visibility toggle button) */
18
18
  trailingIcon?: React.ReactNode;
19
19
  /** Fill full width of its container */
20
20
  fullWidth?: boolean;
21
21
  }
22
22
 
23
- const sizeClasses: Record<InputSize, { input: string; icon: string; label: string }> = {
23
+ const sizeClasses: Record<
24
+ InputSize,
25
+ { input: string; icon: string; label: string; trailingPad: string }
26
+ > = {
24
27
  sm: {
25
28
  input: "h-8 px-sm text-body-sm",
26
29
  icon: "w-4 h-4",
27
30
  label: "text-body-sm",
31
+ trailingPad: "pr-9",
28
32
  },
29
33
  md: {
30
34
  input: "h-10 px-md text-body-md",
31
35
  icon: "w-4 h-4",
32
36
  label: "text-body-sm",
37
+ trailingPad: "pr-10",
33
38
  },
34
39
  lg: {
35
40
  input: "h-12 px-base text-body-lg",
36
41
  icon: "w-5 h-5",
37
42
  label: "text-body-md",
43
+ trailingPad: "pr-12",
38
44
  },
39
45
  };
40
46
 
@@ -59,7 +65,12 @@ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
59
65
  const inputId = id ?? generatedId;
60
66
  const helperId = `${inputId}-helper`;
61
67
  const hasError = Boolean(error);
62
- const { input: inputSize, icon: iconSize, label: labelSize } = sizeClasses[size];
68
+ const {
69
+ input: inputSize,
70
+ icon: iconSize,
71
+ label: labelSize,
72
+ trailingPad,
73
+ } = sizeClasses[size];
63
74
 
64
75
  const borderColor = hasError
65
76
  ? "border-semantic-error focus:ring-semantic-error/30 focus:border-semantic-error"
@@ -102,7 +113,7 @@ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
102
113
  inputSize,
103
114
  borderColor,
104
115
  leadingIcon ? "pl-9" : "",
105
- trailingIcon ? "pr-9" : "",
116
+ trailingIcon ? trailingPad : "",
106
117
  disabled
107
118
  ? "cursor-not-allowed bg-surface-soft text-muted opacity-60"
108
119
  : "",
@@ -114,10 +125,7 @@ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
114
125
  />
115
126
 
116
127
  {trailingIcon && (
117
- <span
118
- aria-hidden="true"
119
- className={`absolute right-md flex items-center text-muted ${iconSize}`}
120
- >
128
+ <span className="absolute right-sm flex items-center justify-center text-muted overflow-visible pointer-events-auto">
121
129
  {trailingIcon}
122
130
  </span>
123
131
  )}
@@ -1,28 +1,11 @@
1
1
  import React from "react";
2
2
  import { Input } from "./Input";
3
-
4
- const MailIcon = () => (
5
- <svg viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth={1.5} className="w-full h-full">
6
- <rect x="2.5" y="4.5" width="15" height="11" rx="1.5" />
7
- <path d="M2.5 7l7.09 4.5a.9.9 0 0 0 .82 0L17.5 7" />
8
- </svg>
9
- );
10
-
11
- const SearchIcon = () => (
12
- <svg viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth={1.5} className="w-full h-full">
13
- <circle cx="9" cy="9" r="5.5" />
14
- <path d="M14 14l3.5 3.5" strokeLinecap="round" />
15
- </svg>
16
- );
17
-
18
- const EyeIcon = () => (
19
- <svg viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth={1.5} className="w-full h-full">
20
- <path d="M2 10s3-6 8-6 8 6 8 6-3 6-8 6-8-6-8-6z" />
21
- <circle cx="10" cy="10" r="2.5" />
22
- </svg>
23
- );
3
+ import { Icon } from "../Icon";
4
+ import { Button } from "../Button";
24
5
 
25
6
  export default function InputPreview() {
7
+ const [showPassword, setShowPassword] = React.useState(false);
8
+
26
9
  return (
27
10
  <div className="w-full max-w-2xl mx-auto p-lg space-y-xl">
28
11
 
@@ -73,20 +56,36 @@ export default function InputPreview() {
73
56
  <Input
74
57
  label="Email address"
75
58
  placeholder="you@example.com"
76
- leadingIcon={<MailIcon />}
59
+ leadingIcon={<Icon name="inbox-mail-tray" className="w-full h-full" />}
77
60
  fullWidth
78
61
  />
79
62
  <Input
80
63
  label="Search"
81
64
  placeholder="Search anything…"
82
- leadingIcon={<SearchIcon />}
65
+ leadingIcon={<Icon name="search-magnifier" className="w-full h-full" />}
83
66
  fullWidth
84
67
  />
85
68
  <Input
86
69
  label="Password"
87
- type="password"
70
+ type={showPassword ? "text" : "password"}
88
71
  placeholder="Enter your password"
89
- trailingIcon={<EyeIcon />}
72
+ defaultValue="hunter2"
73
+ trailingIcon={
74
+ <Button
75
+ type="button"
76
+ variant="ghost"
77
+ size="sm"
78
+ className="p-xs rounded-md"
79
+ aria-label={showPassword ? "Hide password" : "Show password"}
80
+ aria-pressed={showPassword}
81
+ onClick={() => setShowPassword((v) => !v)}
82
+ >
83
+ <Icon
84
+ name={showPassword ? "eye-off-hide-password" : "eye-show-password"}
85
+ className="w-5 h-5"
86
+ />
87
+ </Button>
88
+ }
90
89
  fullWidth
91
90
  />
92
91
  </div>
@@ -0,0 +1,320 @@
1
+ import React from "react";
2
+ import { createPortal } from "react-dom";
3
+ import { Button } from "../Button";
4
+ import { Icon } from "../Icon";
5
+
6
+ export interface MenuItem {
7
+ /** Stable identifier, also used as the React key */
8
+ id: string;
9
+ /** Visible label */
10
+ label: string;
11
+ /** Optional icon name resolved through the shared Icon atom, rendered as a leading prefix */
12
+ icon?: string;
13
+ /** Called when the item is chosen (click or Enter/Space while focused) */
14
+ onSelect?: () => void;
15
+ /** Disables the item */
16
+ disabled?: boolean;
17
+ /** Renders the item in the destructive (error) color */
18
+ destructive?: boolean;
19
+ /** Renders a hairline divider above this item */
20
+ withDividerBefore?: boolean;
21
+ }
22
+
23
+ export interface MenuProps extends React.HTMLAttributes<HTMLDivElement> {
24
+ /** Items rendered in the floating list, top to bottom */
25
+ items: MenuItem[];
26
+ /** Custom trigger element. When omitted, a default Button with `triggerLabel` is rendered */
27
+ trigger?: React.ReactNode;
28
+ /** Label for the default trigger button (ignored when `trigger` is provided) */
29
+ triggerLabel?: string;
30
+ /** Which edge of the trigger the menu is anchored to */
31
+ align?: "left" | "right";
32
+ /** Controlled open state */
33
+ open?: boolean;
34
+ /** Called whenever the menu requests an open/close state change */
35
+ onOpenChange?: (open: boolean) => void;
36
+ /** Uncontrolled initial open state (useful for previews) */
37
+ defaultOpen?: boolean;
38
+ /** Accessible label for the default trigger button */
39
+ "aria-label"?: string;
40
+ /**
41
+ * Renders the floating item list through a portal into `document.body`,
42
+ * positioned with `position: fixed` against the trigger's viewport
43
+ * coordinates instead of being absolutely positioned inside this
44
+ * component. Use this whenever the trigger lives inside an ancestor that
45
+ * clips overflow (`overflow-hidden`) or that animates/transforms — the
46
+ * default `absolute` list would otherwise be clipped or mis-positioned.
47
+ * Defaults to false.
48
+ */
49
+ portal?: boolean;
50
+ }
51
+
52
+ const CLOSE_ANIMATION_MS = 200;
53
+
54
+ export const Menu = React.forwardRef<HTMLDivElement, MenuProps>(
55
+ (
56
+ {
57
+ items,
58
+ trigger,
59
+ triggerLabel = "Options",
60
+ align = "left",
61
+ open: controlledOpen,
62
+ onOpenChange,
63
+ defaultOpen = false,
64
+ className,
65
+ "aria-label": ariaLabel,
66
+ portal = false,
67
+ ...rest
68
+ },
69
+ ref
70
+ ) => {
71
+ const isControlled = controlledOpen !== undefined;
72
+ const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen);
73
+ const open = isControlled ? (controlledOpen as boolean) : uncontrolledOpen;
74
+
75
+ // `mounted` keeps the list in the DOM through the close transition;
76
+ // `visible` drives the opacity/scale classes — mirrors the Modal pattern.
77
+ const [mounted, setMounted] = React.useState(open);
78
+ const [visible, setVisible] = React.useState(false);
79
+
80
+ const rootRef = React.useRef<HTMLDivElement>(null);
81
+ const triggerWrapRef = React.useRef<HTMLSpanElement>(null);
82
+ const listRef = React.useRef<HTMLDivElement>(null);
83
+ const itemRefs = React.useRef<Array<HTMLButtonElement | null>>([]);
84
+ const [highlighted, setHighlighted] = React.useState(-1);
85
+ const [coords, setCoords] = React.useState<{ top: number; left: number; right: number } | null>(null);
86
+
87
+ const setRefs = React.useCallback(
88
+ (node: HTMLDivElement | null) => {
89
+ (rootRef as React.MutableRefObject<HTMLDivElement | null>).current = node;
90
+ if (typeof ref === "function") ref(node);
91
+ else if (ref) (ref as React.MutableRefObject<HTMLDivElement | null>).current = node;
92
+ },
93
+ [ref]
94
+ );
95
+
96
+ const setOpen = React.useCallback(
97
+ (next: boolean) => {
98
+ if (!isControlled) setUncontrolledOpen(next);
99
+ onOpenChange?.(next);
100
+ },
101
+ [isControlled, onOpenChange]
102
+ );
103
+
104
+ const updateCoords = React.useCallback(() => {
105
+ const el = triggerWrapRef.current;
106
+ if (!el) return;
107
+ const rect = el.getBoundingClientRect();
108
+ setCoords({ top: rect.bottom + 4, left: rect.left, right: window.innerWidth - rect.right });
109
+ }, []);
110
+
111
+ // Mount-then-paint-then-fade, same double-rAF technique as Modal so the
112
+ // browser doesn't batch the initial + final opacity into one frame.
113
+ React.useEffect(() => {
114
+ if (open) {
115
+ if (portal) updateCoords();
116
+ setMounted(true);
117
+ const raf = requestAnimationFrame(() => {
118
+ requestAnimationFrame(() => setVisible(true));
119
+ });
120
+ return () => cancelAnimationFrame(raf);
121
+ }
122
+ setVisible(false);
123
+ const timer = window.setTimeout(() => setMounted(false), CLOSE_ANIMATION_MS);
124
+ return () => window.clearTimeout(timer);
125
+ }, [open, portal, updateCoords]);
126
+
127
+ React.useEffect(() => {
128
+ if (!open) return;
129
+ setHighlighted(-1);
130
+ const handlePointerDown = (e: PointerEvent) => {
131
+ const target = e.target as Node;
132
+ if (rootRef.current?.contains(target)) return;
133
+ if (portal && listRef.current?.contains(target)) return;
134
+ setOpen(false);
135
+ };
136
+ const handleKey = (e: KeyboardEvent) => {
137
+ if (e.key === "Escape") setOpen(false);
138
+ };
139
+ document.addEventListener("pointerdown", handlePointerDown);
140
+ document.addEventListener("keydown", handleKey);
141
+ if (portal) {
142
+ window.addEventListener("resize", updateCoords);
143
+ window.addEventListener("scroll", updateCoords, true);
144
+ }
145
+ return () => {
146
+ document.removeEventListener("pointerdown", handlePointerDown);
147
+ document.removeEventListener("keydown", handleKey);
148
+ if (portal) {
149
+ window.removeEventListener("resize", updateCoords);
150
+ window.removeEventListener("scroll", updateCoords, true);
151
+ }
152
+ };
153
+ }, [open, setOpen, portal, updateCoords]);
154
+
155
+ React.useEffect(() => {
156
+ if (highlighted >= 0) itemRefs.current[highlighted]?.focus();
157
+ }, [highlighted]);
158
+
159
+ const enabledIndexes = items
160
+ .map((item, idx) => (item.disabled ? -1 : idx))
161
+ .filter((idx) => idx >= 0);
162
+
163
+ const moveHighlight = (dir: 1 | -1) => {
164
+ if (enabledIndexes.length === 0) return;
165
+ const pos = enabledIndexes.indexOf(highlighted);
166
+ const nextPos =
167
+ pos === -1
168
+ ? dir === 1
169
+ ? 0
170
+ : enabledIndexes.length - 1
171
+ : (pos + dir + enabledIndexes.length) % enabledIndexes.length;
172
+ setHighlighted(enabledIndexes[nextPos]);
173
+ };
174
+
175
+ const handleTriggerKeyDown = (e: React.KeyboardEvent) => {
176
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
177
+ e.preventDefault();
178
+ if (!open) setOpen(true);
179
+ moveHighlight(e.key === "ArrowDown" ? 1 : -1);
180
+ }
181
+ };
182
+
183
+ const handleListKeyDown = (e: React.KeyboardEvent) => {
184
+ if (e.key === "ArrowDown") {
185
+ e.preventDefault();
186
+ moveHighlight(1);
187
+ } else if (e.key === "ArrowUp") {
188
+ e.preventDefault();
189
+ moveHighlight(-1);
190
+ } else if (e.key === "Tab") {
191
+ setOpen(false);
192
+ }
193
+ };
194
+
195
+ const commit = (item: MenuItem) => {
196
+ if (item.disabled) return;
197
+ setOpen(false);
198
+ item.onSelect?.();
199
+ };
200
+
201
+ const listClassName = [
202
+ "z-10 mt-xs min-w-52 origin-top overflow-hidden rounded-md border border-hairline-soft bg-surface p-xxs shadow-card",
203
+ "transition-all duration-200 ease-in-out will-change-transform",
204
+ visible
205
+ ? "pointer-events-auto opacity-100 translate-y-0 scale-100"
206
+ : "pointer-events-none opacity-0 -translate-y-1 scale-95",
207
+ ].join(" ");
208
+
209
+ const listContent = mounted && (
210
+ <div
211
+ ref={(node) => {
212
+ (listRef as React.MutableRefObject<HTMLDivElement | null>).current = node;
213
+ setRefs(node);
214
+ }}
215
+ role="menu"
216
+ aria-label={ariaLabel ?? triggerLabel}
217
+ aria-hidden={!open}
218
+ onKeyDown={handleListKeyDown}
219
+ className={
220
+ portal
221
+ ? ["fixed", listClassName, "!mt-0"].join(" ")
222
+ : ["absolute", listClassName, align === "right" ? "right-0" : "left-0"].join(" ")
223
+ }
224
+ style={
225
+ portal && coords
226
+ ? {
227
+ top: coords.top,
228
+ ...(align === "right" ? { right: coords.right } : { left: coords.left }),
229
+ zIndex: "var(--z-dropdown, 9999)",
230
+ }
231
+ : undefined
232
+ }
233
+ >
234
+ {items.map((item, idx) => (
235
+ <React.Fragment key={item.id}>
236
+ {item.withDividerBefore && <div className="my-xxs h-px bg-hairline-soft" />}
237
+ <Button
238
+ ref={(node) => {
239
+ itemRefs.current[idx] = node;
240
+ }}
241
+ type="button"
242
+ role="menuitem"
243
+ variant="bare"
244
+ size="auto"
245
+ pushEffect={false}
246
+ disabled={item.disabled}
247
+ tabIndex={-1}
248
+ onMouseEnter={() => setHighlighted(idx)}
249
+ onClick={() => commit(item)}
250
+ className={[
251
+ "!flex !w-full items-center !justify-start gap-sm rounded-sm px-sm py-sm text-left text-body-sm transition-colors",
252
+ item.disabled
253
+ ? "cursor-not-allowed text-muted-soft"
254
+ : item.destructive
255
+ ? "text-[var(--color-semantic-error)] hover:bg-surface-soft"
256
+ : "text-ink hover:bg-surface-soft",
257
+ idx === highlighted && !item.disabled ? "bg-surface-soft" : "",
258
+ ].join(" ")}
259
+ >
260
+ {item.icon && (
261
+ <Icon
262
+ name={item.icon}
263
+ className={[
264
+ "size-4 shrink-0",
265
+ item.disabled ? "text-muted-soft" : item.destructive ? "text-[var(--color-semantic-error)]" : "text-muted",
266
+ ].join(" ")}
267
+ />
268
+ )}
269
+ <span className="flex-1 truncate">{item.label}</span>
270
+ </Button>
271
+ </React.Fragment>
272
+ ))}
273
+ </div>
274
+ );
275
+
276
+ return (
277
+ <div
278
+ ref={portal ? rootRef : setRefs}
279
+ className={["relative inline-block", className].filter(Boolean).join(" ")}
280
+ {...rest}
281
+ >
282
+ <span ref={triggerWrapRef} onKeyDown={handleTriggerKeyDown}>
283
+ {trigger ? (
284
+ <span
285
+ onClick={() => setOpen(!open)}
286
+ aria-haspopup="menu"
287
+ aria-expanded={open}
288
+ role="button"
289
+ tabIndex={0}
290
+ >
291
+ {trigger}
292
+ </span>
293
+ ) : (
294
+ <Button
295
+ type="button"
296
+ variant="secondary"
297
+ size="sm"
298
+ aria-haspopup="menu"
299
+ aria-expanded={open}
300
+ aria-label={ariaLabel ?? triggerLabel}
301
+ onClick={() => setOpen(!open)}
302
+ className="!gap-sm"
303
+ >
304
+ <span>{triggerLabel}</span>
305
+ <Icon
306
+ name="chevron-down"
307
+ className="size-4 shrink-0 transition-transform duration-180 ease-in-out"
308
+ style={{ transform: open ? "rotate(180deg)" : "rotate(0deg)" }}
309
+ />
310
+ </Button>
311
+ )}
312
+ </span>
313
+
314
+ {portal ? (mounted && typeof document !== "undefined" ? createPortal(listContent, document.body) : null) : listContent}
315
+ </div>
316
+ );
317
+ }
318
+ );
319
+
320
+ Menu.displayName = "Menu";
@@ -0,0 +1,2 @@
1
+ export { Menu } from "./Menu";
2
+ export type { MenuProps, MenuItem } from "./Menu";
@@ -0,0 +1,63 @@
1
+ import React from "react";
2
+ import { Menu, type MenuItem } from "./Menu";
3
+ import { Button } from "../Button";
4
+ import { Icon } from "../Icon";
5
+
6
+ export default function MenuPreview() {
7
+ const [lastAction, setLastAction] = React.useState<string>("—");
8
+
9
+ const accountItems: MenuItem[] = [
10
+ { id: "profile", label: "Profile", icon: "two-people-users-group", onSelect: () => setLastAction("Profile") },
11
+ { id: "settings", label: "Settings", icon: "settings-gear", onSelect: () => setLastAction("Settings") },
12
+ { id: "rename", label: "Rename", icon: "pencil-edit", onSelect: () => setLastAction("Rename") },
13
+ { id: "logout", label: "Log out", icon: "logout-sign-out", onSelect: () => setLastAction("Log out"), withDividerBefore: true },
14
+ ];
15
+
16
+ const fileItems: MenuItem[] = [
17
+ { id: "open", label: "Open", icon: "folder", onSelect: () => setLastAction("Open") },
18
+ { id: "star", label: "Star", icon: "star", onSelect: () => setLastAction("Star") },
19
+ { id: "archive", label: "Archive", icon: "archive", disabled: true },
20
+ { id: "delete", label: "Delete", icon: "trash-delete", destructive: true, onSelect: () => setLastAction("Delete"), withDividerBefore: true },
21
+ ];
22
+
23
+ const [controlledOpen, setControlledOpen] = React.useState(false);
24
+
25
+ return (
26
+ <div className="w-full max-w-3xl mx-auto p-lg space-y-xl">
27
+ <p className="text-body-sm text-muted">
28
+ Last action: <span className="text-ink font-weight-heading-sm">{lastAction}</span>
29
+ </p>
30
+
31
+ <div className="flex flex-wrap items-start gap-xl">
32
+ <div className="space-y-sm">
33
+ <p className="text-caption uppercase tracking-wide text-muted-soft">Default trigger</p>
34
+ <Menu triggerLabel="Account" items={accountItems} />
35
+ </div>
36
+
37
+ <div className="space-y-sm">
38
+ <p className="text-caption uppercase tracking-wide text-muted-soft">Right-aligned, custom trigger</p>
39
+ <Menu
40
+ align="right"
41
+ items={fileItems}
42
+ aria-label="File actions"
43
+ trigger={
44
+ <Button variant="ghost" size="sm" aria-label="File actions" className="!px-xs">
45
+ <Icon name="more-options-vertical-dots" className="size-5" />
46
+ </Button>
47
+ }
48
+ />
49
+ </div>
50
+
51
+ <div className="space-y-sm">
52
+ <p className="text-caption uppercase tracking-wide text-muted-soft">Controlled</p>
53
+ <Menu
54
+ triggerLabel={controlledOpen ? "Close menu" : "Open menu"}
55
+ items={accountItems}
56
+ open={controlledOpen}
57
+ onOpenChange={setControlledOpen}
58
+ />
59
+ </div>
60
+ </div>
61
+ </div>
62
+ );
63
+ }