@quarklab/rad-ui 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,58 +0,0 @@
1
- import * as React from "react";
2
- import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group";
3
- import { type VariantProps } from "class-variance-authority";
4
- import { cn } from "../lib/utils";
5
- import { toggleVariants } from "./toggle";
6
-
7
- const ToggleGroupContext = React.createContext<
8
- VariantProps<typeof toggleVariants>
9
- >({
10
- size: "md",
11
- variant: "default",
12
- });
13
-
14
- const ToggleGroup = React.forwardRef<
15
- React.ElementRef<typeof ToggleGroupPrimitive.Root>,
16
- React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Root> &
17
- VariantProps<typeof toggleVariants>
18
- >(({ className, variant, size, children, ...props }, ref) => (
19
- <ToggleGroupPrimitive.Root
20
- ref={ref}
21
- className={cn("flex items-center justify-center gap-1", className)}
22
- {...props}
23
- >
24
- <ToggleGroupContext.Provider value={{ variant, size }}>
25
- {children}
26
- </ToggleGroupContext.Provider>
27
- </ToggleGroupPrimitive.Root>
28
- ));
29
-
30
- ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName;
31
-
32
- const ToggleGroupItem = React.forwardRef<
33
- React.ElementRef<typeof ToggleGroupPrimitive.Item>,
34
- React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Item> &
35
- VariantProps<typeof toggleVariants>
36
- >(({ className, children, variant, size, ...props }, ref) => {
37
- const context = React.useContext(ToggleGroupContext);
38
-
39
- return (
40
- <ToggleGroupPrimitive.Item
41
- ref={ref}
42
- className={cn(
43
- toggleVariants({
44
- variant: context.variant || variant,
45
- size: context.size || size,
46
- }),
47
- className
48
- )}
49
- {...props}
50
- >
51
- {children}
52
- </ToggleGroupPrimitive.Item>
53
- );
54
- });
55
-
56
- ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
57
-
58
- export { ToggleGroup, ToggleGroupItem };
@@ -1,45 +0,0 @@
1
- import * as React from "react";
2
- import * as TogglePrimitive from "@radix-ui/react-toggle";
3
- import { type VariantProps, cva } from "class-variance-authority";
4
- import { cn } from "../lib/utils";
5
-
6
- const toggleVariants = cva(
7
- "inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-primary data-[state=on]:text-primary-foreground",
8
- {
9
- variants: {
10
- variant: {
11
- default: "bg-transparent",
12
- outline:
13
- "border border-border bg-transparent hover:bg-muted hover:text-foreground",
14
- },
15
- size: {
16
- sm: "h-9 px-2.5 min-w-9 text-xs",
17
- md: "h-10 px-3 min-w-10",
18
- lg: "h-11 px-5 min-w-11 text-base",
19
- },
20
- },
21
- defaultVariants: {
22
- variant: "default",
23
- size: "md",
24
- },
25
- }
26
- );
27
-
28
- export interface ToggleProps
29
- extends React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root>,
30
- VariantProps<typeof toggleVariants> {}
31
-
32
- const Toggle = React.forwardRef<
33
- React.ElementRef<typeof TogglePrimitive.Root>,
34
- ToggleProps
35
- >(({ className, variant, size, ...props }, ref) => (
36
- <TogglePrimitive.Root
37
- ref={ref}
38
- className={cn(toggleVariants({ variant, size, className }))}
39
- {...props}
40
- />
41
- ));
42
-
43
- Toggle.displayName = TogglePrimitive.Root.displayName;
44
-
45
- export { Toggle, toggleVariants };