@mbao01/common 0.0.16 → 0.0.18

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.
Files changed (33) hide show
  1. package/dist/types/components/Avatar/constants.d.ts +2 -2
  2. package/dist/types/components/Card/Card.d.ts +4 -1
  3. package/dist/types/components/Card/types.d.ts +3 -0
  4. package/dist/types/components/Skeleton/constants.d.ts +2 -2
  5. package/dist/types/components/Tabs/Tabs.d.ts +10 -0
  6. package/dist/types/components/Tabs/constants.d.ts +3 -0
  7. package/dist/types/components/Tabs/index.d.ts +1 -0
  8. package/dist/types/components/Tabs/types.d.ts +8 -0
  9. package/dist/types/components/Toggle/Toggle.d.ts +12 -0
  10. package/dist/types/components/Toggle/constants.d.ts +3 -0
  11. package/dist/types/components/Toggle/index.d.ts +1 -0
  12. package/dist/types/components/Toggle/types.d.ts +7 -0
  13. package/dist/types/components/ToggleGroup/ToggleGroup.d.ts +16 -0
  14. package/dist/types/components/ToggleGroup/constants.d.ts +1 -0
  15. package/dist/types/components/ToggleGroup/index.d.ts +1 -0
  16. package/dist/types/components/ToggleGroup/types.d.ts +6 -0
  17. package/dist/types/index.d.ts +2 -0
  18. package/package.json +5 -2
  19. package/src/components/Card/Card.tsx +20 -2
  20. package/src/components/Card/types.ts +3 -0
  21. package/src/components/Tabs/Tabs.tsx +60 -0
  22. package/src/components/Tabs/constants.ts +13 -0
  23. package/src/components/Tabs/index.ts +1 -0
  24. package/src/components/Tabs/types.ts +26 -0
  25. package/src/components/Toggle/Toggle.tsx +27 -0
  26. package/src/components/Toggle/constants.ts +21 -0
  27. package/src/components/Toggle/index.ts +1 -0
  28. package/src/components/Toggle/types.ts +15 -0
  29. package/src/components/ToggleGroup/ToggleGroup.tsx +62 -0
  30. package/src/components/ToggleGroup/constants.ts +5 -0
  31. package/src/components/ToggleGroup/index.ts +1 -0
  32. package/src/components/ToggleGroup/types.ts +14 -0
  33. package/src/index.ts +2 -0
