agentic-ds-kit 0.1.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/AGENTS.md +10 -0
- package/CLAUDE.md +1 -0
- package/LICENSE +21 -0
- package/README.md +38 -0
- package/contracts/accordion.json +38 -0
- package/contracts/alert.json +57 -0
- package/contracts/alertdialog.json +89 -0
- package/contracts/appheader.json +140 -0
- package/contracts/appnav.json +72 -0
- package/contracts/avatar.json +63 -0
- package/contracts/avatargroup.json +83 -0
- package/contracts/badge.json +92 -0
- package/contracts/barchart.json +55 -0
- package/contracts/breadcrumb.json +76 -0
- package/contracts/button.json +120 -0
- package/contracts/buttongroup.json +48 -0
- package/contracts/calendar.json +93 -0
- package/contracts/card.json +123 -0
- package/contracts/carousel.json +98 -0
- package/contracts/cell.json +203 -0
- package/contracts/chat.json +131 -0
- package/contracts/checkbox.json +101 -0
- package/contracts/collapsible.json +66 -0
- package/contracts/command.json +84 -0
- package/contracts/datatable.json +126 -0
- package/contracts/datepicker.json +102 -0
- package/contracts/drawer.json +93 -0
- package/contracts/dropdownmenu.json +190 -0
- package/contracts/empty.json +79 -0
- package/contracts/field.json +49 -0
- package/contracts/fieldset.json +29 -0
- package/contracts/headercell.json +107 -0
- package/contracts/index.json +478 -0
- package/contracts/input.json +119 -0
- package/contracts/inputotp.json +119 -0
- package/contracts/insightcard.json +130 -0
- package/contracts/linechart.json +51 -0
- package/contracts/loadinganimation.json +33 -0
- package/contracts/modal.json +100 -0
- package/contracts/modalcard.json +88 -0
- package/contracts/navigationmenu.json +65 -0
- package/contracts/numbertransition.json +33 -0
- package/contracts/pageheader.json +101 -0
- package/contracts/pagination.json +85 -0
- package/contracts/patterns/activity.json +30 -0
- package/contracts/patterns/assistant-workspace.json +16 -0
- package/contracts/patterns/dashboard.json +12 -0
- package/contracts/patterns/empty-first-run.json +15 -0
- package/contracts/patterns/inbox.json +32 -0
- package/contracts/patterns/invite-members.json +14 -0
- package/contracts/patterns/list-detail.json +13 -0
- package/contracts/patterns/settings-form.json +13 -0
- package/contracts/piechart.json +68 -0
- package/contracts/progress.json +124 -0
- package/contracts/progresssteps.json +91 -0
- package/contracts/radiogroup.json +132 -0
- package/contracts/scoreboard.json +46 -0
- package/contracts/scorecard.json +124 -0
- package/contracts/section.json +97 -0
- package/contracts/select.json +130 -0
- package/contracts/shimmertext.json +33 -0
- package/contracts/sidenav.json +133 -0
- package/contracts/slider.json +81 -0
- package/contracts/spinner.json +52 -0
- package/contracts/switch.json +94 -0
- package/contracts/table.json +92 -0
- package/contracts/tabs.json +90 -0
- package/contracts/textarea.json +54 -0
- package/contracts/thinkinganimation.json +32 -0
- package/contracts/timeline.json +49 -0
- package/contracts/toast.json +104 -0
- package/contracts/tooltip.json +66 -0
- package/lib/tokens.css +637 -0
- package/package.json +60 -0
- package/skills/prototype-from-kit/SKILL.md +29 -0
- package/src/index.ts +71 -0
- package/tokens/tokens.json +725 -0
- package/ui/Accordion/Accordion.module.css +68 -0
- package/ui/Accordion/Accordion.tsx +51 -0
- package/ui/Accordion/Accordion.types.ts +10 -0
- package/ui/Accordion/index.ts +2 -0
- package/ui/Alert/Alert.module.css +62 -0
- package/ui/Alert/Alert.tsx +27 -0
- package/ui/Alert/Alert.types.ts +7 -0
- package/ui/Alert/index.ts +2 -0
- package/ui/AlertDialog/AlertDialog.module.css +71 -0
- package/ui/AlertDialog/AlertDialog.tsx +109 -0
- package/ui/AlertDialog/AlertDialog.types.ts +14 -0
- package/ui/AlertDialog/index.ts +6 -0
- package/ui/AppHeader/AppHeader.module.css +120 -0
- package/ui/AppHeader/AppHeader.tsx +70 -0
- package/ui/AppHeader/AppHeader.types.ts +28 -0
- package/ui/AppHeader/index.ts +2 -0
- package/ui/AppNav/AppNav.module.css +168 -0
- package/ui/AppNav/AppNav.tsx +137 -0
- package/ui/AppNav/AppNav.types.ts +24 -0
- package/ui/AppNav/index.ts +2 -0
- package/ui/Avatar/Avatar.module.css +52 -0
- package/ui/Avatar/Avatar.tsx +62 -0
- package/ui/Avatar/Avatar.types.ts +8 -0
- package/ui/Avatar/index.ts +2 -0
- package/ui/AvatarGroup/AvatarGroup.module.css +49 -0
- package/ui/AvatarGroup/AvatarGroup.tsx +29 -0
- package/ui/AvatarGroup/AvatarGroup.types.ts +16 -0
- package/ui/AvatarGroup/index.ts +2 -0
- package/ui/Badge/Badge.module.css +92 -0
- package/ui/Badge/Badge.tsx +43 -0
- package/ui/Badge/Badge.types.ts +11 -0
- package/ui/Badge/index.ts +2 -0
- package/ui/BarChart/BarChart.module.css +56 -0
- package/ui/BarChart/BarChart.tsx +380 -0
- package/ui/BarChart/BarChart.types.ts +18 -0
- package/ui/BarChart/index.ts +2 -0
- package/ui/Breadcrumb/Breadcrumb.module.css +64 -0
- package/ui/Breadcrumb/Breadcrumb.tsx +89 -0
- package/ui/Breadcrumb/Breadcrumb.types.ts +14 -0
- package/ui/Breadcrumb/index.ts +2 -0
- package/ui/Button/Button.module.css +101 -0
- package/ui/Button/Button.tsx +49 -0
- package/ui/Button/Button.types.ts +18 -0
- package/ui/Button/index.ts +2 -0
- package/ui/Button/lucideName.tsx +188 -0
- package/ui/ButtonGroup/ButtonGroup.module.css +31 -0
- package/ui/ButtonGroup/ButtonGroup.tsx +12 -0
- package/ui/ButtonGroup/ButtonGroup.types.ts +6 -0
- package/ui/ButtonGroup/index.ts +2 -0
- package/ui/Calendar/Calendar.module.css +146 -0
- package/ui/Calendar/Calendar.tsx +296 -0
- package/ui/Calendar/Calendar.types.ts +11 -0
- package/ui/Calendar/index.ts +2 -0
- package/ui/Card/Card.module.css +95 -0
- package/ui/Card/Card.tsx +69 -0
- package/ui/Card/Card.types.ts +23 -0
- package/ui/Card/index.ts +2 -0
- package/ui/Carousel/Carousel.module.css +114 -0
- package/ui/Carousel/Carousel.tsx +152 -0
- package/ui/Carousel/Carousel.types.ts +17 -0
- package/ui/Carousel/index.ts +7 -0
- package/ui/Cell/Cell.module.css +133 -0
- package/ui/Cell/Cell.tsx +300 -0
- package/ui/Cell/Cell.types.ts +69 -0
- package/ui/Cell/index.ts +11 -0
- package/ui/Chat/Chat.module.css +149 -0
- package/ui/Chat/Chat.tsx +175 -0
- package/ui/Chat/Chat.types.ts +39 -0
- package/ui/Chat/index.ts +2 -0
- package/ui/Checkbox/Checkbox.module.css +135 -0
- package/ui/Checkbox/Checkbox.tsx +70 -0
- package/ui/Checkbox/Checkbox.types.ts +15 -0
- package/ui/Checkbox/index.ts +2 -0
- package/ui/Collapsible/Collapsible.module.css +68 -0
- package/ui/Collapsible/Collapsible.tsx +59 -0
- package/ui/Collapsible/Collapsible.types.ts +9 -0
- package/ui/Collapsible/index.ts +2 -0
- package/ui/Command/Command.module.css +138 -0
- package/ui/Command/Command.tsx +152 -0
- package/ui/Command/Command.types.ts +20 -0
- package/ui/Command/index.ts +2 -0
- package/ui/DataTable/DataTable.module.css +211 -0
- package/ui/DataTable/DataTable.tsx +429 -0
- package/ui/DataTable/DataTable.types.ts +35 -0
- package/ui/DataTable/index.ts +8 -0
- package/ui/DatePicker/DatePicker.module.css +44 -0
- package/ui/DatePicker/DatePicker.tsx +123 -0
- package/ui/DatePicker/DatePicker.types.ts +15 -0
- package/ui/DatePicker/index.ts +2 -0
- package/ui/Drawer/Drawer.module.css +204 -0
- package/ui/Drawer/Drawer.tsx +112 -0
- package/ui/Drawer/Drawer.types.ts +14 -0
- package/ui/Drawer/index.ts +2 -0
- package/ui/DropdownMenu/DropdownMenu.module.css +319 -0
- package/ui/DropdownMenu/DropdownMenu.tsx +580 -0
- package/ui/DropdownMenu/DropdownMenu.types.ts +48 -0
- package/ui/DropdownMenu/index.ts +8 -0
- package/ui/Empty/Empty.module.css +68 -0
- package/ui/Empty/Empty.tsx +35 -0
- package/ui/Empty/Empty.types.ts +10 -0
- package/ui/Empty/index.ts +2 -0
- package/ui/Field/Field.module.css +66 -0
- package/ui/Field/Field.tsx +46 -0
- package/ui/Field/Field.types.ts +12 -0
- package/ui/Field/index.ts +2 -0
- package/ui/FieldSet/FieldSet.module.css +30 -0
- package/ui/FieldSet/FieldSet.tsx +14 -0
- package/ui/FieldSet/FieldSet.types.ts +7 -0
- package/ui/FieldSet/index.ts +2 -0
- package/ui/HeaderCell/HeaderCell.module.css +85 -0
- package/ui/HeaderCell/HeaderCell.tsx +71 -0
- package/ui/HeaderCell/HeaderCell.types.ts +18 -0
- package/ui/HeaderCell/index.ts +2 -0
- package/ui/Input/Input.module.css +59 -0
- package/ui/Input/Input.tsx +65 -0
- package/ui/Input/Input.types.ts +22 -0
- package/ui/Input/index.ts +2 -0
- package/ui/InputOTP/InputOTP.module.css +139 -0
- package/ui/InputOTP/InputOTP.tsx +136 -0
- package/ui/InputOTP/InputOTP.types.ts +19 -0
- package/ui/InputOTP/index.ts +2 -0
- package/ui/InsightCard/InsightCard.module.css +166 -0
- package/ui/InsightCard/InsightCard.tsx +90 -0
- package/ui/InsightCard/InsightCard.types.ts +20 -0
- package/ui/InsightCard/index.ts +7 -0
- package/ui/LineChart/LineChart.module.css +93 -0
- package/ui/LineChart/LineChart.tsx +424 -0
- package/ui/LineChart/LineChart.types.ts +19 -0
- package/ui/LineChart/index.ts +2 -0
- package/ui/LoadingAnimation/LoadingAnimation.module.css +66 -0
- package/ui/LoadingAnimation/LoadingAnimation.tsx +41 -0
- package/ui/LoadingAnimation/LoadingAnimation.types.ts +9 -0
- package/ui/LoadingAnimation/index.ts +6 -0
- package/ui/Modal/Modal.module.css +48 -0
- package/ui/Modal/Modal.tsx +114 -0
- package/ui/Modal/Modal.types.ts +15 -0
- package/ui/Modal/index.ts +2 -0
- package/ui/ModalCard/ModalCard.module.css +137 -0
- package/ui/ModalCard/ModalCard.tsx +58 -0
- package/ui/ModalCard/ModalCard.types.ts +15 -0
- package/ui/ModalCard/index.ts +2 -0
- package/ui/NavigationMenu/NavigationMenu.module.css +31 -0
- package/ui/NavigationMenu/NavigationMenu.tsx +57 -0
- package/ui/NavigationMenu/NavigationMenu.types.ts +22 -0
- package/ui/NavigationMenu/index.ts +7 -0
- package/ui/NumberTransition/NumberTransition.module.css +110 -0
- package/ui/NumberTransition/NumberTransition.tsx +78 -0
- package/ui/NumberTransition/NumberTransition.types.ts +9 -0
- package/ui/NumberTransition/index.ts +2 -0
- package/ui/PageHeader/PageHeader.module.css +57 -0
- package/ui/PageHeader/PageHeader.tsx +39 -0
- package/ui/PageHeader/PageHeader.types.ts +12 -0
- package/ui/PageHeader/index.ts +2 -0
- package/ui/Pagination/Pagination.module.css +19 -0
- package/ui/Pagination/Pagination.tsx +147 -0
- package/ui/Pagination/Pagination.types.ts +12 -0
- package/ui/Pagination/index.ts +2 -0
- package/ui/PieChart/PieChart.module.css +116 -0
- package/ui/PieChart/PieChart.tsx +293 -0
- package/ui/PieChart/PieChart.types.ts +22 -0
- package/ui/PieChart/index.ts +2 -0
- package/ui/Progress/Progress.module.css +226 -0
- package/ui/Progress/Progress.tsx +167 -0
- package/ui/Progress/Progress.types.ts +15 -0
- package/ui/Progress/index.ts +8 -0
- package/ui/ProgressSteps/ProgressSteps.module.css +210 -0
- package/ui/ProgressSteps/ProgressSteps.tsx +105 -0
- package/ui/ProgressSteps/ProgressSteps.types.ts +19 -0
- package/ui/ProgressSteps/index.ts +8 -0
- package/ui/RadioGroup/RadioGroup.module.css +284 -0
- package/ui/RadioGroup/RadioGroup.tsx +116 -0
- package/ui/RadioGroup/RadioGroup.types.ts +30 -0
- package/ui/RadioGroup/index.ts +8 -0
- package/ui/Scoreboard/Scoreboard.module.css +53 -0
- package/ui/Scoreboard/Scoreboard.tsx +41 -0
- package/ui/Scoreboard/Scoreboard.types.ts +7 -0
- package/ui/Scoreboard/index.ts +2 -0
- package/ui/Scorecard/Scorecard.module.css +150 -0
- package/ui/Scorecard/Scorecard.tsx +92 -0
- package/ui/Scorecard/Scorecard.types.ts +18 -0
- package/ui/Scorecard/index.ts +2 -0
- package/ui/Section/Section.module.css +104 -0
- package/ui/Section/Section.tsx +75 -0
- package/ui/Section/Section.types.ts +15 -0
- package/ui/Section/index.ts +2 -0
- package/ui/Select/Select.module.css +7 -0
- package/ui/Select/Select.tsx +113 -0
- package/ui/Select/Select.types.ts +26 -0
- package/ui/Select/index.ts +2 -0
- package/ui/ShimmerText/ShimmerText.module.css +46 -0
- package/ui/ShimmerText/ShimmerText.tsx +48 -0
- package/ui/ShimmerText/ShimmerText.types.ts +12 -0
- package/ui/ShimmerText/index.ts +2 -0
- package/ui/SideNav/SideNav.module.css +347 -0
- package/ui/SideNav/SideNav.tsx +222 -0
- package/ui/SideNav/SideNav.types.ts +42 -0
- package/ui/SideNav/index.ts +8 -0
- package/ui/Slider/Slider.module.css +105 -0
- package/ui/Slider/Slider.tsx +187 -0
- package/ui/Slider/Slider.types.ts +11 -0
- package/ui/Slider/index.ts +2 -0
- package/ui/Spinner/Spinner.module.css +58 -0
- package/ui/Spinner/Spinner.tsx +19 -0
- package/ui/Spinner/Spinner.types.ts +6 -0
- package/ui/Spinner/index.ts +2 -0
- package/ui/Switch/Switch.module.css +189 -0
- package/ui/Switch/Switch.tsx +65 -0
- package/ui/Switch/Switch.types.ts +12 -0
- package/ui/Switch/index.ts +2 -0
- package/ui/Table/Table.module.css +132 -0
- package/ui/Table/Table.tsx +108 -0
- package/ui/Table/Table.types.ts +26 -0
- package/ui/Table/index.ts +8 -0
- package/ui/Tabs/Tabs.module.css +162 -0
- package/ui/Tabs/Tabs.tsx +150 -0
- package/ui/Tabs/Tabs.types.ts +21 -0
- package/ui/Tabs/index.ts +2 -0
- package/ui/Textarea/Textarea.module.css +74 -0
- package/ui/Textarea/Textarea.tsx +38 -0
- package/ui/Textarea/Textarea.types.ts +14 -0
- package/ui/Textarea/index.ts +2 -0
- package/ui/ThinkingAnimation/ThinkingAnimation.module.css +75 -0
- package/ui/ThinkingAnimation/ThinkingAnimation.tsx +31 -0
- package/ui/ThinkingAnimation/ThinkingAnimation.types.ts +8 -0
- package/ui/ThinkingAnimation/index.ts +2 -0
- package/ui/Timeline/Timeline.module.css +99 -0
- package/ui/Timeline/Timeline.tsx +47 -0
- package/ui/Timeline/Timeline.types.ts +16 -0
- package/ui/Timeline/index.ts +2 -0
- package/ui/Toast/Toast.module.css +133 -0
- package/ui/Toast/Toast.tsx +89 -0
- package/ui/Toast/Toast.types.ts +17 -0
- package/ui/Toast/index.ts +2 -0
- package/ui/Tooltip/Tooltip.module.css +111 -0
- package/ui/Tooltip/Tooltip.tsx +101 -0
- package/ui/Tooltip/index.ts +2 -0
- package/ui/patterns/ActivityPattern/ActivityFeed.tsx +77 -0
- package/ui/patterns/ActivityPattern/ActivityPattern.tsx +120 -0
- package/ui/patterns/ActivityPattern/ActivityTasks.tsx +86 -0
- package/ui/patterns/ActivityPattern/TaskDrawer.module.css +39 -0
- package/ui/patterns/ActivityPattern/TaskDrawer.tsx +186 -0
- package/ui/patterns/ActivityPattern/index.ts +2 -0
- package/ui/patterns/AssistantWorkspacePattern/AssistantWorkspacePattern.module.css +16 -0
- package/ui/patterns/AssistantWorkspacePattern/AssistantWorkspacePattern.tsx +159 -0
- package/ui/patterns/AssistantWorkspacePattern/index.ts +2 -0
- package/ui/patterns/DashboardPattern/DashboardPattern.tsx +102 -0
- package/ui/patterns/DashboardPattern/index.ts +1 -0
- package/ui/patterns/DashboardPattern/patterns.module.css +6 -0
- package/ui/patterns/EmptyFirstRunPattern/EmptyFirstRunPattern.tsx +125 -0
- package/ui/patterns/EmptyFirstRunPattern/index.ts +2 -0
- package/ui/patterns/InboxPattern/InboxPattern.module.css +40 -0
- package/ui/patterns/InboxPattern/InboxPattern.tsx +192 -0
- package/ui/patterns/InboxPattern/InboxReplyDrawer.tsx +97 -0
- package/ui/patterns/InboxPattern/inbox-data.ts +101 -0
- package/ui/patterns/InboxPattern/index.ts +2 -0
- package/ui/patterns/InviteMembersPattern/InviteMembersPattern.tsx +148 -0
- package/ui/patterns/InviteMembersPattern/index.ts +2 -0
- package/ui/patterns/ListDetailPattern/ListDetailPattern.module.css +34 -0
- package/ui/patterns/ListDetailPattern/ListDetailPattern.tsx +145 -0
- package/ui/patterns/ListDetailPattern/index.ts +2 -0
- package/ui/patterns/SettingsFormPattern/SettingsFormPattern.module.css +12 -0
- package/ui/patterns/SettingsFormPattern/SettingsFormPattern.tsx +89 -0
- package/ui/patterns/SettingsFormPattern/index.ts +3 -0
- package/ui/shared/ChartFrame.module.css +295 -0
- package/ui/shared/ChartFrame.tsx +87 -0
- package/ui/shared/chartMath.ts +228 -0
- package/ui/shared/controls.module.css +48 -0
- package/ui/shared/useChartSize.ts +22 -0
|
@@ -0,0 +1,580 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
useEffect,
|
|
5
|
+
useId,
|
|
6
|
+
useLayoutEffect,
|
|
7
|
+
useMemo,
|
|
8
|
+
useRef,
|
|
9
|
+
useState,
|
|
10
|
+
type CSSProperties,
|
|
11
|
+
type KeyboardEvent as ReactKeyboardEvent,
|
|
12
|
+
type ReactNode,
|
|
13
|
+
} from "react";
|
|
14
|
+
import { createPortal } from "react-dom";
|
|
15
|
+
import { Badge } from "../Badge";
|
|
16
|
+
import { Button } from "../Button";
|
|
17
|
+
import { Checkbox } from "../Checkbox";
|
|
18
|
+
import { Input } from "../Input";
|
|
19
|
+
import { LucideByName } from "../Button/lucideName";
|
|
20
|
+
import type { DropdownMenuGroup, DropdownMenuItem, DropdownMenuProps } from "./DropdownMenu.types";
|
|
21
|
+
import styles from "./DropdownMenu.module.css";
|
|
22
|
+
|
|
23
|
+
export type {
|
|
24
|
+
DropdownMenuProps,
|
|
25
|
+
DropdownMenuGroup,
|
|
26
|
+
DropdownMenuItem,
|
|
27
|
+
DropdownMenuAlign,
|
|
28
|
+
DropdownMenuTriggerStyle,
|
|
29
|
+
} from "./DropdownMenu.types";
|
|
30
|
+
|
|
31
|
+
function flattenItems(groups: DropdownMenuGroup[]): DropdownMenuItem[] {
|
|
32
|
+
return groups.flatMap((group) => group.items);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function DropdownMenu({
|
|
36
|
+
trigger,
|
|
37
|
+
triggerStyle = "button",
|
|
38
|
+
iconStart,
|
|
39
|
+
iconEnd,
|
|
40
|
+
id,
|
|
41
|
+
disabled = false,
|
|
42
|
+
error = false,
|
|
43
|
+
describedBy,
|
|
44
|
+
ariaLabel,
|
|
45
|
+
variant = "secondary",
|
|
46
|
+
size = "md",
|
|
47
|
+
align = "start",
|
|
48
|
+
columns = 1,
|
|
49
|
+
groups,
|
|
50
|
+
open: openProp,
|
|
51
|
+
onOpenChange,
|
|
52
|
+
onSelect,
|
|
53
|
+
closeOnSelect = true,
|
|
54
|
+
triggerMuted = false,
|
|
55
|
+
triggerBadge,
|
|
56
|
+
searchable = false,
|
|
57
|
+
searchPlaceholder = "Search",
|
|
58
|
+
}: DropdownMenuProps) {
|
|
59
|
+
const isControlled = typeof openProp === "boolean";
|
|
60
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(false);
|
|
61
|
+
const open = isControlled ? openProp : uncontrolledOpen;
|
|
62
|
+
const uid = useId();
|
|
63
|
+
const menuId = `${uid}-menu`;
|
|
64
|
+
const rootRef = useRef<HTMLDivElement>(null);
|
|
65
|
+
const panelRef = useRef<HTMLDivElement>(null);
|
|
66
|
+
const subPanelRef = useRef<HTMLDivElement>(null);
|
|
67
|
+
const [highlightId, setHighlightId] = useState<string | null>(null);
|
|
68
|
+
const [openSubId, setOpenSubId] = useState<string | null>(null);
|
|
69
|
+
const [coords, setCoords] = useState<CSSProperties | null>(null);
|
|
70
|
+
const [subCoords, setSubCoords] = useState<CSSProperties | null>(null);
|
|
71
|
+
const [mounted, setMounted] = useState(false);
|
|
72
|
+
const [query, setQuery] = useState("");
|
|
73
|
+
const searchId = `${uid}-search`;
|
|
74
|
+
|
|
75
|
+
const visibleGroups = useMemo(() => {
|
|
76
|
+
const q = query.trim().toLowerCase();
|
|
77
|
+
if (!q) return groups;
|
|
78
|
+
return groups
|
|
79
|
+
.map((group) => ({
|
|
80
|
+
...group,
|
|
81
|
+
items: group.items.filter((item) => item.label.toLowerCase().includes(q)),
|
|
82
|
+
}))
|
|
83
|
+
.filter((group) => group.items.length > 0);
|
|
84
|
+
}, [groups, query]);
|
|
85
|
+
|
|
86
|
+
const mainItems = useMemo(() => flattenItems(visibleGroups), [visibleGroups]);
|
|
87
|
+
const enabledIds = useMemo(
|
|
88
|
+
() => mainItems.filter((item) => !item.disabled).map((item) => item.id),
|
|
89
|
+
[mainItems],
|
|
90
|
+
);
|
|
91
|
+
const activeId =
|
|
92
|
+
highlightId && enabledIds.includes(highlightId) ? highlightId : (enabledIds[0] ?? null);
|
|
93
|
+
const activeItem = mainItems.find((item) => item.id === activeId) ?? null;
|
|
94
|
+
const subGroups = mainItems.find((item) => item.id === openSubId)?.submenu;
|
|
95
|
+
const subItems = subGroups ? flattenItems(subGroups) : [];
|
|
96
|
+
const subEnabledIds = subItems.filter((item) => !item.disabled).map((item) => item.id);
|
|
97
|
+
|
|
98
|
+
function setOpen(next: boolean) {
|
|
99
|
+
if (!isControlled) setUncontrolledOpen(next);
|
|
100
|
+
onOpenChange?.(next);
|
|
101
|
+
if (!next) {
|
|
102
|
+
setHighlightId(null);
|
|
103
|
+
setOpenSubId(null);
|
|
104
|
+
setQuery("");
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function triggerButton(): HTMLButtonElement | null {
|
|
109
|
+
return rootRef.current?.querySelector("button") ?? null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function queryItem(root: HTMLElement | null, id: string): HTMLElement | null {
|
|
113
|
+
const escaped = typeof CSS !== "undefined" && CSS.escape ? CSS.escape(id) : id;
|
|
114
|
+
return root?.querySelector<HTMLElement>(`[data-id="${escaped}"]`) ?? null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function placePanel() {
|
|
118
|
+
const button = triggerButton();
|
|
119
|
+
if (!button) return;
|
|
120
|
+
const rect = button.getBoundingClientRect();
|
|
121
|
+
const next: CSSProperties = {
|
|
122
|
+
top: rect.bottom + 4,
|
|
123
|
+
};
|
|
124
|
+
if (columns === 2) {
|
|
125
|
+
next.minWidth = "28rem";
|
|
126
|
+
} else if (triggerStyle === "field") {
|
|
127
|
+
next.minWidth = rect.width;
|
|
128
|
+
} else {
|
|
129
|
+
next.minWidth = Math.max(216, rect.width);
|
|
130
|
+
}
|
|
131
|
+
if (align === "end") {
|
|
132
|
+
next.right = window.innerWidth - rect.right;
|
|
133
|
+
next.left = "auto";
|
|
134
|
+
} else {
|
|
135
|
+
next.left = rect.left;
|
|
136
|
+
next.right = "auto";
|
|
137
|
+
}
|
|
138
|
+
setCoords(next);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function placeSubPanel(id: string) {
|
|
142
|
+
const el = queryItem(panelRef.current, id);
|
|
143
|
+
if (!el) return;
|
|
144
|
+
const rect = el.getBoundingClientRect();
|
|
145
|
+
const next: CSSProperties = { top: rect.top, minWidth: 160 };
|
|
146
|
+
if (window.innerWidth - rect.right < 168) {
|
|
147
|
+
next.right = window.innerWidth - rect.left + 4;
|
|
148
|
+
next.left = "auto";
|
|
149
|
+
} else {
|
|
150
|
+
next.left = rect.right + 4;
|
|
151
|
+
next.right = "auto";
|
|
152
|
+
}
|
|
153
|
+
setSubCoords(next);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
useEffect(() => {
|
|
157
|
+
setMounted(true);
|
|
158
|
+
}, []);
|
|
159
|
+
|
|
160
|
+
useLayoutEffect(() => {
|
|
161
|
+
const button = triggerButton();
|
|
162
|
+
if (!button) return;
|
|
163
|
+
button.setAttribute("aria-haspopup", "menu");
|
|
164
|
+
button.setAttribute("aria-expanded", open ? "true" : "false");
|
|
165
|
+
button.setAttribute("aria-controls", menuId);
|
|
166
|
+
}, [open, menuId]);
|
|
167
|
+
|
|
168
|
+
useLayoutEffect(() => {
|
|
169
|
+
if (!open) {
|
|
170
|
+
setCoords(null);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
placePanel();
|
|
174
|
+
}, [open, align, size, triggerStyle, columns]);
|
|
175
|
+
|
|
176
|
+
useLayoutEffect(() => {
|
|
177
|
+
if (!open || !openSubId) {
|
|
178
|
+
setSubCoords(null);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
placeSubPanel(openSubId);
|
|
182
|
+
}, [open, openSubId, coords]);
|
|
183
|
+
|
|
184
|
+
useEffect(() => {
|
|
185
|
+
if (!open) return undefined;
|
|
186
|
+
|
|
187
|
+
function onPointerDown(event: PointerEvent) {
|
|
188
|
+
const target = event.target as Node;
|
|
189
|
+
if (
|
|
190
|
+
rootRef.current?.contains(target) ||
|
|
191
|
+
panelRef.current?.contains(target) ||
|
|
192
|
+
subPanelRef.current?.contains(target)
|
|
193
|
+
) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
setOpen(false);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function onDocumentKey(event: globalThis.KeyboardEvent) {
|
|
200
|
+
if (event.key === "Escape") {
|
|
201
|
+
event.preventDefault();
|
|
202
|
+
if (openSubId) {
|
|
203
|
+
setOpenSubId(null);
|
|
204
|
+
if (activeId) queryItem(panelRef.current, activeId)?.focus();
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
setOpen(false);
|
|
208
|
+
triggerButton()?.focus();
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function onReposition() {
|
|
213
|
+
placePanel();
|
|
214
|
+
if (openSubId) placeSubPanel(openSubId);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
document.addEventListener("pointerdown", onPointerDown);
|
|
218
|
+
document.addEventListener("keydown", onDocumentKey);
|
|
219
|
+
window.addEventListener("resize", onReposition);
|
|
220
|
+
window.addEventListener("scroll", onReposition, true);
|
|
221
|
+
return () => {
|
|
222
|
+
document.removeEventListener("pointerdown", onPointerDown);
|
|
223
|
+
document.removeEventListener("keydown", onDocumentKey);
|
|
224
|
+
window.removeEventListener("resize", onReposition);
|
|
225
|
+
window.removeEventListener("scroll", onReposition, true);
|
|
226
|
+
};
|
|
227
|
+
}, [open, align, size, columns, openSubId, activeId]);
|
|
228
|
+
|
|
229
|
+
useEffect(() => {
|
|
230
|
+
if (!open || !mounted) return;
|
|
231
|
+
if (searchable) {
|
|
232
|
+
panelRef.current?.querySelector<HTMLInputElement>("input")?.focus();
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const item = panelRef.current?.querySelector<HTMLElement>("[role='menuitem'][data-enabled='true'], [role='menuitemcheckbox'][data-enabled='true']");
|
|
236
|
+
item?.focus();
|
|
237
|
+
}, [open, mounted, coords, searchable]);
|
|
238
|
+
|
|
239
|
+
function findItem(id: string): DropdownMenuItem | undefined {
|
|
240
|
+
return mainItems.find((item) => item.id === id) ?? subItems.find((item) => item.id === id);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function select(id: string) {
|
|
244
|
+
const item = findItem(id);
|
|
245
|
+
if (!item || item.disabled || item.submenu) return;
|
|
246
|
+
onSelect?.(id);
|
|
247
|
+
if (!closeOnSelect) return;
|
|
248
|
+
setOpen(false);
|
|
249
|
+
triggerButton()?.focus();
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function highlight(id: string) {
|
|
253
|
+
const item = mainItems.find((entry) => entry.id === id);
|
|
254
|
+
if (!item || item.disabled) return;
|
|
255
|
+
setHighlightId(id);
|
|
256
|
+
setOpenSubId(item.submenu ? id : null);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function move(delta: number) {
|
|
260
|
+
if (enabledIds.length === 0) return;
|
|
261
|
+
const current = activeId ? enabledIds.indexOf(activeId) : -1;
|
|
262
|
+
const next = (current + delta + enabledIds.length) % enabledIds.length;
|
|
263
|
+
highlight(enabledIds[next]);
|
|
264
|
+
queryItem(panelRef.current, enabledIds[next])?.focus();
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function onMenuKeyDown(event: ReactKeyboardEvent<HTMLDivElement>) {
|
|
268
|
+
const inSearch = event.target instanceof HTMLInputElement;
|
|
269
|
+
if (inSearch) {
|
|
270
|
+
if (event.key === "ArrowDown") {
|
|
271
|
+
event.preventDefault();
|
|
272
|
+
if (enabledIds[0]) {
|
|
273
|
+
highlight(enabledIds[0]);
|
|
274
|
+
queryItem(panelRef.current, enabledIds[0])?.focus();
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
if (event.key === "Tab") setOpen(false);
|
|
278
|
+
if (event.key === "Enter") event.preventDefault();
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
switch (event.key) {
|
|
282
|
+
case "ArrowDown":
|
|
283
|
+
event.preventDefault();
|
|
284
|
+
move(1);
|
|
285
|
+
break;
|
|
286
|
+
case "ArrowUp":
|
|
287
|
+
event.preventDefault();
|
|
288
|
+
move(-1);
|
|
289
|
+
break;
|
|
290
|
+
case "ArrowRight":
|
|
291
|
+
if (activeItem?.submenu) {
|
|
292
|
+
event.preventDefault();
|
|
293
|
+
setOpenSubId(activeItem.id);
|
|
294
|
+
const first = flattenItems(activeItem.submenu).find((item) => !item.disabled);
|
|
295
|
+
if (first) {
|
|
296
|
+
requestAnimationFrame(() => queryItem(subPanelRef.current, first.id)?.focus());
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
break;
|
|
300
|
+
case "Home":
|
|
301
|
+
event.preventDefault();
|
|
302
|
+
if (enabledIds[0]) {
|
|
303
|
+
highlight(enabledIds[0]);
|
|
304
|
+
queryItem(panelRef.current, enabledIds[0])?.focus();
|
|
305
|
+
}
|
|
306
|
+
break;
|
|
307
|
+
case "End":
|
|
308
|
+
event.preventDefault();
|
|
309
|
+
if (enabledIds[enabledIds.length - 1]) {
|
|
310
|
+
const last = enabledIds[enabledIds.length - 1];
|
|
311
|
+
highlight(last);
|
|
312
|
+
queryItem(panelRef.current, last)?.focus();
|
|
313
|
+
}
|
|
314
|
+
break;
|
|
315
|
+
case "Tab":
|
|
316
|
+
setOpen(false);
|
|
317
|
+
break;
|
|
318
|
+
default:
|
|
319
|
+
break;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function onSubKeyDown(event: ReactKeyboardEvent<HTMLDivElement>) {
|
|
324
|
+
const current = document.activeElement instanceof HTMLElement ? document.activeElement.dataset.id : null;
|
|
325
|
+
const index = current ? subEnabledIds.indexOf(current) : -1;
|
|
326
|
+
switch (event.key) {
|
|
327
|
+
case "ArrowDown": {
|
|
328
|
+
event.preventDefault();
|
|
329
|
+
if (subEnabledIds.length === 0) return;
|
|
330
|
+
const next = (index + 1 + subEnabledIds.length) % subEnabledIds.length;
|
|
331
|
+
queryItem(subPanelRef.current, subEnabledIds[next])?.focus();
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
case "ArrowUp": {
|
|
335
|
+
event.preventDefault();
|
|
336
|
+
if (subEnabledIds.length === 0) return;
|
|
337
|
+
const next = (index - 1 + subEnabledIds.length) % subEnabledIds.length;
|
|
338
|
+
queryItem(subPanelRef.current, subEnabledIds[next])?.focus();
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
case "ArrowLeft":
|
|
342
|
+
event.preventDefault();
|
|
343
|
+
setOpenSubId(null);
|
|
344
|
+
if (openSubId) queryItem(panelRef.current, openSubId)?.focus();
|
|
345
|
+
break;
|
|
346
|
+
case "Escape":
|
|
347
|
+
event.preventDefault();
|
|
348
|
+
setOpenSubId(null);
|
|
349
|
+
if (openSubId) queryItem(panelRef.current, openSubId)?.focus();
|
|
350
|
+
break;
|
|
351
|
+
case "Tab":
|
|
352
|
+
setOpen(false);
|
|
353
|
+
break;
|
|
354
|
+
default:
|
|
355
|
+
break;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function renderItems(list: DropdownMenuGroup[], inSubmenu: boolean): ReactNode {
|
|
360
|
+
return list.map((group, groupIndex) => (
|
|
361
|
+
<div
|
|
362
|
+
key={group.heading ?? `group-${groupIndex}`}
|
|
363
|
+
className={styles.group}
|
|
364
|
+
role="group"
|
|
365
|
+
aria-label={group.heading}
|
|
366
|
+
>
|
|
367
|
+
{group.heading ? <div className={styles.heading}>{group.heading}</div> : null}
|
|
368
|
+
{group.items.map((item) => {
|
|
369
|
+
const highlighted = !inSubmenu && item.id === activeId;
|
|
370
|
+
const hasSub = Boolean(item.submenu && item.submenu.length > 0);
|
|
371
|
+
const asLink = Boolean(item.href) && !item.disabled && !hasSub;
|
|
372
|
+
const className = [
|
|
373
|
+
styles.item,
|
|
374
|
+
highlighted || openSubId === item.id ? styles.itemHighlighted : "",
|
|
375
|
+
item.disabled ? styles.itemDisabled : "",
|
|
376
|
+
item.danger ? styles.itemDanger : "",
|
|
377
|
+
item.description ? styles.itemWithDescription : "",
|
|
378
|
+
]
|
|
379
|
+
.filter(Boolean)
|
|
380
|
+
.join(" ");
|
|
381
|
+
const showCheck = typeof item.selected === "boolean" && !item.checkbox;
|
|
382
|
+
const body = (
|
|
383
|
+
<>
|
|
384
|
+
{item.checkbox ? (
|
|
385
|
+
<span className={styles.itemCheckbox} inert aria-hidden>
|
|
386
|
+
<Checkbox
|
|
387
|
+
id={`${uid}-cb-${item.id}`}
|
|
388
|
+
size="sm"
|
|
389
|
+
checked={Boolean(item.selected)}
|
|
390
|
+
ariaLabel={item.label}
|
|
391
|
+
onChange={() => {}}
|
|
392
|
+
/>
|
|
393
|
+
</span>
|
|
394
|
+
) : showCheck ? (
|
|
395
|
+
item.selected ? (
|
|
396
|
+
<LucideByName name="Check" size={16} className={styles.itemCheck} />
|
|
397
|
+
) : (
|
|
398
|
+
<span className={styles.itemCheck} />
|
|
399
|
+
)
|
|
400
|
+
) : item.icon ? (
|
|
401
|
+
<LucideByName name={item.icon} size={16} className={styles.itemIcon} />
|
|
402
|
+
) : null}
|
|
403
|
+
<span className={styles.itemText}>
|
|
404
|
+
<span className={styles.itemLabel}>{item.label}</span>
|
|
405
|
+
{item.description ? (
|
|
406
|
+
<span className={styles.itemDescription}>{item.description}</span>
|
|
407
|
+
) : null}
|
|
408
|
+
</span>
|
|
409
|
+
{item.shortcut ? <span className={styles.shortcut}>{item.shortcut}</span> : null}
|
|
410
|
+
{hasSub ? <LucideByName name="ChevronRight" size={16} className={styles.itemChevron} /> : null}
|
|
411
|
+
</>
|
|
412
|
+
);
|
|
413
|
+
const shared = {
|
|
414
|
+
className,
|
|
415
|
+
role: (item.checkbox ? "menuitemcheckbox" : "menuitem") as "menuitem" | "menuitemcheckbox",
|
|
416
|
+
"data-id": item.id,
|
|
417
|
+
"data-enabled": item.disabled ? "false" : "true",
|
|
418
|
+
"aria-checked": item.checkbox ? Boolean(item.selected) : undefined,
|
|
419
|
+
"aria-disabled": item.disabled || undefined,
|
|
420
|
+
"aria-haspopup": hasSub ? ("menu" as const) : undefined,
|
|
421
|
+
"aria-expanded": hasSub ? openSubId === item.id : undefined,
|
|
422
|
+
tabIndex: highlighted ? 0 : -1,
|
|
423
|
+
onMouseEnter: () => {
|
|
424
|
+
if (item.disabled) return;
|
|
425
|
+
if (inSubmenu) return;
|
|
426
|
+
highlight(item.id);
|
|
427
|
+
},
|
|
428
|
+
onClick: () => {
|
|
429
|
+
if (hasSub) {
|
|
430
|
+
setOpenSubId(item.id);
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
select(item.id);
|
|
434
|
+
},
|
|
435
|
+
};
|
|
436
|
+
if (asLink) {
|
|
437
|
+
return (
|
|
438
|
+
<a key={item.id} href={item.href} {...shared}>
|
|
439
|
+
{body}
|
|
440
|
+
</a>
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
return (
|
|
444
|
+
<button key={item.id} type="button" {...shared}>
|
|
445
|
+
{body}
|
|
446
|
+
</button>
|
|
447
|
+
);
|
|
448
|
+
})}
|
|
449
|
+
</div>
|
|
450
|
+
));
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
const hasLabel = Boolean(trigger && trigger.trim());
|
|
454
|
+
|
|
455
|
+
const panelClass = [
|
|
456
|
+
styles.panel,
|
|
457
|
+
columns === 2 ? styles.panelColumns : "",
|
|
458
|
+
searchable ? styles.panelSearchable : "",
|
|
459
|
+
]
|
|
460
|
+
.filter(Boolean)
|
|
461
|
+
.join(" ");
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
const panel =
|
|
465
|
+
open && mounted && coords
|
|
466
|
+
? createPortal(
|
|
467
|
+
<div
|
|
468
|
+
ref={panelRef}
|
|
469
|
+
id={menuId}
|
|
470
|
+
role="menu"
|
|
471
|
+
aria-label={ariaLabel || trigger || "Menu"}
|
|
472
|
+
className={panelClass}
|
|
473
|
+
style={coords}
|
|
474
|
+
onKeyDown={onMenuKeyDown}
|
|
475
|
+
>
|
|
476
|
+
{searchable ? (
|
|
477
|
+
<div className={styles.search}>
|
|
478
|
+
<Input
|
|
479
|
+
id={searchId}
|
|
480
|
+
size="sm"
|
|
481
|
+
type="search"
|
|
482
|
+
iconStart="Search"
|
|
483
|
+
placeholder={searchPlaceholder}
|
|
484
|
+
value={query}
|
|
485
|
+
onChange={setQuery}
|
|
486
|
+
ariaLabel="Search options"
|
|
487
|
+
/>
|
|
488
|
+
</div>
|
|
489
|
+
) : null}
|
|
490
|
+
{visibleGroups.length === 0 ? (
|
|
491
|
+
<div className={styles.empty}>No results.</div>
|
|
492
|
+
) : (
|
|
493
|
+
renderItems(visibleGroups, false)
|
|
494
|
+
)}
|
|
495
|
+
</div>,
|
|
496
|
+
document.body,
|
|
497
|
+
)
|
|
498
|
+
: null;
|
|
499
|
+
|
|
500
|
+
const subPanel =
|
|
501
|
+
open && mounted && openSubId && subGroups && subCoords
|
|
502
|
+
? createPortal(
|
|
503
|
+
<div
|
|
504
|
+
ref={subPanelRef}
|
|
505
|
+
role="menu"
|
|
506
|
+
aria-label={mainItems.find((item) => item.id === openSubId)?.label || "Submenu"}
|
|
507
|
+
className={styles.panel}
|
|
508
|
+
style={subCoords}
|
|
509
|
+
onKeyDown={onSubKeyDown}
|
|
510
|
+
onMouseEnter={() => setOpenSubId(openSubId)}
|
|
511
|
+
>
|
|
512
|
+
{renderItems(subGroups, true)}
|
|
513
|
+
</div>,
|
|
514
|
+
document.body,
|
|
515
|
+
)
|
|
516
|
+
: null;
|
|
517
|
+
|
|
518
|
+
const fieldTrigger = triggerStyle === "field";
|
|
519
|
+
const navTrigger = triggerStyle === "nav";
|
|
520
|
+
const iconPx = size === "sm" ? 14 : size === "lg" ? 18 : 16;
|
|
521
|
+
|
|
522
|
+
return (
|
|
523
|
+
<div ref={rootRef} className={`${styles.root}${fieldTrigger ? ` ${styles.rootField}` : ""}`}>
|
|
524
|
+
{fieldTrigger ? (
|
|
525
|
+
<button
|
|
526
|
+
type="button"
|
|
527
|
+
id={id}
|
|
528
|
+
disabled={disabled}
|
|
529
|
+
aria-label={ariaLabel}
|
|
530
|
+
aria-invalid={error || undefined}
|
|
531
|
+
aria-describedby={describedBy}
|
|
532
|
+
className={`${styles.fieldTrigger} ${styles[`field${size}`]}${error ? ` ${styles.fieldError}` : ""}${triggerMuted ? ` ${styles.fieldMuted}` : ""}`}
|
|
533
|
+
onClick={() => {
|
|
534
|
+
if (!disabled) setOpen(!open);
|
|
535
|
+
}}
|
|
536
|
+
>
|
|
537
|
+
<span className={styles.fieldMain}>
|
|
538
|
+
<span className={styles.fieldLabel}>{trigger || "Select"}</span>
|
|
539
|
+
{triggerBadge ? (
|
|
540
|
+
<Badge size="sm" tone="neutral">
|
|
541
|
+
{triggerBadge}
|
|
542
|
+
</Badge>
|
|
543
|
+
) : null}
|
|
544
|
+
</span>
|
|
545
|
+
<LucideByName name={iconEnd || "ChevronsUpDown"} size={iconPx} className={styles.fieldIcon} />
|
|
546
|
+
</button>
|
|
547
|
+
) : navTrigger ? (
|
|
548
|
+
<button
|
|
549
|
+
type="button"
|
|
550
|
+
id={id}
|
|
551
|
+
disabled={disabled}
|
|
552
|
+
aria-label={ariaLabel}
|
|
553
|
+
aria-haspopup="menu"
|
|
554
|
+
aria-expanded={open}
|
|
555
|
+
aria-controls={menuId}
|
|
556
|
+
className={`${styles.navTrigger}${open ? ` ${styles.navOpen}` : ""}`}
|
|
557
|
+
onClick={() => {
|
|
558
|
+
if (!disabled) setOpen(!open);
|
|
559
|
+
}}
|
|
560
|
+
>
|
|
561
|
+
{hasLabel ? trigger : null}
|
|
562
|
+
<LucideByName name="ChevronDown" size={14} className={styles.navChevron} />
|
|
563
|
+
</button>
|
|
564
|
+
) : (
|
|
565
|
+
<Button
|
|
566
|
+
variant={variant}
|
|
567
|
+
size={size}
|
|
568
|
+
iconStart={iconStart}
|
|
569
|
+
iconEnd={iconEnd}
|
|
570
|
+
ariaLabel={hasLabel ? undefined : ariaLabel}
|
|
571
|
+
onClick={() => setOpen(!open)}
|
|
572
|
+
>
|
|
573
|
+
{hasLabel ? trigger : undefined}
|
|
574
|
+
</Button>
|
|
575
|
+
)}
|
|
576
|
+
{panel}
|
|
577
|
+
{subPanel}
|
|
578
|
+
</div>
|
|
579
|
+
);
|
|
580
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ButtonSize, ButtonVariant } from "../Button/Button.types";
|
|
2
|
+
|
|
3
|
+
export type DropdownMenuAlign = "start" | "end";
|
|
4
|
+
export type DropdownMenuTriggerStyle = "button" | "field" | "nav";
|
|
5
|
+
|
|
6
|
+
export interface DropdownMenuItem {
|
|
7
|
+
id: string;
|
|
8
|
+
label: string;
|
|
9
|
+
icon?: string;
|
|
10
|
+
shortcut?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
danger?: boolean;
|
|
13
|
+
description?: string;
|
|
14
|
+
href?: string;
|
|
15
|
+
selected?: boolean;
|
|
16
|
+
checkbox?: boolean;
|
|
17
|
+
submenu?: DropdownMenuGroup[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface DropdownMenuGroup {
|
|
21
|
+
heading?: string;
|
|
22
|
+
items: DropdownMenuItem[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface DropdownMenuProps {
|
|
26
|
+
trigger?: string;
|
|
27
|
+
triggerStyle?: DropdownMenuTriggerStyle;
|
|
28
|
+
iconStart?: string;
|
|
29
|
+
iconEnd?: string;
|
|
30
|
+
id?: string;
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
error?: boolean;
|
|
33
|
+
describedBy?: string;
|
|
34
|
+
ariaLabel?: string;
|
|
35
|
+
variant?: ButtonVariant;
|
|
36
|
+
size?: ButtonSize;
|
|
37
|
+
align?: DropdownMenuAlign;
|
|
38
|
+
columns?: 1 | 2;
|
|
39
|
+
groups: DropdownMenuGroup[];
|
|
40
|
+
open?: boolean;
|
|
41
|
+
onOpenChange?: (open: boolean) => void;
|
|
42
|
+
onSelect?: (id: string) => void;
|
|
43
|
+
closeOnSelect?: boolean;
|
|
44
|
+
triggerMuted?: boolean;
|
|
45
|
+
triggerBadge?: string;
|
|
46
|
+
searchable?: boolean;
|
|
47
|
+
searchPlaceholder?: string;
|
|
48
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
display: grid;
|
|
3
|
+
justify-items: center;
|
|
4
|
+
gap: var(--space-4);
|
|
5
|
+
width: 100%;
|
|
6
|
+
padding: var(--space-6);
|
|
7
|
+
text-align: center;
|
|
8
|
+
min-width: 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.outlined {
|
|
12
|
+
border: var(--border-100) solid var(--border-faint);
|
|
13
|
+
border-radius: var(--radius-surface-sm);
|
|
14
|
+
background: var(--surface-card);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.mediaSlot {
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
justify-content: center;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.mediaWell {
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
width: 3rem;
|
|
28
|
+
height: 3rem;
|
|
29
|
+
border-radius: var(--radius-full);
|
|
30
|
+
background: var(--surface-muted);
|
|
31
|
+
color: var(--icon-secondary);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.mediaWell svg {
|
|
35
|
+
display: block;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.copy {
|
|
39
|
+
display: grid;
|
|
40
|
+
gap: var(--space-2);
|
|
41
|
+
max-width: 24rem;
|
|
42
|
+
min-width: 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.title {
|
|
46
|
+
margin: 0;
|
|
47
|
+
font-family: var(--font-sans);
|
|
48
|
+
font-size: var(--type-size-heading);
|
|
49
|
+
font-weight: var(--type-weight-heading);
|
|
50
|
+
line-height: var(--type-line-body);
|
|
51
|
+
color: var(--text-primary);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.description {
|
|
55
|
+
margin: 0;
|
|
56
|
+
font-family: var(--font-sans);
|
|
57
|
+
font-size: var(--type-size-body-sm);
|
|
58
|
+
line-height: var(--type-line-body);
|
|
59
|
+
color: var(--text-secondary);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.actions {
|
|
63
|
+
display: flex;
|
|
64
|
+
flex-wrap: wrap;
|
|
65
|
+
align-items: center;
|
|
66
|
+
justify-content: center;
|
|
67
|
+
gap: var(--space-2);
|
|
68
|
+
}
|