@kala-ui/react 0.0.1-beta.7 → 0.0.2
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/dist/components/accordion/accordion-skeleton.js +1 -1
- package/dist/components/accordion/accordion.js +2 -1
- package/dist/components/action-icon/action-icon.d.ts +12 -0
- package/dist/components/action-icon/action-icon.js +35 -0
- package/dist/components/action-icon/action-icon.stories.d.ts +9 -0
- package/dist/components/action-icon/action-icon.stories.js +42 -0
- package/dist/components/action-icon/index.d.ts +1 -0
- package/dist/components/action-icon/index.js +1 -0
- package/dist/components/alert/alert-skeleton.js +4 -3
- package/dist/components/alert/alert.d.ts +2 -2
- package/dist/components/alert/alert.js +8 -6
- package/dist/components/alert/alert.stories.js +13 -9
- package/dist/components/alert/index.d.ts +1 -1
- package/dist/components/alert-dialog/alert-dialog.js +8 -5
- package/dist/components/app-shell/app-shell.d.ts +58 -0
- package/dist/components/app-shell/app-shell.js +111 -0
- package/dist/components/app-shell/app-shell.stories.d.ts +8 -0
- package/dist/components/app-shell/app-shell.stories.js +35 -0
- package/dist/components/app-shell/index.d.ts +1 -0
- package/dist/components/app-shell/index.js +1 -0
- package/dist/components/avatar/avatar.d.ts +2 -2
- package/dist/components/avatar/avatar.stories.js +1 -1
- package/dist/components/badge/badge.d.ts +1 -1
- package/dist/components/badge/badge.js +1 -1
- package/dist/components/badge/badge.stories.js +1 -1
- package/dist/components/banner/banner-skeleton.js +1 -1
- package/dist/components/banner/banner.d.ts +1 -1
- package/dist/components/banner/banner.stories.js +1 -1
- package/dist/components/box/box.d.ts +8 -0
- package/dist/components/box/box.js +10 -0
- package/dist/components/box/box.stories.d.ts +8 -0
- package/dist/components/box/box.stories.js +32 -0
- package/dist/components/box/index.d.ts +1 -0
- package/dist/components/box/index.js +1 -0
- package/dist/components/breadcrumbs/breadcrumbs-skeleton.js +1 -1
- package/dist/components/breadcrumbs/breadcrumbs.stories.js +1 -1
- package/dist/components/burger/burger.d.ts +8 -0
- package/dist/components/burger/burger.js +21 -0
- package/dist/components/burger/burger.stories.d.ts +8 -0
- package/dist/components/burger/burger.stories.js +31 -0
- package/dist/components/burger/index.d.ts +1 -0
- package/dist/components/burger/index.js +1 -0
- package/dist/components/button/button.d.ts +2 -2
- package/dist/components/button/button.stories.js +10 -7
- package/dist/components/button-group/button-group.stories.js +1 -1
- package/dist/components/calendar/calendar-skeleton.js +1 -1
- package/dist/components/calendar/calendar.d.ts +1 -1
- package/dist/components/calendar/calendar.js +1 -1
- package/dist/components/calendar/calendar.types.d.ts +3 -3
- package/dist/components/card/card-skeleton.js +2 -2
- package/dist/components/card/card.js +17 -14
- package/dist/components/card/index.d.ts +1 -1
- package/dist/components/center/center.d.ts +7 -0
- package/dist/components/center/center.js +10 -0
- package/dist/components/center/center.stories.d.ts +7 -0
- package/dist/components/center/center.stories.js +25 -0
- package/dist/components/center/index.d.ts +1 -0
- package/dist/components/center/index.js +1 -0
- package/dist/components/charts/area-chart.js +1 -1
- package/dist/components/charts/bar-chart.js +1 -1
- package/dist/components/charts/donut-chart.js +1 -1
- package/dist/components/charts/index.d.ts +2 -2
- package/dist/components/charts/index.js +2 -2
- package/dist/components/charts/line-chart.js +1 -1
- package/dist/components/charts/radial-bar-chart.js +1 -1
- package/dist/components/charts/theme-utils.d.ts +1 -1
- package/dist/components/charts/use-theme-aware-chart.d.ts +1 -1
- package/dist/components/charts/use-theme-aware-chart.js +2 -1
- package/dist/components/checkbox/checkbox.js +1 -1
- package/dist/components/checkbox/checkbox.stories.js +12 -8
- package/dist/components/close-button/close-button.d.ts +7 -0
- package/dist/components/close-button/close-button.js +9 -0
- package/dist/components/close-button/close-button.stories.d.ts +7 -0
- package/dist/components/close-button/close-button.stories.js +18 -0
- package/dist/components/close-button/index.d.ts +1 -0
- package/dist/components/close-button/index.js +1 -0
- package/dist/components/code/code.d.ts +8 -0
- package/dist/components/code/code.js +14 -0
- package/dist/components/code/code.stories.d.ts +8 -0
- package/dist/components/code/code.stories.js +31 -0
- package/dist/components/code/index.d.ts +1 -0
- package/dist/components/code/index.js +1 -0
- package/dist/components/collapse/collapse.d.ts +17 -0
- package/dist/components/collapse/collapse.js +34 -0
- package/dist/components/collapse/index.d.ts +1 -0
- package/dist/components/collapse/index.js +1 -0
- package/dist/components/color-input/color-input.d.ts +28 -0
- package/dist/components/color-input/color-input.js +35 -0
- package/dist/components/color-input/color-input.stories.d.ts +10 -0
- package/dist/components/color-input/color-input.stories.js +41 -0
- package/dist/components/color-input/index.d.ts +1 -0
- package/dist/components/color-input/index.js +1 -0
- package/dist/components/combobox/combobox-skeleton.js +1 -1
- package/dist/components/combobox/combobox.d.ts +1 -1
- package/dist/components/combobox/combobox.js +17 -8
- package/dist/components/combobox/combobox.stories.js +1 -1
- package/dist/components/command/command.d.ts +2 -2
- package/dist/components/command/command.stories.js +14 -19
- package/dist/components/container/container.d.ts +1 -1
- package/dist/components/container/index.d.ts +1 -1
- package/dist/components/container/index.js +1 -1
- package/dist/components/data-table/column-header-filter.js +11 -6
- package/dist/components/data-table/data-table-skeleton.js +5 -15
- package/dist/components/data-table/data-table.js +18 -15
- package/dist/components/data-table/data-table.stories.js +3 -5
- package/dist/components/date-picker/date-picker.d.ts +1 -1
- package/dist/components/date-picker/date-picker.js +3 -3
- package/dist/components/date-picker/date-picker.types.d.ts +1 -1
- package/dist/components/dialog/dialog-skeleton.js +1 -1
- package/dist/components/dialog/dialog.js +6 -4
- package/dist/components/dialog/dialog.stories.js +2 -2
- package/dist/components/dnd/dnd.d.ts +4 -5
- package/dist/components/dnd/dnd.js +5 -5
- package/dist/components/dnd/dnd.stories.js +48 -40
- package/dist/components/drawer/drawer.stories.js +2 -2
- package/dist/components/empty-state/empty-state-skeleton.js +2 -3
- package/dist/components/empty-state/empty-state.d.ts +1 -1
- package/dist/components/field/field-skeleton.js +1 -1
- package/dist/components/field/field.stories.js +1 -1
- package/dist/components/file-upload/file-upload-skeleton.js +1 -1
- package/dist/components/flex/flex.d.ts +7 -5
- package/dist/components/flex/flex.js +2 -2
- package/dist/components/flex/index.d.ts +1 -1
- package/dist/components/flex/index.js +1 -1
- package/dist/components/grid/grid.d.ts +24 -0
- package/dist/components/grid/grid.js +136 -0
- package/dist/components/grid/grid.stories.d.ts +8 -0
- package/dist/components/grid/grid.stories.js +31 -0
- package/dist/components/grid/index.d.ts +1 -0
- package/dist/components/grid/index.js +1 -0
- package/dist/components/group/group.d.ts +2 -2
- package/dist/components/group/group.js +1 -1
- package/dist/components/group/index.d.ts +1 -1
- package/dist/components/group/index.js +1 -1
- package/dist/components/header/header-skeleton.js +1 -1
- package/dist/components/header/header.d.ts +3 -3
- package/dist/components/header/header.js +17 -31
- package/dist/components/header/index.d.ts +1 -1
- package/dist/components/heading/heading.d.ts +4 -2
- package/dist/components/heading/heading.js +3 -7
- package/dist/components/heading/index.d.ts +1 -1
- package/dist/components/heading/index.js +1 -1
- package/dist/components/indicator/index.d.ts +1 -0
- package/dist/components/indicator/index.js +1 -0
- package/dist/components/indicator/indicator.d.ts +30 -0
- package/dist/components/indicator/indicator.js +89 -0
- package/dist/components/indicator/indicator.stories.d.ts +10 -0
- package/dist/components/indicator/indicator.stories.js +75 -0
- package/dist/components/input/input.js +1 -1
- package/dist/components/input/input.stories.js +1 -1
- package/dist/components/input-group/input-group.stories.js +1 -1
- package/dist/components/kbd/index.d.ts +1 -0
- package/dist/components/kbd/index.js +1 -0
- package/dist/components/kbd/kbd.d.ts +6 -0
- package/dist/components/kbd/kbd.js +13 -0
- package/dist/components/kbd/kbd.stories.d.ts +9 -0
- package/dist/components/kbd/kbd.stories.js +28 -0
- package/dist/components/label/label.stories.js +1 -1
- package/dist/components/list/list-skeleton.js +2 -2
- package/dist/components/list/list.js +1 -1
- package/dist/components/list/list.stories.js +1 -1
- package/dist/components/list/list.types.d.ts +2 -2
- package/dist/components/loading-overlay/index.d.ts +1 -0
- package/dist/components/loading-overlay/index.js +1 -0
- package/dist/components/loading-overlay/loading-overlay.d.ts +19 -0
- package/dist/components/loading-overlay/loading-overlay.js +19 -0
- package/dist/components/loading-overlay/loading-overlay.stories.d.ts +8 -0
- package/dist/components/loading-overlay/loading-overlay.stories.js +46 -0
- package/dist/components/metric-card/metric-card-skeleton.js +2 -2
- package/dist/components/metric-card/metric-card.js +1 -1
- package/dist/components/multi-select/multi-select-skeleton.js +1 -1
- package/dist/components/multi-select/multi-select.stories.js +1 -1
- package/dist/components/nav-link/index.d.ts +1 -0
- package/dist/components/nav-link/index.js +1 -0
- package/dist/components/nav-link/nav-link.d.ts +26 -0
- package/dist/components/nav-link/nav-link.js +26 -0
- package/dist/components/nav-link/nav-link.stories.d.ts +9 -0
- package/dist/components/nav-link/nav-link.stories.js +37 -0
- package/dist/components/navigation/navigation-skeleton.js +1 -1
- package/dist/components/number-input/index.d.ts +1 -0
- package/dist/components/number-input/index.js +1 -0
- package/dist/components/number-input/number-input.d.ts +40 -0
- package/dist/components/number-input/number-input.js +69 -0
- package/dist/components/number-input/number-input.stories.d.ts +11 -0
- package/dist/components/number-input/number-input.stories.js +54 -0
- package/dist/components/overlay/index.d.ts +1 -0
- package/dist/components/overlay/index.js +1 -0
- package/dist/components/overlay/overlay.d.ts +22 -0
- package/dist/components/overlay/overlay.js +45 -0
- package/dist/components/overlay/overlay.stories.d.ts +9 -0
- package/dist/components/overlay/overlay.stories.js +47 -0
- package/dist/components/page-transition/page-transition.stories.js +1 -1
- package/dist/components/pagination/index.d.ts +1 -1
- package/dist/components/pagination/index.js +1 -1
- package/dist/components/pagination/pagination-skeleton.js +1 -1
- package/dist/components/pagination/pagination.d.ts +44 -28
- package/dist/components/pagination/pagination.js +53 -79
- package/dist/components/pagination/pagination.stories.d.ts +1 -0
- package/dist/components/pagination/pagination.stories.js +31 -5
- package/dist/components/paper/index.d.ts +1 -0
- package/dist/components/paper/index.js +1 -0
- package/dist/components/paper/paper.d.ts +12 -0
- package/dist/components/paper/paper.js +39 -0
- package/dist/components/paper/paper.stories.d.ts +7 -0
- package/dist/components/paper/paper.stories.js +30 -0
- package/dist/components/password-strength-indicator/password-strength-indicator.stories.js +1 -1
- package/dist/components/popover/popover-skeleton.js +1 -1
- package/dist/components/popover/popover.stories.js +2 -2
- package/dist/components/progress/index.d.ts +1 -1
- package/dist/components/progress/progress.d.ts +1 -1
- package/dist/components/progress/progress.stories.js +1 -1
- package/dist/components/radio-group/radio-group-skeleton.js +1 -1
- package/dist/components/radio-group/radio-group.stories.js +1 -1
- package/dist/components/resizable/resizable.stories.js +8 -8
- package/dist/components/ring-progress/index.d.ts +1 -0
- package/dist/components/ring-progress/index.js +1 -0
- package/dist/components/ring-progress/ring-progress.d.ts +24 -0
- package/dist/components/ring-progress/ring-progress.js +20 -0
- package/dist/components/ring-progress/ring-progress.stories.d.ts +9 -0
- package/dist/components/ring-progress/ring-progress.stories.js +46 -0
- package/dist/components/scroll-area/scroll-area.stories.js +26 -26
- package/dist/components/segmented-control/index.d.ts +1 -0
- package/dist/components/segmented-control/index.js +1 -0
- package/dist/components/segmented-control/segmented-control.d.ts +19 -0
- package/dist/components/segmented-control/segmented-control.js +46 -0
- package/dist/components/segmented-control/segmented-control.stories.d.ts +10 -0
- package/dist/components/segmented-control/segmented-control.stories.js +53 -0
- package/dist/components/select/select.js +1 -1
- package/dist/components/select/select.stories.js +1 -1
- package/dist/components/separator/separator.stories.js +1 -1
- package/dist/components/session-card/session-card-skeleton.js +2 -2
- package/dist/components/session-card/session-card.js +1 -1
- package/dist/components/sidebar/sidebar-skeleton.js +2 -2
- package/dist/components/skeleton/index.d.ts +3 -3
- package/dist/components/skeleton/index.js +1 -1
- package/dist/components/skeleton/skeleton.types.d.ts +0 -249
- package/dist/components/slider/index.d.ts +1 -1
- package/dist/components/slider/slider.js +1 -1
- package/dist/components/slider/slider.stories.js +1 -1
- package/dist/components/social-login-button/social-login-button.js +6 -6
- package/dist/components/sparkline-chart/sparkline-chart.js +6 -3
- package/dist/components/sparkline-chart/sparkline-chart.stories.js +1 -1
- package/dist/components/spinner/spinner.d.ts +1 -1
- package/dist/components/spoiler/index.d.ts +1 -0
- package/dist/components/spoiler/index.js +1 -0
- package/dist/components/spoiler/spoiler.d.ts +14 -0
- package/dist/components/spoiler/spoiler.js +20 -0
- package/dist/components/spoiler/spoiler.stories.d.ts +8 -0
- package/dist/components/spoiler/spoiler.stories.js +35 -0
- package/dist/components/stack/index.d.ts +1 -1
- package/dist/components/stack/index.js +1 -1
- package/dist/components/stack/stack.d.ts +2 -2
- package/dist/components/stack/stack.js +1 -1
- package/dist/components/steps/steps-skeleton.js +1 -1
- package/dist/components/steps/steps.js +7 -5
- package/dist/components/steps/steps.stories.js +6 -2
- package/dist/components/switch/index.d.ts +1 -1
- package/dist/components/switch/switch.js +1 -1
- package/dist/components/switch/switch.stories.js +1 -1
- package/dist/components/table/table-skeleton.js +2 -2
- package/dist/components/table/table.js +4 -3
- package/dist/components/table/table.stories.js +10 -7
- package/dist/components/tabs/tabs-skeleton.js +1 -1
- package/dist/components/tabs/tabs.d.ts +3 -3
- package/dist/components/tabs/tabs.js +1 -1
- package/dist/components/tabs/tabs.stories.js +5 -5
- package/dist/components/text/index.d.ts +1 -1
- package/dist/components/text/index.js +1 -1
- package/dist/components/text/text.d.ts +7 -5
- package/dist/components/text/text.js +2 -2
- package/dist/components/text/text.stories.js +34 -3
- package/dist/components/textarea/textarea.js +1 -1
- package/dist/components/textarea/textarea.stories.js +1 -1
- package/dist/components/timeline/index.d.ts +1 -0
- package/dist/components/timeline/index.js +1 -0
- package/dist/components/timeline/timeline.d.ts +35 -0
- package/dist/components/timeline/timeline.js +36 -0
- package/dist/components/timeline/timeline.stories.d.ts +7 -0
- package/dist/components/timeline/timeline.stories.js +21 -0
- package/dist/components/toast/toast.js +6 -6
- package/dist/components/toggle/toggle.stories.js +1 -1
- package/dist/components/tooltip/tooltip.stories.js +1 -1
- package/dist/components/user-menu-dropdown/user-menu-dropdown.js +1 -1
- package/dist/config/tailwind-base.d.ts +10 -0
- package/dist/config/tailwind-base.js +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +25 -10
- package/dist/lib/animations.js +94 -94
- package/dist/primitives/command/Command.js +2 -1
- package/dist/styles/globals.css +415 -82
- package/package.json +101 -24
|
@@ -21,32 +21,32 @@ const providerConfig = {
|
|
|
21
21
|
google: {
|
|
22
22
|
icon: siGoogle,
|
|
23
23
|
label: "Google",
|
|
24
|
-
color: "hover:bg-
|
|
24
|
+
color: "hover:bg-brand-google hover:text-white hover:border-brand-google",
|
|
25
25
|
},
|
|
26
26
|
github: {
|
|
27
27
|
icon: siGithub,
|
|
28
28
|
label: "GitHub",
|
|
29
|
-
color: "hover:bg-
|
|
29
|
+
color: "hover:bg-brand-github hover:text-white hover:border-brand-github",
|
|
30
30
|
},
|
|
31
31
|
facebook: {
|
|
32
32
|
icon: siFacebook,
|
|
33
33
|
label: "Facebook",
|
|
34
|
-
color: "hover:bg-
|
|
34
|
+
color: "hover:bg-brand-facebook hover:text-white hover:border-brand-facebook",
|
|
35
35
|
},
|
|
36
36
|
twitter: {
|
|
37
37
|
icon: siX,
|
|
38
38
|
label: "X",
|
|
39
|
-
color: "hover:bg-
|
|
39
|
+
color: "hover:bg-brand-twitter hover:text-white hover:border-brand-twitter",
|
|
40
40
|
},
|
|
41
41
|
x: {
|
|
42
42
|
icon: siX,
|
|
43
43
|
label: "X",
|
|
44
|
-
color: "hover:bg-
|
|
44
|
+
color: "hover:bg-brand-twitter hover:text-white hover:border-brand-twitter",
|
|
45
45
|
},
|
|
46
46
|
linkedin: {
|
|
47
47
|
icon: null, // Custom component used instead
|
|
48
48
|
label: "LinkedIn",
|
|
49
|
-
color: "hover:bg-
|
|
49
|
+
color: "hover:bg-brand-linkedin hover:text-white hover:border-brand-linkedin",
|
|
50
50
|
},
|
|
51
51
|
};
|
|
52
52
|
export const SocialLoginButton = React.forwardRef(({ provider, isLoading = false, label, className, disabled, ...props }, ref) => {
|
|
@@ -7,7 +7,10 @@
|
|
|
7
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
8
|
import { cn } from "../../lib/utils";
|
|
9
9
|
import { Chart } from "../charts/chart";
|
|
10
|
-
|
|
10
|
+
import { useThemeAwareChart } from "../charts";
|
|
11
|
+
export function SparklineChart({ data, type = "line", color, width = "100%", height = 64, tooltip = false, className, gradientFrom, gradientTo, animated = true, interactive = false, }) {
|
|
12
|
+
const { colors: themeColors, theme } = useThemeAwareChart();
|
|
13
|
+
const chartColor = color || themeColors.primary[0];
|
|
11
14
|
const options = {
|
|
12
15
|
chart: {
|
|
13
16
|
type,
|
|
@@ -25,6 +28,7 @@ export function SparklineChart({ data, type = "line", color = "#3B82F6", width =
|
|
|
25
28
|
enabled: false,
|
|
26
29
|
},
|
|
27
30
|
},
|
|
31
|
+
colors: [chartColor],
|
|
28
32
|
states: {
|
|
29
33
|
hover: {
|
|
30
34
|
filter: {
|
|
@@ -67,10 +71,9 @@ export function SparklineChart({ data, type = "line", color = "#3B82F6", width =
|
|
|
67
71
|
},
|
|
68
72
|
}),
|
|
69
73
|
},
|
|
70
|
-
colors: [color],
|
|
71
74
|
tooltip: {
|
|
72
75
|
enabled: tooltip,
|
|
73
|
-
theme: "dark",
|
|
76
|
+
theme: theme === "dark" || theme === "accent" ? "dark" : "light",
|
|
74
77
|
x: {
|
|
75
78
|
show: false,
|
|
76
79
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "../card
|
|
2
|
+
import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "../card";
|
|
3
3
|
import { SparklineChart } from "./sparkline-chart";
|
|
4
4
|
const meta = {
|
|
5
5
|
title: "Data Display/SparklineChart",
|
|
@@ -2,7 +2,7 @@ import { type VariantProps } from "class-variance-authority";
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
declare const spinnerVariants: (props?: ({
|
|
4
4
|
size?: "sm" | "md" | "lg" | "xl" | null | undefined;
|
|
5
|
-
variant?: "
|
|
5
|
+
variant?: "current" | "default" | "white" | "muted" | "ghost" | null | undefined;
|
|
6
6
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
7
|
export interface SpinnerProps extends React.ComponentProps<"svg">, VariantProps<typeof spinnerVariants> {
|
|
8
8
|
label?: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./spoiler";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./spoiler";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface SpoilerProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
/** Max height in collapsed state (px) */
|
|
4
|
+
maxHeight: number;
|
|
5
|
+
/** Label for "Show more" button */
|
|
6
|
+
showLabel?: React.ReactNode;
|
|
7
|
+
/** Label for "Show less" button */
|
|
8
|
+
hideLabel?: React.ReactNode;
|
|
9
|
+
/** Initial state */
|
|
10
|
+
initialState?: boolean;
|
|
11
|
+
/** Transition duration in seconds */
|
|
12
|
+
transitionDuration?: number;
|
|
13
|
+
}
|
|
14
|
+
export declare const Spoiler: React.ForwardRefExoticComponent<SpoilerProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useDisclosure } from "@kala-ui/react-hooks";
|
|
3
|
+
import { motion } from "framer-motion";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { cn } from "../../lib/utils";
|
|
6
|
+
import { Box } from "../box";
|
|
7
|
+
import { Button } from "../button";
|
|
8
|
+
import { Flex } from "../flex";
|
|
9
|
+
export const Spoiler = React.forwardRef(({ className, children, maxHeight = 100, showLabel = "Show more", hideLabel = "Show less", initialState = false, transitionDuration = 0.2, ...props }, ref) => {
|
|
10
|
+
const [expanded, { toggle: toggleExpanded }] = useDisclosure(initialState);
|
|
11
|
+
const [showButton, setShowButton] = React.useState(false);
|
|
12
|
+
const contentRef = React.useRef(null);
|
|
13
|
+
React.useEffect(() => {
|
|
14
|
+
if (contentRef.current) {
|
|
15
|
+
setShowButton(contentRef.current.scrollHeight > maxHeight);
|
|
16
|
+
}
|
|
17
|
+
}, [maxHeight]);
|
|
18
|
+
return (_jsxs(Box, { ref: ref, className: cn("relative", className), ...props, children: [_jsx(motion.div, { initial: false, animate: { height: expanded ? "auto" : maxHeight }, transition: { duration: transitionDuration, ease: "easeInOut" }, className: "overflow-hidden", children: _jsx(Box, { ref: contentRef, children: children }) }), showButton && (_jsx(Flex, { justify: "center", className: "mt-2", children: _jsx(Button, { variant: "ghost", size: "sm", onClick: toggleExpanded, children: expanded ? hideLabel : showLabel }) }))] }));
|
|
19
|
+
});
|
|
20
|
+
Spoiler.displayName = "Spoiler";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { Spoiler } from "./spoiler";
|
|
3
|
+
declare const meta: Meta<typeof Spoiler>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Spoiler>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const CustomLabels: Story;
|
|
8
|
+
export declare const NoButtonIfNeeded: Story;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Spoiler } from "./spoiler";
|
|
3
|
+
import { Stack } from "../stack";
|
|
4
|
+
import { Text } from "../text";
|
|
5
|
+
const meta = {
|
|
6
|
+
title: "Components/Spoiler",
|
|
7
|
+
component: Spoiler,
|
|
8
|
+
tags: ["autodocs"],
|
|
9
|
+
argTypes: {
|
|
10
|
+
maxHeight: { control: "number" },
|
|
11
|
+
transitionDuration: { control: "number" },
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
export default meta;
|
|
15
|
+
const longContent = (_jsxs(Stack, { gap: 4, children: [_jsx(Text, { children: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat." }), _jsx(Text, { children: "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." }), _jsx(Text, { children: "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo." })] }));
|
|
16
|
+
export const Default = {
|
|
17
|
+
args: {
|
|
18
|
+
maxHeight: 60,
|
|
19
|
+
children: longContent,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
export const CustomLabels = {
|
|
23
|
+
args: {
|
|
24
|
+
maxHeight: 50,
|
|
25
|
+
showLabel: "Read full article",
|
|
26
|
+
hideLabel: "Hide article",
|
|
27
|
+
children: longContent,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
export const NoButtonIfNeeded = {
|
|
31
|
+
args: {
|
|
32
|
+
maxHeight: 500, // Large enough to fit content
|
|
33
|
+
children: _jsx(Text, { children: "Short content that fits within max height." }),
|
|
34
|
+
},
|
|
35
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./stack";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./stack";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { type FlexProps } from "../flex
|
|
2
|
+
import { type FlexProps } from "../flex";
|
|
3
3
|
export interface StackProps extends Omit<FlexProps, "direction"> {
|
|
4
4
|
direction?: "column" | "columnReverse";
|
|
5
5
|
}
|
|
6
|
-
declare const Stack: React.ForwardRefExoticComponent<StackProps & React.RefAttributes<
|
|
6
|
+
declare const Stack: React.ForwardRefExoticComponent<Omit<StackProps, "ref"> & React.RefAttributes<HTMLElement>>;
|
|
7
7
|
export { Stack };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { cn } from "../../lib/utils";
|
|
4
|
-
import { Flex } from "../flex
|
|
4
|
+
import { Flex } from "../flex";
|
|
5
5
|
const Stack = React.forwardRef(({ className, direction = "column", gap = 4, align = "stretch", ...props }, ref) => {
|
|
6
6
|
return (_jsx(Flex, { ref: ref, direction: direction, gap: gap, align: align, className: cn("w-full", className), ...props }));
|
|
7
7
|
});
|
|
@@ -7,7 +7,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
7
7
|
*/
|
|
8
8
|
import { Fragment } from "react";
|
|
9
9
|
import { cn } from "../../lib/utils";
|
|
10
|
-
import { Skeleton } from "../skeleton
|
|
10
|
+
import { Skeleton } from "../skeleton";
|
|
11
11
|
/**
|
|
12
12
|
* Steps skeleton component
|
|
13
13
|
*
|
|
@@ -3,6 +3,8 @@ import { cva } from "class-variance-authority";
|
|
|
3
3
|
import { Check } from "lucide-react";
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import { cn } from "../../lib/utils";
|
|
6
|
+
import { Box } from "../box";
|
|
7
|
+
import { Text } from "../text";
|
|
6
8
|
const stepsVariants = cva("flex w-full", {
|
|
7
9
|
variants: {
|
|
8
10
|
orientation: {
|
|
@@ -15,21 +17,21 @@ const stepsVariants = cva("flex w-full", {
|
|
|
15
17
|
},
|
|
16
18
|
});
|
|
17
19
|
const Steps = React.forwardRef(({ className, orientation, currentStep, items, onStepClick, showLine = true, ...props }, ref) => {
|
|
18
|
-
return (_jsx(
|
|
20
|
+
return (_jsx(Box, { ref: ref, className: cn(stepsVariants({ orientation }), className), ...props, children: items.map((step, index) => {
|
|
19
21
|
const stepNumber = index + 1;
|
|
20
22
|
const isCompleted = stepNumber < currentStep;
|
|
21
23
|
const isActive = stepNumber === currentStep;
|
|
22
24
|
const isLast = index === items.length - 1;
|
|
23
25
|
const isClickable = !!onStepClick;
|
|
24
|
-
return (_jsxs(
|
|
26
|
+
return (_jsxs(Box, { className: cn("group relative flex", orientation === "vertical"
|
|
25
27
|
? "flex-col pb-8 last:pb-0"
|
|
26
|
-
: "flex-1 flex-col items-center"), children: [!isLast && showLine && (_jsxs(_Fragment, { children: [orientation === "horizontal" && (_jsx(
|
|
28
|
+
: "flex-1 flex-col items-center"), children: [!isLast && showLine && (_jsxs(_Fragment, { children: [orientation === "horizontal" && (_jsx(Box, { className: "absolute top-4 left-1/2 w-full h-[2px] -translate-y-1/2 bg-separator", children: _jsx(Box, { className: cn("h-full bg-primary transition-all duration-500 ease-in-out", isCompleted ? "w-full" : "w-0") }) })), orientation === "vertical" && (_jsx(Box, { className: "absolute top-8 left-4 h-[calc(100%-32px)] w-[2px] -translate-x-1/2 bg-separator", children: _jsx(Box, { className: cn("w-full bg-primary transition-all duration-500 ease-in-out", isCompleted ? "h-full" : "h-0") }) }))] })), _jsxs(Box, { className: cn("flex items-center", orientation === "vertical" ? "flex-row" : "flex-col w-full"), children: [_jsx(Box, { as: "button", type: "button", className: cn("relative z-10 flex h-8 w-8 shrink-0 items-center justify-center rounded-full border-2 text-sm font-semibold transition-all duration-300", isActive
|
|
27
29
|
? "border-primary bg-primary text-primary-foreground scale-110"
|
|
28
30
|
: isCompleted
|
|
29
31
|
? "border-primary bg-primary text-primary-foreground"
|
|
30
|
-
: "border-border bg-background text-muted-foreground group-hover:border-primary/50", isClickable && !isActive ? "cursor-pointer" : ""), disabled: !isClickable, onClick: () => onStepClick?.(stepNumber), children: isCompleted ? (_jsx(Check, { className: "h-4 w-4" })) : (step.icon || stepNumber) }), _jsxs(
|
|
32
|
+
: "border-border bg-background text-muted-foreground group-hover:border-primary/50", isClickable && !isActive ? "cursor-pointer" : ""), disabled: !isClickable, onClick: () => onStepClick?.(stepNumber), children: isCompleted ? (_jsx(Check, { className: "h-4 w-4" })) : (step.icon || stepNumber) }), _jsxs(Box, { className: cn(orientation === "vertical"
|
|
31
33
|
? "ml-4"
|
|
32
|
-
: "mt-2 text-center px-2"), children: [_jsx(
|
|
34
|
+
: "mt-2 text-center px-2"), children: [_jsx(Text, { size: "sm", weight: "medium", className: cn(isActive ? "text-primary" : "text-foreground"), children: step.title }), step.description && (_jsx(Text, { size: "xs", className: "text-muted-foreground mt-0.5", children: step.description }))] })] })] }, step.title));
|
|
33
35
|
}) }));
|
|
34
36
|
});
|
|
35
37
|
Steps.displayName = "Steps";
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { CheckCircle, ChevronLeft, ChevronRight, CreditCard, Settings, User, } from "lucide-react";
|
|
3
3
|
import * as React from "react";
|
|
4
|
+
import { Box } from "../box";
|
|
4
5
|
import { Button } from "../button";
|
|
5
6
|
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "../card";
|
|
7
|
+
import { Flex } from "../flex";
|
|
6
8
|
import { Input } from "../input";
|
|
7
9
|
import { Label } from "../label";
|
|
8
10
|
import { RadioGroup, RadioGroupItem } from "../radio-group";
|
|
11
|
+
import { Stack } from "../stack";
|
|
12
|
+
import { Text } from "../text";
|
|
9
13
|
import { Steps } from "./steps";
|
|
10
14
|
const meta = {
|
|
11
15
|
title: "Data Display/Steps",
|
|
@@ -125,7 +129,7 @@ export const FullFlow = () => {
|
|
|
125
129
|
setCurrentStep((prev) => prev - 1);
|
|
126
130
|
}
|
|
127
131
|
};
|
|
128
|
-
return (_jsxs(
|
|
132
|
+
return (_jsxs(Box, { className: "w-[600px] max-w-full", children: [_jsx(Steps, { currentStep: currentStep, items: flowItems, className: "mb-8" }), _jsxs(Card, { children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { children: flowItems[currentStep - 1]?.title }), _jsx(CardDescription, { children: flowItems[currentStep - 1]?.description })] }), _jsxs(CardContent, { children: [currentStep === 1 && (_jsxs(Stack, { gap: 4, children: [_jsxs(Stack, { gap: 2, children: [_jsx(Label, { htmlFor: "name", children: "Name" }), _jsx(Input, { id: "name", placeholder: "John Doe", value: formData.name, onChange: (e) => setFormData({ ...formData, name: e.target.value }) })] }), _jsxs(Stack, { gap: 2, children: [_jsx(Label, { htmlFor: "email", children: "Email" }), _jsx(Input, { id: "email", type: "email", placeholder: "john@example.com", value: formData.email, onChange: (e) => setFormData({ ...formData, email: e.target.value }) })] })] })), currentStep === 2 && (_jsxs(RadioGroup, { value: formData.plan, onValueChange: (val) => setFormData({ ...formData, plan: val }), variant: "cards", children: [_jsx(RadioGroupItem, { value: "free", id: "free", children: _jsxs(Flex, { align: "center", justify: "between", className: "w-full", children: [_jsxs(Box, { children: [_jsx(Text, { size: "sm", weight: "medium", children: "Free Plan" }), _jsx(Text, { size: "sm", className: "text-muted-foreground", children: "Basic features" })] }), _jsx(Text, { weight: "bold", children: "$0/mo" })] }) }), _jsx(RadioGroupItem, { value: "pro", id: "pro", children: _jsxs(Flex, { align: "center", justify: "between", className: "w-full", children: [_jsxs(Box, { children: [_jsx(Text, { size: "sm", weight: "medium", children: "Pro Plan" }), _jsx(Text, { size: "sm", className: "text-muted-foreground", children: "All features included" })] }), _jsx(Text, { weight: "bold", children: "$20/mo" })] }) })] })), currentStep === 3 && (_jsx(Stack, { gap: 4, children: _jsxs(Stack, { gap: 2, children: [_jsx(Label, { htmlFor: "card", children: "Card Number" }), _jsx(Input, { id: "card", placeholder: "0000 0000 0000 0000", value: formData.cardNumber, onChange: (e) => setFormData({ ...formData, cardNumber: e.target.value }) })] }) })), currentStep === 4 && (_jsx(Stack, { gap: 4, children: _jsxs(Box, { className: "rounded-md bg-muted p-4", children: [_jsxs(Text, { children: [_jsx("strong", { children: "Name:" }), " ", formData.name || "Not set"] }), _jsxs(Text, { children: [_jsx("strong", { children: "Email:" }), " ", formData.email || "Not set"] }), _jsxs(Text, { children: [_jsx("strong", { children: "Plan:" }), " ", formData.plan] }), _jsxs(Text, { children: [_jsx("strong", { children: "Card:" }), " **** **** ****", " ", formData.cardNumber.slice(-4) || "****"] })] }) }))] }), _jsxs(CardFooter, { className: "flex justify-between", children: [_jsxs(Button, { variant: "outline", onClick: handlePrev, disabled: currentStep === 1, children: [_jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }), " Back"] }), _jsxs(Button, { onClick: handleNext, disabled: currentStep === flowItems.length, children: [currentStep === flowItems.length ? "Finish" : "Next", " ", _jsx(ChevronRight, { className: "ml-2 h-4 w-4" })] })] })] })] }));
|
|
129
133
|
};
|
|
130
134
|
export const VerticalFullFlow = () => {
|
|
131
135
|
const [currentStep, setCurrentStep] = React.useState(1);
|
|
@@ -167,5 +171,5 @@ export const VerticalFullFlow = () => {
|
|
|
167
171
|
setCurrentStep((prev) => prev - 1);
|
|
168
172
|
}
|
|
169
173
|
};
|
|
170
|
-
return (_jsxs(
|
|
174
|
+
return (_jsxs(Flex, { className: "w-[800px] max-w-full", gap: 8, children: [_jsx(Box, { className: "w-64 shrink-0", children: _jsx(Steps, { currentStep: currentStep, items: flowItems, orientation: "vertical" }) }), _jsxs(Card, { className: "flex-1", children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { children: flowItems[currentStep - 1]?.title }), _jsx(CardDescription, { children: flowItems[currentStep - 1]?.description })] }), _jsxs(CardContent, { children: [currentStep === 1 && (_jsxs(Stack, { gap: 4, children: [_jsxs(Stack, { gap: 2, children: [_jsx(Label, { htmlFor: "v-name", children: "Name" }), _jsx(Input, { id: "v-name", placeholder: "John Doe", value: formData.name, onChange: (e) => setFormData({ ...formData, name: e.target.value }) })] }), _jsxs(Stack, { gap: 2, children: [_jsx(Label, { htmlFor: "v-email", children: "Email" }), _jsx(Input, { id: "v-email", type: "email", placeholder: "john@example.com", value: formData.email, onChange: (e) => setFormData({ ...formData, email: e.target.value }) })] })] })), currentStep === 2 && (_jsxs(RadioGroup, { value: formData.plan, onValueChange: (val) => setFormData({ ...formData, plan: val }), variant: "cards", children: [_jsx(RadioGroupItem, { value: "free", id: "v-free", children: _jsxs(Flex, { align: "center", justify: "between", className: "w-full", children: [_jsxs(Box, { children: [_jsx(Text, { size: "sm", weight: "medium", children: "Free Plan" }), _jsx(Text, { size: "sm", className: "text-muted-foreground", children: "Basic features" })] }), _jsx(Text, { weight: "bold", children: "$0/mo" })] }) }), _jsx(RadioGroupItem, { value: "pro", id: "v-pro", children: _jsxs(Flex, { align: "center", justify: "between", className: "w-full", children: [_jsxs(Box, { children: [_jsx(Text, { size: "sm", weight: "medium", children: "Pro Plan" }), _jsx(Text, { size: "sm", className: "text-muted-foreground", children: "All features included" })] }), _jsx(Text, { weight: "bold", children: "$20/mo" })] }) })] })), currentStep === 3 && (_jsx(Stack, { gap: 4, children: _jsxs(Stack, { gap: 2, children: [_jsx(Label, { htmlFor: "v-card", children: "Card Number" }), _jsx(Input, { id: "v-card", placeholder: "0000 0000 0000 0000", value: formData.cardNumber, onChange: (e) => setFormData({ ...formData, cardNumber: e.target.value }) })] }) })), currentStep === 4 && (_jsx(Stack, { gap: 4, children: _jsxs(Box, { className: "rounded-md bg-muted p-4", children: [_jsxs(Text, { children: [_jsx("strong", { children: "Name:" }), " ", formData.name || "Not set"] }), _jsxs(Text, { children: [_jsx("strong", { children: "Email:" }), " ", formData.email || "Not set"] }), _jsxs(Text, { children: [_jsx("strong", { children: "Plan:" }), " ", formData.plan] }), _jsxs(Text, { children: [_jsx("strong", { children: "Card:" }), " **** **** ****", " ", formData.cardNumber.slice(-4) || "****"] })] }) }))] }), _jsxs(CardFooter, { className: "flex justify-between", children: [_jsxs(Button, { variant: "outline", onClick: handlePrev, disabled: currentStep === 1, children: [_jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }), " Back"] }), _jsxs(Button, { onClick: handleNext, disabled: currentStep === flowItems.length, children: [currentStep === flowItems.length ? "Finish" : "Next", " ", _jsx(ChevronRight, { className: "ml-2 h-4 w-4" })] })] })] })] }));
|
|
171
175
|
};
|
|
@@ -3,7 +3,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import * as SwitchPrimitive from "@radix-ui/react-switch";
|
|
4
4
|
import { switchStyles, switchThumbStyles } from "../../config/switch";
|
|
5
5
|
import { cn } from "../../lib/utils";
|
|
6
|
-
import { Skeleton } from "../skeleton
|
|
6
|
+
import { Skeleton } from "../skeleton";
|
|
7
7
|
function Switch({ className, isLoading = false, ...props }) {
|
|
8
8
|
if (isLoading) {
|
|
9
9
|
return _jsx(Skeleton, { className: cn("h-6 w-11 rounded-full", className) });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { fn } from "@storybook/test";
|
|
3
3
|
import { Label } from "../label";
|
|
4
|
-
import { Skeleton } from "../skeleton
|
|
4
|
+
import { Skeleton } from "../skeleton";
|
|
5
5
|
import { Switch } from "./switch";
|
|
6
6
|
const meta = {
|
|
7
7
|
title: "Forms/Switch",
|
|
@@ -4,8 +4,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
4
4
|
* Provides a loading placeholder that matches the actual Table component structure
|
|
5
5
|
* to prevent Cumulative Layout Shift (CLS)
|
|
6
6
|
*/
|
|
7
|
-
import { cn } from "../../lib/utils";
|
|
8
7
|
import { tableBodyStyles, tableCellStyles, tableHeaderStyles, tableHeadStyles, tableRowStyles, } from "../../config/table";
|
|
8
|
+
import { cn } from "../../lib/utils";
|
|
9
9
|
import { Skeleton } from "../skeleton";
|
|
10
10
|
export function TableSkeleton({ rows = 5, columns = 4, headers, columnWidths, showActions = false, showCheckboxes = false, stickyHeader = false, }) {
|
|
11
11
|
const _totalColumns = columns + (showActions ? 1 : 0);
|
|
@@ -18,7 +18,7 @@ export function TableSkeleton({ rows = 5, columns = 4, headers, columnWidths, sh
|
|
|
18
18
|
// Calculate default width based on alignment to match typical column behavior
|
|
19
19
|
return undefined; // Let CSS handle default width
|
|
20
20
|
};
|
|
21
|
-
return (_jsx("div", { className: "relative w-full overflow-x-auto border rounded-lg bg-card theme-card shadow-sm", children: _jsxs("table", { "data-slot": "table", className: "w-full caption-bottom text-sm", children: [_jsx("thead", { "data-slot": "table-header", className: cn(tableHeaderStyles.base, "bg-muted/50", stickyHeader && "sticky top-0 z-1"), children: _jsxs("tr", { "data-slot": "table-row", className: cn(tableRowStyles.base, "border-0"), children: [showCheckboxes && _jsx("th", { "data-slot": "table-head", className: cn(tableHeadStyles.base, "w-12") }), displayHeaders.map((header, index) => (_jsx("th", { "data-slot": "table-head", className: tableHeadStyles.base, style: { width: getCellWidth(index) }, children: header || _jsx(Skeleton, { className: "h-4 w-24" }) }, `header-${header || index}-${crypto.randomUUID()}`))), showActions && _jsx("th", { "data-slot": "table-head", className: tableHeadStyles.base, children: "Actions" }, "actions-header")] }) }), _jsx("tbody", { "data-slot": "table-body", className: tableBodyStyles.base, children: Array.from({ length: rows }).map(() => {
|
|
21
|
+
return (_jsx("div", { className: "relative w-full overflow-x-auto border rounded-lg bg-card theme-card shadow-sm", children: _jsxs("table", { "data-slot": "table", className: "w-full caption-bottom text-sm", children: [_jsx("thead", { "data-slot": "table-header", className: cn(tableHeaderStyles.base, "bg-muted/50", stickyHeader && "sticky top-0 z-1"), children: _jsxs("tr", { "data-slot": "table-row", className: cn(tableRowStyles.base, "border-0"), children: [showCheckboxes && (_jsx("th", { "data-slot": "table-head", className: cn(tableHeadStyles.base, "w-12") })), displayHeaders.map((header, index) => (_jsx("th", { "data-slot": "table-head", className: tableHeadStyles.base, style: { width: getCellWidth(index) }, children: header || _jsx(Skeleton, { className: "h-4 w-24" }) }, `header-${header || index}-${crypto.randomUUID()}`))), showActions && (_jsx("th", { "data-slot": "table-head", className: tableHeadStyles.base, children: "Actions" }, "actions-header"))] }) }), _jsx("tbody", { "data-slot": "table-body", className: tableBodyStyles.base, children: Array.from({ length: rows }).map(() => {
|
|
22
22
|
const rowId = crypto.randomUUID();
|
|
23
23
|
return (_jsxs("tr", { "data-slot": "table-row", className: cn(tableRowStyles.base, "border-0"), children: [showCheckboxes && (_jsx("td", { "data-slot": "table-cell", className: tableCellStyles.base, children: _jsx(Skeleton, { className: "h-4 w-4 rounded" }) })), Array.from({ length: columns }).map((_, colIndex) => {
|
|
24
24
|
const cellId = crypto.randomUUID();
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { Skeleton } from "../skeleton/skeleton";
|
|
4
3
|
import { tableBodyStyles, tableCaptionStyles, tableCellStyles, tableFooterStyles, tableHeaderStyles, tableHeadStyles, tableRowStyles, } from "../../config/table";
|
|
5
4
|
import { cn } from "../../lib/utils";
|
|
5
|
+
import { Box } from "../box";
|
|
6
|
+
import { Skeleton } from "../skeleton";
|
|
6
7
|
// Table Skeleton component (defined inline to avoid circular dependencies)
|
|
7
8
|
function TableSkeleton({ rows = 5, columns = 4, headers, showActions = false, showCheckboxes = false, }) {
|
|
8
|
-
return (_jsx(
|
|
9
|
+
return (_jsx(Box, { className: "relative w-full overflow-x-auto border rounded-lg bg-card theme-card", children: _jsxs("table", { className: "w-full caption-bottom text-sm", children: [headers ? (_jsx("thead", { className: "border-b bg-muted/50", children: _jsxs("tr", { children: [showCheckboxes && (_jsx("th", { className: "w-10 px-4 py-3 text-left", children: _jsx(Skeleton, { className: "h-4 w-4" }) })), headers.map((_header, i) => (_jsx("th", { className: "px-4 py-3 text-left", children: _jsx(Skeleton, { className: "h-4 w-24" }) }, i))), showActions && (_jsx("th", { className: "w-16 px-4 py-3 text-right", children: _jsx(Skeleton, { className: "ml-auto h-4 w-8" }) }))] }) })) : (_jsx("thead", { className: "border-b bg-muted/50", children: _jsxs("tr", { children: [showCheckboxes && (_jsx("th", { className: "w-10 px-4 py-3 text-left", children: _jsx(Skeleton, { className: "h-4 w-4" }) })), Array.from({ length: columns }).map((_, i) => (_jsx("th", { className: "px-4 py-3 text-left", children: _jsx(Skeleton, { className: "h-4 w-24" }) }, i))), showActions && (_jsx("th", { className: "w-16 px-4 py-3 text-right", children: _jsx(Skeleton, { className: "ml-auto h-4 w-8" }) }))] }) })), _jsx("tbody", { className: tableBodyStyles.base, children: Array.from({ length: rows }).map((_, rowIndex) => (_jsxs("tr", { className: "border-b transition-colors hover:bg-muted/50", children: [showCheckboxes && (_jsx("td", { className: "w-10 px-4 py-3", children: _jsx(Skeleton, { className: "h-4 w-4" }) })), Array.from({ length: columns }).map((_, colIndex) => (_jsx("td", { className: "px-4 py-3", children: _jsx(Skeleton, { className: "h-4 w-full max-w-[200px]" }) }, colIndex))), showActions && (_jsx("td", { className: "w-16 px-4 py-3 text-right", children: _jsx(Skeleton, { className: "ml-auto h-4 w-8" }) }))] }, rowIndex))) })] }) }));
|
|
9
10
|
}
|
|
10
11
|
function Table({ className, isLoading, loadingRows = 5, loadingColumns = 4, loadingShowActions = false, loadingHeaders, skeletonConfig, skeleton, ...props }) {
|
|
11
12
|
// Render skeleton state directly
|
|
@@ -23,7 +24,7 @@ function Table({ className, isLoading, loadingRows = 5, loadingColumns = 4, load
|
|
|
23
24
|
};
|
|
24
25
|
return _jsx(TableSkeleton, { ...config });
|
|
25
26
|
}
|
|
26
|
-
return (_jsx(
|
|
27
|
+
return (_jsx(Box, { "data-slot": "table-container", className: "relative w-full overflow-x-auto border rounded-lg bg-card theme-card", children: _jsx("table", { "data-slot": "table", className: cn("w-full caption-bottom text-sm", className), ...props }) }));
|
|
27
28
|
}
|
|
28
29
|
function TableHeader({ className, ...props }) {
|
|
29
30
|
return (_jsx("thead", { "data-slot": "table-header", className: cn(tableHeaderStyles.base, className), ...props }));
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { Badge } from "../badge";
|
|
4
|
+
import { Box } from "../box";
|
|
4
5
|
import { Button } from "../button";
|
|
5
|
-
import { Skeleton } from "../skeleton
|
|
6
|
+
import { Skeleton } from "../skeleton";
|
|
7
|
+
import { Stack } from "../stack";
|
|
8
|
+
import { Text } from "../text";
|
|
6
9
|
import { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, } from "./table";
|
|
7
10
|
import { TableSkeleton } from "./table-skeleton";
|
|
8
11
|
const meta = {
|
|
@@ -116,7 +119,7 @@ export const Hoverable = {
|
|
|
116
119
|
email: "bob@example.com",
|
|
117
120
|
status: "Inactive",
|
|
118
121
|
},
|
|
119
|
-
].map((user) => (_jsxs(TableRow, { className: "cursor-pointer hover:bg-primary/10", onClick: () => alert(`Clicked ${user.name}`), children: [_jsx(TableCell, { children: user.id }), _jsx(TableCell, { className: "font-medium", children: user.name }), _jsx(TableCell, { children: user.email }), _jsx(TableCell, { children: _jsx("span",
|
|
122
|
+
].map((user) => (_jsxs(TableRow, { className: "cursor-pointer hover:bg-primary/10", onClick: () => alert(`Clicked ${user.name}`), children: [_jsx(TableCell, { children: user.id }), _jsx(TableCell, { className: "font-medium", children: user.name }), _jsx(TableCell, { children: user.email }), _jsx(TableCell, { children: _jsx(Text, { as: "span", className: `inline-flex px-2 py-1 text-xs font-semibold rounded-full ${user.status === "Active"
|
|
120
123
|
? "bg-success/10 text-success"
|
|
121
124
|
: "bg-muted text-muted-foreground"}`, children: user.status }) })] }, user.id))) })] })),
|
|
122
125
|
};
|
|
@@ -124,7 +127,7 @@ export const Hoverable = {
|
|
|
124
127
|
* Responsive table that stacks on mobile
|
|
125
128
|
*/
|
|
126
129
|
export const Responsive = {
|
|
127
|
-
render: () => (_jsx(
|
|
130
|
+
render: () => (_jsx(Box, { className: "w-full max-w-4xl", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: "Product" }), _jsx(TableHead, { className: "hidden sm:table-cell", children: "Category" }), _jsx(TableHead, { className: "hidden md:table-cell", children: "Stock" }), _jsx(TableHead, { className: "text-right", children: "Price" })] }) }), _jsx(TableBody, { children: [
|
|
128
131
|
{
|
|
129
132
|
product: "Laptop Pro",
|
|
130
133
|
category: "Electronics",
|
|
@@ -171,7 +174,7 @@ export const CenterAligned = {
|
|
|
171
174
|
* Dark theme table
|
|
172
175
|
*/
|
|
173
176
|
export const BackgroundExample = {
|
|
174
|
-
render: () => (_jsx(
|
|
177
|
+
render: () => (_jsx(Box, { className: "p-6 bg-card rounded-lg border", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: "Name" }), _jsx(TableHead, { children: "Email" }), _jsx(TableHead, { children: "Role" }), _jsx(TableHead, { className: "text-right", children: "Status" })] }) }), _jsxs(TableBody, { children: [_jsxs(TableRow, { children: [_jsx(TableCell, { className: "font-medium", children: "Alice Johnson" }), _jsx(TableCell, { children: "alice@example.com" }), _jsx(TableCell, { children: "Admin" }), _jsx(TableCell, { className: "text-right", children: _jsx(Badge, { variant: "success", children: "Active" }) })] }), _jsxs(TableRow, { children: [_jsx(TableCell, { className: "font-medium", children: "Bob Smith" }), _jsx(TableCell, { children: "bob@example.com" }), _jsx(TableCell, { children: "User" }), _jsx(TableCell, { className: "text-right", children: _jsx(Badge, { variant: "success", children: "Active" }) })] }), _jsxs(TableRow, { children: [_jsx(TableCell, { className: "font-medium", children: "Carol White" }), _jsx(TableCell, { children: "carol@example.com" }), _jsx(TableCell, { children: "User" }), _jsx(TableCell, { className: "text-right", children: _jsx(Badge, { variant: "secondary", children: "Inactive" }) })] })] })] }) })),
|
|
175
178
|
};
|
|
176
179
|
/**
|
|
177
180
|
* Scrollable table with fixed height - useful for tables with many rows
|
|
@@ -192,7 +195,7 @@ export const ScrollableWithManyRows = {
|
|
|
192
195
|
}));
|
|
193
196
|
};
|
|
194
197
|
const rows = generateRows(50);
|
|
195
|
-
return (_jsxs(
|
|
198
|
+
return (_jsxs(Stack, { gap: 4, children: [_jsx(Text, { size: "sm", className: "text-muted-foreground", children: "This table has 50 rows with a maximum height of 600px and vertical scrolling." }), _jsx(Box, { className: "max-h-[600px] overflow-y-auto rounded-lg border", children: _jsxs(Table, { children: [_jsx(TableHeader, { className: "sticky top-0 bg-card z-10", children: _jsxs(TableRow, { children: [_jsx(TableHead, { className: "w-[80px]", children: "#" }), _jsx(TableHead, { children: "Name" }), _jsx(TableHead, { children: "Email" }), _jsx(TableHead, { children: "Role" }), _jsx(TableHead, { className: "text-right", children: "Status" })] }) }), _jsx(TableBody, { children: rows.map((row) => (_jsxs(TableRow, { children: [_jsx(TableCell, { className: "font-medium", children: row.id }), _jsx(TableCell, { children: row.name }), _jsx(TableCell, { children: row.email }), _jsx(TableCell, { children: row.role }), _jsx(TableCell, { className: "text-right", children: _jsx(Badge, { variant: row.status === "Active"
|
|
196
199
|
? "success"
|
|
197
200
|
: row.status === "Inactive"
|
|
198
201
|
? "secondary"
|
|
@@ -228,11 +231,11 @@ export const LoadingState = {
|
|
|
228
231
|
{ id: 2, name: "Jane Smith", email: "jane@example.com", role: "User" },
|
|
229
232
|
{ id: 3, name: "Bob Johnson", email: "bob@example.com", role: "User" },
|
|
230
233
|
];
|
|
231
|
-
return (_jsxs(
|
|
234
|
+
return (_jsxs(Box, { children: [_jsx(Box, { className: "mb-4", children: _jsx(Button, { onClick: () => setIsLoading(!isLoading), children: isLoading ? "Show Data" : "Show Loading" }) }), _jsxs(Table, { isLoading: isLoading, loadingRows: 3, loadingColumns: 4, loadingHeaders: ["ID", "Name", "Email", "Role"], children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: "ID" }), _jsx(TableHead, { children: "Name" }), _jsx(TableHead, { children: "Email" }), _jsx(TableHead, { children: "Role" })] }) }), _jsx(TableBody, { children: data.map((row) => (_jsxs(TableRow, { children: [_jsx(TableCell, { children: row.id }), _jsx(TableCell, { children: row.name }), _jsx(TableCell, { children: row.email }), _jsx(TableCell, { children: row.role })] }, row.id))) })] })] }));
|
|
232
235
|
},
|
|
233
236
|
};
|
|
234
237
|
export const LoadingSkeleton = {
|
|
235
|
-
render: () => (_jsx(
|
|
238
|
+
render: () => (_jsx(Box, { className: "w-full", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: _jsx(Skeleton, { className: "h-4 w-16" }) }), _jsx(TableHead, { children: _jsx(Skeleton, { className: "h-4 w-24" }) }), _jsx(TableHead, { children: _jsx(Skeleton, { className: "h-4 w-32" }) }), _jsx(TableHead, { children: _jsx(Skeleton, { className: "h-4 w-20" }) })] }) }), _jsx(TableBody, { children: Array.from({ length: 5 }).map((_, i) => (_jsxs(TableRow, { children: [_jsx(TableCell, { children: _jsx(Skeleton, { className: "h-4 w-12" }) }), _jsx(TableCell, { children: _jsx(Skeleton, { className: "h-4 w-32" }) }), _jsx(TableCell, { children: _jsx(Skeleton, { className: "h-4 w-40" }) }), _jsx(TableCell, { children: _jsx(Skeleton, { className: "h-4 w-24" }) })] }, i))) })] }) })),
|
|
236
239
|
parameters: {
|
|
237
240
|
docs: {
|
|
238
241
|
description: {
|
|
@@ -6,7 +6,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
6
6
|
* Supports different variants and content area.
|
|
7
7
|
*/
|
|
8
8
|
import { cn } from "../../lib/utils";
|
|
9
|
-
import { Skeleton } from "../skeleton
|
|
9
|
+
import { Skeleton } from "../skeleton";
|
|
10
10
|
/**
|
|
11
11
|
* Tabs skeleton component
|
|
12
12
|
*
|
|
@@ -3,11 +3,11 @@ import { type VariantProps } from "class-variance-authority";
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
declare const Tabs: React.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
5
5
|
declare const TabsList: React.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsListProps & React.RefAttributes<HTMLDivElement>, "ref"> & VariantProps<(props?: ({
|
|
6
|
-
variant?: "
|
|
7
|
-
align?: "center" | "
|
|
6
|
+
variant?: "line" | "vertical" | "default" | null | undefined;
|
|
7
|
+
align?: "center" | "start" | "end" | null | undefined;
|
|
8
8
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string> & React.RefAttributes<HTMLDivElement>>;
|
|
9
9
|
declare const TabsTrigger: React.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsTriggerProps & React.RefAttributes<HTMLButtonElement>, "ref"> & VariantProps<(props?: ({
|
|
10
|
-
variant?: "
|
|
10
|
+
variant?: "line" | "vertical" | "default" | null | undefined;
|
|
11
11
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string> & React.RefAttributes<HTMLButtonElement>>;
|
|
12
12
|
declare const TabsContent: React.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
13
13
|
export { Tabs, TabsList, TabsTrigger, TabsContent };
|
|
@@ -25,7 +25,7 @@ const Tabs = React.forwardRef(({ className, value, onValueChange, defaultValue,
|
|
|
25
25
|
onChange: onValueChange,
|
|
26
26
|
defaultProp: defaultValue,
|
|
27
27
|
});
|
|
28
|
-
return (_jsx(TabsContext.Provider, { value: { activeTab, setActiveTab, uniqueId }, children: _jsx(TabsPrimitive.Root, { ref: ref,
|
|
28
|
+
return (_jsx(TabsContext.Provider, { value: { activeTab, setActiveTab, uniqueId }, children: _jsx(TabsPrimitive.Root, { ref: ref, value: activeTab, onValueChange: setActiveTab, orientation: orientation, "data-slot": "tabs", className: cn("flex", orientation === "vertical" ? "flex-row gap-6" : "flex-col", className), ...props }) }));
|
|
29
29
|
});
|
|
30
30
|
Tabs.displayName = TabsPrimitive.Root.displayName;
|
|
31
31
|
const tabsListVariants = cva(tabsListStyles.base, {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Button } from "../button
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { Button } from "../button";
|
|
3
|
+
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "../card";
|
|
4
|
+
import { Input } from "../input";
|
|
5
|
+
import { Label } from "../label";
|
|
6
|
+
import { Skeleton } from "../skeleton";
|
|
7
7
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "./tabs";
|
|
8
8
|
const meta = {
|
|
9
9
|
title: "Navigation/Tabs",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./text";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./text";
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { type VariantProps } from "class-variance-authority";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
declare const textVariants: (props?: ({
|
|
4
|
-
size?: "base" | "
|
|
5
|
-
weight?: "bold" | "
|
|
6
|
-
align?: "center" | "end" | "
|
|
4
|
+
size?: "base" | "xs" | "sm" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "7xl" | "8xl" | "9xl" | null | undefined;
|
|
5
|
+
weight?: "bold" | "medium" | "semibold" | "extrabold" | "thin" | "extralight" | "light" | "normal" | "black" | null | undefined;
|
|
6
|
+
align?: "center" | "end" | "left" | "right" | "justify" | "start" | null | undefined;
|
|
7
7
|
color?: "default" | "primary" | "secondary" | "destructive" | "muted" | "accent" | null | undefined;
|
|
8
8
|
truncate?: boolean | null | undefined;
|
|
9
9
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
10
|
-
export interface TextProps extends Omit<React.HTMLAttributes<
|
|
10
|
+
export interface TextProps extends Omit<React.HTMLAttributes<HTMLElement>, "color">, VariantProps<typeof textVariants> {
|
|
11
11
|
asChild?: boolean;
|
|
12
|
+
as?: React.ElementType;
|
|
13
|
+
[key: string]: any;
|
|
12
14
|
}
|
|
13
|
-
declare const Text: React.ForwardRefExoticComponent<TextProps & React.RefAttributes<
|
|
15
|
+
declare const Text: React.ForwardRefExoticComponent<Omit<TextProps, "ref"> & React.RefAttributes<HTMLElement>>;
|
|
14
16
|
export { Text, textVariants };
|
|
@@ -58,8 +58,8 @@ const textVariants = cva("text-foreground", {
|
|
|
58
58
|
color: "default",
|
|
59
59
|
},
|
|
60
60
|
});
|
|
61
|
-
const Text = React.forwardRef(({ className, size, weight, align, color, truncate, asChild = false, ...props }, ref) => {
|
|
62
|
-
const Comp = asChild ? Slot :
|
|
61
|
+
const Text = React.forwardRef(({ className, size, weight, align, color, truncate, asChild = false, as: Tag = "p", ...props }, ref) => {
|
|
62
|
+
const Comp = asChild ? Slot : Tag;
|
|
63
63
|
return (_jsx(Comp, { className: cn(textVariants({ size, weight, align, color, truncate, className })), ref: ref, ...props }));
|
|
64
64
|
});
|
|
65
65
|
Text.displayName = "Text";
|