@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.
Files changed (94) hide show
  1. package/README.md +1 -2
  2. package/dist/types/components/Avatar/Avatar.d.ts +14 -0
  3. package/dist/types/components/Avatar/constants.d.ts +15 -0
  4. package/dist/types/components/Avatar/index.d.ts +1 -0
  5. package/dist/types/components/Avatar/types.d.ts +6 -0
  6. package/dist/types/components/Badge/Badge.d.ts +1 -1
  7. package/dist/types/components/Badge/constants.d.ts +5 -5
  8. package/dist/types/components/Badge/types.d.ts +3 -7
  9. package/dist/types/components/Breadcrumbs/Breadcrumbs.d.ts +3 -0
  10. package/dist/types/components/Breadcrumbs/index.d.ts +1 -0
  11. package/dist/types/components/Breadcrumbs/types.d.ts +2 -0
  12. package/dist/types/components/Button/Button.d.ts +11 -2
  13. package/dist/types/components/Button/constants.d.ts +7 -8
  14. package/dist/types/components/Button/types.d.ts +6 -12
  15. package/dist/types/components/Card/Card.d.ts +1 -1
  16. package/dist/types/components/Card/constants.d.ts +6 -0
  17. package/dist/types/components/Card/types.d.ts +3 -18
  18. package/dist/types/components/Description/Description.d.ts +2 -2
  19. package/dist/types/components/Loading/Loading.d.ts +2 -0
  20. package/dist/types/components/Loading/constants.d.ts +5 -0
  21. package/dist/types/components/Loading/index.d.ts +1 -0
  22. package/dist/types/components/Loading/types.d.ts +3 -0
  23. package/dist/types/components/Progress/Progress.d.ts +5 -0
  24. package/dist/types/components/Progress/constants.d.ts +6 -0
  25. package/dist/types/components/Progress/index.d.ts +1 -0
  26. package/dist/types/components/Progress/types.d.ts +4 -0
  27. package/dist/types/components/Separator/Separator.d.ts +2 -0
  28. package/dist/types/components/Separator/constants.d.ts +3 -0
  29. package/dist/types/components/Separator/index.d.ts +1 -0
  30. package/dist/types/components/Separator/types.d.ts +2 -0
  31. package/dist/types/components/Skeleton/Skeleton.d.ts +1 -1
  32. package/dist/types/components/Skeleton/constants.d.ts +6 -5
  33. package/dist/types/components/Skeleton/types.d.ts +3 -7
  34. package/dist/types/components/Text/Text.d.ts +2 -4
  35. package/dist/types/components/Text/constants.d.ts +4 -5
  36. package/dist/types/components/Text/types.d.ts +4 -9
  37. package/dist/types/components/Tooltip/Tooltip.d.ts +14 -2
  38. package/dist/types/components/Tooltip/constants.d.ts +6 -5
  39. package/dist/types/components/Tooltip/types.d.ts +5 -10
  40. package/dist/types/index.d.ts +5 -0
  41. package/dist/types/libs/cva.d.ts +1 -0
  42. package/dist/types/libs/index.d.ts +1 -0
  43. package/dist/types/utilities/cn.d.ts +2 -0
  44. package/dist/types/utilities/getSubpaths/getSubpaths.d.ts +6 -0
  45. package/dist/types/utilities/getSubpaths/index.d.ts +1 -0
  46. package/dist/types/utilities/index.d.ts +2 -0
  47. package/package.json +14 -4
  48. package/plugin.js +1 -3
  49. package/src/components/Avatar/Avatar.tsx +59 -0
  50. package/src/components/Avatar/constants.ts +69 -0
  51. package/src/components/Avatar/index.ts +1 -0
  52. package/src/components/Avatar/types.ts +25 -0
  53. package/src/components/Badge/Badge.tsx +4 -14
  54. package/src/components/Badge/constants.ts +28 -30
  55. package/src/components/Badge/types.ts +4 -17
  56. package/src/components/Breadcrumbs/Breadcrumbs.tsx +13 -0
  57. package/src/components/Breadcrumbs/index.ts +1 -0
  58. package/src/components/Breadcrumbs/types.ts +3 -0
  59. package/src/components/Button/Button.tsx +51 -37
  60. package/src/components/Button/constants.ts +39 -43
  61. package/src/components/Button/types.ts +7 -25
  62. package/src/components/Card/Card.tsx +9 -15
  63. package/src/components/Card/constants.ts +22 -0
  64. package/src/components/Card/types.ts +4 -18
  65. package/src/components/Description/Description.tsx +11 -6
  66. package/src/components/Loading/Loading.tsx +18 -0
  67. package/src/components/Loading/constants.ts +30 -0
  68. package/src/components/Loading/index.ts +1 -0
  69. package/src/components/Loading/types.ts +5 -0
  70. package/src/components/Progress/Progress.tsx +31 -0
  71. package/src/components/Progress/constants.ts +49 -0
  72. package/src/components/Progress/index.ts +1 -0
  73. package/src/components/Progress/types.ts +9 -0
  74. package/src/components/Separator/Separator.tsx +20 -0
  75. package/src/components/Separator/constants.ts +10 -0
  76. package/src/components/Separator/index.ts +1 -0
  77. package/src/components/Separator/types.ts +5 -0
  78. package/src/components/Skeleton/Skeleton.tsx +7 -11
  79. package/src/components/Skeleton/constants.ts +39 -37
  80. package/src/components/Skeleton/types.ts +4 -7
  81. package/src/components/Text/Text.tsx +24 -9
  82. package/src/components/Text/constants.ts +26 -28
  83. package/src/components/Text/types.ts +9 -20
  84. package/src/components/Tooltip/Tooltip.tsx +35 -21
  85. package/src/components/Tooltip/constants.ts +32 -31
  86. package/src/components/Tooltip/types.ts +13 -22
  87. package/src/index.ts +5 -0
  88. package/src/libs/cva.ts +1 -0
  89. package/src/libs/index.ts +1 -0
  90. package/src/utilities/cn.ts +6 -0
  91. package/src/utilities/getSubpaths/getSubpaths.ts +34 -0
  92. package/src/utilities/getSubpaths/index.ts +1 -0
  93. package/src/utilities/index.ts +2 -0
  94. package/vitest-setup.ts +11 -1
