@mbao01/common 0.0.17 → 0.0.19
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/types/components/Accordion/Accordion.d.ts +10 -0
- package/dist/types/components/Accordion/constants.d.ts +3 -0
- package/dist/types/components/Accordion/index.d.ts +1 -0
- package/dist/types/components/Accordion/types.d.ts +6 -0
- package/dist/types/components/Avatar/constants.d.ts +2 -2
- package/dist/types/components/Carousel/Carousel.d.ts +27 -0
- package/dist/types/components/Carousel/CarouselContext.d.ts +3 -0
- package/dist/types/components/Carousel/constants.d.ts +12 -0
- package/dist/types/components/Carousel/index.d.ts +1 -0
- package/dist/types/components/Carousel/types.d.ts +21 -0
- package/dist/types/components/Carousel/useCarousel.d.ts +1 -0
- package/dist/types/components/Collapsible/Collapsible.d.ts +9 -0
- package/dist/types/components/Collapsible/index.d.ts +1 -0
- package/dist/types/components/Collapsible/types.d.ts +3 -0
- package/dist/types/components/HoverCard/HoverCard.d.ts +9 -0
- package/dist/types/components/HoverCard/constants.d.ts +1 -0
- package/dist/types/components/HoverCard/index.d.ts +1 -0
- package/dist/types/components/HoverCard/types.d.ts +3 -0
- package/dist/types/components/Skeleton/constants.d.ts +2 -2
- package/dist/types/components/Toggle/Toggle.d.ts +12 -0
- package/dist/types/components/Toggle/constants.d.ts +3 -0
- package/dist/types/components/Toggle/index.d.ts +1 -0
- package/dist/types/components/Toggle/types.d.ts +7 -0
- package/dist/types/components/ToggleGroup/ToggleGroup.d.ts +16 -0
- package/dist/types/components/ToggleGroup/constants.d.ts +1 -0
- package/dist/types/components/ToggleGroup/index.d.ts +1 -0
- package/dist/types/components/ToggleGroup/types.d.ts +6 -0
- package/dist/types/index.d.ts +6 -1
- package/package.json +8 -2
- package/src/components/Accordion/Accordion.tsx +68 -0
- package/src/components/Accordion/constants.ts +11 -0
- package/src/components/Accordion/index.ts +1 -0
- package/src/components/Accordion/types.ts +17 -0
- package/src/components/Carousel/Carousel.tsx +204 -0
- package/src/components/Carousel/CarouselContext.ts +4 -0
- package/src/components/Carousel/constants.ts +58 -0
- package/src/components/Carousel/index.ts +1 -0
- package/src/components/Carousel/types.ts +24 -0
- package/src/components/Carousel/useCarousel.ts +12 -0
- package/src/components/Collapsible/Collapsible.tsx +13 -0
- package/src/components/Collapsible/index.ts +1 -0
- package/src/components/Collapsible/types.ts +5 -0
- package/src/components/HoverCard/HoverCard.tsx +30 -0
- package/src/components/HoverCard/constants.ts +5 -0
- package/src/components/HoverCard/index.ts +1 -0
- package/src/components/HoverCard/types.ts +5 -0
- package/src/components/Toggle/Toggle.tsx +27 -0
- package/src/components/Toggle/constants.ts +21 -0
- package/src/components/Toggle/index.ts +1 -0
- package/src/components/Toggle/types.ts +15 -0
- package/src/components/ToggleGroup/ToggleGroup.tsx +62 -0
- package/src/components/ToggleGroup/constants.ts +5 -0
- package/src/components/ToggleGroup/index.ts +1 -0
- package/src/components/ToggleGroup/types.ts +14 -0
- package/src/index.ts +6 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
3
|
+
import type { AccordionProps } from "./types";
|
|
4
|
+
declare const Accordion: {
|
|
5
|
+
(props: AccordionProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
Item: React.ForwardRefExoticComponent<Omit<AccordionPrimitive.AccordionItemProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
7
|
+
Trigger: React.ForwardRefExoticComponent<Omit<AccordionPrimitive.AccordionTriggerProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
8
|
+
Content: React.ForwardRefExoticComponent<Omit<AccordionPrimitive.AccordionContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
9
|
+
};
|
|
10
|
+
export { Accordion };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const getAccordionItemClasses: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
2
|
+
export declare const getAccordionTriggerClasses: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
3
|
+
export declare const getAccordionContentClasses: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Accordion } from "./Accordion";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
3
|
+
export type AccordionProps = React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Root>;
|
|
4
|
+
export type AccordionContentProps = React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>;
|
|
5
|
+
export type AccordionItemProps = React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>;
|
|
6
|
+
export type AccordionTriggerProps = React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const getAvatarClasses: (props?: ({
|
|
2
|
-
size?: 4 | 8 | 12 |
|
|
2
|
+
size?: 16 | 4 | 8 | 12 | 24 | 32 | 48 | 64 | null | undefined;
|
|
3
3
|
status?: "online" | "offline" | null | undefined;
|
|
4
4
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
5
5
|
export declare const getAvatarImageClasses: (props?: ({
|
|
@@ -8,7 +8,7 @@ export declare const getAvatarImageClasses: (props?: ({
|
|
|
8
8
|
ring?: boolean | null | undefined;
|
|
9
9
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
10
10
|
export declare const getAvatarFallbackClasses: (props?: ({
|
|
11
|
-
size?: 4 | 8 | 12 |
|
|
11
|
+
size?: 16 | 4 | 8 | 12 | 24 | 32 | 48 | 64 | null | undefined;
|
|
12
12
|
variant?: "accent" | "default" | "error" | "ghost" | "info" | "neutral" | "primary" | "secondary" | "success" | "warning" | null | undefined;
|
|
13
13
|
shape?: "circle" | "round" | "hexagon" | "triangle" | "television" | null | undefined;
|
|
14
14
|
ring?: boolean | null | undefined;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { CarouselProps } from "./types";
|
|
3
|
+
declare const Carousel: {
|
|
4
|
+
({ orientation, opts, setApi, plugins, className, children, ...props }: CarouselProps & React.HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
displayName: string;
|
|
6
|
+
Content: import("react").ForwardRefExoticComponent<import("react").HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
|
|
7
|
+
Item: import("react").ForwardRefExoticComponent<import("react").HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
|
|
8
|
+
Next: import("react").ForwardRefExoticComponent<Omit<import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
9
|
+
variant?: "accent" | "default" | "error" | "ghost" | "info" | "link" | "neutral" | "primary" | "secondary" | "success" | "warning" | undefined;
|
|
10
|
+
outline?: boolean | undefined;
|
|
11
|
+
wide?: boolean | undefined;
|
|
12
|
+
size?: "xs" | "sm" | "md" | "lg" | undefined;
|
|
13
|
+
isLoading?: boolean | undefined;
|
|
14
|
+
} & {
|
|
15
|
+
as?: "a" | "span" | "p" | undefined;
|
|
16
|
+
} & import("react").RefAttributes<HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
17
|
+
Previous: import("react").ForwardRefExoticComponent<Omit<import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
18
|
+
variant?: "accent" | "default" | "error" | "ghost" | "info" | "link" | "neutral" | "primary" | "secondary" | "success" | "warning" | undefined;
|
|
19
|
+
outline?: boolean | undefined;
|
|
20
|
+
wide?: boolean | undefined;
|
|
21
|
+
size?: "xs" | "sm" | "md" | "lg" | undefined;
|
|
22
|
+
isLoading?: boolean | undefined;
|
|
23
|
+
} & {
|
|
24
|
+
as?: "a" | "span" | "p" | undefined;
|
|
25
|
+
} & import("react").RefAttributes<HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
26
|
+
};
|
|
27
|
+
export { Carousel };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const getCarouselContentClasses: (props?: ({
|
|
2
|
+
orientation?: "horizontal" | "vertical" | null | undefined;
|
|
3
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
4
|
+
export declare const getCarouselItemClasses: (props?: ({
|
|
5
|
+
orientation?: "horizontal" | "vertical" | null | undefined;
|
|
6
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
|
+
export declare const getCarouselNextClasses: (props?: ({
|
|
8
|
+
orientation?: "horizontal" | "vertical" | null | undefined;
|
|
9
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
10
|
+
export declare const getCarouselPreviousClasses: (props?: ({
|
|
11
|
+
orientation?: "horizontal" | "vertical" | null | undefined;
|
|
12
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Carousel } from "./Carousel";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type UseEmblaCarouselType } from "embla-carousel-react";
|
|
2
|
+
import useEmblaCarousel from "embla-carousel-react";
|
|
3
|
+
type UseCarouselParameters = Parameters<typeof useEmblaCarousel>;
|
|
4
|
+
type CarouselOptions = UseCarouselParameters[0];
|
|
5
|
+
type CarouselPlugin = UseCarouselParameters[1];
|
|
6
|
+
export type CarouselApi = UseEmblaCarouselType[1];
|
|
7
|
+
export type CarouselProps = {
|
|
8
|
+
opts?: CarouselOptions;
|
|
9
|
+
plugins?: CarouselPlugin;
|
|
10
|
+
orientation?: "horizontal" | "vertical";
|
|
11
|
+
setApi?: (api: CarouselApi) => void;
|
|
12
|
+
};
|
|
13
|
+
export type CarouselContextProps = {
|
|
14
|
+
carouselRef: ReturnType<typeof useEmblaCarousel>[0];
|
|
15
|
+
api: ReturnType<typeof useEmblaCarousel>[1];
|
|
16
|
+
scrollPrev: () => void;
|
|
17
|
+
scrollNext: () => void;
|
|
18
|
+
canScrollPrev: boolean;
|
|
19
|
+
canScrollNext: boolean;
|
|
20
|
+
} & CarouselProps;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useCarousel(): import("./types").CarouselContextProps;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
|
|
3
|
+
import { type CollapsibleProps } from "@radix-ui/react-accordion";
|
|
4
|
+
declare const Collapsible: {
|
|
5
|
+
(props: CollapsibleProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
Trigger: import("react").ForwardRefExoticComponent<CollapsiblePrimitive.CollapsibleTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
7
|
+
Content: import("react").ForwardRefExoticComponent<CollapsiblePrimitive.CollapsibleContentProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
8
|
+
};
|
|
9
|
+
export { Collapsible };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Collapsible } from "./Collapsible";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import * as HoverCardPrimitive from "@radix-ui/react-hover-card";
|
|
3
|
+
import { HoverCardProps } from "./types";
|
|
4
|
+
declare const HoverCard: {
|
|
5
|
+
(props: HoverCardProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
Content: import("react").ForwardRefExoticComponent<Omit<HoverCardPrimitive.HoverCardContentProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
7
|
+
Trigger: import("react").ForwardRefExoticComponent<HoverCardPrimitive.HoverCardTriggerProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
8
|
+
};
|
|
9
|
+
export { HoverCard };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getHoverCardContentClasses: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { HoverCard } from "./HoverCard";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const getSkeletonClasses: (props?: ({
|
|
2
2
|
variant?: "pulse" | null | undefined;
|
|
3
|
-
width?: 4 | 8 | 12 |
|
|
4
|
-
height?: 4 | 8 | 12 |
|
|
3
|
+
width?: 16 | 2 | 4 | 8 | 12 | 24 | 32 | 48 | 64 | "full" | null | undefined;
|
|
4
|
+
height?: 16 | 2 | 4 | 8 | 12 | 24 | 32 | 48 | 64 | "full" | null | undefined;
|
|
5
5
|
round?: boolean | null | undefined;
|
|
6
6
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as TogglePrimitive from "@radix-ui/react-toggle";
|
|
3
|
+
declare const Toggle: React.ForwardRefExoticComponent<Omit<TogglePrimitive.ToggleProps & React.RefAttributes<HTMLButtonElement>, "ref"> & Omit<{
|
|
4
|
+
variant?: "accent" | "default" | "error" | "ghost" | "info" | "link" | "neutral" | "primary" | "secondary" | "success" | "warning" | undefined;
|
|
5
|
+
outline?: boolean | undefined;
|
|
6
|
+
wide?: boolean | undefined;
|
|
7
|
+
size?: "xs" | "sm" | "md" | "lg" | undefined;
|
|
8
|
+
isLoading?: boolean | undefined;
|
|
9
|
+
}, "variant" | "isLoading"> & {
|
|
10
|
+
variant?: "accent" | "default" | "error" | "info" | "link" | "neutral" | "primary" | "secondary" | "success" | "warning" | undefined;
|
|
11
|
+
} & React.RefAttributes<HTMLButtonElement>>;
|
|
12
|
+
export { Toggle };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Toggle } from "./Toggle";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import * as TogglePrimitive from "@radix-ui/react-toggle";
|
|
3
|
+
import { type VariantProps } from "../../libs";
|
|
4
|
+
import { getButtonClasses } from "../Button/constants";
|
|
5
|
+
import { getToggleClasses } from "./constants";
|
|
6
|
+
export type BaseToggleProps = Omit<VariantProps<typeof getButtonClasses>, "variant" | "isLoading"> & VariantProps<typeof getToggleClasses>;
|
|
7
|
+
export type ToggleProps = React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root> & BaseToggleProps;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group";
|
|
3
|
+
import type { ToggleGroupProps } from "./types";
|
|
4
|
+
declare const ToggleGroup: {
|
|
5
|
+
({ className, variant, children, ...props }: ToggleGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
Item: import("react").ForwardRefExoticComponent<Omit<ToggleGroupPrimitive.ToggleGroupItemProps & import("react").RefAttributes<HTMLButtonElement>, "ref"> & Omit<{
|
|
7
|
+
variant?: "accent" | "default" | "error" | "ghost" | "info" | "link" | "neutral" | "primary" | "secondary" | "success" | "warning" | undefined;
|
|
8
|
+
outline?: boolean | undefined;
|
|
9
|
+
wide?: boolean | undefined;
|
|
10
|
+
size?: "xs" | "sm" | "md" | "lg" | undefined;
|
|
11
|
+
isLoading?: boolean | undefined;
|
|
12
|
+
}, "variant" | "isLoading"> & {
|
|
13
|
+
variant?: "accent" | "default" | "error" | "info" | "link" | "neutral" | "primary" | "secondary" | "success" | "warning" | undefined;
|
|
14
|
+
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
15
|
+
};
|
|
16
|
+
export { ToggleGroup };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getToggleGroupClasses: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ToggleGroup } from "./ToggleGroup";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group";
|
|
3
|
+
import { BaseToggleProps } from "../Toggle/types";
|
|
4
|
+
export type ToggleGroupProps = React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Root> & Pick<BaseToggleProps, "variant">;
|
|
5
|
+
export type ToggleGroupItemProps = React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Item> & BaseToggleProps;
|
|
6
|
+
export type ToggleGroupContextType = Pick<BaseToggleProps, "variant">;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
/** actions */
|
|
2
2
|
export * from "./components/Button";
|
|
3
3
|
export * from "./components/Breadcrumbs";
|
|
4
|
+
export * from "./components/Toggle";
|
|
5
|
+
export * from "./components/ToggleGroup";
|
|
4
6
|
/** data display */
|
|
7
|
+
export * from "./components/Accordion";
|
|
5
8
|
export * from "./components/Alert";
|
|
6
9
|
export * from "./components/Avatar";
|
|
7
10
|
export * from "./components/Badge";
|
|
8
11
|
export * from "./components/Card";
|
|
9
12
|
export * from "./components/Calendar";
|
|
13
|
+
export * from "./components/Collapsible";
|
|
10
14
|
export * from "./components/Description";
|
|
11
15
|
export * from "./components/Progress";
|
|
12
16
|
export * from "./components/Separator";
|
|
@@ -23,6 +27,7 @@ export * from "./components/Skeleton";
|
|
|
23
27
|
export * from "./components/Tooltip";
|
|
24
28
|
/** composable */
|
|
25
29
|
export * from "./components/AlertDialog";
|
|
26
|
-
export * from "./components/Dialog";
|
|
27
30
|
export * from "./components/Command";
|
|
31
|
+
export * from "./components/Dialog";
|
|
32
|
+
export * from "./components/HoverCard";
|
|
28
33
|
export * from "./components/Popover";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mbao01/common",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.19",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Ayomide Bakare",
|
|
7
7
|
"license": "MIT",
|
|
@@ -60,10 +60,13 @@
|
|
|
60
60
|
"test:coverage": "vitest run --coverage"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
+
"@radix-ui/react-accordion": "^1.1.2",
|
|
63
64
|
"@radix-ui/react-alert-dialog": "^1.0.5",
|
|
64
65
|
"@radix-ui/react-avatar": "^1.0.4",
|
|
65
66
|
"@radix-ui/react-checkbox": "^1.0.4",
|
|
67
|
+
"@radix-ui/react-collapsible": "^1.0.3",
|
|
66
68
|
"@radix-ui/react-dialog": "^1.0.5",
|
|
69
|
+
"@radix-ui/react-hover-card": "^1.0.7",
|
|
67
70
|
"@radix-ui/react-icons": "^1.3.0",
|
|
68
71
|
"@radix-ui/react-label": "^2.0.2",
|
|
69
72
|
"@radix-ui/react-popover": "^1.0.7",
|
|
@@ -73,12 +76,15 @@
|
|
|
73
76
|
"@radix-ui/react-slider": "^1.1.2",
|
|
74
77
|
"@radix-ui/react-slot": "^1.0.2",
|
|
75
78
|
"@radix-ui/react-tabs": "^1.0.4",
|
|
79
|
+
"@radix-ui/react-toggle": "^1.0.3",
|
|
80
|
+
"@radix-ui/react-toggle-group": "^1.0.4",
|
|
76
81
|
"@radix-ui/react-tooltip": "^1.0.7",
|
|
77
82
|
"class-variance-authority": "^0.7.0",
|
|
78
83
|
"clsx": "^2.1.0",
|
|
79
84
|
"cmdk": "^1.0.0",
|
|
80
85
|
"daisyui": "^4.6.2",
|
|
81
86
|
"date-fns": "^3.6.0",
|
|
87
|
+
"embla-carousel-react": "^8.0.2",
|
|
82
88
|
"react-day-picker": "^8.10.0",
|
|
83
89
|
"react-international-phone": "^4.2.6",
|
|
84
90
|
"sonner": "^1.4.41",
|
|
@@ -130,5 +136,5 @@
|
|
|
130
136
|
"react-dom": "^18.2.0",
|
|
131
137
|
"typescript": "^5.2.2"
|
|
132
138
|
},
|
|
133
|
-
"gitHead": "
|
|
139
|
+
"gitHead": "3bc7cfc3008d4e1a0f47a850aec1055455ec399a"
|
|
134
140
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
5
|
+
import type {
|
|
6
|
+
AccordionProps,
|
|
7
|
+
AccordionContentProps,
|
|
8
|
+
AccordionItemProps,
|
|
9
|
+
AccordionTriggerProps,
|
|
10
|
+
} from "./types";
|
|
11
|
+
import { cn } from "../../utilities";
|
|
12
|
+
import {
|
|
13
|
+
getAccordionContentClasses,
|
|
14
|
+
getAccordionItemClasses,
|
|
15
|
+
getAccordionTriggerClasses,
|
|
16
|
+
} from "./constants";
|
|
17
|
+
|
|
18
|
+
const Accordion = (props: AccordionProps) => (
|
|
19
|
+
<AccordionPrimitive.Root {...props} />
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const AccordionItem = React.forwardRef<
|
|
23
|
+
React.ElementRef<typeof AccordionPrimitive.Item>,
|
|
24
|
+
AccordionItemProps
|
|
25
|
+
>(({ className, ...props }, ref) => (
|
|
26
|
+
<AccordionPrimitive.Item
|
|
27
|
+
ref={ref}
|
|
28
|
+
className={cn(getAccordionItemClasses(), className)}
|
|
29
|
+
{...props}
|
|
30
|
+
/>
|
|
31
|
+
));
|
|
32
|
+
AccordionItem.displayName = "AccordionItem";
|
|
33
|
+
|
|
34
|
+
const AccordionTrigger = React.forwardRef<
|
|
35
|
+
React.ElementRef<typeof AccordionPrimitive.Trigger>,
|
|
36
|
+
AccordionTriggerProps
|
|
37
|
+
>(({ className, children, ...props }, ref) => (
|
|
38
|
+
<AccordionPrimitive.Header className="flex">
|
|
39
|
+
<AccordionPrimitive.Trigger
|
|
40
|
+
ref={ref}
|
|
41
|
+
className={cn(getAccordionTriggerClasses(), className)}
|
|
42
|
+
{...props}
|
|
43
|
+
>
|
|
44
|
+
{children}
|
|
45
|
+
</AccordionPrimitive.Trigger>
|
|
46
|
+
</AccordionPrimitive.Header>
|
|
47
|
+
));
|
|
48
|
+
AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;
|
|
49
|
+
|
|
50
|
+
const AccordionContent = React.forwardRef<
|
|
51
|
+
React.ElementRef<typeof AccordionPrimitive.Content>,
|
|
52
|
+
AccordionContentProps
|
|
53
|
+
>(({ className, children, ...props }, ref) => (
|
|
54
|
+
<AccordionPrimitive.Content
|
|
55
|
+
ref={ref}
|
|
56
|
+
className={cn(getAccordionContentClasses())}
|
|
57
|
+
{...props}
|
|
58
|
+
>
|
|
59
|
+
<div className={cn("pb-4 pt-0", className)}>{children}</div>
|
|
60
|
+
</AccordionPrimitive.Content>
|
|
61
|
+
));
|
|
62
|
+
AccordionContent.displayName = AccordionPrimitive.Content.displayName;
|
|
63
|
+
|
|
64
|
+
Accordion.Item = AccordionItem;
|
|
65
|
+
Accordion.Trigger = AccordionTrigger;
|
|
66
|
+
Accordion.Content = AccordionContent;
|
|
67
|
+
|
|
68
|
+
export { Accordion };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { cva } from "../../libs";
|
|
2
|
+
|
|
3
|
+
export const getAccordionItemClasses = cva("border-b");
|
|
4
|
+
|
|
5
|
+
export const getAccordionTriggerClasses = cva(
|
|
6
|
+
"flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all [&:hover:not(:disabled)]:underline disabled:opacity-50 [&[data-state=open]>svg]:rotate-180"
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
export const getAccordionContentClasses = cva(
|
|
10
|
+
"overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"
|
|
11
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Accordion } from "./Accordion";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
2
|
+
|
|
3
|
+
export type AccordionProps = React.ComponentPropsWithoutRef<
|
|
4
|
+
typeof AccordionPrimitive.Root
|
|
5
|
+
>;
|
|
6
|
+
|
|
7
|
+
export type AccordionContentProps = React.ComponentPropsWithoutRef<
|
|
8
|
+
typeof AccordionPrimitive.Content
|
|
9
|
+
>;
|
|
10
|
+
|
|
11
|
+
export type AccordionItemProps = React.ComponentPropsWithoutRef<
|
|
12
|
+
typeof AccordionPrimitive.Item
|
|
13
|
+
>;
|
|
14
|
+
|
|
15
|
+
export type AccordionTriggerProps = React.ComponentPropsWithoutRef<
|
|
16
|
+
typeof AccordionPrimitive.Trigger
|
|
17
|
+
>;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { forwardRef, useCallback, useEffect, useState } from "react";
|
|
4
|
+
import useEmblaCarousel from "embla-carousel-react";
|
|
5
|
+
import { ArrowLeftIcon, ArrowRightIcon } from "@radix-ui/react-icons";
|
|
6
|
+
import type { CarouselApi, CarouselProps } from "./types";
|
|
7
|
+
import { cn } from "../../utilities";
|
|
8
|
+
import { Button } from "../Button";
|
|
9
|
+
import {
|
|
10
|
+
getCarouselContentClasses,
|
|
11
|
+
getCarouselItemClasses,
|
|
12
|
+
getCarouselNextClasses,
|
|
13
|
+
getCarouselPreviousClasses,
|
|
14
|
+
} from "./constants";
|
|
15
|
+
import { CarouselContext } from "./CarouselContext";
|
|
16
|
+
import { useCarousel } from "./useCarousel";
|
|
17
|
+
|
|
18
|
+
const Carousel = ({
|
|
19
|
+
orientation = "horizontal",
|
|
20
|
+
opts,
|
|
21
|
+
setApi,
|
|
22
|
+
plugins,
|
|
23
|
+
className,
|
|
24
|
+
children,
|
|
25
|
+
...props
|
|
26
|
+
}: CarouselProps & React.HTMLAttributes<HTMLDivElement>) => {
|
|
27
|
+
const [carouselRef, api] = useEmblaCarousel(
|
|
28
|
+
{
|
|
29
|
+
...opts,
|
|
30
|
+
axis: orientation === "horizontal" ? "x" : "y",
|
|
31
|
+
},
|
|
32
|
+
plugins
|
|
33
|
+
);
|
|
34
|
+
const [canScrollPrev, setCanScrollPrev] = useState(false);
|
|
35
|
+
const [canScrollNext, setCanScrollNext] = useState(false);
|
|
36
|
+
|
|
37
|
+
const onSelect = useCallback((api: CarouselApi) => {
|
|
38
|
+
if (!api) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
setCanScrollPrev(api.canScrollPrev());
|
|
43
|
+
setCanScrollNext(api.canScrollNext());
|
|
44
|
+
}, []);
|
|
45
|
+
|
|
46
|
+
const scrollPrev = useCallback(() => {
|
|
47
|
+
api?.scrollPrev();
|
|
48
|
+
}, [api]);
|
|
49
|
+
|
|
50
|
+
const scrollNext = useCallback(() => {
|
|
51
|
+
api?.scrollNext();
|
|
52
|
+
}, [api]);
|
|
53
|
+
|
|
54
|
+
const handleKeyDown = useCallback(
|
|
55
|
+
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
56
|
+
if (event.key === "ArrowLeft") {
|
|
57
|
+
event.preventDefault();
|
|
58
|
+
scrollPrev();
|
|
59
|
+
} else if (event.key === "ArrowRight") {
|
|
60
|
+
event.preventDefault();
|
|
61
|
+
scrollNext();
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
[scrollPrev, scrollNext]
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (!api || !setApi) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
setApi(api);
|
|
73
|
+
}, [api, setApi]);
|
|
74
|
+
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (!api) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
onSelect(api);
|
|
81
|
+
api.on("reInit", onSelect);
|
|
82
|
+
api.on("select", onSelect);
|
|
83
|
+
|
|
84
|
+
return () => {
|
|
85
|
+
api?.off("select", onSelect);
|
|
86
|
+
};
|
|
87
|
+
}, [api, onSelect]);
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<CarouselContext.Provider
|
|
91
|
+
value={{
|
|
92
|
+
carouselRef,
|
|
93
|
+
api: api,
|
|
94
|
+
opts,
|
|
95
|
+
orientation:
|
|
96
|
+
orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
|
|
97
|
+
scrollPrev,
|
|
98
|
+
scrollNext,
|
|
99
|
+
canScrollPrev,
|
|
100
|
+
canScrollNext,
|
|
101
|
+
}}
|
|
102
|
+
>
|
|
103
|
+
<div
|
|
104
|
+
onKeyDownCapture={handleKeyDown}
|
|
105
|
+
className={cn("relative", className)}
|
|
106
|
+
role="region"
|
|
107
|
+
aria-roledescription="carousel"
|
|
108
|
+
{...props}
|
|
109
|
+
>
|
|
110
|
+
{children}
|
|
111
|
+
</div>
|
|
112
|
+
</CarouselContext.Provider>
|
|
113
|
+
);
|
|
114
|
+
};
|
|
115
|
+
Carousel.displayName = "Carousel";
|
|
116
|
+
|
|
117
|
+
const CarouselContent = forwardRef<
|
|
118
|
+
HTMLDivElement,
|
|
119
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
120
|
+
>(({ className, ...props }, ref) => {
|
|
121
|
+
const { carouselRef, orientation } = useCarousel();
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<div ref={carouselRef} className="overflow-hidden">
|
|
125
|
+
<div
|
|
126
|
+
ref={ref}
|
|
127
|
+
className={cn(getCarouselContentClasses({ orientation }), className)}
|
|
128
|
+
{...props}
|
|
129
|
+
/>
|
|
130
|
+
</div>
|
|
131
|
+
);
|
|
132
|
+
});
|
|
133
|
+
CarouselContent.displayName = "CarouselContent";
|
|
134
|
+
|
|
135
|
+
const CarouselItem = forwardRef<
|
|
136
|
+
HTMLDivElement,
|
|
137
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
138
|
+
>(({ className, ...props }, ref) => {
|
|
139
|
+
const { orientation } = useCarousel();
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<div
|
|
143
|
+
ref={ref}
|
|
144
|
+
role="group"
|
|
145
|
+
aria-roledescription="slide"
|
|
146
|
+
className={cn(getCarouselItemClasses({ orientation }), className)}
|
|
147
|
+
{...props}
|
|
148
|
+
/>
|
|
149
|
+
);
|
|
150
|
+
});
|
|
151
|
+
CarouselItem.displayName = "CarouselItem";
|
|
152
|
+
|
|
153
|
+
const CarouselPrevious = forwardRef<
|
|
154
|
+
HTMLButtonElement,
|
|
155
|
+
React.ComponentProps<typeof Button>
|
|
156
|
+
>(({ className, variant = "ghost", outline = true, ...props }, ref) => {
|
|
157
|
+
const { orientation, scrollPrev, canScrollPrev } = useCarousel();
|
|
158
|
+
|
|
159
|
+
return (
|
|
160
|
+
<Button
|
|
161
|
+
ref={ref}
|
|
162
|
+
outline={outline}
|
|
163
|
+
variant={variant}
|
|
164
|
+
className={cn(getCarouselPreviousClasses({ orientation }), className)}
|
|
165
|
+
disabled={!canScrollPrev}
|
|
166
|
+
onClick={scrollPrev}
|
|
167
|
+
{...props}
|
|
168
|
+
>
|
|
169
|
+
<ArrowLeftIcon className="h-4 w-4" />
|
|
170
|
+
<span className="sr-only">Previous slide</span>
|
|
171
|
+
</Button>
|
|
172
|
+
);
|
|
173
|
+
});
|
|
174
|
+
CarouselPrevious.displayName = "CarouselPrevious";
|
|
175
|
+
|
|
176
|
+
const CarouselNext = forwardRef<
|
|
177
|
+
HTMLButtonElement,
|
|
178
|
+
React.ComponentProps<typeof Button>
|
|
179
|
+
>(({ className, outline = true, variant = "ghost", ...props }, ref) => {
|
|
180
|
+
const { orientation, scrollNext, canScrollNext } = useCarousel();
|
|
181
|
+
|
|
182
|
+
return (
|
|
183
|
+
<Button
|
|
184
|
+
ref={ref}
|
|
185
|
+
outline={outline}
|
|
186
|
+
variant={variant}
|
|
187
|
+
className={cn(getCarouselNextClasses({ orientation }), className)}
|
|
188
|
+
disabled={!canScrollNext}
|
|
189
|
+
onClick={scrollNext}
|
|
190
|
+
{...props}
|
|
191
|
+
>
|
|
192
|
+
<ArrowRightIcon className="h-4 w-4" />
|
|
193
|
+
<span className="sr-only">Next slide</span>
|
|
194
|
+
</Button>
|
|
195
|
+
);
|
|
196
|
+
});
|
|
197
|
+
CarouselNext.displayName = "CarouselNext";
|
|
198
|
+
|
|
199
|
+
Carousel.Content = CarouselContent;
|
|
200
|
+
Carousel.Item = CarouselItem;
|
|
201
|
+
Carousel.Next = CarouselNext;
|
|
202
|
+
Carousel.Previous = CarouselPrevious;
|
|
203
|
+
|
|
204
|
+
export { Carousel };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { cva } from "../../libs";
|
|
2
|
+
|
|
3
|
+
export const getCarouselContentClasses = cva("flex", {
|
|
4
|
+
variants: {
|
|
5
|
+
orientation: {
|
|
6
|
+
horizontal: "-ml-4",
|
|
7
|
+
vertical: "-mt-4 flex-col",
|
|
8
|
+
},
|
|
9
|
+
},
|
|
10
|
+
defaultVariants: {
|
|
11
|
+
orientation: "horizontal",
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const getCarouselItemClasses = cva(
|
|
16
|
+
"min-w-0 shrink-0 grow-0 basis-full",
|
|
17
|
+
{
|
|
18
|
+
variants: {
|
|
19
|
+
orientation: {
|
|
20
|
+
horizontal: "pl-4",
|
|
21
|
+
vertical: "pt-4",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
defaultVariants: {
|
|
25
|
+
orientation: "horizontal",
|
|
26
|
+
},
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
export const getCarouselNextClasses = cva(
|
|
31
|
+
"absolute h-8 w-8 rounded-full p-0 disabled:bg-transparent",
|
|
32
|
+
{
|
|
33
|
+
variants: {
|
|
34
|
+
orientation: {
|
|
35
|
+
horizontal: "-right-12 top-1/2 -translate-y-1/2",
|
|
36
|
+
vertical: "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
defaultVariants: {
|
|
40
|
+
orientation: "horizontal",
|
|
41
|
+
},
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
export const getCarouselPreviousClasses = cva(
|
|
46
|
+
"absolute h-8 w-8 rounded-full p-0 disabled:bg-transparent",
|
|
47
|
+
{
|
|
48
|
+
variants: {
|
|
49
|
+
orientation: {
|
|
50
|
+
horizontal: "-left-12 top-1/2 -translate-y-1/2",
|
|
51
|
+
vertical: "-top-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
defaultVariants: {
|
|
55
|
+
orientation: "horizontal",
|
|
56
|
+
},
|
|
57
|
+
}
|
|
58
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Carousel } from "./Carousel";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type UseEmblaCarouselType } from "embla-carousel-react";
|
|
2
|
+
import useEmblaCarousel from "embla-carousel-react";
|
|
3
|
+
|
|
4
|
+
type UseCarouselParameters = Parameters<typeof useEmblaCarousel>;
|
|
5
|
+
type CarouselOptions = UseCarouselParameters[0];
|
|
6
|
+
type CarouselPlugin = UseCarouselParameters[1];
|
|
7
|
+
|
|
8
|
+
export type CarouselApi = UseEmblaCarouselType[1];
|
|
9
|
+
|
|
10
|
+
export type CarouselProps = {
|
|
11
|
+
opts?: CarouselOptions;
|
|
12
|
+
plugins?: CarouselPlugin;
|
|
13
|
+
orientation?: "horizontal" | "vertical";
|
|
14
|
+
setApi?: (api: CarouselApi) => void;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type CarouselContextProps = {
|
|
18
|
+
carouselRef: ReturnType<typeof useEmblaCarousel>[0];
|
|
19
|
+
api: ReturnType<typeof useEmblaCarousel>[1];
|
|
20
|
+
scrollPrev: () => void;
|
|
21
|
+
scrollNext: () => void;
|
|
22
|
+
canScrollPrev: boolean;
|
|
23
|
+
canScrollNext: boolean;
|
|
24
|
+
} & CarouselProps;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { CarouselContext } from "./CarouselContext";
|
|
3
|
+
|
|
4
|
+
export function useCarousel() {
|
|
5
|
+
const context = useContext(CarouselContext);
|
|
6
|
+
|
|
7
|
+
if (!context) {
|
|
8
|
+
throw new Error("useCarousel must be used within a <Carousel />");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return context;
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
|
|
4
|
+
import { type CollapsibleProps } from "@radix-ui/react-accordion";
|
|
5
|
+
|
|
6
|
+
const Collapsible = (props: CollapsibleProps) => (
|
|
7
|
+
<CollapsiblePrimitive.Root {...props} />
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
Collapsible.Trigger = CollapsiblePrimitive.CollapsibleTrigger;
|
|
11
|
+
Collapsible.Content = CollapsiblePrimitive.CollapsibleContent;
|
|
12
|
+
|
|
13
|
+
export { Collapsible };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Collapsible } from "./Collapsible";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as HoverCardPrimitive from "@radix-ui/react-hover-card";
|
|
4
|
+
import { cn } from "../../utilities";
|
|
5
|
+
import { getHoverCardContentClasses } from "./constants";
|
|
6
|
+
import { forwardRef } from "react";
|
|
7
|
+
import { HoverCardProps } from "./types";
|
|
8
|
+
|
|
9
|
+
const HoverCard = (props: HoverCardProps) => (
|
|
10
|
+
<HoverCardPrimitive.Root {...props} />
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
const HoverCardContent = forwardRef<
|
|
14
|
+
React.ElementRef<typeof HoverCardPrimitive.Content>,
|
|
15
|
+
React.ComponentPropsWithoutRef<typeof HoverCardPrimitive.Content>
|
|
16
|
+
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
|
|
17
|
+
<HoverCardPrimitive.Content
|
|
18
|
+
ref={ref}
|
|
19
|
+
align={align}
|
|
20
|
+
sideOffset={sideOffset}
|
|
21
|
+
className={cn(getHoverCardContentClasses(), className)}
|
|
22
|
+
{...props}
|
|
23
|
+
/>
|
|
24
|
+
));
|
|
25
|
+
HoverCardContent.displayName = HoverCardPrimitive.Content.displayName;
|
|
26
|
+
|
|
27
|
+
HoverCard.Content = HoverCardContent;
|
|
28
|
+
HoverCard.Trigger = HoverCardPrimitive.Trigger;
|
|
29
|
+
|
|
30
|
+
export { HoverCard };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { cva } from "../../libs";
|
|
2
|
+
|
|
3
|
+
export const getHoverCardContentClasses = cva(
|
|
4
|
+
"z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"
|
|
5
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { HoverCard } from "./HoverCard";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as TogglePrimitive from "@radix-ui/react-toggle";
|
|
5
|
+
import { type ToggleProps } from "./types";
|
|
6
|
+
import { cn } from "../../utilities";
|
|
7
|
+
import { getToggleClasses } from "./constants";
|
|
8
|
+
import { getButtonClasses } from "../Button/constants";
|
|
9
|
+
|
|
10
|
+
const Toggle = React.forwardRef<
|
|
11
|
+
React.ElementRef<typeof TogglePrimitive.Root>,
|
|
12
|
+
ToggleProps
|
|
13
|
+
>(({ className, variant = "default", size, wide, outline, ...props }, ref) => (
|
|
14
|
+
<TogglePrimitive.Root
|
|
15
|
+
ref={ref}
|
|
16
|
+
className={cn(
|
|
17
|
+
getButtonClasses({ size, wide, outline }),
|
|
18
|
+
getToggleClasses({ variant }),
|
|
19
|
+
className
|
|
20
|
+
)}
|
|
21
|
+
{...props}
|
|
22
|
+
/>
|
|
23
|
+
));
|
|
24
|
+
|
|
25
|
+
Toggle.displayName = TogglePrimitive.Root.displayName;
|
|
26
|
+
|
|
27
|
+
export { Toggle };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { cva } from "../../libs";
|
|
2
|
+
|
|
3
|
+
export const getToggleClasses = cva(
|
|
4
|
+
"transition-colors disabled:pointer-events-none disabled:opacity-50 data-[state=off]:btn-ghost",
|
|
5
|
+
{
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
accent: "data-[state=on]:btn-accent",
|
|
9
|
+
default: "data-[state=on]:btn-default",
|
|
10
|
+
error: "data-[state=on]:btn-error",
|
|
11
|
+
info: "data-[state=on]:btn-info",
|
|
12
|
+
link: "data-[state=on]:btn-link",
|
|
13
|
+
neutral: "data-[state=on]:btn-neutral",
|
|
14
|
+
primary: "data-[state=on]:btn-primary",
|
|
15
|
+
secondary: "data-[state=on]:btn-secondary",
|
|
16
|
+
success: "data-[state=on]:btn-success",
|
|
17
|
+
warning: "data-[state=on]:btn-warning",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
}
|
|
21
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Toggle } from "./Toggle";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as TogglePrimitive from "@radix-ui/react-toggle";
|
|
2
|
+
import { type VariantProps } from "../../libs";
|
|
3
|
+
import { getButtonClasses } from "../Button/constants";
|
|
4
|
+
import { getToggleClasses } from "./constants";
|
|
5
|
+
|
|
6
|
+
export type BaseToggleProps = Omit<
|
|
7
|
+
VariantProps<typeof getButtonClasses>,
|
|
8
|
+
"variant" | "isLoading"
|
|
9
|
+
> &
|
|
10
|
+
VariantProps<typeof getToggleClasses>;
|
|
11
|
+
|
|
12
|
+
export type ToggleProps = React.ComponentPropsWithoutRef<
|
|
13
|
+
typeof TogglePrimitive.Root
|
|
14
|
+
> &
|
|
15
|
+
BaseToggleProps;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { createContext, forwardRef, useContext } from "react";
|
|
4
|
+
import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group";
|
|
5
|
+
import type {
|
|
6
|
+
ToggleGroupContextType,
|
|
7
|
+
ToggleGroupItemProps,
|
|
8
|
+
ToggleGroupProps,
|
|
9
|
+
} from "./types";
|
|
10
|
+
import { cn } from "../../utilities";
|
|
11
|
+
import { getToggleClasses } from "../Toggle/constants";
|
|
12
|
+
import { getToggleGroupClasses } from "./constants";
|
|
13
|
+
import { getButtonClasses } from "../Button/constants";
|
|
14
|
+
|
|
15
|
+
const ToggleGroupContext = createContext<ToggleGroupContextType>({
|
|
16
|
+
variant: "default",
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const ToggleGroup = ({
|
|
20
|
+
className,
|
|
21
|
+
variant,
|
|
22
|
+
children,
|
|
23
|
+
...props
|
|
24
|
+
}: ToggleGroupProps) => (
|
|
25
|
+
<ToggleGroupPrimitive.Root
|
|
26
|
+
className={cn(getToggleGroupClasses(), className)}
|
|
27
|
+
{...props}
|
|
28
|
+
>
|
|
29
|
+
<ToggleGroupContext.Provider value={{ variant }}>
|
|
30
|
+
{children}
|
|
31
|
+
</ToggleGroupContext.Provider>
|
|
32
|
+
</ToggleGroupPrimitive.Root>
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const ToggleGroupItem = forwardRef<
|
|
36
|
+
React.ElementRef<typeof ToggleGroupPrimitive.Item>,
|
|
37
|
+
ToggleGroupItemProps
|
|
38
|
+
>(({ className, children, variant, size, wide, outline, ...props }, ref) => {
|
|
39
|
+
const context = useContext(ToggleGroupContext);
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<ToggleGroupPrimitive.Item
|
|
43
|
+
ref={ref}
|
|
44
|
+
className={cn(
|
|
45
|
+
getButtonClasses({ size, wide, outline }),
|
|
46
|
+
getToggleClasses({
|
|
47
|
+
variant: context.variant ?? variant,
|
|
48
|
+
}),
|
|
49
|
+
className
|
|
50
|
+
)}
|
|
51
|
+
{...props}
|
|
52
|
+
>
|
|
53
|
+
{children}
|
|
54
|
+
</ToggleGroupPrimitive.Item>
|
|
55
|
+
);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
|
|
59
|
+
|
|
60
|
+
ToggleGroup.Item = ToggleGroupItem;
|
|
61
|
+
|
|
62
|
+
export { ToggleGroup };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ToggleGroup } from "./ToggleGroup";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group";
|
|
2
|
+
import { BaseToggleProps } from "../Toggle/types";
|
|
3
|
+
|
|
4
|
+
export type ToggleGroupProps = React.ComponentPropsWithoutRef<
|
|
5
|
+
typeof ToggleGroupPrimitive.Root
|
|
6
|
+
> &
|
|
7
|
+
Pick<BaseToggleProps, "variant">;
|
|
8
|
+
|
|
9
|
+
export type ToggleGroupItemProps = React.ComponentPropsWithoutRef<
|
|
10
|
+
typeof ToggleGroupPrimitive.Item
|
|
11
|
+
> &
|
|
12
|
+
BaseToggleProps;
|
|
13
|
+
|
|
14
|
+
export type ToggleGroupContextType = Pick<BaseToggleProps, "variant">;
|
package/src/index.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
/** actions */
|
|
2
2
|
export * from "./components/Button";
|
|
3
3
|
export * from "./components/Breadcrumbs";
|
|
4
|
+
export * from "./components/Toggle";
|
|
5
|
+
export * from "./components/ToggleGroup";
|
|
4
6
|
|
|
5
7
|
/** data display */
|
|
8
|
+
export * from "./components/Accordion";
|
|
6
9
|
export * from "./components/Alert";
|
|
7
10
|
export * from "./components/Avatar";
|
|
8
11
|
export * from "./components/Badge";
|
|
9
12
|
export * from "./components/Card";
|
|
10
13
|
export * from "./components/Calendar";
|
|
14
|
+
export * from "./components/Collapsible";
|
|
11
15
|
export * from "./components/Description";
|
|
12
16
|
export * from "./components/Progress";
|
|
13
17
|
export * from "./components/Separator";
|
|
@@ -27,6 +31,7 @@ export * from "./components/Tooltip";
|
|
|
27
31
|
|
|
28
32
|
/** composable */
|
|
29
33
|
export * from "./components/AlertDialog";
|
|
30
|
-
export * from "./components/Dialog";
|
|
31
34
|
export * from "./components/Command";
|
|
35
|
+
export * from "./components/Dialog";
|
|
36
|
+
export * from "./components/HoverCard";
|
|
32
37
|
export * from "./components/Popover";
|