@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
|
@@ -1,12 +1,36 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
export interface PaginationProps extends React.ComponentProps<"nav"> {
|
|
2
|
+
export interface PaginationProps extends Omit<React.ComponentProps<"nav">, "onChange"> {
|
|
3
|
+
/**
|
|
4
|
+
* Total amount of pages
|
|
5
|
+
*/
|
|
6
|
+
total?: number;
|
|
7
|
+
/**
|
|
8
|
+
* Active page
|
|
9
|
+
*/
|
|
10
|
+
page?: number;
|
|
11
|
+
/**
|
|
12
|
+
* Initial active page
|
|
13
|
+
*/
|
|
14
|
+
initialPage?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Siblings amount on left/right side of selected page
|
|
17
|
+
*/
|
|
18
|
+
siblings?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Amount of elements visible on left/right edges
|
|
21
|
+
*/
|
|
22
|
+
boundaries?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Callback fired after change of each page
|
|
25
|
+
*/
|
|
26
|
+
onChange?: (page: number) => void;
|
|
3
27
|
/**
|
|
4
28
|
* ARIA label for the navigation
|
|
5
29
|
* @default "Pagination"
|
|
6
30
|
*/
|
|
7
31
|
"aria-label"?: string;
|
|
8
32
|
}
|
|
9
|
-
declare function Pagination({ className, "aria-label": ariaLabel, ...props }: PaginationProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
declare function Pagination({ className, "aria-label": ariaLabel, total, page, initialPage, siblings, boundaries, onChange, children, ...props }: PaginationProps): import("react/jsx-runtime").JSX.Element;
|
|
10
34
|
export interface PaginationContentProps extends React.ComponentProps<"ul"> {
|
|
11
35
|
/**
|
|
12
36
|
* Visual variant
|
|
@@ -19,8 +43,9 @@ export interface PaginationContentProps extends React.ComponentProps<"ul"> {
|
|
|
19
43
|
*/
|
|
20
44
|
spaced?: boolean;
|
|
21
45
|
}
|
|
46
|
+
declare function PaginationContent({ className, variant, spaced, ...props }: PaginationContentProps): import("react/jsx-runtime").JSX.Element;
|
|
22
47
|
declare function PaginationItem({ className, ...props }: React.ComponentProps<"li">): import("react/jsx-runtime").JSX.Element;
|
|
23
|
-
export interface PaginationLinkProps extends React.ComponentProps<"
|
|
48
|
+
export interface PaginationLinkProps extends Omit<React.ComponentProps<"button">, "onClick"> {
|
|
24
49
|
/**
|
|
25
50
|
* Whether this page is currently active
|
|
26
51
|
* @default false
|
|
@@ -36,8 +61,20 @@ export interface PaginationLinkProps extends React.ComponentProps<"a"> {
|
|
|
36
61
|
* @default false
|
|
37
62
|
*/
|
|
38
63
|
isIconButton?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Page number to navigate to (if using as button)
|
|
66
|
+
*/
|
|
67
|
+
page?: number;
|
|
68
|
+
/**
|
|
69
|
+
* Link href (if using as anchor)
|
|
70
|
+
*/
|
|
71
|
+
href?: string;
|
|
72
|
+
/**
|
|
73
|
+
* On click handler
|
|
74
|
+
*/
|
|
75
|
+
onClick?: (e: React.MouseEvent) => void;
|
|
39
76
|
}
|
|
40
|
-
declare function PaginationLink({ className, isActive, size, isIconButton, children, ...props }: PaginationLinkProps): import("react/jsx-runtime").JSX.Element;
|
|
77
|
+
declare function PaginationLink({ className, isActive, size, isIconButton, children, page, href, onClick, ...props }: PaginationLinkProps): import("react/jsx-runtime").JSX.Element;
|
|
41
78
|
export interface PaginationPreviousProps extends Omit<PaginationLinkProps, "isIconButton"> {
|
|
42
79
|
/**
|
|
43
80
|
* Show label text alongside icon
|
|
@@ -45,7 +82,7 @@ export interface PaginationPreviousProps extends Omit<PaginationLinkProps, "isIc
|
|
|
45
82
|
*/
|
|
46
83
|
showLabel?: boolean;
|
|
47
84
|
}
|
|
48
|
-
declare function PaginationPrevious({ className, showLabel, children, ...props }: PaginationPreviousProps): import("react/jsx-runtime").JSX.Element;
|
|
85
|
+
declare function PaginationPrevious({ className, showLabel, children, onClick, ...props }: PaginationPreviousProps): import("react/jsx-runtime").JSX.Element;
|
|
49
86
|
export interface PaginationNextProps extends Omit<PaginationLinkProps, "isIconButton"> {
|
|
50
87
|
/**
|
|
51
88
|
* Show label text alongside icon
|
|
@@ -53,27 +90,6 @@ export interface PaginationNextProps extends Omit<PaginationLinkProps, "isIconBu
|
|
|
53
90
|
*/
|
|
54
91
|
showLabel?: boolean;
|
|
55
92
|
}
|
|
56
|
-
declare function PaginationNext({ className, showLabel, children, ...props }: PaginationNextProps): import("react/jsx-runtime").JSX.Element;
|
|
93
|
+
declare function PaginationNext({ className, showLabel, children, onClick, ...props }: PaginationNextProps): import("react/jsx-runtime").JSX.Element;
|
|
57
94
|
declare function PaginationEllipsis({ className, ...props }: React.ComponentProps<"span">): import("react/jsx-runtime").JSX.Element;
|
|
58
|
-
|
|
59
|
-
export interface PageItem {
|
|
60
|
-
type: "page" | "ellipsis";
|
|
61
|
-
page?: number;
|
|
62
|
-
key: string;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Generate page items with ellipsis for large page ranges
|
|
66
|
-
*
|
|
67
|
-
* @param currentPage - Current active page (1-indexed)
|
|
68
|
-
* @param totalPages - Total number of pages
|
|
69
|
-
* @param siblingCount - Number of siblings to show on each side of current page
|
|
70
|
-
* @returns Array of page items to render
|
|
71
|
-
*
|
|
72
|
-
* @example
|
|
73
|
-
* ```tsx
|
|
74
|
-
* const items = generatePagination(5, 10, 1);
|
|
75
|
-
* // Returns: [1, ellipsis, 4, 5, 6, ellipsis, 10]
|
|
76
|
-
* ```
|
|
77
|
-
*/
|
|
78
|
-
export declare function generatePagination(currentPage: number, totalPages: number, siblingCount?: number): PageItem[];
|
|
79
|
-
export { Pagination, PaginationContentWithContext as PaginationContent, PaginationItem, PaginationLink, PaginationPrevious, PaginationNext, PaginationEllipsis, };
|
|
95
|
+
export { Pagination, PaginationContent, PaginationItem, PaginationLink, PaginationPrevious, PaginationNext, PaginationEllipsis, };
|
|
@@ -1,27 +1,45 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { usePagination } from "@kala-ui/react-hooks";
|
|
2
3
|
import { ChevronLeft, ChevronRight, MoreHorizontal } from "lucide-react";
|
|
3
4
|
import * as React from "react";
|
|
4
5
|
import { cn } from "../../lib/utils";
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
import { Box } from "../box";
|
|
7
|
+
import { Flex } from "../flex";
|
|
8
|
+
import { Text } from "../text";
|
|
9
|
+
function Pagination({ className, "aria-label": ariaLabel = "Pagination", total, page, initialPage, siblings, boundaries, onChange, children, ...props }) {
|
|
10
|
+
const pagination = usePagination({
|
|
11
|
+
total: total || 0,
|
|
12
|
+
page,
|
|
13
|
+
initialPage,
|
|
14
|
+
siblings,
|
|
15
|
+
boundaries,
|
|
16
|
+
onChange,
|
|
17
|
+
});
|
|
18
|
+
return (_jsx(PaginationContext.Provider, { value: pagination, children: _jsx(Box, { as: "nav", "aria-label": ariaLabel, className: cn("mx-auto flex w-full justify-center", className), ...props, children: children }) }));
|
|
19
|
+
}
|
|
20
|
+
const PaginationContext = React.createContext(null);
|
|
21
|
+
function usePaginationContext() {
|
|
22
|
+
const context = React.useContext(PaginationContext);
|
|
23
|
+
return context;
|
|
7
24
|
}
|
|
8
25
|
function PaginationContent({ className, variant = "default", spaced = false, ...props }) {
|
|
9
|
-
return (_jsx(
|
|
26
|
+
return (_jsx(PaginationVariantContext.Provider, { value: variant, children: _jsx(Flex, { as: "ul", align: "center", gap: spaced ? 2 : 1, className: className, "data-variant": variant, ...props }) }));
|
|
10
27
|
}
|
|
11
28
|
// ============================================================================
|
|
12
29
|
// Pagination Item (List Item Container)
|
|
13
30
|
// ============================================================================
|
|
14
31
|
function PaginationItem({ className, ...props }) {
|
|
15
|
-
return _jsx("li",
|
|
32
|
+
return _jsx(Box, { as: "li", className: cn("", className), ...props });
|
|
16
33
|
}
|
|
17
|
-
function PaginationLink({ className, isActive, size = "default", isIconButton = false, children, ...props }) {
|
|
34
|
+
function PaginationLink({ className, isActive, size = "default", isIconButton = false, children, page, href, onClick, ...props }) {
|
|
18
35
|
const parentVariant = React.useContext(PaginationVariantContext) || "default";
|
|
36
|
+
const pagination = usePaginationContext();
|
|
19
37
|
const sizeClasses = {
|
|
20
38
|
sm: "h-8 min-w-8 text-xs",
|
|
21
39
|
default: "h-9 min-w-9 text-sm",
|
|
22
40
|
lg: "h-10 min-w-10 text-base",
|
|
23
41
|
};
|
|
24
|
-
const baseClasses = cn("inline-flex items-center justify-center whitespace-nowrap rounded-md font-medium transition-colors", "focus-ring", "disabled:pointer-events-none disabled:opacity-50", "text-foreground", sizeClasses[size], isIconButton ? "px-2" : "px-3");
|
|
42
|
+
const baseClasses = cn("inline-flex items-center justify-center whitespace-nowrap rounded-md font-medium transition-colors cursor-pointer", "focus-ring", "disabled:pointer-events-none disabled:opacity-50", "text-foreground", sizeClasses[size], isIconButton ? "px-2" : "px-3");
|
|
25
43
|
// Variant-specific styles
|
|
26
44
|
const variantClasses = {
|
|
27
45
|
default: cn("hover:bg-accent hover:text-accent-foreground", isActive &&
|
|
@@ -33,88 +51,44 @@ function PaginationLink({ className, isActive, size = "default", isIconButton =
|
|
|
33
51
|
circle: cn("rounded-full", "bg-muted hover:bg-accent hover:text-accent-foreground", isActive &&
|
|
34
52
|
"bg-primary text-primary-foreground hover:bg-primary/90 shadow-sm"),
|
|
35
53
|
};
|
|
36
|
-
|
|
54
|
+
const handleClick = (e) => {
|
|
55
|
+
if (page !== undefined && pagination) {
|
|
56
|
+
pagination.setPage(page);
|
|
57
|
+
}
|
|
58
|
+
onClick?.(e);
|
|
59
|
+
};
|
|
60
|
+
if (href) {
|
|
61
|
+
return (_jsx(Box, { as: "a", href: href, "aria-current": isActive ? "page" : undefined, className: cn(baseClasses, variantClasses[parentVariant], className), ...props, children: children }));
|
|
62
|
+
}
|
|
63
|
+
return (_jsx(Box, { as: "button", type: "button", "aria-current": isActive ? "page" : undefined, className: cn(baseClasses, variantClasses[parentVariant], className), onClick: handleClick, ...props, children: children }));
|
|
37
64
|
}
|
|
38
|
-
function PaginationPrevious({ className, showLabel = true, children, ...props }) {
|
|
39
|
-
|
|
65
|
+
function PaginationPrevious({ className, showLabel = true, children, onClick, ...props }) {
|
|
66
|
+
const pagination = usePaginationContext();
|
|
67
|
+
const handleClick = (e) => {
|
|
68
|
+
pagination?.previous();
|
|
69
|
+
onClick?.(e);
|
|
70
|
+
};
|
|
71
|
+
return (_jsxs(PaginationLink, { "aria-label": "Go to previous page", isIconButton: !showLabel, className: cn("gap-1", className), onClick: handleClick, disabled: pagination?.active === 1, ...props, children: [_jsx(ChevronLeft, { className: "h-4 w-4" }), showLabel && _jsx(Text, { as: "span", children: children || "Previous" })] }));
|
|
40
72
|
}
|
|
41
|
-
function PaginationNext({ className, showLabel = true, children, ...props }) {
|
|
42
|
-
|
|
73
|
+
function PaginationNext({ className, showLabel = true, children, onClick, ...props }) {
|
|
74
|
+
const pagination = usePaginationContext();
|
|
75
|
+
const handleClick = (e) => {
|
|
76
|
+
pagination?.next();
|
|
77
|
+
onClick?.(e);
|
|
78
|
+
};
|
|
79
|
+
return (_jsxs(PaginationLink, { "aria-label": "Go to next page", isIconButton: !showLabel, className: cn("gap-1", className), onClick: handleClick, disabled: pagination ? pagination.active >= pagination.total : undefined, ...props, children: [showLabel && _jsx(Text, { as: "span", children: children || "Next" }), _jsx(ChevronRight, { className: "h-4 w-4" })] }));
|
|
43
80
|
}
|
|
44
81
|
// ============================================================================
|
|
45
82
|
// Pagination Ellipsis
|
|
46
83
|
// ============================================================================
|
|
47
84
|
function PaginationEllipsis({ className, ...props }) {
|
|
48
|
-
return (_jsxs("span",
|
|
85
|
+
return (_jsxs(Flex, { as: "span", align: "center", justify: "center", "aria-hidden": true, className: cn("h-9 w-9", className), ...props, children: [_jsx(MoreHorizontal, { className: "size-4" }), _jsx(Text, { className: "sr-only", children: "More pages" })] }));
|
|
49
86
|
}
|
|
50
87
|
// ============================================================================
|
|
51
88
|
// Context for variant propagation
|
|
52
89
|
// ============================================================================
|
|
53
90
|
const PaginationVariantContext = React.createContext("default");
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
* Generate page items with ellipsis for large page ranges
|
|
59
|
-
*
|
|
60
|
-
* @param currentPage - Current active page (1-indexed)
|
|
61
|
-
* @param totalPages - Total number of pages
|
|
62
|
-
* @param siblingCount - Number of siblings to show on each side of current page
|
|
63
|
-
* @returns Array of page items to render
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* ```tsx
|
|
67
|
-
* const items = generatePagination(5, 10, 1);
|
|
68
|
-
* // Returns: [1, ellipsis, 4, 5, 6, ellipsis, 10]
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
export function generatePagination(currentPage, totalPages, siblingCount = 1) {
|
|
72
|
-
// Always show first page, last page, current page, and siblings
|
|
73
|
-
const totalNumbers = siblingCount * 2 + 3; // siblings + current + first + last
|
|
74
|
-
const totalBlocks = totalNumbers + 2; // + 2 ellipsis
|
|
75
|
-
if (totalPages <= totalBlocks) {
|
|
76
|
-
// Show all pages if total is small
|
|
77
|
-
return Array.from({ length: totalPages }, (_, i) => ({
|
|
78
|
-
type: "page",
|
|
79
|
-
page: i + 1,
|
|
80
|
-
key: `page-${i + 1}`,
|
|
81
|
-
}));
|
|
82
|
-
}
|
|
83
|
-
const leftSiblingIndex = Math.max(currentPage - siblingCount, 1);
|
|
84
|
-
const rightSiblingIndex = Math.min(currentPage + siblingCount, totalPages);
|
|
85
|
-
const shouldShowLeftEllipsis = leftSiblingIndex > 2;
|
|
86
|
-
const shouldShowRightEllipsis = rightSiblingIndex < totalPages - 1;
|
|
87
|
-
const items = [];
|
|
88
|
-
// First page
|
|
89
|
-
items.push({ type: "page", page: 1, key: "page-1" });
|
|
90
|
-
// Left ellipsis
|
|
91
|
-
if (shouldShowLeftEllipsis) {
|
|
92
|
-
items.push({ type: "ellipsis", key: "ellipsis-left" });
|
|
93
|
-
}
|
|
94
|
-
else if (leftSiblingIndex === 2) {
|
|
95
|
-
items.push({ type: "page", page: 2, key: "page-2" });
|
|
96
|
-
}
|
|
97
|
-
// Middle pages (siblings + current)
|
|
98
|
-
for (let i = leftSiblingIndex; i <= rightSiblingIndex; i++) {
|
|
99
|
-
if (i !== 1 && i !== totalPages) {
|
|
100
|
-
items.push({ type: "page", page: i, key: `page-${i}` });
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
// Right ellipsis
|
|
104
|
-
if (shouldShowRightEllipsis) {
|
|
105
|
-
items.push({ type: "ellipsis", key: "ellipsis-right" });
|
|
106
|
-
}
|
|
107
|
-
else if (rightSiblingIndex === totalPages - 1) {
|
|
108
|
-
items.push({
|
|
109
|
-
type: "page",
|
|
110
|
-
page: totalPages - 1,
|
|
111
|
-
key: `page-${totalPages - 1}`,
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
// Last page
|
|
115
|
-
if (totalPages > 1) {
|
|
116
|
-
items.push({ type: "page", page: totalPages, key: `page-${totalPages}` });
|
|
117
|
-
}
|
|
118
|
-
return items;
|
|
119
|
-
}
|
|
120
|
-
export { Pagination, PaginationContentWithContext as PaginationContent, PaginationItem, PaginationLink, PaginationPrevious, PaginationNext, PaginationEllipsis, };
|
|
91
|
+
// ============================================================================
|
|
92
|
+
// Export components
|
|
93
|
+
// ============================================================================
|
|
94
|
+
export { Pagination, PaginationContent, PaginationItem, PaginationLink, PaginationPrevious, PaginationNext, PaginationEllipsis, };
|
|
@@ -14,6 +14,7 @@ export declare const Basic: Story;
|
|
|
14
14
|
export declare const WithEllipsis: Story;
|
|
15
15
|
export declare const IconOnly: Story;
|
|
16
16
|
export declare const Sizes: Story;
|
|
17
|
+
export declare const Dynamic: Story;
|
|
17
18
|
export declare const Variants: Story;
|
|
18
19
|
export declare const Spaced: Story;
|
|
19
20
|
export declare const Interactive: Story;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { usePagination } from "@kala-ui/react-hooks";
|
|
2
3
|
import { useState } from "react";
|
|
3
|
-
import { Skeleton } from "../skeleton
|
|
4
|
-
import {
|
|
4
|
+
import { Skeleton } from "../skeleton";
|
|
5
|
+
import { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, } from "./pagination";
|
|
5
6
|
const meta = {
|
|
6
|
-
title: "
|
|
7
|
+
title: "Components/Pagination",
|
|
7
8
|
component: Pagination,
|
|
8
9
|
parameters: {
|
|
9
10
|
layout: "centered",
|
|
@@ -11,6 +12,21 @@ const meta = {
|
|
|
11
12
|
tags: ["autodocs"],
|
|
12
13
|
};
|
|
13
14
|
export default meta;
|
|
15
|
+
// Helper to adapt usePagination range to story format
|
|
16
|
+
function usePaginationItems(currentPage, totalPages) {
|
|
17
|
+
const { range } = usePagination({
|
|
18
|
+
total: totalPages,
|
|
19
|
+
page: currentPage,
|
|
20
|
+
siblings: 1,
|
|
21
|
+
boundaries: 1,
|
|
22
|
+
});
|
|
23
|
+
return range.map((item, index) => {
|
|
24
|
+
if (item === "dots") {
|
|
25
|
+
return { key: `dots-${index}`, type: "ellipsis" };
|
|
26
|
+
}
|
|
27
|
+
return { key: item, type: "page", page: item };
|
|
28
|
+
});
|
|
29
|
+
}
|
|
14
30
|
// ============================================================================
|
|
15
31
|
// Basic Example
|
|
16
32
|
// ============================================================================
|
|
@@ -36,6 +52,16 @@ export const Sizes = {
|
|
|
36
52
|
render: () => (_jsxs("div", { className: "flex flex-col gap-6", children: [_jsx(Pagination, { children: _jsxs(PaginationContent, { children: [_jsx(PaginationItem, { children: _jsx(PaginationPrevious, { href: "#", size: "sm" }) }), _jsx(PaginationItem, { children: _jsx(PaginationLink, { href: "#", size: "sm", children: "1" }) }), _jsx(PaginationItem, { children: _jsx(PaginationLink, { href: "#", size: "sm", isActive: true, children: "2" }) }), _jsx(PaginationItem, { children: _jsx(PaginationLink, { href: "#", size: "sm", children: "3" }) }), _jsx(PaginationItem, { children: _jsx(PaginationNext, { href: "#", size: "sm" }) })] }) }), _jsx(Pagination, { children: _jsxs(PaginationContent, { children: [_jsx(PaginationItem, { children: _jsx(PaginationPrevious, { href: "#" }) }), _jsx(PaginationItem, { children: _jsx(PaginationLink, { href: "#", children: "1" }) }), _jsx(PaginationItem, { children: _jsx(PaginationLink, { href: "#", isActive: true, children: "2" }) }), _jsx(PaginationItem, { children: _jsx(PaginationLink, { href: "#", children: "3" }) }), _jsx(PaginationItem, { children: _jsx(PaginationNext, { href: "#" }) })] }) }), _jsx(Pagination, { children: _jsxs(PaginationContent, { children: [_jsx(PaginationItem, { children: _jsx(PaginationPrevious, { href: "#", size: "lg" }) }), _jsx(PaginationItem, { children: _jsx(PaginationLink, { href: "#", size: "lg", children: "1" }) }), _jsx(PaginationItem, { children: _jsx(PaginationLink, { href: "#", size: "lg", isActive: true, children: "2" }) }), _jsx(PaginationItem, { children: _jsx(PaginationLink, { href: "#", size: "lg", children: "3" }) }), _jsx(PaginationItem, { children: _jsx(PaginationNext, { href: "#", size: "lg" }) })] }) })] })),
|
|
37
53
|
};
|
|
38
54
|
// ============================================================================
|
|
55
|
+
// Dynamic (Using Hook Range)
|
|
56
|
+
// ============================================================================
|
|
57
|
+
export const Dynamic = {
|
|
58
|
+
render: () => {
|
|
59
|
+
const [page, setPage] = useState(1);
|
|
60
|
+
const total = 10;
|
|
61
|
+
return (_jsx(Pagination, { total: total, page: page, onChange: setPage, children: _jsxs(PaginationContent, { children: [_jsx(PaginationItem, { children: _jsx(PaginationPrevious, {}) }), _jsx(PaginationItem, { children: _jsx(PaginationLink, { page: 1, isActive: page === 1, children: "1" }) }), page > 3 && (_jsx(PaginationItem, { children: _jsx(PaginationEllipsis, {}) })), page > 2 && page < total - 1 && (_jsx(PaginationItem, { children: _jsx(PaginationLink, { page: page, isActive: true, children: page }) })), page < total - 2 && (_jsx(PaginationItem, { children: _jsx(PaginationEllipsis, {}) })), _jsx(PaginationItem, { children: _jsx(PaginationLink, { page: total, isActive: page === total, children: total }) }), _jsx(PaginationItem, { children: _jsx(PaginationNext, {}) })] }) }));
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
// ============================================================================
|
|
39
65
|
// Visual Variants
|
|
40
66
|
// ============================================================================
|
|
41
67
|
export const Variants = {
|
|
@@ -54,7 +80,7 @@ export const Interactive = {
|
|
|
54
80
|
render: () => {
|
|
55
81
|
const [currentPage, setCurrentPage] = useState(5);
|
|
56
82
|
const totalPages = 10;
|
|
57
|
-
const pages =
|
|
83
|
+
const pages = usePaginationItems(currentPage, totalPages);
|
|
58
84
|
return (_jsxs("div", { className: "space-y-4", children: [_jsxs("p", { className: "text-center text-sm text-muted-foreground", children: ["Page ", currentPage, " of ", totalPages] }), _jsx(Pagination, { children: _jsxs(PaginationContent, { children: [_jsx(PaginationItem, { children: _jsx(PaginationPrevious, { href: "#", onClick: (e) => {
|
|
59
85
|
e.preventDefault();
|
|
60
86
|
setCurrentPage((p) => Math.max(1, p - 1));
|
|
@@ -81,7 +107,7 @@ export const WithResultsSummary = {
|
|
|
81
107
|
const totalItems = 157;
|
|
82
108
|
const startItem = (currentPage - 1) * itemsPerPage + 1;
|
|
83
109
|
const endItem = Math.min(currentPage * itemsPerPage, totalItems);
|
|
84
|
-
const pages =
|
|
110
|
+
const pages = usePaginationItems(currentPage, totalPages);
|
|
85
111
|
return (_jsx("div", { className: "w-full max-w-3xl space-y-4 rounded-lg border bg-card text-card-foreground p-6 theme-card", children: _jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("p", { className: "text-sm text-muted-foreground", children: ["Showing ", _jsx("span", { className: "font-medium", children: startItem }), " to", " ", _jsx("span", { className: "font-medium", children: endItem }), " of", " ", _jsx("span", { className: "font-medium", children: totalItems }), " results"] }), _jsx(Pagination, { children: _jsxs(PaginationContent, { variant: "outline", spaced: true, children: [_jsx(PaginationItem, { children: _jsx(PaginationPrevious, { href: "#", size: "sm", onClick: (e) => {
|
|
86
112
|
e.preventDefault();
|
|
87
113
|
setCurrentPage((p) => Math.max(1, p - 1));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./paper";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./paper";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type VariantProps } from "class-variance-authority";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
declare const paperVariants: (props?: ({
|
|
4
|
+
shadow?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | null | undefined;
|
|
5
|
+
radius?: "none" | "sm" | "md" | "lg" | "xl" | "full" | null | undefined;
|
|
6
|
+
withBorder?: boolean | null | undefined;
|
|
7
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
8
|
+
export interface PaperProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof paperVariants> {
|
|
9
|
+
asChild?: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare const Paper: React.ForwardRefExoticComponent<PaperProps & React.RefAttributes<HTMLDivElement>>;
|
|
12
|
+
export { Paper, paperVariants };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { cn } from "../../lib/utils";
|
|
6
|
+
const paperVariants = cva("bg-background text-foreground", {
|
|
7
|
+
variants: {
|
|
8
|
+
shadow: {
|
|
9
|
+
none: "shadow-none",
|
|
10
|
+
xs: "shadow-sm",
|
|
11
|
+
sm: "shadow",
|
|
12
|
+
md: "shadow-md",
|
|
13
|
+
lg: "shadow-lg",
|
|
14
|
+
xl: "shadow-xl",
|
|
15
|
+
},
|
|
16
|
+
radius: {
|
|
17
|
+
none: "rounded-none",
|
|
18
|
+
sm: "rounded-sm",
|
|
19
|
+
md: "rounded-md",
|
|
20
|
+
lg: "rounded-lg",
|
|
21
|
+
xl: "rounded-xl",
|
|
22
|
+
full: "rounded-full",
|
|
23
|
+
},
|
|
24
|
+
withBorder: {
|
|
25
|
+
true: "border border-border",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
defaultVariants: {
|
|
29
|
+
shadow: "none",
|
|
30
|
+
radius: "sm",
|
|
31
|
+
withBorder: false,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
const Paper = React.forwardRef(({ className, shadow, radius, withBorder, asChild = false, ...props }, ref) => {
|
|
35
|
+
const Comp = asChild ? Slot : "div";
|
|
36
|
+
return (_jsx(Comp, { className: cn(paperVariants({ shadow, radius, withBorder, className })), ref: ref, ...props }));
|
|
37
|
+
});
|
|
38
|
+
Paper.displayName = "Paper";
|
|
39
|
+
export { Paper, paperVariants };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { Paper } from "./paper";
|
|
3
|
+
declare const meta: Meta<typeof Paper>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Paper>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Shadows: Story;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Paper } from "./paper";
|
|
3
|
+
const meta = {
|
|
4
|
+
title: "Components/Paper",
|
|
5
|
+
component: Paper,
|
|
6
|
+
tags: ["autodocs"],
|
|
7
|
+
argTypes: {
|
|
8
|
+
shadow: {
|
|
9
|
+
control: "select",
|
|
10
|
+
options: ["none", "xs", "sm", "md", "lg", "xl"],
|
|
11
|
+
},
|
|
12
|
+
radius: {
|
|
13
|
+
control: "select",
|
|
14
|
+
options: ["none", "sm", "md", "lg", "xl", "full"],
|
|
15
|
+
},
|
|
16
|
+
withBorder: {
|
|
17
|
+
control: "boolean",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
export default meta;
|
|
22
|
+
export const Default = {
|
|
23
|
+
args: {
|
|
24
|
+
children: _jsx("div", { className: "p-4", children: "Paper content" }),
|
|
25
|
+
withBorder: true,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
export const Shadows = {
|
|
29
|
+
render: () => (_jsxs("div", { className: "flex flex-col gap-4 p-4 bg-gray-50", children: [_jsx(Paper, { shadow: "xs", className: "p-4", children: "Shadow XS" }), _jsx(Paper, { shadow: "sm", className: "p-4", children: "Shadow SM" }), _jsx(Paper, { shadow: "md", className: "p-4", children: "Shadow MD" }), _jsx(Paper, { shadow: "lg", className: "p-4", children: "Shadow LG" }), _jsx(Paper, { shadow: "xl", className: "p-4", children: "Shadow XL" })] })),
|
|
30
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { Input } from "../input";
|
|
4
|
-
import { Label } from "../label
|
|
4
|
+
import { Label } from "../label";
|
|
5
5
|
import { PasswordStrengthIndicator } from "./password-strength-indicator";
|
|
6
6
|
const meta = {
|
|
7
7
|
title: "Application/PasswordStrengthIndicator",
|
|
@@ -6,7 +6,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
6
6
|
* Compact skeleton for small content areas.
|
|
7
7
|
*/
|
|
8
8
|
import { cn } from "../../lib/utils";
|
|
9
|
-
import { Skeleton } from "../skeleton
|
|
9
|
+
import { Skeleton } from "../skeleton";
|
|
10
10
|
/**
|
|
11
11
|
* Popover skeleton component
|
|
12
12
|
*
|
|
@@ -4,7 +4,7 @@ import * as React from "react";
|
|
|
4
4
|
import { Button } from "../button";
|
|
5
5
|
import { Input } from "../input";
|
|
6
6
|
import { Label } from "../label";
|
|
7
|
-
import { Skeleton } from "../skeleton
|
|
7
|
+
import { Skeleton } from "../skeleton";
|
|
8
8
|
import { Popover, PopoverBody, PopoverClose, PopoverContent, PopoverHeader, PopoverTrigger, } from "./popover";
|
|
9
9
|
const meta = {
|
|
10
10
|
title: "Overlay/Popover",
|
|
@@ -67,7 +67,7 @@ export const DismissibleFocus = {
|
|
|
67
67
|
},
|
|
68
68
|
};
|
|
69
69
|
export const LoadingSkeleton = {
|
|
70
|
-
render: () =>
|
|
70
|
+
render: () => _jsx(Skeleton, { className: "h-10 w-32 rounded-md" }),
|
|
71
71
|
parameters: {
|
|
72
72
|
docs: {
|
|
73
73
|
description: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ProgressBarProps, ProgressProps } from "./progress.types";
|
|
3
3
|
type ProgressSize = "sm" | "md" | "lg";
|
|
4
4
|
declare const Progress: React.ForwardRefExoticComponent<ProgressProps & React.RefAttributes<HTMLDivElement>>;
|
|
5
5
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { Button } from "../button";
|
|
4
|
-
import { Skeleton } from "../skeleton
|
|
4
|
+
import { Skeleton } from "../skeleton";
|
|
5
5
|
import { Progress, ProgressBar, ProgressGroup } from "./progress";
|
|
6
6
|
const meta = {
|
|
7
7
|
title: "Feedback/Progress",
|
|
@@ -6,7 +6,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
6
6
|
* Matches radio button layout with vertical/horizontal orientation.
|
|
7
7
|
*/
|
|
8
8
|
import { cn } from "../../lib/utils";
|
|
9
|
-
import { Skeleton } from "../skeleton
|
|
9
|
+
import { Skeleton } from "../skeleton";
|
|
10
10
|
/**
|
|
11
11
|
* Radio Group skeleton component
|
|
12
12
|
*
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { Button } from "../button";
|
|
4
4
|
import { Label } from "../label";
|
|
5
|
-
import { Skeleton } from "../skeleton
|
|
5
|
+
import { Skeleton } from "../skeleton";
|
|
6
6
|
import { RadioGroup, RadioGroupItem } from "./radio-group";
|
|
7
7
|
const meta = {
|
|
8
8
|
title: "Forms/RadioGroup",
|
|
@@ -120,14 +120,14 @@ export const DisabledHandle = {
|
|
|
120
120
|
*/
|
|
121
121
|
export const IDELayout = {
|
|
122
122
|
args: {},
|
|
123
|
-
render: () => (_jsxs(ResizablePanelGroup, { direction: "horizontal", className: "min-h-[500px] rounded-lg border", children: [_jsx(ResizablePanel, { defaultSize: 20, minSize: 15, maxSize: 30, className: "border-r", children: _jsxs("div", { className: "flex h-full flex-col", children: [_jsx("div", { className: "border-b p-4 font-semibold", children: "Explorer" }), _jsx("div", { className: "flex-1 p-4", children: _jsxs("div", { className: "space-y-2", children: [_jsx("div", { className: "text-sm", children: "\uD83D\uDCC1 src" }), _jsxs("div", { className: "ml-4 space-y-1 text-sm", children: [_jsx("div", { children: "\uD83D\uDCC4 App.tsx" }), _jsx("div", { children: "\uD83D\uDCC4 index.tsx" }), _jsx("div", { children: "\uD83D\uDCC4 styles.css" })] })] }) })] }) }), _jsx(ResizableHandle, {}), _jsx(ResizablePanel, { defaultSize: 60, children: _jsxs(ResizablePanelGroup, { direction: "vertical", children: [_jsx(ResizablePanel, { defaultSize: 70, minSize: 30, children: _jsxs("div", { className: "flex h-full flex-col", children: [_jsx("div", { className: "border-b p-4 font-semibold", children: "Editor" }), _jsx("div", { className: "bg-muted/20 flex-1 p-4", children: _jsx("pre", { className: "text-sm", children: _jsx("code", { children: `import React from 'react';
|
|
124
|
-
|
|
125
|
-
function App() {
|
|
126
|
-
return (
|
|
127
|
-
<div>Hello World</div>
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
|
|
123
|
+
render: () => (_jsxs(ResizablePanelGroup, { direction: "horizontal", className: "min-h-[500px] rounded-lg border", children: [_jsx(ResizablePanel, { defaultSize: 20, minSize: 15, maxSize: 30, className: "border-r", children: _jsxs("div", { className: "flex h-full flex-col", children: [_jsx("div", { className: "border-b p-4 font-semibold", children: "Explorer" }), _jsx("div", { className: "flex-1 p-4", children: _jsxs("div", { className: "space-y-2", children: [_jsx("div", { className: "text-sm", children: "\uD83D\uDCC1 src" }), _jsxs("div", { className: "ml-4 space-y-1 text-sm", children: [_jsx("div", { children: "\uD83D\uDCC4 App.tsx" }), _jsx("div", { children: "\uD83D\uDCC4 index.tsx" }), _jsx("div", { children: "\uD83D\uDCC4 styles.css" })] })] }) })] }) }), _jsx(ResizableHandle, {}), _jsx(ResizablePanel, { defaultSize: 60, children: _jsxs(ResizablePanelGroup, { direction: "vertical", children: [_jsx(ResizablePanel, { defaultSize: 70, minSize: 30, children: _jsxs("div", { className: "flex h-full flex-col", children: [_jsx("div", { className: "border-b p-4 font-semibold", children: "Editor" }), _jsx("div", { className: "bg-muted/20 flex-1 p-4", children: _jsx("pre", { className: "text-sm", children: _jsx("code", { children: `import React from 'react';
|
|
124
|
+
|
|
125
|
+
function App() {
|
|
126
|
+
return (
|
|
127
|
+
<div>Hello World</div>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
131
|
export default App;` }) }) })] }) }), _jsx(ResizableHandle, { withHandle: true }), _jsx(ResizablePanel, { defaultSize: 30, minSize: 20, children: _jsxs("div", { className: "flex h-full flex-col", children: [_jsx("div", { className: "border-t p-4 font-semibold", children: "Terminal" }), _jsx("div", { className: "bg-muted/40 flex-1 p-4", children: _jsxs("div", { className: "font-mono text-sm", children: [_jsx("div", { children: "$ npm run dev" }), _jsx("div", { className: "text-muted-foreground mt-2", children: "Server running on port 3000..." })] }) })] }) })] }) }), _jsx(ResizableHandle, {}), _jsx(ResizablePanel, { defaultSize: 20, minSize: 15, maxSize: 30, className: "border-l", children: _jsxs("div", { className: "flex h-full flex-col", children: [_jsx("div", { className: "border-b p-4 font-semibold", children: "Properties" }), _jsxs("div", { className: "flex-1 space-y-4 p-4", children: [_jsxs("div", { children: [_jsx("div", { className: "text-muted-foreground mb-1 text-xs font-medium", children: "File Info" }), _jsx("div", { className: "text-sm", children: "App.tsx" })] }), _jsxs("div", { children: [_jsx("div", { className: "text-muted-foreground mb-1 text-xs font-medium", children: "Lines" }), _jsx("div", { className: "text-sm", children: "9" })] }), _jsxs("div", { children: [_jsx("div", { className: "text-muted-foreground mb-1 text-xs font-medium", children: "Size" }), _jsx("div", { className: "text-sm", children: "128 bytes" })] })] })] }) })] })),
|
|
132
132
|
};
|
|
133
133
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ring-progress";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ring-progress";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface RingProgressProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
/** Value (0-100) */
|
|
4
|
+
value?: number;
|
|
5
|
+
/** Size in px */
|
|
6
|
+
size?: number;
|
|
7
|
+
/** Ring thickness */
|
|
8
|
+
thickness?: number;
|
|
9
|
+
/** Color (class name like text-blue-500) */
|
|
10
|
+
color?: string;
|
|
11
|
+
/** Empty ring color (class name) */
|
|
12
|
+
emptyColor?: string;
|
|
13
|
+
/** Label content centered in the ring */
|
|
14
|
+
label?: React.ReactNode;
|
|
15
|
+
/** Round caps */
|
|
16
|
+
roundCaps?: boolean;
|
|
17
|
+
/** Sections for multiple segments [{ value: 20, color: 'text-red-500' }] */
|
|
18
|
+
sections?: {
|
|
19
|
+
value: number;
|
|
20
|
+
color: string;
|
|
21
|
+
tooltip?: React.ReactNode;
|
|
22
|
+
}[];
|
|
23
|
+
}
|
|
24
|
+
export declare const RingProgress: React.ForwardRefExoticComponent<RingProgressProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cn } from "../../lib/utils";
|
|
4
|
+
export const RingProgress = React.forwardRef(({ className, value, size = 120, thickness = 12, color = "text-primary", emptyColor = "text-muted", label, roundCaps = true, sections, ...props }, ref) => {
|
|
5
|
+
const radius = (size - thickness) / 2;
|
|
6
|
+
const circumference = radius * 2 * Math.PI;
|
|
7
|
+
const segments = sections || (value !== undefined ? [{ value, color }] : []);
|
|
8
|
+
// Normalize values to ensure they sum up to <= 100 if needed, or just map them
|
|
9
|
+
// We map them to arc lengths.
|
|
10
|
+
let accumulatedValue = 0;
|
|
11
|
+
const renderedSegments = segments.map((segment, i) => {
|
|
12
|
+
const segmentValue = Math.min(Math.max(segment.value, 0), 100);
|
|
13
|
+
const offset = circumference - (segmentValue / 100) * circumference;
|
|
14
|
+
const rotation = (accumulatedValue / 100) * 360;
|
|
15
|
+
accumulatedValue += segmentValue;
|
|
16
|
+
return (_jsx("circle", { cx: size / 2, cy: size / 2, r: radius, fill: "none", strokeWidth: thickness, stroke: "currentColor", strokeDasharray: `${circumference} ${circumference}`, strokeDashoffset: offset, strokeLinecap: roundCaps ? "round" : "butt", className: cn("transition-all duration-500 ease-out", segment.color), transform: `rotate(${rotation - 90} ${size / 2} ${size / 2})` }, i));
|
|
17
|
+
});
|
|
18
|
+
return (_jsxs("div", { ref: ref, className: cn("relative flex items-center justify-center", className), style: { width: size, height: size }, ...props, children: [_jsxs("svg", { width: size, height: size, className: "transform", role: "img", children: [_jsx("title", { children: "Progress ring" }), _jsx("circle", { cx: size / 2, cy: size / 2, r: radius, fill: "none", strokeWidth: thickness, stroke: "currentColor", className: cn("opacity-20", emptyColor) }), renderedSegments] }), label && (_jsx("div", { className: "absolute inset-0 flex items-center justify-center", children: label }))] }));
|
|
19
|
+
});
|
|
20
|
+
RingProgress.displayName = "RingProgress";
|