package/README.md CHANGED
@@ -23,8 +23,7 @@ export default {
23
23
  ...
24
24
  ],
25
25
  "plugins": [
26
- require("@mbao01/common/plugin"), // -> import the library plugin
27
- ...
26
+ ...require("@mbao01/common/plugin"), // -> import the library plugin
28
27
  ]
29
28
  }
30
29
  ```
@@ -0,0 +1,14 @@
1
+ import type { AvatarProps, AvatarImageProps, AvatarFallbackProps } from "./types";
2
+ declare const Avatar: {
3
+ ({ className, size, status, ...props }: AvatarProps): import("react/jsx-runtime").JSX.Element;
4
+ displayName: string | undefined;
5
+ Image: {
6
+ ({ className, ring, shape, variant, ...props }: AvatarImageProps): import("react/jsx-runtime").JSX.Element;
7
+ displayName: string | undefined;
8
+ };
9
+ Fallback: {
10
+ ({ className, size, ring, shape, variant, ...props }: AvatarFallbackProps): import("react/jsx-runtime").JSX.Element;
11
+ displayName: string | undefined;
12
+ };
13
+ };
14
+ export { Avatar };
@@ -0,0 +1,15 @@
1
+ export declare const getAvatarClasses: (props?: ({
2
+ size?: 4 | 8 | 12 | 16 | 24 | 32 | 48 | 64 | null | undefined;
3
+ status?: "online" | "offline" | null | undefined;
4
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
5
+ export declare const getAvatarImageClasses: (props?: ({
6
+ variant?: "accent" | "default" | "error" | "ghost" | "info" | "neutral" | "primary" | "secondary" | "success" | "warning" | null | undefined;
7
+ shape?: "circle" | "round" | "hexagon" | "triangle" | "television" | null | undefined;
8
+ ring?: boolean | null | undefined;
9
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
10
+ export declare const getAvatarFallbackClasses: (props?: ({
11
+ size?: 4 | 8 | 12 | 16 | 24 | 32 | 48 | 64 | null | undefined;
12
+ variant?: "accent" | "default" | "error" | "ghost" | "info" | "neutral" | "primary" | "secondary" | "success" | "warning" | null | undefined;
13
+ shape?: "circle" | "round" | "hexagon" | "triangle" | "television" | null | undefined;
14
+ ring?: boolean | null | undefined;
15
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
@@ -0,0 +1 @@
1
+ export { Avatar } from "./Avatar";
@@ -0,0 +1,6 @@
1
+ import * as AvatarPrimitive from "@radix-ui/react-avatar";
2
+ import { type VariantProps } from "../../libs";
3
+ import { getAvatarClasses, getAvatarFallbackClasses, getAvatarImageClasses } from "./constants";
4
+ export type AvatarProps = Omit<React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>, "asChild" | "size"> & VariantProps<typeof getAvatarClasses>;
5
+ export type AvatarImageProps = Omit<React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>, "asChild"> & VariantProps<typeof getAvatarImageClasses>;
6
+ export type AvatarFallbackProps = Omit<React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>, "asChild"> & VariantProps<typeof getAvatarFallbackClasses>;
@@ -1,2 +1,2 @@
1
1
  import { type BadgeProps } from "./types";
2
- export declare const Badge: ({ size, outline, variant, children, className, ...props }: BadgeProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const Badge: ({ size, outline, variant, className, ...props }: BadgeProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,5 @@
1
- import type { BadgeSize, BadgeVariant } from "./types";
2
- export declare const getBadgeClasses: ({ size, variant, }: {
3
- size?: BadgeSize | undefined;
4
- variant?: BadgeVariant | undefined;
5
- }) => string;
1
+ export declare const getBadgeClasses: (props?: ({
2
+ variant?: "accent" | "error" | "ghost" | "info" | "neutral" | "primary" | "secondary" | "success" | "warning" | null | undefined;
3
+ outline?: boolean | null | undefined;
4
+ size?: "xs" | "sm" | "md" | "lg" | null | undefined;
5
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
@@ -1,7 +1,3 @@
1
- export type BadgeSize = "xs" | "sm" | "md" | "lg";
2
- export type BadgeVariant = "neutral" | "primary" | "secondary" | "accent" | "ghost" | "info" | "success" | "warning" | "error";
3
- export type BadgeProps = React.HTMLAttributes<HTMLSpanElement> & {
4
- size?: BadgeSize;
5
- outline?: boolean;
6
- variant?: BadgeVariant;
7
- };
1
+ import { type VariantProps } from "../../libs";
2
+ import { getBadgeClasses } from "./constants";
3
+ export type BadgeProps = React.HTMLAttributes<HTMLSpanElement> & VariantProps<typeof getBadgeClasses>;
@@ -0,0 +1,3 @@
1
+ import type { BreadcrumbProps, BreadcrumbsProps } from "./types";
2
+ export declare const Breadcrumbs: (props: BreadcrumbsProps) => import("react/jsx-runtime").JSX.Element;
3
+ export declare const Breadcrumb: (props: BreadcrumbProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export { Breadcrumbs } from "./Breadcrumbs";
@@ -0,0 +1,2 @@
1
+ export type BreadcrumbProps = React.HTMLAttributes<HTMLLIElement>;
2
+ export type BreadcrumbsProps = React.HTMLAttributes<HTMLUListElement>;
@@ -1,2 +1,11 @@
1
- import { type ButtonProps } from "./types";
2
- export declare const Button: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
1
+ import React from "react";
2
+ declare const Button: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & import("class-variance-authority").VariantProps<(props?: ({
3
+ variant?: "accent" | "default" | "error" | "ghost" | "info" | "link" | "neutral" | "primary" | "secondary" | "success" | "warning" | null | undefined;
4
+ outline?: boolean | null | undefined;
5
+ wide?: boolean | null | undefined;
6
+ size?: "xs" | "sm" | "md" | "lg" | null | undefined;
7
+ isLoading?: boolean | null | undefined;
8
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string> & {
9
+ as?: "a" | "span" | "p" | undefined;
10
+ } & React.RefAttributes<HTMLButtonElement>>;
11
+ export { Button };
@@ -1,8 +1,7 @@
1
- import type { ButtonSize, ButtonVariant } from './types';
2
- export declare const getButtonClasses: ({ size, wide, loading, outline, variant, }: {
3
- size?: ButtonSize | undefined;
4
- wide?: boolean | undefined;
5
- loading?: boolean | undefined;
6
- outline?: boolean | undefined;
7
- variant?: ButtonVariant | undefined;
8
- }) => string;
1
+ export declare const getButtonClasses: (props?: ({
2
+ variant?: "accent" | "default" | "error" | "ghost" | "info" | "link" | "neutral" | "primary" | "secondary" | "success" | "warning" | null | undefined;
3
+ outline?: boolean | null | undefined;
4
+ wide?: boolean | null | undefined;
5
+ size?: "xs" | "sm" | "md" | "lg" | null | undefined;
6
+ isLoading?: boolean | null | undefined;
7
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
@@ -1,12 +1,6 @@
1
- import type { ButtonHTMLAttributes, ReactNode } from 'react';
2
- export type ButtonSize = 'xs' | 'sm' | 'md' | 'lg';
3
- export type ButtonVariant = 'default' | 'neutral' | 'primary' | 'secondary' | 'accent' | 'ghost' | 'link' | 'info' | 'success' | 'warning' | 'error';
4
- export type ButtonProps = {
5
- size?: ButtonSize;
6
- wide?: boolean;
7
- label: ReactNode;
8
- loading?: boolean;
9
- outline?: boolean;
10
- variant?: ButtonVariant;
11
- disabled?: boolean;
12
- } & ButtonHTMLAttributes<HTMLButtonElement>;
1
+ import { type VariantProps } from "../../libs";
2
+ import { type ButtonHTMLAttributes } from "react";
3
+ import { getButtonClasses } from "./constants";
4
+ export type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & VariantProps<typeof getButtonClasses> & {
5
+ as?: keyof Pick<JSX.IntrinsicElements, "a" | "span" | "p">;
6
+ };
@@ -1,4 +1,4 @@
1
- import { CardContentProps, CardDescriptionProps, CardFooterProps, CardHeaderProps, CardImageProps, CardProps } from "./types";
1
+ import type { CardContentProps, CardDescriptionProps, CardFooterProps, CardHeaderProps, CardImageProps, CardProps } from "./types";
2
2
  declare const Card: {
3
3
  ({ compact, bordered, horizontal, overlay, className, ...props }: CardProps): import("react/jsx-runtime").JSX.Element;
4
4
  Header: ({ className, ...props }: CardHeaderProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ export declare const getCardClasses: (props?: ({
2
+ bordered?: boolean | null | undefined;
3
+ compact?: boolean | null | undefined;
4
+ horizontal?: boolean | null | undefined;
5
+ overlay?: boolean | null | undefined;
6
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
@@ -1,22 +1,7 @@
1
1
  import React from "react";
2
- export type CardProps = {
3
- /**
4
- * applies smaller padding to the card.
5
- */
6
- compact?: boolean;
7
- /**
8
- * applies border to the card.
9
- */
10
- bordered?: boolean;
11
- /**
12
- * shows the card horizontally with image to the right or left of it.
13
- */
14
- horizontal?: boolean;
15
- /**
16
- * overlay is used to make the image full width with the content on top.
17
- */
18
- overlay?: boolean;
19
- } & React.HTMLAttributes<HTMLDivElement>;
2
+ import { type VariantProps } from "../../libs";
3
+ import { getCardClasses } from "./constants";
4
+ export type CardProps = React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof getCardClasses>;
20
5
  export type CardContentProps = React.HTMLAttributes<HTMLDivElement>;
21
6
  export type CardImageProps = React.ImgHTMLAttributes<HTMLImageElement>;
22
7
  export type CardHeaderProps = React.HTMLAttributes<HTMLDivElement>;
@@ -1,7 +1,7 @@
1
1
  import type { DescriptionProps, DescriptionTermProps, DescriptionDetailProps } from "./types";
2
2
  declare const Description: {
3
3
  (props: DescriptionProps): import("react/jsx-runtime").JSX.Element;
4
- Term: (props: DescriptionTermProps) => import("react/jsx-runtime").JSX.Element;
5
- Detail: (props: DescriptionDetailProps) => import("react/jsx-runtime").JSX.Element;
4
+ Term: ({ className, ...props }: DescriptionTermProps) => import("react/jsx-runtime").JSX.Element;
5
+ Detail: ({ className, ...props }: DescriptionDetailProps) => import("react/jsx-runtime").JSX.Element;
6
6
  };
7
7
  export { Description };
@@ -0,0 +1,2 @@
1
+ import { type LoadingProps } from "./types";
2
+ export declare const Loading: ({ size, intent, variant, className, ...props }: LoadingProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ export declare const getLoadingClasses: (props?: ({
2
+ variant?: "spinner" | "dots" | "ring" | "ball" | "bars" | "infinity" | null | undefined;
3
+ intent?: "accent" | "error" | "info" | "neutral" | "primary" | "secondary" | "success" | "warning" | null | undefined;
4
+ size?: "xs" | "sm" | "md" | "lg" | null | undefined;
5
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
@@ -0,0 +1 @@
1
+ export { Loading } from "./Loading";
@@ -0,0 +1,3 @@
1
+ import { type VariantProps } from "../../libs";
2
+ import { getLoadingClasses } from "./constants";
3
+ export type LoadingProps = React.HTMLAttributes<HTMLSpanElement> & VariantProps<typeof getLoadingClasses>;
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ import * as ProgressPrimitive from "@radix-ui/react-progress";
3
+ export declare const Progress: React.ForwardRefExoticComponent<Omit<Omit<ProgressPrimitive.ProgressProps & React.RefAttributes<HTMLDivElement>, "ref">, "asChild"> & import("class-variance-authority").VariantProps<(props?: ({
4
+ variant?: "accent" | "error" | "ghost" | "info" | "link" | "neutral" | "primary" | "secondary" | "success" | "warning" | "base" | null | undefined;
5
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string> & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,6 @@
1
+ export declare const getProgressClasses: (props?: ({
2
+ variant?: "accent" | "error" | "ghost" | "info" | "link" | "neutral" | "primary" | "secondary" | "success" | "warning" | "base" | null | undefined;
3
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
4
+ export declare const getProgressIndicatorClasses: (props?: ({
5
+ variant?: "accent" | "error" | "ghost" | "info" | "link" | "neutral" | "primary" | "secondary" | "success" | "warning" | "base" | null | undefined;
6
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
@@ -0,0 +1 @@
1
+ export { Progress } from "./Progress";
@@ -0,0 +1,4 @@
1
+ import * as ProgressPrimitive from "@radix-ui/react-progress";
2
+ import { type VariantProps } from "../../libs";
3
+ import { getProgressClasses } from "./constants";
4
+ export type ProgressProps = Omit<React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>, "asChild"> & VariantProps<typeof getProgressClasses>;
@@ -0,0 +1,2 @@
1
+ import { type SeparatorProps } from "./types";
2
+ export declare const Separator: ({ className, orientation, decorative, ...props }: SeparatorProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ export declare const getSeparatorClasses: (props?: ({
2
+ orientation?: "horizontal" | "vertical" | null | undefined;
3
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
@@ -0,0 +1 @@
1
+ export { Separator } from "./Separator";
@@ -0,0 +1,2 @@
1
+ import * as SeparatorPrimitive from "@radix-ui/react-separator";
2
+ export type SeparatorProps = React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>;
@@ -1,2 +1,2 @@
1
1
  import { type SkeletonProps } from "./types";
2
- export declare const Skeleton: ({ className, round, width, height, ...props }: SkeletonProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const Skeleton: ({ round, width, height, variant, className, ...props }: SkeletonProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,6 @@
1
- import { Size } from "./types";
2
- export declare const getSkeletonSize: ({ width, height, }: {
3
- width?: Size | undefined;
4
- height?: Size | undefined;
5
- }) => string;
1
+ export declare const getSkeletonClasses: (props?: ({
2
+ variant?: "pulse" | null | undefined;
3
+ width?: 4 | 8 | 12 | 16 | 24 | 32 | 48 | 64 | 2 | "full" | null | undefined;
4
+ height?: 4 | 8 | 12 | 16 | 24 | 32 | 48 | 64 | 2 | "full" | null | undefined;
5
+ round?: boolean | null | undefined;
6
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
@@ -1,7 +1,3 @@
1
- export type Size = 2 | 4 | 8 | 12 | 16 | 24 | 32 | 48 | 64 | "full";
2
- export type SkeletonProps = React.HTMLAttributes<HTMLDivElement> & {
3
- width?: Size;
4
- height?: Size;
5
- round?: boolean;
6
- className?: string;
7
- };
1
+ import { type VariantProps } from "../../libs";
2
+ import { getSkeletonClasses } from "./constants";
3
+ export type SkeletonProps = React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof getSkeletonClasses>;
@@ -1,4 +1,2 @@
1
- import { type TextProps } from './types';
2
- export declare const Text: ({ as, size, variant, children, className }: TextProps) => import("react").DetailedReactHTMLElement<{
3
- className: string;
4
- }, HTMLElement>;
1
+ import { type TextProps } from "./types";
2
+ export declare const Text: ({ as, size, variant, children, className, ...props }: TextProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,4 @@
1
- import type { TextSize, TextVariant } from './types';
2
- export declare const getTextClasses: ({ size, variant }: {
3
- size?: TextSize | undefined;
4
- variant?: TextVariant | undefined;
5
- }) => string;
1
+ export declare const getTextClasses: (props?: ({
2
+ variant?: "accent" | "error" | "info" | "neutral" | "primary" | "secondary" | "success" | "warning" | null | undefined;
3
+ size?: "xs" | "sm" | "lg" | "base" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | null | undefined;
4
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
@@ -1,10 +1,5 @@
1
- export type TextSize = 'xs' | 'sm' | 'base' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl';
2
- export type TextTag = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'p' | 'span';
3
- export type TextVariant = 'info' | 'error' | 'success' | 'warning' | 'primary' | 'secondary' | 'accent' | 'neutral';
4
- export type TextProps = {
5
- as?: TextTag;
6
- size?: TextSize;
7
- variant?: TextVariant;
8
- children: React.ReactNode;
9
- className?: string;
1
+ import { type VariantProps } from "../../libs";
2
+ import { getTextClasses } from "./constants";
3
+ export type TextProps = React.HTMLAttributes<HTMLSpanElement> & VariantProps<typeof getTextClasses> & {
4
+ as?: keyof Pick<JSX.IntrinsicElements, "h1" | "h2" | "h3" | "h4" | "h5" | "p">;
10
5
  };
@@ -1,2 +1,14 @@
1
- import { type TooltipProps } from './types';
2
- export declare const Tooltip: ({ content, children, variant, position, className, ...props }: TooltipProps) => import("react/jsx-runtime").JSX.Element;
1
+ import React from "react";
2
+ import * as TooltipPrimitive from "@radix-ui/react-tooltip";
3
+ import type { TooltipArrowProps } from "./types";
4
+ declare const Tooltip: {
5
+ (props: TooltipPrimitive.TooltipProps): import("react/jsx-runtime").JSX.Element;
6
+ Content: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & TooltipPrimitive.TooltipContentProps & import("class-variance-authority").VariantProps<(props?: ({
7
+ variant?: "accent" | "error" | "info" | "neutral" | "primary" | "secondary" | "success" | "warning" | null | undefined;
8
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string> & React.RefAttributes<HTMLDivElement>>;
9
+ Arrow: ({ className, variant, ...props }: TooltipArrowProps) => import("react/jsx-runtime").JSX.Element;
10
+ Portal: React.FC<TooltipPrimitive.TooltipPortalProps>;
11
+ Provider: React.FC<TooltipPrimitive.TooltipProviderProps>;
12
+ Trigger: React.ForwardRefExoticComponent<TooltipPrimitive.TooltipTriggerProps & React.RefAttributes<HTMLButtonElement>>;
13
+ };
14
+ export { Tooltip };
@@ -1,5 +1,6 @@
1
- import type { TooltipPosition, TooltipVariant } from "./types";
2
- export declare const getTooltipClasses: ({ variant, position, }: {
3
- variant?: TooltipVariant | undefined;
4
- position?: TooltipPosition | undefined;
5
- }) => string;
1
+ export declare const getTooltipContentClasses: (props?: ({
2
+ variant?: "accent" | "error" | "info" | "neutral" | "primary" | "secondary" | "success" | "warning" | null | undefined;
3
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
4
+ export declare const getTooltipArrowClasses: (props?: ({
5
+ variant?: "accent" | "error" | "info" | "neutral" | "primary" | "secondary" | "success" | "warning" | null | undefined;
6
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
@@ -1,10 +1,5 @@
1
- import { type ReactNode } from 'react';
2
- export type TooltipPosition = 'top' | 'bottom' | 'left' | 'right';
3
- export type TooltipVariant = 'default' | 'neutral' | 'primary' | 'secondary' | 'accent' | 'ghost' | 'link' | 'info' | 'success' | 'warning' | 'error';
4
- export type TooltipProps = React.HTMLAttributes<HTMLDivElement> & {
5
- content: string;
6
- children: ReactNode;
7
- variant?: TooltipVariant;
8
- position?: TooltipPosition;
9
- className?: string;
10
- };
1
+ import { type VariantProps } from "../../libs";
2
+ import { getTooltipArrowClasses, getTooltipContentClasses } from "./constants";
3
+ import * as TooltipPrimitive from "@radix-ui/react-tooltip";
4
+ export type TooltipArrowProps = React.HTMLAttributes<React.ElementRef<typeof TooltipPrimitive.Arrow>> & TooltipPrimitive.TooltipArrowProps & VariantProps<typeof getTooltipArrowClasses>;
5
+ export type TooltipContentProps = React.HTMLAttributes<React.ElementRef<typeof TooltipPrimitive.Content>> & TooltipPrimitive.TooltipContentProps & VariantProps<typeof getTooltipContentClasses>;
@@ -1,11 +1,16 @@
1
1
  /** actions */
2
2
  export * from "./components/Button";
3
+ export * from "./components/Breadcrumbs";
3
4
  /** data display */
5
+ export * from "./components/Avatar";
4
6
  export * from "./components/Badge";
5
7
  export * from "./components/Card";
6
8
  export * from "./components/Description";
9
+ export * from "./components/Progress";
10
+ export * from "./components/Separator";
7
11
  export * from "./components/Text";
8
12
  /** data input */
9
13
  /** feedback */
14
+ export * from "./components/Loading";
10
15
  export * from "./components/Skeleton";
11
16
  export * from "./components/Tooltip";
@@ -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,2 @@
1
+ import { type ClassValue } from "clsx";
2
+ export declare function cn(...inputs: ClassValue[]): string;
@@ -0,0 +1,6 @@
1
+ export declare const getSubpaths: (pathname: string, pathLabels?: Record<string, string> | undefined, includeRoot?: boolean) => {
2
+ href: {
3
+ pathname: string;
4
+ };
5
+ label: string;
6
+ }[];
@@ -0,0 +1 @@
1
+ export { getSubpaths } from "./getSubpaths";
@@ -0,0 +1,2 @@
1
+ export { cn } from "./cn";
2
+ export { getSubpaths } from "./getSubpaths";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mbao01/common",
3
3
  "private": false,
4
- "version": "0.0.5",
4
+ "version": "0.0.7",
5
5
  "type": "module",
6
6
  "author": "Ayomide Bakare",
7
7
  "license": "MIT",
@@ -20,7 +20,9 @@
20
20
  "default": "./src/index.ts"
21
21
  }
22
22
  },
23
+ "./libs": "./src/libs/index.ts",
23
24
  "./plugin": "./plugin.js",
25
+ "./utilities": "./src/utilities/index.ts",
24
26
  "./vitest/setup": "./vitest-setup.ts",
25
27
  "./vitest/config": "./vitest.config.ts",
26
28
  "./styles": "./src/stylesheets/index.css"
@@ -58,8 +60,17 @@
58
60
  "test:coverage": "vitest run --coverage"
59
61
  },
60
62
  "dependencies": {
63
+ "@radix-ui/react-avatar": "^1.0.4",
64
+ "@radix-ui/react-icons": "^1.3.0",
65
+ "@radix-ui/react-progress": "^1.0.3",
66
+ "@radix-ui/react-separator": "^1.0.3",
67
+ "@radix-ui/react-slot": "^1.0.2",
68
+ "@radix-ui/react-tooltip": "^1.0.7",
69
+ "class-variance-authority": "^0.7.0",
61
70
  "clsx": "^2.1.0",
62
- "daisyui": "^4.6.2"
71
+ "daisyui": "^4.6.2",
72
+ "tailwind-merge": "^2.2.1",
73
+ "tailwindcss-animate": "^1.0.7"
63
74
  },
64
75
  "devDependencies": {
65
76
  "@storybook/addon-essentials": "^7.6.14",
@@ -102,10 +113,9 @@
102
113
  "vitest": "^1.2.2"
103
114
  },
104
115
  "peerDependencies": {
105
- "@heroicons/react": "^2.1.1",
106
116
  "react": "^18.2.0",
107
117
  "react-dom": "^18.2.0",
108
118
  "typescript": "^5.2.2"
109
119
  },
110
- "gitHead": "d40fb1867ee09180de85ab18ffe74c4436e43413"
120
+ "gitHead": "5a26b3e951c2b2a1a6cf5cb597129bc25a336a2d"
111
121
  }
package/plugin.js CHANGED
@@ -1,3 +1 @@
1
- const daisyui = require("daisyui");
2
-
3
- module.exports = daisyui;
1
+ module.exports = [require("daisyui"), require("tailwindcss-animate")];
@@ -0,0 +1,59 @@
1
+ "use client";
2
+
3
+ import * as AvatarPrimitive from "@radix-ui/react-avatar";
4
+ import type {
5
+ AvatarProps,
6
+ AvatarImageProps,
7
+ AvatarFallbackProps,
8
+ } from "./types";
9
+ import { cn } from "../../utilities";
10
+ import {
11
+ getAvatarClasses,
12
+ getAvatarImageClasses,
13
+ getAvatarFallbackClasses,
14
+ } from "./constants";
15
+
16
+ const Avatar = ({ className, size, status, ...props }: AvatarProps) => (
17
+ <AvatarPrimitive.Root
18
+ className={cn(getAvatarClasses({ size, status }), className)}
19
+ {...props}
20
+ />
21
+ );
22
+ Avatar.displayName = AvatarPrimitive.Root.displayName;
23
+
24
+ const AvatarImage = ({
25
+ className,
26
+ ring,
27
+ shape,
28
+ variant,
29
+ ...props
30
+ }: AvatarImageProps) => (
31
+ <AvatarPrimitive.Image
32
+ className={cn(getAvatarImageClasses({ ring, shape, variant }), className)}
33
+ {...props}
34
+ />
35
+ );
36
+ AvatarImage.displayName = AvatarPrimitive.Image.displayName;
37
+
38
+ const AvatarFallback = ({
39
+ className,
40
+ size,
41
+ ring,
42
+ shape,
43
+ variant,
44
+ ...props
45
+ }: AvatarFallbackProps) => (
46
+ <AvatarPrimitive.Fallback
47
+ className={cn(
48
+ getAvatarFallbackClasses({ ring, size, shape, variant }),
49
+ className
50
+ )}
51
+ {...props}
52
+ />
53
+ );
54
+ AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
55
+
56
+ Avatar.Image = AvatarImage;
57
+ Avatar.Fallback = AvatarFallback;
58
+
59
+ export { Avatar };
@@ -0,0 +1,69 @@
1
+ import { cva } from "../../libs";
2
+
3
+ export const getAvatarClasses = cva("avatar", {
4
+ variants: {
5
+ size: {
6
+ 4: "w-4 h-4",
7
+ 8: "w-8 h-8",
8
+ 12: "w-12 h-12",
9
+ 16: "w-16 h-16",
10
+ 24: "w-24 h-24",
11
+ 32: "w-32 h-32",
12
+ 48: "w-48 h-48",
13
+ 64: "w-64 h-64",
14
+ },
15
+ status: {
16
+ online: "online",
17
+ offline: "offline",
18
+ },
19
+ },
20
+ });
21
+
22
+ const classesConfig = {
23
+ variants: {
24
+ variant: {
25
+ accent: "bg-accent text-accent-content ring-accent",
26
+ default: "bg-default text-default-content ring-default",
27
+ error: "bg-error text-error-content ring-error",
28
+ ghost: "bg-ghost text-ghost-content ring-ghost",
29
+ info: "bg-info text-info-content ring-info",
30
+ neutral: "bg-neutral text-neutral-content ring-neutral",
31
+ primary: "bg-primary text-primary-content ring-primary",
32
+ secondary: "bg-secondary text-secondary-content ring-secondary",
33
+ success: "bg-success text-success-content ring-success",
34
+ warning: "bg-warning text-warning-content ring-warning",
35
+ },
36
+ shape: {
37
+ round: "rounded",
38
+ circle: "rounded-full",
39
+ hexagon: "mask mask-hexagon",
40
+ triangle: "mask mask-triangle",
41
+ television: "mask mask-squircle",
42
+ },
43
+ ring: {
44
+ true: "ring ring-offset-base-100 ring-offset-2",
45
+ },
46
+ },
47
+ };
48
+
49
+ export const getAvatarImageClasses = cva("", classesConfig);
50
+
51
+ export const getAvatarFallbackClasses = cva(
52
+ "flex items-center justify-center w-full",
53
+ {
54
+ ...classesConfig,
55
+ variants: {
56
+ ...classesConfig.variants,
57
+ size: {
58
+ 4: "text-[4px]",
59
+ 8: "text-base",
60
+ 12: "text-lg",
61
+ 16: "text-xl",
62
+ 24: "text-2xl",
63
+ 32: "text-3xl",
64
+ 48: "text-4xl",
65
+ 64: "text-5xl",
66
+ },
67
+ },
68
+ }
69
+ );