@mbao01/common 0.9.3 → 0.9.5
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/Drawer/Drawer.d.ts +3 -3
- package/dist/types/components/Drawer/constants.d.ts +1 -0
- package/dist/types/components/Drawer/types.d.ts +4 -0
- package/dist/types/components/Skeleton/constants.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/Dialog/constants.ts +1 -1
- package/src/components/Drawer/Drawer.tsx +15 -4
- package/src/components/Drawer/constants.ts +4 -0
- package/src/components/Drawer/types.ts +5 -0
- package/src/components/Skeleton/constants.ts +8 -2
- package/src/components/WidgetShell/WidgetShell.tsx +2 -0
- package/src/components/WidgetShell/WidgetShellSkeleton.tsx +10 -13
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DrawerProps } from './types';
|
|
1
|
+
import { DrawerContentProps, DrawerProps } from './types';
|
|
2
2
|
declare const Drawer: {
|
|
3
3
|
({ shouldScaleBackground, ...props }: DrawerProps): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
displayName: string;
|
|
@@ -6,7 +6,7 @@ declare const Drawer: {
|
|
|
6
6
|
Overlay: import('react').ForwardRefExoticComponent<Omit<Omit<import('@radix-ui/react-dialog').DialogOverlayProps & import('react').RefAttributes<HTMLDivElement>, "ref"> & import('react').RefAttributes<HTMLDivElement>, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
|
|
7
7
|
Trigger: import('react').ForwardRefExoticComponent<import('@radix-ui/react-dialog').DialogTriggerProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
8
8
|
Close: import('react').ForwardRefExoticComponent<import('@radix-ui/react-dialog').DialogCloseProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
9
|
-
Content: import('react').ForwardRefExoticComponent<Omit<
|
|
9
|
+
Content: import('react').ForwardRefExoticComponent<Omit<DrawerContentProps, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
|
|
10
10
|
Header: {
|
|
11
11
|
({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
12
12
|
displayName: string;
|
|
@@ -22,7 +22,7 @@ declare const DrawerTrigger: import('react').ForwardRefExoticComponent<import('@
|
|
|
22
22
|
declare const DrawerPortal: typeof import('vaul').Portal;
|
|
23
23
|
declare const DrawerClose: import('react').ForwardRefExoticComponent<import('@radix-ui/react-dialog').DialogCloseProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
24
24
|
declare const DrawerOverlay: import('react').ForwardRefExoticComponent<Omit<Omit<import('@radix-ui/react-dialog').DialogOverlayProps & import('react').RefAttributes<HTMLDivElement>, "ref"> & import('react').RefAttributes<HTMLDivElement>, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
|
|
25
|
-
declare const DrawerContent: import('react').ForwardRefExoticComponent<Omit<
|
|
25
|
+
declare const DrawerContent: import('react').ForwardRefExoticComponent<Omit<DrawerContentProps, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
|
|
26
26
|
declare const DrawerHeader: {
|
|
27
27
|
({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
28
28
|
displayName: string;
|
|
@@ -4,3 +4,4 @@ export declare const getDrawerHeaderClasses: (props?: import('class-variance-aut
|
|
|
4
4
|
export declare const getDrawerFooterClasses: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
|
|
5
5
|
export declare const getDrawerOverlayClasses: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
|
|
6
6
|
export declare const getDrawerTitleClasses: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
|
|
7
|
+
export declare const getDrawerCloseClasses: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import { Drawer as DrawerPrimitive } from 'vaul';
|
|
2
2
|
export type DrawerProps = React.ComponentProps<typeof DrawerPrimitive.Root>;
|
|
3
|
+
export type DrawerContentProps = React.ComponentProps<typeof DrawerPrimitive.Content> & {
|
|
4
|
+
showClose?: boolean;
|
|
5
|
+
closeProps?: React.ComponentProps<typeof DrawerPrimitive.Close>;
|
|
6
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const getSkeletonClasses: (props?: ({
|
|
2
|
-
animate?: "pulse" | null | undefined;
|
|
2
|
+
animate?: "none" | "pulse" | "wave" | "bounce" | null | undefined;
|
|
3
3
|
width?: 4 | 8 | "full" | 2 | 12 | 16 | 24 | 32 | 48 | 64 | null | undefined;
|
|
4
4
|
height?: 4 | 8 | "full" | 2 | 12 | 16 | 24 | 32 | 48 | 64 | null | undefined;
|
|
5
5
|
round?: boolean | null | undefined;
|
package/package.json
CHANGED
|
@@ -41,5 +41,5 @@ export const getDialogTitleClasses = cva("text-lg font-semibold leading-none tra
|
|
|
41
41
|
export const getDialogDescriptionClasses = cva("text-sm text-muted-foreground");
|
|
42
42
|
|
|
43
43
|
export const getDialogCloseClasses = cva(
|
|
44
|
-
"absolute right-4 top-4 rounded-xs opacity-70 ring-offset-background transition-all duration-200 hover:opacity-100 hover:rotate-90 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"
|
|
44
|
+
"absolute right-4 top-4 cursor-pointer rounded-xs opacity-70 ring-offset-background transition-all duration-200 hover:opacity-100 hover:rotate-90 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"
|
|
45
45
|
);
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
|
+
import { XIcon } from "lucide-react";
|
|
4
5
|
import { Drawer as DrawerPrimitive } from "vaul";
|
|
5
6
|
import { cn } from "../../utilities";
|
|
6
7
|
import {
|
|
8
|
+
getDrawerCloseClasses,
|
|
7
9
|
getDrawerContentClasses,
|
|
8
10
|
getDrawerDescriptionClasses,
|
|
9
11
|
getDrawerFooterClasses,
|
|
@@ -11,7 +13,7 @@ import {
|
|
|
11
13
|
getDrawerOverlayClasses,
|
|
12
14
|
getDrawerTitleClasses,
|
|
13
15
|
} from "./constants";
|
|
14
|
-
import { DrawerProps } from "./types";
|
|
16
|
+
import { DrawerContentProps, DrawerProps } from "./types";
|
|
15
17
|
|
|
16
18
|
const Drawer = ({ shouldScaleBackground = true, ...props }: DrawerProps) => (
|
|
17
19
|
<DrawerPrimitive.Root shouldScaleBackground={shouldScaleBackground} {...props} />
|
|
@@ -38,8 +40,8 @@ DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName;
|
|
|
38
40
|
|
|
39
41
|
const DrawerContent = forwardRef<
|
|
40
42
|
React.ElementRef<typeof DrawerPrimitive.Content>,
|
|
41
|
-
|
|
42
|
-
>(({ className, children, ...props }, ref) => (
|
|
43
|
+
DrawerContentProps
|
|
44
|
+
>(({ className, children, showClose, closeProps, ...props }, ref) => (
|
|
43
45
|
<DrawerPortal>
|
|
44
46
|
<DrawerOverlay />
|
|
45
47
|
<DrawerPrimitive.Content
|
|
@@ -47,8 +49,17 @@ const DrawerContent = forwardRef<
|
|
|
47
49
|
className={cn(getDrawerContentClasses(), className)}
|
|
48
50
|
{...props}
|
|
49
51
|
>
|
|
50
|
-
<div className="mx-auto mt-4 h-2 w-[80px] rounded-full bg-base-300" />
|
|
52
|
+
<div className="mx-auto mt-4 h-2 min-h-2 w-[80px] rounded-full bg-base-300" />
|
|
51
53
|
{children}
|
|
54
|
+
{showClose ? (
|
|
55
|
+
<DrawerPrimitive.Close
|
|
56
|
+
{...closeProps}
|
|
57
|
+
className={cn(getDrawerCloseClasses(), closeProps?.className)}
|
|
58
|
+
>
|
|
59
|
+
<XIcon className="h-4 w-4" />
|
|
60
|
+
<span className="sr-only">Close</span>
|
|
61
|
+
</DrawerPrimitive.Close>
|
|
62
|
+
) : null}
|
|
52
63
|
</DrawerPrimitive.Content>
|
|
53
64
|
</DrawerPortal>
|
|
54
65
|
));
|
|
@@ -13,3 +13,7 @@ export const getDrawerFooterClasses = cva("mt-auto flex flex-col gap-2 p-4");
|
|
|
13
13
|
export const getDrawerOverlayClasses = cva("fixed inset-0 z-50 bg-black/60 backdrop-blur-sm");
|
|
14
14
|
|
|
15
15
|
export const getDrawerTitleClasses = cva("text-lg font-semibold leading-none tracking-tight");
|
|
16
|
+
|
|
17
|
+
export const getDrawerCloseClasses = cva(
|
|
18
|
+
"absolute right-4 top-4 cursor-pointer rounded-xs opacity-70 ring-offset-background transition-all duration-200 hover:opacity-100 hover:rotate-90 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"
|
|
19
|
+
);
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import { Drawer as DrawerPrimitive } from "vaul";
|
|
2
2
|
|
|
3
3
|
export type DrawerProps = React.ComponentProps<typeof DrawerPrimitive.Root>;
|
|
4
|
+
|
|
5
|
+
export type DrawerContentProps = React.ComponentProps<typeof DrawerPrimitive.Content> & {
|
|
6
|
+
showClose?: boolean;
|
|
7
|
+
closeProps?: React.ComponentProps<typeof DrawerPrimitive.Close>;
|
|
8
|
+
};
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { cva } from "../../libs";
|
|
2
2
|
import { createVariants } from "../../utilities";
|
|
3
3
|
|
|
4
|
-
export const getSkeletonClasses = cva("skeleton
|
|
4
|
+
export const getSkeletonClasses = cva("skeleton", {
|
|
5
5
|
variants: createVariants({
|
|
6
|
-
animate: {
|
|
6
|
+
animate: {
|
|
7
|
+
none: "animate-none",
|
|
8
|
+
wave: "",
|
|
9
|
+
bounce: "animate-bounce",
|
|
10
|
+
pulse: "animate-pulse",
|
|
11
|
+
},
|
|
7
12
|
width: {
|
|
8
13
|
2: "w-2",
|
|
9
14
|
4: "w-4",
|
|
@@ -37,5 +42,6 @@ export const getSkeletonClasses = cva("skeleton animate-pulse", {
|
|
|
37
42
|
width: "full",
|
|
38
43
|
height: 4,
|
|
39
44
|
round: false,
|
|
45
|
+
animate: "pulse",
|
|
40
46
|
},
|
|
41
47
|
});
|
|
@@ -69,6 +69,8 @@ const WidgetShellError = ({
|
|
|
69
69
|
</div>
|
|
70
70
|
{onRetry && (
|
|
71
71
|
<Button
|
|
72
|
+
outline
|
|
73
|
+
size="sm"
|
|
72
74
|
type="button"
|
|
73
75
|
onClick={onRetry}
|
|
74
76
|
className="inline-flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs font-medium transition-colors duration-200 hover:bg-base-200"
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { cn } from "../../utilities";
|
|
2
|
+
import { Flex } from "../Flex";
|
|
3
|
+
import { Skeleton } from "../Skeleton";
|
|
2
4
|
|
|
3
5
|
export type WidgetShellSkeletonProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
4
6
|
/** Number of skeleton lines to show */
|
|
@@ -14,25 +16,20 @@ const WidgetShellSkeleton = ({
|
|
|
14
16
|
...props
|
|
15
17
|
}: WidgetShellSkeletonProps) => {
|
|
16
18
|
return (
|
|
17
|
-
<div
|
|
18
|
-
className={cn(
|
|
19
|
-
"rounded-lg border bg-base-100 shadow-sm",
|
|
20
|
-
className
|
|
21
|
-
)}
|
|
22
|
-
{...props}
|
|
23
|
-
>
|
|
19
|
+
<div className={cn("rounded-lg border bg-base-100 shadow-sm", className)} {...props}>
|
|
24
20
|
{header && (
|
|
25
|
-
<
|
|
26
|
-
<
|
|
27
|
-
<
|
|
28
|
-
</
|
|
21
|
+
<Flex direction="col" gap={2} className="border-b px-4 py-3">
|
|
22
|
+
<Skeleton animate="wave" className="inline-block h-4 w-32 rounded" />
|
|
23
|
+
<Skeleton animate="wave" className="mt-0.5 inline-block h-3 w-48 rounded" />
|
|
24
|
+
</Flex>
|
|
29
25
|
)}
|
|
30
26
|
<div className="p-4">
|
|
31
27
|
<div className="flex flex-col gap-3" role="status" aria-label="Loading">
|
|
32
28
|
{Array.from({ length: lines }, (_, i) => (
|
|
33
|
-
<
|
|
29
|
+
<Skeleton
|
|
30
|
+
animate="wave"
|
|
34
31
|
key={i}
|
|
35
|
-
className="
|
|
32
|
+
className="h-4 rounded"
|
|
36
33
|
style={{ width: `${100 - i * 15}%` }}
|
|
37
34
|
/>
|
|
38
35
|
))}
|