@mbao01/common 0.0.49 → 0.0.50

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,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.50",
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": "1a3e0a5b712ff6dbb8fc8265056caedc28b2c00c"
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,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>;