@mbao01/common 0.0.49 → 0.0.51

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,20 @@
1
+ import { BreadcrumbEllipsisProps, BreadcrumbItemProps, BreadcrumbListProps, BreadcrumbPageProps, BreadcrumbProps, BreadcrumbSeparatorProps } from './types';
2
+ declare const Breadcrumb: {
3
+ ({ children, ...props }: BreadcrumbProps): import("react/jsx-runtime").JSX.Element;
4
+ displayName: string;
5
+ List: import('react').ForwardRefExoticComponent<BreadcrumbListProps & import('react').RefAttributes<HTMLOListElement>>;
6
+ Item: import('react').ForwardRefExoticComponent<BreadcrumbItemProps & import('react').RefAttributes<HTMLLIElement>>;
7
+ Link: import('react').ForwardRefExoticComponent<import('react').HTMLAttributes<HTMLAnchorElement> & {
8
+ asChild?: boolean;
9
+ } & import('react').RefAttributes<HTMLAnchorElement>>;
10
+ Page: import('react').ForwardRefExoticComponent<BreadcrumbPageProps & import('react').RefAttributes<HTMLSpanElement>>;
11
+ Separator: {
12
+ ({ children, className, ...props }: BreadcrumbSeparatorProps): import("react/jsx-runtime").JSX.Element;
13
+ displayName: string;
14
+ };
15
+ Ellipsis: {
16
+ ({ className, ...props }: BreadcrumbEllipsisProps): import("react/jsx-runtime").JSX.Element;
17
+ displayName: string;
18
+ };
19
+ };
20
+ export { Breadcrumb };
@@ -0,0 +1,6 @@
1
+ export declare const getBreadcrumbListClasses: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
2
+ export declare const getBreadcrumbItemClasses: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
3
+ export declare const getBreadcrumbLinkClasses: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
4
+ export declare const getBreadcrumbPageClasses: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
5
+ export declare const getBreadcrumbSeparatorClasses: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
6
+ export declare const getBreadcrumbEllipsisClasses: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
@@ -0,0 +1 @@
1
+ export { Breadcrumb } from './Breadcrumb';
@@ -0,0 +1,12 @@
1
+ import { ReactNode } from 'react';
2
+ export type BreadcrumbProps = React.HTMLAttributes<HTMLElement> & {
3
+ separator?: ReactNode;
4
+ };
5
+ export type BreadcrumbListProps = React.HTMLAttributes<HTMLUListElement>;
6
+ export type BreadcrumbItemProps = React.HTMLAttributes<HTMLLIElement>;
7
+ export type BreadcrumbLinkProps = React.HTMLAttributes<HTMLAnchorElement> & {
8
+ asChild?: boolean;
9
+ };
10
+ export type BreadcrumbPageProps = React.HTMLAttributes<HTMLSpanElement>;
11
+ export type BreadcrumbSeparatorProps = React.HTMLAttributes<HTMLLIElement>;
12
+ export type BreadcrumbEllipsisProps = React.HTMLAttributes<HTMLSpanElement>;
@@ -1,6 +1,7 @@
1
- import * as React from "react";
2
- declare const Checkbox: React.ForwardRefExoticComponent<Omit<React.HTMLProps<HTMLInputElement>, "type" | "ref" | "size"> & {
1
+ import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
2
+ declare const Checkbox: import('react').ForwardRefExoticComponent<Omit<Omit<CheckboxPrimitive.CheckboxProps & import('react').RefAttributes<HTMLButtonElement>, "ref">, "checked" | "onCheckedChange"> & {
3
3
  variant?: "accent" | "error" | "info" | "primary" | "secondary" | "success" | "warning" | undefined;
4
4
  size?: "xs" | "sm" | "md" | "lg" | undefined;
5
- } & React.RefAttributes<HTMLInputElement>>;
5
+ rounded?: "xs" | "sm" | "md" | "lg" | undefined;
6
+ } & import('react').RefAttributes<HTMLButtonElement>>;
6
7
  export { Checkbox };