@@ -1,5 +1,5 @@
1
1
  export declare const getAvatarClasses: (props?: ({
2
- size?: 4 | 8 | 12 | 16 | 24 | 32 | 48 | 64 | null | undefined;
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 | 16 | 24 | 32 | 48 | 64 | null | undefined;
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;
@@ -1,7 +1,10 @@
1
- import type { CardContentProps, CardDescriptionProps, CardFooterProps, CardHeaderProps, CardImageProps, CardProps } from "./types";
1
+ import type { CardActionsProps, CardContentProps, CardDescriptionProps, CardFooterProps, CardHeaderProps, CardImageProps, CardTitleProps, CardProps, CardBodyProps } from "./types";
2
2
  declare const Card: {
3
3
  ({ compact, bordered, horizontal, overlay, className, ...props }: CardProps): import("react/jsx-runtime").JSX.Element;
4
+ Actions: ({ className, ...props }: CardActionsProps) => import("react/jsx-runtime").JSX.Element;
5
+ Body: ({ className, ...props }: CardBodyProps) => import("react/jsx-runtime").JSX.Element;
4
6
  Header: ({ className, ...props }: CardHeaderProps) => import("react/jsx-runtime").JSX.Element;
7
+ Title: ({ className, ...props }: CardTitleProps) => import("react/jsx-runtime").JSX.Element;
5
8
  Content: ({ className, ...props }: CardContentProps) => import("react/jsx-runtime").JSX.Element;
6
9
  Description: ({ className, ...props }: CardDescriptionProps) => import("react/jsx-runtime").JSX.Element;
7
10
  Image: ({ className, src, alt, ...props }: CardImageProps) => import("react/jsx-runtime").JSX.Element;
@@ -2,8 +2,11 @@ import React from "react";
2
2
  import { type VariantProps } from "../../libs";
3
3
  import { getCardClasses } from "./constants";
4
4
  export type CardProps = React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof getCardClasses>;
5
+ export type CardActionsProps = React.HTMLAttributes<HTMLDivElement>;
6
+ export type CardBodyProps = React.HTMLAttributes<HTMLDivElement>;
5
7
  export type CardContentProps = React.HTMLAttributes<HTMLDivElement>;
6
8
  export type CardImageProps = React.ImgHTMLAttributes<HTMLImageElement>;
7
9
  export type CardHeaderProps = React.HTMLAttributes<HTMLDivElement>;
10
+ export type CardTitleProps = React.HTMLAttributes<HTMLHeadingElement>;
8
11
  export type CardFooterProps = React.HTMLAttributes<HTMLDivElement>;
9
12
  export type CardDescriptionProps = React.HTMLAttributes<HTMLParagraphElement>;
@@ -1,6 +1,6 @@
1
1
  export declare const getSkeletonClasses: (props?: ({
2
2
  variant?: "pulse" | null | undefined;
3
- width?: 4 | 8 | 12 | 16 | 24 | 32 | 48 | 64 | 2 | "full" | null | undefined;
4
- height?: 4 | 8 | 12 | 16 | 24 | 32 | 48 | 64 | 2 | "full" | null | undefined;
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,10 @@
1
+ import * as React from "react";
2
+ import * as TabsPrimitive from "@radix-ui/react-tabs";
3
+ import type { TabsProps } from "./types";
4
+ declare const Tabs: {
5
+ (props: TabsProps): import("react/jsx-runtime").JSX.Element;
6
+ List: React.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsListProps & React.RefAttributes<HTMLDivElement>, "ref"> & {} & React.RefAttributes<HTMLDivElement>>;
7
+ Trigger: React.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsTriggerProps & React.RefAttributes<HTMLButtonElement>, "ref"> & {} & React.RefAttributes<HTMLButtonElement>>;
8
+ Content: React.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & {} & React.RefAttributes<HTMLDivElement>>;
9
+ };
10
+ export { Tabs };
@@ -0,0 +1,3 @@
1
+ export declare const getTabsListClasses: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
2
+ export declare const getTabsTriggerClasses: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
3
+ export declare const getTabsContentClasses: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
@@ -0,0 +1 @@
1
+ export { Tabs } from "./Tabs";
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import * as TabsPrimitive from "@radix-ui/react-tabs";
3
+ import { type VariantProps } from "../../libs";
4
+ import { getTabsContentClasses, getTabsListClasses, getTabsTriggerClasses } from "./constants";
5
+ export type TabsProps = React.ComponentPropsWithoutRef<typeof TabsPrimitive.Root>;
6
+ export type TabsListProps = React.ComponentPropsWithoutRef<typeof TabsPrimitive.List> & VariantProps<typeof getTabsListClasses>;
7
+ export type TabsTriggerProps = React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger> & VariantProps<typeof getTabsTriggerClasses>;
8
+ export type TabsContentProps = React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content> & VariantProps<typeof getTabsContentClasses>;
@@ -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,3 @@
1
+ export declare const getToggleClasses: (props?: ({
2
+ variant?: "accent" | "default" | "error" | "info" | "link" | "neutral" | "primary" | "secondary" | "success" | "warning" | null | undefined;
3
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
@@ -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">;
@@ -1,6 +1,7 @@
1
1
  /** actions */
2
2
  export * from "./components/Button";
3
3
  export * from "./components/Breadcrumbs";
4
+ export * from "./components/Toggle";
4
5
  /** data display */
5
6
  export * from "./components/Alert";
6
7
  export * from "./components/Avatar";
@@ -11,6 +12,7 @@ export * from "./components/Description";
11
12
  export * from "./components/Progress";
12
13
  export * from "./components/Separator";
13
14
  export * from "./components/Sonner";
15
+ export * from "./components/Tabs";
14
16
  export * from "./components/Text";
15
17
  /** data input */
16
18
  export * from "./components/Form";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mbao01/common",
3
3
  "private": false,
4
- "version": "0.0.16",
4
+ "version": "0.0.18",
5
5
  "type": "module",
6
6
  "author": "Ayomide Bakare",
7
7
  "license": "MIT",
@@ -72,6 +72,9 @@
72
72
  "@radix-ui/react-separator": "^1.0.3",
73
73
  "@radix-ui/react-slider": "^1.1.2",
74
74
  "@radix-ui/react-slot": "^1.0.2",
75
+ "@radix-ui/react-tabs": "^1.0.4",
76
+ "@radix-ui/react-toggle": "^1.0.3",
77
+ "@radix-ui/react-toggle-group": "^1.0.4",
75
78
  "@radix-ui/react-tooltip": "^1.0.7",
76
79
  "class-variance-authority": "^0.7.0",
77
80
  "clsx": "^2.1.0",
@@ -129,5 +132,5 @@
129
132
  "react-dom": "^18.2.0",
130
133
  "typescript": "^5.2.2"
131
134
  },
132
- "gitHead": "109cf6f95514f5d5b0bfc6f89bc02b8ecd821c41"
135
+ "gitHead": "9bc26c6619e27427b22532be6aa94ea63817c0b1"
133
136
  }
@@ -1,10 +1,13 @@
1
1
  import type {
2
+ CardActionsProps,
2
3
  CardContentProps,
3
4
  CardDescriptionProps,
4
5
  CardFooterProps,
5
6
  CardHeaderProps,
6
7
  CardImageProps,
8
+ CardTitleProps,
7
9
  CardProps,
10
+ CardBodyProps,
8
11
  } from "./types";
9
12
  import { cn } from "../../utilities";
10
13
  import { getCardClasses } from "./constants";
@@ -27,6 +30,10 @@ const Card = ({
27
30
  );
28
31
 
29
32
  const CardHeader = ({ className, ...props }: CardHeaderProps) => (
33
+ <div className={cn("flex flex-col space-y-1.5 p-6", className)} {...props} />
34
+ );
35
+
36
+ const CardTitle = ({ className, ...props }: CardTitleProps) => (
30
37
  <h3 className={cn("card-title", className)} {...props} />
31
38
  );
32
39
 
@@ -34,8 +41,12 @@ const CardDescription = ({ className, ...props }: CardDescriptionProps) => (
34
41
  <p className={cn("text-sm text-muted-foreground", className)} {...props} />
35
42
  );
36
43
 
44
+ const CardBody = ({ className, ...props }: CardBodyProps) => (
45
+ <div className={cn("card-body", className)} {...props} />
46
+ );
47
+
37
48
  const CardContent = ({ className, ...props }: CardContentProps) => (
38
- <div className={cn("card-body p-6 pt-0", className)} {...props} />
49
+ <div className={cn("p-6 pt-0", className)} {...props} />
39
50
  );
40
51
 
41
52
  const CardImage = ({ className, src, alt, ...props }: CardImageProps) => (
@@ -44,11 +55,18 @@ const CardImage = ({ className, src, alt, ...props }: CardImageProps) => (
44
55
  </figure>
45
56
  );
46
57
 
47
- const CardFooter = ({ className, ...props }: CardFooterProps) => (
58
+ const CardActions = ({ className, ...props }: CardActionsProps) => (
48
59
  <div className={cn("card-actions", className)} {...props} />
49
60
  );
50
61
 
62
+ const CardFooter = ({ className, ...props }: CardFooterProps) => (
63
+ <div className={cn("flex items-center p-6 pt-0", className)} {...props} />
64
+ );
65
+
66
+ Card.Actions = CardActions;
67
+ Card.Body = CardBody;
51
68
  Card.Header = CardHeader;
69
+ Card.Title = CardTitle;
52
70
  Card.Content = CardContent;
53
71
  Card.Description = CardDescription;
54
72
  Card.Image = CardImage;
@@ -5,8 +5,11 @@ import { getCardClasses } from "./constants";
5
5
  export type CardProps = React.HTMLAttributes<HTMLDivElement> &
6
6
  VariantProps<typeof getCardClasses>;
7
7
 
8
+ export type CardActionsProps = React.HTMLAttributes<HTMLDivElement>;
9
+ export type CardBodyProps = React.HTMLAttributes<HTMLDivElement>;
8
10
  export type CardContentProps = React.HTMLAttributes<HTMLDivElement>;
9
11
  export type CardImageProps = React.ImgHTMLAttributes<HTMLImageElement>;
10
12
  export type CardHeaderProps = React.HTMLAttributes<HTMLDivElement>;
13
+ export type CardTitleProps = React.HTMLAttributes<HTMLHeadingElement>;
11
14
  export type CardFooterProps = React.HTMLAttributes<HTMLDivElement>;
12
15
  export type CardDescriptionProps = React.HTMLAttributes<HTMLParagraphElement>;
@@ -0,0 +1,60 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import * as TabsPrimitive from "@radix-ui/react-tabs";
5
+ import { cn } from "../../utilities";
6
+ import {
7
+ getTabsContentClasses,
8
+ getTabsListClasses,
9
+ getTabsTriggerClasses,
10
+ } from "./constants";
11
+ import type {
12
+ TabsContentProps,
13
+ TabsListProps,
14
+ TabsProps,
15
+ TabsTriggerProps,
16
+ } from "./types";
17
+
18
+ const Tabs = (props: TabsProps) => <TabsPrimitive.Root {...props} />;
19
+
20
+ const TabsList = React.forwardRef<
21
+ React.ElementRef<typeof TabsPrimitive.List>,
22
+ TabsListProps
23
+ >(({ className, ...props }, ref) => (
24
+ <TabsPrimitive.List
25
+ ref={ref}
26
+ className={cn(getTabsListClasses(), className)}
27
+ {...props}
28
+ />
29
+ ));
30
+ TabsList.displayName = TabsPrimitive.List.displayName;
31
+
32
+ const TabsTrigger = React.forwardRef<
33
+ React.ElementRef<typeof TabsPrimitive.Trigger>,
34
+ TabsTriggerProps
35
+ >(({ className, ...props }, ref) => (
36
+ <TabsPrimitive.Trigger
37
+ ref={ref}
38
+ className={cn(getTabsTriggerClasses(), className)}
39
+ {...props}
40
+ />
41
+ ));
42
+ TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
43
+
44
+ const TabsContent = React.forwardRef<
45
+ React.ElementRef<typeof TabsPrimitive.Content>,
46
+ TabsContentProps
47
+ >(({ className, ...props }, ref) => (
48
+ <TabsPrimitive.Content
49
+ ref={ref}
50
+ className={cn(getTabsContentClasses(), className)}
51
+ {...props}
52
+ />
53
+ ));
54
+ TabsContent.displayName = TabsPrimitive.Content.displayName;
55
+
56
+ Tabs.List = TabsList;
57
+ Tabs.Trigger = TabsTrigger;
58
+ Tabs.Content = TabsContent;
59
+
60
+ export { Tabs };
@@ -0,0 +1,13 @@
1
+ import { cva } from "../../libs";
2
+
3
+ export const getTabsListClasses = cva(
4
+ "inline-flex h-9 items-center justify-center rounded-lg bg-base-200 p-1"
5
+ );
6
+
7
+ export const getTabsTriggerClasses = cva(
8
+ "inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-base-100 data-[state=active]:text-foreground data-[state=active]:shadow"
9
+ );
10
+
11
+ export const getTabsContentClasses = cva(
12
+ "mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
13
+ );
@@ -0,0 +1 @@
1
+ export { Tabs } from "./Tabs";
@@ -0,0 +1,26 @@
1
+ import * as TabsPrimitive from "@radix-ui/react-tabs";
2
+ import { type VariantProps } from "../../libs";
3
+ import {
4
+ getTabsContentClasses,
5
+ getTabsListClasses,
6
+ getTabsTriggerClasses,
7
+ } from "./constants";
8
+
9
+ export type TabsProps = React.ComponentPropsWithoutRef<
10
+ typeof TabsPrimitive.Root
11
+ >;
12
+
13
+ export type TabsListProps = React.ComponentPropsWithoutRef<
14
+ typeof TabsPrimitive.List
15
+ > &
16
+ VariantProps<typeof getTabsListClasses>;
17
+
18
+ export type TabsTriggerProps = React.ComponentPropsWithoutRef<
19
+ typeof TabsPrimitive.Trigger
20
+ > &
21
+ VariantProps<typeof getTabsTriggerClasses>;
22
+
23
+ export type TabsContentProps = React.ComponentPropsWithoutRef<
24
+ typeof TabsPrimitive.Content
25
+ > &
26
+ VariantProps<typeof getTabsContentClasses>;
@@ -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,5 @@
1
+ import { cva } from "../../libs";
2
+
3
+ export const getToggleGroupClasses = cva(
4
+ "flex items-center justify-center gap-1"
5
+ );
@@ -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,6 +1,7 @@
1
1
  /** actions */
2
2
  export * from "./components/Button";
3
3
  export * from "./components/Breadcrumbs";
4
+ export * from "./components/Toggle";
4
5
 
5
6
  /** data display */
6
7
  export * from "./components/Alert";
@@ -12,6 +13,7 @@ export * from "./components/Description";
12
13
  export * from "./components/Progress";
13
14
  export * from "./components/Separator";
14
15
  export * from "./components/Sonner";
16
+ export * from "./components/Tabs";
15
17
  export * from "./components/Text";
16
18
 
17
19
  /** data input */