@adminlte/react 0.1.0

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 (83) hide show
  1. package/CHANGELOG.md +161 -0
  2. package/README.md +454 -0
  3. package/dist/context/accessibility.js +141 -0
  4. package/dist/context/body-class-sync.js +22 -0
  5. package/dist/context/color-mode-context.js +61 -0
  6. package/dist/context/command-palette-context.js +28 -0
  7. package/dist/context/html-dir.js +17 -0
  8. package/dist/context/link-context.js +18 -0
  9. package/dist/context/lte-behaviors.js +52 -0
  10. package/dist/context/sidebar-context.js +87 -0
  11. package/dist/css/adminlte.css +17259 -0
  12. package/dist/form/button.js +21 -0
  13. package/dist/form/input-color.js +30 -0
  14. package/dist/form/input-file.js +29 -0
  15. package/dist/form/input-flatpickr.js +45 -0
  16. package/dist/form/input-switch.js +26 -0
  17. package/dist/form/input-tom-select.js +59 -0
  18. package/dist/form/input.js +23 -0
  19. package/dist/form/select.js +25 -0
  20. package/dist/form/textarea.js +22 -0
  21. package/dist/hooks/use-card-widget.js +44 -0
  22. package/dist/hooks/use-direct-chat.js +16 -0
  23. package/dist/hooks/use-fullscreen.js +44 -0
  24. package/dist/hooks/use-push-menu.js +54 -0
  25. package/dist/hooks/use-sortable.js +26 -0
  26. package/dist/hooks/use-treeview-animation.js +27 -0
  27. package/dist/index.d.ts +1010 -0
  28. package/dist/index.js +145 -0
  29. package/dist/layout/app-content.js +18 -0
  30. package/dist/layout/auth-layout.js +25 -0
  31. package/dist/layout/color-mode-toggle.js +67 -0
  32. package/dist/layout/dashboard-layout.js +101 -0
  33. package/dist/layout/footer.js +19 -0
  34. package/dist/layout/sidebar-brand.js +16 -0
  35. package/dist/layout/sidebar-nav-item.js +46 -0
  36. package/dist/layout/sidebar-nav.js +43 -0
  37. package/dist/layout/sidebar-overlay.js +18 -0
  38. package/dist/layout/sidebar.js +48 -0
  39. package/dist/layout/topbar.js +128 -0
  40. package/dist/lib/class-name.js +6 -0
  41. package/dist/lib/flatten-menu.js +23 -0
  42. package/dist/tool/datatable.js +45 -0
  43. package/dist/tool/editor.js +72 -0
  44. package/dist/tool/modal.js +28 -0
  45. package/dist/types/direct-chat.js +0 -0
  46. package/dist/types/layout.js +0 -0
  47. package/dist/types/menu.js +0 -0
  48. package/dist/types/theme.js +0 -0
  49. package/dist/widget/accordion.js +35 -0
  50. package/dist/widget/alert.js +18 -0
  51. package/dist/widget/apex-chart.js +40 -0
  52. package/dist/widget/avatar.js +72 -0
  53. package/dist/widget/badge.js +20 -0
  54. package/dist/widget/breadcrumb.js +26 -0
  55. package/dist/widget/callout.js +11 -0
  56. package/dist/widget/card.js +84 -0
  57. package/dist/widget/carousel.js +56 -0
  58. package/dist/widget/command-palette.js +137 -0
  59. package/dist/widget/description-block.js +19 -0
  60. package/dist/widget/direct-chat.js +96 -0
  61. package/dist/widget/dropdown.js +63 -0
  62. package/dist/widget/info-box.js +24 -0
  63. package/dist/widget/list-group.js +47 -0
  64. package/dist/widget/nav-messages.js +48 -0
  65. package/dist/widget/nav-notifications.js +40 -0
  66. package/dist/widget/nav-tasks.js +60 -0
  67. package/dist/widget/offcanvas.js +61 -0
  68. package/dist/widget/pagination.js +93 -0
  69. package/dist/widget/profile-card.js +32 -0
  70. package/dist/widget/progress-group.js +23 -0
  71. package/dist/widget/progress.js +25 -0
  72. package/dist/widget/ratings.js +20 -0
  73. package/dist/widget/small-box.js +34 -0
  74. package/dist/widget/sparkline-chart.js +43 -0
  75. package/dist/widget/spinner.js +26 -0
  76. package/dist/widget/stepper.js +57 -0
  77. package/dist/widget/table.js +50 -0
  78. package/dist/widget/tabs.js +46 -0
  79. package/dist/widget/timeline.js +15 -0
  80. package/dist/widget/toast.js +41 -0
  81. package/dist/widget/tooltip.js +30 -0
  82. package/dist/widget/world-map.js +42 -0
  83. package/package.json +116 -0
