@mbao01/common 0.0.22 → 0.0.23

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.
@@ -0,0 +1 @@
1
+ export { Slot } 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, outline, className, ...props }: ToasterProps) => import("react/jsx-runtime").JSX.Element;
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
- export type ToasterProps = React.ComponentProps<typeof Toaster> & VariantProps<typeof getToastClasses>;
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 {};
@@ -36,3 +36,4 @@ export * from "./components/Command";
36
36
  export * from "./components/Dialog";
37
37
  export * from "./components/HoverCard";
38
38
  export * from "./components/Popover";
39
+ export * from "./components/Slot";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mbao01/common",
3
3
  "private": false,
4
- "version": "0.0.22",
4
+ "version": "0.0.23",
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": "a37cc681238d753608c43c5b47a829826f059c74"
145
+ "gitHead": "ba76159ca3d5d96cbdcbc04b7dbd545f071027b6"
146
146
  }
@@ -0,0 +1 @@
1
+ export { Slot } 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
- className={cn("toaster group", className)}
21
+ closeButton={showCloseButton}
19
22
  toastOptions={{
20
23
  classNames: {
21
- toast: cn(
22
- "group sonn group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",
23
- getToastClasses({ variant, outline })
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
- "relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-inherit",
5
- {
6
- variants: {
7
- variant: {
8
- accent: "bg-accent text-accent-content border-accent",
9
- default: "bg-default text-default-content border-default",
10
- error: "bg-error text-error-content border-error",
11
- ghost: "bg-ghost text-ghost-content border-transparent",
12
- info: "bg-info text-info-content border-info",
13
- neutral: "bg-neutral text-neutral-content border-neutral",
14
- primary: "bg-primary text-primary-content border-primary",
15
- secondary: "bg-secondary text-secondary-content border-secondary",
16
- success: "bg-success text-success-content border-success",
17
- warning: "bg-warning text-warning-content border-warning",
18
- },
19
- outline: {
20
- true: "border bg-default",
21
- },
22
- },
23
- compoundVariants: [
24
- { outline: true, variant: "accent", className: "text-accent" },
25
- { outline: true, variant: "default", className: "text-default" },
26
- { outline: true, variant: "error", className: "text-error" },
27
- { outline: true, variant: "ghost", className: "text-ghost" },
28
- { outline: true, variant: "info", className: "text-info" },
29
- { outline: true, variant: "neutral", className: "text-neutral" },
30
- { outline: true, variant: "primary", className: "text-primary" },
31
- { outline: true, variant: "secondary", className: "text-secondary" },
32
- { outline: true, variant: "success", className: "text-success" },
33
- { outline: true, variant: "warning", className: "text-warning" },
34
- ],
35
- defaultVariants: {
36
- variant: "default",
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
- export type ToasterProps = React.ComponentProps<typeof Toaster> &
6
- VariantProps<typeof getToastClasses>;
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 };
@@ -1,5 +1,3 @@
1
1
  import { cva } from "../../libs";
2
2
 
3
- export const getThemeSwitchClasses = cva(
4
- "swap swap-rotate flex items-center gap-4"
5
- );
3
+ export const getThemeSwitchClasses = cva("swap swap-rotate");
package/src/index.ts CHANGED
@@ -40,3 +40,4 @@ export * from "./components/Command";
40
40
  export * from "./components/Dialog";
41
41
  export * from "./components/HoverCard";
42
42
  export * from "./components/Popover";
43
+ export * from "./components/Slot";