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,59 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useId, useState } from "react";
|
|
4
|
+
import { ChevronsUpDown } from "lucide-react";
|
|
5
|
+
import type { CollapsibleProps } from "./Collapsible.types";
|
|
6
|
+
import styles from "./Collapsible.module.css";
|
|
7
|
+
|
|
8
|
+
export type { CollapsibleProps } from "./Collapsible.types";
|
|
9
|
+
|
|
10
|
+
export function Collapsible({
|
|
11
|
+
trigger,
|
|
12
|
+
children,
|
|
13
|
+
defaultOpen = false,
|
|
14
|
+
open: openProp,
|
|
15
|
+
onOpenChange,
|
|
16
|
+
}: CollapsibleProps) {
|
|
17
|
+
const isControlled = typeof openProp === "boolean";
|
|
18
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
|
|
19
|
+
const open = isControlled ? openProp : uncontrolledOpen;
|
|
20
|
+
const uid = useId();
|
|
21
|
+
const titleId = `${uid}-title`;
|
|
22
|
+
const buttonId = `${uid}-trigger`;
|
|
23
|
+
const panelId = `${uid}-panel`;
|
|
24
|
+
|
|
25
|
+
function setOpen(next: boolean) {
|
|
26
|
+
if (!isControlled) setUncontrolledOpen(next);
|
|
27
|
+
onOpenChange?.(next);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<div className={styles.root}>
|
|
32
|
+
<div className={styles.header}>
|
|
33
|
+
<p id={titleId} className={styles.title}>
|
|
34
|
+
{trigger}
|
|
35
|
+
</p>
|
|
36
|
+
<button
|
|
37
|
+
type="button"
|
|
38
|
+
id={buttonId}
|
|
39
|
+
className={styles.toggle}
|
|
40
|
+
aria-expanded={open}
|
|
41
|
+
aria-controls={panelId}
|
|
42
|
+
aria-label={`Toggle ${trigger}`}
|
|
43
|
+
onClick={() => setOpen(!open)}
|
|
44
|
+
>
|
|
45
|
+
<ChevronsUpDown size={16} strokeWidth={2} aria-hidden />
|
|
46
|
+
</button>
|
|
47
|
+
</div>
|
|
48
|
+
<div
|
|
49
|
+
id={panelId}
|
|
50
|
+
role="region"
|
|
51
|
+
aria-labelledby={titleId}
|
|
52
|
+
className={styles.panel}
|
|
53
|
+
hidden={!open}
|
|
54
|
+
>
|
|
55
|
+
<div className={styles.body}>{children}</div>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
width: 100%;
|
|
5
|
+
min-width: 0;
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
background-color: var(--surface-card);
|
|
8
|
+
border: var(--border-surface) solid var(--border-faint);
|
|
9
|
+
border-radius: var(--radius-surface-md);
|
|
10
|
+
box-shadow: var(--shadow-sm);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.search {
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
gap: var(--space-2);
|
|
17
|
+
padding: var(--space-2) var(--space-3);
|
|
18
|
+
border-bottom: var(--border-divider) solid var(--border-faint);
|
|
19
|
+
border-top-left-radius: var(--radius-surface-md);
|
|
20
|
+
border-top-right-radius: var(--radius-surface-md);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.search:focus-within {
|
|
24
|
+
outline: var(--border-focus-width) solid var(--focus-ring);
|
|
25
|
+
outline-offset: var(--space-inset-2xs);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.searchIcon {
|
|
29
|
+
flex-shrink: 0;
|
|
30
|
+
color: var(--icon-muted);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.input {
|
|
34
|
+
width: 100%;
|
|
35
|
+
min-width: 0;
|
|
36
|
+
margin: 0;
|
|
37
|
+
padding: 0;
|
|
38
|
+
border: 0;
|
|
39
|
+
background: transparent;
|
|
40
|
+
font-family: var(--font-sans);
|
|
41
|
+
font-size: var(--type-size-body-sm);
|
|
42
|
+
line-height: var(--type-line-body);
|
|
43
|
+
color: var(--text-primary);
|
|
44
|
+
appearance: none;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.input::placeholder {
|
|
48
|
+
color: var(--text-muted);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.input:focus {
|
|
52
|
+
outline: none;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.input::-webkit-search-decoration,
|
|
56
|
+
.input::-webkit-search-cancel-button,
|
|
57
|
+
.input::-webkit-search-results-button,
|
|
58
|
+
.input::-webkit-search-results-decoration {
|
|
59
|
+
appearance: none;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.list {
|
|
63
|
+
max-height: 18rem;
|
|
64
|
+
overflow-x: hidden;
|
|
65
|
+
overflow-y: auto;
|
|
66
|
+
padding: var(--space-1);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.group + .group {
|
|
70
|
+
margin-top: var(--space-1);
|
|
71
|
+
padding-top: var(--space-1);
|
|
72
|
+
border-top: var(--border-divider) solid var(--border-faint);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.heading {
|
|
76
|
+
padding: var(--space-2) var(--space-2) var(--space-1);
|
|
77
|
+
font-family: var(--font-sans);
|
|
78
|
+
font-size: var(--type-size-overline);
|
|
79
|
+
font-weight: var(--type-weight-overline);
|
|
80
|
+
letter-spacing: var(--type-tracking-overline);
|
|
81
|
+
color: var(--text-secondary);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.item {
|
|
85
|
+
display: flex;
|
|
86
|
+
align-items: center;
|
|
87
|
+
gap: var(--space-2);
|
|
88
|
+
width: 100%;
|
|
89
|
+
margin: 0;
|
|
90
|
+
padding: var(--space-2);
|
|
91
|
+
border: 0;
|
|
92
|
+
border-radius: var(--radius-control-sm);
|
|
93
|
+
background: transparent;
|
|
94
|
+
color: var(--text-primary);
|
|
95
|
+
font-family: var(--font-sans);
|
|
96
|
+
font-size: var(--type-size-body-sm);
|
|
97
|
+
line-height: var(--type-line-body);
|
|
98
|
+
text-align: left;
|
|
99
|
+
cursor: pointer;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.item:hover:not([aria-disabled="true"]),
|
|
103
|
+
.itemHighlighted {
|
|
104
|
+
background-color: var(--surface-muted);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.itemDisabled {
|
|
108
|
+
opacity: var(--opacity-disabled);
|
|
109
|
+
cursor: not-allowed;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.itemIcon {
|
|
113
|
+
flex-shrink: 0;
|
|
114
|
+
color: var(--icon-muted);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.itemLabel {
|
|
118
|
+
flex: 1;
|
|
119
|
+
min-width: 0;
|
|
120
|
+
overflow-wrap: anywhere;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.shortcut {
|
|
124
|
+
flex-shrink: 0;
|
|
125
|
+
font-family: var(--font-mono);
|
|
126
|
+
font-size: var(--type-size-caption);
|
|
127
|
+
font-weight: var(--type-weight-caption);
|
|
128
|
+
color: var(--text-muted);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.empty {
|
|
132
|
+
padding: var(--space-6) var(--space-4);
|
|
133
|
+
text-align: center;
|
|
134
|
+
font-family: var(--font-sans);
|
|
135
|
+
font-size: var(--type-size-body-sm);
|
|
136
|
+
line-height: var(--type-line-body);
|
|
137
|
+
color: var(--text-secondary);
|
|
138
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useId, useMemo, useState, type KeyboardEvent } from "react";
|
|
4
|
+
import { LucideByName } from "../Button/lucideName";
|
|
5
|
+
import type { CommandProps } from "./Command.types";
|
|
6
|
+
import styles from "./Command.module.css";
|
|
7
|
+
|
|
8
|
+
export type { CommandProps, CommandGroup, CommandItem } from "./Command.types";
|
|
9
|
+
|
|
10
|
+
const DEFAULT_PLACEHOLDER = "Type a command or search...";
|
|
11
|
+
const DEFAULT_EMPTY = "No results found.";
|
|
12
|
+
const DEFAULT_LABEL = "Command menu";
|
|
13
|
+
|
|
14
|
+
export function Command({
|
|
15
|
+
placeholder = DEFAULT_PLACEHOLDER,
|
|
16
|
+
empty = DEFAULT_EMPTY,
|
|
17
|
+
groups,
|
|
18
|
+
onSelect,
|
|
19
|
+
label = DEFAULT_LABEL,
|
|
20
|
+
}: CommandProps) {
|
|
21
|
+
const uid = useId();
|
|
22
|
+
const listboxId = `${uid}-list`;
|
|
23
|
+
const [query, setQuery] = useState("");
|
|
24
|
+
const [highlightId, setHighlightId] = useState<string | null>(null);
|
|
25
|
+
|
|
26
|
+
const visibleGroups = useMemo(() => {
|
|
27
|
+
const q = query.trim().toLowerCase();
|
|
28
|
+
return groups
|
|
29
|
+
.map((group) => ({
|
|
30
|
+
heading: group.heading,
|
|
31
|
+
items: q
|
|
32
|
+
? group.items.filter((item) => item.label.toLowerCase().includes(q))
|
|
33
|
+
: group.items,
|
|
34
|
+
}))
|
|
35
|
+
.filter((group) => group.items.length > 0);
|
|
36
|
+
}, [groups, query]);
|
|
37
|
+
|
|
38
|
+
const enabledIds = useMemo(
|
|
39
|
+
() =>
|
|
40
|
+
visibleGroups.flatMap((group) =>
|
|
41
|
+
group.items.filter((item) => !item.disabled).map((item) => item.id),
|
|
42
|
+
),
|
|
43
|
+
[visibleGroups],
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const activeId =
|
|
47
|
+
highlightId && enabledIds.includes(highlightId) ? highlightId : (enabledIds[0] ?? null);
|
|
48
|
+
|
|
49
|
+
function optionId(id: string) {
|
|
50
|
+
return `${uid}-opt-${id}`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function select(id: string) {
|
|
54
|
+
const item = visibleGroups.flatMap((group) => group.items).find((entry) => entry.id === id);
|
|
55
|
+
if (!item || item.disabled) return;
|
|
56
|
+
onSelect?.(id);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function move(delta: number) {
|
|
60
|
+
if (enabledIds.length === 0) return;
|
|
61
|
+
const current = activeId ? enabledIds.indexOf(activeId) : -1;
|
|
62
|
+
const next = (current + delta + enabledIds.length) % enabledIds.length;
|
|
63
|
+
setHighlightId(enabledIds[next]);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function onKeyDown(event: KeyboardEvent<HTMLInputElement>) {
|
|
67
|
+
switch (event.key) {
|
|
68
|
+
case "ArrowDown":
|
|
69
|
+
event.preventDefault();
|
|
70
|
+
move(1);
|
|
71
|
+
break;
|
|
72
|
+
case "ArrowUp":
|
|
73
|
+
event.preventDefault();
|
|
74
|
+
move(-1);
|
|
75
|
+
break;
|
|
76
|
+
case "Home":
|
|
77
|
+
event.preventDefault();
|
|
78
|
+
if (enabledIds[0]) setHighlightId(enabledIds[0]);
|
|
79
|
+
break;
|
|
80
|
+
case "End":
|
|
81
|
+
event.preventDefault();
|
|
82
|
+
if (enabledIds.length) setHighlightId(enabledIds[enabledIds.length - 1]);
|
|
83
|
+
break;
|
|
84
|
+
case "Enter":
|
|
85
|
+
event.preventDefault();
|
|
86
|
+
if (activeId) select(activeId);
|
|
87
|
+
break;
|
|
88
|
+
default:
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<div className={styles.root}>
|
|
95
|
+
<div className={styles.search}>
|
|
96
|
+
<LucideByName name="Search" size={16} className={styles.searchIcon} />
|
|
97
|
+
<input
|
|
98
|
+
type="search"
|
|
99
|
+
role="combobox"
|
|
100
|
+
className={styles.input}
|
|
101
|
+
placeholder={placeholder}
|
|
102
|
+
value={query}
|
|
103
|
+
autoComplete="off"
|
|
104
|
+
onChange={(event) => setQuery(event.target.value)}
|
|
105
|
+
onKeyDown={onKeyDown}
|
|
106
|
+
aria-expanded={true}
|
|
107
|
+
aria-controls={listboxId}
|
|
108
|
+
aria-activedescendant={activeId ? optionId(activeId) : undefined}
|
|
109
|
+
aria-autocomplete="list"
|
|
110
|
+
aria-label={label}
|
|
111
|
+
/>
|
|
112
|
+
</div>
|
|
113
|
+
<div id={listboxId} role="listbox" className={styles.list} aria-label={label}>
|
|
114
|
+
{visibleGroups.length === 0 ? (
|
|
115
|
+
<div className={styles.empty}>{empty}</div>
|
|
116
|
+
) : (
|
|
117
|
+
visibleGroups.map((group, index) => (
|
|
118
|
+
<div key={group.heading ?? `group-${index}`} className={styles.group}>
|
|
119
|
+
{group.heading ? <div className={styles.heading}>{group.heading}</div> : null}
|
|
120
|
+
{group.items.map((item) => {
|
|
121
|
+
const highlighted = item.id === activeId;
|
|
122
|
+
return (
|
|
123
|
+
<div
|
|
124
|
+
key={item.id}
|
|
125
|
+
id={optionId(item.id)}
|
|
126
|
+
role="option"
|
|
127
|
+
aria-selected={highlighted}
|
|
128
|
+
aria-disabled={item.disabled || undefined}
|
|
129
|
+
className={`${styles.item}${highlighted ? ` ${styles.itemHighlighted}` : ""}${
|
|
130
|
+
item.disabled ? ` ${styles.itemDisabled}` : ""
|
|
131
|
+
}`}
|
|
132
|
+
onMouseEnter={() => {
|
|
133
|
+
if (!item.disabled) setHighlightId(item.id);
|
|
134
|
+
}}
|
|
135
|
+
onMouseDown={(event) => event.preventDefault()}
|
|
136
|
+
onClick={() => {
|
|
137
|
+
if (!item.disabled) select(item.id);
|
|
138
|
+
}}
|
|
139
|
+
>
|
|
140
|
+
<LucideByName name={item.icon} size={16} className={styles.itemIcon} />
|
|
141
|
+
<span className={styles.itemLabel}>{item.label}</span>
|
|
142
|
+
{item.shortcut ? <span className={styles.shortcut}>{item.shortcut}</span> : null}
|
|
143
|
+
</div>
|
|
144
|
+
);
|
|
145
|
+
})}
|
|
146
|
+
</div>
|
|
147
|
+
))
|
|
148
|
+
)}
|
|
149
|
+
</div>
|
|
150
|
+
</div>
|
|
151
|
+
);
|
|
152
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface CommandItem {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
icon?: string;
|
|
5
|
+
shortcut?: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface CommandGroup {
|
|
10
|
+
heading?: string;
|
|
11
|
+
items: CommandItem[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface CommandProps {
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
empty?: string;
|
|
17
|
+
groups: CommandGroup[];
|
|
18
|
+
onSelect?: (id: string) => void;
|
|
19
|
+
label?: string;
|
|
20
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
width: 100%;
|
|
3
|
+
min-width: 0;
|
|
4
|
+
overflow: hidden;
|
|
5
|
+
background-color: var(--surface-card);
|
|
6
|
+
border: var(--border-surface) solid var(--border-faint);
|
|
7
|
+
border-radius: var(--radius-surface-md);
|
|
8
|
+
box-shadow: var(--shadow-sm);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.toolbar {
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-wrap: wrap;
|
|
14
|
+
align-items: center;
|
|
15
|
+
gap: var(--space-2);
|
|
16
|
+
padding: var(--space-3) var(--space-4);
|
|
17
|
+
border-bottom: var(--border-divider) solid var(--border-faint);
|
|
18
|
+
background: transparent;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.search {
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
gap: var(--space-2);
|
|
25
|
+
flex: 1 1 12rem;
|
|
26
|
+
min-width: 0;
|
|
27
|
+
max-width: 18rem;
|
|
28
|
+
padding: var(--space-2) var(--space-3);
|
|
29
|
+
border: var(--border-control) solid var(--border-faint);
|
|
30
|
+
border-radius: var(--radius-control-md);
|
|
31
|
+
background-color: var(--surface-card);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.search:focus-within {
|
|
35
|
+
border-color: var(--border-focus);
|
|
36
|
+
outline: var(--border-focus-width) solid var(--focus-ring);
|
|
37
|
+
outline-offset: var(--space-inset-2xs);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.searchIcon {
|
|
41
|
+
flex-shrink: 0;
|
|
42
|
+
color: var(--icon-muted);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.searchInput {
|
|
46
|
+
width: 100%;
|
|
47
|
+
min-width: 0;
|
|
48
|
+
margin: 0;
|
|
49
|
+
padding: 0;
|
|
50
|
+
border: 0;
|
|
51
|
+
background: transparent;
|
|
52
|
+
font-family: var(--font-sans);
|
|
53
|
+
font-size: var(--type-size-body-sm);
|
|
54
|
+
line-height: var(--type-line-body);
|
|
55
|
+
color: var(--text-primary);
|
|
56
|
+
appearance: none;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.searchInput::placeholder {
|
|
60
|
+
color: var(--text-muted);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.searchInput:focus {
|
|
64
|
+
outline: none;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.searchInput::-webkit-search-decoration,
|
|
68
|
+
.searchInput::-webkit-search-cancel-button,
|
|
69
|
+
.searchInput::-webkit-search-results-button,
|
|
70
|
+
.searchInput::-webkit-search-results-decoration {
|
|
71
|
+
appearance: none;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.filter {
|
|
75
|
+
position: relative;
|
|
76
|
+
display: inline-flex;
|
|
77
|
+
align-items: center;
|
|
78
|
+
min-width: 0;
|
|
79
|
+
flex-shrink: 0;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.columns {
|
|
83
|
+
position: relative;
|
|
84
|
+
margin-left: auto;
|
|
85
|
+
flex-shrink: 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.columnMenu {
|
|
89
|
+
position: absolute;
|
|
90
|
+
top: calc(100% + var(--space-1));
|
|
91
|
+
right: 0;
|
|
92
|
+
z-index: var(--z-overlay);
|
|
93
|
+
display: flex;
|
|
94
|
+
flex-direction: column;
|
|
95
|
+
gap: var(--space-2);
|
|
96
|
+
min-width: 10rem;
|
|
97
|
+
padding: var(--space-3);
|
|
98
|
+
background-color: var(--surface-elevated);
|
|
99
|
+
border: var(--border-surface) solid var(--border-faint);
|
|
100
|
+
border-radius: var(--radius-surface-sm);
|
|
101
|
+
box-shadow: var(--shadow-sm);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.count {
|
|
105
|
+
margin: 0;
|
|
106
|
+
padding: var(--space-2) var(--space-4);
|
|
107
|
+
border-bottom: var(--border-divider) solid var(--border-faint);
|
|
108
|
+
font-family: var(--font-sans);
|
|
109
|
+
font-size: var(--type-size-caption);
|
|
110
|
+
font-weight: var(--type-weight-caption);
|
|
111
|
+
line-height: var(--type-line-body);
|
|
112
|
+
color: var(--text-muted);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.scroller {
|
|
116
|
+
width: 100%;
|
|
117
|
+
min-width: 0;
|
|
118
|
+
overflow-x: auto;
|
|
119
|
+
background-color: var(--surface-card);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.table {
|
|
123
|
+
width: 100%;
|
|
124
|
+
border-collapse: collapse;
|
|
125
|
+
font-family: var(--font-sans);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.caption {
|
|
129
|
+
padding: var(--space-3) var(--space-4);
|
|
130
|
+
border-bottom: var(--border-divider) solid var(--border-faint);
|
|
131
|
+
background-color: var(--surface-card);
|
|
132
|
+
font-family: var(--font-sans);
|
|
133
|
+
font-size: var(--type-size-heading);
|
|
134
|
+
font-weight: var(--type-weight-heading);
|
|
135
|
+
line-height: var(--type-line-heading);
|
|
136
|
+
color: var(--text-primary);
|
|
137
|
+
text-align: left;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.th,
|
|
141
|
+
.td {
|
|
142
|
+
padding: 0;
|
|
143
|
+
font-size: var(--type-size-body-sm);
|
|
144
|
+
line-height: var(--type-line-body);
|
|
145
|
+
text-align: left;
|
|
146
|
+
vertical-align: middle;
|
|
147
|
+
border-bottom: var(--border-divider) solid var(--border-faint);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.th {
|
|
151
|
+
font-weight: var(--type-weight-label);
|
|
152
|
+
color: var(--text-secondary);
|
|
153
|
+
background-color: var(--surface-muted);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.td {
|
|
157
|
+
color: var(--text-primary);
|
|
158
|
+
background-color: var(--surface-card);
|
|
159
|
+
transition: background-color var(--motion-interaction-duration) var(--motion-interaction-easing);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.numeric {
|
|
163
|
+
width: 1%;
|
|
164
|
+
white-space: nowrap;
|
|
165
|
+
text-align: right;
|
|
166
|
+
font-variant-numeric: tabular-nums;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.actionCell {
|
|
170
|
+
width: 1%;
|
|
171
|
+
white-space: nowrap;
|
|
172
|
+
text-align: center;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.checkCell {
|
|
176
|
+
width: 1%;
|
|
177
|
+
padding-inline: var(--space-4);
|
|
178
|
+
text-align: center;
|
|
179
|
+
vertical-align: middle;
|
|
180
|
+
white-space: nowrap;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.root[data-size="md"] .checkCell {
|
|
184
|
+
padding-inline: var(--space-6);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.checkCell :global(label) {
|
|
188
|
+
display: inline-flex;
|
|
189
|
+
justify-content: center;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.tr:hover .td,
|
|
193
|
+
.tr[data-selected] .td {
|
|
194
|
+
background-color: var(--surface-muted);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.tr:last-child .td {
|
|
198
|
+
border-bottom: none;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.emptyCell {
|
|
202
|
+
padding: var(--space-8) var(--space-4);
|
|
203
|
+
text-align: center;
|
|
204
|
+
color: var(--text-secondary);
|
|
205
|
+
background-color: var(--surface-card);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.tr:hover .emptyCell,
|
|
209
|
+
.emptyCell:hover {
|
|
210
|
+
background-color: var(--surface-card);
|
|
211
|
+
}
|