@mbao01/common 0.0.22 → 0.0.24
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/Button/Button.d.ts +1 -1
- package/dist/types/components/Button/types.d.ts +1 -1
- package/dist/types/components/Carousel/Carousel.d.ts +2 -2
- package/dist/types/components/Command/Command.d.ts +6 -6
- package/dist/types/components/Slot/Slot.d.ts +1 -0
- package/dist/types/components/Slot/index.d.ts +1 -0
- package/dist/types/components/Sonner/Toaster.d.ts +1 -1
- package/dist/types/components/Sonner/constants.d.ts +4 -0
- package/dist/types/components/Sonner/types.d.ts +6 -2
- package/dist/types/index.d.ts +1 -0
- package/package.json +2 -2
- package/src/components/Button/Button.tsx +12 -16
- package/src/components/Button/types.ts +1 -1
- package/src/components/Slot/Slot.tsx +1 -0
- package/src/components/Slot/index.ts +1 -0
- package/src/components/Sonner/Toaster.tsx +17 -11
- package/src/components/Sonner/constants.ts +105 -37
- package/src/components/Sonner/types.ts +14 -3
- package/src/components/ThemeSwitch/constants.ts +1 -3
- package/src/index.ts +1 -0
|
@@ -6,6 +6,6 @@ declare const Button: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes
|
|
|
6
6
|
size?: "xs" | "sm" | "md" | "lg" | undefined;
|
|
7
7
|
isLoading?: boolean | undefined;
|
|
8
8
|
} & {
|
|
9
|
-
|
|
9
|
+
asChild?: boolean | undefined;
|
|
10
10
|
} & React.RefAttributes<HTMLButtonElement>>;
|
|
11
11
|
export { Button };
|
|
@@ -2,5 +2,5 @@ import { type VariantProps } from "../../libs";
|
|
|
2
2
|
import { type ButtonHTMLAttributes } from "react";
|
|
3
3
|
import { getButtonClasses } from "./constants";
|
|
4
4
|
export type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & VariantProps<typeof getButtonClasses> & {
|
|
5
|
-
|
|
5
|
+
asChild?: boolean;
|
|
6
6
|
};
|
|
@@ -12,7 +12,7 @@ declare const Carousel: {
|
|
|
12
12
|
size?: "xs" | "sm" | "md" | "lg" | undefined;
|
|
13
13
|
isLoading?: boolean | undefined;
|
|
14
14
|
} & {
|
|
15
|
-
|
|
15
|
+
asChild?: boolean | undefined;
|
|
16
16
|
} & import("react").RefAttributes<HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
17
17
|
Previous: import("react").ForwardRefExoticComponent<Omit<import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
18
18
|
variant?: "accent" | "default" | "error" | "ghost" | "info" | "link" | "neutral" | "primary" | "secondary" | "success" | "warning" | undefined;
|
|
@@ -21,7 +21,7 @@ declare const Carousel: {
|
|
|
21
21
|
size?: "xs" | "sm" | "md" | "lg" | undefined;
|
|
22
22
|
isLoading?: boolean | undefined;
|
|
23
23
|
} & {
|
|
24
|
-
|
|
24
|
+
asChild?: boolean | undefined;
|
|
25
25
|
} & import("react").RefAttributes<HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
26
26
|
};
|
|
27
27
|
export { Carousel };
|
|
@@ -8,7 +8,7 @@ declare const Command: {
|
|
|
8
8
|
ref?: React.Ref<HTMLInputElement> | undefined;
|
|
9
9
|
} & {
|
|
10
10
|
asChild?: boolean | undefined;
|
|
11
|
-
}, "
|
|
11
|
+
}, "asChild" | "key" | keyof React.InputHTMLAttributes<HTMLInputElement>>, "onChange" | "type" | "value"> & {
|
|
12
12
|
value?: string | undefined;
|
|
13
13
|
onValueChange?: ((search: string) => void) | undefined;
|
|
14
14
|
} & React.RefAttributes<HTMLInputElement>, "ref"> & {} & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -18,7 +18,7 @@ declare const Command: {
|
|
|
18
18
|
ref?: React.Ref<HTMLDivElement> | undefined;
|
|
19
19
|
} & {
|
|
20
20
|
asChild?: boolean | undefined;
|
|
21
|
-
}, "key" | keyof React.HTMLAttributes<HTMLDivElement
|
|
21
|
+
}, "asChild" | "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
22
22
|
label?: string | undefined;
|
|
23
23
|
} & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
24
24
|
Empty: React.ForwardRefExoticComponent<Omit<{
|
|
@@ -27,14 +27,14 @@ declare const Command: {
|
|
|
27
27
|
ref?: React.Ref<HTMLDivElement> | undefined;
|
|
28
28
|
} & {
|
|
29
29
|
asChild?: boolean | undefined;
|
|
30
|
-
}, "key" | keyof React.HTMLAttributes<HTMLDivElement
|
|
30
|
+
}, "asChild" | "key" | keyof React.HTMLAttributes<HTMLDivElement>> & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
31
31
|
Group: React.ForwardRefExoticComponent<Omit<{
|
|
32
32
|
children?: React.ReactNode;
|
|
33
33
|
} & Omit<Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
34
34
|
ref?: React.Ref<HTMLDivElement> | undefined;
|
|
35
35
|
} & {
|
|
36
36
|
asChild?: boolean | undefined;
|
|
37
|
-
}, "key" | keyof React.HTMLAttributes<HTMLDivElement
|
|
37
|
+
}, "asChild" | "key" | keyof React.HTMLAttributes<HTMLDivElement>>, "heading" | "value"> & {
|
|
38
38
|
heading?: React.ReactNode;
|
|
39
39
|
value?: string | undefined;
|
|
40
40
|
forceMount?: boolean | undefined;
|
|
@@ -45,7 +45,7 @@ declare const Command: {
|
|
|
45
45
|
ref?: React.Ref<HTMLDivElement> | undefined;
|
|
46
46
|
} & {
|
|
47
47
|
asChild?: boolean | undefined;
|
|
48
|
-
}, "key" | keyof React.HTMLAttributes<HTMLDivElement
|
|
48
|
+
}, "asChild" | "key" | keyof React.HTMLAttributes<HTMLDivElement>>, "onSelect" | "disabled" | "value"> & {
|
|
49
49
|
disabled?: boolean | undefined;
|
|
50
50
|
onSelect?: ((value: string) => void) | undefined;
|
|
51
51
|
value?: string | undefined;
|
|
@@ -60,7 +60,7 @@ declare const Command: {
|
|
|
60
60
|
ref?: React.Ref<HTMLDivElement> | undefined;
|
|
61
61
|
} & {
|
|
62
62
|
asChild?: boolean | undefined;
|
|
63
|
-
}, "key" | keyof React.HTMLAttributes<HTMLDivElement
|
|
63
|
+
}, "asChild" | "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
64
64
|
alwaysRender?: boolean | undefined;
|
|
65
65
|
} & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
66
66
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Slot, Slottable } from "@radix-ui/react-slot";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Slot } from "./Slot";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type ToasterProps } from "./types";
|
|
2
|
-
export declare const Toaster: ({ theme, variant,
|
|
2
|
+
export declare const Toaster: ({ theme, variant, actionButton, cancelButton, closeButton, showCloseButton, outline, ...props }: ToasterProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,3 +2,7 @@ export declare const getToastClasses: (props?: ({
|
|
|
2
2
|
variant?: "accent" | "default" | "error" | "ghost" | "info" | "neutral" | "primary" | "secondary" | "success" | "warning" | null | undefined;
|
|
3
3
|
outline?: boolean | null | undefined;
|
|
4
4
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
5
|
+
export declare const getToastButtonClasses: (props?: ({
|
|
6
|
+
variant?: "accent" | "error" | "info" | "neutral" | "primary" | "secondary" | "success" | "warning" | "base" | null | undefined;
|
|
7
|
+
outline?: boolean | null | undefined;
|
|
8
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Toaster } from "sonner";
|
|
3
3
|
import { type VariantProps } from "../../libs";
|
|
4
|
-
import { getToastClasses } from "./constants";
|
|
5
|
-
|
|
4
|
+
import { getToastButtonClasses, getToastClasses } from "./constants";
|
|
5
|
+
type ToastButtonVariantProps = VariantProps<typeof getToastButtonClasses>;
|
|
6
|
+
export type ToasterProps = Omit<React.ComponentProps<typeof Toaster>, "closeButton"> & VariantProps<typeof getToastClasses> & Partial<Record<"actionButton" | "cancelButton" | "closeButton", ToastButtonVariantProps>> & {
|
|
7
|
+
showCloseButton?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
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.24",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Ayomide Bakare",
|
|
7
7
|
"license": "MIT",
|
|
@@ -142,5 +142,5 @@
|
|
|
142
142
|
"react-dom": "^18.2.0",
|
|
143
143
|
"typescript": "^5.2.2"
|
|
144
144
|
},
|
|
145
|
-
"gitHead": "
|
|
145
|
+
"gitHead": "b95f089ac1b19964127f550809c9943b2766749f"
|
|
146
146
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Slot } from "@radix-ui/react-slot";
|
|
2
|
+
import { Slot, Slottable } from "@radix-ui/react-slot";
|
|
3
3
|
import { type ButtonProps } from "./types";
|
|
4
4
|
import { getButtonClasses } from "./constants";
|
|
5
5
|
import { Loading } from "../Loading";
|
|
@@ -8,7 +8,7 @@ import { cn } from "../../utilities";
|
|
|
8
8
|
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
9
9
|
(
|
|
10
10
|
{
|
|
11
|
-
|
|
11
|
+
asChild,
|
|
12
12
|
className,
|
|
13
13
|
outline,
|
|
14
14
|
children,
|
|
@@ -20,8 +20,7 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
20
20
|
},
|
|
21
21
|
ref
|
|
22
22
|
) => {
|
|
23
|
-
const Comp =
|
|
24
|
-
const SlotChild = as ? as : React.Fragment;
|
|
23
|
+
const Comp = asChild ? Slot : "button";
|
|
25
24
|
|
|
26
25
|
return (
|
|
27
26
|
<Comp
|
|
@@ -32,18 +31,15 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
32
31
|
)}
|
|
33
32
|
{...props}
|
|
34
33
|
>
|
|
35
|
-
{
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
</span>
|
|
45
|
-
) : null}
|
|
46
|
-
</SlotChild>
|
|
34
|
+
<Slottable>{children}</Slottable>
|
|
35
|
+
{isLoading ? (
|
|
36
|
+
<span
|
|
37
|
+
className="absolute left-0 top-0 flex h-full w-full items-center justify-center bg-[inherit]"
|
|
38
|
+
data-testid="loading"
|
|
39
|
+
>
|
|
40
|
+
<Loading />
|
|
41
|
+
</span>
|
|
42
|
+
) : null}
|
|
47
43
|
</Comp>
|
|
48
44
|
);
|
|
49
45
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Slot, Slottable } from "@radix-ui/react-slot";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Slot } from "./Slot";
|
|
@@ -3,30 +3,36 @@
|
|
|
3
3
|
import { Toaster as Sonner } from "sonner";
|
|
4
4
|
import { type ToasterProps } from "./types";
|
|
5
5
|
import { cn } from "../../utilities";
|
|
6
|
-
import { getToastClasses } from "./constants";
|
|
6
|
+
import { getToastButtonClasses, getToastClasses } from "./constants";
|
|
7
7
|
|
|
8
8
|
export const Toaster = ({
|
|
9
9
|
theme,
|
|
10
10
|
variant,
|
|
11
|
+
actionButton,
|
|
12
|
+
cancelButton,
|
|
13
|
+
closeButton,
|
|
14
|
+
showCloseButton,
|
|
11
15
|
outline,
|
|
12
|
-
className,
|
|
13
16
|
...props
|
|
14
17
|
}: ToasterProps) => {
|
|
15
18
|
return (
|
|
16
19
|
<Sonner
|
|
17
20
|
theme={theme}
|
|
18
|
-
|
|
21
|
+
closeButton={showCloseButton}
|
|
19
22
|
toastOptions={{
|
|
20
23
|
classNames: {
|
|
21
|
-
toast: cn(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
toast: cn(getToastClasses({ variant, outline })),
|
|
25
|
+
actionButton: cn(getToastButtonClasses(actionButton)),
|
|
26
|
+
cancelButton: cn(
|
|
27
|
+
getToastButtonClasses({
|
|
28
|
+
outline: true,
|
|
29
|
+
variant: "base",
|
|
30
|
+
...cancelButton,
|
|
31
|
+
})
|
|
32
|
+
),
|
|
33
|
+
closeButton: cn(
|
|
34
|
+
getToastButtonClasses({ variant: "neutral", ...closeButton })
|
|
24
35
|
),
|
|
25
|
-
description: "group-[.sonn]:text-muted-foreground",
|
|
26
|
-
actionButton:
|
|
27
|
-
"group-[.sonn]:bg-primary group-[.sonn]:text-primary-foreground",
|
|
28
|
-
cancelButton:
|
|
29
|
-
"group-[.sonn]:bg-muted group-[.sonn]:text-muted-foreground",
|
|
30
36
|
},
|
|
31
37
|
}}
|
|
32
38
|
{...props}
|
|
@@ -1,39 +1,107 @@
|
|
|
1
1
|
import { cva } from "../../libs";
|
|
2
2
|
|
|
3
|
-
export const getToastClasses = cva(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
3
|
+
export const getToastClasses = cva("sonner group", {
|
|
4
|
+
variants: {
|
|
5
|
+
variant: {
|
|
6
|
+
accent: "bg-accent text-accent-content border-accent",
|
|
7
|
+
default: "bg-default text-default-content border-default",
|
|
8
|
+
error: "bg-error text-error-content border-error",
|
|
9
|
+
ghost: "bg-ghost text-ghost-content border-transparent",
|
|
10
|
+
info: "bg-info text-info-content border-info",
|
|
11
|
+
neutral: "bg-neutral text-neutral-content border-neutral",
|
|
12
|
+
primary: "bg-primary text-primary-content border-primary",
|
|
13
|
+
secondary: "bg-secondary text-secondary-content border-secondary",
|
|
14
|
+
success: "bg-success text-success-content border-success",
|
|
15
|
+
warning: "bg-warning text-warning-content border-warning",
|
|
16
|
+
},
|
|
17
|
+
outline: {
|
|
18
|
+
true: "border bg-default",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
compoundVariants: [
|
|
22
|
+
{ outline: true, variant: "accent", className: "text-accent" },
|
|
23
|
+
{ outline: true, variant: "default", className: "text-default" },
|
|
24
|
+
{ outline: true, variant: "error", className: "text-error" },
|
|
25
|
+
{ outline: true, variant: "ghost", className: "text-ghost" },
|
|
26
|
+
{ outline: true, variant: "info", className: "text-info" },
|
|
27
|
+
{ outline: true, variant: "neutral", className: "text-neutral" },
|
|
28
|
+
{ outline: true, variant: "primary", className: "text-primary" },
|
|
29
|
+
{ outline: true, variant: "secondary", className: "text-secondary" },
|
|
30
|
+
{ outline: true, variant: "success", className: "text-success" },
|
|
31
|
+
{ outline: true, variant: "warning", className: "text-warning" },
|
|
32
|
+
],
|
|
33
|
+
defaultVariants: {
|
|
34
|
+
variant: "default",
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export const getToastButtonClasses = cva("", {
|
|
39
|
+
variants: {
|
|
40
|
+
variant: {
|
|
41
|
+
base: "group-[.sonner]:!bg-base-300 group-[.sonner]:!text-base-content",
|
|
42
|
+
accent: "group-[.sonner]:!bg-accent group-[.sonner]:!text-accent-content",
|
|
43
|
+
error: "group-[.sonner]:!bg-error group-[.sonner]:!text-error-content",
|
|
44
|
+
info: "group-[.sonner]:!bg-info group-[.sonner]:!text-info-content",
|
|
45
|
+
neutral:
|
|
46
|
+
"group-[.sonner]:!bg-neutral group-[.sonner]:!text-neutral-content",
|
|
47
|
+
primary:
|
|
48
|
+
"group-[.sonner]:!bg-primary group-[.sonner]:!text-primary-content",
|
|
49
|
+
secondary:
|
|
50
|
+
"group-[.sonner]:!bg-secondary group-[.sonner]:!text-secondary-content",
|
|
51
|
+
success:
|
|
52
|
+
"group-[.sonner]:!bg-success group-[.sonner]:!text-success-content",
|
|
53
|
+
warning:
|
|
54
|
+
"group-[.sonner]:!bg-warning group-[.sonner]:!text-warning-content",
|
|
55
|
+
},
|
|
56
|
+
outline: {
|
|
57
|
+
true: "group-[.sonner]:!border group-[.sonner]:!border-solid group-[.sonner]:!bg-transparent",
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
compoundVariants: [
|
|
61
|
+
{
|
|
62
|
+
outline: true,
|
|
63
|
+
variant: "accent",
|
|
64
|
+
className: "group-[.sonner]:!border-accent group-[.sonner]:!text-accent",
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
outline: true,
|
|
68
|
+
variant: "error",
|
|
69
|
+
className: "group-[.sonner]:!border-error group-[.sonner]:!text-error",
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
outline: true,
|
|
73
|
+
variant: "info",
|
|
74
|
+
className: "group-[.sonner]:!text-info",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
outline: true,
|
|
78
|
+
variant: "neutral",
|
|
79
|
+
className:
|
|
80
|
+
"group-[.sonner]:!border-neutral group-[.sonner]:!text-neutral",
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
outline: true,
|
|
84
|
+
variant: "primary",
|
|
85
|
+
className:
|
|
86
|
+
"group-[.sonner]:!border-primary group-[.sonner]:!text-primary",
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
outline: true,
|
|
90
|
+
variant: "secondary",
|
|
91
|
+
className:
|
|
92
|
+
"group-[.sonner]:!border-secondary group-[.sonner]:!text-secondary",
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
outline: true,
|
|
96
|
+
variant: "success",
|
|
97
|
+
className:
|
|
98
|
+
"group-[.sonner]:!border-success group-[.sonner]:!text-success",
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
outline: true,
|
|
102
|
+
variant: "warning",
|
|
103
|
+
className:
|
|
104
|
+
"group-[.sonner]:!border-warning group-[.sonner]:!text-warning",
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
});
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { Toaster } from "sonner";
|
|
2
2
|
import { type VariantProps } from "../../libs";
|
|
3
|
-
import { getToastClasses } from "./constants";
|
|
3
|
+
import { getToastButtonClasses, getToastClasses } from "./constants";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
type ToastButtonVariantProps = VariantProps<typeof getToastButtonClasses>;
|
|
6
|
+
|
|
7
|
+
export type ToasterProps = Omit<
|
|
8
|
+
React.ComponentProps<typeof Toaster>,
|
|
9
|
+
"closeButton"
|
|
10
|
+
> &
|
|
11
|
+
VariantProps<typeof getToastClasses> &
|
|
12
|
+
Partial<
|
|
13
|
+
Record<
|
|
14
|
+
"actionButton" | "cancelButton" | "closeButton",
|
|
15
|
+
ToastButtonVariantProps
|
|
16
|
+
>
|
|
17
|
+
> & { showCloseButton?: boolean };
|
package/src/index.ts
CHANGED