periplo-ui 3.6.2 → 3.7.1
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/dist/components/Breadcrumb/Breadcrumb.d.ts +29 -3
- package/dist/components/Breadcrumb/Breadcrumb.js +87 -13
- package/dist/components/Breadcrumb/Breadcrumb.js.map +1 -1
- package/dist/components/Breadcrumb/index.js +1 -1
- package/dist/components/Form/Form.d.ts +2 -1
- package/dist/components/Form/Form.js +14 -2
- package/dist/components/Form/Form.js.map +1 -1
- package/dist/components/Sidebar/Sidebar.d.ts +61 -0
- package/dist/components/Sidebar/Sidebar.js +486 -0
- package/dist/components/Sidebar/Sidebar.js.map +1 -0
- package/dist/components/Sidebar/index.d.ts +1 -0
- package/dist/components/Sidebar/index.js +2 -0
- package/dist/components/Sidebar/index.js.map +1 -0
- package/dist/components/Typography/Typography.d.ts +2 -2
- package/dist/components/Typography/Typography.js +16 -18
- package/dist/components/Typography/Typography.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/plugin.js +11 -2
- package/dist/lib/plugin.js.map +1 -1
- package/dist/lib/useMobile.d.ts +1 -0
- package/dist/lib/useMobile.js +19 -0
- package/dist/lib/useMobile.js.map +1 -0
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
* Root container for the breadcrumb navigation.
|
|
4
4
|
* Provides the overall context and ARIA labeling.
|
|
5
5
|
*/
|
|
6
|
-
declare const
|
|
6
|
+
declare const BreadcrumbRoot: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & {
|
|
7
7
|
/** Custom separator element to use between breadcrumb items */
|
|
8
8
|
separator?: React.ReactNode;
|
|
9
9
|
} & React.RefAttributes<HTMLElement>>;
|
|
@@ -17,6 +17,8 @@ declare const BreadcrumbList: React.ForwardRefExoticComponent<Omit<React.Detaile
|
|
|
17
17
|
* Wraps a link or the current page indicator.
|
|
18
18
|
*/
|
|
19
19
|
declare const BreadcrumbItem: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref"> & React.RefAttributes<HTMLLIElement>>;
|
|
20
|
+
/** Text transform options for breadcrumb links */
|
|
21
|
+
type TextTransformOption = 'capitalize' | 'capitalize-first' | 'uppercase' | 'none';
|
|
20
22
|
/**
|
|
21
23
|
* Interactive link element for breadcrumb navigation.
|
|
22
24
|
* Can be rendered as a custom element using asChild.
|
|
@@ -24,12 +26,16 @@ declare const BreadcrumbItem: React.ForwardRefExoticComponent<Omit<React.Detaile
|
|
|
24
26
|
declare const BreadcrumbLink: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "ref"> & {
|
|
25
27
|
/** When true, the component will render its children directly instead of wrapping them in an anchor tag */
|
|
26
28
|
asChild?: boolean;
|
|
29
|
+
/** The text transformation to apply to the link text */
|
|
30
|
+
textTransform?: TextTransformOption;
|
|
27
31
|
} & React.RefAttributes<HTMLAnchorElement>>;
|
|
28
32
|
/**
|
|
29
33
|
* Current page indicator in the breadcrumb.
|
|
30
34
|
* Non-interactive element showing the current location.
|
|
31
35
|
*/
|
|
32
|
-
declare const BreadcrumbPage: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> &
|
|
36
|
+
declare const BreadcrumbPage: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
37
|
+
textTransform?: TextTransformOption;
|
|
38
|
+
} & React.RefAttributes<HTMLSpanElement>>;
|
|
33
39
|
/**
|
|
34
40
|
* Separator element between breadcrumb items.
|
|
35
41
|
* Can be customized with different icons or characters.
|
|
@@ -46,4 +52,24 @@ declare const BreadcrumbEllipsis: {
|
|
|
46
52
|
({ className, ...props }: React.ComponentProps<"span">): import("react/jsx-runtime").JSX.Element;
|
|
47
53
|
displayName: string;
|
|
48
54
|
};
|
|
49
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Navigation breadcrumb component.
|
|
57
|
+
* Displays a breadcrumb navigation for the current path.
|
|
58
|
+
* @param pathname - The current pathname
|
|
59
|
+
* @param pathMappings - Optional object containing custom path mappings
|
|
60
|
+
* @param t - Optional translation function
|
|
61
|
+
*/
|
|
62
|
+
declare const NavigationBreadcrumb: ({ pathname, pathMappings, t, textTransform, }: {
|
|
63
|
+
pathname: string;
|
|
64
|
+
pathMappings?: Record<string, string>;
|
|
65
|
+
t?: (key: string) => string;
|
|
66
|
+
textTransform?: TextTransformOption;
|
|
67
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
68
|
+
declare const PagesBreadcrumb: ({ pages, currentPage }: {
|
|
69
|
+
pages: {
|
|
70
|
+
link: string;
|
|
71
|
+
text: string;
|
|
72
|
+
}[];
|
|
73
|
+
currentPage: string;
|
|
74
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
75
|
+
export { BreadcrumbRoot, BreadcrumbList, BreadcrumbItem, BreadcrumbLink, BreadcrumbPage, BreadcrumbSeparator, BreadcrumbEllipsis, NavigationBreadcrumb, PagesBreadcrumb, };
|
|
@@ -5,8 +5,8 @@ import * as React from 'react';
|
|
|
5
5
|
import { Typography } from '../Typography/Typography.js';
|
|
6
6
|
import { cn } from '../../lib/utils.js';
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
|
|
8
|
+
const BreadcrumbRoot = React.forwardRef(({ ...props }, ref) => /* @__PURE__ */ jsx("nav", { ref, "aria-label": "breadcrumb", ...props }));
|
|
9
|
+
BreadcrumbRoot.displayName = "BreadcrumbRoot";
|
|
10
10
|
const BreadcrumbList = React.forwardRef(
|
|
11
11
|
({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
12
12
|
"ol",
|
|
@@ -25,30 +25,54 @@ const BreadcrumbItem = React.forwardRef(
|
|
|
25
25
|
({ className, ...props }, ref) => /* @__PURE__ */ jsx("li", { ref, className: cn("inline-flex items-center gap-1.5", className), ...props })
|
|
26
26
|
);
|
|
27
27
|
BreadcrumbItem.displayName = "BreadcrumbItem";
|
|
28
|
-
const
|
|
28
|
+
const getTextTransformClass = (transform) => {
|
|
29
|
+
switch (transform) {
|
|
30
|
+
case "capitalize-first":
|
|
31
|
+
return "[&]:has-[::first-letter]:uppercase";
|
|
32
|
+
case "capitalize":
|
|
33
|
+
return "capitalize";
|
|
34
|
+
case "uppercase":
|
|
35
|
+
return "uppercase";
|
|
36
|
+
default:
|
|
37
|
+
return "";
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const BreadcrumbLink = React.forwardRef(({ asChild, className, textTransform = "capitalize-first", children, ...props }, ref) => {
|
|
29
41
|
const Comp = asChild ? Slot : "a";
|
|
30
|
-
|
|
42
|
+
const content = textTransform === "capitalize-first" && typeof children === "string" ? children.charAt(0).toUpperCase() + children.slice(1) : children;
|
|
43
|
+
return /* @__PURE__ */ jsx(Typography, { variant: "title-sm", weight: "medium", children: /* @__PURE__ */ jsx(
|
|
31
44
|
Comp,
|
|
32
45
|
{
|
|
33
46
|
ref,
|
|
34
|
-
className: cn(
|
|
35
|
-
|
|
47
|
+
className: cn(
|
|
48
|
+
"text-neutral-500 transition-colors hover:text-neutral-950",
|
|
49
|
+
textTransform !== "capitalize-first" && getTextTransformClass(textTransform),
|
|
50
|
+
className
|
|
51
|
+
),
|
|
52
|
+
...props,
|
|
53
|
+
children: content
|
|
36
54
|
}
|
|
37
55
|
) });
|
|
38
56
|
});
|
|
39
57
|
BreadcrumbLink.displayName = "BreadcrumbLink";
|
|
40
|
-
const BreadcrumbPage = React.forwardRef(
|
|
41
|
-
|
|
58
|
+
const BreadcrumbPage = React.forwardRef(({ className, textTransform = "capitalize-first", children, ...props }, ref) => {
|
|
59
|
+
const content = textTransform === "capitalize-first" && typeof children === "string" ? children.charAt(0).toUpperCase() + children.slice(1) : children;
|
|
60
|
+
return /* @__PURE__ */ jsx(Typography, { variant: "title-sm", children: /* @__PURE__ */ jsx(
|
|
42
61
|
"span",
|
|
43
62
|
{
|
|
44
63
|
ref,
|
|
45
64
|
"aria-disabled": "true",
|
|
46
65
|
"aria-current": "page",
|
|
47
|
-
className: cn(
|
|
48
|
-
|
|
66
|
+
className: cn(
|
|
67
|
+
"font-medium text-neutral-950",
|
|
68
|
+
textTransform !== "capitalize-first" && getTextTransformClass(textTransform),
|
|
69
|
+
className
|
|
70
|
+
),
|
|
71
|
+
...props,
|
|
72
|
+
children: content
|
|
49
73
|
}
|
|
50
|
-
) })
|
|
51
|
-
);
|
|
74
|
+
) });
|
|
75
|
+
});
|
|
52
76
|
BreadcrumbPage.displayName = "BreadcrumbPage";
|
|
53
77
|
const BreadcrumbSeparator = ({ children, className, ...props }) => /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: cn("text-neutral-500 [&>svg]:size-3.5", className), ...props, children: children ?? /* @__PURE__ */ jsx(CaretRight, {}) });
|
|
54
78
|
BreadcrumbSeparator.displayName = "BreadcrumbSeparator";
|
|
@@ -57,6 +81,56 @@ const BreadcrumbEllipsis = ({ className, ...props }) => /* @__PURE__ */ jsxs("sp
|
|
|
57
81
|
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "More" })
|
|
58
82
|
] });
|
|
59
83
|
BreadcrumbEllipsis.displayName = "BreadcrumbEllipsis";
|
|
84
|
+
const sanitizeRoute = (route) => {
|
|
85
|
+
return route.replace(/-/g, " ");
|
|
86
|
+
};
|
|
87
|
+
const routeToTranslationKey = (route) => {
|
|
88
|
+
return route.split("-").map((word, index) => index === 0 ? word : word.charAt(0).toUpperCase() + word.slice(1)).join("");
|
|
89
|
+
};
|
|
90
|
+
const getRoutes = (pathname, pathMappings, t) => {
|
|
91
|
+
const baseRoutes = pathname.split("/").filter(Boolean);
|
|
92
|
+
const routes = baseRoutes.map((route, index) => {
|
|
93
|
+
let displayName = route;
|
|
94
|
+
if (pathMappings && pathMappings[route]) {
|
|
95
|
+
displayName = pathMappings[route];
|
|
96
|
+
} else if (t) {
|
|
97
|
+
const translationKey = routeToTranslationKey(route);
|
|
98
|
+
displayName = t(translationKey);
|
|
99
|
+
} else {
|
|
100
|
+
displayName = sanitizeRoute(route);
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
name: displayName,
|
|
104
|
+
href: `/${baseRoutes.slice(0, index + 1).join("/")}`
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
const homeKey = "home";
|
|
108
|
+
routes.unshift({
|
|
109
|
+
name: pathMappings?.[homeKey] || t?.(homeKey) || "Home",
|
|
110
|
+
href: "/"
|
|
111
|
+
});
|
|
112
|
+
return routes;
|
|
113
|
+
};
|
|
114
|
+
const NavigationBreadcrumb = ({
|
|
115
|
+
pathname,
|
|
116
|
+
pathMappings,
|
|
117
|
+
t,
|
|
118
|
+
textTransform
|
|
119
|
+
}) => {
|
|
120
|
+
return /* @__PURE__ */ jsx(BreadcrumbRoot, { children: /* @__PURE__ */ jsx(BreadcrumbList, { children: getRoutes(pathname, pathMappings, t).map((route, index, array) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
121
|
+
/* @__PURE__ */ jsx(BreadcrumbItem, { children: index === array.length - 1 ? /* @__PURE__ */ jsx(BreadcrumbPage, { textTransform, children: route.name }) : /* @__PURE__ */ jsx(BreadcrumbLink, { href: route.href, textTransform, children: route.name }) }),
|
|
122
|
+
index < array.length - 1 && /* @__PURE__ */ jsx(BreadcrumbSeparator, {})
|
|
123
|
+
] }, index)) }) });
|
|
124
|
+
};
|
|
125
|
+
const PagesBreadcrumb = ({ pages, currentPage }) => {
|
|
126
|
+
return /* @__PURE__ */ jsx(BreadcrumbRoot, { children: /* @__PURE__ */ jsxs(BreadcrumbList, { children: [
|
|
127
|
+
pages.map((page) => /* @__PURE__ */ jsxs(BreadcrumbItem, { children: [
|
|
128
|
+
/* @__PURE__ */ jsx(BreadcrumbLink, { href: page.link, children: page.text }),
|
|
129
|
+
/* @__PURE__ */ jsx(BreadcrumbSeparator, {})
|
|
130
|
+
] }, pages.indexOf(page))),
|
|
131
|
+
/* @__PURE__ */ jsx(BreadcrumbItem, { children: /* @__PURE__ */ jsx(BreadcrumbPage, { children: currentPage }) })
|
|
132
|
+
] }) });
|
|
133
|
+
};
|
|
60
134
|
|
|
61
|
-
export {
|
|
135
|
+
export { BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbRoot, BreadcrumbSeparator, NavigationBreadcrumb, PagesBreadcrumb };
|
|
62
136
|
//# sourceMappingURL=Breadcrumb.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Breadcrumb.js","sources":["../../../src/components/Breadcrumb/Breadcrumb.tsx"],"sourcesContent":["import { CaretRight, DotsThree } from '@phosphor-icons/react'\nimport { Slot } from '@radix-ui/react-slot'\nimport * as React from 'react'\nimport { Typography } from '../Typography'\nimport { cn } from '@/lib/utils'\n\n/**\n * Root container for the breadcrumb navigation.\n * Provides the overall context and ARIA labeling.\n */\nconst Breadcrumb = React.forwardRef<\n HTMLElement,\n React.ComponentPropsWithoutRef<'nav'> & {\n /** Custom separator element to use between breadcrumb items */\n separator?: React.ReactNode\n }\n>(({ ...props }, ref) => <nav ref={ref} aria-label=\"breadcrumb\" {...props} />)\nBreadcrumb.displayName = 'Breadcrumb'\n\n/**\n * Container for breadcrumb items.\n * Handles layout and spacing of the breadcrumb navigation.\n */\nconst BreadcrumbList = React.forwardRef<HTMLOListElement, React.ComponentPropsWithoutRef<'ol'>>(\n ({ className, ...props }, ref) => (\n <ol\n ref={ref}\n className={cn(\n 'text-muted-foreground flex flex-wrap items-center gap-1.5 break-words text-sm sm:gap-2.5',\n className,\n )}\n {...props}\n />\n ),\n)\nBreadcrumbList.displayName = 'BreadcrumbList'\n\n/**\n * Individual breadcrumb item container.\n * Wraps a link or the current page indicator.\n */\nconst BreadcrumbItem = React.forwardRef<HTMLLIElement, React.ComponentPropsWithoutRef<'li'>>(\n ({ className, ...props }, ref) => (\n <li ref={ref} className={cn('inline-flex items-center gap-1.5', className)} {...props} />\n ),\n)\nBreadcrumbItem.displayName = 'BreadcrumbItem'\n\n/**\n * Interactive link element for breadcrumb navigation.\n * Can be rendered as a custom element using asChild.\n */\nconst BreadcrumbLink = React.forwardRef<\n HTMLAnchorElement,\n React.ComponentPropsWithoutRef<'a'> & {\n /** When true, the component will render its children directly instead of wrapping them in an anchor tag */\n asChild?: boolean\n }\n>(({ asChild, className, ...props }, ref) => {\n const Comp = asChild ? Slot : 'a'\n\n return (\n <Typography variant=\"title-sm\">\n <Comp\n ref={ref}\n className={cn('text-neutral-500 transition-colors hover:text-neutral-950', className)}\n {...props}\n />\n </Typography>\n )\n})\nBreadcrumbLink.displayName = 'BreadcrumbLink'\n\n/**\n * Current page indicator in the breadcrumb.\n * Non-interactive element showing the current location.\n */\nconst BreadcrumbPage = React.forwardRef<HTMLSpanElement, React.ComponentPropsWithoutRef<'span'>>(\n ({ className, ...props }, ref) => (\n <Typography variant=\"title-sm\">\n <span\n ref={ref}\n aria-disabled=\"true\"\n aria-current=\"page\"\n className={cn('font-medium text-neutral-950', className)}\n {...props}\n />\n </Typography>\n ),\n)\nBreadcrumbPage.displayName = 'BreadcrumbPage'\n\n/**\n * Separator element between breadcrumb items.\n * Can be customized with different icons or characters.\n */\nconst BreadcrumbSeparator = ({ children, className, ...props }: React.ComponentProps<'span'>) => (\n <span aria-hidden=\"true\" className={cn('text-neutral-500 [&>svg]:size-3.5', className)} {...props}>\n {children ?? <CaretRight />}\n </span>\n)\nBreadcrumbSeparator.displayName = 'BreadcrumbSeparator'\n\n/**\n * Ellipsis indicator for truncated breadcrumb paths.\n * Used to show that there are hidden items in the path.\n */\nconst BreadcrumbEllipsis = ({ className, ...props }: React.ComponentProps<'span'>) => (\n <span aria-hidden=\"true\" className={cn('flex h-9 w-9 items-center justify-center', className)} {...props}>\n <DotsThree className=\"h-4 w-4\" />\n <span className=\"sr-only\">More</span>\n </span>\n)\nBreadcrumbEllipsis.displayName = 'BreadcrumbEllipsis'\n\nexport {\n Breadcrumb,\n BreadcrumbList,\n BreadcrumbItem,\n BreadcrumbLink,\n BreadcrumbPage,\n BreadcrumbSeparator,\n BreadcrumbEllipsis,\n}\n"],"names":[],"mappings":";;;;;;;AAUA,MAAM,aAAa,KAAM,CAAA,UAAA,CAMvB,CAAC,EAAE,GAAG,KAAM,EAAA,EAAG,GAAQ,qBAAA,GAAA,CAAC,SAAI,GAAU,EAAA,YAAA,EAAW,YAAc,EAAA,GAAG,OAAO,CAAE;AAC7E,UAAA,CAAW,WAAc,GAAA,YAAA;AAMzB,MAAM,iBAAiB,KAAM,CAAA,UAAA;AAAA,EAC3B,CAAC,EAAE,SAAA,EAAW,GAAG,KAAA,IAAS,GACxB,qBAAA,GAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,SAAW,EAAA,EAAA;AAAA,QACT,0FAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA;AAGV;AACA,cAAA,CAAe,WAAc,GAAA,gBAAA;AAM7B,MAAM,iBAAiB,KAAM,CAAA,UAAA;AAAA,EAC3B,CAAC,EAAE,SAAA,EAAW,GAAG,KAAA,IAAS,GACxB,qBAAA,GAAA,CAAC,IAAG,EAAA,EAAA,GAAA,EAAU,WAAW,EAAG,CAAA,kCAAA,EAAoC,SAAS,CAAA,EAAI,GAAG,KAAO,EAAA;AAE3F;AACA,cAAA,CAAe,WAAc,GAAA,gBAAA;AAMvB,MAAA,cAAA,GAAiB,KAAM,CAAA,UAAA,CAM3B,CAAC,EAAE,SAAS,SAAW,EAAA,GAAG,KAAM,EAAA,EAAG,GAAQ,KAAA;AAC3C,EAAM,MAAA,IAAA,GAAO,UAAU,IAAO,GAAA,GAAA;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A;AAAA,kBAAC,GAAA,CAAA,SAAA,EAAA,EAAU,WAAU,SAAU,EAAA,CAAA;AAAA,kBAC9B,GAAA,CAAA,MAAA,EAAA,EAAK,SAAU,EAAA,SAAA,EAAU,QAAI,EAAA,MAAA,EAAA;AAAA,CAChC,EAAA;AAEF,kBAAA,CAAmB,WAAc,GAAA,oBAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"Breadcrumb.js","sources":["../../../src/components/Breadcrumb/Breadcrumb.tsx"],"sourcesContent":["import { CaretRight, DotsThree } from '@phosphor-icons/react'\nimport { Slot } from '@radix-ui/react-slot'\nimport * as React from 'react'\nimport { Typography } from '../Typography'\nimport { cn } from '@/lib/utils'\n\n/**\n * Root container for the breadcrumb navigation.\n * Provides the overall context and ARIA labeling.\n */\nconst BreadcrumbRoot = React.forwardRef<\n HTMLElement,\n React.ComponentPropsWithoutRef<'nav'> & {\n /** Custom separator element to use between breadcrumb items */\n separator?: React.ReactNode\n }\n>(({ ...props }, ref) => <nav ref={ref} aria-label=\"breadcrumb\" {...props} />)\nBreadcrumbRoot.displayName = 'BreadcrumbRoot'\n\n/**\n * Container for breadcrumb items.\n * Handles layout and spacing of the breadcrumb navigation.\n */\nconst BreadcrumbList = React.forwardRef<HTMLOListElement, React.ComponentPropsWithoutRef<'ol'>>(\n ({ className, ...props }, ref) => (\n <ol\n ref={ref}\n className={cn(\n 'text-muted-foreground flex flex-wrap items-center gap-1.5 break-words text-sm sm:gap-2.5',\n className,\n )}\n {...props}\n />\n ),\n)\nBreadcrumbList.displayName = 'BreadcrumbList'\n\n/**\n * Individual breadcrumb item container.\n * Wraps a link or the current page indicator.\n */\nconst BreadcrumbItem = React.forwardRef<HTMLLIElement, React.ComponentPropsWithoutRef<'li'>>(\n ({ className, ...props }, ref) => (\n <li ref={ref} className={cn('inline-flex items-center gap-1.5', className)} {...props} />\n ),\n)\nBreadcrumbItem.displayName = 'BreadcrumbItem'\n\n/** Text transform options for breadcrumb links */\ntype TextTransformOption = 'capitalize' | 'capitalize-first' | 'uppercase' | 'none'\n\n/** Get class names for text transform styling */\nconst getTextTransformClass = (transform: TextTransformOption): string => {\n switch (transform) {\n case 'capitalize-first':\n return '[&]:has-[::first-letter]:uppercase'\n case 'capitalize':\n return 'capitalize'\n case 'uppercase':\n return 'uppercase'\n default:\n return ''\n }\n}\n\n/**\n * Interactive link element for breadcrumb navigation.\n * Can be rendered as a custom element using asChild.\n */\nconst BreadcrumbLink = React.forwardRef<\n HTMLAnchorElement,\n React.ComponentPropsWithoutRef<'a'> & {\n /** When true, the component will render its children directly instead of wrapping them in an anchor tag */\n asChild?: boolean\n /** The text transformation to apply to the link text */\n textTransform?: TextTransformOption\n }\n>(({ asChild, className, textTransform = 'capitalize-first', children, ...props }, ref) => {\n const Comp = asChild ? Slot : 'a'\n\n // Simplify the capitalization logic using a direct string transformation\n const content =\n textTransform === 'capitalize-first' && typeof children === 'string'\n ? children.charAt(0).toUpperCase() + children.slice(1)\n : children\n\n return (\n <Typography variant=\"title-sm\" weight={'medium'}>\n <Comp\n ref={ref}\n className={cn(\n 'text-neutral-500 transition-colors hover:text-neutral-950',\n textTransform !== 'capitalize-first' && getTextTransformClass(textTransform),\n className,\n )}\n {...props}\n >\n {content}\n </Comp>\n </Typography>\n )\n})\nBreadcrumbLink.displayName = 'BreadcrumbLink'\n\n/**\n * Current page indicator in the breadcrumb.\n * Non-interactive element showing the current location.\n */\nconst BreadcrumbPage = React.forwardRef<\n HTMLSpanElement,\n React.ComponentPropsWithoutRef<'span'> & {\n textTransform?: TextTransformOption\n }\n>(({ className, textTransform = 'capitalize-first', children, ...props }, ref) => {\n const content =\n textTransform === 'capitalize-first' && typeof children === 'string'\n ? children.charAt(0).toUpperCase() + children.slice(1)\n : children\n\n return (\n <Typography variant=\"title-sm\">\n <span\n ref={ref}\n aria-disabled=\"true\"\n aria-current=\"page\"\n className={cn(\n 'font-medium text-neutral-950',\n textTransform !== 'capitalize-first' && getTextTransformClass(textTransform),\n className,\n )}\n {...props}\n >\n {content}\n </span>\n </Typography>\n )\n})\nBreadcrumbPage.displayName = 'BreadcrumbPage'\n\n/**\n * Separator element between breadcrumb items.\n * Can be customized with different icons or characters.\n */\nconst BreadcrumbSeparator = ({ children, className, ...props }: React.ComponentProps<'span'>) => (\n <span aria-hidden=\"true\" className={cn('text-neutral-500 [&>svg]:size-3.5', className)} {...props}>\n {children ?? <CaretRight />}\n </span>\n)\nBreadcrumbSeparator.displayName = 'BreadcrumbSeparator'\n\n/**\n * Ellipsis indicator for truncated breadcrumb paths.\n * Used to show that there are hidden items in the path.\n */\nconst BreadcrumbEllipsis = ({ className, ...props }: React.ComponentProps<'span'>) => (\n <span aria-hidden=\"true\" className={cn('flex h-9 w-9 items-center justify-center', className)} {...props}>\n <DotsThree className=\"h-4 w-4\" />\n <span className=\"sr-only\">More</span>\n </span>\n)\nBreadcrumbEllipsis.displayName = 'BreadcrumbEllipsis'\n\n/**\n * Sanitizes a route string by replacing hyphens with spaces.\n * @param route - The route string to sanitize.\n * @returns The sanitized route string.\n */\nconst sanitizeRoute = (route: string) => {\n return route.replace(/-/g, ' ')\n}\n\n/**\n * Transforms a kebab-case route to a camelCase translation key\n * @param route - The route segment in kebab-case\n * @returns The translation key in camelCase\n */\nconst routeToTranslationKey = (route: string): string => {\n return route\n .split('-')\n .map((word, index) => (index === 0 ? word : word.charAt(0).toUpperCase() + word.slice(1)))\n .join('')\n}\n\n/**\n * Gets the routes for the breadcrumb navigation.\n * @param pathname - The current pathname.\n * @param pathMappings - Optional object containing custom path mappings.\n * @param t - Optional translation function.\n * @returns The routes for the breadcrumb navigation.\n */\nconst getRoutes = (pathname: string, pathMappings?: Record<string, string>, t?: (key: string) => string) => {\n const baseRoutes = pathname.split('/').filter(Boolean)\n\n const routes = baseRoutes.map((route, index) => {\n let displayName = route\n\n // Check if there's a custom mapping for this route\n if (pathMappings && pathMappings[route]) {\n displayName = pathMappings[route]\n }\n // If there's a translation function, convert route to translation key\n else if (t) {\n const translationKey = routeToTranslationKey(route)\n displayName = t(translationKey)\n }\n // If no mapping or translation function, sanitize the route\n else {\n displayName = sanitizeRoute(route)\n }\n\n return {\n name: displayName,\n href: `/${baseRoutes.slice(0, index + 1).join('/')}`,\n }\n })\n\n // Handle home translation\n const homeKey = 'home'\n routes.unshift({\n name: pathMappings?.[homeKey] || t?.(homeKey) || 'Home',\n href: '/',\n })\n\n return routes\n}\n\n/**\n * Navigation breadcrumb component.\n * Displays a breadcrumb navigation for the current path.\n * @param pathname - The current pathname\n * @param pathMappings - Optional object containing custom path mappings\n * @param t - Optional translation function\n */\nconst NavigationBreadcrumb = ({\n pathname,\n pathMappings,\n t,\n textTransform,\n}: {\n pathname: string\n pathMappings?: Record<string, string>\n t?: (key: string) => string\n textTransform?: TextTransformOption\n}) => {\n return (\n <BreadcrumbRoot>\n <BreadcrumbList>\n {getRoutes(pathname, pathMappings, t).map((route, index, array) => (\n <React.Fragment key={index}>\n <BreadcrumbItem>\n {index === array.length - 1 ? (\n <BreadcrumbPage textTransform={textTransform}>{route.name}</BreadcrumbPage>\n ) : (\n <BreadcrumbLink href={route.href} textTransform={textTransform}>\n {route.name}\n </BreadcrumbLink>\n )}\n </BreadcrumbItem>\n {index < array.length - 1 && <BreadcrumbSeparator />}\n </React.Fragment>\n ))}\n </BreadcrumbList>\n </BreadcrumbRoot>\n )\n}\n\nconst PagesBreadcrumb = ({ pages, currentPage }: { pages: { link: string; text: string }[]; currentPage: string }) => {\n return (\n <BreadcrumbRoot>\n <BreadcrumbList>\n {pages.map((page) => (\n <BreadcrumbItem key={pages.indexOf(page)}>\n <BreadcrumbLink href={page.link}>{page.text}</BreadcrumbLink>\n <BreadcrumbSeparator />\n </BreadcrumbItem>\n ))}\n <BreadcrumbItem>\n <BreadcrumbPage>{currentPage}</BreadcrumbPage>\n </BreadcrumbItem>\n </BreadcrumbList>\n </BreadcrumbRoot>\n )\n}\n\nexport {\n BreadcrumbRoot,\n BreadcrumbList,\n BreadcrumbItem,\n BreadcrumbLink,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GAAA,CAAA,cAAA,EAAA,EACC,QAAC,kBAAA,GAAA,CAAA,cAAA,EAAA,EAAgB,uBAAY,CAC/B,EAAA;AAAA,GAAA,EACF,CACF,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbRoot, BreadcrumbSeparator, NavigationBreadcrumb, PagesBreadcrumb } from './Breadcrumb.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ControllerProps, FieldPath, FieldValues } from 'react-hook-form';
|
|
2
|
+
import { TypographyProps } from '../Typography';
|
|
2
3
|
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
3
4
|
import * as React from 'react';
|
|
4
5
|
declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues extends FieldValues | undefined = undefined>(props: import('react-hook-form').FormProviderProps<TFieldValues, TContext, TTransformedValues>) => React.JSX.Element;
|
|
@@ -19,5 +20,5 @@ declare const FormItem: React.ForwardRefExoticComponent<React.HTMLAttributes<HTM
|
|
|
19
20
|
declare const FormLabel: React.ForwardRefExoticComponent<Omit<LabelPrimitive.LabelProps & React.RefAttributes<HTMLLabelElement>, "ref"> & React.RefAttributes<HTMLLabelElement>>;
|
|
20
21
|
declare const FormControl: React.ForwardRefExoticComponent<Omit<import('@radix-ui/react-slot').SlotProps & React.RefAttributes<HTMLElement>, "ref"> & React.RefAttributes<HTMLElement>>;
|
|
21
22
|
declare const FormDescription: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
22
|
-
declare const FormMessage: React.ForwardRefExoticComponent<
|
|
23
|
+
declare const FormMessage: React.ForwardRefExoticComponent<TypographyProps & React.RefAttributes<HTMLParagraphElement>>;
|
|
23
24
|
export { useFormField, Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField };
|
|
@@ -5,6 +5,7 @@ import * as React from 'react';
|
|
|
5
5
|
import { FormProvider, Controller, useFormContext } from 'react-hook-form';
|
|
6
6
|
import { Label } from '../Label/Label.js';
|
|
7
7
|
import { cn } from '../../lib/utils.js';
|
|
8
|
+
import { Typography } from '../Typography/Typography.js';
|
|
8
9
|
|
|
9
10
|
const Form = FormProvider;
|
|
10
11
|
const FormFieldContext = React.createContext({});
|
|
@@ -67,13 +68,24 @@ const FormDescription = React.forwardRef(
|
|
|
67
68
|
);
|
|
68
69
|
FormDescription.displayName = "FormDescription";
|
|
69
70
|
const FormMessage = React.forwardRef(
|
|
70
|
-
({ className, children, ...props }, ref) => {
|
|
71
|
+
({ className = "", children, ...props }, ref) => {
|
|
71
72
|
const { error, formMessageId } = useFormField();
|
|
72
73
|
const body = error ? String(error.message) : children;
|
|
73
74
|
if (!body) {
|
|
74
75
|
return null;
|
|
75
76
|
}
|
|
76
|
-
return /* @__PURE__ */ jsx(
|
|
77
|
+
return /* @__PURE__ */ jsx(
|
|
78
|
+
Typography,
|
|
79
|
+
{
|
|
80
|
+
ref,
|
|
81
|
+
component: "p",
|
|
82
|
+
className: cn("flex items-center gap-2", error ? "text-error" : "text-neutral-500", className),
|
|
83
|
+
variant: "body-md",
|
|
84
|
+
id: formMessageId,
|
|
85
|
+
...props,
|
|
86
|
+
children: body
|
|
87
|
+
}
|
|
88
|
+
);
|
|
77
89
|
}
|
|
78
90
|
);
|
|
79
91
|
FormMessage.displayName = "FormMessage";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.js","sources":["../../../src/components/Form/Form.tsx"],"sourcesContent":["'use client'\nimport * as LabelPrimitive from '@radix-ui/react-label'\nimport { Slot } from '@radix-ui/react-slot'\nimport * as React from 'react'\nimport { Controller, ControllerProps, FieldPath, FieldValues, FormProvider, useFormContext } from 'react-hook-form'\n\nimport { Label } from '../Label/Label'\n\nimport { cn } from '@/lib/utils'\n\nconst Form = FormProvider\n\ninterface FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> {\n name: TName\n}\n\nconst FormFieldContext = React.createContext<FormFieldContextValue>({} as FormFieldContextValue)\n\nconst FormField = <\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n ...props\n}: ControllerProps<TFieldValues, TName>) => {\n const contextValue = React.useMemo(() => ({ name: props.name }), [props.name])\n\n return (\n <FormFieldContext.Provider value={contextValue}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n )\n}\n\nconst useFormField = () => {\n const fieldContext = React.useContext(FormFieldContext)\n const itemContext = React.useContext(FormItemContext)\n const { getFieldState, formState } = useFormContext()\n\n const fieldState = getFieldState(fieldContext.name, formState)\n\n const { id } = itemContext\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n ...fieldState,\n }\n}\n\ninterface FormItemContextValue {\n id: string\n}\n\nconst FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue)\n\nconst FormItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n ({ className, ...props }, ref) => {\n const id = React.useId()\n const contextValue = React.useMemo(() => ({ id }), [id])\n\n return (\n <FormItemContext.Provider value={contextValue}>\n <div ref={ref} className={cn('space-y-2', className)} {...props} />\n </FormItemContext.Provider>\n )\n },\n)\nFormItem.displayName = 'FormItem'\n\nconst FormLabel = React.forwardRef<\n React.ElementRef<typeof LabelPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>\n>(({ className, ...props }, ref) => {\n const { error, formItemId } = useFormField()\n\n return <Label ref={ref} className={cn(error && '', className)} htmlFor={formItemId} {...props} />\n})\nFormLabel.displayName = 'FormLabel'\n\nconst FormControl = React.forwardRef<React.ElementRef<typeof Slot>, React.ComponentPropsWithoutRef<typeof Slot>>(\n ({ ...props }, ref) => {\n const { error, formItemId, formDescriptionId, formMessageId } = useFormField()\n\n return (\n <Slot\n ref={ref}\n id={formItemId}\n aria-describedby={`${formDescriptionId} ${error ? formMessageId : ''}`}\n aria-invalid={!!error}\n {...props}\n />\n )\n },\n)\nFormControl.displayName = 'FormControl'\n\nconst FormDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(\n ({ className, ...props }, ref) => {\n const { formDescriptionId } = useFormField()\n\n return <p ref={ref} id={formDescriptionId} className={cn('text-muted-foreground text-sm', className)} {...props} />\n },\n)\nFormDescription.displayName = 'FormDescription'\n\nconst FormMessage = React.forwardRef<HTMLParagraphElement,
|
|
1
|
+
{"version":3,"file":"Form.js","sources":["../../../src/components/Form/Form.tsx"],"sourcesContent":["'use client'\nimport * as LabelPrimitive from '@radix-ui/react-label'\nimport { Slot } from '@radix-ui/react-slot'\nimport * as React from 'react'\nimport { Controller, ControllerProps, FieldPath, FieldValues, FormProvider, useFormContext } from 'react-hook-form'\n\nimport { Label } from '../Label/Label'\n\nimport { cn } from '@/lib/utils'\nimport { Typography, TypographyProps } from '../Typography'\n\nconst Form = FormProvider\n\ninterface FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> {\n name: TName\n}\n\nconst FormFieldContext = React.createContext<FormFieldContextValue>({} as FormFieldContextValue)\n\nconst FormField = <\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n ...props\n}: ControllerProps<TFieldValues, TName>) => {\n const contextValue = React.useMemo(() => ({ name: props.name }), [props.name])\n\n return (\n <FormFieldContext.Provider value={contextValue}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n )\n}\n\nconst useFormField = () => {\n const fieldContext = React.useContext(FormFieldContext)\n const itemContext = React.useContext(FormItemContext)\n const { getFieldState, formState } = useFormContext()\n\n const fieldState = getFieldState(fieldContext.name, formState)\n\n const { id } = itemContext\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n ...fieldState,\n }\n}\n\ninterface FormItemContextValue {\n id: string\n}\n\nconst FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue)\n\nconst FormItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n ({ className, ...props }, ref) => {\n const id = React.useId()\n const contextValue = React.useMemo(() => ({ id }), [id])\n\n return (\n <FormItemContext.Provider value={contextValue}>\n <div ref={ref} className={cn('space-y-2', className)} {...props} />\n </FormItemContext.Provider>\n )\n },\n)\nFormItem.displayName = 'FormItem'\n\nconst FormLabel = React.forwardRef<\n React.ElementRef<typeof LabelPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>\n>(({ className, ...props }, ref) => {\n const { error, formItemId } = useFormField()\n\n return <Label ref={ref} className={cn(error && '', className)} htmlFor={formItemId} {...props} />\n})\nFormLabel.displayName = 'FormLabel'\n\nconst FormControl = React.forwardRef<React.ElementRef<typeof Slot>, React.ComponentPropsWithoutRef<typeof Slot>>(\n ({ ...props }, ref) => {\n const { error, formItemId, formDescriptionId, formMessageId } = useFormField()\n\n return (\n <Slot\n ref={ref}\n id={formItemId}\n aria-describedby={`${formDescriptionId} ${error ? formMessageId : ''}`}\n aria-invalid={!!error}\n {...props}\n />\n )\n },\n)\nFormControl.displayName = 'FormControl'\n\nconst FormDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(\n ({ className, ...props }, ref) => {\n const { formDescriptionId } = useFormField()\n\n return <p ref={ref} id={formDescriptionId} className={cn('text-muted-foreground text-sm', className)} {...props} />\n },\n)\nFormDescription.displayName = 'FormDescription'\n\nconst FormMessage = React.forwardRef<HTMLParagraphElement, TypographyProps>(\n ({ className = '', children, ...props }, ref) => {\n const { error, formMessageId } = useFormField()\n const body = error ? String(error.message) : children\n\n if (!body) {\n return null\n }\n\n return (\n <Typography\n ref={ref}\n component=\"p\"\n className={cn('flex items-center gap-2', error ? 'text-error' : 'text-neutral-500', className)}\n variant=\"body-md\"\n id={formMessageId}\n {...props}\n >\n {body}\n </Typography>\n )\n },\n)\n\nFormMessage.displayName = 'FormMessage'\n\nexport { useFormField, Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField }\n"],"names":[],"mappings":";;;;;;;;;AAWA;AASA;AAEA;AAGE;AAEF;AACE;AAEA;AAKF;AAEA;AACE;AACA;AACA;AAEA;AAEA;AAEA;AAAO;AACL;AACmB;AACF;AACO;AACJ;AACjB;AAEP;AAMA;AAEA;AAAuB;AAEnB;AACA;AAEA;AAGE;AAGN;AACA;AAEM;AAIJ;AAEA;AACF;AACA;AAEA;AAA0B;AAEtB;AAEA;AACE;AAAC;AAAA;AACC;AACI;AACiE;AACrD;AACZ;AAAA;AACN;AAGN;AACA;AAEA;AAA8B;AAE1B;AAEA;AAAiH;AAErH;AACA;AAEA;AAA0B;AAEtB;AACA;AAEA;AACE;AAAO;AAGT;AACE;AAAC;AAAA;AACC;AACU;AACmF;AACrF;AACJ;AACA;AAEH;AAAA;AACH;AAGN;AAEA;;"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { TooltipContent } from '../Tooltip';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
type SidebarContext = {
|
|
4
|
+
state: 'expanded' | 'collapsed';
|
|
5
|
+
open: boolean;
|
|
6
|
+
setOpen: (open: boolean) => void;
|
|
7
|
+
openMobile: boolean;
|
|
8
|
+
setOpenMobile: (open: boolean) => void;
|
|
9
|
+
isMobile: boolean;
|
|
10
|
+
toggleSidebar: () => void;
|
|
11
|
+
};
|
|
12
|
+
declare const SidebarContext: React.Context<SidebarContext | null>;
|
|
13
|
+
declare function useSidebar(): SidebarContext;
|
|
14
|
+
declare const SidebarProvider: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
|
|
15
|
+
defaultOpen?: boolean;
|
|
16
|
+
open?: boolean;
|
|
17
|
+
onOpenChange?: (open: boolean) => void;
|
|
18
|
+
}, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
19
|
+
declare const SidebarRoot: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
|
|
20
|
+
side?: "left" | "right";
|
|
21
|
+
variant?: "default" | "hidden";
|
|
22
|
+
}, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
23
|
+
declare const SidebarTrigger: React.ForwardRefExoticComponent<Omit<import('../Button').ButtonProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
24
|
+
declare const SidebarRail: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
25
|
+
declare const SidebarInset: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
26
|
+
declare const SidebarInput: React.ForwardRefExoticComponent<Omit<import('../Input').InputProps & React.RefAttributes<HTMLInputElement>, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
27
|
+
declare const SidebarHeader: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
28
|
+
declare const SidebarFooter: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
29
|
+
declare const SidebarSeparator: React.ForwardRefExoticComponent<Omit<import('../Separator').SeparatorProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
30
|
+
declare const SidebarContent: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
31
|
+
declare const SidebarGroup: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
32
|
+
declare const SidebarGroupLabel: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
|
|
33
|
+
asChild?: boolean;
|
|
34
|
+
}, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
35
|
+
declare const SidebarGroupAction: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLButtonElement> & React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
36
|
+
asChild?: boolean;
|
|
37
|
+
}, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
38
|
+
declare const SidebarGroupContent: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
39
|
+
declare const SidebarMenu: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & React.RefAttributes<HTMLUListElement>>;
|
|
40
|
+
declare const SidebarMenuItem: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref"> & React.RefAttributes<HTMLLIElement>>;
|
|
41
|
+
declare const SidebarMenuButton: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLButtonElement> & React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
42
|
+
asChild?: boolean;
|
|
43
|
+
isActive?: boolean;
|
|
44
|
+
tooltip?: string | React.ComponentProps<typeof TooltipContent>;
|
|
45
|
+
variant?: "navigation-item" | "element";
|
|
46
|
+
}, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
47
|
+
declare const SidebarMenuAction: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLButtonElement> & React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
48
|
+
asChild?: boolean;
|
|
49
|
+
showOnHover?: boolean;
|
|
50
|
+
}, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
51
|
+
declare const SidebarMenuBadge: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
52
|
+
declare const SidebarMenuSkeleton: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
|
|
53
|
+
showIcon?: boolean;
|
|
54
|
+
}, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
55
|
+
declare const SidebarMenuSub: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & React.RefAttributes<HTMLUListElement>>;
|
|
56
|
+
declare const SidebarMenuSubItem: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref"> & React.RefAttributes<HTMLLIElement>>;
|
|
57
|
+
declare const SidebarMenuSubButton: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLAnchorElement> & React.AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
58
|
+
asChild?: boolean;
|
|
59
|
+
isActive?: boolean;
|
|
60
|
+
}, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
|
|
61
|
+
export { SidebarRoot, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, useSidebar, };
|