@mbao01/common 0.0.5 → 0.0.7
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/README.md +1 -2
- package/dist/types/components/Avatar/Avatar.d.ts +14 -0
- package/dist/types/components/Avatar/constants.d.ts +15 -0
- package/dist/types/components/Avatar/index.d.ts +1 -0
- package/dist/types/components/Avatar/types.d.ts +6 -0
- package/dist/types/components/Badge/Badge.d.ts +1 -1
- package/dist/types/components/Badge/constants.d.ts +5 -5
- package/dist/types/components/Badge/types.d.ts +3 -7
- package/dist/types/components/Breadcrumbs/Breadcrumbs.d.ts +3 -0
- package/dist/types/components/Breadcrumbs/index.d.ts +1 -0
- package/dist/types/components/Breadcrumbs/types.d.ts +2 -0
- package/dist/types/components/Button/Button.d.ts +11 -2
- package/dist/types/components/Button/constants.d.ts +7 -8
- package/dist/types/components/Button/types.d.ts +6 -12
- package/dist/types/components/Card/Card.d.ts +1 -1
- package/dist/types/components/Card/constants.d.ts +6 -0
- package/dist/types/components/Card/types.d.ts +3 -18
- package/dist/types/components/Description/Description.d.ts +2 -2
- package/dist/types/components/Loading/Loading.d.ts +2 -0
- package/dist/types/components/Loading/constants.d.ts +5 -0
- package/dist/types/components/Loading/index.d.ts +1 -0
- package/dist/types/components/Loading/types.d.ts +3 -0
- package/dist/types/components/Progress/Progress.d.ts +5 -0
- package/dist/types/components/Progress/constants.d.ts +6 -0
- package/dist/types/components/Progress/index.d.ts +1 -0
- package/dist/types/components/Progress/types.d.ts +4 -0
- package/dist/types/components/Separator/Separator.d.ts +2 -0
- package/dist/types/components/Separator/constants.d.ts +3 -0
- package/dist/types/components/Separator/index.d.ts +1 -0
- package/dist/types/components/Separator/types.d.ts +2 -0
- package/dist/types/components/Skeleton/Skeleton.d.ts +1 -1
- package/dist/types/components/Skeleton/constants.d.ts +6 -5
- package/dist/types/components/Skeleton/types.d.ts +3 -7
- package/dist/types/components/Text/Text.d.ts +2 -4
- package/dist/types/components/Text/constants.d.ts +4 -5
- package/dist/types/components/Text/types.d.ts +4 -9
- package/dist/types/components/Tooltip/Tooltip.d.ts +14 -2
- package/dist/types/components/Tooltip/constants.d.ts +6 -5
- package/dist/types/components/Tooltip/types.d.ts +5 -10
- package/dist/types/index.d.ts +5 -0
- package/dist/types/libs/cva.d.ts +1 -0
- package/dist/types/libs/index.d.ts +1 -0
- package/dist/types/utilities/cn.d.ts +2 -0
- package/dist/types/utilities/getSubpaths/getSubpaths.d.ts +6 -0
- package/dist/types/utilities/getSubpaths/index.d.ts +1 -0
- package/dist/types/utilities/index.d.ts +2 -0
- package/package.json +14 -4
- package/plugin.js +1 -3
- package/src/components/Avatar/Avatar.tsx +59 -0
- package/src/components/Avatar/constants.ts +69 -0
- package/src/components/Avatar/index.ts +1 -0
- package/src/components/Avatar/types.ts +25 -0
- package/src/components/Badge/Badge.tsx +4 -14
- package/src/components/Badge/constants.ts +28 -30
- package/src/components/Badge/types.ts +4 -17
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +13 -0
- package/src/components/Breadcrumbs/index.ts +1 -0
- package/src/components/Breadcrumbs/types.ts +3 -0
- package/src/components/Button/Button.tsx +51 -37
- package/src/components/Button/constants.ts +39 -43
- package/src/components/Button/types.ts +7 -25
- package/src/components/Card/Card.tsx +9 -15
- package/src/components/Card/constants.ts +22 -0
- package/src/components/Card/types.ts +4 -18
- package/src/components/Description/Description.tsx +11 -6
- package/src/components/Loading/Loading.tsx +18 -0
- package/src/components/Loading/constants.ts +30 -0
- package/src/components/Loading/index.ts +1 -0
- package/src/components/Loading/types.ts +5 -0
- package/src/components/Progress/Progress.tsx +31 -0
- package/src/components/Progress/constants.ts +49 -0
- package/src/components/Progress/index.ts +1 -0
- package/src/components/Progress/types.ts +9 -0
- package/src/components/Separator/Separator.tsx +20 -0
- package/src/components/Separator/constants.ts +10 -0
- package/src/components/Separator/index.ts +1 -0
- package/src/components/Separator/types.ts +5 -0
- package/src/components/Skeleton/Skeleton.tsx +7 -11
- package/src/components/Skeleton/constants.ts +39 -37
- package/src/components/Skeleton/types.ts +4 -7
- package/src/components/Text/Text.tsx +24 -9
- package/src/components/Text/constants.ts +26 -28
- package/src/components/Text/types.ts +9 -20
- package/src/components/Tooltip/Tooltip.tsx +35 -21
- package/src/components/Tooltip/constants.ts +32 -31
- package/src/components/Tooltip/types.ts +13 -22
- package/src/index.ts +5 -0
- package/src/libs/cva.ts +1 -0
- package/src/libs/index.ts +1 -0
- package/src/utilities/cn.ts +6 -0
- package/src/utilities/getSubpaths/getSubpaths.ts +34 -0
- package/src/utilities/getSubpaths/index.ts +1 -0
- package/src/utilities/index.ts +2 -0
- package/vitest-setup.ts +11 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Progress } from "./Progress";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as ProgressPrimitive from "@radix-ui/react-progress";
|
|
2
|
+
import { type VariantProps } from "../../libs";
|
|
3
|
+
import { getProgressClasses } from "./constants";
|
|
4
|
+
|
|
5
|
+
export type ProgressProps = Omit<
|
|
6
|
+
React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>,
|
|
7
|
+
"asChild"
|
|
8
|
+
> &
|
|
9
|
+
VariantProps<typeof getProgressClasses>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as SeparatorPrimitive from "@radix-ui/react-separator";
|
|
4
|
+
import { type SeparatorProps } from "./types";
|
|
5
|
+
import { getSeparatorClasses } from "./constants";
|
|
6
|
+
import { cn } from "../../utilities";
|
|
7
|
+
|
|
8
|
+
export const Separator = ({
|
|
9
|
+
className,
|
|
10
|
+
orientation = "horizontal",
|
|
11
|
+
decorative = true,
|
|
12
|
+
...props
|
|
13
|
+
}: SeparatorProps) => (
|
|
14
|
+
<SeparatorPrimitive.Root
|
|
15
|
+
decorative={decorative}
|
|
16
|
+
orientation={orientation}
|
|
17
|
+
className={cn(getSeparatorClasses({ orientation }), className)}
|
|
18
|
+
{...props}
|
|
19
|
+
/>
|
|
20
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Separator } from "./Separator";
|
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
import c from "clsx";
|
|
2
1
|
import { type SkeletonProps } from "./types";
|
|
3
|
-
import {
|
|
2
|
+
import { getSkeletonClasses } from "./constants";
|
|
3
|
+
import { cn } from "../../utilities";
|
|
4
4
|
|
|
5
5
|
export const Skeleton = ({
|
|
6
|
-
className,
|
|
7
6
|
round,
|
|
8
7
|
width,
|
|
9
8
|
height,
|
|
9
|
+
variant,
|
|
10
|
+
className,
|
|
10
11
|
...props
|
|
11
12
|
}: SkeletonProps) => {
|
|
12
13
|
return (
|
|
13
14
|
<div
|
|
14
|
-
{
|
|
15
|
-
|
|
16
|
-
"skeleton",
|
|
17
|
-
getSkeletonSize({ width, height }),
|
|
18
|
-
{
|
|
19
|
-
"rounded-md": !round,
|
|
20
|
-
"rounded-full": round,
|
|
21
|
-
},
|
|
15
|
+
className={cn(
|
|
16
|
+
getSkeletonClasses({ width, height, round, variant }),
|
|
22
17
|
className
|
|
23
18
|
)}
|
|
19
|
+
{...props}
|
|
24
20
|
/>
|
|
25
21
|
);
|
|
26
22
|
};
|
|
@@ -1,38 +1,40 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Size } from "./types";
|
|
1
|
+
import { cva } from "../../libs";
|
|
3
2
|
|
|
4
|
-
const
|
|
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
|
-
|
|
3
|
+
export const getSkeletonClasses = cva("skeleton", {
|
|
4
|
+
variants: {
|
|
5
|
+
variant: { pulse: "animate-pulse" },
|
|
6
|
+
width: {
|
|
7
|
+
2: "w-2",
|
|
8
|
+
4: "w-4",
|
|
9
|
+
8: "w-8",
|
|
10
|
+
12: "w-12",
|
|
11
|
+
16: "w-16",
|
|
12
|
+
24: "w-24",
|
|
13
|
+
32: "w-32",
|
|
14
|
+
48: "w-48",
|
|
15
|
+
64: "w-64",
|
|
16
|
+
full: "w-full",
|
|
17
|
+
},
|
|
18
|
+
height: {
|
|
19
|
+
2: "h-2",
|
|
20
|
+
4: "h-4",
|
|
21
|
+
8: "h-8",
|
|
22
|
+
12: "h-12",
|
|
23
|
+
16: "h-16",
|
|
24
|
+
24: "h-24",
|
|
25
|
+
32: "h-32",
|
|
26
|
+
48: "h-48",
|
|
27
|
+
64: "h-64",
|
|
28
|
+
full: "h-full",
|
|
29
|
+
},
|
|
30
|
+
round: {
|
|
31
|
+
true: "rounded-full",
|
|
32
|
+
false: "rounded-md",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
defaultVariants: {
|
|
36
|
+
width: "full",
|
|
37
|
+
height: 4,
|
|
38
|
+
round: false,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { type VariantProps } from "../../libs";
|
|
2
|
+
import { getSkeletonClasses } from "./constants";
|
|
2
3
|
|
|
3
|
-
export type SkeletonProps = React.HTMLAttributes<HTMLDivElement> &
|
|
4
|
-
|
|
5
|
-
height?: Size;
|
|
6
|
-
round?: boolean;
|
|
7
|
-
className?: string;
|
|
8
|
-
};
|
|
4
|
+
export type SkeletonProps = React.HTMLAttributes<HTMLDivElement> &
|
|
5
|
+
VariantProps<typeof getSkeletonClasses>;
|
|
@@ -1,12 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type TextProps } from "./types";
|
|
3
|
+
import { getTextClasses } from "./constants";
|
|
4
|
+
import { cn } from "../../utilities";
|
|
5
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
5
6
|
|
|
6
|
-
export const Text = ({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
export const Text = ({
|
|
8
|
+
as,
|
|
9
|
+
size,
|
|
10
|
+
variant,
|
|
11
|
+
children,
|
|
12
|
+
className,
|
|
13
|
+
...props
|
|
14
|
+
}: TextProps) => {
|
|
15
|
+
const Comp = as ? Slot : "span";
|
|
16
|
+
const SlotChild = as ? as : React.Fragment;
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<Comp
|
|
20
|
+
className={cn(getTextClasses({ size, variant }), className)}
|
|
21
|
+
{...props}
|
|
22
|
+
>
|
|
23
|
+
{/* slot merges it's prop into it's immediate child */}
|
|
24
|
+
<SlotChild>{children}</SlotChild>
|
|
25
|
+
</Comp>
|
|
11
26
|
);
|
|
12
27
|
};
|
|
@@ -1,29 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { TextSize, TextVariant } from './types';
|
|
1
|
+
import { cva } from "../../libs";
|
|
3
2
|
|
|
4
|
-
const
|
|
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
|
-
};
|
|
3
|
+
export const getTextClasses = cva("", {
|
|
4
|
+
variants: {
|
|
5
|
+
variant: {
|
|
6
|
+
info: "text-info",
|
|
7
|
+
error: "text-error",
|
|
8
|
+
success: "text-success",
|
|
9
|
+
warning: "text-warning",
|
|
10
|
+
primary: "text-primary",
|
|
11
|
+
secondary: "text-secondary",
|
|
12
|
+
accent: "text-accent",
|
|
13
|
+
neutral: "text-neutral",
|
|
14
|
+
},
|
|
15
|
+
size: {
|
|
16
|
+
xs: "text-xs",
|
|
17
|
+
sm: "text-sm",
|
|
18
|
+
base: "text-base",
|
|
19
|
+
lg: "text-lg",
|
|
20
|
+
xl: "text-xl",
|
|
21
|
+
"2xl": "text-2xl",
|
|
22
|
+
"3xl": "text-3xl",
|
|
23
|
+
"4xl": "text-4xl",
|
|
24
|
+
"5xl": "text-5xl",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
});
|
|
@@ -1,21 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { type VariantProps } from "../../libs";
|
|
2
|
+
import { getTextClasses } from "./constants";
|
|
2
3
|
|
|
3
|
-
export type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
| 'primary'
|
|
11
|
-
| 'secondary'
|
|
12
|
-
| 'accent'
|
|
13
|
-
| 'neutral';
|
|
14
|
-
|
|
15
|
-
export type TextProps = {
|
|
16
|
-
as?: TextTag;
|
|
17
|
-
size?: TextSize;
|
|
18
|
-
variant?: TextVariant;
|
|
19
|
-
children: React.ReactNode;
|
|
20
|
-
className?: string;
|
|
21
|
-
};
|
|
4
|
+
export type TextProps = React.HTMLAttributes<HTMLSpanElement> &
|
|
5
|
+
VariantProps<typeof getTextClasses> & {
|
|
6
|
+
as?: keyof Pick<
|
|
7
|
+
JSX.IntrinsicElements,
|
|
8
|
+
"h1" | "h2" | "h3" | "h4" | "h5" | "p"
|
|
9
|
+
>;
|
|
10
|
+
};
|
|
@@ -1,22 +1,36 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import React from "react";
|
|
2
|
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
3
|
+
import type { TooltipArrowProps, TooltipContentProps } from "./types";
|
|
4
|
+
import { getTooltipArrowClasses, getTooltipContentClasses } from "./constants";
|
|
5
|
+
import { cn } from "../../utilities";
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
7
|
+
const Tooltip = (props: TooltipPrimitive.TooltipProps) => (
|
|
8
|
+
<TooltipPrimitive.Root {...props} />
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
const TooltipArrow = ({ className, variant, ...props }: TooltipArrowProps) => (
|
|
12
|
+
<TooltipPrimitive.Arrow
|
|
13
|
+
className={cn(getTooltipArrowClasses({ variant }), className)}
|
|
14
|
+
{...props}
|
|
15
|
+
/>
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
const TooltipContent = React.forwardRef<
|
|
19
|
+
React.ElementRef<typeof TooltipPrimitive.Content>,
|
|
20
|
+
TooltipContentProps
|
|
21
|
+
>(({ className, variant, ...props }, ref) => (
|
|
22
|
+
<TooltipPrimitive.Content
|
|
23
|
+
ref={ref}
|
|
24
|
+
className={cn(getTooltipContentClasses({ variant }), className)}
|
|
25
|
+
{...props}
|
|
26
|
+
/>
|
|
27
|
+
));
|
|
28
|
+
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
|
29
|
+
|
|
30
|
+
Tooltip.Content = TooltipContent;
|
|
31
|
+
Tooltip.Arrow = TooltipArrow;
|
|
32
|
+
Tooltip.Portal = TooltipPrimitive.Portal;
|
|
33
|
+
Tooltip.Provider = TooltipPrimitive.Provider;
|
|
34
|
+
Tooltip.Trigger = TooltipPrimitive.Trigger;
|
|
35
|
+
|
|
36
|
+
export { Tooltip };
|
|
@@ -1,33 +1,34 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { TooltipPosition, TooltipVariant } from "./types";
|
|
1
|
+
import { cva } from "../../libs";
|
|
3
2
|
|
|
4
|
-
const
|
|
5
|
-
top:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
export const getTooltipContentClasses = cva(
|
|
4
|
+
"bg-base-200 text-base-content z-50 overflow-hidden rounded-md px-3 py-1.5 text-xs animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
5
|
+
{
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
primary: "bg-primary text-primary-content",
|
|
9
|
+
secondary: "bg-secondary text-secondary-content",
|
|
10
|
+
accent: "bg-accent text-accent-content",
|
|
11
|
+
neutral: "bg-neutral text-neutral-content",
|
|
12
|
+
info: "bg-info text-info-content",
|
|
13
|
+
success: "bg-success text-success-content",
|
|
14
|
+
warning: "bg-warning text-warning-content",
|
|
15
|
+
error: "bg-error text-error-content",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
}
|
|
19
|
+
);
|
|
10
20
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const getTooltipClasses = ({
|
|
26
|
-
variant,
|
|
27
|
-
position,
|
|
28
|
-
}: {
|
|
29
|
-
variant?: TooltipVariant;
|
|
30
|
-
position?: TooltipPosition;
|
|
31
|
-
}) => {
|
|
32
|
-
return c("tooltip", TOOLTIP_VARIANTS[variant!], TOOLTIP_POSITION[position!]);
|
|
33
|
-
};
|
|
21
|
+
export const getTooltipArrowClasses = cva("fill-base-200", {
|
|
22
|
+
variants: {
|
|
23
|
+
variant: {
|
|
24
|
+
primary: "fill-primary",
|
|
25
|
+
secondary: "fill-secondary",
|
|
26
|
+
accent: "fill-accent",
|
|
27
|
+
neutral: "fill-neutral",
|
|
28
|
+
info: "fill-info",
|
|
29
|
+
success: "fill-success",
|
|
30
|
+
warning: "fill-warning",
|
|
31
|
+
error: "fill-error",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
});
|
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type VariantProps } from "../../libs";
|
|
2
|
+
import { getTooltipArrowClasses, getTooltipContentClasses } from "./constants";
|
|
3
|
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
2
4
|
|
|
3
|
-
export type
|
|
5
|
+
export type TooltipArrowProps = React.HTMLAttributes<
|
|
6
|
+
React.ElementRef<typeof TooltipPrimitive.Arrow>
|
|
7
|
+
> &
|
|
8
|
+
TooltipPrimitive.TooltipArrowProps &
|
|
9
|
+
VariantProps<typeof getTooltipArrowClasses>;
|
|
4
10
|
|
|
5
|
-
export type
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
| 'accent'
|
|
11
|
-
| 'ghost'
|
|
12
|
-
| 'link'
|
|
13
|
-
| 'info'
|
|
14
|
-
| 'success'
|
|
15
|
-
| 'warning'
|
|
16
|
-
| 'error';
|
|
17
|
-
|
|
18
|
-
export type TooltipProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
19
|
-
content: string;
|
|
20
|
-
children: ReactNode;
|
|
21
|
-
variant?: TooltipVariant;
|
|
22
|
-
position?: TooltipPosition;
|
|
23
|
-
className?: string;
|
|
24
|
-
};
|
|
11
|
+
export type TooltipContentProps = React.HTMLAttributes<
|
|
12
|
+
React.ElementRef<typeof TooltipPrimitive.Content>
|
|
13
|
+
> &
|
|
14
|
+
TooltipPrimitive.TooltipContentProps &
|
|
15
|
+
VariantProps<typeof getTooltipContentClasses>;
|
package/src/index.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
/** actions */
|
|
2
2
|
export * from "./components/Button";
|
|
3
|
+
export * from "./components/Breadcrumbs";
|
|
3
4
|
|
|
4
5
|
/** data display */
|
|
6
|
+
export * from "./components/Avatar";
|
|
5
7
|
export * from "./components/Badge";
|
|
6
8
|
export * from "./components/Card";
|
|
7
9
|
export * from "./components/Description";
|
|
10
|
+
export * from "./components/Progress";
|
|
11
|
+
export * from "./components/Separator";
|
|
8
12
|
export * from "./components/Text";
|
|
9
13
|
|
|
10
14
|
/** data input */
|
|
11
15
|
|
|
12
16
|
/** feedback */
|
|
17
|
+
export * from "./components/Loading";
|
|
13
18
|
export * from "./components/Skeleton";
|
|
14
19
|
export * from "./components/Tooltip";
|
package/src/libs/cva.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { cva, type VariantProps } from "class-variance-authority";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { cva, type VariantProps } from "./cva";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const PATH_SEPARATOR = "/";
|
|
2
|
+
|
|
3
|
+
const createPathObject = (
|
|
4
|
+
segment: string,
|
|
5
|
+
pathname: string,
|
|
6
|
+
pathLabels?: Record<string, string>
|
|
7
|
+
) => ({
|
|
8
|
+
href: { pathname },
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
10
|
+
label: pathLabels?.[pathname] || segment, // always fallback to segment if label does not exist
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const getSubpaths = (
|
|
14
|
+
pathname: string,
|
|
15
|
+
pathLabels?: Record<string, string> | undefined,
|
|
16
|
+
includeRoot?: boolean
|
|
17
|
+
) => {
|
|
18
|
+
const segments = pathname?.split(PATH_SEPARATOR).filter(Boolean);
|
|
19
|
+
|
|
20
|
+
const breadcrumbs = segments.map((segment, index) => {
|
|
21
|
+
const path = `${PATH_SEPARATOR}${segments
|
|
22
|
+
.slice(0, index + 1)
|
|
23
|
+
.join(PATH_SEPARATOR)}`;
|
|
24
|
+
|
|
25
|
+
return createPathObject(segment, path, pathLabels);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
if (includeRoot) {
|
|
29
|
+
const ROOT_PATH = PATH_SEPARATOR;
|
|
30
|
+
breadcrumbs.unshift(createPathObject("", ROOT_PATH, pathLabels));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return breadcrumbs;
|
|
34
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getSubpaths } from "./getSubpaths";
|
package/vitest-setup.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import { afterEach } from "vitest";
|
|
1
|
+
import { afterEach, vi } from "vitest";
|
|
2
2
|
import { cleanup } from "@testing-library/react";
|
|
3
3
|
import "@testing-library/jest-dom/vitest";
|
|
4
4
|
|
|
5
|
+
// Mock the ResizeObserver
|
|
6
|
+
const ResizeObserverMock = vi.fn(() => ({
|
|
7
|
+
observe: vi.fn(),
|
|
8
|
+
unobserve: vi.fn(),
|
|
9
|
+
disconnect: vi.fn(),
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
// Stub the global ResizeObserver
|
|
13
|
+
vi.stubGlobal("ResizeObserver", ResizeObserverMock);
|
|
14
|
+
|
|
5
15
|
// runs a cleanup after each test case (e.g. clearing jsdom)
|
|
6
16
|
afterEach(() => {
|
|
7
17
|
cleanup();
|