@mbao01/common 0.0.4 → 0.0.6

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 (84) hide show
  1. package/README.md +1 -2
  2. package/dist/types/components/Badge/Badge.d.ts +1 -1
  3. package/dist/types/components/Badge/constants.d.ts +5 -5
  4. package/dist/types/components/Badge/types.d.ts +3 -7
  5. package/dist/types/components/Breadcrumbs/Breadcrumbs.d.ts +3 -0
  6. package/dist/types/components/Breadcrumbs/index.d.ts +1 -0
  7. package/dist/types/components/Breadcrumbs/types.d.ts +2 -0
  8. package/dist/types/components/Button/Button.d.ts +11 -2
  9. package/dist/types/components/Button/constants.d.ts +7 -8
  10. package/dist/types/components/Button/types.d.ts +6 -12
  11. package/dist/types/components/Card/Card.d.ts +10 -8
  12. package/dist/types/components/Card/constants.d.ts +6 -0
  13. package/dist/types/components/Card/types.d.ts +3 -18
  14. package/dist/types/components/Description/Description.d.ts +7 -0
  15. package/dist/types/components/Description/index.d.ts +1 -0
  16. package/dist/types/components/Description/types.d.ts +3 -0
  17. package/dist/types/components/Loading/Loading.d.ts +2 -0
  18. package/dist/types/components/Loading/constants.d.ts +5 -0
  19. package/dist/types/components/Loading/index.d.ts +1 -0
  20. package/dist/types/components/Loading/types.d.ts +3 -0
  21. package/dist/types/components/Skeleton/Skeleton.d.ts +2 -0
  22. package/dist/types/components/Skeleton/constants.d.ts +6 -0
  23. package/dist/types/components/Skeleton/index.d.ts +1 -0
  24. package/dist/types/components/Skeleton/types.d.ts +3 -0
  25. package/dist/types/components/Text/Text.d.ts +2 -4
  26. package/dist/types/components/Text/constants.d.ts +4 -5
  27. package/dist/types/components/Text/types.d.ts +4 -9
  28. package/dist/types/components/Tooltip/Tooltip.d.ts +14 -2
  29. package/dist/types/components/Tooltip/constants.d.ts +6 -5
  30. package/dist/types/components/Tooltip/index.d.ts +1 -1
  31. package/dist/types/components/Tooltip/types.d.ts +5 -10
  32. package/dist/types/index.d.ts +9 -2
  33. package/dist/types/libs/cva.d.ts +1 -0
  34. package/dist/types/libs/index.d.ts +1 -0
  35. package/dist/types/utilities/cn.d.ts +2 -0
  36. package/dist/types/utilities/getSubpaths/getSubpaths.d.ts +6 -0
  37. package/dist/types/utilities/getSubpaths/index.d.ts +1 -0
  38. package/dist/types/utilities/index.d.ts +2 -0
  39. package/package.json +12 -5
  40. package/plugin.js +1 -3
  41. package/src/components/Badge/Badge.tsx +4 -14
  42. package/src/components/Badge/constants.ts +28 -30
  43. package/src/components/Badge/types.ts +4 -17
  44. package/src/components/Breadcrumbs/Breadcrumbs.tsx +13 -0
  45. package/src/components/Breadcrumbs/index.ts +1 -0
  46. package/src/components/Breadcrumbs/types.ts +3 -0
  47. package/src/components/Button/Button.tsx +51 -37
  48. package/src/components/Button/constants.ts +39 -43
  49. package/src/components/Button/types.ts +7 -25
  50. package/src/components/Card/Card.tsx +16 -23
  51. package/src/components/Card/constants.ts +22 -0
  52. package/src/components/Card/types.ts +4 -18
  53. package/src/components/Description/Description.tsx +34 -0
  54. package/src/components/Description/index.ts +1 -0
  55. package/src/components/Description/types.ts +5 -0
  56. package/src/components/Loading/Loading.tsx +18 -0
  57. package/src/components/Loading/constants.ts +30 -0
  58. package/src/components/Loading/index.ts +1 -0
  59. package/src/components/Loading/types.ts +5 -0
  60. package/src/components/Skeleton/Skeleton.tsx +22 -0
  61. package/src/components/Skeleton/constants.ts +40 -0
  62. package/src/components/Skeleton/index.ts +1 -0
  63. package/src/components/Skeleton/types.ts +5 -0
  64. package/src/components/Text/Text.tsx +24 -9
  65. package/src/components/Text/constants.ts +26 -28
  66. package/src/components/Text/types.ts +9 -20
  67. package/src/components/Tooltip/Tooltip.tsx +36 -11
  68. package/src/components/Tooltip/constants.ts +32 -31
  69. package/src/components/Tooltip/index.ts +1 -1
  70. package/src/components/Tooltip/types.ts +13 -22
  71. package/src/index.ts +12 -2
  72. package/src/libs/cva.ts +1 -0
  73. package/src/libs/index.ts +1 -0
  74. package/src/utilities/cn.ts +6 -0
  75. package/src/utilities/getSubpaths/getSubpaths.ts +34 -0
  76. package/src/utilities/getSubpaths/index.ts +1 -0
  77. package/src/utilities/index.ts +2 -0
  78. package/vitest-setup.ts +11 -1
  79. package/dist/types/components/Detail/Detail.d.ts +0 -2
  80. package/dist/types/components/Detail/index.d.ts +0 -1
  81. package/dist/types/components/Detail/types.d.ts +0 -5
  82. package/src/components/Detail/Detail.tsx +0 -10
  83. package/src/components/Detail/index.ts +0 -1
  84. package/src/components/Detail/types.ts +0 -6
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
  ```
@@ -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,8 +1,10 @@
1
- import { CardContentProps, CardDescriptionProps, CardFooterProps, CardHeaderProps, CardImageProps, CardProps } from "./types";
2
- declare const Card: ({ compact, bordered, horizontal, overlay, className, ...props }: CardProps) => import("react/jsx-runtime").JSX.Element;
3
- declare const CardHeader: ({ className, ...props }: CardHeaderProps) => import("react/jsx-runtime").JSX.Element;
4
- declare const CardDescription: ({ className, ...props }: CardDescriptionProps) => import("react/jsx-runtime").JSX.Element;
5
- declare const CardContent: ({ className, ...props }: CardContentProps) => import("react/jsx-runtime").JSX.Element;
6
- declare const CardImage: ({ className, src, alt, ...props }: CardImageProps) => import("react/jsx-runtime").JSX.Element;
7
- declare const CardFooter: ({ className, ...props }: CardFooterProps) => import("react/jsx-runtime").JSX.Element;
8
- export { Card, CardHeader, CardFooter, CardDescription, CardContent, CardImage, };
1
+ import type { CardContentProps, CardDescriptionProps, CardFooterProps, CardHeaderProps, CardImageProps, CardProps } from "./types";
2
+ declare const Card: {
3
+ ({ compact, bordered, horizontal, overlay, className, ...props }: CardProps): import("react/jsx-runtime").JSX.Element;
4
+ Header: ({ className, ...props }: CardHeaderProps) => import("react/jsx-runtime").JSX.Element;
5
+ Content: ({ className, ...props }: CardContentProps) => import("react/jsx-runtime").JSX.Element;
6
+ Description: ({ className, ...props }: CardDescriptionProps) => import("react/jsx-runtime").JSX.Element;
7
+ Image: ({ className, src, alt, ...props }: CardImageProps) => import("react/jsx-runtime").JSX.Element;
8
+ Footer: ({ className, ...props }: CardFooterProps) => import("react/jsx-runtime").JSX.Element;
9
+ };
10
+ export { Card };
@@ -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>;
@@ -0,0 +1,7 @@
1
+ import type { DescriptionProps, DescriptionTermProps, DescriptionDetailProps } from "./types";
2
+ declare const Description: {
3
+ (props: DescriptionProps): 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
+ };
7
+ export { Description };
@@ -0,0 +1 @@
1
+ export { Description } from "./Description";
@@ -0,0 +1,3 @@
1
+ export type DescriptionProps = React.HTMLAttributes<HTMLDListElement>;
2
+ export type DescriptionTermProps = React.HTMLAttributes<HTMLElement>;
3
+ export type DescriptionDetailProps = React.HTMLAttributes<HTMLElement>;
@@ -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,2 @@
1
+ import { type SkeletonProps } from "./types";
2
+ export declare const Skeleton: ({ round, width, height, variant, className, ...props }: SkeletonProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ export declare const getSkeletonClasses: (props?: ({
2
+ variant?: "pulse" | null | undefined;
3
+ width?: "full" | 4 | 2 | 8 | 12 | 16 | 24 | 32 | 48 | 64 | null | undefined;
4
+ height?: "full" | 4 | 2 | 8 | 12 | 16 | 24 | 32 | 48 | 64 | null | undefined;
5
+ round?: boolean | null | undefined;
6
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
@@ -0,0 +1 @@
1
+ export { Skeleton } from "./Skeleton";
@@ -0,0 +1,3 @@
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: ({ tip, children, variant, position, className }: 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 +1 @@
1
- export { Tooltip } from './Tooltip';
1
+ export { Tooltip } from "./Tooltip";
@@ -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 = {
5
- tip: 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,6 +1,13 @@
1
- export * from "./components/Badge";
1
+ /** actions */
2
2
  export * from "./components/Button";
3
+ export * from "./components/Breadcrumbs";
4
+ /** data display */
5
+ export * from "./components/Badge";
3
6
  export * from "./components/Card";
4
- export * from "./components/Detail";
7
+ export * from "./components/Description";
5
8
  export * from "./components/Text";
9
+ /** data input */
10
+ /** feedback */
11
+ export * from "./components/Loading";
12
+ export * from "./components/Skeleton";
6
13
  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.4",
4
+ "version": "0.0.6",
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"
@@ -38,7 +40,7 @@
38
40
  "vitest.config.ts"
39
41
  ],
40
42
  "bugs": "https://github.com/mbao01/mbao01/issues",
41
- "homepage": "https://shared.ayomidebakare.site",
43
+ "homepage": "https://ui.ayomidebakare.site/common/",
42
44
  "repository": {
43
45
  "type": "git",
44
46
  "url": "git+https://github.com/mbao01/mbao01.git"
@@ -58,8 +60,14 @@
58
60
  "test:coverage": "vitest run --coverage"
59
61
  },
60
62
  "dependencies": {
63
+ "@radix-ui/react-icons": "^1.3.0",
64
+ "@radix-ui/react-slot": "^1.0.2",
65
+ "@radix-ui/react-tooltip": "^1.0.7",
66
+ "class-variance-authority": "^0.7.0",
61
67
  "clsx": "^2.1.0",
62
- "daisyui": "^4.6.2"
68
+ "daisyui": "^4.6.2",
69
+ "tailwind-merge": "^2.2.1",
70
+ "tailwindcss-animate": "^1.0.7"
63
71
  },
64
72
  "devDependencies": {
65
73
  "@storybook/addon-essentials": "^7.6.14",
@@ -102,10 +110,9 @@
102
110
  "vitest": "^1.2.2"
103
111
  },
104
112
  "peerDependencies": {
105
- "@heroicons/react": "^2.1.1",
106
113
  "react": "^18.2.0",
107
114
  "react-dom": "^18.2.0",
108
115
  "typescript": "^5.2.2"
109
116
  },
110
- "gitHead": "90d186e3fc64e9dae9f8755fd057540a23e6a4cd"
117
+ "gitHead": "ceb6cef48e8547b4da5c51dda329bd6edee73c0b"
111
118
  }
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")];
@@ -1,28 +1,18 @@
1
- import c from "clsx";
1
+ import { cn } from "../../utilities";
2
2
  import { getBadgeClasses } from "./constants";
3
3
  import { type BadgeProps } from "./types";
4
4
 
5
5
  export const Badge = ({
6
6
  size,
7
7
  outline,
8
- variant = "ghost",
9
- children,
8
+ variant,
10
9
  className,
11
10
  ...props
12
11
  }: BadgeProps) => {
13
12
  return (
14
13
  <span
14
+ className={cn(getBadgeClasses({ size, variant, outline }), className)}
15
15
  {...props}
16
- className={c(
17
- getBadgeClasses({ size, variant }),
18
- {
19
- "badge-outline": outline,
20
- "text-base-200": !["ghost", "neutral"].includes(variant),
21
- },
22
- className
23
- )}
24
- >
25
- {children}
26
- </span>
16
+ />
27
17
  );
28
18
  };
@@ -1,31 +1,29 @@
1
- import c from "clsx";
2
- import type { BadgeSize, BadgeVariant } from "./types";
1
+ import { cva } from "../../libs";
3
2
 
4
- const BADGE_SIZE = {
5
- xs: c("badge-xs"),
6
- sm: c("badge-sm"),
7
- md: c("badge-md"),
8
- lg: c("badge-lg"),
9
- } satisfies Record<BadgeSize, string>;
10
-
11
- const BADGE_VARIANTS = {
12
- accent: c("badge-accent"),
13
- error: c("badge-error"),
14
- ghost: c("badge-ghost"),
15
- info: c("badge-info"),
16
- neutral: c("badge-neutral"),
17
- primary: c("badge-primary"),
18
- secondary: c("badge-secondary"),
19
- success: c("badge-success"),
20
- warning: c("badge-warning"),
21
- } satisfies Record<BadgeVariant, string>;
22
-
23
- export const getBadgeClasses = ({
24
- size,
25
- variant,
26
- }: {
27
- size?: BadgeSize;
28
- variant?: BadgeVariant;
29
- }) => {
30
- return c("badge", BADGE_VARIANTS[variant!], BADGE_SIZE[size!]);
31
- };
3
+ export const getBadgeClasses = cva("badge", {
4
+ variants: {
5
+ variant: {
6
+ accent: "badge-accent",
7
+ error: "badge-error",
8
+ ghost: "badge-ghost",
9
+ info: "badge-info",
10
+ neutral: "badge-neutral",
11
+ primary: "badge-primary",
12
+ secondary: "badge-secondary",
13
+ success: "badge-success",
14
+ warning: "badge-warning",
15
+ },
16
+ outline: {
17
+ true: "badge-outline",
18
+ },
19
+ size: {
20
+ xs: "badge-xs",
21
+ sm: "badge-sm",
22
+ md: "badge-md",
23
+ lg: "badge-lg",
24
+ },
25
+ },
26
+ defaultVariants: {
27
+ variant: "ghost",
28
+ },
29
+ });
@@ -1,18 +1,5 @@
1
- export type BadgeSize = "xs" | "sm" | "md" | "lg";
1
+ import { type VariantProps } from "../../libs";
2
+ import { getBadgeClasses } from "./constants";
2
3
 
3
- export type BadgeVariant =
4
- | "neutral"
5
- | "primary"
6
- | "secondary"
7
- | "accent"
8
- | "ghost"
9
- | "info"
10
- | "success"
11
- | "warning"
12
- | "error";
13
-
14
- export type BadgeProps = React.HTMLAttributes<HTMLSpanElement> & {
15
- size?: BadgeSize;
16
- outline?: boolean;
17
- variant?: BadgeVariant;
18
- };
4
+ export type BadgeProps = React.HTMLAttributes<HTMLSpanElement> &
5
+ VariantProps<typeof getBadgeClasses>;
@@ -0,0 +1,13 @@
1
+ import type { BreadcrumbProps, BreadcrumbsProps } from "./types";
2
+
3
+ export const Breadcrumbs = (props: BreadcrumbsProps) => {
4
+ return (
5
+ <div className="breadcrumbs -ml-1 w-fit px-1 text-sm">
6
+ <ul {...props} />
7
+ </div>
8
+ );
9
+ };
10
+
11
+ export const Breadcrumb = (props: BreadcrumbProps) => {
12
+ return <li {...props} />;
13
+ };
@@ -0,0 +1 @@
1
+ export { Breadcrumbs } from "./Breadcrumbs";
@@ -0,0 +1,3 @@
1
+ export type BreadcrumbProps = React.HTMLAttributes<HTMLLIElement>;
2
+
3
+ export type BreadcrumbsProps = React.HTMLAttributes<HTMLUListElement>;