@raydenui/ui 0.9.6 → 0.10.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.
- package/dist/Table-DCNSxua1.d.cts +31 -0
- package/dist/Table-DCNSxua1.d.ts +31 -0
- package/dist/blocks/ApplicationShellBlock.cjs +157 -0
- package/dist/blocks/ApplicationShellBlock.js +154 -0
- package/dist/blocks/CheckoutReviewBlock.cjs +16 -0
- package/dist/blocks/CheckoutReviewBlock.js +13 -0
- package/dist/blocks/CommandPaletteBlock.cjs +334 -0
- package/dist/blocks/CommandPaletteBlock.js +331 -0
- package/dist/blocks/CreateAccountBlock.cjs +147 -0
- package/dist/blocks/CreateAccountBlock.js +143 -0
- package/dist/blocks/EmptyStateBlock.cjs +19 -0
- package/dist/blocks/EmptyStateBlock.js +16 -0
- package/dist/blocks/FeatureOverviewBlock.cjs +54 -0
- package/dist/blocks/FeatureOverviewBlock.js +51 -0
- package/dist/blocks/HeaderBlock.cjs +230 -0
- package/dist/blocks/HeaderBlock.js +227 -0
- package/dist/blocks/KpiOverviewBlock.cjs +63 -0
- package/dist/blocks/KpiOverviewBlock.js +60 -0
- package/dist/blocks/LoginBlock.cjs +66 -0
- package/dist/blocks/LoginBlock.js +63 -0
- package/dist/blocks/NotificationsBlock.cjs +17 -0
- package/dist/blocks/NotificationsBlock.js +14 -0
- package/dist/blocks/PageHeaderBlock.cjs +121 -0
- package/dist/blocks/PageHeaderBlock.js +118 -0
- package/dist/blocks/PricingPlansBlock.cjs +146 -0
- package/dist/blocks/PricingPlansBlock.js +143 -0
- package/dist/blocks/ProductCollectionBlock.cjs +37 -0
- package/dist/blocks/ProductCollectionBlock.js +34 -0
- package/dist/blocks/ProductDetailBlock.cjs +30 -0
- package/dist/blocks/ProductDetailBlock.js +27 -0
- package/dist/blocks/ProductHeroBlock.cjs +83 -0
- package/dist/blocks/ProductHeroBlock.js +80 -0
- package/dist/blocks/ProfileSettingsBlock.cjs +130 -0
- package/dist/blocks/ProfileSettingsBlock.js +126 -0
- package/dist/blocks/QuickSendBlock.cjs +11 -0
- package/dist/blocks/QuickSendBlock.js +8 -0
- package/dist/blocks/RecentTransactionsBlock.cjs +13 -0
- package/dist/blocks/RecentTransactionsBlock.js +10 -0
- package/dist/blocks/SearchableTableBlock.cjs +91 -0
- package/dist/blocks/SearchableTableBlock.js +88 -0
- package/dist/blocks/ShoppingCartBlock.cjs +16 -0
- package/dist/blocks/ShoppingCartBlock.js +13 -0
- package/dist/blocks/SiteFooterBlock.cjs +69 -0
- package/dist/blocks/SiteFooterBlock.js +66 -0
- package/dist/blocks/TableBlock.cjs +20 -0
- package/dist/blocks/TableBlock.js +17 -0
- package/dist/blocks/TaskListBlock.cjs +198 -0
- package/dist/blocks/TaskListBlock.js +195 -0
- package/dist/blocks/WorkspaceSwitcherBlock.cjs +291 -0
- package/dist/blocks/WorkspaceSwitcherBlock.js +288 -0
- package/dist/blocks/commerce.cjs +44 -0
- package/dist/blocks/commerce.js +35 -0
- package/dist/blocks/index.cjs +53 -0
- package/dist/blocks/index.js +24 -0
- package/dist/blocks.d.cts +1820 -0
- package/dist/blocks.d.ts +1820 -0
- package/dist/chart.cjs +13 -0
- package/dist/chart.d.cts +59 -0
- package/dist/chart.d.ts +59 -0
- package/dist/chart.js +5 -0
- package/dist/components/Accordion/Accordion.cjs +94 -0
- package/dist/components/Accordion/Accordion.js +91 -0
- package/dist/components/Accordion/index.cjs +8 -0
- package/dist/components/Accordion/index.js +1 -0
- package/dist/components/ActivityFeed/ActivityContent.cjs +40 -0
- package/dist/components/ActivityFeed/ActivityContent.js +37 -0
- package/dist/components/ActivityFeed/ActivityItem.cjs +19 -0
- package/dist/components/ActivityFeed/ActivityItem.js +16 -0
- package/dist/components/ActivityFeed/index.cjs +7 -0
- package/dist/components/ActivityFeed/index.js +2 -0
- package/dist/components/Alert/Alert.cjs +42 -0
- package/dist/components/Alert/Alert.js +39 -0
- package/dist/components/Alert/index.cjs +5 -0
- package/dist/components/Alert/index.js +1 -0
- package/dist/components/Avatar/Avatar.cjs +101 -0
- package/dist/components/Avatar/Avatar.js +98 -0
- package/dist/components/Avatar/index.cjs +6 -0
- package/dist/components/Avatar/index.js +1 -0
- package/dist/components/Badge/Badge.cjs +53 -0
- package/dist/components/Badge/Badge.js +50 -0
- package/dist/components/Badge/index.cjs +5 -0
- package/dist/components/Badge/index.js +1 -0
- package/dist/components/Banner/Banner.cjs +83 -0
- package/dist/components/Banner/Banner.js +80 -0
- package/dist/components/Banner/index.cjs +5 -0
- package/dist/components/Banner/index.js +1 -0
- package/dist/components/Breadcrumb/Breadcrumb.cjs +31 -0
- package/dist/components/Breadcrumb/Breadcrumb.js +28 -0
- package/dist/components/Breadcrumb/index.cjs +5 -0
- package/dist/components/Breadcrumb/index.js +1 -0
- package/dist/components/Button/Button.cjs +88 -0
- package/dist/components/Button/Button.js +85 -0
- package/dist/components/Button/index.cjs +5 -0
- package/dist/components/Button/index.js +1 -0
- package/dist/components/ButtonGroup/ButtonGroup.cjs +8 -0
- package/dist/components/ButtonGroup/ButtonGroup.js +5 -0
- package/dist/components/ButtonGroup/ButtonGroupItem.cjs +15 -0
- package/dist/components/ButtonGroup/ButtonGroupItem.js +12 -0
- package/dist/components/ButtonGroup/index.cjs +7 -0
- package/dist/components/ButtonGroup/index.js +2 -0
- package/dist/components/Card/Card.cjs +94 -0
- package/dist/components/Card/Card.js +91 -0
- package/dist/components/Card/index.cjs +9 -0
- package/dist/components/Card/index.js +1 -0
- package/dist/components/Chart/Chart.cjs +160 -0
- package/dist/components/Chart/Chart.js +153 -0
- package/dist/components/Chart/index.cjs +10 -0
- package/dist/components/Chart/index.js +2 -0
- package/dist/components/Chart/theme.cjs +67 -0
- package/dist/components/Chart/theme.js +62 -0
- package/dist/components/Chip/Chip.cjs +18 -0
- package/dist/components/Chip/Chip.js +15 -0
- package/dist/components/Chip/index.cjs +5 -0
- package/dist/components/Chip/index.js +1 -0
- package/dist/components/Counter/Counter.cjs +74 -0
- package/dist/components/Counter/Counter.js +71 -0
- package/dist/components/Counter/index.cjs +6 -0
- package/dist/components/Counter/index.js +1 -0
- package/dist/components/DatePicker/DatePicker.cjs +343 -0
- package/dist/components/DatePicker/DatePicker.js +340 -0
- package/dist/components/DatePicker/index.cjs +5 -0
- package/dist/components/DatePicker/index.js +1 -0
- package/dist/components/Divider/Divider.cjs +31 -0
- package/dist/components/Divider/Divider.js +28 -0
- package/dist/components/Divider/index.cjs +5 -0
- package/dist/components/Divider/index.js +1 -0
- package/dist/components/DropdownMenu/DropdownMenu.cjs +108 -0
- package/dist/components/DropdownMenu/DropdownMenu.js +105 -0
- package/dist/components/DropdownMenu/index.cjs +11 -0
- package/dist/components/DropdownMenu/index.js +1 -0
- package/dist/components/EmptyStateIllustration/EmptyStateIllustration.cjs +42 -0
- package/dist/components/EmptyStateIllustration/EmptyStateIllustration.js +39 -0
- package/dist/components/EmptyStateIllustration/illustrations.cjs +3322 -0
- package/dist/components/EmptyStateIllustration/illustrations.js +3319 -0
- package/dist/components/EmptyStateIllustration/index.cjs +7 -0
- package/dist/components/EmptyStateIllustration/index.js +2 -0
- package/dist/components/FileUpload/FileUpload.cjs +116 -0
- package/dist/components/FileUpload/FileUpload.js +113 -0
- package/dist/components/FileUpload/FileUploadDropZone.cjs +58 -0
- package/dist/components/FileUpload/FileUploadDropZone.js +55 -0
- package/dist/components/FileUpload/FileUploadIcons.cjs +55 -0
- package/dist/components/FileUpload/FileUploadIcons.js +50 -0
- package/dist/components/FileUpload/FileUploadItem.cjs +34 -0
- package/dist/components/FileUpload/FileUploadItem.js +31 -0
- package/dist/components/FileUpload/index.cjs +9 -0
- package/dist/components/FileUpload/index.js +3 -0
- package/dist/components/FormControl/Checkbox.cjs +27 -0
- package/dist/components/FormControl/Checkbox.js +24 -0
- package/dist/components/FormControl/Radio.cjs +15 -0
- package/dist/components/FormControl/Radio.js +12 -0
- package/dist/components/FormControl/Toggle.cjs +15 -0
- package/dist/components/FormControl/Toggle.js +12 -0
- package/dist/components/FormControl/index.cjs +9 -0
- package/dist/components/FormControl/index.js +3 -0
- package/dist/components/Icon/Icon.cjs +70 -0
- package/dist/components/Icon/Icon.js +34 -0
- package/dist/components/Icon/catalog.cjs +1672 -0
- package/dist/components/Icon/catalog.js +1669 -0
- package/dist/components/Icon/icons.cjs +5621 -0
- package/dist/components/Icon/icons.js +5610 -0
- package/dist/components/Icon/index.cjs +8 -0
- package/dist/components/Icon/index.js +2 -0
- package/dist/components/Input/Input.cjs +64 -0
- package/dist/components/Input/Input.js +61 -0
- package/dist/components/Input/index.cjs +5 -0
- package/dist/components/Input/index.js +1 -0
- package/dist/components/MetricsCard/MetricsCard.cjs +107 -0
- package/dist/components/MetricsCard/MetricsCard.js +104 -0
- package/dist/components/MetricsCard/index.cjs +5 -0
- package/dist/components/MetricsCard/index.js +1 -0
- package/dist/components/Modal/Modal.cjs +126 -0
- package/dist/components/Modal/Modal.js +123 -0
- package/dist/components/Modal/index.cjs +5 -0
- package/dist/components/Modal/index.js +1 -0
- package/dist/components/Pagination/Pagination.cjs +42 -0
- package/dist/components/Pagination/Pagination.js +39 -0
- package/dist/components/Pagination/index.cjs +5 -0
- package/dist/components/Pagination/index.js +1 -0
- package/dist/components/ProgressBar/ProgressBar.cjs +34 -0
- package/dist/components/ProgressBar/ProgressBar.js +31 -0
- package/dist/components/ProgressBar/index.cjs +5 -0
- package/dist/components/ProgressBar/index.js +1 -0
- package/dist/components/ProgressCircle/ProgressCircle.cjs +34 -0
- package/dist/components/ProgressCircle/ProgressCircle.js +31 -0
- package/dist/components/ProgressCircle/index.cjs +5 -0
- package/dist/components/ProgressCircle/index.js +1 -0
- package/dist/components/Select/Select.cjs +84 -0
- package/dist/components/Select/Select.js +80 -0
- package/dist/components/Select/SelectOption.cjs +26 -0
- package/dist/components/Select/SelectOption.js +23 -0
- package/dist/components/Select/index.cjs +7 -0
- package/dist/components/Select/index.js +2 -0
- package/dist/components/SidebarMenu/SidebarMenu.cjs +85 -0
- package/dist/components/SidebarMenu/SidebarMenu.js +81 -0
- package/dist/components/SidebarMenu/SidebarMenuItem.cjs +126 -0
- package/dist/components/SidebarMenu/SidebarMenuItem.js +122 -0
- package/dist/components/SidebarMenu/SidebarMenuSection.cjs +14 -0
- package/dist/components/SidebarMenu/SidebarMenuSection.js +11 -0
- package/dist/components/SidebarMenu/index.cjs +12 -0
- package/dist/components/SidebarMenu/index.js +4 -0
- package/dist/components/Slider/Slider.cjs +161 -0
- package/dist/components/Slider/Slider.js +158 -0
- package/dist/components/Slider/index.cjs +6 -0
- package/dist/components/Slider/index.js +1 -0
- package/dist/components/Spinner/Spinner.cjs +93 -0
- package/dist/components/Spinner/Spinner.js +90 -0
- package/dist/components/Spinner/index.cjs +5 -0
- package/dist/components/Spinner/index.js +1 -0
- package/dist/components/Stepper/Stepper.cjs +82 -0
- package/dist/components/Stepper/Stepper.js +79 -0
- package/dist/components/Stepper/index.cjs +7 -0
- package/dist/components/Stepper/index.js +1 -0
- package/dist/components/Table/Table.cjs +25 -0
- package/dist/components/Table/Table.js +22 -0
- package/dist/components/Table/index.cjs +10 -0
- package/dist/components/Table/index.js +1 -0
- package/dist/components/Table/useTableSelection.cjs +60 -0
- package/dist/components/Table/useTableSelection.js +57 -0
- package/dist/components/Tabs/Tab.cjs +70 -0
- package/dist/components/Tabs/Tab.js +67 -0
- package/dist/components/Tabs/Tabs.cjs +133 -0
- package/dist/components/Tabs/Tabs.js +129 -0
- package/dist/components/Tabs/index.cjs +7 -0
- package/dist/components/Tabs/index.js +2 -0
- package/dist/components/Tooltip/Tooltip.cjs +101 -0
- package/dist/components/Tooltip/Tooltip.js +98 -0
- package/dist/components/Tooltip/index.cjs +5 -0
- package/dist/components/Tooltip/index.js +1 -0
- package/dist/context/ThemeContext.cjs +97 -0
- package/dist/context/ThemeContext.js +92 -0
- package/dist/fonts/README.md +13 -0
- package/dist/fonts/hanken-grotesk-cyrillic-ext-italic.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-cyrillic-ext-normal.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-latin-ext-italic.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-latin-ext-normal.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-latin-italic.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-latin-normal.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-vietnamese-italic.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-vietnamese-normal.woff2 +0 -0
- package/dist/fonts/hankengrotesk-LICENSE.txt +94 -0
- package/dist/fonts/manrope-LICENSE.txt +93 -0
- package/dist/fonts/manrope-cyrillic-ext-normal.woff2 +0 -0
- package/dist/fonts/manrope-cyrillic-normal.woff2 +0 -0
- package/dist/fonts/manrope-greek-normal.woff2 +0 -0
- package/dist/fonts/manrope-latin-ext-normal.woff2 +0 -0
- package/dist/fonts/manrope-latin-normal.woff2 +0 -0
- package/dist/fonts/manrope-vietnamese-normal.woff2 +0 -0
- package/dist/fonts.css +148 -0
- package/dist/hooks/form/index.cjs +11 -0
- package/dist/hooks/form/index.js +3 -0
- package/dist/hooks/form/useRaydenFormControl.cjs +81 -0
- package/dist/hooks/form/useRaydenFormControl.js +76 -0
- package/dist/hooks/form/useRaydenInput.cjs +38 -0
- package/dist/hooks/form/useRaydenInput.js +35 -0
- package/dist/hooks/form/useRaydenSelect.cjs +45 -0
- package/dist/hooks/form/useRaydenSelect.js +42 -0
- package/dist/hooks/index.cjs +17 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useBodyScrollLock.cjs +24 -0
- package/dist/hooks/useBodyScrollLock.js +21 -0
- package/dist/hooks/useCollisionAwareSide.cjs +72 -0
- package/dist/hooks/useCollisionAwareSide.js +69 -0
- package/dist/hooks/useControllableValue.cjs +16 -0
- package/dist/hooks/useControllableValue.js +13 -0
- package/dist/hooks/useDismissableLayer.cjs +100 -0
- package/dist/hooks/useDismissableLayer.js +97 -0
- package/dist/hooks/usePopupList.cjs +101 -0
- package/dist/hooks/usePopupList.js +98 -0
- package/dist/icons-8yD7I5jO.d.cts +430 -0
- package/dist/icons-8yD7I5jO.d.ts +430 -0
- package/dist/icons.cjs +2111 -418
- package/dist/icons.d.cts +1256 -429
- package/dist/icons.d.ts +1256 -429
- package/dist/icons.js +2089 -1
- package/dist/index.cjs +128 -15034
- package/dist/index.d.cts +698 -661
- package/dist/index.d.ts +698 -661
- package/dist/index.js +43 -14950
- package/dist/motion/Collapse.cjs +28 -0
- package/dist/motion/Collapse.js +25 -0
- package/dist/motion/MotionProvider.cjs +43 -0
- package/dist/motion/MotionProvider.js +38 -0
- package/dist/motion/Pressable.cjs +46 -0
- package/dist/motion/Pressable.js +43 -0
- package/dist/motion/Reveal.cjs +19 -0
- package/dist/motion/Reveal.js +16 -0
- package/dist/motion/SharedLayout.cjs +46 -0
- package/dist/motion/SharedLayout.js +43 -0
- package/dist/motion/index.cjs +19 -0
- package/dist/motion/index.js +6 -0
- package/dist/motion/presence.cjs +58 -0
- package/dist/motion/presence.js +55 -0
- package/dist/motion/presets.cjs +88 -0
- package/dist/motion/presets.js +84 -0
- package/dist/motion.d.cts +51 -0
- package/dist/motion.d.ts +51 -0
- package/dist/preset.cjs +356 -195
- package/dist/preset.d.cts +111 -32
- package/dist/preset.d.ts +111 -32
- package/dist/preset.js +353 -187
- package/dist/presets-Ba5QndHg.d.cts +144 -0
- package/dist/presets-Ba5QndHg.d.ts +144 -0
- package/dist/styles.css +1 -1
- package/dist/utils/cn.cjs +38 -0
- package/dist/utils/cn.js +35 -0
- package/dist/utils/resolveIcon.cjs +18 -0
- package/dist/utils/resolveIcon.js +15 -0
- package/package.json +79 -21
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
import { resolveIcon } from "../../utils/resolveIcon.js";
|
|
5
|
+
import { useSelectContext } from "./Select.js";
|
|
6
|
+
export const SelectOption = forwardRef(({ value, icon, avatar, statusColor, description, disabled = false, children, className, onClick, ...rest }, ref) => {
|
|
7
|
+
const ctx = useSelectContext();
|
|
8
|
+
const isSelected = ctx.value === value;
|
|
9
|
+
const handleClick = (e) => {
|
|
10
|
+
if (disabled)
|
|
11
|
+
return;
|
|
12
|
+
onClick?.(e);
|
|
13
|
+
if (!e.defaultPrevented)
|
|
14
|
+
ctx.onSelect(value);
|
|
15
|
+
};
|
|
16
|
+
const resolvedIcon = resolveIcon(icon, "md");
|
|
17
|
+
// Determine leading element
|
|
18
|
+
const leading = avatar ? (_jsx("span", { className: "shrink-0 size-5", children: avatar })) : statusColor ? (_jsx("span", { className: "shrink-0 size-2 rounded-full border-[1.5px] border-white", style: { backgroundColor: statusColor } })) : resolvedIcon ? (_jsx("span", { className: cn("shrink-0 size-5", disabled && "opacity-50"), children: resolvedIcon })) : null;
|
|
19
|
+
return (_jsxs("button", { ref: ref, type: "button", role: "option", tabIndex: -1, "aria-selected": isSelected, disabled: disabled, onClick: handleClick, className: cn("flex w-full items-center px-4 py-2 text-left text-body-sm outline-none transition-colors", statusColor ? "gap-2" : "gap-3", disabled
|
|
20
|
+
? "bg-grey-100 text-grey-500 cursor-not-allowed"
|
|
21
|
+
: "text-grey-900 hover:bg-grey-50 focus:bg-grey-100 focus:font-medium", className), ...rest, children: [_jsxs("div", { className: cn("flex flex-1 items-center", statusColor ? "gap-2" : "gap-3"), children: [leading, _jsx("span", { className: "shrink-0", children: children }), description && _jsx("span", { className: "text-grey-500 truncate", children: description })] }), isSelected && !disabled && (_jsx("span", { className: "ml-2 shrink-0", children: _jsxs("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", className: "text-[#1671D9]", children: [_jsx("circle", { cx: "8", cy: "8", r: "8", fill: "currentColor" }), _jsx("path", { d: "M11.5 5.5L6.5 10.5L4.5 8.5", stroke: "white", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round" })] }) }))] }));
|
|
22
|
+
});
|
|
23
|
+
SelectOption.displayName = "SelectOption";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SelectOption = exports.Select = void 0;
|
|
4
|
+
var Select_1 = require("./Select.cjs");
|
|
5
|
+
Object.defineProperty(exports, "Select", { enumerable: true, get: function () { return Select_1.Select; } });
|
|
6
|
+
var SelectOption_1 = require("./SelectOption.cjs");
|
|
7
|
+
Object.defineProperty(exports, "SelectOption", { enumerable: true, get: function () { return SelectOption_1.SelectOption; } });
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SidebarMenu = exports.sidebarThemeStyles = void 0;
|
|
4
|
+
exports.useSidebarMenuContext = useSidebarMenuContext;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const cn_1 = require("../../utils/cn.cjs");
|
|
8
|
+
exports.sidebarThemeStyles = {
|
|
9
|
+
light: {
|
|
10
|
+
container: "bg-surface",
|
|
11
|
+
defaultText: "text-on-surface-body",
|
|
12
|
+
defaultIcon: "text-on-surface-muted",
|
|
13
|
+
selectedBg: "bg-primary-50",
|
|
14
|
+
selectedText: "text-on-surface",
|
|
15
|
+
selectedBorder: "border-l-2 border-primary-400",
|
|
16
|
+
selectedIcon: "text-on-surface",
|
|
17
|
+
hoverBg: "hover:bg-grey-50 dark:hover:bg-grey-100",
|
|
18
|
+
sectionTitle: "text-on-surface-muted",
|
|
19
|
+
divider: "border-grey-100",
|
|
20
|
+
badgeDefault: "bg-grey-100 text-grey-700",
|
|
21
|
+
badgeSelected: "bg-primary-50 text-action-primary-text",
|
|
22
|
+
},
|
|
23
|
+
blue: {
|
|
24
|
+
container: "bg-[#1671D9]",
|
|
25
|
+
defaultText: "text-white",
|
|
26
|
+
defaultIcon: "text-white/70",
|
|
27
|
+
selectedBg: "bg-[#0D5EBA]",
|
|
28
|
+
selectedText: "text-white",
|
|
29
|
+
selectedBorder: "",
|
|
30
|
+
selectedIcon: "text-white",
|
|
31
|
+
hoverBg: "hover:bg-[#0D5EBA]/50",
|
|
32
|
+
sectionTitle: "text-[#B6D8FF]",
|
|
33
|
+
divider: "border-[#80BBFF]",
|
|
34
|
+
badgeDefault: "bg-grey-100 text-grey-700",
|
|
35
|
+
badgeSelected: "bg-grey-100 text-grey-700",
|
|
36
|
+
},
|
|
37
|
+
"dark-blue": {
|
|
38
|
+
container: "bg-[#04326B]",
|
|
39
|
+
defaultText: "text-[#C6DDF7]",
|
|
40
|
+
defaultIcon: "text-[#C6DDF7]/70",
|
|
41
|
+
selectedBg: "bg-[#034592]",
|
|
42
|
+
selectedText: "text-white",
|
|
43
|
+
selectedBorder: "",
|
|
44
|
+
selectedIcon: "text-white",
|
|
45
|
+
hoverBg: "hover:bg-[#034592]/50",
|
|
46
|
+
sectionTitle: "text-[#E3EFFC]",
|
|
47
|
+
divider: "border-[#80BBFF]",
|
|
48
|
+
badgeDefault: "bg-grey-100 text-grey-700",
|
|
49
|
+
badgeSelected: "bg-grey-100 text-grey-700",
|
|
50
|
+
},
|
|
51
|
+
"dark-grey": {
|
|
52
|
+
container: "bg-[#101928]",
|
|
53
|
+
defaultText: "text-[#F0F2F5]",
|
|
54
|
+
defaultIcon: "text-[#F0F2F5]/70",
|
|
55
|
+
selectedBg: "bg-[#1D2739]",
|
|
56
|
+
selectedText: "text-white",
|
|
57
|
+
selectedBorder: "",
|
|
58
|
+
selectedIcon: "text-white",
|
|
59
|
+
hoverBg: "hover:bg-[#1D2739]/50",
|
|
60
|
+
sectionTitle: "text-[#98A2B3]",
|
|
61
|
+
divider: "border-[#344054]",
|
|
62
|
+
badgeDefault: "bg-grey-100 text-grey-700",
|
|
63
|
+
badgeSelected: "bg-grey-100 text-grey-700",
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
const SidebarMenuContext = (0, react_1.createContext)(null);
|
|
67
|
+
function useSidebarMenuContext() {
|
|
68
|
+
const ctx = (0, react_1.useContext)(SidebarMenuContext);
|
|
69
|
+
if (!ctx)
|
|
70
|
+
throw new Error("SidebarMenuItem / SidebarMenuSection must be used within SidebarMenu");
|
|
71
|
+
return ctx;
|
|
72
|
+
}
|
|
73
|
+
// ─── Component ────────────────────────────────────────────────────
|
|
74
|
+
exports.SidebarMenu = (0, react_1.forwardRef)(({ value, defaultValue = "", onValueChange, collapsed = false, theme = "light", children, className, ...rest }, ref) => {
|
|
75
|
+
const [internalValue, setInternalValue] = (0, react_1.useState)(defaultValue);
|
|
76
|
+
const activeValue = value ?? internalValue;
|
|
77
|
+
const onSelect = (0, react_1.useCallback)((val) => {
|
|
78
|
+
if (value === undefined)
|
|
79
|
+
setInternalValue(val);
|
|
80
|
+
onValueChange?.(val);
|
|
81
|
+
}, [value, onValueChange]);
|
|
82
|
+
const ts = exports.sidebarThemeStyles[theme];
|
|
83
|
+
return ((0, jsx_runtime_1.jsx)(SidebarMenuContext.Provider, { value: { activeValue, onSelect, collapsed, theme }, children: (0, jsx_runtime_1.jsx)("nav", { ref: ref, "aria-label": "Main navigation", className: (0, cn_1.cn)("flex flex-col gap-3 overflow-y-auto rounded-xl py-6", ts.container, collapsed ? "w-[82px] items-center px-3" : "w-[272px] px-4", className), ...rest, children: children }) }));
|
|
84
|
+
});
|
|
85
|
+
exports.SidebarMenu.displayName = "SidebarMenu";
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useCallback, useContext, useState, forwardRef, } from "react";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
export const sidebarThemeStyles = {
|
|
5
|
+
light: {
|
|
6
|
+
container: "bg-surface",
|
|
7
|
+
defaultText: "text-on-surface-body",
|
|
8
|
+
defaultIcon: "text-on-surface-muted",
|
|
9
|
+
selectedBg: "bg-primary-50",
|
|
10
|
+
selectedText: "text-on-surface",
|
|
11
|
+
selectedBorder: "border-l-2 border-primary-400",
|
|
12
|
+
selectedIcon: "text-on-surface",
|
|
13
|
+
hoverBg: "hover:bg-grey-50 dark:hover:bg-grey-100",
|
|
14
|
+
sectionTitle: "text-on-surface-muted",
|
|
15
|
+
divider: "border-grey-100",
|
|
16
|
+
badgeDefault: "bg-grey-100 text-grey-700",
|
|
17
|
+
badgeSelected: "bg-primary-50 text-action-primary-text",
|
|
18
|
+
},
|
|
19
|
+
blue: {
|
|
20
|
+
container: "bg-[#1671D9]",
|
|
21
|
+
defaultText: "text-white",
|
|
22
|
+
defaultIcon: "text-white/70",
|
|
23
|
+
selectedBg: "bg-[#0D5EBA]",
|
|
24
|
+
selectedText: "text-white",
|
|
25
|
+
selectedBorder: "",
|
|
26
|
+
selectedIcon: "text-white",
|
|
27
|
+
hoverBg: "hover:bg-[#0D5EBA]/50",
|
|
28
|
+
sectionTitle: "text-[#B6D8FF]",
|
|
29
|
+
divider: "border-[#80BBFF]",
|
|
30
|
+
badgeDefault: "bg-grey-100 text-grey-700",
|
|
31
|
+
badgeSelected: "bg-grey-100 text-grey-700",
|
|
32
|
+
},
|
|
33
|
+
"dark-blue": {
|
|
34
|
+
container: "bg-[#04326B]",
|
|
35
|
+
defaultText: "text-[#C6DDF7]",
|
|
36
|
+
defaultIcon: "text-[#C6DDF7]/70",
|
|
37
|
+
selectedBg: "bg-[#034592]",
|
|
38
|
+
selectedText: "text-white",
|
|
39
|
+
selectedBorder: "",
|
|
40
|
+
selectedIcon: "text-white",
|
|
41
|
+
hoverBg: "hover:bg-[#034592]/50",
|
|
42
|
+
sectionTitle: "text-[#E3EFFC]",
|
|
43
|
+
divider: "border-[#80BBFF]",
|
|
44
|
+
badgeDefault: "bg-grey-100 text-grey-700",
|
|
45
|
+
badgeSelected: "bg-grey-100 text-grey-700",
|
|
46
|
+
},
|
|
47
|
+
"dark-grey": {
|
|
48
|
+
container: "bg-[#101928]",
|
|
49
|
+
defaultText: "text-[#F0F2F5]",
|
|
50
|
+
defaultIcon: "text-[#F0F2F5]/70",
|
|
51
|
+
selectedBg: "bg-[#1D2739]",
|
|
52
|
+
selectedText: "text-white",
|
|
53
|
+
selectedBorder: "",
|
|
54
|
+
selectedIcon: "text-white",
|
|
55
|
+
hoverBg: "hover:bg-[#1D2739]/50",
|
|
56
|
+
sectionTitle: "text-[#98A2B3]",
|
|
57
|
+
divider: "border-[#344054]",
|
|
58
|
+
badgeDefault: "bg-grey-100 text-grey-700",
|
|
59
|
+
badgeSelected: "bg-grey-100 text-grey-700",
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
const SidebarMenuContext = createContext(null);
|
|
63
|
+
export function useSidebarMenuContext() {
|
|
64
|
+
const ctx = useContext(SidebarMenuContext);
|
|
65
|
+
if (!ctx)
|
|
66
|
+
throw new Error("SidebarMenuItem / SidebarMenuSection must be used within SidebarMenu");
|
|
67
|
+
return ctx;
|
|
68
|
+
}
|
|
69
|
+
// ─── Component ────────────────────────────────────────────────────
|
|
70
|
+
export const SidebarMenu = forwardRef(({ value, defaultValue = "", onValueChange, collapsed = false, theme = "light", children, className, ...rest }, ref) => {
|
|
71
|
+
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
72
|
+
const activeValue = value ?? internalValue;
|
|
73
|
+
const onSelect = useCallback((val) => {
|
|
74
|
+
if (value === undefined)
|
|
75
|
+
setInternalValue(val);
|
|
76
|
+
onValueChange?.(val);
|
|
77
|
+
}, [value, onValueChange]);
|
|
78
|
+
const ts = sidebarThemeStyles[theme];
|
|
79
|
+
return (_jsx(SidebarMenuContext.Provider, { value: { activeValue, onSelect, collapsed, theme }, children: _jsx("nav", { ref: ref, "aria-label": "Main navigation", className: cn("flex flex-col gap-3 overflow-y-auto rounded-xl py-6", ts.container, collapsed ? "w-[82px] items-center px-3" : "w-[272px] px-4", className), ...rest, children: children }) }));
|
|
80
|
+
});
|
|
81
|
+
SidebarMenu.displayName = "SidebarMenu";
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SidebarMenuItem = exports.SidebarMenuSubItem = void 0;
|
|
4
|
+
exports.SidebarMenuSub = SidebarMenuSub;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const react_dom_1 = require("react-dom");
|
|
8
|
+
const cn_1 = require("../../utils/cn.cjs");
|
|
9
|
+
const Icon_1 = require("../Icon/index.cjs");
|
|
10
|
+
const resolveIcon_1 = require("../../utils/resolveIcon.cjs");
|
|
11
|
+
const SidebarMenu_1 = require("./SidebarMenu.cjs");
|
|
12
|
+
function SidebarMenuSub({ children }) {
|
|
13
|
+
return (0, jsx_runtime_1.jsx)("div", { className: "flex flex-col gap-1", children: children });
|
|
14
|
+
}
|
|
15
|
+
SidebarMenuSub.displayName = "SidebarMenuSub";
|
|
16
|
+
exports.SidebarMenuSubItem = (0, react_1.forwardRef)(({ value, children, className, ...rest }, ref) => {
|
|
17
|
+
const { activeValue, onSelect, theme } = (0, SidebarMenu_1.useSidebarMenuContext)();
|
|
18
|
+
const isActive = activeValue === value;
|
|
19
|
+
const ts = SidebarMenu_1.sidebarThemeStyles[theme];
|
|
20
|
+
return ((0, jsx_runtime_1.jsx)("button", { ref: ref, type: "button", role: "menuitem", onClick: () => onSelect(value), className: (0, cn_1.cn)("flex w-full cursor-pointer items-center rounded py-3 pl-12 pr-4 text-left text-body-sm transition-colors", isActive
|
|
21
|
+
? (0, cn_1.cn)(ts.selectedBg, "font-medium", ts.selectedText)
|
|
22
|
+
: (0, cn_1.cn)(ts.defaultText, ts.hoverBg), className), ...rest, children: children }));
|
|
23
|
+
});
|
|
24
|
+
exports.SidebarMenuSubItem.displayName = "SidebarMenuSubItem";
|
|
25
|
+
exports.SidebarMenuItem = (0, react_1.forwardRef)(({ value, icon, badge, disabled = false, label, children, className, ...rest }, ref) => {
|
|
26
|
+
const { activeValue, onSelect, collapsed, theme } = (0, SidebarMenu_1.useSidebarMenuContext)();
|
|
27
|
+
const ts = SidebarMenu_1.sidebarThemeStyles[theme];
|
|
28
|
+
const isActive = activeValue === value;
|
|
29
|
+
// Detect if this item has a SidebarMenuSub child (expandable)
|
|
30
|
+
let labelContent = null;
|
|
31
|
+
let subMenuContent = null;
|
|
32
|
+
react_1.Children.forEach(children, (child) => {
|
|
33
|
+
if ((0, react_1.isValidElement)(child) && child.type === SidebarMenuSub) {
|
|
34
|
+
subMenuContent = child;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
labelContent = child;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const isExpandable = subMenuContent !== null;
|
|
41
|
+
const [open, setOpen] = (0, react_1.useState)(false);
|
|
42
|
+
// Check if any sub-item is active (to keep parent highlighted)
|
|
43
|
+
let hasActiveSub = false;
|
|
44
|
+
if (isExpandable && (0, react_1.isValidElement)(subMenuContent)) {
|
|
45
|
+
react_1.Children.forEach(subMenuContent.props.children, (child) => {
|
|
46
|
+
if ((0, react_1.isValidElement)(child) &&
|
|
47
|
+
child.props.value === activeValue) {
|
|
48
|
+
hasActiveSub = true;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
const highlighted = isActive || hasActiveSub;
|
|
53
|
+
const handleClick = () => {
|
|
54
|
+
if (disabled)
|
|
55
|
+
return;
|
|
56
|
+
if (isExpandable) {
|
|
57
|
+
setOpen((prev) => !prev);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
onSelect(value);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const resolvedIcon = (0, resolveIcon_1.resolveIcon)(icon, "md");
|
|
64
|
+
// The collapsed rail scrolls (overflow-y-auto), which also clips horizontally, so
|
|
65
|
+
// an absolutely positioned flyout is cut off. Render it in a portal anchored to the
|
|
66
|
+
// trigger instead, and close it on outside pointer or Escape.
|
|
67
|
+
const triggerRef = (0, react_1.useRef)(null);
|
|
68
|
+
const flyoutRef = (0, react_1.useRef)(null);
|
|
69
|
+
const [mounted, setMounted] = (0, react_1.useState)(false);
|
|
70
|
+
const [anchor, setAnchor] = (0, react_1.useState)(null);
|
|
71
|
+
(0, react_1.useEffect)(() => setMounted(true), []);
|
|
72
|
+
const place = (0, react_1.useCallback)(() => {
|
|
73
|
+
const rect = triggerRef.current?.getBoundingClientRect();
|
|
74
|
+
if (rect)
|
|
75
|
+
setAnchor({ top: rect.top, left: rect.right + 8 });
|
|
76
|
+
}, []);
|
|
77
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
78
|
+
if (!collapsed || !open || !isExpandable)
|
|
79
|
+
return;
|
|
80
|
+
place();
|
|
81
|
+
const onScroll = () => place();
|
|
82
|
+
window.addEventListener("scroll", onScroll, true);
|
|
83
|
+
window.addEventListener("resize", onScroll);
|
|
84
|
+
const onPointer = (event) => {
|
|
85
|
+
const target = event.target;
|
|
86
|
+
if (!triggerRef.current?.contains(target) && !flyoutRef.current?.contains(target))
|
|
87
|
+
setOpen(false);
|
|
88
|
+
};
|
|
89
|
+
const onKey = (event) => {
|
|
90
|
+
if (event.key !== "Escape")
|
|
91
|
+
return;
|
|
92
|
+
setOpen(false);
|
|
93
|
+
triggerRef.current?.focus();
|
|
94
|
+
};
|
|
95
|
+
document.addEventListener("pointerdown", onPointer);
|
|
96
|
+
document.addEventListener("keydown", onKey);
|
|
97
|
+
return () => {
|
|
98
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
99
|
+
window.removeEventListener("resize", onScroll);
|
|
100
|
+
document.removeEventListener("pointerdown", onPointer);
|
|
101
|
+
document.removeEventListener("keydown", onKey);
|
|
102
|
+
};
|
|
103
|
+
}, [collapsed, open, isExpandable, place]);
|
|
104
|
+
// A collapsed item shows only an icon, so it needs an explicit name: an
|
|
105
|
+
// element child such as <span>Home</span> cannot serve as one.
|
|
106
|
+
const compactName = label ?? (typeof labelContent === "string" ? labelContent : undefined);
|
|
107
|
+
// Collapsed mode: icon only, with nested destinations reachable via a flyout
|
|
108
|
+
// rather than being dropped entirely.
|
|
109
|
+
if (collapsed) {
|
|
110
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "relative", children: [(0, jsx_runtime_1.jsx)("button", { ref: (node) => {
|
|
111
|
+
triggerRef.current = node;
|
|
112
|
+
if (typeof ref === "function")
|
|
113
|
+
ref(node);
|
|
114
|
+
else if (ref)
|
|
115
|
+
ref.current = node;
|
|
116
|
+
}, type: "button", role: "menuitem", disabled: disabled, onClick: handleClick, "aria-label": compactName, "aria-expanded": isExpandable ? open : undefined, "aria-haspopup": isExpandable ? "menu" : undefined, className: (0, cn_1.cn)("flex size-11 cursor-pointer items-center justify-center rounded transition-colors", highlighted ? (0, cn_1.cn)(ts.selectedBg, ts.selectedIcon) : (0, cn_1.cn)(ts.defaultIcon, ts.hoverBg), disabled && "pointer-events-none opacity-50", className), ...rest, children: resolvedIcon }), isExpandable &&
|
|
117
|
+
open &&
|
|
118
|
+
mounted &&
|
|
119
|
+
anchor &&
|
|
120
|
+
(0, react_dom_1.createPortal)((0, jsx_runtime_1.jsxs)("div", { ref: flyoutRef, role: "menu", "aria-label": compactName, style: { top: anchor.top, left: anchor.left }, className: (0, cn_1.cn)("fixed z-50 min-w-[200px] rounded-lg p-2 shadow-soft-sm", "border border-black/10 dark:border-white/15", ts.container), children: [compactName && ((0, jsx_runtime_1.jsx)("p", { className: (0, cn_1.cn)("px-3 pb-1 text-body-xs font-medium", ts.defaultText), children: compactName })), subMenuContent] }), document.body)] }));
|
|
121
|
+
}
|
|
122
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("button", { ref: ref, type: "button", role: "menuitem", "aria-expanded": isExpandable ? open : undefined, "aria-haspopup": isExpandable ? "menu" : undefined, disabled: disabled, onClick: handleClick, className: (0, cn_1.cn)("flex w-full cursor-pointer items-center gap-1 rounded py-3 px-4 text-left text-body-sm transition-colors", highlighted
|
|
123
|
+
? (0, cn_1.cn)(ts.selectedBg, ts.selectedBorder, "font-medium", ts.selectedText)
|
|
124
|
+
: (0, cn_1.cn)(ts.defaultText, ts.hoverBg), disabled && "pointer-events-none opacity-50", className), ...rest, children: [resolvedIcon && ((0, jsx_runtime_1.jsx)("span", { className: (0, cn_1.cn)("shrink-0", highlighted ? ts.selectedIcon : ts.defaultIcon), children: resolvedIcon })), (0, jsx_runtime_1.jsx)("span", { className: "flex-1 truncate", children: labelContent }), badge != null && ((0, jsx_runtime_1.jsx)("span", { className: (0, cn_1.cn)("ml-auto shrink-0 rounded-[10px] px-2 text-body-xs font-medium", highlighted ? ts.badgeSelected : ts.badgeDefault), children: badge })), isExpandable && ((0, jsx_runtime_1.jsx)(Icon_1.Icon, { name: open ? "chevron-up" : "chevron-down", size: "sm", "aria-hidden": "true", className: (0, cn_1.cn)("ml-1 shrink-0 transition-transform", highlighted ? ts.selectedIcon : ts.defaultIcon) }))] }), isExpandable && open && (0, jsx_runtime_1.jsx)("div", { className: "mt-1", children: subMenuContent })] }));
|
|
125
|
+
});
|
|
126
|
+
exports.SidebarMenuItem.displayName = "SidebarMenuItem";
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useCallback, useEffect, useLayoutEffect, useRef, useState, Children, isValidElement, } from "react";
|
|
3
|
+
import { createPortal } from "react-dom";
|
|
4
|
+
import { cn } from "../../utils/cn.js";
|
|
5
|
+
import { Icon } from "../Icon/index.js";
|
|
6
|
+
import { resolveIcon } from "../../utils/resolveIcon.js";
|
|
7
|
+
import { useSidebarMenuContext, sidebarThemeStyles } from "./SidebarMenu.js";
|
|
8
|
+
export function SidebarMenuSub({ children }) {
|
|
9
|
+
return _jsx("div", { className: "flex flex-col gap-1", children: children });
|
|
10
|
+
}
|
|
11
|
+
SidebarMenuSub.displayName = "SidebarMenuSub";
|
|
12
|
+
export const SidebarMenuSubItem = forwardRef(({ value, children, className, ...rest }, ref) => {
|
|
13
|
+
const { activeValue, onSelect, theme } = useSidebarMenuContext();
|
|
14
|
+
const isActive = activeValue === value;
|
|
15
|
+
const ts = sidebarThemeStyles[theme];
|
|
16
|
+
return (_jsx("button", { ref: ref, type: "button", role: "menuitem", onClick: () => onSelect(value), className: cn("flex w-full cursor-pointer items-center rounded py-3 pl-12 pr-4 text-left text-body-sm transition-colors", isActive
|
|
17
|
+
? cn(ts.selectedBg, "font-medium", ts.selectedText)
|
|
18
|
+
: cn(ts.defaultText, ts.hoverBg), className), ...rest, children: children }));
|
|
19
|
+
});
|
|
20
|
+
SidebarMenuSubItem.displayName = "SidebarMenuSubItem";
|
|
21
|
+
export const SidebarMenuItem = forwardRef(({ value, icon, badge, disabled = false, label, children, className, ...rest }, ref) => {
|
|
22
|
+
const { activeValue, onSelect, collapsed, theme } = useSidebarMenuContext();
|
|
23
|
+
const ts = sidebarThemeStyles[theme];
|
|
24
|
+
const isActive = activeValue === value;
|
|
25
|
+
// Detect if this item has a SidebarMenuSub child (expandable)
|
|
26
|
+
let labelContent = null;
|
|
27
|
+
let subMenuContent = null;
|
|
28
|
+
Children.forEach(children, (child) => {
|
|
29
|
+
if (isValidElement(child) && child.type === SidebarMenuSub) {
|
|
30
|
+
subMenuContent = child;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
labelContent = child;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
const isExpandable = subMenuContent !== null;
|
|
37
|
+
const [open, setOpen] = useState(false);
|
|
38
|
+
// Check if any sub-item is active (to keep parent highlighted)
|
|
39
|
+
let hasActiveSub = false;
|
|
40
|
+
if (isExpandable && isValidElement(subMenuContent)) {
|
|
41
|
+
Children.forEach(subMenuContent.props.children, (child) => {
|
|
42
|
+
if (isValidElement(child) &&
|
|
43
|
+
child.props.value === activeValue) {
|
|
44
|
+
hasActiveSub = true;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
const highlighted = isActive || hasActiveSub;
|
|
49
|
+
const handleClick = () => {
|
|
50
|
+
if (disabled)
|
|
51
|
+
return;
|
|
52
|
+
if (isExpandable) {
|
|
53
|
+
setOpen((prev) => !prev);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
onSelect(value);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const resolvedIcon = resolveIcon(icon, "md");
|
|
60
|
+
// The collapsed rail scrolls (overflow-y-auto), which also clips horizontally, so
|
|
61
|
+
// an absolutely positioned flyout is cut off. Render it in a portal anchored to the
|
|
62
|
+
// trigger instead, and close it on outside pointer or Escape.
|
|
63
|
+
const triggerRef = useRef(null);
|
|
64
|
+
const flyoutRef = useRef(null);
|
|
65
|
+
const [mounted, setMounted] = useState(false);
|
|
66
|
+
const [anchor, setAnchor] = useState(null);
|
|
67
|
+
useEffect(() => setMounted(true), []);
|
|
68
|
+
const place = useCallback(() => {
|
|
69
|
+
const rect = triggerRef.current?.getBoundingClientRect();
|
|
70
|
+
if (rect)
|
|
71
|
+
setAnchor({ top: rect.top, left: rect.right + 8 });
|
|
72
|
+
}, []);
|
|
73
|
+
useLayoutEffect(() => {
|
|
74
|
+
if (!collapsed || !open || !isExpandable)
|
|
75
|
+
return;
|
|
76
|
+
place();
|
|
77
|
+
const onScroll = () => place();
|
|
78
|
+
window.addEventListener("scroll", onScroll, true);
|
|
79
|
+
window.addEventListener("resize", onScroll);
|
|
80
|
+
const onPointer = (event) => {
|
|
81
|
+
const target = event.target;
|
|
82
|
+
if (!triggerRef.current?.contains(target) && !flyoutRef.current?.contains(target))
|
|
83
|
+
setOpen(false);
|
|
84
|
+
};
|
|
85
|
+
const onKey = (event) => {
|
|
86
|
+
if (event.key !== "Escape")
|
|
87
|
+
return;
|
|
88
|
+
setOpen(false);
|
|
89
|
+
triggerRef.current?.focus();
|
|
90
|
+
};
|
|
91
|
+
document.addEventListener("pointerdown", onPointer);
|
|
92
|
+
document.addEventListener("keydown", onKey);
|
|
93
|
+
return () => {
|
|
94
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
95
|
+
window.removeEventListener("resize", onScroll);
|
|
96
|
+
document.removeEventListener("pointerdown", onPointer);
|
|
97
|
+
document.removeEventListener("keydown", onKey);
|
|
98
|
+
};
|
|
99
|
+
}, [collapsed, open, isExpandable, place]);
|
|
100
|
+
// A collapsed item shows only an icon, so it needs an explicit name: an
|
|
101
|
+
// element child such as <span>Home</span> cannot serve as one.
|
|
102
|
+
const compactName = label ?? (typeof labelContent === "string" ? labelContent : undefined);
|
|
103
|
+
// Collapsed mode: icon only, with nested destinations reachable via a flyout
|
|
104
|
+
// rather than being dropped entirely.
|
|
105
|
+
if (collapsed) {
|
|
106
|
+
return (_jsxs("div", { className: "relative", children: [_jsx("button", { ref: (node) => {
|
|
107
|
+
triggerRef.current = node;
|
|
108
|
+
if (typeof ref === "function")
|
|
109
|
+
ref(node);
|
|
110
|
+
else if (ref)
|
|
111
|
+
ref.current = node;
|
|
112
|
+
}, type: "button", role: "menuitem", disabled: disabled, onClick: handleClick, "aria-label": compactName, "aria-expanded": isExpandable ? open : undefined, "aria-haspopup": isExpandable ? "menu" : undefined, className: cn("flex size-11 cursor-pointer items-center justify-center rounded transition-colors", highlighted ? cn(ts.selectedBg, ts.selectedIcon) : cn(ts.defaultIcon, ts.hoverBg), disabled && "pointer-events-none opacity-50", className), ...rest, children: resolvedIcon }), isExpandable &&
|
|
113
|
+
open &&
|
|
114
|
+
mounted &&
|
|
115
|
+
anchor &&
|
|
116
|
+
createPortal(_jsxs("div", { ref: flyoutRef, role: "menu", "aria-label": compactName, style: { top: anchor.top, left: anchor.left }, className: cn("fixed z-50 min-w-[200px] rounded-lg p-2 shadow-soft-sm", "border border-black/10 dark:border-white/15", ts.container), children: [compactName && (_jsx("p", { className: cn("px-3 pb-1 text-body-xs font-medium", ts.defaultText), children: compactName })), subMenuContent] }), document.body)] }));
|
|
117
|
+
}
|
|
118
|
+
return (_jsxs("div", { children: [_jsxs("button", { ref: ref, type: "button", role: "menuitem", "aria-expanded": isExpandable ? open : undefined, "aria-haspopup": isExpandable ? "menu" : undefined, disabled: disabled, onClick: handleClick, className: cn("flex w-full cursor-pointer items-center gap-1 rounded py-3 px-4 text-left text-body-sm transition-colors", highlighted
|
|
119
|
+
? cn(ts.selectedBg, ts.selectedBorder, "font-medium", ts.selectedText)
|
|
120
|
+
: cn(ts.defaultText, ts.hoverBg), disabled && "pointer-events-none opacity-50", className), ...rest, children: [resolvedIcon && (_jsx("span", { className: cn("shrink-0", highlighted ? ts.selectedIcon : ts.defaultIcon), children: resolvedIcon })), _jsx("span", { className: "flex-1 truncate", children: labelContent }), badge != null && (_jsx("span", { className: cn("ml-auto shrink-0 rounded-[10px] px-2 text-body-xs font-medium", highlighted ? ts.badgeSelected : ts.badgeDefault), children: badge })), isExpandable && (_jsx(Icon, { name: open ? "chevron-up" : "chevron-down", size: "sm", "aria-hidden": "true", className: cn("ml-1 shrink-0 transition-transform", highlighted ? ts.selectedIcon : ts.defaultIcon) }))] }), isExpandable && open && _jsx("div", { className: "mt-1", children: subMenuContent })] }));
|
|
121
|
+
});
|
|
122
|
+
SidebarMenuItem.displayName = "SidebarMenuItem";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SidebarMenuSection = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const cn_1 = require("../../utils/cn.cjs");
|
|
7
|
+
const SidebarMenu_1 = require("./SidebarMenu.cjs");
|
|
8
|
+
// ─── Component ────────────────────────────────────────────────────
|
|
9
|
+
exports.SidebarMenuSection = (0, react_1.forwardRef)(({ title, showDivider = true, children, className, ...rest }, ref) => {
|
|
10
|
+
const { collapsed, theme } = (0, SidebarMenu_1.useSidebarMenuContext)();
|
|
11
|
+
const ts = SidebarMenu_1.sidebarThemeStyles[theme];
|
|
12
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: ref, className: (0, cn_1.cn)("flex flex-col", className), ...rest, children: [title && !collapsed && ((0, jsx_runtime_1.jsx)("span", { className: (0, cn_1.cn)("mb-2 px-4 text-body-xs font-medium uppercase tracking-wider", ts.sectionTitle), children: title })), (0, jsx_runtime_1.jsx)("div", { className: "flex flex-col gap-1", role: "menu", children: children }), showDivider && (0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("mt-3 border-b", ts.divider) })] }));
|
|
13
|
+
});
|
|
14
|
+
exports.SidebarMenuSection.displayName = "SidebarMenuSection";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
import { useSidebarMenuContext, sidebarThemeStyles } from "./SidebarMenu.js";
|
|
5
|
+
// ─── Component ────────────────────────────────────────────────────
|
|
6
|
+
export const SidebarMenuSection = forwardRef(({ title, showDivider = true, children, className, ...rest }, ref) => {
|
|
7
|
+
const { collapsed, theme } = useSidebarMenuContext();
|
|
8
|
+
const ts = sidebarThemeStyles[theme];
|
|
9
|
+
return (_jsxs("div", { ref: ref, className: cn("flex flex-col", className), ...rest, children: [title && !collapsed && (_jsx("span", { className: cn("mb-2 px-4 text-body-xs font-medium uppercase tracking-wider", ts.sectionTitle), children: title })), _jsx("div", { className: "flex flex-col gap-1", role: "menu", children: children }), showDivider && _jsx("div", { className: cn("mt-3 border-b", ts.divider) })] }));
|
|
10
|
+
});
|
|
11
|
+
SidebarMenuSection.displayName = "SidebarMenuSection";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SidebarMenuSection = exports.SidebarMenuSubItem = exports.SidebarMenuSub = exports.SidebarMenuItem = exports.SidebarMenu = void 0;
|
|
4
|
+
var SidebarMenu_1 = require("./SidebarMenu.cjs");
|
|
5
|
+
Object.defineProperty(exports, "SidebarMenu", { enumerable: true, get: function () { return SidebarMenu_1.SidebarMenu; } });
|
|
6
|
+
var SidebarMenuItem_1 = require("./SidebarMenuItem.cjs");
|
|
7
|
+
Object.defineProperty(exports, "SidebarMenuItem", { enumerable: true, get: function () { return SidebarMenuItem_1.SidebarMenuItem; } });
|
|
8
|
+
var SidebarMenuItem_2 = require("./SidebarMenuItem.cjs");
|
|
9
|
+
Object.defineProperty(exports, "SidebarMenuSub", { enumerable: true, get: function () { return SidebarMenuItem_2.SidebarMenuSub; } });
|
|
10
|
+
Object.defineProperty(exports, "SidebarMenuSubItem", { enumerable: true, get: function () { return SidebarMenuItem_2.SidebarMenuSubItem; } });
|
|
11
|
+
var SidebarMenuSection_1 = require("./SidebarMenuSection.cjs");
|
|
12
|
+
Object.defineProperty(exports, "SidebarMenuSection", { enumerable: true, get: function () { return SidebarMenuSection_1.SidebarMenuSection; } });
|