package/dist/index.js ADDED
@@ -0,0 +1,145 @@
1
+ import { SidebarProvider, useSidebarContext } from "./context/sidebar-context.js";
2
+ import { ColorModeProvider, useColorModeContext } from "./context/color-mode-context.js";
3
+ import { CommandPaletteProvider, useCommandPalette } from "./context/command-palette-context.js";
4
+ import { LinkProvider, useLinkComponent } from "./context/link-context.js";
5
+ import { DashboardLayout } from "./layout/dashboard-layout.js";
6
+ import { AuthLayout } from "./layout/auth-layout.js";
7
+ import { AppContent } from "./layout/app-content.js";
8
+ import { Topbar } from "./layout/topbar.js";
9
+ import { Sidebar } from "./layout/sidebar.js";
10
+ import { SidebarBrand } from "./layout/sidebar-brand.js";
11
+ import { SidebarNav } from "./layout/sidebar-nav.js";
12
+ import { SidebarNavItem } from "./layout/sidebar-nav-item.js";
13
+ import { SidebarOverlay } from "./layout/sidebar-overlay.js";
14
+ import { Footer } from "./layout/footer.js";
15
+ import { ColorModeToggle } from "./layout/color-mode-toggle.js";
16
+ import { SmallBox } from "./widget/small-box.js";
17
+ import { InfoBox } from "./widget/info-box.js";
18
+ import { Card } from "./widget/card.js";
19
+ import { Alert } from "./widget/alert.js";
20
+ import { Callout } from "./widget/callout.js";
21
+ import { Progress } from "./widget/progress.js";
22
+ import { ProgressGroup } from "./widget/progress-group.js";
23
+ import { Ratings } from "./widget/ratings.js";
24
+ import { ProfileCard } from "./widget/profile-card.js";
25
+ import { DescriptionBlock } from "./widget/description-block.js";
26
+ import { Timeline } from "./widget/timeline.js";
27
+ import { NavMessages } from "./widget/nav-messages.js";
28
+ import { NavNotifications } from "./widget/nav-notifications.js";
29
+ import { NavTasks } from "./widget/nav-tasks.js";
30
+ import { DirectChat } from "./widget/direct-chat.js";
31
+ import { ApexChart } from "./widget/apex-chart.js";
32
+ import { SparklineChart } from "./widget/sparkline-chart.js";
33
+ import { WorldMap } from "./widget/world-map.js";
34
+ import { CommandPalette } from "./widget/command-palette.js";
35
+ import { flattenMenuToCommands } from "./lib/flatten-menu.js";
36
+ import { Accordion } from "./widget/accordion.js";
37
+ import { Tabs } from "./widget/tabs.js";
38
+ import { Toast } from "./widget/toast.js";
39
+ import { Tooltip } from "./widget/tooltip.js";
40
+ import { Badge } from "./widget/badge.js";
41
+ import { Breadcrumb } from "./widget/breadcrumb.js";
42
+ import { Spinner } from "./widget/spinner.js";
43
+ import { Avatar, AvatarGroup } from "./widget/avatar.js";
44
+ import { ListGroup, ListGroupItem } from "./widget/list-group.js";
45
+ import { Table } from "./widget/table.js";
46
+ import { Pagination } from "./widget/pagination.js";
47
+ import { Stepper } from "./widget/stepper.js";
48
+ import { Dropdown } from "./widget/dropdown.js";
49
+ import { Carousel } from "./widget/carousel.js";
50
+ import { Offcanvas, OffcanvasTrigger } from "./widget/offcanvas.js";
51
+ import { Button } from "./form/button.js";
52
+ import { Input } from "./form/input.js";
53
+ import { Select } from "./form/select.js";
54
+ import { Textarea } from "./form/textarea.js";
55
+ import { InputSwitch } from "./form/input-switch.js";
56
+ import { InputColor } from "./form/input-color.js";
57
+ import { InputFile } from "./form/input-file.js";
58
+ import { InputFlatpickr } from "./form/input-flatpickr.js";
59
+ import { InputTomSelect } from "./form/input-tom-select.js";
60
+ import { Modal } from "./tool/modal.js";
61
+ import { Datatable } from "./tool/datatable.js";
62
+ import { Editor } from "./tool/editor.js";
63
+ import { usePushMenu } from "./hooks/use-push-menu.js";
64
+ import { useCardWidget } from "./hooks/use-card-widget.js";
65
+ import { useDirectChat } from "./hooks/use-direct-chat.js";
66
+ import { useFullscreen } from "./hooks/use-fullscreen.js";
67
+ import { useTreeviewAnimation } from "./hooks/use-treeview-animation.js";
68
+ import { useSortable } from "./hooks/use-sortable.js";
69
+ export {
70
+ Accordion,
71
+ Alert,
72
+ ApexChart,
73
+ AppContent,
74
+ AuthLayout,
75
+ Avatar,
76
+ AvatarGroup,
77
+ Badge,
78
+ Breadcrumb,
79
+ Button,
80
+ Callout,
81
+ Card,
82
+ Carousel,
83
+ ColorModeProvider,
84
+ ColorModeToggle,
85
+ CommandPalette,
86
+ CommandPaletteProvider,
87
+ DashboardLayout,
88
+ Datatable,
89
+ DescriptionBlock,
90
+ DirectChat,
91
+ Dropdown,
92
+ Editor,
93
+ Footer,
94
+ InfoBox,
95
+ Input,
96
+ InputColor,
97
+ InputFile,
98
+ InputFlatpickr,
99
+ InputSwitch,
100
+ InputTomSelect,
101
+ LinkProvider,
102
+ ListGroup,
103
+ ListGroupItem,
104
+ Modal,
105
+ NavMessages,
106
+ NavNotifications,
107
+ NavTasks,
108
+ Offcanvas,
109
+ OffcanvasTrigger,
110
+ Pagination,
111
+ ProfileCard,
112
+ Progress,
113
+ ProgressGroup,
114
+ Ratings,
115
+ Select,
116
+ Sidebar,
117
+ SidebarBrand,
118
+ SidebarNav,
119
+ SidebarNavItem,
120
+ SidebarOverlay,
121
+ SidebarProvider,
122
+ SmallBox,
123
+ SparklineChart,
124
+ Spinner,
125
+ Stepper,
126
+ Table,
127
+ Tabs,
128
+ Textarea,
129
+ Timeline,
130
+ Toast,
131
+ Tooltip,
132
+ Topbar,
133
+ WorldMap,
134
+ flattenMenuToCommands,
135
+ useCardWidget,
136
+ useColorModeContext,
137
+ useCommandPalette,
138
+ useDirectChat,
139
+ useFullscreen,
140
+ useLinkComponent,
141
+ usePushMenu,
142
+ useSidebarContext,
143
+ useSortable,
144
+ useTreeviewAnimation
145
+ };
@@ -0,0 +1,18 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ function AppContent({
3
+ breadcrumbs,
4
+ title,
5
+ fluid = true,
6
+ children
7
+ }) {
8
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
9
+ (title || breadcrumbs) && /* @__PURE__ */ jsx("div", { className: "app-content-header", children: /* @__PURE__ */ jsx("div", { className: `container-${fluid ? "fluid" : "lg"}`, children: /* @__PURE__ */ jsxs("div", { className: "row", children: [
10
+ /* @__PURE__ */ jsx("div", { className: "col-sm-6", children: title && /* @__PURE__ */ jsx("h3", { className: "mb-0", children: title }) }),
11
+ breadcrumbs && breadcrumbs.length > 0 && /* @__PURE__ */ jsx("div", { className: "col-sm-6", children: /* @__PURE__ */ jsx("ol", { className: "breadcrumb float-sm-end", children: breadcrumbs.map((crumb, idx) => /* @__PURE__ */ jsx("li", { className: `breadcrumb-item ${idx === breadcrumbs.length - 1 ? "active" : ""}`, children: crumb.href ? /* @__PURE__ */ jsx("a", { href: crumb.href, children: crumb.label }) : crumb.label }, idx)) }) })
12
+ ] }) }) }),
13
+ /* @__PURE__ */ jsx("div", { className: "app-content", children: /* @__PURE__ */ jsx("div", { className: `container-${fluid ? "fluid" : "lg"}`, children }) })
14
+ ] });
15
+ }
16
+ export {
17
+ AppContent
18
+ };
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { useEffect } from "react";
4
+ function AuthLayout({
5
+ authType = "login",
6
+ logo = /* @__PURE__ */ jsxs(Fragment, { children: [
7
+ /* @__PURE__ */ jsx("b", { children: "Admin" }),
8
+ "LTE"
9
+ ] }),
10
+ logoHref = "/",
11
+ children
12
+ }) {
13
+ useEffect(() => {
14
+ const cls = [`${authType}-page`, "bg-body-secondary"];
15
+ document.body.classList.add(...cls);
16
+ return () => document.body.classList.remove(...cls);
17
+ }, [authType]);
18
+ return /* @__PURE__ */ jsxs("div", { className: `${authType}-box`, children: [
19
+ /* @__PURE__ */ jsx("div", { className: `${authType}-logo`, children: /* @__PURE__ */ jsx("a", { href: logoHref, children: logo }) }),
20
+ /* @__PURE__ */ jsx("div", { className: "card", children: /* @__PURE__ */ jsx("div", { className: `card-body ${authType}-card-body`, children }) })
21
+ ] });
22
+ }
23
+ export {
24
+ AuthLayout
25
+ };
@@ -0,0 +1,67 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useColorModeContext } from "../context/color-mode-context.js";
4
+ function ColorModeToggle() {
5
+ const { colorMode, setColorMode } = useColorModeContext();
6
+ const toggleMode = (mode) => {
7
+ setColorMode(mode);
8
+ };
9
+ return /* @__PURE__ */ jsxs("li", { className: "nav-item dropdown", children: [
10
+ /* @__PURE__ */ jsx(
11
+ "button",
12
+ {
13
+ className: "nav-link",
14
+ id: "bd-theme",
15
+ type: "button",
16
+ "aria-label": "Toggle color scheme",
17
+ "data-bs-toggle": "dropdown",
18
+ "aria-expanded": "false",
19
+ children: /* @__PURE__ */ jsx("i", { className: `bi bi-${colorMode === "light" ? "sun-fill" : colorMode === "dark" ? "moon-fill" : "circle-half"}` })
20
+ }
21
+ ),
22
+ /* @__PURE__ */ jsxs("ul", { className: "dropdown-menu dropdown-menu-end", "aria-labelledby": "bd-theme", children: [
23
+ /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
24
+ "button",
25
+ {
26
+ type: "button",
27
+ className: `dropdown-item d-flex align-items-center ${colorMode === "light" ? "active" : ""}`,
28
+ onClick: () => toggleMode("light"),
29
+ children: [
30
+ /* @__PURE__ */ jsx("i", { className: "bi bi-sun-fill me-2" }),
31
+ "Light",
32
+ colorMode === "light" && /* @__PURE__ */ jsx("i", { className: "bi bi-check-lg ms-auto" })
33
+ ]
34
+ }
35
+ ) }),
36
+ /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
37
+ "button",
38
+ {
39
+ type: "button",
40
+ className: `dropdown-item d-flex align-items-center ${colorMode === "dark" ? "active" : ""}`,
41
+ onClick: () => toggleMode("dark"),
42
+ children: [
43
+ /* @__PURE__ */ jsx("i", { className: "bi bi-moon-fill me-2" }),
44
+ "Dark",
45
+ colorMode === "dark" && /* @__PURE__ */ jsx("i", { className: "bi bi-check-lg ms-auto" })
46
+ ]
47
+ }
48
+ ) }),
49
+ /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
50
+ "button",
51
+ {
52
+ type: "button",
53
+ className: `dropdown-item d-flex align-items-center ${colorMode === "auto" ? "active" : ""}`,
54
+ onClick: () => toggleMode("auto"),
55
+ children: [
56
+ /* @__PURE__ */ jsx("i", { className: "bi bi-circle-half me-2" }),
57
+ "Auto",
58
+ colorMode === "auto" && /* @__PURE__ */ jsx("i", { className: "bi bi-check-lg ms-auto" })
59
+ ]
60
+ }
61
+ ) })
62
+ ] })
63
+ ] });
64
+ }
65
+ export {
66
+ ColorModeToggle
67
+ };
@@ -0,0 +1,101 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { cn } from "../lib/class-name.js";
3
+ import { SidebarProvider } from "../context/sidebar-context.js";
4
+ import { ColorModeProvider } from "../context/color-mode-context.js";
5
+ import { CommandPaletteProvider } from "../context/command-palette-context.js";
6
+ import { LinkProvider } from "../context/link-context.js";
7
+ import { BodyClassSync } from "../context/body-class-sync.js";
8
+ import { LteBehaviors } from "../context/lte-behaviors.js";
9
+ import { Accessibility } from "../context/accessibility.js";
10
+ import { HtmlDir } from "../context/html-dir.js";
11
+ import { Topbar } from "./topbar.js";
12
+ import { Sidebar } from "./sidebar.js";
13
+ import { Footer } from "./footer.js";
14
+ import { CommandPalette } from "../widget/command-palette.js";
15
+ import { flattenMenuToCommands } from "../lib/flatten-menu.js";
16
+ function DashboardLayout({
17
+ menuItems,
18
+ logo = /* @__PURE__ */ jsxs(Fragment, { children: [
19
+ /* @__PURE__ */ jsx("b", { children: "Admin" }),
20
+ "LTE"
21
+ ] }),
22
+ logoHref = "/",
23
+ user,
24
+ sidebarTheme = "dark",
25
+ sidebarClass,
26
+ sidebarBreakpoint = "lg",
27
+ sidebarMini = false,
28
+ fixedHeader = false,
29
+ fixedSidebar = false,
30
+ fixedFooter = false,
31
+ colorModeToggle = true,
32
+ initialColorMode = "auto",
33
+ dir,
34
+ enableSidebarPersistence = false,
35
+ navbarClass,
36
+ bodyClass,
37
+ topbarStart,
38
+ topbarEnd,
39
+ footer,
40
+ linkComponent,
41
+ docsHref,
42
+ docsLabel,
43
+ children
44
+ }) {
45
+ const breakpointValue = sidebarBreakpoint === "lg" ? 992 : 768;
46
+ const staticBodyClasses = cn(
47
+ "layout-fixed",
48
+ `sidebar-expand-${sidebarBreakpoint}`,
49
+ fixedHeader && "fixed-header",
50
+ fixedSidebar && "fixed-sidebar",
51
+ fixedFooter && "fixed-footer",
52
+ "bg-body-tertiary",
53
+ bodyClass
54
+ );
55
+ const defaultSidebarClass = "bg-body-secondary shadow";
56
+ const commandItems = flattenMenuToCommands(menuItems);
57
+ return /* @__PURE__ */ jsx(LinkProvider, { component: linkComponent, children: /* @__PURE__ */ jsx(ColorModeProvider, { initialMode: initialColorMode, children: /* @__PURE__ */ jsx(
58
+ SidebarProvider,
59
+ {
60
+ sidebarMini,
61
+ enablePersistence: enableSidebarPersistence,
62
+ sidebarBreakpoint: breakpointValue,
63
+ children: /* @__PURE__ */ jsxs(CommandPaletteProvider, { children: [
64
+ /* @__PURE__ */ jsx(BodyClassSync, { staticClasses: staticBodyClasses }),
65
+ /* @__PURE__ */ jsx(LteBehaviors, {}),
66
+ /* @__PURE__ */ jsx(Accessibility, {}),
67
+ dir && /* @__PURE__ */ jsx(HtmlDir, { dir }),
68
+ /* @__PURE__ */ jsxs("div", { className: "app-wrapper", children: [
69
+ /* @__PURE__ */ jsx(
70
+ Topbar,
71
+ {
72
+ colorModeToggle,
73
+ navbarClass,
74
+ start: topbarStart,
75
+ end: topbarEnd,
76
+ user
77
+ }
78
+ ),
79
+ /* @__PURE__ */ jsx(
80
+ Sidebar,
81
+ {
82
+ items: menuItems,
83
+ logo,
84
+ logoHref,
85
+ theme: sidebarTheme,
86
+ sidebarClass: sidebarClass || defaultSidebarClass,
87
+ docsHref,
88
+ docsLabel
89
+ }
90
+ ),
91
+ /* @__PURE__ */ jsx("main", { className: "app-main", children }),
92
+ /* @__PURE__ */ jsx(Footer, { children: footer })
93
+ ] }),
94
+ /* @__PURE__ */ jsx(CommandPalette, { items: commandItems })
95
+ ] })
96
+ }
97
+ ) }) });
98
+ }
99
+ export {
100
+ DashboardLayout
101
+ };
@@ -0,0 +1,19 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ function Footer({ children }) {
3
+ const year = (/* @__PURE__ */ new Date()).getFullYear();
4
+ return /* @__PURE__ */ jsxs("footer", { className: "app-footer fs-7", children: [
5
+ /* @__PURE__ */ jsx("div", { className: "float-end d-none d-sm-inline", children: "Anything you want" }),
6
+ /* @__PURE__ */ jsxs("strong", { children: [
7
+ "Copyright \xA9 2014-",
8
+ year,
9
+ "\xA0",
10
+ /* @__PURE__ */ jsx("a", { href: "https://adminlte.io", className: "text-decoration-none", children: "AdminLTE.io" }),
11
+ "."
12
+ ] }),
13
+ "All rights reserved.",
14
+ children
15
+ ] });
16
+ }
17
+ export {
18
+ Footer
19
+ };
@@ -0,0 +1,16 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ function SidebarBrand({ logo = /* @__PURE__ */ jsxs(Fragment, { children: [
3
+ /* @__PURE__ */ jsx("b", { children: "Admin" }),
4
+ "LTE"
5
+ ] }), href = "/" }) {
6
+ return /* @__PURE__ */ jsx("div", { className: "sidebar-brand", children: /* @__PURE__ */ jsx("a", { href, className: "brand-link", children: typeof logo === "string" ? /* @__PURE__ */ jsxs(Fragment, { children: [
7
+ /* @__PURE__ */ jsx("img", { src: logo, alt: "Logo", className: "brand-image opacity-75 shadow" }),
8
+ /* @__PURE__ */ jsx("span", { className: "brand-text fw-light", children: "AdminLTE 4" })
9
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
10
+ /* @__PURE__ */ jsx("span", { className: "brand-image opacity-75 shadow" }),
11
+ /* @__PURE__ */ jsx("span", { className: "brand-text fw-light", children: logo })
12
+ ] }) }) });
13
+ }
14
+ export {
15
+ SidebarBrand
16
+ };
@@ -0,0 +1,46 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useState } from "react";
4
+ import { useTreeviewAnimation } from "../hooks/use-treeview-animation.js";
5
+ import { useLinkComponent } from "../context/link-context.js";
6
+ import { cn } from "../lib/class-name.js";
7
+ function SidebarNavGroup({
8
+ item,
9
+ currentPath,
10
+ depth
11
+ }) {
12
+ const hasActiveChild = item.children.some(
13
+ (child) => child.type === "item" && (currentPath === child.href || currentPath.startsWith(child.href + "/"))
14
+ );
15
+ const [isOpen, setIsOpen] = useState(hasActiveChild);
16
+ const { ref, style } = useTreeviewAnimation(isOpen, 300);
17
+ return /* @__PURE__ */ jsxs("li", { className: cn("nav-item", isOpen && "menu-open"), children: [
18
+ /* @__PURE__ */ jsxs("button", { type: "button", className: "nav-link", onClick: () => setIsOpen(!isOpen), children: [
19
+ item.icon && /* @__PURE__ */ jsx("i", { className: `nav-icon bi ${item.icon}` }),
20
+ /* @__PURE__ */ jsxs("p", { children: [
21
+ item.text,
22
+ /* @__PURE__ */ jsx("i", { className: "nav-arrow bi bi-chevron-right" })
23
+ ] }),
24
+ item.badge && /* @__PURE__ */ jsx("span", { className: `nav-badge badge text-bg-${item.badgeColor || "secondary"} ms-auto me-3`, children: item.badge })
25
+ ] }),
26
+ /* @__PURE__ */ jsx("ul", { ref, style, className: "nav nav-treeview", children: item.children.map((child, idx) => /* @__PURE__ */ jsx(SidebarNavItem, { item: child, currentPath, depth: depth + 1 }, idx)) })
27
+ ] });
28
+ }
29
+ function SidebarNavItem({ item, currentPath, depth = 0 }) {
30
+ const Link = useLinkComponent();
31
+ if (item.type === "header") {
32
+ return /* @__PURE__ */ jsx("li", { className: "nav-header", children: item.text });
33
+ }
34
+ if (item.type === "item") {
35
+ const isActive = currentPath === item.href || currentPath.startsWith(item.href + "/");
36
+ return /* @__PURE__ */ jsx("li", { className: cn("nav-item", isActive && "active"), children: /* @__PURE__ */ jsxs(Link, { href: item.href, className: cn("nav-link", isActive && "active"), target: item.target, children: [
37
+ item.icon && /* @__PURE__ */ jsx("i", { className: cn("nav-icon bi", item.icon, item.iconColor && `text-${item.iconColor}`) }),
38
+ /* @__PURE__ */ jsx("p", { children: item.text }),
39
+ item.badge && /* @__PURE__ */ jsx("span", { className: `nav-badge badge text-bg-${item.badgeColor || "secondary"} ms-auto`, children: item.badge })
40
+ ] }) });
41
+ }
42
+ return /* @__PURE__ */ jsx(SidebarNavGroup, { item, currentPath, depth });
43
+ }
44
+ export {
45
+ SidebarNavItem
46
+ };
@@ -0,0 +1,43 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { usePathname } from "next/navigation";
4
+ import { SidebarNavItem } from "./sidebar-nav-item.js";
5
+ import { useLinkComponent } from "../context/link-context.js";
6
+ function SidebarNav({ items, docsHref, docsLabel = "View documentation" }) {
7
+ const pathname = usePathname();
8
+ const Link = useLinkComponent();
9
+ return /* @__PURE__ */ jsxs("nav", { className: "mt-2", "aria-label": "Main navigation", children: [
10
+ /* @__PURE__ */ jsx(
11
+ "ul",
12
+ {
13
+ className: "nav sidebar-menu flex-column",
14
+ "data-lte-toggle": "treeview",
15
+ "data-accordion": "false",
16
+ id: "navigation",
17
+ children: items.map((item, idx) => /* @__PURE__ */ jsx(
18
+ SidebarNavItem,
19
+ {
20
+ item,
21
+ currentPath: pathname,
22
+ depth: 0
23
+ },
24
+ idx
25
+ ))
26
+ }
27
+ ),
28
+ docsHref && /* @__PURE__ */ jsx("div", { className: "p-3 mt-3 border-top border-secondary border-opacity-25", children: /* @__PURE__ */ jsxs(
29
+ Link,
30
+ {
31
+ href: docsHref,
32
+ className: "btn btn-sm btn-outline-light w-100 d-flex align-items-center justify-content-center gap-2",
33
+ children: [
34
+ /* @__PURE__ */ jsx("i", { className: "bi bi-book", "aria-hidden": "true" }),
35
+ docsLabel
36
+ ]
37
+ }
38
+ ) })
39
+ ] });
40
+ }
41
+ export {
42
+ SidebarNav
43
+ };
@@ -0,0 +1,18 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { useSidebarContext } from "../context/sidebar-context.js";
4
+ function SidebarOverlay() {
5
+ const { collapse } = useSidebarContext();
6
+ return /* @__PURE__ */ jsx(
7
+ "div",
8
+ {
9
+ className: "sidebar-overlay",
10
+ onClick: collapse,
11
+ onTouchEnd: collapse,
12
+ role: "presentation"
13
+ }
14
+ );
15
+ }
16
+ export {
17
+ SidebarOverlay
18
+ };
@@ -0,0 +1,48 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useRef } from "react";
4
+ import { SidebarBrand } from "./sidebar-brand.js";
5
+ import { SidebarNav } from "./sidebar-nav.js";
6
+ import { SidebarOverlay } from "./sidebar-overlay.js";
7
+ function Sidebar({
8
+ items,
9
+ logo,
10
+ logoHref = "/",
11
+ theme = "dark",
12
+ sidebarClass,
13
+ docsHref,
14
+ docsLabel
15
+ }) {
16
+ const wrapperRef = useRef(null);
17
+ useEffect(() => {
18
+ if (typeof window === "undefined" || window.innerWidth <= 992) return;
19
+ let instance;
20
+ let rafId = 0;
21
+ const deadline = performance.now() + 1e4;
22
+ const tryInit = () => {
23
+ const osg = window.OverlayScrollbarsGlobal;
24
+ if (osg?.OverlayScrollbars && wrapperRef.current) {
25
+ instance = osg.OverlayScrollbars(wrapperRef.current, {
26
+ scrollbars: { theme: "os-theme-light", autoHide: "leave", clickScroll: true }
27
+ });
28
+ } else if (performance.now() < deadline) {
29
+ rafId = window.requestAnimationFrame(tryInit);
30
+ }
31
+ };
32
+ tryInit();
33
+ return () => {
34
+ window.cancelAnimationFrame(rafId);
35
+ instance?.destroy?.();
36
+ };
37
+ }, []);
38
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
39
+ /* @__PURE__ */ jsxs("aside", { className: `app-sidebar ${sidebarClass || ""}`, "data-bs-theme": theme, children: [
40
+ /* @__PURE__ */ jsx(SidebarBrand, { logo, href: logoHref }),
41
+ /* @__PURE__ */ jsx("div", { className: "sidebar-wrapper", ref: wrapperRef, children: /* @__PURE__ */ jsx(SidebarNav, { items, docsHref, docsLabel }) })
42
+ ] }),
43
+ /* @__PURE__ */ jsx(SidebarOverlay, {})
44
+ ] });
45
+ }
46
+ export {
47
+ Sidebar
48
+ };