@codefast/ui 0.3.13-canary.3 → 0.3.13
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/CHANGELOG.md +44 -0
- package/dist/components/accordion.d.mts +37 -0
- package/dist/components/accordion.mjs +53 -0
- package/dist/components/alert-dialog.d.mts +74 -0
- package/dist/components/alert-dialog.mjs +92 -0
- package/dist/components/alert.d.mts +30 -0
- package/dist/components/alert.mjs +49 -0
- package/dist/components/aspect-ratio.d.mts +10 -0
- package/dist/components/aspect-ratio.mjs +12 -0
- package/dist/components/avatar.d.mts +21 -0
- package/dist/components/avatar.mjs +28 -0
- package/dist/components/badge.d.mts +24 -0
- package/dist/components/badge.mjs +56 -0
- package/dist/components/breadcrumb.d.mts +44 -0
- package/dist/components/breadcrumb.mjs +67 -0
- package/dist/components/button-group.d.mts +34 -0
- package/dist/components/button-group.mjs +53 -0
- package/dist/components/button.d.mts +38 -0
- package/dist/components/button.mjs +99 -0
- package/dist/components/calendar.d.mts +27 -0
- package/dist/components/calendar.mjs +114 -0
- package/dist/components/card.d.mts +41 -0
- package/dist/components/card.mjs +55 -0
- package/dist/components/carousel.d.mts +68 -0
- package/dist/components/carousel.mjs +135 -0
- package/dist/components/chart.d.mts +93 -0
- package/dist/components/chart.mjs +189 -0
- package/dist/components/checkbox-cards.d.mts +17 -0
- package/dist/components/checkbox-cards.mjs +30 -0
- package/dist/components/checkbox-group.d.mts +16 -0
- package/dist/components/checkbox-group.mjs +27 -0
- package/dist/components/checkbox.d.mts +11 -0
- package/dist/components/checkbox.mjs +20 -0
- package/dist/components/collapsible.d.mts +18 -0
- package/dist/components/collapsible.mjs +24 -0
- package/dist/components/command.d.mts +57 -0
- package/dist/components/command.mjs +92 -0
- package/dist/components/context-menu.d.mts +91 -0
- package/dist/components/context-menu.mjs +122 -0
- package/dist/components/dialog.d.mts +65 -0
- package/dist/components/dialog.mjs +93 -0
- package/dist/components/drawer.d.mts +65 -0
- package/dist/components/drawer.mjs +78 -0
- package/dist/components/dropdown-menu.d.mts +92 -0
- package/dist/components/dropdown-menu.mjs +129 -0
- package/dist/components/empty.d.mts +44 -0
- package/dist/components/empty.mjs +64 -0
- package/dist/components/field.d.mts +79 -0
- package/dist/components/field.mjs +132 -0
- package/dist/components/form.d.mts +48 -0
- package/dist/components/form.mjs +92 -0
- package/dist/components/hover-card.d.mts +26 -0
- package/dist/components/hover-card.mjs +35 -0
- package/dist/components/input-group.d.mts +61 -0
- package/dist/components/input-group.mjs +142 -0
- package/dist/components/input-number.d.mts +28 -0
- package/dist/components/input-number.mjs +61 -0
- package/dist/components/input-otp.d.mts +29 -0
- package/dist/components/input-otp.mjs +48 -0
- package/dist/components/input-password.d.mts +13 -0
- package/dist/components/input-password.mjs +38 -0
- package/dist/components/input-search.d.mts +20 -0
- package/dist/components/input-search.mjs +50 -0
- package/dist/components/input.d.mts +11 -0
- package/dist/components/input.mjs +14 -0
- package/dist/components/item.d.mts +82 -0
- package/dist/components/item.mjs +137 -0
- package/dist/components/kbd.d.mts +15 -0
- package/dist/components/kbd.mjs +19 -0
- package/dist/components/label.d.mts +11 -0
- package/dist/components/label.mjs +14 -0
- package/dist/components/menubar.d.mts +100 -0
- package/dist/components/menubar.mjs +133 -0
- package/dist/components/native-select.d.mts +19 -0
- package/dist/components/native-select.mjs +34 -0
- package/dist/components/navigation-menu.d.mts +44 -0
- package/dist/components/navigation-menu.mjs +79 -0
- package/dist/components/pagination.d.mts +46 -0
- package/dist/components/pagination.mjs +71 -0
- package/dist/components/popover.d.mts +30 -0
- package/dist/components/popover.mjs +41 -0
- package/dist/components/progress-circle.d.mts +124 -0
- package/dist/components/progress-circle.mjs +120 -0
- package/dist/components/progress.d.mts +12 -0
- package/dist/components/progress.mjs +19 -0
- package/dist/components/{radio-cards.d.ts → radio-cards.d.mts} +10 -5
- package/dist/components/radio-cards.mjs +29 -0
- package/dist/components/radio-group.d.mts +16 -0
- package/dist/components/radio-group.mjs +25 -0
- package/dist/components/radio.d.mts +14 -0
- package/dist/components/radio.mjs +16 -0
- package/dist/components/resizable.d.mts +23 -0
- package/dist/components/resizable.mjs +32 -0
- package/dist/components/scroll-area.d.mts +40 -0
- package/dist/components/scroll-area.mjs +101 -0
- package/dist/components/select.d.mts +62 -0
- package/dist/components/select.mjs +101 -0
- package/dist/components/separator.d.mts +32 -0
- package/dist/components/separator.mjs +45 -0
- package/dist/components/sheet.d.mts +75 -0
- package/dist/components/sheet.mjs +134 -0
- package/dist/components/sidebar.d.mts +195 -0
- package/dist/components/sidebar.mjs +375 -0
- package/dist/components/skeleton.d.mts +10 -0
- package/dist/components/skeleton.mjs +12 -0
- package/dist/components/slider.d.mts +15 -0
- package/dist/components/slider.mjs +40 -0
- package/dist/components/sonner.d.mts +10 -0
- package/dist/components/sonner.mjs +21 -0
- package/dist/components/spinner.d.mts +14 -0
- package/dist/components/spinner.mjs +40 -0
- package/dist/components/switch.d.mts +11 -0
- package/dist/components/switch.mjs +18 -0
- package/dist/components/table.d.mts +45 -0
- package/dist/components/table.mjs +65 -0
- package/dist/components/tabs.d.mts +26 -0
- package/dist/components/tabs.mjs +35 -0
- package/dist/components/textarea.d.mts +10 -0
- package/dist/components/textarea.mjs +12 -0
- package/dist/components/toggle-group.d.mts +30 -0
- package/dist/components/toggle-group.mjs +53 -0
- package/dist/components/toggle.d.mts +28 -0
- package/dist/components/toggle.mjs +53 -0
- package/dist/components/tooltip.d.mts +30 -0
- package/dist/components/tooltip.mjs +42 -0
- package/dist/hooks/{use-animated-value.d.ts → use-animated-value.d.mts} +4 -2
- package/dist/hooks/use-animated-value.mjs +62 -0
- package/dist/hooks/{use-copy-to-clipboard.d.ts → use-copy-to-clipboard.d.mts} +11 -6
- package/dist/hooks/use-copy-to-clipboard.mjs +43 -0
- package/dist/hooks/{use-is-mobile.d.ts → use-is-mobile.d.mts} +4 -2
- package/dist/hooks/use-is-mobile.mjs +26 -0
- package/dist/hooks/{use-media-query.d.ts → use-media-query.d.mts} +4 -2
- package/dist/hooks/use-media-query.mjs +50 -0
- package/dist/hooks/{use-mutation-observer.d.ts → use-mutation-observer.d.mts} +6 -3
- package/dist/hooks/use-mutation-observer.mjs +41 -0
- package/dist/hooks/use-pagination.d.mts +44 -0
- package/dist/hooks/use-pagination.mjs +107 -0
- package/dist/index.d.mts +69 -0
- package/dist/index.mjs +69 -0
- package/dist/lib/utils.d.mts +13 -0
- package/dist/lib/utils.mjs +10 -0
- package/dist/node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/clsx.d.mts +6 -0
- package/dist/primitives/checkbox-group.d.mts +144 -0
- package/dist/primitives/checkbox-group.mjs +126 -0
- package/dist/primitives/input-number.d.mts +73 -0
- package/dist/primitives/input-number.mjs +514 -0
- package/dist/primitives/input.d.mts +72 -0
- package/dist/primitives/input.mjs +75 -0
- package/dist/primitives/progress-circle.d.mts +146 -0
- package/dist/primitives/progress-circle.mjs +178 -0
- package/package.json +164 -170
- package/dist/components/accordion.d.ts +0 -19
- package/dist/components/accordion.d.ts.map +0 -1
- package/dist/components/accordion.js +0 -26
- package/dist/components/alert-dialog.d.ts +0 -39
- package/dist/components/alert-dialog.d.ts.map +0 -1
- package/dist/components/alert-dialog.js +0 -39
- package/dist/components/alert.d.ts +0 -19
- package/dist/components/alert.d.ts.map +0 -1
- package/dist/components/alert.js +0 -41
- package/dist/components/aspect-ratio.d.ts +0 -7
- package/dist/components/aspect-ratio.d.ts.map +0 -1
- package/dist/components/aspect-ratio.js +0 -10
- package/dist/components/avatar.d.ts +0 -11
- package/dist/components/avatar.d.ts.map +0 -1
- package/dist/components/avatar.js +0 -17
- package/dist/components/badge.d.ts +0 -18
- package/dist/components/badge.d.ts.map +0 -1
- package/dist/components/badge.js +0 -59
- package/dist/components/breadcrumb.d.ts +0 -22
- package/dist/components/breadcrumb.d.ts.map +0 -1
- package/dist/components/breadcrumb.js +0 -31
- package/dist/components/button-group.d.ts +0 -20
- package/dist/components/button-group.d.ts.map +0 -1
- package/dist/components/button-group.js +0 -48
- package/dist/components/button.d.ts +0 -29
- package/dist/components/button.d.ts.map +0 -1
- package/dist/components/button.js +0 -92
- package/dist/components/calendar.d.ts +0 -13
- package/dist/components/calendar.d.ts.map +0 -1
- package/dist/components/calendar.js +0 -104
- package/dist/components/card.d.ts +0 -18
- package/dist/components/card.d.ts.map +0 -1
- package/dist/components/card.js +0 -27
- package/dist/components/carousel.d.ts +0 -38
- package/dist/components/carousel.d.ts.map +0 -1
- package/dist/components/carousel.js +0 -103
- package/dist/components/chart.d.ts +0 -58
- package/dist/components/chart.d.ts.map +0 -1
- package/dist/components/chart.js +0 -198
- package/dist/components/checkbox-cards.d.ts +0 -11
- package/dist/components/checkbox-cards.d.ts.map +0 -1
- package/dist/components/checkbox-cards.js +0 -16
- package/dist/components/checkbox-group.d.ts +0 -9
- package/dist/components/checkbox-group.d.ts.map +0 -1
- package/dist/components/checkbox-group.js +0 -15
- package/dist/components/checkbox.d.ts +0 -7
- package/dist/components/checkbox.d.ts.map +0 -1
- package/dist/components/checkbox.js +0 -12
- package/dist/components/collapsible.d.ts +0 -11
- package/dist/components/collapsible.d.ts.map +0 -1
- package/dist/components/collapsible.js +0 -16
- package/dist/components/command.d.ts +0 -26
- package/dist/components/command.d.ts.map +0 -1
- package/dist/components/command.js +0 -41
- package/dist/components/context-menu.d.ts +0 -42
- package/dist/components/context-menu.d.ts.map +0 -1
- package/dist/components/context-menu.js +0 -54
- package/dist/components/dialog.d.ts +0 -35
- package/dist/components/dialog.d.ts.map +0 -1
- package/dist/components/dialog.js +0 -41
- package/dist/components/drawer.d.ts +0 -34
- package/dist/components/drawer.d.ts.map +0 -1
- package/dist/components/drawer.js +0 -36
- package/dist/components/dropdown-menu.d.ts +0 -42
- package/dist/components/dropdown-menu.d.ts.map +0 -1
- package/dist/components/dropdown-menu.js +0 -54
- package/dist/components/empty.d.ts +0 -23
- package/dist/components/empty.d.ts.map +0 -1
- package/dist/components/empty.js +0 -47
- package/dist/components/field.d.ts +0 -42
- package/dist/components/field.d.ts.map +0 -1
- package/dist/components/field.js +0 -85
- package/dist/components/form.d.ts +0 -27
- package/dist/components/form.d.ts.map +0 -1
- package/dist/components/form.js +0 -76
- package/dist/components/hover-card.d.ts +0 -13
- package/dist/components/hover-card.d.ts.map +0 -1
- package/dist/components/hover-card.js +0 -20
- package/dist/components/input-group.d.ts +0 -37
- package/dist/components/input-group.d.ts.map +0 -1
- package/dist/components/input-group.js +0 -127
- package/dist/components/input-number.d.ts +0 -8
- package/dist/components/input-number.d.ts.map +0 -1
- package/dist/components/input-number.js +0 -20
- package/dist/components/input-otp.d.ts +0 -16
- package/dist/components/input-otp.d.ts.map +0 -1
- package/dist/components/input-otp.js +0 -25
- package/dist/components/input-password.d.ts +0 -7
- package/dist/components/input-password.d.ts.map +0 -1
- package/dist/components/input-password.js +0 -17
- package/dist/components/input-search.d.ts +0 -11
- package/dist/components/input-search.d.ts.map +0 -1
- package/dist/components/input-search.js +0 -22
- package/dist/components/input.d.ts +0 -6
- package/dist/components/input.d.ts.map +0 -1
- package/dist/components/input.js +0 -10
- package/dist/components/item.d.ts +0 -46
- package/dist/components/item.d.ts.map +0 -1
- package/dist/components/item.js +0 -94
- package/dist/components/kbd.d.ts +0 -8
- package/dist/components/kbd.d.ts.map +0 -1
- package/dist/components/kbd.js +0 -12
- package/dist/components/label.d.ts +0 -7
- package/dist/components/label.d.ts.map +0 -1
- package/dist/components/label.js +0 -11
- package/dist/components/menubar.d.ts +0 -44
- package/dist/components/menubar.d.ts.map +0 -1
- package/dist/components/menubar.js +0 -57
- package/dist/components/native-select.d.ts +0 -10
- package/dist/components/native-select.d.ts.map +0 -1
- package/dist/components/native-select.js +0 -16
- package/dist/components/navigation-menu.d.ts +0 -21
- package/dist/components/navigation-menu.d.ts.map +0 -1
- package/dist/components/navigation-menu.js +0 -43
- package/dist/components/pagination.d.ts +0 -26
- package/dist/components/pagination.d.ts.map +0 -1
- package/dist/components/pagination.js +0 -29
- package/dist/components/popover.d.ts +0 -15
- package/dist/components/popover.d.ts.map +0 -1
- package/dist/components/popover.js +0 -23
- package/dist/components/progress-circle.d.ts +0 -107
- package/dist/components/progress-circle.d.ts.map +0 -1
- package/dist/components/progress-circle.js +0 -83
- package/dist/components/progress.d.ts +0 -7
- package/dist/components/progress.d.ts.map +0 -1
- package/dist/components/progress.js +0 -13
- package/dist/components/radio-cards.d.ts.map +0 -1
- package/dist/components/radio-cards.js +0 -15
- package/dist/components/radio-group.d.ts +0 -9
- package/dist/components/radio-group.d.ts.map +0 -1
- package/dist/components/radio-group.js +0 -14
- package/dist/components/radio.d.ts +0 -8
- package/dist/components/radio.d.ts.map +0 -1
- package/dist/components/radio.js +0 -11
- package/dist/components/resizable.d.ts +0 -13
- package/dist/components/resizable.d.ts.map +0 -1
- package/dist/components/resizable.js +0 -18
- package/dist/components/scroll-area.d.ts +0 -28
- package/dist/components/scroll-area.d.ts.map +0 -1
- package/dist/components/scroll-area.js +0 -77
- package/dist/components/select.d.ts +0 -29
- package/dist/components/select.d.ts.map +0 -1
- package/dist/components/select.js +0 -49
- package/dist/components/separator.d.ts +0 -23
- package/dist/components/separator.d.ts.map +0 -1
- package/dist/components/separator.js +0 -36
- package/dist/components/sheet.d.ts +0 -43
- package/dist/components/sheet.d.ts.map +0 -1
- package/dist/components/sheet.js +0 -90
- package/dist/components/sidebar.d.ts +0 -102
- package/dist/components/sidebar.d.ts.map +0 -1
- package/dist/components/sidebar.js +0 -241
- package/dist/components/skeleton.d.ts +0 -6
- package/dist/components/skeleton.d.ts.map +0 -1
- package/dist/components/skeleton.js +0 -9
- package/dist/components/slider.d.ts +0 -7
- package/dist/components/slider.d.ts.map +0 -1
- package/dist/components/slider.js +0 -18
- package/dist/components/sonner.d.ts +0 -8
- package/dist/components/sonner.d.ts.map +0 -1
- package/dist/components/sonner.js +0 -18
- package/dist/components/spinner.d.ts +0 -8
- package/dist/components/spinner.d.ts.map +0 -1
- package/dist/components/spinner.js +0 -27
- package/dist/components/switch.d.ts +0 -7
- package/dist/components/switch.d.ts.map +0 -1
- package/dist/components/switch.js +0 -11
- package/dist/components/table.d.ts +0 -20
- package/dist/components/table.d.ts.map +0 -1
- package/dist/components/table.js +0 -30
- package/dist/components/tabs.d.ts +0 -13
- package/dist/components/tabs.d.ts.map +0 -1
- package/dist/components/tabs.js +0 -20
- package/dist/components/textarea.d.ts +0 -6
- package/dist/components/textarea.d.ts.map +0 -1
- package/dist/components/textarea.js +0 -9
- package/dist/components/toggle-group.d.ts +0 -16
- package/dist/components/toggle-group.d.ts.map +0 -1
- package/dist/components/toggle-group.js +0 -35
- package/dist/components/toggle.d.ts +0 -21
- package/dist/components/toggle.d.ts.map +0 -1
- package/dist/components/toggle.js +0 -49
- package/dist/components/tooltip.d.ts +0 -15
- package/dist/components/tooltip.d.ts.map +0 -1
- package/dist/components/tooltip.js +0 -23
- package/dist/hooks/use-animated-value.d.ts.map +0 -1
- package/dist/hooks/use-animated-value.js +0 -71
- package/dist/hooks/use-copy-to-clipboard.d.ts.map +0 -1
- package/dist/hooks/use-copy-to-clipboard.js +0 -46
- package/dist/hooks/use-is-mobile.d.ts.map +0 -1
- package/dist/hooks/use-is-mobile.js +0 -23
- package/dist/hooks/use-media-query.d.ts.map +0 -1
- package/dist/hooks/use-media-query.js +0 -53
- package/dist/hooks/use-mutation-observer.d.ts.map +0 -1
- package/dist/hooks/use-mutation-observer.js +0 -40
- package/dist/hooks/use-pagination.d.ts +0 -37
- package/dist/hooks/use-pagination.d.ts.map +0 -1
- package/dist/hooks/use-pagination.js +0 -107
- package/dist/index.d.ts +0 -131
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -68
- package/dist/lib/utils.d.ts +0 -10
- package/dist/lib/utils.d.ts.map +0 -1
- package/dist/lib/utils.js +0 -10
- package/dist/primitives/checkbox-group.d.ts +0 -123
- package/dist/primitives/checkbox-group.d.ts.map +0 -1
- package/dist/primitives/checkbox-group.js +0 -112
- package/dist/primitives/input-number.d.ts +0 -63
- package/dist/primitives/input-number.d.ts.map +0 -1
- package/dist/primitives/input-number.js +0 -458
- package/dist/primitives/input.d.ts +0 -67
- package/dist/primitives/input.d.ts.map +0 -1
- package/dist/primitives/input.js +0 -76
- package/dist/primitives/progress-circle.d.ts +0 -116
- package/dist/primitives/progress-circle.d.ts.map +0 -1
- package/dist/primitives/progress-circle.js +0 -163
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { VariantProps } from "../lib/utils.mjs";
|
|
2
|
+
import { Separator } from "./separator.mjs";
|
|
3
|
+
import * as _$_codefast_tailwind_variants0 from "@codefast/tailwind-variants";
|
|
4
|
+
import { ComponentProps, JSX } from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/components/button-group.d.ts
|
|
7
|
+
declare const buttonGroupVariants: _$_codefast_tailwind_variants0.VariantFunctionType<{
|
|
8
|
+
orientation: {
|
|
9
|
+
horizontal: string[];
|
|
10
|
+
vertical: string[];
|
|
11
|
+
};
|
|
12
|
+
}, Record<string, never>>;
|
|
13
|
+
type ButtonGroupProps = ComponentProps<"div"> & VariantProps<typeof buttonGroupVariants>;
|
|
14
|
+
declare function ButtonGroup({
|
|
15
|
+
className,
|
|
16
|
+
orientation,
|
|
17
|
+
...props
|
|
18
|
+
}: ButtonGroupProps): JSX.Element;
|
|
19
|
+
interface ButtonGroupTextProps extends ComponentProps<"div"> {
|
|
20
|
+
asChild?: boolean;
|
|
21
|
+
}
|
|
22
|
+
declare function ButtonGroupText({
|
|
23
|
+
asChild,
|
|
24
|
+
className,
|
|
25
|
+
...props
|
|
26
|
+
}: ButtonGroupTextProps): JSX.Element;
|
|
27
|
+
type ButtonGroupSeparatorProps = ComponentProps<typeof Separator>;
|
|
28
|
+
declare function ButtonGroupSeparator({
|
|
29
|
+
className,
|
|
30
|
+
orientation,
|
|
31
|
+
...props
|
|
32
|
+
}: ButtonGroupSeparatorProps): JSX.Element;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { ButtonGroup, type ButtonGroupProps, ButtonGroupSeparator, type ButtonGroupSeparatorProps, ButtonGroupText, type ButtonGroupTextProps, buttonGroupVariants };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn, tv } from "../lib/utils.mjs";
|
|
3
|
+
import { Separator } from "./separator.mjs";
|
|
4
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/button-group.tsx
|
|
7
|
+
const buttonGroupVariants = tv({
|
|
8
|
+
base: [
|
|
9
|
+
"flex w-fit items-stretch",
|
|
10
|
+
"has-[>[data-slot=button-group]]:gap-2",
|
|
11
|
+
"[&>*]:focus-visible:relative [&>*]:focus-visible:z-10",
|
|
12
|
+
"has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-lg",
|
|
13
|
+
"[&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit",
|
|
14
|
+
"[&>input]:flex-1"
|
|
15
|
+
],
|
|
16
|
+
defaultVariants: { orientation: "horizontal" },
|
|
17
|
+
variants: { orientation: {
|
|
18
|
+
horizontal: ["[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0", "[&>*:not(:last-child)]:rounded-r-none"],
|
|
19
|
+
vertical: [
|
|
20
|
+
"flex-col",
|
|
21
|
+
"[&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0",
|
|
22
|
+
"[&>*:not(:last-child)]:rounded-b-none"
|
|
23
|
+
]
|
|
24
|
+
} }
|
|
25
|
+
});
|
|
26
|
+
function ButtonGroup({ className, orientation, ...props }) {
|
|
27
|
+
return /* @__PURE__ */ jsx("div", {
|
|
28
|
+
className: buttonGroupVariants({
|
|
29
|
+
orientation,
|
|
30
|
+
className
|
|
31
|
+
}),
|
|
32
|
+
"data-orientation": orientation,
|
|
33
|
+
"data-slot": "button-group",
|
|
34
|
+
role: "group",
|
|
35
|
+
...props
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function ButtonGroupText({ asChild = false, className, ...props }) {
|
|
39
|
+
return /* @__PURE__ */ jsx(asChild ? Slot : "div", {
|
|
40
|
+
className: cn("flex items-center gap-2", "px-4", "rounded-lg border", "bg-muted shadow-xs", "text-sm font-medium", "[&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4", className),
|
|
41
|
+
...props
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function ButtonGroupSeparator({ className, orientation = "vertical", ...props }) {
|
|
45
|
+
return /* @__PURE__ */ jsx(Separator, {
|
|
46
|
+
className: cn("relative self-stretch", "bg-input", "data-vertical:h-auto", "!m-0", className),
|
|
47
|
+
"data-slot": "button-group-separator",
|
|
48
|
+
orientation,
|
|
49
|
+
...props
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { ButtonGroup, ButtonGroupSeparator, ButtonGroupText, buttonGroupVariants };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { VariantProps } from "../lib/utils.mjs";
|
|
2
|
+
import * as _$_codefast_tailwind_variants0 from "@codefast/tailwind-variants";
|
|
3
|
+
import { ComponentProps, JSX } from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/button.d.ts
|
|
6
|
+
declare const buttonVariants: _$_codefast_tailwind_variants0.VariantFunctionType<{
|
|
7
|
+
size: {
|
|
8
|
+
"icon-sm": string;
|
|
9
|
+
icon: string;
|
|
10
|
+
"icon-lg": string;
|
|
11
|
+
sm: string[];
|
|
12
|
+
md: string[];
|
|
13
|
+
lg: string[];
|
|
14
|
+
};
|
|
15
|
+
variant: {
|
|
16
|
+
default: string[];
|
|
17
|
+
destructive: string[];
|
|
18
|
+
ghost: string[];
|
|
19
|
+
link: string[];
|
|
20
|
+
outline: string[];
|
|
21
|
+
secondary: string[];
|
|
22
|
+
};
|
|
23
|
+
}, Record<string, never>>;
|
|
24
|
+
type ButtonProps = ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
|
|
25
|
+
asChild?: boolean;
|
|
26
|
+
type?: ComponentProps<"button">["type"];
|
|
27
|
+
};
|
|
28
|
+
declare function Button({
|
|
29
|
+
asChild,
|
|
30
|
+
children,
|
|
31
|
+
className,
|
|
32
|
+
size,
|
|
33
|
+
type,
|
|
34
|
+
variant,
|
|
35
|
+
...props
|
|
36
|
+
}: ButtonProps): JSX.Element;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { Button, type ButtonProps, buttonVariants };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { tv } from "../lib/utils.mjs";
|
|
2
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/button.tsx
|
|
5
|
+
const buttonVariants = tv({
|
|
6
|
+
base: [
|
|
7
|
+
"inline-flex shrink-0 items-center justify-center gap-2",
|
|
8
|
+
"rounded-lg outline-hidden",
|
|
9
|
+
"text-sm font-medium whitespace-nowrap",
|
|
10
|
+
"transition select-none",
|
|
11
|
+
"focus-visible:ring-3",
|
|
12
|
+
"disabled:opacity-50",
|
|
13
|
+
"[&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
|
|
14
|
+
],
|
|
15
|
+
defaultVariants: {
|
|
16
|
+
size: "md",
|
|
17
|
+
variant: "default"
|
|
18
|
+
},
|
|
19
|
+
variants: {
|
|
20
|
+
size: {
|
|
21
|
+
"icon-sm": "size-8",
|
|
22
|
+
icon: "size-9",
|
|
23
|
+
"icon-lg": "size-10",
|
|
24
|
+
sm: ["h-8 px-3", "has-[>svg]:px-2.5"],
|
|
25
|
+
md: ["h-9 px-4", "has-[>svg]:px-3"],
|
|
26
|
+
lg: ["h-10 px-6", "has-[>svg]:px-4"]
|
|
27
|
+
},
|
|
28
|
+
variant: {
|
|
29
|
+
default: [
|
|
30
|
+
"bg-primary text-primary-foreground",
|
|
31
|
+
"hover:not-disabled:bg-primary/80",
|
|
32
|
+
"focus-visible:ring-primary/20",
|
|
33
|
+
"dark:focus-visible:ring-primary/40"
|
|
34
|
+
],
|
|
35
|
+
destructive: [
|
|
36
|
+
"bg-destructive text-white",
|
|
37
|
+
"hover:not-disabled:bg-destructive/90",
|
|
38
|
+
"focus-visible:ring-destructive/20",
|
|
39
|
+
"dark:bg-destructive/60",
|
|
40
|
+
"dark:focus-visible:ring-destructive/40"
|
|
41
|
+
],
|
|
42
|
+
ghost: [
|
|
43
|
+
"hover:not-disabled:bg-secondary hover:not-disabled:text-secondary-foreground",
|
|
44
|
+
"focus-visible:ring-ring/50",
|
|
45
|
+
"dark:hover:not-disabled:bg-secondary/50"
|
|
46
|
+
],
|
|
47
|
+
link: [
|
|
48
|
+
"text-primary underline-offset-4",
|
|
49
|
+
"hover:not-disabled:underline",
|
|
50
|
+
"focus-visible:ring-ring/50"
|
|
51
|
+
],
|
|
52
|
+
outline: [
|
|
53
|
+
"border border-input shadow-xs",
|
|
54
|
+
"hover:not-disabled:border-ring/60 hover:not-disabled:bg-secondary hover:not-disabled:text-secondary-foreground",
|
|
55
|
+
"focus-visible:border-ring focus-visible:ring-ring/50",
|
|
56
|
+
"aria-invalid:border-destructive",
|
|
57
|
+
"focus-within:aria-invalid:ring-destructive/20",
|
|
58
|
+
"hover:not-disabled:aria-invalid:border-destructive/60",
|
|
59
|
+
"dark:bg-input/30",
|
|
60
|
+
"dark:hover:not-disabled:bg-input/50",
|
|
61
|
+
"dark:aria-invalid:border-destructive/70",
|
|
62
|
+
"dark:focus-within:aria-invalid:ring-destructive/40"
|
|
63
|
+
],
|
|
64
|
+
secondary: [
|
|
65
|
+
"bg-secondary text-secondary-foreground",
|
|
66
|
+
"hover:not-disabled:bg-secondary/80",
|
|
67
|
+
"focus-visible:ring-ring/50"
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
function Button({ asChild = false, children, className, size, type = "button", variant, ...props }) {
|
|
73
|
+
const Comp = asChild ? Slot : "button";
|
|
74
|
+
if (asChild) return /* @__PURE__ */ jsx(Comp, {
|
|
75
|
+
className: buttonVariants({
|
|
76
|
+
className,
|
|
77
|
+
size,
|
|
78
|
+
variant
|
|
79
|
+
}),
|
|
80
|
+
"data-slot": "button",
|
|
81
|
+
"data-variant": variant,
|
|
82
|
+
...props,
|
|
83
|
+
children
|
|
84
|
+
});
|
|
85
|
+
return /* @__PURE__ */ jsx("button", {
|
|
86
|
+
className: buttonVariants({
|
|
87
|
+
className,
|
|
88
|
+
size,
|
|
89
|
+
variant
|
|
90
|
+
}),
|
|
91
|
+
"data-slot": "button",
|
|
92
|
+
"data-variant": variant,
|
|
93
|
+
type,
|
|
94
|
+
...props,
|
|
95
|
+
children
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
export { Button, buttonVariants };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Button } from "./button.mjs";
|
|
2
|
+
import { ComponentProps, JSX } from "react";
|
|
3
|
+
import { DayButton, DayPicker } from "react-day-picker";
|
|
4
|
+
|
|
5
|
+
//#region src/components/calendar.d.ts
|
|
6
|
+
type CalendarProps = ComponentProps<typeof DayPicker> & {
|
|
7
|
+
buttonVariant?: ComponentProps<typeof Button>["variant"];
|
|
8
|
+
};
|
|
9
|
+
declare function Calendar({
|
|
10
|
+
buttonVariant,
|
|
11
|
+
captionLayout,
|
|
12
|
+
className,
|
|
13
|
+
classNames,
|
|
14
|
+
components,
|
|
15
|
+
formatters,
|
|
16
|
+
showOutsideDays,
|
|
17
|
+
...props
|
|
18
|
+
}: CalendarProps): JSX.Element;
|
|
19
|
+
type CalendarDayButtonProps = ComponentProps<typeof DayButton>;
|
|
20
|
+
declare function CalendarDayButton({
|
|
21
|
+
className,
|
|
22
|
+
day,
|
|
23
|
+
modifiers,
|
|
24
|
+
...props
|
|
25
|
+
}: CalendarDayButtonProps): JSX.Element;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { Calendar, CalendarDayButton, type CalendarDayButtonProps, type CalendarProps };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/utils.mjs";
|
|
3
|
+
import { Button, buttonVariants } from "./button.mjs";
|
|
4
|
+
import { ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { useEffect, useRef } from "react";
|
|
7
|
+
import { DayPicker, getDefaultClassNames } from "react-day-picker";
|
|
8
|
+
//#region src/components/calendar.tsx
|
|
9
|
+
function Calendar({ buttonVariant = "ghost", captionLayout = "label", className, classNames, components, formatters, showOutsideDays = true, ...props }) {
|
|
10
|
+
const defaultClassNames = getDefaultClassNames();
|
|
11
|
+
return /* @__PURE__ */ jsx(DayPicker, {
|
|
12
|
+
captionLayout,
|
|
13
|
+
className: cn("group/calendar", "p-3", "bg-background", "in-data-[slot=card-content]:bg-transparent", "in-data-[slot=popover-content]:bg-transparent", "rtl:**:[.rdp-button_next>svg]:rotate-180", "rtl:**:[.rdp-button_previous>svg]:rotate-180", "[--cell-size:--spacing(8)]", className),
|
|
14
|
+
classNames: {
|
|
15
|
+
button_next: buttonVariants({
|
|
16
|
+
variant: buttonVariant,
|
|
17
|
+
className: ["size-(--cell-size) p-0 select-none aria-disabled:opacity-50", defaultClassNames.button_next]
|
|
18
|
+
}),
|
|
19
|
+
button_previous: buttonVariants({
|
|
20
|
+
variant: buttonVariant,
|
|
21
|
+
className: ["size-(--cell-size) p-0 select-none aria-disabled:opacity-50", defaultClassNames.button_previous]
|
|
22
|
+
}),
|
|
23
|
+
caption_label: cn("font-medium", "select-none", captionLayout === "label" ? "text-sm" : "flex h-8 items-center gap-1 rounded-md pr-1 pl-2 text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground", defaultClassNames.caption_label),
|
|
24
|
+
day: cn("group/day relative", "aspect-square h-full w-full p-0 text-center", "select-none", "[&:last-child[data-selected=true]_button]:rounded-r-md", props.showWeekNumber ? "[&:nth-child(2)[data-selected=true]_button]:rounded-l-md" : "[&:first-child[data-selected=true]_button]:rounded-l-md", defaultClassNames.day),
|
|
25
|
+
disabled: cn("opacity-50", "text-muted-foreground", defaultClassNames.disabled),
|
|
26
|
+
dropdown: cn("absolute inset-0", "bg-popover", "opacity-0", defaultClassNames.dropdown),
|
|
27
|
+
dropdown_root: cn("relative", "rounded-md border border-input shadow-xs", "has-focus:border-ring has-focus:ring-3 has-focus:ring-ring/50", defaultClassNames.dropdown_root),
|
|
28
|
+
dropdowns: cn("flex h-(--cell-size) w-full items-center justify-center gap-1.5", "text-sm font-medium", defaultClassNames.dropdowns),
|
|
29
|
+
hidden: cn("invisible", defaultClassNames.hidden),
|
|
30
|
+
month: cn("flex w-full flex-col gap-4", defaultClassNames.month),
|
|
31
|
+
month_caption: cn("flex h-(--cell-size) w-full items-center justify-center", "px-(--cell-size)", defaultClassNames.month_caption),
|
|
32
|
+
months: cn("relative flex flex-col gap-4", "md:flex-row", defaultClassNames.months),
|
|
33
|
+
nav: cn("absolute flex w-full items-center justify-between gap-1", "inset-x-0 top-0", defaultClassNames.nav),
|
|
34
|
+
outside: cn("text-muted-foreground", "aria-selected:text-muted-foreground", defaultClassNames.outside),
|
|
35
|
+
range_end: cn("rounded-r-md", "bg-accent", defaultClassNames.range_end),
|
|
36
|
+
range_middle: cn("rounded-none", defaultClassNames.range_middle),
|
|
37
|
+
range_start: cn("rounded-l-md", "bg-accent", defaultClassNames.range_start),
|
|
38
|
+
root: cn("w-fit", defaultClassNames.root),
|
|
39
|
+
table: "w-full border-collapse",
|
|
40
|
+
today: cn("rounded-md", "bg-accent text-accent-foreground", "data-selected:rounded-none", defaultClassNames.today),
|
|
41
|
+
week: cn("flex w-full", "mt-2", defaultClassNames.week),
|
|
42
|
+
week_number: cn("text-[0.8rem] text-muted-foreground", "select-none", defaultClassNames.week_number),
|
|
43
|
+
week_number_header: cn("w-(--cell-size)", "select-none", defaultClassNames.week_number_header),
|
|
44
|
+
weekday: cn("flex-1", "rounded-md", "text-[0.8rem] font-normal text-muted-foreground", "select-none", defaultClassNames.weekday),
|
|
45
|
+
weekdays: cn("flex", defaultClassNames.weekdays),
|
|
46
|
+
...classNames
|
|
47
|
+
},
|
|
48
|
+
components: {
|
|
49
|
+
Chevron: CalendarChevron,
|
|
50
|
+
DayButton: CalendarDayButton,
|
|
51
|
+
Root: CalendarRoot,
|
|
52
|
+
WeekNumber: CalendarWeekNumber,
|
|
53
|
+
...components
|
|
54
|
+
},
|
|
55
|
+
formatters: {
|
|
56
|
+
formatMonthDropdown: (date) => date.toLocaleString("default", { month: "short" }),
|
|
57
|
+
...formatters
|
|
58
|
+
},
|
|
59
|
+
showOutsideDays,
|
|
60
|
+
...props
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function CalendarChevron({ className, orientation, ...props }) {
|
|
64
|
+
if (orientation === "left") return /* @__PURE__ */ jsx(ChevronLeftIcon, {
|
|
65
|
+
className: cn("size-4", className),
|
|
66
|
+
...props
|
|
67
|
+
});
|
|
68
|
+
if (orientation === "right") return /* @__PURE__ */ jsx(ChevronRightIcon, {
|
|
69
|
+
className: cn("size-4", className),
|
|
70
|
+
...props
|
|
71
|
+
});
|
|
72
|
+
return /* @__PURE__ */ jsx(ChevronDownIcon, {
|
|
73
|
+
className: cn("size-4", className),
|
|
74
|
+
...props
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function CalendarRoot({ className, rootRef, ...props }) {
|
|
78
|
+
return /* @__PURE__ */ jsx("div", {
|
|
79
|
+
ref: rootRef,
|
|
80
|
+
className: cn(className),
|
|
81
|
+
"data-slot": "calendar",
|
|
82
|
+
...props
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function CalendarWeekNumber({ children, ...props }) {
|
|
86
|
+
return /* @__PURE__ */ jsx("td", {
|
|
87
|
+
...props,
|
|
88
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
89
|
+
className: cn("flex size-(--cell-size) items-center justify-center", "text-center"),
|
|
90
|
+
children
|
|
91
|
+
})
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function CalendarDayButton({ className, day, modifiers, ...props }) {
|
|
95
|
+
const defaultClassNames = getDefaultClassNames();
|
|
96
|
+
const ref = useRef(null);
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (modifiers.focused) ref.current?.focus();
|
|
99
|
+
}, [modifiers.focused]);
|
|
100
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
101
|
+
ref,
|
|
102
|
+
className: cn("flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal", "group-data-focused/day:relative group-data-focused/day:z-10 group-data-focused/day:border-ring group-data-focused/day:ring-3 group-data-focused/day:ring-ring/50", "data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground", "data-[range-middle=true]:rounded-none data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground", "data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground", "data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground", "dark:hover:text-accent-foreground", "[&>span]:text-xs [&>span]:opacity-70", defaultClassNames.day, className),
|
|
103
|
+
"data-day": day.date.toLocaleDateString(),
|
|
104
|
+
"data-range-end": modifiers.range_end,
|
|
105
|
+
"data-range-middle": modifiers.range_middle,
|
|
106
|
+
"data-range-start": modifiers.range_start,
|
|
107
|
+
"data-selected-single": modifiers.selected && !modifiers.range_start && !modifiers.range_end && !modifiers.range_middle,
|
|
108
|
+
size: "icon",
|
|
109
|
+
variant: "ghost",
|
|
110
|
+
...props
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
//#endregion
|
|
114
|
+
export { Calendar, CalendarDayButton };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ComponentProps, JSX } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/components/card.d.ts
|
|
4
|
+
type CardProps = ComponentProps<"div">;
|
|
5
|
+
declare function Card({
|
|
6
|
+
className,
|
|
7
|
+
...props
|
|
8
|
+
}: CardProps): JSX.Element;
|
|
9
|
+
type CardHeaderProps = ComponentProps<"div">;
|
|
10
|
+
declare function CardHeader({
|
|
11
|
+
className,
|
|
12
|
+
...props
|
|
13
|
+
}: CardHeaderProps): JSX.Element;
|
|
14
|
+
type CardTitleProps = ComponentProps<"div">;
|
|
15
|
+
declare function CardTitle({
|
|
16
|
+
children,
|
|
17
|
+
className,
|
|
18
|
+
...props
|
|
19
|
+
}: CardTitleProps): JSX.Element;
|
|
20
|
+
type CardDescriptionProps = ComponentProps<"div">;
|
|
21
|
+
declare function CardDescription({
|
|
22
|
+
className,
|
|
23
|
+
...props
|
|
24
|
+
}: CardDescriptionProps): JSX.Element;
|
|
25
|
+
type CardContentProps = ComponentProps<"div">;
|
|
26
|
+
declare function CardContent({
|
|
27
|
+
className,
|
|
28
|
+
...props
|
|
29
|
+
}: CardContentProps): JSX.Element;
|
|
30
|
+
type CardFooterProps = ComponentProps<"div">;
|
|
31
|
+
declare function CardFooter({
|
|
32
|
+
className,
|
|
33
|
+
...props
|
|
34
|
+
}: CardFooterProps): JSX.Element;
|
|
35
|
+
type CardActionProps = ComponentProps<"div">;
|
|
36
|
+
declare function CardAction({
|
|
37
|
+
className,
|
|
38
|
+
...props
|
|
39
|
+
}: CardActionProps): JSX.Element;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { Card, CardAction, type CardActionProps, CardContent, type CardContentProps, CardDescription, type CardDescriptionProps, CardFooter, type CardFooterProps, CardHeader, type CardHeaderProps, type CardProps, CardTitle, type CardTitleProps };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { cn } from "../lib/utils.mjs";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/card.tsx
|
|
4
|
+
function Card({ className, ...props }) {
|
|
5
|
+
return /* @__PURE__ */ jsx("div", {
|
|
6
|
+
className: cn("flex flex-col gap-6 overflow-auto py-6", "rounded-xl border", "bg-card text-card-foreground shadow-sm", className),
|
|
7
|
+
"data-slot": "card",
|
|
8
|
+
...props
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
function CardHeader({ className, ...props }) {
|
|
12
|
+
return /* @__PURE__ */ jsx("div", {
|
|
13
|
+
className: cn("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5", "px-6", "has-[data-slot=card-action]:grid-cols-[1fr_auto]", "[.border-b]:pb-6", className),
|
|
14
|
+
"data-slot": "card-header",
|
|
15
|
+
...props
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function CardTitle({ children, className, ...props }) {
|
|
19
|
+
return /* @__PURE__ */ jsx("div", {
|
|
20
|
+
className: cn("leading-none font-semibold", className),
|
|
21
|
+
"data-slot": "card-title",
|
|
22
|
+
...props,
|
|
23
|
+
children
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function CardDescription({ className, ...props }) {
|
|
27
|
+
return /* @__PURE__ */ jsx("div", {
|
|
28
|
+
className: cn("text-sm text-muted-foreground", className),
|
|
29
|
+
"data-slot": "card-description",
|
|
30
|
+
...props
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function CardContent({ className, ...props }) {
|
|
34
|
+
return /* @__PURE__ */ jsx("div", {
|
|
35
|
+
className: cn("px-6", className),
|
|
36
|
+
"data-slot": "card-content",
|
|
37
|
+
...props
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function CardFooter({ className, ...props }) {
|
|
41
|
+
return /* @__PURE__ */ jsx("div", {
|
|
42
|
+
className: cn("flex items-center", "px-6", "[.border-t]:pt-6", className),
|
|
43
|
+
"data-slot": "card-footer",
|
|
44
|
+
...props
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function CardAction({ className, ...props }) {
|
|
48
|
+
return /* @__PURE__ */ jsx("div", {
|
|
49
|
+
className: cn("col-start-2 row-span-2 row-start-1 self-start justify-self-end", className),
|
|
50
|
+
"data-slot": "card-action",
|
|
51
|
+
...props
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Button } from "./button.mjs";
|
|
2
|
+
import { ComponentProps, JSX } from "react";
|
|
3
|
+
import * as _$_radix_ui_react_context0 from "@radix-ui/react-context";
|
|
4
|
+
import { Scope } from "@radix-ui/react-context";
|
|
5
|
+
import useEmblaCarousel, { UseEmblaCarouselType } from "embla-carousel-react";
|
|
6
|
+
|
|
7
|
+
//#region src/components/carousel.d.ts
|
|
8
|
+
type ScopedProps<P> = P & {
|
|
9
|
+
__scopeCarousel?: Scope;
|
|
10
|
+
};
|
|
11
|
+
declare const createCarouselScope: _$_radix_ui_react_context0.CreateScope;
|
|
12
|
+
type CarouselApi = UseEmblaCarouselType[1];
|
|
13
|
+
type UseCarouselParameters = Parameters<typeof useEmblaCarousel>;
|
|
14
|
+
type CarouselOptions = UseCarouselParameters[0];
|
|
15
|
+
type CarouselPlugin = UseCarouselParameters[1];
|
|
16
|
+
interface BaseCarouselProps {
|
|
17
|
+
opts?: CarouselOptions;
|
|
18
|
+
orientation?: "horizontal" | "vertical";
|
|
19
|
+
plugins?: CarouselPlugin;
|
|
20
|
+
setApi?: (api: CarouselApi) => void;
|
|
21
|
+
}
|
|
22
|
+
interface CarouselProps extends BaseCarouselProps, ComponentProps<"div"> {}
|
|
23
|
+
declare function Carousel({
|
|
24
|
+
__scopeCarousel,
|
|
25
|
+
children,
|
|
26
|
+
className,
|
|
27
|
+
opts,
|
|
28
|
+
orientation,
|
|
29
|
+
plugins,
|
|
30
|
+
setApi,
|
|
31
|
+
...props
|
|
32
|
+
}: ScopedProps<CarouselProps>): JSX.Element;
|
|
33
|
+
interface CarouselContentProps extends ComponentProps<"div"> {
|
|
34
|
+
classNames?: {
|
|
35
|
+
content?: string;
|
|
36
|
+
wrapper?: string;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
declare function CarouselContent({
|
|
40
|
+
__scopeCarousel,
|
|
41
|
+
className,
|
|
42
|
+
classNames,
|
|
43
|
+
...props
|
|
44
|
+
}: ScopedProps<CarouselContentProps>): JSX.Element;
|
|
45
|
+
type CarouselItemProps = ComponentProps<"div">;
|
|
46
|
+
declare function CarouselItem({
|
|
47
|
+
__scopeCarousel,
|
|
48
|
+
className,
|
|
49
|
+
...props
|
|
50
|
+
}: ScopedProps<CarouselItemProps>): JSX.Element;
|
|
51
|
+
type CarouselPreviousProps = ComponentProps<typeof Button>;
|
|
52
|
+
declare function CarouselPrevious({
|
|
53
|
+
__scopeCarousel,
|
|
54
|
+
className,
|
|
55
|
+
size,
|
|
56
|
+
variant,
|
|
57
|
+
...props
|
|
58
|
+
}: ScopedProps<CarouselPreviousProps>): JSX.Element;
|
|
59
|
+
type CarouselNextProps = ComponentProps<typeof Button>;
|
|
60
|
+
declare function CarouselNext({
|
|
61
|
+
__scopeCarousel,
|
|
62
|
+
className,
|
|
63
|
+
size,
|
|
64
|
+
variant,
|
|
65
|
+
...props
|
|
66
|
+
}: ScopedProps<CarouselNextProps>): JSX.Element;
|
|
67
|
+
//#endregion
|
|
68
|
+
export { Carousel, type CarouselApi, CarouselContent, type CarouselContentProps, CarouselItem, type CarouselItemProps, CarouselNext, type CarouselNextProps, CarouselPrevious, type CarouselPreviousProps, type CarouselProps, createCarouselScope };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/utils.mjs";
|
|
3
|
+
import { Button } from "./button.mjs";
|
|
4
|
+
import { ArrowLeftIcon, ArrowRightIcon } from "lucide-react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { useCallback, useEffect, useState } from "react";
|
|
7
|
+
import { createContextScope } from "@radix-ui/react-context";
|
|
8
|
+
import useEmblaCarousel from "embla-carousel-react";
|
|
9
|
+
//#region src/components/carousel.tsx
|
|
10
|
+
const CAROUSEL_NAME = "Carousel";
|
|
11
|
+
const [createCarouselContext, createCarouselScope] = createContextScope(CAROUSEL_NAME);
|
|
12
|
+
const [CarouselContextProvider, useCarouselContext] = createCarouselContext(CAROUSEL_NAME);
|
|
13
|
+
function Carousel({ __scopeCarousel, children, className, opts, orientation, plugins, setApi, ...props }) {
|
|
14
|
+
const [carouselRef, api] = useEmblaCarousel({
|
|
15
|
+
...opts,
|
|
16
|
+
axis: orientation === "vertical" ? "y" : "x"
|
|
17
|
+
}, plugins);
|
|
18
|
+
const [canScrollPrevious, setCanScrollPrevious] = useState(false);
|
|
19
|
+
const [canScrollNext, setCanScrollNext] = useState(false);
|
|
20
|
+
const onSelect = useCallback((carouselApi) => {
|
|
21
|
+
if (!carouselApi) return;
|
|
22
|
+
setCanScrollPrevious(carouselApi.canScrollPrev());
|
|
23
|
+
setCanScrollNext(carouselApi.canScrollNext());
|
|
24
|
+
}, []);
|
|
25
|
+
const scrollPrevious = useCallback(() => {
|
|
26
|
+
api?.scrollPrev();
|
|
27
|
+
}, [api]);
|
|
28
|
+
const scrollNext = useCallback(() => {
|
|
29
|
+
api?.scrollNext();
|
|
30
|
+
}, [api]);
|
|
31
|
+
const handleKeyDown = useCallback((event) => {
|
|
32
|
+
if (event.key === "ArrowLeft") {
|
|
33
|
+
event.preventDefault();
|
|
34
|
+
scrollPrevious();
|
|
35
|
+
} else if (event.key === "ArrowRight") {
|
|
36
|
+
event.preventDefault();
|
|
37
|
+
scrollNext();
|
|
38
|
+
}
|
|
39
|
+
}, [scrollPrevious, scrollNext]);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (!api || !setApi) return;
|
|
42
|
+
setApi(api);
|
|
43
|
+
}, [api, setApi]);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (!api) return;
|
|
46
|
+
queueMicrotask(() => {
|
|
47
|
+
onSelect(api);
|
|
48
|
+
});
|
|
49
|
+
api.on("reInit", onSelect);
|
|
50
|
+
api.on("select", onSelect);
|
|
51
|
+
return () => {
|
|
52
|
+
api.off("select", onSelect);
|
|
53
|
+
};
|
|
54
|
+
}, [api, onSelect]);
|
|
55
|
+
return /* @__PURE__ */ jsx(CarouselContextProvider, {
|
|
56
|
+
api,
|
|
57
|
+
canScrollNext,
|
|
58
|
+
canScrollPrev: canScrollPrevious,
|
|
59
|
+
carouselRef,
|
|
60
|
+
opts,
|
|
61
|
+
orientation: orientation ?? (opts?.axis === "y" ? "vertical" : "horizontal"),
|
|
62
|
+
scope: __scopeCarousel,
|
|
63
|
+
scrollNext,
|
|
64
|
+
scrollPrev: scrollPrevious,
|
|
65
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
66
|
+
className: cn("relative", className),
|
|
67
|
+
"data-slot": "carousel",
|
|
68
|
+
onKeyDownCapture: handleKeyDown,
|
|
69
|
+
...props,
|
|
70
|
+
children
|
|
71
|
+
})
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
const CAROUSEL_CONTENT_NAME = "CarouselContent";
|
|
75
|
+
function CarouselContent({ __scopeCarousel, className, classNames, ...props }) {
|
|
76
|
+
const { carouselRef, orientation } = useCarouselContext(CAROUSEL_CONTENT_NAME, __scopeCarousel);
|
|
77
|
+
return /* @__PURE__ */ jsx("div", {
|
|
78
|
+
ref: carouselRef,
|
|
79
|
+
className: cn("overflow-hidden", classNames?.wrapper),
|
|
80
|
+
"data-slot": "carousel-content",
|
|
81
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
82
|
+
className: cn("flex", orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col", classNames?.content, className),
|
|
83
|
+
...props
|
|
84
|
+
})
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const CAROUSEL_ITEM_NAME = "CarouselItem";
|
|
88
|
+
function CarouselItem({ __scopeCarousel, className, ...props }) {
|
|
89
|
+
const { orientation } = useCarouselContext(CAROUSEL_ITEM_NAME, __scopeCarousel);
|
|
90
|
+
return /* @__PURE__ */ jsx("div", {
|
|
91
|
+
"aria-roledescription": "slide",
|
|
92
|
+
className: cn("min-w-0 shrink-0 grow-0 basis-full", orientation === "horizontal" ? "pl-4" : "pt-4", className),
|
|
93
|
+
"data-slot": "carousel-item",
|
|
94
|
+
role: "group",
|
|
95
|
+
...props
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
const CAROUSEL_PREVIOUS_NAME = "CarouselPrevious";
|
|
99
|
+
function CarouselPrevious({ __scopeCarousel, className, size = "icon", variant = "outline", ...props }) {
|
|
100
|
+
const { canScrollPrev, orientation, scrollPrev } = useCarouselContext(CAROUSEL_PREVIOUS_NAME, __scopeCarousel);
|
|
101
|
+
return /* @__PURE__ */ jsxs(Button, {
|
|
102
|
+
"aria-label": "Previous slide",
|
|
103
|
+
className: cn("absolute", "size-8", "shadow-none", orientation === "horizontal" ? "top-1/2 -left-12 -translate-y-1/2" : "-top-12 left-1/2 -translate-x-1/2 rotate-90", className),
|
|
104
|
+
"data-slot": "carousel-previous",
|
|
105
|
+
disabled: !canScrollPrev,
|
|
106
|
+
size,
|
|
107
|
+
variant,
|
|
108
|
+
onClick: scrollPrev,
|
|
109
|
+
...props,
|
|
110
|
+
children: [/* @__PURE__ */ jsx(ArrowLeftIcon, {}), /* @__PURE__ */ jsx("span", {
|
|
111
|
+
className: "sr-only",
|
|
112
|
+
children: "Previous slide"
|
|
113
|
+
})]
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
const CAROUSEL_NEXT_NAME = "CarouselNext";
|
|
117
|
+
function CarouselNext({ __scopeCarousel, className, size = "icon", variant = "outline", ...props }) {
|
|
118
|
+
const { canScrollNext, orientation, scrollNext } = useCarouselContext(CAROUSEL_NEXT_NAME, __scopeCarousel);
|
|
119
|
+
return /* @__PURE__ */ jsxs(Button, {
|
|
120
|
+
"aria-label": "Next slide",
|
|
121
|
+
className: cn("absolute", "size-8", "shadow-none", orientation === "horizontal" ? "top-1/2 -right-12 -translate-y-1/2" : "-bottom-12 left-1/2 -translate-x-1/2 rotate-90", className),
|
|
122
|
+
"data-slot": "carousel-next",
|
|
123
|
+
disabled: !canScrollNext,
|
|
124
|
+
size,
|
|
125
|
+
variant,
|
|
126
|
+
onClick: scrollNext,
|
|
127
|
+
...props,
|
|
128
|
+
children: [/* @__PURE__ */ jsx(ArrowRightIcon, {}), /* @__PURE__ */ jsx("span", {
|
|
129
|
+
className: "sr-only",
|
|
130
|
+
children: "Next slide"
|
|
131
|
+
})]
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
//#endregion
|
|
135
|
+
export { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, createCarouselScope };
|