@@ -1,4 +1,9 @@
1
1
  export declare const getCheckboxClasses: (props?: ({
2
2
  variant?: "accent" | "error" | "info" | "primary" | "secondary" | "success" | "warning" | null | undefined;
3
3
  size?: "xs" | "sm" | "md" | "lg" | null | undefined;
4
+ rounded?: "xs" | "sm" | "md" | "lg" | null | undefined;
5
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
6
+ export declare const getCheckboxIndicatorClasses: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
7
+ export declare const getCheckboxIconClasses: (props?: ({
8
+ size?: "xs" | "sm" | "md" | "lg" | null | undefined;
4
9
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
@@ -1,3 +1,5 @@
1
+ import { ComponentPropsWithoutRef } from 'react';
1
2
  import { VariantProps } from '../../../libs';
2
3
  import { getCheckboxClasses } from './constants';
3
- export type CheckboxProps = Omit<React.HTMLProps<HTMLInputElement>, "size" | "ref" | "type"> & VariantProps<typeof getCheckboxClasses>;
4
+ import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
5
+ export type CheckboxProps = Omit<ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>, "checked" | "onCheckedChange"> & VariantProps<typeof getCheckboxClasses>;
@@ -1,7 +1,7 @@
1
1
  /** actions */
2
2
  export * from './components/Anchor';
3
3
  export * from './components/Button';
4
- export * from './components/Breadcrumbs';
4
+ export * from './components/Breadcrumb';
5
5
  export * from './components/Menu';
6
6
  export * from './components/Pagination';
7
7
  export * from './components/ThemeSwitch';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mbao01/common",
3
3
  "private": false,
4
- "version": "0.0.49",
4
+ "version": "0.0.51",
5
5
  "type": "module",
6
6
  "author": "Ayomide Bakare",
7
7
  "license": "MIT",
@@ -171,5 +171,5 @@
171
171
  "react-dom": "^18.2.0",
172
172
  "typescript": "^5.2.2"
173
173
  },
174
- "gitHead": "86697af331eb24f58fb8689ebd8ca76d302ad387"
174
+ "gitHead": "4719b1effc0e198fed741e9001b853016f2563f6"
175
175
  }
@@ -0,0 +1,99 @@
1
+ import { forwardRef } from "react";
2
+ import { Slot } from "@radix-ui/react-slot";
3
+ import { ChevronRightIcon, EllipsisIcon } from "lucide-react";
4
+ import type {
5
+ BreadcrumbEllipsisProps,
6
+ BreadcrumbItemProps,
7
+ BreadcrumbLinkProps,
8
+ BreadcrumbListProps,
9
+ BreadcrumbPageProps,
10
+ BreadcrumbProps,
11
+ BreadcrumbSeparatorProps,
12
+ } from "./types";
13
+ import { cn } from "../../utilities";
14
+ import {
15
+ getBreadcrumbEllipsisClasses,
16
+ getBreadcrumbItemClasses,
17
+ getBreadcrumbLinkClasses,
18
+ getBreadcrumbListClasses,
19
+ getBreadcrumbPageClasses,
20
+ getBreadcrumbSeparatorClasses,
21
+ } from "./constants";
22
+
23
+ const Breadcrumb = ({ children, ...props }: BreadcrumbProps) => (
24
+ <nav aria-label="breadcrumb" {...props}>
25
+ {children}
26
+ </nav>
27
+ );
28
+ Breadcrumb.displayName = "Breadcrumb";
29
+
30
+ const BreadcrumbList = forwardRef<HTMLOListElement, BreadcrumbListProps>(
31
+ ({ className, ...props }, ref) => (
32
+ <ol ref={ref} className={cn(getBreadcrumbListClasses(), className)} {...props} />
33
+ )
34
+ );
35
+ BreadcrumbList.displayName = "BreadcrumbList";
36
+
37
+ const BreadcrumbItem = forwardRef<HTMLLIElement, BreadcrumbItemProps>(
38
+ ({ className, ...props }, ref) => (
39
+ <li ref={ref} className={cn(getBreadcrumbItemClasses(), className)} {...props} />
40
+ )
41
+ );
42
+ BreadcrumbItem.displayName = "BreadcrumbItem";
43
+
44
+ const BreadcrumbLink = forwardRef<HTMLAnchorElement, BreadcrumbLinkProps>(
45
+ ({ asChild, className, ...props }, ref) => {
46
+ const Comp = asChild ? Slot : "a";
47
+
48
+ return <Comp ref={ref} className={cn(getBreadcrumbLinkClasses(), className)} {...props} />;
49
+ }
50
+ );
51
+ BreadcrumbLink.displayName = "BreadcrumbLink";
52
+
53
+ const BreadcrumbPage = forwardRef<HTMLSpanElement, BreadcrumbPageProps>(
54
+ ({ className, ...props }, ref) => (
55
+ <span
56
+ ref={ref}
57
+ role="link"
58
+ aria-disabled="true"
59
+ aria-current="page"
60
+ className={cn(getBreadcrumbPageClasses(), className)}
61
+ {...props}
62
+ />
63
+ )
64
+ );
65
+ BreadcrumbPage.displayName = "BreadcrumbPage";
66
+
67
+ const BreadcrumbSeparator = ({ children, className, ...props }: BreadcrumbSeparatorProps) => (
68
+ <li
69
+ role="presentation"
70
+ aria-hidden="true"
71
+ className={cn(getBreadcrumbSeparatorClasses(), className)}
72
+ {...props}
73
+ >
74
+ {children ?? <ChevronRightIcon />}
75
+ </li>
76
+ );
77
+ BreadcrumbSeparator.displayName = "BreadcrumbSeparator";
78
+
79
+ const BreadcrumbEllipsis = ({ className, ...props }: BreadcrumbEllipsisProps) => (
80
+ <span
81
+ role="presentation"
82
+ aria-hidden="true"
83
+ className={cn(getBreadcrumbEllipsisClasses(), className)}
84
+ {...props}
85
+ >
86
+ <EllipsisIcon className="h-4 w-4" />
87
+ <span className="sr-only">More</span>
88
+ </span>
89
+ );
90
+ BreadcrumbEllipsis.displayName = "BreadcrumbEllipsis";
91
+
92
+ Breadcrumb.List = BreadcrumbList;
93
+ Breadcrumb.Item = BreadcrumbItem;
94
+ Breadcrumb.Link = BreadcrumbLink;
95
+ Breadcrumb.Page = BreadcrumbPage;
96
+ Breadcrumb.Separator = BreadcrumbSeparator;
97
+ Breadcrumb.Ellipsis = BreadcrumbEllipsis;
98
+
99
+ export { Breadcrumb };
@@ -0,0 +1,15 @@
1
+ import { cva } from "../../libs";
2
+
3
+ export const getBreadcrumbListClasses = cva(
4
+ "flex flex-wrap items-center gap-1.5 break-words text-sm sm:gap-2.5"
5
+ );
6
+
7
+ export const getBreadcrumbItemClasses = cva("inline-flex items-center gap-1.5");
8
+
9
+ export const getBreadcrumbLinkClasses = cva("transition-colors");
10
+
11
+ export const getBreadcrumbPageClasses = cva("font-normal");
12
+
13
+ export const getBreadcrumbSeparatorClasses = cva("[&>svg]:w-3.5 [&>svg]:h-3.5");
14
+
15
+ export const getBreadcrumbEllipsisClasses = cva("flex h-9 w-9 items-center justify-center");
@@ -0,0 +1 @@
1
+ export { Breadcrumb } from "./Breadcrumb";
@@ -0,0 +1,19 @@
1
+ import { ReactNode } from "react";
2
+
3
+ export type BreadcrumbProps = React.HTMLAttributes<HTMLElement> & {
4
+ separator?: ReactNode;
5
+ };
6
+
7
+ export type BreadcrumbListProps = React.HTMLAttributes<HTMLUListElement>;
8
+
9
+ export type BreadcrumbItemProps = React.HTMLAttributes<HTMLLIElement>;
10
+
11
+ export type BreadcrumbLinkProps = React.HTMLAttributes<HTMLAnchorElement> & {
12
+ asChild?: boolean;
13
+ };
14
+
15
+ export type BreadcrumbPageProps = React.HTMLAttributes<HTMLSpanElement>;
16
+
17
+ export type BreadcrumbSeparatorProps = React.HTMLAttributes<HTMLLIElement>;
18
+
19
+ export type BreadcrumbEllipsisProps = React.HTMLAttributes<HTMLSpanElement>;
@@ -1,18 +1,39 @@
1
- import * as React from "react";
1
+ import type { ElementRef } from "react";
2
+ import { forwardRef, useState } from "react";
3
+ import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
4
+ import { CheckIcon, MinusIcon } from "lucide-react";
2
5
  import { cn } from "../../../utilities";
3
- import { getCheckboxClasses } from "./constants";
6
+ import {
7
+ getCheckboxClasses,
8
+ getCheckboxIconClasses,
9
+ getCheckboxIndicatorClasses,
10
+ } from "./constants";
4
11
  import { type CheckboxProps } from "./types";
5
12
 
6
- const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(
7
- ({ className, size, variant, ...props }, ref) => (
8
- <input
9
- ref={ref}
10
- type="checkbox"
11
- className={cn(getCheckboxClasses({ size, variant }), className)}
12
- {...props}
13
- />
14
- )
13
+ const Checkbox = forwardRef<ElementRef<typeof CheckboxPrimitive.Root>, CheckboxProps>(
14
+ ({ className, size, rounded, variant, defaultChecked, ...props }, ref) => {
15
+ const [checked, setChecked] = useState<CheckboxPrimitive.CheckedState | undefined>(
16
+ defaultChecked
17
+ );
18
+
19
+ return (
20
+ <CheckboxPrimitive.Root
21
+ ref={ref}
22
+ checked={checked}
23
+ onCheckedChange={setChecked}
24
+ className={cn(getCheckboxClasses({ size, rounded, variant }), className)}
25
+ {...props}
26
+ >
27
+ <CheckboxPrimitive.Indicator className={cn(getCheckboxIndicatorClasses())}>
28
+ {checked === "indeterminate" && (
29
+ <MinusIcon className={cn(getCheckboxIconClasses({ size }))} />
30
+ )}
31
+ {checked === true && <CheckIcon className={cn(getCheckboxIconClasses({ size }))} />}
32
+ </CheckboxPrimitive.Indicator>
33
+ </CheckboxPrimitive.Root>
34
+ );
35
+ }
15
36
  );
16
- Checkbox.displayName = "Checkbox";
37
+ Checkbox.displayName = CheckboxPrimitive.Root.displayName;
17
38
 
18
39
  export { Checkbox };
@@ -1,21 +1,48 @@
1
1
  import { cva } from "../../../libs";
2
2
 
3
- export const getCheckboxClasses = cva("checkbox", {
4
- variants: {
5
- variant: {
6
- primary: "checkbox-primary",
7
- secondary: "checkbox-secondary",
8
- accent: "checkbox-accent",
9
- success: "checkbox-success",
10
- warning: "checkbox-warning",
11
- info: "checkbox-info",
12
- error: "checkbox-error",
3
+ export const getCheckboxClasses = cva(
4
+ "peer flex items-center justify-center h-6 w-6 shrink-0 rounded-sm border focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-base-content disabled:cursor-not-allowed disabled:opacity-50",
5
+ {
6
+ variants: {
7
+ variant: {
8
+ primary:
9
+ "border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-content",
10
+ secondary:
11
+ "border-secondary data-[state=checked]:bg-secondary data-[state=checked]:text-secondary-content",
12
+ accent:
13
+ "border-accent data-[state=checked]:bg-accent data-[state=checked]:text-accent-content",
14
+ success:
15
+ "border-success data-[state=checked]:bg-success data-[state=checked]:text-success-content",
16
+ warning:
17
+ "border-warning data-[state=checked]:bg-warning data-[state=checked]:text-warning-content",
18
+ info: "border-info data-[state=checked]:bg-info data-[state=checked]:text-info-content",
19
+ error: "border-error data-[state=checked]:bg-error data-[state=checked]:text-error-content",
20
+ },
21
+ size: {
22
+ xs: "h-4 w-4",
23
+ sm: "h-5 w-5",
24
+ md: "h-6 w-6",
25
+ lg: "h-8 w-8",
26
+ },
27
+ rounded: {
28
+ xs: "rounded-xs",
29
+ sm: "rounded-sm",
30
+ md: "rounded-md",
31
+ lg: "rounded-lg",
32
+ },
13
33
  },
34
+ }
35
+ );
36
+
37
+ export const getCheckboxIndicatorClasses = cva("flex items-center justify-center text-current");
38
+
39
+ export const getCheckboxIconClasses = cva("h-4 w-4", {
40
+ variants: {
14
41
  size: {
15
- xs: "checkbox-xs",
16
- sm: "checkbox-sm",
17
- md: "checkbox-md",
18
- lg: "checkbox-lg",
42
+ xs: "h-2.5 w-2.5",
43
+ sm: "h-3.5 w-3.5",
44
+ md: "h-5 w-5",
45
+ lg: "h-6 w-6",
19
46
  },
20
47
  },
21
48
  });
@@ -1,5 +1,10 @@
1
+ import { ComponentPropsWithoutRef } from "react";
2
+ import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
1
3
  import { type VariantProps } from "../../../libs";
2
4
  import { getCheckboxClasses } from "./constants";
3
5
 
4
- export type CheckboxProps = Omit<React.HTMLProps<HTMLInputElement>, "size" | "ref" | "type"> &
6
+ export type CheckboxProps = Omit<
7
+ ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>,
8
+ "checked" | "onCheckedChange"
9
+ > &
5
10
  VariantProps<typeof getCheckboxClasses>;
@@ -1,6 +1,5 @@
1
1
  import { HTMLAttributes } from "react";
2
- import { Breadcrumbs } from "../../../../Breadcrumbs";
3
- import { Breadcrumb } from "../../../../Breadcrumbs/Breadcrumbs";
2
+ import { Breadcrumb } from "../../../../Breadcrumb";
4
3
  import { Sidebar } from "../../../Sidebar";
5
4
  import { type SidebarProps } from "../../../types";
6
5
 
@@ -12,15 +11,15 @@ export const AppMain = ({
12
11
  <Sidebar.Inset {...props}>
13
12
  <header className="flex h-16 shrink-0 items-center gap-2 border-b px-4">
14
13
  {side !== "right" ? <Sidebar.Trigger className="-ml-1" /> : null}
15
- <Breadcrumbs>
16
- <Breadcrumb className="hidden md:block">
17
- <a href="#">Building Your Application</a>
18
- </Breadcrumb>
19
-
20
- <Breadcrumb>
21
- <span>Data Fetching</span>
22
- </Breadcrumb>
23
- </Breadcrumbs>
14
+ <Breadcrumb>
15
+ <Breadcrumb.List>
16
+ <Breadcrumb.Link asChild className="hidden md:block">
17
+ <a href="#">Building Your Application</a>
18
+ </Breadcrumb.Link>
19
+ <Breadcrumb.Separator />
20
+ <Breadcrumb.Page>Data Fetching</Breadcrumb.Page>
21
+ </Breadcrumb.List>
22
+ </Breadcrumb>
24
23
  {side === "right" ? <Sidebar.Trigger className="-mr-1 ml-auto !rotate-180" /> : null}
25
24
  </header>
26
25
  <div className="flex flex-1 flex-col gap-4 p-4">
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /** actions */
2
2
  export * from "./components/Anchor";
3
3
  export * from "./components/Button";
4
- export * from "./components/Breadcrumbs";
4
+ export * from "./components/Breadcrumb";
5
5
  export * from "./components/Menu";
6
6
  export * from "./components/Pagination";
7
7
  export * from "./components/ThemeSwitch";
@@ -1,3 +0,0 @@
1
- import { 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;
@@ -1 +0,0 @@
1
- export { Breadcrumbs } from './Breadcrumbs';
@@ -1,2 +0,0 @@
1
- export type BreadcrumbProps = React.HTMLAttributes<HTMLLIElement>;
2
- export type BreadcrumbsProps = React.HTMLAttributes<HTMLUListElement>;
@@ -1,13 +0,0 @@
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
- };
@@ -1 +0,0 @@
1
- export { Breadcrumbs } from "./Breadcrumbs";
@@ -1,3 +0,0 @@
1
- export type BreadcrumbProps = React.HTMLAttributes<HTMLLIElement>;
2
-
3
- export type BreadcrumbsProps = React.HTMLAttributes<HTMLUListElement>;