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,152 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useCallback, useEffect, useMemo, useRef, useState, type KeyboardEvent } from "react";
|
|
4
|
+
import useEmblaCarousel from "embla-carousel-react";
|
|
5
|
+
import { Button } from "../Button";
|
|
6
|
+
import type { CarouselProps } from "./Carousel.types";
|
|
7
|
+
import styles from "./Carousel.module.css";
|
|
8
|
+
|
|
9
|
+
export type {
|
|
10
|
+
CarouselProps,
|
|
11
|
+
CarouselOrientation,
|
|
12
|
+
CarouselAlign,
|
|
13
|
+
CarouselSlidesPerView,
|
|
14
|
+
} from "./Carousel.types";
|
|
15
|
+
|
|
16
|
+
export function Carousel({
|
|
17
|
+
items,
|
|
18
|
+
orientation = "horizontal",
|
|
19
|
+
loop = false,
|
|
20
|
+
align = "start",
|
|
21
|
+
slidesPerView = 1,
|
|
22
|
+
showControls = true,
|
|
23
|
+
showIndex = false,
|
|
24
|
+
onIndexChange,
|
|
25
|
+
ariaLabel = "Carousel",
|
|
26
|
+
}: CarouselProps) {
|
|
27
|
+
const emblaOptions = useMemo(
|
|
28
|
+
() => ({
|
|
29
|
+
axis: (orientation === "vertical" ? "y" : "x") as "x" | "y",
|
|
30
|
+
loop,
|
|
31
|
+
align,
|
|
32
|
+
}),
|
|
33
|
+
[orientation, loop, align],
|
|
34
|
+
);
|
|
35
|
+
const [viewportRef, emblaApi] = useEmblaCarousel(emblaOptions);
|
|
36
|
+
|
|
37
|
+
const [canScrollPrev, setCanScrollPrev] = useState(false);
|
|
38
|
+
const [canScrollNext, setCanScrollNext] = useState(false);
|
|
39
|
+
const [index, setIndex] = useState(0);
|
|
40
|
+
const [snapCount, setSnapCount] = useState(Math.max(items.length, 1));
|
|
41
|
+
const onIndexChangeRef = useRef(onIndexChange);
|
|
42
|
+
onIndexChangeRef.current = onIndexChange;
|
|
43
|
+
|
|
44
|
+
const sync = useCallback(() => {
|
|
45
|
+
if (!emblaApi) return;
|
|
46
|
+
const nextIndex = emblaApi.selectedScrollSnap();
|
|
47
|
+
setCanScrollPrev(emblaApi.canScrollPrev());
|
|
48
|
+
setCanScrollNext(emblaApi.canScrollNext());
|
|
49
|
+
setIndex(nextIndex);
|
|
50
|
+
setSnapCount(emblaApi.scrollSnapList().length);
|
|
51
|
+
onIndexChangeRef.current?.(nextIndex);
|
|
52
|
+
}, [emblaApi]);
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (!emblaApi) return;
|
|
56
|
+
sync();
|
|
57
|
+
emblaApi.on("select", sync);
|
|
58
|
+
emblaApi.on("reInit", sync);
|
|
59
|
+
return () => {
|
|
60
|
+
emblaApi.off("select", sync);
|
|
61
|
+
emblaApi.off("reInit", sync);
|
|
62
|
+
};
|
|
63
|
+
}, [emblaApi, sync]);
|
|
64
|
+
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
emblaApi?.reInit();
|
|
67
|
+
}, [emblaApi, items.length, slidesPerView]);
|
|
68
|
+
|
|
69
|
+
function scrollPrev() {
|
|
70
|
+
emblaApi?.scrollPrev();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function scrollNext() {
|
|
74
|
+
emblaApi?.scrollNext();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function onKeyDown(event: KeyboardEvent<HTMLDivElement>) {
|
|
78
|
+
const prevKey = orientation === "vertical" ? "ArrowUp" : "ArrowLeft";
|
|
79
|
+
const nextKey = orientation === "vertical" ? "ArrowDown" : "ArrowRight";
|
|
80
|
+
if (event.key === prevKey) {
|
|
81
|
+
event.preventDefault();
|
|
82
|
+
scrollPrev();
|
|
83
|
+
} else if (event.key === nextKey) {
|
|
84
|
+
event.preventDefault();
|
|
85
|
+
scrollNext();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const count = snapCount || Math.max(items.length, 1);
|
|
90
|
+
const prevIcon = orientation === "vertical" ? "ChevronUp" : "ChevronLeft";
|
|
91
|
+
const nextIcon = orientation === "vertical" ? "ChevronDown" : "ChevronRight";
|
|
92
|
+
const perClass =
|
|
93
|
+
slidesPerView === 2 ? styles.per2 : slidesPerView === 3 ? styles.per3 : slidesPerView === 4 ? styles.per4 : "";
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<div
|
|
97
|
+
className={`${styles.root} ${styles[orientation]} ${perClass}`}
|
|
98
|
+
role="region"
|
|
99
|
+
aria-roledescription="carousel"
|
|
100
|
+
aria-label={ariaLabel}
|
|
101
|
+
tabIndex={0}
|
|
102
|
+
onKeyDown={onKeyDown}
|
|
103
|
+
>
|
|
104
|
+
<div className={styles.stage}>
|
|
105
|
+
<div className={styles.viewport} ref={viewportRef}>
|
|
106
|
+
<div className={styles.track}>
|
|
107
|
+
{items.map((item, i) => (
|
|
108
|
+
<div
|
|
109
|
+
key={i}
|
|
110
|
+
className={styles.slide}
|
|
111
|
+
role="group"
|
|
112
|
+
aria-roledescription="slide"
|
|
113
|
+
aria-label={`Slide ${i + 1} of ${items.length}`}
|
|
114
|
+
>
|
|
115
|
+
{item}
|
|
116
|
+
</div>
|
|
117
|
+
))}
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
{showControls ? (
|
|
121
|
+
<>
|
|
122
|
+
<div className={styles.prev}>
|
|
123
|
+
<Button
|
|
124
|
+
variant="secondary"
|
|
125
|
+
size="sm"
|
|
126
|
+
iconStart={prevIcon}
|
|
127
|
+
ariaLabel="Previous slide"
|
|
128
|
+
disabled={!canScrollPrev}
|
|
129
|
+
onClick={scrollPrev}
|
|
130
|
+
/>
|
|
131
|
+
</div>
|
|
132
|
+
<div className={styles.next}>
|
|
133
|
+
<Button
|
|
134
|
+
variant="secondary"
|
|
135
|
+
size="sm"
|
|
136
|
+
iconStart={nextIcon}
|
|
137
|
+
ariaLabel="Next slide"
|
|
138
|
+
disabled={!canScrollNext}
|
|
139
|
+
onClick={scrollNext}
|
|
140
|
+
/>
|
|
141
|
+
</div>
|
|
142
|
+
</>
|
|
143
|
+
) : null}
|
|
144
|
+
</div>
|
|
145
|
+
{showIndex ? (
|
|
146
|
+
<p className={styles.index} aria-live="polite">
|
|
147
|
+
{`Slide ${index + 1} of ${count}`}
|
|
148
|
+
</p>
|
|
149
|
+
) : null}
|
|
150
|
+
</div>
|
|
151
|
+
);
|
|
152
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
export type CarouselOrientation = "horizontal" | "vertical";
|
|
4
|
+
export type CarouselAlign = "start" | "center";
|
|
5
|
+
export type CarouselSlidesPerView = 1 | 2 | 3 | 4;
|
|
6
|
+
|
|
7
|
+
export interface CarouselProps {
|
|
8
|
+
items: ReactNode[];
|
|
9
|
+
orientation?: CarouselOrientation;
|
|
10
|
+
loop?: boolean;
|
|
11
|
+
align?: CarouselAlign;
|
|
12
|
+
slidesPerView?: CarouselSlidesPerView;
|
|
13
|
+
showControls?: boolean;
|
|
14
|
+
showIndex?: boolean;
|
|
15
|
+
onIndexChange?: (index: number) => void;
|
|
16
|
+
ariaLabel?: string;
|
|
17
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
.cell {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
min-width: 0;
|
|
6
|
+
max-width: 100%;
|
|
7
|
+
width: 100%;
|
|
8
|
+
background-color: transparent;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.sm {
|
|
12
|
+
min-height: 3rem;
|
|
13
|
+
padding: var(--space-2) var(--space-4);
|
|
14
|
+
gap: var(--space-3);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.md {
|
|
18
|
+
min-height: 3.5rem;
|
|
19
|
+
padding: var(--space-3) var(--space-6);
|
|
20
|
+
gap: var(--space-3);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.visual {
|
|
24
|
+
display: inline-flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
flex-shrink: 0;
|
|
27
|
+
min-width: 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.copy {
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-direction: column;
|
|
33
|
+
justify-content: center;
|
|
34
|
+
min-width: 0;
|
|
35
|
+
gap: 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.label {
|
|
39
|
+
min-width: 0;
|
|
40
|
+
font-family: var(--font-sans);
|
|
41
|
+
line-height: var(--type-line-body);
|
|
42
|
+
color: var(--text-primary);
|
|
43
|
+
overflow-wrap: anywhere;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.copy .label {
|
|
47
|
+
font-weight: var(--type-weight-label);
|
|
48
|
+
line-height: var(--type-line-heading);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.support {
|
|
52
|
+
min-width: 0;
|
|
53
|
+
font-family: var(--font-sans);
|
|
54
|
+
font-size: var(--type-size-caption);
|
|
55
|
+
font-weight: var(--type-weight-body);
|
|
56
|
+
line-height: var(--type-line-heading);
|
|
57
|
+
color: var(--text-secondary);
|
|
58
|
+
overflow-wrap: anywhere;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.sm .label,
|
|
62
|
+
.md .label {
|
|
63
|
+
font-size: var(--type-size-body-sm);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.icon {
|
|
67
|
+
flex-shrink: 0;
|
|
68
|
+
color: var(--icon-muted);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.trend {
|
|
72
|
+
display: inline-flex;
|
|
73
|
+
align-items: center;
|
|
74
|
+
gap: var(--space-2);
|
|
75
|
+
min-width: 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.trendPositive {
|
|
79
|
+
color: var(--status-success);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.trendNegative {
|
|
83
|
+
color: var(--status-danger);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.trend .label {
|
|
87
|
+
color: inherit;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.badges {
|
|
91
|
+
display: inline-flex;
|
|
92
|
+
flex-wrap: wrap;
|
|
93
|
+
align-items: center;
|
|
94
|
+
gap: var(--space-1);
|
|
95
|
+
min-width: 0;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.selectWrap {
|
|
99
|
+
display: block;
|
|
100
|
+
width: 10rem;
|
|
101
|
+
max-width: 100%;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.progressWrap {
|
|
105
|
+
display: block;
|
|
106
|
+
width: 8rem;
|
|
107
|
+
max-width: 100%;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.rating {
|
|
111
|
+
display: inline-flex;
|
|
112
|
+
align-items: center;
|
|
113
|
+
gap: var(--space-1);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.starOn {
|
|
117
|
+
color: var(--icon-warning);
|
|
118
|
+
fill: currentColor;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.starOff {
|
|
122
|
+
color: var(--icon-muted);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.actionIcons {
|
|
126
|
+
display: inline-flex;
|
|
127
|
+
align-items: center;
|
|
128
|
+
gap: var(--space-1);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.actionMenu {
|
|
132
|
+
justify-content: center;
|
|
133
|
+
}
|
package/ui/Cell/Cell.tsx
ADDED
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useId, type ReactNode } from "react";
|
|
4
|
+
import { Avatar } from "../Avatar";
|
|
5
|
+
import { AvatarGroup } from "../AvatarGroup";
|
|
6
|
+
import { Badge } from "../Badge";
|
|
7
|
+
import { Button } from "../Button";
|
|
8
|
+
import { DropdownMenu } from "../DropdownMenu";
|
|
9
|
+
import { Progress } from "../Progress";
|
|
10
|
+
import { ButtonGroup } from "../ButtonGroup";
|
|
11
|
+
import { Checkbox } from "../Checkbox";
|
|
12
|
+
import { Select } from "../Select";
|
|
13
|
+
import { LucideByName } from "../Button/lucideName";
|
|
14
|
+
import type { CellProps, CellType } from "./Cell.types";
|
|
15
|
+
import styles from "./Cell.module.css";
|
|
16
|
+
|
|
17
|
+
export type {
|
|
18
|
+
CellProps,
|
|
19
|
+
CellValue,
|
|
20
|
+
CellType,
|
|
21
|
+
CellSize,
|
|
22
|
+
CellPerson,
|
|
23
|
+
CellBadgeItem,
|
|
24
|
+
CellOption,
|
|
25
|
+
CellAction,
|
|
26
|
+
} from "./Cell.types";
|
|
27
|
+
|
|
28
|
+
const ICON_PX = { sm: 14, md: 16 } as const;
|
|
29
|
+
const STAR_COUNT = 5;
|
|
30
|
+
const NO_SIDE_LABEL = new Set<CellType>([
|
|
31
|
+
"badge",
|
|
32
|
+
"badges",
|
|
33
|
+
"select",
|
|
34
|
+
"rating",
|
|
35
|
+
"actions",
|
|
36
|
+
"actionIcons",
|
|
37
|
+
"actionMenu",
|
|
38
|
+
]);
|
|
39
|
+
|
|
40
|
+
function clamp(n: number, min: number, max: number): number {
|
|
41
|
+
return Math.min(max, Math.max(min, n));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function toPercent(value?: string | number): number {
|
|
45
|
+
if (value === undefined || value === "") return 0;
|
|
46
|
+
const n = typeof value === "number" ? value : parseFloat(String(value).replace("%", ""));
|
|
47
|
+
if (Number.isNaN(n)) return 0;
|
|
48
|
+
return clamp(n, 0, 100);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function toRating(value?: string | number): number {
|
|
52
|
+
if (value === undefined || value === "") return 0;
|
|
53
|
+
const n = typeof value === "number" ? value : parseFloat(String(value));
|
|
54
|
+
if (Number.isNaN(n)) return 0;
|
|
55
|
+
return clamp(Math.round(n), 0, STAR_COUNT);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function sideLabelText(
|
|
59
|
+
type: CellType,
|
|
60
|
+
label?: string,
|
|
61
|
+
name?: string,
|
|
62
|
+
value?: string | number,
|
|
63
|
+
): string {
|
|
64
|
+
if (NO_SIDE_LABEL.has(type)) return "";
|
|
65
|
+
if (type === "progress") {
|
|
66
|
+
if (label) return label;
|
|
67
|
+
return `${Math.round(toPercent(value))}%`;
|
|
68
|
+
}
|
|
69
|
+
if (type === "trendPositive" || type === "trendNegative") {
|
|
70
|
+
if (label) return label;
|
|
71
|
+
if (value !== undefined) return String(value);
|
|
72
|
+
return "";
|
|
73
|
+
}
|
|
74
|
+
if (label) return label;
|
|
75
|
+
if (type === "avatar" || type === "avatarGroup") return name ?? "";
|
|
76
|
+
return "";
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function trendAria(direction: "Up" | "Down", value?: string | number): string {
|
|
80
|
+
if (value === undefined || value === "") return direction;
|
|
81
|
+
return `${direction} ${value}`;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function Cell({
|
|
85
|
+
type = "text",
|
|
86
|
+
size = "md",
|
|
87
|
+
text = true,
|
|
88
|
+
checkbox = false,
|
|
89
|
+
label,
|
|
90
|
+
name,
|
|
91
|
+
src,
|
|
92
|
+
initials,
|
|
93
|
+
people,
|
|
94
|
+
icon,
|
|
95
|
+
tone = "neutral",
|
|
96
|
+
badges,
|
|
97
|
+
value,
|
|
98
|
+
options,
|
|
99
|
+
actions,
|
|
100
|
+
checked,
|
|
101
|
+
defaultChecked,
|
|
102
|
+
onCheckedChange,
|
|
103
|
+
id,
|
|
104
|
+
}: CellProps) {
|
|
105
|
+
const generatedId = useId();
|
|
106
|
+
const checkboxId = id ?? generatedId;
|
|
107
|
+
const selectId = `${generatedId}-select`;
|
|
108
|
+
const iconPx = ICON_PX[size];
|
|
109
|
+
const personName = name || label || "";
|
|
110
|
+
const shown = sideLabelText(type, label, name, value);
|
|
111
|
+
const selectName = label || name || "row";
|
|
112
|
+
const buttonSize = size === "sm" ? "sm" : "sm";
|
|
113
|
+
|
|
114
|
+
let rootAria: string | undefined;
|
|
115
|
+
if (!text) {
|
|
116
|
+
if (type === "file" || type === "payment") {
|
|
117
|
+
rootAria = label || name;
|
|
118
|
+
} else if (type === "trendPositive") {
|
|
119
|
+
rootAria = trendAria("Up", value);
|
|
120
|
+
} else if (type === "trendNegative") {
|
|
121
|
+
rootAria = trendAria("Down", value);
|
|
122
|
+
} else if (type === "rating") {
|
|
123
|
+
rootAria = `${toRating(value)} of ${STAR_COUNT}`;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
let visual: ReactNode = null;
|
|
128
|
+
if (type === "avatar") {
|
|
129
|
+
visual = <Avatar name={personName} src={src} initials={initials} size={size} />;
|
|
130
|
+
} else if (type === "avatarGroup" && people && people.length > 0) {
|
|
131
|
+
visual = <AvatarGroup items={people} size={size} max={3} ariaLabel={label} />;
|
|
132
|
+
} else if (type === "file") {
|
|
133
|
+
visual = <LucideByName name={icon || "File"} size={iconPx} className={styles.icon} />;
|
|
134
|
+
} else if (type === "payment") {
|
|
135
|
+
visual = <LucideByName name={icon || "CreditCard"} size={iconPx} className={styles.icon} />;
|
|
136
|
+
} else if (type === "badge") {
|
|
137
|
+
visual = (
|
|
138
|
+
<Badge tone={tone} size={size}>
|
|
139
|
+
{label || ""}
|
|
140
|
+
</Badge>
|
|
141
|
+
);
|
|
142
|
+
} else if (type === "badges") {
|
|
143
|
+
visual = (
|
|
144
|
+
<span className={styles.badges}>
|
|
145
|
+
{(badges ?? []).slice(0, 3).map((item, index) => (
|
|
146
|
+
<Badge key={`${item.label}-${index}`} tone={item.tone ?? "neutral"} size={size}>
|
|
147
|
+
{item.label}
|
|
148
|
+
</Badge>
|
|
149
|
+
))}
|
|
150
|
+
</span>
|
|
151
|
+
);
|
|
152
|
+
} else if (type === "trendPositive" || type === "trendNegative") {
|
|
153
|
+
const positive = type === "trendPositive";
|
|
154
|
+
visual = (
|
|
155
|
+
<span className={`${styles.trend} ${positive ? styles.trendPositive : styles.trendNegative}`}>
|
|
156
|
+
<LucideByName name={positive ? "ChevronUp" : "ChevronDown"} size={iconPx} />
|
|
157
|
+
{text && shown ? <span className={styles.label}>{shown}</span> : null}
|
|
158
|
+
</span>
|
|
159
|
+
);
|
|
160
|
+
} else if (type === "select" && options && options.length > 0) {
|
|
161
|
+
const selected = value !== undefined && value !== "" ? String(value) : options[0].value;
|
|
162
|
+
visual = (
|
|
163
|
+
<span className={styles.selectWrap}>
|
|
164
|
+
<Select
|
|
165
|
+
id={selectId}
|
|
166
|
+
size="sm"
|
|
167
|
+
options={options}
|
|
168
|
+
defaultValue={selected}
|
|
169
|
+
ariaLabel={label || "Select"}
|
|
170
|
+
/>
|
|
171
|
+
</span>
|
|
172
|
+
);
|
|
173
|
+
} else if (type === "progress") {
|
|
174
|
+
const percent = toPercent(value);
|
|
175
|
+
visual = (
|
|
176
|
+
<span className={styles.progressWrap}>
|
|
177
|
+
<Progress
|
|
178
|
+
value={percent}
|
|
179
|
+
size={size}
|
|
180
|
+
ariaLabel={label || `${Math.round(percent)}%`}
|
|
181
|
+
/>
|
|
182
|
+
</span>
|
|
183
|
+
);
|
|
184
|
+
} else if (type === "rating") {
|
|
185
|
+
const score = toRating(value);
|
|
186
|
+
visual = (
|
|
187
|
+
<span className={styles.rating} role="img" aria-label={label || `${score} of ${STAR_COUNT}`}>
|
|
188
|
+
{Array.from({ length: STAR_COUNT }, (_, index) => (
|
|
189
|
+
<LucideByName
|
|
190
|
+
key={index}
|
|
191
|
+
name="Star"
|
|
192
|
+
size={iconPx}
|
|
193
|
+
className={index < score ? styles.starOn : styles.starOff}
|
|
194
|
+
/>
|
|
195
|
+
))}
|
|
196
|
+
</span>
|
|
197
|
+
);
|
|
198
|
+
} else if (type === "actions") {
|
|
199
|
+
const items = (actions ?? []).slice(0, 3);
|
|
200
|
+
if (items.length > 0) {
|
|
201
|
+
visual = (
|
|
202
|
+
<ButtonGroup ariaLabel={label || "Row actions"}>
|
|
203
|
+
{items.map((item, index) => (
|
|
204
|
+
<Button
|
|
205
|
+
key={`${item.label || item.icon || "action"}-${index}`}
|
|
206
|
+
size={buttonSize}
|
|
207
|
+
variant={item.variant ?? (index === 0 ? "secondary" : "tertiary")}
|
|
208
|
+
iconStart={item.icon}
|
|
209
|
+
ariaLabel={item.ariaLabel}
|
|
210
|
+
onClick={item.onClick}
|
|
211
|
+
>
|
|
212
|
+
{item.label}
|
|
213
|
+
</Button>
|
|
214
|
+
))}
|
|
215
|
+
</ButtonGroup>
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
} else if (type === "actionIcons") {
|
|
219
|
+
const items = (actions ?? []).slice(0, 3);
|
|
220
|
+
if (items.length > 0) {
|
|
221
|
+
visual = (
|
|
222
|
+
<span className={styles.actionIcons} role="group" aria-label={label || "Row actions"}>
|
|
223
|
+
{items.map((item, index) => (
|
|
224
|
+
<Button
|
|
225
|
+
key={`${item.icon || item.label || "icon"}-${index}`}
|
|
226
|
+
size={buttonSize}
|
|
227
|
+
variant={item.variant ?? "tertiary"}
|
|
228
|
+
iconStart={item.icon}
|
|
229
|
+
ariaLabel={item.ariaLabel || item.label || "Action"}
|
|
230
|
+
onClick={item.onClick}
|
|
231
|
+
/>
|
|
232
|
+
))}
|
|
233
|
+
</span>
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
} else if (type === "actionMenu") {
|
|
237
|
+
const menuItems = (actions ?? []).map((item, index) => ({
|
|
238
|
+
id: item.label || item.ariaLabel || item.icon || `action-${index}`,
|
|
239
|
+
label: item.label || item.ariaLabel || "Action",
|
|
240
|
+
icon: item.icon,
|
|
241
|
+
danger: item.variant === "danger",
|
|
242
|
+
}));
|
|
243
|
+
visual = (
|
|
244
|
+
<DropdownMenu
|
|
245
|
+
iconStart={icon || "Ellipsis"}
|
|
246
|
+
ariaLabel={label || "Row actions"}
|
|
247
|
+
variant="tertiary"
|
|
248
|
+
size={buttonSize}
|
|
249
|
+
align="end"
|
|
250
|
+
groups={[{ items: menuItems }]}
|
|
251
|
+
onSelect={(id) => {
|
|
252
|
+
const hit = (actions ?? []).find(
|
|
253
|
+
(item, index) => (item.label || item.ariaLabel || item.icon || `action-${index}`) === id,
|
|
254
|
+
);
|
|
255
|
+
hit?.onClick?.();
|
|
256
|
+
}}
|
|
257
|
+
/>
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
const avatarSupport = type === "avatar" && name && label && label !== name ? label : "";
|
|
262
|
+
const showAvatarCopy = type === "avatar" && text && Boolean(personName);
|
|
263
|
+
const showSideLabel =
|
|
264
|
+
text &&
|
|
265
|
+
shown &&
|
|
266
|
+
type !== "trendPositive" &&
|
|
267
|
+
type !== "trendNegative" &&
|
|
268
|
+
type !== "avatar";
|
|
269
|
+
const empty = !checkbox && !visual && !showSideLabel && !showAvatarCopy;
|
|
270
|
+
|
|
271
|
+
const actionMenu = type === "actionMenu";
|
|
272
|
+
|
|
273
|
+
return (
|
|
274
|
+
<span
|
|
275
|
+
className={`${styles.cell} ${styles[size]}${actionMenu ? ` ${styles.actionMenu}` : ""}`}
|
|
276
|
+
aria-label={rootAria}
|
|
277
|
+
>
|
|
278
|
+
{checkbox ? (
|
|
279
|
+
<Checkbox
|
|
280
|
+
id={checkboxId}
|
|
281
|
+
size="sm"
|
|
282
|
+
ariaLabel={`Select ${selectName}`}
|
|
283
|
+
checked={checked}
|
|
284
|
+
defaultChecked={defaultChecked}
|
|
285
|
+
onChange={onCheckedChange}
|
|
286
|
+
/>
|
|
287
|
+
) : null}
|
|
288
|
+
{visual ? <span className={styles.visual}>{visual}</span> : null}
|
|
289
|
+
{showAvatarCopy ? (
|
|
290
|
+
<span className={styles.copy}>
|
|
291
|
+
<span className={styles.label}>{personName}</span>
|
|
292
|
+
{avatarSupport ? <span className={styles.support}>{avatarSupport}</span> : null}
|
|
293
|
+
</span>
|
|
294
|
+
) : showSideLabel ? (
|
|
295
|
+
<span className={styles.label}>{shown}</span>
|
|
296
|
+
) : null}
|
|
297
|
+
{empty ? "\u00a0" : null}
|
|
298
|
+
</span>
|
|
299
|
+
);
|
|
300
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { BadgeTone } from "../Badge/Badge.types";
|
|
2
|
+
import type { ButtonVariant } from "../Button/Button.types";
|
|
3
|
+
|
|
4
|
+
export type CellType =
|
|
5
|
+
| "text"
|
|
6
|
+
| "avatar"
|
|
7
|
+
| "file"
|
|
8
|
+
| "payment"
|
|
9
|
+
| "badge"
|
|
10
|
+
| "badges"
|
|
11
|
+
| "trendPositive"
|
|
12
|
+
| "trendNegative"
|
|
13
|
+
| "avatarGroup"
|
|
14
|
+
| "select"
|
|
15
|
+
| "progress"
|
|
16
|
+
| "rating"
|
|
17
|
+
| "actions"
|
|
18
|
+
| "actionIcons"
|
|
19
|
+
| "actionMenu";
|
|
20
|
+
|
|
21
|
+
export type CellSize = "sm" | "md";
|
|
22
|
+
|
|
23
|
+
export interface CellPerson {
|
|
24
|
+
name: string;
|
|
25
|
+
src?: string;
|
|
26
|
+
initials?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface CellBadgeItem {
|
|
30
|
+
label: string;
|
|
31
|
+
tone?: BadgeTone;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface CellOption {
|
|
35
|
+
value: string;
|
|
36
|
+
label: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface CellAction {
|
|
40
|
+
label?: string;
|
|
41
|
+
icon?: string;
|
|
42
|
+
ariaLabel?: string;
|
|
43
|
+
variant?: ButtonVariant;
|
|
44
|
+
onClick?: () => void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface CellProps {
|
|
48
|
+
type?: CellType;
|
|
49
|
+
size?: CellSize;
|
|
50
|
+
text?: boolean;
|
|
51
|
+
checkbox?: boolean;
|
|
52
|
+
label?: string;
|
|
53
|
+
name?: string;
|
|
54
|
+
src?: string;
|
|
55
|
+
initials?: string;
|
|
56
|
+
people?: CellPerson[];
|
|
57
|
+
icon?: string;
|
|
58
|
+
tone?: BadgeTone;
|
|
59
|
+
badges?: CellBadgeItem[];
|
|
60
|
+
value?: string | number;
|
|
61
|
+
options?: CellOption[];
|
|
62
|
+
actions?: CellAction[];
|
|
63
|
+
checked?: boolean;
|
|
64
|
+
defaultChecked?: boolean;
|
|
65
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
66
|
+
id?: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type CellValue = CellProps;
|