@hyunsdev/ui 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.
- package/LICENSE +674 -0
- package/README.md +89 -0
- package/SKILL.md +38 -0
- package/dist/WindowContext-DybYtZJa.d.ts +50 -0
- package/dist/_styles-BbTx89aX.d.ts +3 -0
- package/dist/chunk-23KUNTRD.js +49 -0
- package/dist/chunk-23KUNTRD.js.map +1 -0
- package/dist/chunk-3RTSANKB.js +51 -0
- package/dist/chunk-3RTSANKB.js.map +1 -0
- package/dist/chunk-4QIWBOF4.js +129 -0
- package/dist/chunk-4QIWBOF4.js.map +1 -0
- package/dist/chunk-5JCWC7IU.js +293 -0
- package/dist/chunk-5JCWC7IU.js.map +1 -0
- package/dist/chunk-6ANDNGHD.js +33 -0
- package/dist/chunk-6ANDNGHD.js.map +1 -0
- package/dist/chunk-7W7QZHEZ.js +42 -0
- package/dist/chunk-7W7QZHEZ.js.map +1 -0
- package/dist/chunk-BHO4WT2N.js +51 -0
- package/dist/chunk-BHO4WT2N.js.map +1 -0
- package/dist/chunk-BI3KKBIC.js +11 -0
- package/dist/chunk-BI3KKBIC.js.map +1 -0
- package/dist/chunk-D3SP7GL3.js +55 -0
- package/dist/chunk-D3SP7GL3.js.map +1 -0
- package/dist/chunk-D7W4RSQX.js +115 -0
- package/dist/chunk-D7W4RSQX.js.map +1 -0
- package/dist/chunk-DN2AEEA2.js +11 -0
- package/dist/chunk-DN2AEEA2.js.map +1 -0
- package/dist/chunk-ETTKFCO6.js +84 -0
- package/dist/chunk-ETTKFCO6.js.map +1 -0
- package/dist/chunk-GJT7TDBS.js +66 -0
- package/dist/chunk-GJT7TDBS.js.map +1 -0
- package/dist/chunk-HZT6RQYZ.js +109 -0
- package/dist/chunk-HZT6RQYZ.js.map +1 -0
- package/dist/chunk-JB2QZV7K.js +60 -0
- package/dist/chunk-JB2QZV7K.js.map +1 -0
- package/dist/chunk-KJJB2PVC.js +21 -0
- package/dist/chunk-KJJB2PVC.js.map +1 -0
- package/dist/chunk-NE3IVPMO.js +31 -0
- package/dist/chunk-NE3IVPMO.js.map +1 -0
- package/dist/chunk-O2BG2KSY.js +23 -0
- package/dist/chunk-O2BG2KSY.js.map +1 -0
- package/dist/chunk-OUFGNJ3V.js +1726 -0
- package/dist/chunk-OUFGNJ3V.js.map +1 -0
- package/dist/chunk-PLZMCJSL.js +351 -0
- package/dist/chunk-PLZMCJSL.js.map +1 -0
- package/dist/chunk-POG5DZBT.js +104 -0
- package/dist/chunk-POG5DZBT.js.map +1 -0
- package/dist/chunk-SECZM6JE.js +170 -0
- package/dist/chunk-SECZM6JE.js.map +1 -0
- package/dist/chunk-T64WPXSC.js +48 -0
- package/dist/chunk-T64WPXSC.js.map +1 -0
- package/dist/chunk-TU5CYBB4.js +90 -0
- package/dist/chunk-TU5CYBB4.js.map +1 -0
- package/dist/chunk-UVAI2U6X.js +153 -0
- package/dist/chunk-UVAI2U6X.js.map +1 -0
- package/dist/chunk-UXCBLYG6.js +142 -0
- package/dist/chunk-UXCBLYG6.js.map +1 -0
- package/dist/chunk-VUR4MQMH.js +53 -0
- package/dist/chunk-VUR4MQMH.js.map +1 -0
- package/dist/chunk-WIEKNG4S.js +26 -0
- package/dist/chunk-WIEKNG4S.js.map +1 -0
- package/dist/chunk-WIZ4OLOB.js +23 -0
- package/dist/chunk-WIZ4OLOB.js.map +1 -0
- package/dist/chunk-WJRJBMFN.js +21 -0
- package/dist/chunk-WJRJBMFN.js.map +1 -0
- package/dist/chunk-YUPLJP3F.js +33 -0
- package/dist/chunk-YUPLJP3F.js.map +1 -0
- package/dist/chunk-Z7ITPSUF.js +184 -0
- package/dist/chunk-Z7ITPSUF.js.map +1 -0
- package/dist/chunk-ZC76ALSI.js +75 -0
- package/dist/chunk-ZC76ALSI.js.map +1 -0
- package/dist/code-block-core-xkE94Rk5.d.ts +30 -0
- package/dist/components/accordion.d.ts +9 -0
- package/dist/components/accordion.js +98 -0
- package/dist/components/accordion.js.map +1 -0
- package/dist/components/alert-dialog.d.ts +26 -0
- package/dist/components/alert-dialog.js +341 -0
- package/dist/components/alert-dialog.js.map +1 -0
- package/dist/components/alert.d.ts +13 -0
- package/dist/components/alert.js +76 -0
- package/dist/components/alert.js.map +1 -0
- package/dist/components/aspect-ratio.d.ts +6 -0
- package/dist/components/aspect-ratio.js +12 -0
- package/dist/components/aspect-ratio.js.map +1 -0
- package/dist/components/avatar.d.ts +13 -0
- package/dist/components/avatar.js +19 -0
- package/dist/components/avatar.js.map +1 -0
- package/dist/components/badge.d.ts +12 -0
- package/dist/components/badge.js +11 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/breadcrumb.d.ts +13 -0
- package/dist/components/breadcrumb.js +102 -0
- package/dist/components/breadcrumb.js.map +1 -0
- package/dist/components/button-group.d.ts +16 -0
- package/dist/components/button-group.js +15 -0
- package/dist/components/button-group.js.map +1 -0
- package/dist/components/button.d.ts +14 -0
- package/dist/components/button.js +11 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/calendar.d.ts +14 -0
- package/dist/components/calendar.js +13 -0
- package/dist/components/calendar.js.map +1 -0
- package/dist/components/card.d.ts +13 -0
- package/dist/components/card.js +21 -0
- package/dist/components/card.js.map +1 -0
- package/dist/components/carousel.d.ts +32 -0
- package/dist/components/carousel.js +196 -0
- package/dist/components/carousel.js.map +1 -0
- package/dist/components/chart.d.ts +46 -0
- package/dist/components/chart.js +254 -0
- package/dist/components/chart.js.map +1 -0
- package/dist/components/checkbox.d.ts +6 -0
- package/dist/components/checkbox.js +41 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/code-block-core.d.ts +3 -0
- package/dist/components/code-block-core.js +13 -0
- package/dist/components/code-block-core.js.map +1 -0
- package/dist/components/code-block-custom.d.ts +20 -0
- package/dist/components/code-block-custom.js +16 -0
- package/dist/components/code-block-custom.js.map +1 -0
- package/dist/components/code-block-shiki.d.ts +13 -0
- package/dist/components/code-block-shiki.js +15 -0
- package/dist/components/code-block-shiki.js.map +1 -0
- package/dist/components/code-block.d.ts +5 -0
- package/dist/components/code-block.js +14 -0
- package/dist/components/code-block.js.map +1 -0
- package/dist/components/collapsible.d.ts +8 -0
- package/dist/components/collapsible.js +24 -0
- package/dist/components/collapsible.js.map +1 -0
- package/dist/components/collection.d.ts +63 -0
- package/dist/components/collection.js +598 -0
- package/dist/components/collection.js.map +1 -0
- package/dist/components/color-dot.d.ts +19 -0
- package/dist/components/color-dot.js +41 -0
- package/dist/components/color-dot.js.map +1 -0
- package/dist/components/color-picker.d.ts +12 -0
- package/dist/components/color-picker.js +142 -0
- package/dist/components/color-picker.js.map +1 -0
- package/dist/components/combobox.d.ts +74 -0
- package/dist/components/combobox.js +610 -0
- package/dist/components/combobox.js.map +1 -0
- package/dist/components/command.d.ts +21 -0
- package/dist/components/command.js +31 -0
- package/dist/components/command.js.map +1 -0
- package/dist/components/date-picker.d.ts +43 -0
- package/dist/components/date-picker.js +235 -0
- package/dist/components/date-picker.js.map +1 -0
- package/dist/components/dialog.d.ts +25 -0
- package/dist/components/dialog.js +31 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/drawer.d.ts +15 -0
- package/dist/components/drawer.js +124 -0
- package/dist/components/drawer.js.map +1 -0
- package/dist/components/dropdown-menu.d.ts +34 -0
- package/dist/components/dropdown-menu.js +248 -0
- package/dist/components/dropdown-menu.js.map +1 -0
- package/dist/components/empty.d.ts +15 -0
- package/dist/components/empty.js +104 -0
- package/dist/components/empty.js.map +1 -0
- package/dist/components/field.d.ts +29 -0
- package/dist/components/field.js +214 -0
- package/dist/components/field.js.map +1 -0
- package/dist/components/format-bytes.d.ts +12 -0
- package/dist/components/format-bytes.js +30 -0
- package/dist/components/format-bytes.js.map +1 -0
- package/dist/components/format-number.d.ts +12 -0
- package/dist/components/format-number.js +30 -0
- package/dist/components/format-number.js.map +1 -0
- package/dist/components/gauge.d.ts +11 -0
- package/dist/components/gauge.js +82 -0
- package/dist/components/gauge.js.map +1 -0
- package/dist/components/hover-card.d.ts +8 -0
- package/dist/components/hover-card.js +45 -0
- package/dist/components/hover-card.js.map +1 -0
- package/dist/components/input-group.d.ts +24 -0
- package/dist/components/input-group.js +23 -0
- package/dist/components/input-group.js.map +1 -0
- package/dist/components/input-otp.d.ts +20 -0
- package/dist/components/input-otp.js +95 -0
- package/dist/components/input-otp.js.map +1 -0
- package/dist/components/input.d.ts +9 -0
- package/dist/components/input.js +9 -0
- package/dist/components/input.js.map +1 -0
- package/dist/components/item.d.ts +27 -0
- package/dist/components/item.js +182 -0
- package/dist/components/item.js.map +1 -0
- package/dist/components/kbd.d.ts +6 -0
- package/dist/components/kbd.js +34 -0
- package/dist/components/kbd.js.map +1 -0
- package/dist/components/label.d.ts +6 -0
- package/dist/components/label.js +9 -0
- package/dist/components/label.js.map +1 -0
- package/dist/components/loading-bar.d.ts +8 -0
- package/dist/components/loading-bar.js +127 -0
- package/dist/components/loading-bar.js.map +1 -0
- package/dist/components/loading-dots.d.ts +5 -0
- package/dist/components/loading-dots.js +45 -0
- package/dist/components/loading-dots.js.map +1 -0
- package/dist/components/main-provider.d.ts +7 -0
- package/dist/components/main-provider.js +12 -0
- package/dist/components/main-provider.js.map +1 -0
- package/dist/components/mark.d.ts +11 -0
- package/dist/components/mark.js +44 -0
- package/dist/components/mark.js.map +1 -0
- package/dist/components/pagination.d.ts +21 -0
- package/dist/components/pagination.js +114 -0
- package/dist/components/pagination.js.map +1 -0
- package/dist/components/popover.d.ts +12 -0
- package/dist/components/popover.js +22 -0
- package/dist/components/popover.js.map +1 -0
- package/dist/components/prev-next-navigation.d.ts +15 -0
- package/dist/components/prev-next-navigation.js +85 -0
- package/dist/components/prev-next-navigation.js.map +1 -0
- package/dist/components/progress.d.ts +6 -0
- package/dist/components/progress.js +38 -0
- package/dist/components/progress.js.map +1 -0
- package/dist/components/radio-group.d.ts +7 -0
- package/dist/components/radio-group.js +57 -0
- package/dist/components/radio-group.js.map +1 -0
- package/dist/components/relative-time.d.ts +16 -0
- package/dist/components/relative-time.js +75 -0
- package/dist/components/relative-time.js.map +1 -0
- package/dist/components/resizable.d.ts +10 -0
- package/dist/components/resizable.js +45 -0
- package/dist/components/resizable.js.map +1 -0
- package/dist/components/scroll-area.d.ts +7 -0
- package/dist/components/scroll-area.js +11 -0
- package/dist/components/scroll-area.js.map +1 -0
- package/dist/components/select.d.ts +20 -0
- package/dist/components/select.js +189 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/separator.d.ts +6 -0
- package/dist/components/separator.js +9 -0
- package/dist/components/separator.js.map +1 -0
- package/dist/components/sheet.d.ts +16 -0
- package/dist/components/sheet.js +25 -0
- package/dist/components/sheet.js.map +1 -0
- package/dist/components/show-more.d.ts +15 -0
- package/dist/components/show-more.js +79 -0
- package/dist/components/show-more.js.map +1 -0
- package/dist/components/skeleton.d.ts +5 -0
- package/dist/components/skeleton.js +8 -0
- package/dist/components/skeleton.js.map +1 -0
- package/dist/components/slider.d.ts +6 -0
- package/dist/components/slider.js +65 -0
- package/dist/components/slider.js.map +1 -0
- package/dist/components/snippet.d.ts +13 -0
- package/dist/components/snippet.js +135 -0
- package/dist/components/snippet.js.map +1 -0
- package/dist/components/sonner.d.ts +6 -0
- package/dist/components/sonner.js +10 -0
- package/dist/components/sonner.js.map +1 -0
- package/dist/components/spinner.d.ts +5 -0
- package/dist/components/spinner.js +8 -0
- package/dist/components/spinner.js.map +1 -0
- package/dist/components/stat.d.ts +17 -0
- package/dist/components/stat.js +71 -0
- package/dist/components/stat.js.map +1 -0
- package/dist/components/steps.d.ts +17 -0
- package/dist/components/steps.js +133 -0
- package/dist/components/steps.js.map +1 -0
- package/dist/components/switch.d.ts +8 -0
- package/dist/components/switch.js +44 -0
- package/dist/components/switch.js.map +1 -0
- package/dist/components/table.d.ts +12 -0
- package/dist/components/table.js +101 -0
- package/dist/components/table.js.map +1 -0
- package/dist/components/tabs.d.ts +14 -0
- package/dist/components/tabs.js +88 -0
- package/dist/components/tabs.js.map +1 -0
- package/dist/components/textarea.d.ts +5 -0
- package/dist/components/textarea.js +9 -0
- package/dist/components/textarea.js.map +1 -0
- package/dist/components/theme-provider.d.ts +10 -0
- package/dist/components/theme-provider.js +14 -0
- package/dist/components/theme-provider.js.map +1 -0
- package/dist/components/time-picker.d.ts +17 -0
- package/dist/components/time-picker.js +219 -0
- package/dist/components/time-picker.js.map +1 -0
- package/dist/components/timeline.d.ts +17 -0
- package/dist/components/timeline.js +138 -0
- package/dist/components/timeline.js.map +1 -0
- package/dist/components/toggle-group.d.ts +14 -0
- package/dist/components/toggle-group.js +82 -0
- package/dist/components/toggle-group.js.map +1 -0
- package/dist/components/toggle.d.ts +12 -0
- package/dist/components/toggle.js +11 -0
- package/dist/components/toggle.js.map +1 -0
- package/dist/components/tooltip.d.ts +9 -0
- package/dist/components/tooltip.js +15 -0
- package/dist/components/tooltip.js.map +1 -0
- package/dist/components/typography.d.ts +17 -0
- package/dist/components/typography.js +91 -0
- package/dist/components/typography.js.map +1 -0
- package/dist/hooks/use-mobile.d.ts +3 -0
- package/dist/hooks/use-mobile.js +7 -0
- package/dist/hooks/use-mobile.js.map +1 -0
- package/dist/hooks/use-theme.d.ts +3 -0
- package/dist/hooks/use-theme.js +8 -0
- package/dist/hooks/use-theme.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/layouts/center/index.d.ts +18 -0
- package/dist/layouts/center/index.js +73 -0
- package/dist/layouts/center/index.js.map +1 -0
- package/dist/layouts/chat/index.d.ts +42 -0
- package/dist/layouts/chat/index.js +191 -0
- package/dist/layouts/chat/index.js.map +1 -0
- package/dist/layouts/command/index.d.ts +2 -0
- package/dist/layouts/command/index.js +1 -0
- package/dist/layouts/command/index.js.map +1 -0
- package/dist/layouts/panel/index.d.ts +55 -0
- package/dist/layouts/panel/index.js +513 -0
- package/dist/layouts/panel/index.js.map +1 -0
- package/dist/layouts/presentation/index.d.ts +14 -0
- package/dist/layouts/presentation/index.js +100 -0
- package/dist/layouts/presentation/index.js.map +1 -0
- package/dist/layouts/site/index.d.ts +17 -0
- package/dist/layouts/site/index.js +82 -0
- package/dist/layouts/site/index.js.map +1 -0
- package/dist/layouts/window/index.d.ts +223 -0
- package/dist/layouts/window/index.js +127 -0
- package/dist/layouts/window/index.js.map +1 -0
- package/dist/layouts/workbench/index.d.ts +281 -0
- package/dist/layouts/workbench/index.js +2457 -0
- package/dist/layouts/workbench/index.js.map +1 -0
- package/dist/lib/format.d.ts +15 -0
- package/dist/lib/format.js +9 -0
- package/dist/lib/format.js.map +1 -0
- package/dist/lib/theme.d.ts +22 -0
- package/dist/lib/theme.js +25 -0
- package/dist/lib/theme.js.map +1 -0
- package/dist/lib/utils.d.ts +5 -0
- package/dist/lib/utils.js +7 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/styles/fonts.css +1 -0
- package/dist/styles/globals.css +717 -0
- package/dist/styles/tokens.css +693 -0
- package/package.json +137 -0
|
@@ -0,0 +1,2457 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sidedockFocusClass,
|
|
3
|
+
sidedockOutlineStrokeClass,
|
|
4
|
+
sidedockShellClass
|
|
5
|
+
} from "../../chunk-BI3KKBIC.js";
|
|
6
|
+
import {
|
|
7
|
+
useIsMobile
|
|
8
|
+
} from "../../chunk-WJRJBMFN.js";
|
|
9
|
+
import {
|
|
10
|
+
Skeleton
|
|
11
|
+
} from "../../chunk-KJJB2PVC.js";
|
|
12
|
+
import {
|
|
13
|
+
Sheet,
|
|
14
|
+
SheetContent,
|
|
15
|
+
SheetDescription,
|
|
16
|
+
SheetHeader,
|
|
17
|
+
SheetTitle
|
|
18
|
+
} from "../../chunk-4QIWBOF4.js";
|
|
19
|
+
import {
|
|
20
|
+
Separator
|
|
21
|
+
} from "../../chunk-6ANDNGHD.js";
|
|
22
|
+
import {
|
|
23
|
+
Tooltip,
|
|
24
|
+
TooltipContent,
|
|
25
|
+
TooltipTrigger
|
|
26
|
+
} from "../../chunk-D3SP7GL3.js";
|
|
27
|
+
import "../../chunk-TU5CYBB4.js";
|
|
28
|
+
import "../../chunk-O2BG2KSY.js";
|
|
29
|
+
import {
|
|
30
|
+
cn
|
|
31
|
+
} from "../../chunk-DN2AEEA2.js";
|
|
32
|
+
|
|
33
|
+
// src/layouts/workbench/core/components/WorkbenchRibbonBar.tsx
|
|
34
|
+
import * as React2 from "react";
|
|
35
|
+
import * as Slot from "@radix-ui/react-slot";
|
|
36
|
+
import { cva } from "class-variance-authority";
|
|
37
|
+
|
|
38
|
+
// src/layouts/workbench/core/contexts/WorkbenchPrimarySidebarContext.tsx
|
|
39
|
+
import React from "react";
|
|
40
|
+
|
|
41
|
+
// src/layouts/workbench/core/workbench.const.tsx
|
|
42
|
+
var WORKBENCH_PRIMARY_SIDEBAR_COOKIE_NAME = "workbench_primary_sidebar_state";
|
|
43
|
+
var WORKBENCH_SECONDARY_SIDEBAR_COOKIE_NAME = "workbench_secondary_sidebar_state";
|
|
44
|
+
var WORKBENCH_SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
|
45
|
+
var WORKBENCH_SIDEBAR_MIN_WIDTH = "250px";
|
|
46
|
+
var WORKBENCH_SIDEBAR_DEFAULT_WIDTH = "270px";
|
|
47
|
+
var WORKBENCH_SIDEBAR_MAX_WIDTH = "400px";
|
|
48
|
+
var WORKBENCH_SIDEBAR_WIDTH_MOBILE = "400px";
|
|
49
|
+
|
|
50
|
+
// src/layouts/workbench/core/contexts/WorkbenchPrimarySidebarContext.tsx
|
|
51
|
+
import { jsx } from "react/jsx-runtime";
|
|
52
|
+
var WorkbenchPrimarySidebarContext = React.createContext(null);
|
|
53
|
+
function WorkbenchPrimarySidebarProvider({
|
|
54
|
+
defaultOpen = true,
|
|
55
|
+
open: openProp,
|
|
56
|
+
onOpenChange: setOpenProp,
|
|
57
|
+
className,
|
|
58
|
+
style,
|
|
59
|
+
children,
|
|
60
|
+
...props
|
|
61
|
+
}) {
|
|
62
|
+
const isMobile = useIsMobile();
|
|
63
|
+
const [openMobile, setOpenMobile] = React.useState(false);
|
|
64
|
+
const [_open, _setOpen] = React.useState(defaultOpen);
|
|
65
|
+
const open = openProp ?? _open;
|
|
66
|
+
const setOpen = React.useCallback(
|
|
67
|
+
(value) => {
|
|
68
|
+
const nextOpen = typeof value === "function" ? value(open) : value;
|
|
69
|
+
if (setOpenProp) {
|
|
70
|
+
setOpenProp(nextOpen);
|
|
71
|
+
} else {
|
|
72
|
+
_setOpen(nextOpen);
|
|
73
|
+
}
|
|
74
|
+
document.cookie = `${WORKBENCH_PRIMARY_SIDEBAR_COOKIE_NAME}=${nextOpen}; path=/; max-age=${WORKBENCH_SIDEBAR_COOKIE_MAX_AGE}`;
|
|
75
|
+
},
|
|
76
|
+
[open, setOpenProp]
|
|
77
|
+
);
|
|
78
|
+
const toggleSidebar = React.useCallback(() => {
|
|
79
|
+
if (isMobile) {
|
|
80
|
+
setOpenMobile((currentOpen) => !currentOpen);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
setOpen((currentOpen) => !currentOpen);
|
|
84
|
+
}, [isMobile, setOpen]);
|
|
85
|
+
const state = open ? "expanded" : "collapsed";
|
|
86
|
+
const contextValue = React.useMemo(
|
|
87
|
+
() => ({
|
|
88
|
+
state,
|
|
89
|
+
open,
|
|
90
|
+
setOpen,
|
|
91
|
+
openMobile,
|
|
92
|
+
setOpenMobile,
|
|
93
|
+
isMobile,
|
|
94
|
+
toggleSidebar
|
|
95
|
+
}),
|
|
96
|
+
[state, open, setOpen, openMobile, isMobile, toggleSidebar]
|
|
97
|
+
);
|
|
98
|
+
return /* @__PURE__ */ jsx(WorkbenchPrimarySidebarContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
|
|
99
|
+
"div",
|
|
100
|
+
{
|
|
101
|
+
"data-slot": "sidebar-wrapper",
|
|
102
|
+
style,
|
|
103
|
+
className: cn(
|
|
104
|
+
"group/sidebar-wrapper has-data-[variant=inset]:bg-sidedock-background flex min-h-svh w-full",
|
|
105
|
+
className
|
|
106
|
+
),
|
|
107
|
+
...props,
|
|
108
|
+
children
|
|
109
|
+
}
|
|
110
|
+
) });
|
|
111
|
+
}
|
|
112
|
+
function useWorkbenchPrimarySidebar() {
|
|
113
|
+
const context = React.useContext(WorkbenchPrimarySidebarContext);
|
|
114
|
+
if (!context) {
|
|
115
|
+
throw new Error(
|
|
116
|
+
"useWorkbenchPrimarySidebar must be used within a WorkbenchPrimarySidebarProvider"
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
return context;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// src/layouts/workbench/core/components/WorkbenchRibbonBar.tsx
|
|
123
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
124
|
+
var WORKBENCH_RIBBON_BAR_WIDTH = "52px";
|
|
125
|
+
var ribbonBarButtonVariants = cva(
|
|
126
|
+
cn(
|
|
127
|
+
"text-sidedock-text hover:bg-sidedock-hover-background hover:text-sidedock-text-hover active:bg-sidedock-active-background active:text-sidedock-text-active data-active:bg-sidedock-active-background data-active:text-sidedock-text-active inline-flex shrink-0 cursor-pointer items-center justify-center rounded-md border border-transparent outline-hidden transition-colors disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
128
|
+
sidedockFocusClass
|
|
129
|
+
),
|
|
130
|
+
{
|
|
131
|
+
variants: {
|
|
132
|
+
size: {
|
|
133
|
+
default: "size-9 [&_svg:not([class*=size-])]:size-5",
|
|
134
|
+
sm: "size-8 [&_svg:not([class*=size-])]:size-4"
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
defaultVariants: {
|
|
138
|
+
size: "default"
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
function WorkbenchRibbonBar({ className, ...props }) {
|
|
143
|
+
const primarySidebar = React2.useContext(WorkbenchPrimarySidebarContext);
|
|
144
|
+
return /* @__PURE__ */ jsx2(
|
|
145
|
+
"aside",
|
|
146
|
+
{
|
|
147
|
+
"data-slot": "workbench-ribbon-bar",
|
|
148
|
+
"data-primary-sidebar-state": primarySidebar?.state,
|
|
149
|
+
className: cn(
|
|
150
|
+
"bg-sidedock-background text-sidedock-text border-sidedock-border relative z-[calc(var(--layer-sidebar)+1)] flex h-svh w-(--workbench-ribbon-bar-width) shrink-0 flex-col items-center border-r data-[primary-sidebar-state=collapsed]:border-r-transparent",
|
|
151
|
+
className
|
|
152
|
+
),
|
|
153
|
+
...props
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
function WorkbenchRibbonBarHeader({ className, ...props }) {
|
|
158
|
+
return /* @__PURE__ */ jsx2(
|
|
159
|
+
"div",
|
|
160
|
+
{
|
|
161
|
+
"data-slot": "workbench-ribbon-bar-header",
|
|
162
|
+
className: cn("flex w-full shrink-0 flex-col items-center gap-1 p-2", className),
|
|
163
|
+
...props
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
function WorkbenchRibbonBarContent({ className, ...props }) {
|
|
168
|
+
return /* @__PURE__ */ jsx2(
|
|
169
|
+
"div",
|
|
170
|
+
{
|
|
171
|
+
"data-slot": "workbench-ribbon-bar-content",
|
|
172
|
+
className: cn(
|
|
173
|
+
"no-scrollbar flex min-h-0 w-full flex-1 flex-col items-center gap-1 overflow-y-auto p-2",
|
|
174
|
+
className
|
|
175
|
+
),
|
|
176
|
+
...props
|
|
177
|
+
}
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
function WorkbenchRibbonBarFooter({ className, ...props }) {
|
|
181
|
+
return /* @__PURE__ */ jsx2(
|
|
182
|
+
"div",
|
|
183
|
+
{
|
|
184
|
+
"data-slot": "workbench-ribbon-bar-footer",
|
|
185
|
+
className: cn("flex w-full shrink-0 flex-col items-center gap-1 p-2", className),
|
|
186
|
+
...props
|
|
187
|
+
}
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
function WorkbenchRibbonBarSeparator({ className, ...props }) {
|
|
191
|
+
return /* @__PURE__ */ jsx2(
|
|
192
|
+
"div",
|
|
193
|
+
{
|
|
194
|
+
role: "separator",
|
|
195
|
+
"data-slot": "workbench-ribbon-bar-separator",
|
|
196
|
+
className: cn("bg-sidedock-border my-1 h-px w-8 shrink-0", className),
|
|
197
|
+
...props
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
function WorkbenchRibbonBarButton({
|
|
202
|
+
asChild = false,
|
|
203
|
+
isActive = false,
|
|
204
|
+
size = "default",
|
|
205
|
+
tooltip,
|
|
206
|
+
className,
|
|
207
|
+
type = "button",
|
|
208
|
+
"aria-label": ariaLabel,
|
|
209
|
+
...props
|
|
210
|
+
}) {
|
|
211
|
+
const Comp = asChild ? Slot.Root : "button";
|
|
212
|
+
const tooltipProps = typeof tooltip === "string" ? { children: tooltip } : tooltip;
|
|
213
|
+
const label = ariaLabel ?? (typeof tooltip === "string" ? tooltip : void 0);
|
|
214
|
+
const button = /* @__PURE__ */ jsx2(
|
|
215
|
+
Comp,
|
|
216
|
+
{
|
|
217
|
+
"data-slot": "workbench-ribbon-bar-button",
|
|
218
|
+
"data-active": isActive || void 0,
|
|
219
|
+
"aria-label": label,
|
|
220
|
+
type: asChild ? void 0 : type,
|
|
221
|
+
className: cn(ribbonBarButtonVariants({ size }), className),
|
|
222
|
+
...props
|
|
223
|
+
}
|
|
224
|
+
);
|
|
225
|
+
if (!tooltipProps) {
|
|
226
|
+
return button;
|
|
227
|
+
}
|
|
228
|
+
return /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
229
|
+
/* @__PURE__ */ jsx2(TooltipTrigger, { asChild: true, children: button }),
|
|
230
|
+
/* @__PURE__ */ jsx2(TooltipContent, { side: "right", align: "center", ...tooltipProps })
|
|
231
|
+
] });
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// src/layouts/workbench/core/components/Workbench.tsx
|
|
235
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
236
|
+
function Workbench({ className, style, ...props }) {
|
|
237
|
+
const workbenchStyle = {
|
|
238
|
+
"--workbench-ribbon-bar-width": WORKBENCH_RIBBON_BAR_WIDTH,
|
|
239
|
+
...style
|
|
240
|
+
};
|
|
241
|
+
return /* @__PURE__ */ jsx3(
|
|
242
|
+
"div",
|
|
243
|
+
{
|
|
244
|
+
"data-slot": "workbench",
|
|
245
|
+
style: workbenchStyle,
|
|
246
|
+
className: cn(
|
|
247
|
+
"bg-workbench-background flex min-h-svh w-full has-data-[slot=workbench-ribbon-bar]:[--workbench-ribbon-bar-offset:var(--workbench-ribbon-bar-width)]",
|
|
248
|
+
className
|
|
249
|
+
),
|
|
250
|
+
...props
|
|
251
|
+
}
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// src/layouts/workbench/core/contexts/WorkbenchSecondarySidebarContext.tsx
|
|
256
|
+
import React3 from "react";
|
|
257
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
258
|
+
var WorkbenchSecondarySidebarContext = React3.createContext(null);
|
|
259
|
+
function WorkbenchSecondarySidebarProvider({
|
|
260
|
+
defaultOpen = true,
|
|
261
|
+
open: openProp,
|
|
262
|
+
onOpenChange: setOpenProp,
|
|
263
|
+
className,
|
|
264
|
+
style,
|
|
265
|
+
children,
|
|
266
|
+
...props
|
|
267
|
+
}) {
|
|
268
|
+
const isMobile = useIsMobile();
|
|
269
|
+
const [openMobile, setOpenMobile] = React3.useState(false);
|
|
270
|
+
const [_open, _setOpen] = React3.useState(defaultOpen);
|
|
271
|
+
const open = openProp ?? _open;
|
|
272
|
+
const setOpen = React3.useCallback(
|
|
273
|
+
(value) => {
|
|
274
|
+
const nextOpen = typeof value === "function" ? value(open) : value;
|
|
275
|
+
if (setOpenProp) {
|
|
276
|
+
setOpenProp(nextOpen);
|
|
277
|
+
} else {
|
|
278
|
+
_setOpen(nextOpen);
|
|
279
|
+
}
|
|
280
|
+
document.cookie = `${WORKBENCH_SECONDARY_SIDEBAR_COOKIE_NAME}=${nextOpen}; path=/; max-age=${WORKBENCH_SIDEBAR_COOKIE_MAX_AGE}`;
|
|
281
|
+
},
|
|
282
|
+
[open, setOpenProp]
|
|
283
|
+
);
|
|
284
|
+
const toggleSidebar = React3.useCallback(() => {
|
|
285
|
+
if (isMobile) {
|
|
286
|
+
setOpenMobile((currentOpen) => !currentOpen);
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
setOpen((currentOpen) => !currentOpen);
|
|
290
|
+
}, [isMobile, setOpen]);
|
|
291
|
+
const state = open ? "expanded" : "collapsed";
|
|
292
|
+
const contextValue = React3.useMemo(
|
|
293
|
+
() => ({
|
|
294
|
+
state,
|
|
295
|
+
open,
|
|
296
|
+
setOpen,
|
|
297
|
+
openMobile,
|
|
298
|
+
setOpenMobile,
|
|
299
|
+
isMobile,
|
|
300
|
+
toggleSidebar
|
|
301
|
+
}),
|
|
302
|
+
[state, open, setOpen, openMobile, isMobile, toggleSidebar]
|
|
303
|
+
);
|
|
304
|
+
return /* @__PURE__ */ jsx4(WorkbenchSecondarySidebarContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx4(
|
|
305
|
+
"div",
|
|
306
|
+
{
|
|
307
|
+
"data-slot": "sidebar-secondary-wrapper",
|
|
308
|
+
style,
|
|
309
|
+
className: cn("contents", className),
|
|
310
|
+
...props,
|
|
311
|
+
children
|
|
312
|
+
}
|
|
313
|
+
) });
|
|
314
|
+
}
|
|
315
|
+
function useWorkbenchSecondarySidebar() {
|
|
316
|
+
const context = React3.useContext(WorkbenchSecondarySidebarContext);
|
|
317
|
+
if (!context) {
|
|
318
|
+
throw new Error(
|
|
319
|
+
"useWorkbenchSecondarySidebar must be used within a WorkbenchSecondarySidebarProvider"
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
return context;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// src/layouts/workbench/core/components/WorkbenchProvider.tsx
|
|
326
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
327
|
+
function WorkbenchProvider({ children }) {
|
|
328
|
+
return /* @__PURE__ */ jsx5(WorkbenchPrimarySidebarProvider, { children: /* @__PURE__ */ jsx5(WorkbenchSecondarySidebarProvider, { children }) });
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// src/layouts/workbench/core/components/panel/WorkbenchContentArea.tsx
|
|
332
|
+
import * as React4 from "react";
|
|
333
|
+
import * as ResizablePrimitive from "react-resizable-panels";
|
|
334
|
+
import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
335
|
+
var WORKBENCH_CONTEXT_AREA_PANEL_MIN_SIZE = "220px";
|
|
336
|
+
var WORKBENCH_CONTEXT_AREA_RESIZE_TARGET_MINIMUM_SIZE = {
|
|
337
|
+
coarse: 36,
|
|
338
|
+
fine: 12
|
|
339
|
+
};
|
|
340
|
+
function getPanelKey(child, index) {
|
|
341
|
+
return React4.isValidElement(child) && child.key != null ? child.key : index;
|
|
342
|
+
}
|
|
343
|
+
function WorkbenchContentArea({
|
|
344
|
+
className,
|
|
345
|
+
children,
|
|
346
|
+
orientation = "horizontal",
|
|
347
|
+
...props
|
|
348
|
+
}) {
|
|
349
|
+
const panels = React4.Children.toArray(children);
|
|
350
|
+
const hasResizablePanels = panels.length > 1;
|
|
351
|
+
return /* @__PURE__ */ jsx6(
|
|
352
|
+
"main",
|
|
353
|
+
{
|
|
354
|
+
"data-slot": "sidebar-inset",
|
|
355
|
+
className: cn(
|
|
356
|
+
"relative z-[calc(var(--layer-sidebar)+1)] flex min-h-dvh min-w-0 flex-1 gap-1 rounded-lg md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",
|
|
357
|
+
className
|
|
358
|
+
),
|
|
359
|
+
...props,
|
|
360
|
+
children: hasResizablePanels ? /* @__PURE__ */ jsx6(WorkbenchPanelGroup, { orientation, children: panels }) : children
|
|
361
|
+
}
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
function WorkbenchPanelGroup({
|
|
365
|
+
className,
|
|
366
|
+
children,
|
|
367
|
+
orientation = "horizontal",
|
|
368
|
+
style,
|
|
369
|
+
...props
|
|
370
|
+
}) {
|
|
371
|
+
const panels = React4.Children.toArray(children);
|
|
372
|
+
return /* @__PURE__ */ jsx6(
|
|
373
|
+
ResizablePrimitive.Group,
|
|
374
|
+
{
|
|
375
|
+
...props,
|
|
376
|
+
"data-slot": "workbench-panel-group",
|
|
377
|
+
orientation,
|
|
378
|
+
resizeTargetMinimumSize: WORKBENCH_CONTEXT_AREA_RESIZE_TARGET_MINIMUM_SIZE,
|
|
379
|
+
style: { overflow: "visible", ...style },
|
|
380
|
+
className: cn(
|
|
381
|
+
"relative z-[calc(var(--layer-sidebar)+1)] flex h-full min-h-0 w-full min-w-0 flex-1 aria-[orientation=vertical]:flex-col",
|
|
382
|
+
className
|
|
383
|
+
),
|
|
384
|
+
children: panels.map((panel, index) => /* @__PURE__ */ jsxs2(React4.Fragment, { children: [
|
|
385
|
+
index > 0 && /* @__PURE__ */ jsx6(WorkbenchContextAreaRail, {}),
|
|
386
|
+
/* @__PURE__ */ jsx6(
|
|
387
|
+
ResizablePrimitive.Panel,
|
|
388
|
+
{
|
|
389
|
+
"data-slot": "workbench-context-area-panel",
|
|
390
|
+
defaultSize: `${100 / panels.length}%`,
|
|
391
|
+
minSize: WORKBENCH_CONTEXT_AREA_PANEL_MIN_SIZE,
|
|
392
|
+
style: { overflow: "visible" },
|
|
393
|
+
className: "relative min-h-0 min-w-0",
|
|
394
|
+
children: panel
|
|
395
|
+
}
|
|
396
|
+
)
|
|
397
|
+
] }, getPanelKey(panel, index)))
|
|
398
|
+
}
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
function WorkbenchContextAreaRail({
|
|
402
|
+
className,
|
|
403
|
+
"aria-label": ariaLabel = "Resize workbench panels",
|
|
404
|
+
...props
|
|
405
|
+
}) {
|
|
406
|
+
return /* @__PURE__ */ jsx6(
|
|
407
|
+
ResizablePrimitive.Separator,
|
|
408
|
+
{
|
|
409
|
+
...props,
|
|
410
|
+
"data-slot": "workbench-context-area-rail",
|
|
411
|
+
"aria-label": ariaLabel,
|
|
412
|
+
className: cn(
|
|
413
|
+
"hover:after:bg-sidedock-border focus-visible:ring-focus-ring relative isolate z-[calc(var(--layer-popover)+1)] flex w-1 cursor-col-resize touch-none items-stretch justify-center bg-transparent outline-hidden transition-colors after:absolute after:inset-y-0 after:left-1/2 after:w-px after:-translate-x-1/2 after:bg-transparent after:transition-colors focus-visible:ring-1",
|
|
414
|
+
"aria-[orientation=horizontal]:h-1 aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:cursor-row-resize aria-[orientation=horizontal]:items-center aria-[orientation=horizontal]:after:inset-x-0 aria-[orientation=horizontal]:after:inset-y-auto aria-[orientation=horizontal]:after:top-1/2 aria-[orientation=horizontal]:after:h-px aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2",
|
|
415
|
+
className
|
|
416
|
+
)
|
|
417
|
+
}
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// src/layouts/workbench/core/components/sidebar/WorkbenchSidebar.tsx
|
|
422
|
+
import * as React5 from "react";
|
|
423
|
+
import * as Slot2 from "@radix-ui/react-slot";
|
|
424
|
+
import { cva as cva2 } from "class-variance-authority";
|
|
425
|
+
import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
426
|
+
var WORKBENCH_SIDEBAR_RESIZE_STEP = 16;
|
|
427
|
+
var WORKBENCH_SIDEBAR_DRAG_THRESHOLD = 3;
|
|
428
|
+
var WorkbenchSidebarVisualContext = React5.createContext(null);
|
|
429
|
+
function useWorkbenchSidebarVisualContext() {
|
|
430
|
+
const context = React5.useContext(WorkbenchSidebarVisualContext);
|
|
431
|
+
if (!context) {
|
|
432
|
+
throw new Error("Workbench sidebar components must be used within a sidebar shell.");
|
|
433
|
+
}
|
|
434
|
+
return context;
|
|
435
|
+
}
|
|
436
|
+
function toPixelWidth(width) {
|
|
437
|
+
const parsedWidth = Number.parseInt(width, 10);
|
|
438
|
+
return Number.isNaN(parsedWidth) ? 0 : parsedWidth;
|
|
439
|
+
}
|
|
440
|
+
var WORKBENCH_SIDEBAR_MIN_WIDTH_PX = toPixelWidth(WORKBENCH_SIDEBAR_MIN_WIDTH);
|
|
441
|
+
var WORKBENCH_SIDEBAR_DEFAULT_WIDTH_PX = toPixelWidth(WORKBENCH_SIDEBAR_DEFAULT_WIDTH);
|
|
442
|
+
var WORKBENCH_SIDEBAR_MAX_WIDTH_PX = toPixelWidth(WORKBENCH_SIDEBAR_MAX_WIDTH);
|
|
443
|
+
function clampWorkbenchSidebarWidth(width) {
|
|
444
|
+
return Math.min(WORKBENCH_SIDEBAR_MAX_WIDTH_PX, Math.max(WORKBENCH_SIDEBAR_MIN_WIDTH_PX, width));
|
|
445
|
+
}
|
|
446
|
+
function SidebarRail({
|
|
447
|
+
className,
|
|
448
|
+
currentWidth,
|
|
449
|
+
label,
|
|
450
|
+
onClick,
|
|
451
|
+
onKeyDown,
|
|
452
|
+
onPointerDown,
|
|
453
|
+
side,
|
|
454
|
+
state,
|
|
455
|
+
...props
|
|
456
|
+
}) {
|
|
457
|
+
const isCollapsed = state === "collapsed";
|
|
458
|
+
const railCursorClass = isCollapsed ? side === "left" ? "cursor-e-resize" : "cursor-w-resize" : side === "left" ? "cursor-w-resize" : "cursor-e-resize";
|
|
459
|
+
const railStyle = React5.useMemo(() => {
|
|
460
|
+
const left = side === "left" ? isCollapsed ? "var(--workbench-ribbon-bar-offset, 0px)" : `calc(var(--workbench-ribbon-bar-offset, 0px) + ${currentWidth}px - 2px)` : isCollapsed ? "100vw" : `calc(100vw - ${currentWidth}px)`;
|
|
461
|
+
return { left };
|
|
462
|
+
}, [currentWidth, isCollapsed, side]);
|
|
463
|
+
return /* @__PURE__ */ jsx7(
|
|
464
|
+
"button",
|
|
465
|
+
{
|
|
466
|
+
type: "button",
|
|
467
|
+
"data-sidebar": "rail",
|
|
468
|
+
"data-slot": "sidebar-rail",
|
|
469
|
+
"aria-label": label,
|
|
470
|
+
"aria-orientation": "vertical",
|
|
471
|
+
"aria-valuemax": WORKBENCH_SIDEBAR_MAX_WIDTH_PX,
|
|
472
|
+
"aria-valuemin": WORKBENCH_SIDEBAR_MIN_WIDTH_PX,
|
|
473
|
+
"aria-valuenow": currentWidth,
|
|
474
|
+
tabIndex: 0,
|
|
475
|
+
onClick,
|
|
476
|
+
onKeyDown,
|
|
477
|
+
onPointerDown,
|
|
478
|
+
title: label,
|
|
479
|
+
style: railStyle,
|
|
480
|
+
className: cn(
|
|
481
|
+
"hover:after:bg-sidedock-border fixed top-[var(--radius-panel)] bottom-[var(--radius-panel)] z-(--layer-popover) hidden w-4 touch-none transition-[background] ease-linear after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2",
|
|
482
|
+
railCursorClass,
|
|
483
|
+
isCollapsed && "hover:bg-sidedock-background",
|
|
484
|
+
className
|
|
485
|
+
),
|
|
486
|
+
...props
|
|
487
|
+
}
|
|
488
|
+
);
|
|
489
|
+
}
|
|
490
|
+
function WorkbenchSidebarShell({
|
|
491
|
+
className,
|
|
492
|
+
children,
|
|
493
|
+
description,
|
|
494
|
+
dir,
|
|
495
|
+
isMobile,
|
|
496
|
+
openMobile,
|
|
497
|
+
setOpenMobile,
|
|
498
|
+
side,
|
|
499
|
+
state,
|
|
500
|
+
style,
|
|
501
|
+
title,
|
|
502
|
+
toggleSidebar,
|
|
503
|
+
...props
|
|
504
|
+
}) {
|
|
505
|
+
const [sidebarWidth, setSidebarWidth] = React5.useState(
|
|
506
|
+
() => clampWorkbenchSidebarWidth(WORKBENCH_SIDEBAR_DEFAULT_WIDTH_PX)
|
|
507
|
+
);
|
|
508
|
+
const [isResizing, setIsResizing] = React5.useState(false);
|
|
509
|
+
const dragStateRef = React5.useRef({
|
|
510
|
+
pointerId: null,
|
|
511
|
+
startX: 0,
|
|
512
|
+
startWidth: WORKBENCH_SIDEBAR_DEFAULT_WIDTH_PX
|
|
513
|
+
});
|
|
514
|
+
const didDragRef = React5.useRef(false);
|
|
515
|
+
const handleRailPointerDown = React5.useCallback(
|
|
516
|
+
(event) => {
|
|
517
|
+
if (event.button !== 0) {
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
event.preventDefault();
|
|
521
|
+
setIsResizing(true);
|
|
522
|
+
didDragRef.current = false;
|
|
523
|
+
dragStateRef.current = {
|
|
524
|
+
pointerId: event.pointerId,
|
|
525
|
+
startX: event.clientX,
|
|
526
|
+
startWidth: sidebarWidth
|
|
527
|
+
};
|
|
528
|
+
const handlePointerMove = (pointerEvent) => {
|
|
529
|
+
if (pointerEvent.pointerId !== dragStateRef.current.pointerId) {
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
const deltaX = pointerEvent.clientX - dragStateRef.current.startX;
|
|
533
|
+
const signedDeltaX = side === "right" ? -deltaX : deltaX;
|
|
534
|
+
if (Math.abs(signedDeltaX) >= WORKBENCH_SIDEBAR_DRAG_THRESHOLD) {
|
|
535
|
+
didDragRef.current = true;
|
|
536
|
+
}
|
|
537
|
+
setSidebarWidth(clampWorkbenchSidebarWidth(dragStateRef.current.startWidth + signedDeltaX));
|
|
538
|
+
};
|
|
539
|
+
const handlePointerEnd = (pointerEvent) => {
|
|
540
|
+
if (pointerEvent.pointerId !== dragStateRef.current.pointerId) {
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
dragStateRef.current.pointerId = null;
|
|
544
|
+
setIsResizing(false);
|
|
545
|
+
document.body.style.userSelect = "";
|
|
546
|
+
document.body.style.cursor = "";
|
|
547
|
+
window.removeEventListener("pointermove", handlePointerMove);
|
|
548
|
+
window.removeEventListener("pointerup", handlePointerEnd);
|
|
549
|
+
window.removeEventListener("pointercancel", handlePointerEnd);
|
|
550
|
+
};
|
|
551
|
+
document.body.style.userSelect = "none";
|
|
552
|
+
document.body.style.cursor = "ew-resize";
|
|
553
|
+
window.addEventListener("pointermove", handlePointerMove);
|
|
554
|
+
window.addEventListener("pointerup", handlePointerEnd);
|
|
555
|
+
window.addEventListener("pointercancel", handlePointerEnd);
|
|
556
|
+
},
|
|
557
|
+
[side, sidebarWidth]
|
|
558
|
+
);
|
|
559
|
+
const handleRailClick = React5.useCallback(
|
|
560
|
+
(event) => {
|
|
561
|
+
if (didDragRef.current) {
|
|
562
|
+
didDragRef.current = false;
|
|
563
|
+
event.preventDefault();
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
toggleSidebar();
|
|
567
|
+
},
|
|
568
|
+
[toggleSidebar]
|
|
569
|
+
);
|
|
570
|
+
const handleRailKeyDown = React5.useCallback(
|
|
571
|
+
(event) => {
|
|
572
|
+
switch (event.key) {
|
|
573
|
+
case "ArrowLeft":
|
|
574
|
+
event.preventDefault();
|
|
575
|
+
setSidebarWidth(
|
|
576
|
+
(currentWidth) => clampWorkbenchSidebarWidth(
|
|
577
|
+
currentWidth + (side === "right" ? WORKBENCH_SIDEBAR_RESIZE_STEP : -WORKBENCH_SIDEBAR_RESIZE_STEP)
|
|
578
|
+
)
|
|
579
|
+
);
|
|
580
|
+
return;
|
|
581
|
+
case "ArrowRight":
|
|
582
|
+
event.preventDefault();
|
|
583
|
+
setSidebarWidth(
|
|
584
|
+
(currentWidth) => clampWorkbenchSidebarWidth(
|
|
585
|
+
currentWidth + (side === "right" ? -WORKBENCH_SIDEBAR_RESIZE_STEP : WORKBENCH_SIDEBAR_RESIZE_STEP)
|
|
586
|
+
)
|
|
587
|
+
);
|
|
588
|
+
return;
|
|
589
|
+
case "Home":
|
|
590
|
+
event.preventDefault();
|
|
591
|
+
setSidebarWidth(WORKBENCH_SIDEBAR_MIN_WIDTH_PX);
|
|
592
|
+
return;
|
|
593
|
+
case "End":
|
|
594
|
+
event.preventDefault();
|
|
595
|
+
setSidebarWidth(WORKBENCH_SIDEBAR_MAX_WIDTH_PX);
|
|
596
|
+
return;
|
|
597
|
+
default:
|
|
598
|
+
}
|
|
599
|
+
},
|
|
600
|
+
[side]
|
|
601
|
+
);
|
|
602
|
+
const desktopSidebarStyle = React5.useMemo(
|
|
603
|
+
() => ({
|
|
604
|
+
...style,
|
|
605
|
+
"--sidebar-width": `${sidebarWidth}px`
|
|
606
|
+
}),
|
|
607
|
+
[sidebarWidth, style]
|
|
608
|
+
);
|
|
609
|
+
const contextValue = React5.useMemo(
|
|
610
|
+
() => ({
|
|
611
|
+
isMobile,
|
|
612
|
+
side,
|
|
613
|
+
state
|
|
614
|
+
}),
|
|
615
|
+
[isMobile, side, state]
|
|
616
|
+
);
|
|
617
|
+
const mobileSidebarStyle = {
|
|
618
|
+
"--sidebar-width": WORKBENCH_SIDEBAR_WIDTH_MOBILE
|
|
619
|
+
};
|
|
620
|
+
if (isMobile) {
|
|
621
|
+
return /* @__PURE__ */ jsx7(WorkbenchSidebarVisualContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx7(Sheet, { open: openMobile, onOpenChange: setOpenMobile, ...props, children: /* @__PURE__ */ jsxs3(
|
|
622
|
+
SheetContent,
|
|
623
|
+
{
|
|
624
|
+
dir,
|
|
625
|
+
"data-sidebar": "sidebar",
|
|
626
|
+
"data-slot": "sidebar",
|
|
627
|
+
"data-mobile": "true",
|
|
628
|
+
className: cn(sidedockShellClass, "w-(--sidebar-width) p-0 [&>button]:hidden"),
|
|
629
|
+
style: mobileSidebarStyle,
|
|
630
|
+
side,
|
|
631
|
+
children: [
|
|
632
|
+
/* @__PURE__ */ jsxs3(SheetHeader, { className: "sr-only", children: [
|
|
633
|
+
/* @__PURE__ */ jsx7(SheetTitle, { children: title }),
|
|
634
|
+
/* @__PURE__ */ jsx7(SheetDescription, { children: description })
|
|
635
|
+
] }),
|
|
636
|
+
/* @__PURE__ */ jsx7("div", { className: "flex h-full w-full flex-col", children })
|
|
637
|
+
]
|
|
638
|
+
}
|
|
639
|
+
) }) });
|
|
640
|
+
}
|
|
641
|
+
return /* @__PURE__ */ jsx7(WorkbenchSidebarVisualContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxs3(
|
|
642
|
+
"div",
|
|
643
|
+
{
|
|
644
|
+
className: "group peer text-sidedock-text hidden md:block",
|
|
645
|
+
"data-state": state,
|
|
646
|
+
"data-collapsible": state === "collapsed" ? "offcanvas" : void 0,
|
|
647
|
+
"data-variant": "sidebar",
|
|
648
|
+
"data-side": side,
|
|
649
|
+
"data-slot": "sidebar",
|
|
650
|
+
style: desktopSidebarStyle,
|
|
651
|
+
children: [
|
|
652
|
+
/* @__PURE__ */ jsx7(
|
|
653
|
+
"div",
|
|
654
|
+
{
|
|
655
|
+
"data-slot": "sidebar-gap",
|
|
656
|
+
className: cn(
|
|
657
|
+
"relative w-(--sidebar-width) bg-transparent",
|
|
658
|
+
isResizing ? "transition-none" : "transition-[width] duration-200 ease-[cubic-bezier(0.1,0.5,0.2,1)]",
|
|
659
|
+
"group-data-[collapsible=offcanvas]:w-0",
|
|
660
|
+
"group-data-[side=right]:rotate-180",
|
|
661
|
+
"group-data-[collapsible=icon]:w-(--sidebar-width-icon)"
|
|
662
|
+
)
|
|
663
|
+
}
|
|
664
|
+
),
|
|
665
|
+
/* @__PURE__ */ jsx7(
|
|
666
|
+
"div",
|
|
667
|
+
{
|
|
668
|
+
"data-slot": "sidebar-container",
|
|
669
|
+
"data-side": side,
|
|
670
|
+
className: cn(
|
|
671
|
+
"fixed inset-y-0 z-[var(--layer-sidebar)] hidden h-svh w-(--sidebar-width) data-[side=left]:left-[var(--workbench-ribbon-bar-offset,0px)] data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--workbench-ribbon-bar-offset,0px)_-_var(--sidebar-width))] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex",
|
|
672
|
+
isResizing ? "transition-none" : "transition-[left,right,width] duration-200 ease-[cubic-bezier(0.1,0.5,0.2,1)]",
|
|
673
|
+
"group-data-[collapsible=icon]:w-(--sidebar-width-icon)",
|
|
674
|
+
className
|
|
675
|
+
),
|
|
676
|
+
...props,
|
|
677
|
+
children: /* @__PURE__ */ jsx7(
|
|
678
|
+
"div",
|
|
679
|
+
{
|
|
680
|
+
"data-sidebar": "sidebar",
|
|
681
|
+
"data-slot": "sidebar-inner",
|
|
682
|
+
className: cn(
|
|
683
|
+
sidedockShellClass,
|
|
684
|
+
"group-data-[variant=floating]:ring-sidedock-border flex size-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1"
|
|
685
|
+
),
|
|
686
|
+
children
|
|
687
|
+
}
|
|
688
|
+
)
|
|
689
|
+
}
|
|
690
|
+
),
|
|
691
|
+
/* @__PURE__ */ jsx7(
|
|
692
|
+
SidebarRail,
|
|
693
|
+
{
|
|
694
|
+
currentWidth: sidebarWidth,
|
|
695
|
+
label: `Resize ${title}`,
|
|
696
|
+
onClick: handleRailClick,
|
|
697
|
+
onKeyDown: handleRailKeyDown,
|
|
698
|
+
onPointerDown: handleRailPointerDown,
|
|
699
|
+
side,
|
|
700
|
+
state
|
|
701
|
+
}
|
|
702
|
+
)
|
|
703
|
+
]
|
|
704
|
+
}
|
|
705
|
+
) });
|
|
706
|
+
}
|
|
707
|
+
function WorkbenchSidebarHeader({ className, ...props }) {
|
|
708
|
+
return /* @__PURE__ */ jsx7(
|
|
709
|
+
"div",
|
|
710
|
+
{
|
|
711
|
+
"data-slot": "sidebar-header",
|
|
712
|
+
"data-sidebar": "header",
|
|
713
|
+
className: cn("flex flex-col gap-2 px-1.5 py-2", className),
|
|
714
|
+
...props
|
|
715
|
+
}
|
|
716
|
+
);
|
|
717
|
+
}
|
|
718
|
+
function WorkbenchSidebarFooter({ className, ...props }) {
|
|
719
|
+
return /* @__PURE__ */ jsx7(
|
|
720
|
+
"div",
|
|
721
|
+
{
|
|
722
|
+
"data-slot": "sidebar-footer",
|
|
723
|
+
"data-sidebar": "footer",
|
|
724
|
+
className: cn("flex flex-col gap-2 px-1.5 py-2", className),
|
|
725
|
+
...props
|
|
726
|
+
}
|
|
727
|
+
);
|
|
728
|
+
}
|
|
729
|
+
function WorkbenchSidebarSeparator({
|
|
730
|
+
className,
|
|
731
|
+
...props
|
|
732
|
+
}) {
|
|
733
|
+
return /* @__PURE__ */ jsx7(
|
|
734
|
+
Separator,
|
|
735
|
+
{
|
|
736
|
+
"data-slot": "sidebar-separator",
|
|
737
|
+
"data-sidebar": "separator",
|
|
738
|
+
className: cn("bg-sidedock-border mx-2 w-auto", className),
|
|
739
|
+
...props
|
|
740
|
+
}
|
|
741
|
+
);
|
|
742
|
+
}
|
|
743
|
+
function WorkbenchSidebarContent({ className, ...props }) {
|
|
744
|
+
return /* @__PURE__ */ jsx7(
|
|
745
|
+
"div",
|
|
746
|
+
{
|
|
747
|
+
"data-slot": "sidebar-content",
|
|
748
|
+
"data-sidebar": "content",
|
|
749
|
+
className: cn(
|
|
750
|
+
"no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
|
|
751
|
+
className
|
|
752
|
+
),
|
|
753
|
+
...props
|
|
754
|
+
}
|
|
755
|
+
);
|
|
756
|
+
}
|
|
757
|
+
function WorkbenchSidebarGroup({ className, ...props }) {
|
|
758
|
+
return /* @__PURE__ */ jsx7(
|
|
759
|
+
"div",
|
|
760
|
+
{
|
|
761
|
+
"data-slot": "sidebar-group",
|
|
762
|
+
"data-sidebar": "group",
|
|
763
|
+
className: cn("relative flex w-full min-w-0 flex-col px-1.5 py-1", className),
|
|
764
|
+
...props
|
|
765
|
+
}
|
|
766
|
+
);
|
|
767
|
+
}
|
|
768
|
+
function WorkbenchSidebarGroupLabel({
|
|
769
|
+
className,
|
|
770
|
+
asChild = false,
|
|
771
|
+
...props
|
|
772
|
+
}) {
|
|
773
|
+
const Comp = asChild ? Slot2.Root : "div";
|
|
774
|
+
return /* @__PURE__ */ jsx7(
|
|
775
|
+
Comp,
|
|
776
|
+
{
|
|
777
|
+
"data-slot": "sidebar-group-label",
|
|
778
|
+
"data-sidebar": "group-label",
|
|
779
|
+
className: cn(
|
|
780
|
+
"text-sidedock-label flex h-8 shrink-0 items-center rounded-md px-1.5 text-xs font-medium outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 [&>svg]:size-4 [&>svg]:shrink-0",
|
|
781
|
+
sidedockFocusClass,
|
|
782
|
+
className
|
|
783
|
+
),
|
|
784
|
+
...props
|
|
785
|
+
}
|
|
786
|
+
);
|
|
787
|
+
}
|
|
788
|
+
function WorkbenchSidebarGroupAction({
|
|
789
|
+
className,
|
|
790
|
+
asChild = false,
|
|
791
|
+
...props
|
|
792
|
+
}) {
|
|
793
|
+
const Comp = asChild ? Slot2.Root : "button";
|
|
794
|
+
return /* @__PURE__ */ jsx7(
|
|
795
|
+
Comp,
|
|
796
|
+
{
|
|
797
|
+
"data-slot": "sidebar-group-action",
|
|
798
|
+
"data-sidebar": "group-action",
|
|
799
|
+
className: cn(
|
|
800
|
+
"text-sidedock-text hover:bg-sidedock-hover-background hover:text-sidedock-text-hover absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0",
|
|
801
|
+
sidedockFocusClass,
|
|
802
|
+
className
|
|
803
|
+
),
|
|
804
|
+
...props
|
|
805
|
+
}
|
|
806
|
+
);
|
|
807
|
+
}
|
|
808
|
+
function WorkbenchSidebarGroupContent({ className, ...props }) {
|
|
809
|
+
return /* @__PURE__ */ jsx7(
|
|
810
|
+
"div",
|
|
811
|
+
{
|
|
812
|
+
"data-slot": "sidebar-group-content",
|
|
813
|
+
"data-sidebar": "group-content",
|
|
814
|
+
className: cn("w-full text-sm", className),
|
|
815
|
+
...props
|
|
816
|
+
}
|
|
817
|
+
);
|
|
818
|
+
}
|
|
819
|
+
function WorkbenchSidebarMenu({ className, ...props }) {
|
|
820
|
+
return /* @__PURE__ */ jsx7(
|
|
821
|
+
"ul",
|
|
822
|
+
{
|
|
823
|
+
"data-slot": "sidebar-menu",
|
|
824
|
+
"data-sidebar": "menu",
|
|
825
|
+
className: cn("flex w-full min-w-0 flex-col gap-0.5", className),
|
|
826
|
+
...props
|
|
827
|
+
}
|
|
828
|
+
);
|
|
829
|
+
}
|
|
830
|
+
function WorkbenchSidebarMenuItem({ className, ...props }) {
|
|
831
|
+
return /* @__PURE__ */ jsx7(
|
|
832
|
+
"li",
|
|
833
|
+
{
|
|
834
|
+
"data-slot": "sidebar-menu-item",
|
|
835
|
+
"data-sidebar": "menu-item",
|
|
836
|
+
className: cn("group/menu-item relative", className),
|
|
837
|
+
...props
|
|
838
|
+
}
|
|
839
|
+
);
|
|
840
|
+
}
|
|
841
|
+
function WorkbenchSidebarMenuRow({ className, ...props }) {
|
|
842
|
+
return /* @__PURE__ */ jsx7(
|
|
843
|
+
"div",
|
|
844
|
+
{
|
|
845
|
+
"data-slot": "sidebar-menu-row",
|
|
846
|
+
"data-sidebar": "menu-row",
|
|
847
|
+
className: cn("group/menu-row relative flex items-center", className),
|
|
848
|
+
...props
|
|
849
|
+
}
|
|
850
|
+
);
|
|
851
|
+
}
|
|
852
|
+
var sidebarMenuButtonVariants = cva2(
|
|
853
|
+
cn(
|
|
854
|
+
"cursor-pointer text-sidedock-text peer/menu-button group/menu-button flex w-full min-w-0 items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm whitespace-nowrap outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-leading-action]/menu-item:pl-7 group-has-data-[sidebar=menu-trailing-action]/menu-item:pr-7 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidedock-hover-background hover:text-sidedock-text-hover active:bg-sidedock-active-background active:text-sidedock-text-active disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidedock-hover-background data-open:hover:text-sidedock-text-hover data-active:bg-sidedock-active-background data-active:font-medium data-active:text-sidedock-text-active [&_svg]:size-4 [&_svg]:shrink-0",
|
|
855
|
+
sidedockFocusClass
|
|
856
|
+
),
|
|
857
|
+
{
|
|
858
|
+
variants: {
|
|
859
|
+
variant: {
|
|
860
|
+
default: "",
|
|
861
|
+
outline: cn("bg-background-primary text-text-normal", sidedockOutlineStrokeClass)
|
|
862
|
+
},
|
|
863
|
+
size: {
|
|
864
|
+
default: "h-7 text-sm",
|
|
865
|
+
sm: "h-6 text-xs",
|
|
866
|
+
lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!"
|
|
867
|
+
}
|
|
868
|
+
},
|
|
869
|
+
defaultVariants: {
|
|
870
|
+
variant: "default",
|
|
871
|
+
size: "default"
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
);
|
|
875
|
+
function WorkbenchSidebarMenuButton({
|
|
876
|
+
asChild = false,
|
|
877
|
+
isActive = false,
|
|
878
|
+
variant = "default",
|
|
879
|
+
size = "default",
|
|
880
|
+
tooltip,
|
|
881
|
+
leadingVisual,
|
|
882
|
+
trailingVisual,
|
|
883
|
+
trailingVisualVisibility = "always",
|
|
884
|
+
className,
|
|
885
|
+
children,
|
|
886
|
+
...props
|
|
887
|
+
}) {
|
|
888
|
+
const Comp = asChild ? Slot2.Root : "button";
|
|
889
|
+
const { isMobile, side, state } = useWorkbenchSidebarVisualContext();
|
|
890
|
+
const content = typeof children === "string" || typeof children === "number" ? /* @__PURE__ */ jsx7("span", { "data-slot": "sidebar-menu-button-label", className: "min-w-0 flex-1 truncate", children }) : children;
|
|
891
|
+
const button = /* @__PURE__ */ jsxs3(
|
|
892
|
+
Comp,
|
|
893
|
+
{
|
|
894
|
+
"data-slot": "sidebar-menu-button",
|
|
895
|
+
"data-sidebar": "menu-button",
|
|
896
|
+
"data-size": size,
|
|
897
|
+
"data-active": isActive,
|
|
898
|
+
className: cn(sidebarMenuButtonVariants({ variant, size }), className),
|
|
899
|
+
...props,
|
|
900
|
+
children: [
|
|
901
|
+
leadingVisual ? /* @__PURE__ */ jsx7(
|
|
902
|
+
"span",
|
|
903
|
+
{
|
|
904
|
+
"data-slot": "sidebar-menu-button-leading-visual",
|
|
905
|
+
className: "flex shrink-0 items-center justify-center",
|
|
906
|
+
children: leadingVisual
|
|
907
|
+
}
|
|
908
|
+
) : null,
|
|
909
|
+
/* @__PURE__ */ jsx7(Slot2.Slottable, { children: content }),
|
|
910
|
+
trailingVisual ? /* @__PURE__ */ jsx7(
|
|
911
|
+
"span",
|
|
912
|
+
{
|
|
913
|
+
"data-slot": "sidebar-menu-button-trailing-visual",
|
|
914
|
+
className: cn(
|
|
915
|
+
"ml-auto flex shrink-0 items-center justify-center",
|
|
916
|
+
trailingVisualVisibility === "hover" && "invisible opacity-0 group-hover/menu-button:visible group-hover/menu-button:opacity-100 group-focus-visible/menu-button:visible group-focus-visible/menu-button:opacity-100"
|
|
917
|
+
),
|
|
918
|
+
children: trailingVisual
|
|
919
|
+
}
|
|
920
|
+
) : null
|
|
921
|
+
]
|
|
922
|
+
}
|
|
923
|
+
);
|
|
924
|
+
if (!tooltip) {
|
|
925
|
+
return button;
|
|
926
|
+
}
|
|
927
|
+
if (typeof tooltip === "string") {
|
|
928
|
+
tooltip = {
|
|
929
|
+
children: tooltip
|
|
930
|
+
};
|
|
931
|
+
}
|
|
932
|
+
return /* @__PURE__ */ jsxs3(Tooltip, { children: [
|
|
933
|
+
/* @__PURE__ */ jsx7(TooltipTrigger, { asChild: true, children: button }),
|
|
934
|
+
/* @__PURE__ */ jsx7(
|
|
935
|
+
TooltipContent,
|
|
936
|
+
{
|
|
937
|
+
side: side === "left" ? "right" : "left",
|
|
938
|
+
align: "center",
|
|
939
|
+
hidden: state !== "collapsed" || isMobile,
|
|
940
|
+
...tooltip
|
|
941
|
+
}
|
|
942
|
+
)
|
|
943
|
+
] });
|
|
944
|
+
}
|
|
945
|
+
function WorkbenchSidebarMenuActionBase({
|
|
946
|
+
className,
|
|
947
|
+
asChild = false,
|
|
948
|
+
dataSidebar,
|
|
949
|
+
dataSlot,
|
|
950
|
+
showOnHover = false,
|
|
951
|
+
...props
|
|
952
|
+
}) {
|
|
953
|
+
const Comp = asChild ? Slot2.Root : "button";
|
|
954
|
+
return /* @__PURE__ */ jsx7(
|
|
955
|
+
Comp,
|
|
956
|
+
{
|
|
957
|
+
"data-slot": dataSlot,
|
|
958
|
+
"data-sidebar": dataSidebar,
|
|
959
|
+
className: cn(
|
|
960
|
+
"text-sidedock-text hover:bg-sidedock-hover-background hover:text-sidedock-text-hover absolute top-1 flex aspect-square w-5 cursor-pointer items-center justify-center rounded-md p-0 outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0",
|
|
961
|
+
sidedockFocusClass,
|
|
962
|
+
dataSidebar === "menu-leading-action" ? "group-focus-within/menu-row:text-sidedock-text-hover group-hover/menu-row:text-sidedock-text-hover left-1" : "peer-hover/menu-button:text-sidedock-text-hover right-1",
|
|
963
|
+
showOnHover && "peer-data-active/menu-button:text-sidedock-text-active group-focus-within/menu-row:opacity-100 group-hover/menu-row:opacity-100 aria-expanded:opacity-100 md:opacity-0",
|
|
964
|
+
className
|
|
965
|
+
),
|
|
966
|
+
...props
|
|
967
|
+
}
|
|
968
|
+
);
|
|
969
|
+
}
|
|
970
|
+
function WorkbenchSidebarMenuLeadingAction(props) {
|
|
971
|
+
return /* @__PURE__ */ jsx7(
|
|
972
|
+
WorkbenchSidebarMenuActionBase,
|
|
973
|
+
{
|
|
974
|
+
dataSidebar: "menu-leading-action",
|
|
975
|
+
dataSlot: "sidebar-menu-leading-action",
|
|
976
|
+
...props
|
|
977
|
+
}
|
|
978
|
+
);
|
|
979
|
+
}
|
|
980
|
+
function WorkbenchSidebarMenuTrailingAction(props) {
|
|
981
|
+
return /* @__PURE__ */ jsx7(
|
|
982
|
+
WorkbenchSidebarMenuActionBase,
|
|
983
|
+
{
|
|
984
|
+
dataSidebar: "menu-trailing-action",
|
|
985
|
+
dataSlot: "sidebar-menu-trailing-action",
|
|
986
|
+
...props
|
|
987
|
+
}
|
|
988
|
+
);
|
|
989
|
+
}
|
|
990
|
+
function WorkbenchSidebarMenuBadge({ className, ...props }) {
|
|
991
|
+
return /* @__PURE__ */ jsx7(
|
|
992
|
+
"div",
|
|
993
|
+
{
|
|
994
|
+
"data-slot": "sidebar-menu-badge",
|
|
995
|
+
"data-sidebar": "menu-badge",
|
|
996
|
+
className: cn(
|
|
997
|
+
"text-sidedock-text peer-hover/menu-button:text-sidedock-text-hover peer-data-active/menu-button:text-sidedock-text-active pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums select-none group-data-[collapsible=icon]:hidden peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1",
|
|
998
|
+
className
|
|
999
|
+
),
|
|
1000
|
+
...props
|
|
1001
|
+
}
|
|
1002
|
+
);
|
|
1003
|
+
}
|
|
1004
|
+
function WorkbenchSidebarMenuSkeleton({
|
|
1005
|
+
className,
|
|
1006
|
+
showIcon = false,
|
|
1007
|
+
...props
|
|
1008
|
+
}) {
|
|
1009
|
+
const [width] = React5.useState(() => {
|
|
1010
|
+
return `${Math.floor(Math.random() * 40) + 50}%`;
|
|
1011
|
+
});
|
|
1012
|
+
const skeletonStyle = {
|
|
1013
|
+
"--skeleton-width": width
|
|
1014
|
+
};
|
|
1015
|
+
return /* @__PURE__ */ jsxs3(
|
|
1016
|
+
"div",
|
|
1017
|
+
{
|
|
1018
|
+
"data-slot": "sidebar-menu-skeleton",
|
|
1019
|
+
"data-sidebar": "menu-skeleton",
|
|
1020
|
+
className: cn("flex h-8 items-center gap-2 rounded-md px-1.5", className),
|
|
1021
|
+
...props,
|
|
1022
|
+
children: [
|
|
1023
|
+
showIcon && /* @__PURE__ */ jsx7(Skeleton, { className: "size-4 rounded-md", "data-sidebar": "menu-skeleton-icon" }),
|
|
1024
|
+
/* @__PURE__ */ jsx7(
|
|
1025
|
+
Skeleton,
|
|
1026
|
+
{
|
|
1027
|
+
className: "h-4 max-w-(--skeleton-width) flex-1",
|
|
1028
|
+
"data-sidebar": "menu-skeleton-text",
|
|
1029
|
+
style: skeletonStyle
|
|
1030
|
+
}
|
|
1031
|
+
)
|
|
1032
|
+
]
|
|
1033
|
+
}
|
|
1034
|
+
);
|
|
1035
|
+
}
|
|
1036
|
+
function WorkbenchSidebarMenuSub({ className, ...props }) {
|
|
1037
|
+
return /* @__PURE__ */ jsx7(
|
|
1038
|
+
"ul",
|
|
1039
|
+
{
|
|
1040
|
+
"data-slot": "sidebar-menu-sub",
|
|
1041
|
+
"data-sidebar": "menu-sub",
|
|
1042
|
+
className: cn(
|
|
1043
|
+
"border-sidedock-border ml-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l py-0.5 pl-1 group-data-[collapsible=icon]:hidden",
|
|
1044
|
+
className
|
|
1045
|
+
),
|
|
1046
|
+
...props
|
|
1047
|
+
}
|
|
1048
|
+
);
|
|
1049
|
+
}
|
|
1050
|
+
function WorkbenchSidebarMenuSubItem({ className, ...props }) {
|
|
1051
|
+
return /* @__PURE__ */ jsx7(
|
|
1052
|
+
"li",
|
|
1053
|
+
{
|
|
1054
|
+
"data-slot": "sidebar-menu-sub-item",
|
|
1055
|
+
"data-sidebar": "menu-sub-item",
|
|
1056
|
+
className: cn("group/menu-sub-item relative", className),
|
|
1057
|
+
...props
|
|
1058
|
+
}
|
|
1059
|
+
);
|
|
1060
|
+
}
|
|
1061
|
+
function WorkbenchSidebarMenuSubButton({
|
|
1062
|
+
asChild = false,
|
|
1063
|
+
size = "md",
|
|
1064
|
+
isActive = false,
|
|
1065
|
+
className,
|
|
1066
|
+
...props
|
|
1067
|
+
}) {
|
|
1068
|
+
const Comp = asChild ? Slot2.Root : "a";
|
|
1069
|
+
return /* @__PURE__ */ jsx7(
|
|
1070
|
+
Comp,
|
|
1071
|
+
{
|
|
1072
|
+
"data-slot": "sidebar-menu-sub-button",
|
|
1073
|
+
"data-sidebar": "menu-sub-button",
|
|
1074
|
+
"data-size": size,
|
|
1075
|
+
"data-active": isActive,
|
|
1076
|
+
className: cn(
|
|
1077
|
+
"text-sidedock-text hover:bg-sidedock-hover-background hover:text-sidedock-text-hover active:bg-sidedock-active-background active:text-sidedock-text-active data-active:bg-sidedock-active-background data-active:text-sidedock-text-active [&>svg]:text-sidedock-text-active flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-1.5 outline-hidden group-data-[collapsible=icon]:hidden disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
|
|
1078
|
+
sidedockFocusClass,
|
|
1079
|
+
className
|
|
1080
|
+
),
|
|
1081
|
+
...props
|
|
1082
|
+
}
|
|
1083
|
+
);
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
// src/layouts/workbench/core/components/sidebar/WorkbenchSidebarTree.tsx
|
|
1087
|
+
import * as React6 from "react";
|
|
1088
|
+
import {
|
|
1089
|
+
closestCenter,
|
|
1090
|
+
DndContext,
|
|
1091
|
+
DragOverlay,
|
|
1092
|
+
PointerSensor,
|
|
1093
|
+
useSensor,
|
|
1094
|
+
useSensors
|
|
1095
|
+
} from "@dnd-kit/core";
|
|
1096
|
+
import { SortableContext, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";
|
|
1097
|
+
import { ChevronRightIcon } from "lucide-react";
|
|
1098
|
+
import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1099
|
+
var DEFAULT_TREE_INDENT_WIDTH = 16;
|
|
1100
|
+
var DEFAULT_TREE_MAX_DEPTH = 8;
|
|
1101
|
+
var TREE_DROP_EDGE_RATIO = 0.28;
|
|
1102
|
+
var TREE_DROP_EDGE_MIN_HEIGHT = 6;
|
|
1103
|
+
var TREE_DROP_EDGE_MAX_HEIGHT = 12;
|
|
1104
|
+
var WorkbenchSidebarTreeContext = React6.createContext(null);
|
|
1105
|
+
function useWorkbenchSidebarTreeContext() {
|
|
1106
|
+
const context = React6.useContext(WorkbenchSidebarTreeContext);
|
|
1107
|
+
if (!context) {
|
|
1108
|
+
throw new Error("WorkbenchSidebarTree hooks must be used within WorkbenchSidebarTreeProvider.");
|
|
1109
|
+
}
|
|
1110
|
+
return context;
|
|
1111
|
+
}
|
|
1112
|
+
function useWorkbenchSidebarTree() {
|
|
1113
|
+
return useWorkbenchSidebarTreeContext();
|
|
1114
|
+
}
|
|
1115
|
+
function useWorkbenchSidebarTreeItem(itemId) {
|
|
1116
|
+
const tree = useWorkbenchSidebarTreeContext();
|
|
1117
|
+
const state = tree.getItemState(itemId);
|
|
1118
|
+
return {
|
|
1119
|
+
...state,
|
|
1120
|
+
select: (event) => tree.selectItem(itemId, event),
|
|
1121
|
+
toggleExpanded: (event) => tree.toggleItemExpanded(itemId, event),
|
|
1122
|
+
expand: (event) => tree.setItemExpanded(itemId, true, event),
|
|
1123
|
+
collapse: (event) => tree.setItemExpanded(itemId, false, event),
|
|
1124
|
+
focus: () => tree.focusItem(itemId)
|
|
1125
|
+
};
|
|
1126
|
+
}
|
|
1127
|
+
function resolveIterableIds(ids, fallback = []) {
|
|
1128
|
+
return Array.from(ids ?? fallback);
|
|
1129
|
+
}
|
|
1130
|
+
function resolveSet(ids, fallback = []) {
|
|
1131
|
+
return new Set(resolveIterableIds(ids, fallback));
|
|
1132
|
+
}
|
|
1133
|
+
function flattenTree(items, expandedIdSet, options = {}) {
|
|
1134
|
+
const { includeCollapsedChildren = false, parentId = null, depth = 0, ancestorIds = [] } = options;
|
|
1135
|
+
const flattenedItems = [];
|
|
1136
|
+
items.forEach((item, index) => {
|
|
1137
|
+
const children = item.children ?? [];
|
|
1138
|
+
const flattenedItem = {
|
|
1139
|
+
item,
|
|
1140
|
+
id: item.id,
|
|
1141
|
+
parentId,
|
|
1142
|
+
index,
|
|
1143
|
+
depth,
|
|
1144
|
+
ancestorIds,
|
|
1145
|
+
childrenCount: children.length
|
|
1146
|
+
};
|
|
1147
|
+
flattenedItems.push(flattenedItem);
|
|
1148
|
+
if (children.length && (includeCollapsedChildren || expandedIdSet.has(item.id))) {
|
|
1149
|
+
flattenedItems.push(
|
|
1150
|
+
...flattenTree(children, expandedIdSet, {
|
|
1151
|
+
includeCollapsedChildren,
|
|
1152
|
+
parentId: item.id,
|
|
1153
|
+
depth: depth + 1,
|
|
1154
|
+
ancestorIds: [...ancestorIds, item.id]
|
|
1155
|
+
})
|
|
1156
|
+
);
|
|
1157
|
+
}
|
|
1158
|
+
});
|
|
1159
|
+
return flattenedItems;
|
|
1160
|
+
}
|
|
1161
|
+
function createItemMap(flattenedItems) {
|
|
1162
|
+
return new Map(flattenedItems.map((item) => [item.id, item]));
|
|
1163
|
+
}
|
|
1164
|
+
function cloneItemsWithoutItem(items, itemId) {
|
|
1165
|
+
let removedItem = null;
|
|
1166
|
+
const nextItems = items.reduce((result, item) => {
|
|
1167
|
+
if (item.id === itemId) {
|
|
1168
|
+
removedItem = item;
|
|
1169
|
+
return result;
|
|
1170
|
+
}
|
|
1171
|
+
if (item.children?.length) {
|
|
1172
|
+
const childResult = cloneItemsWithoutItem(item.children, itemId);
|
|
1173
|
+
if (childResult.removedItem) {
|
|
1174
|
+
removedItem = childResult.removedItem;
|
|
1175
|
+
result.push({
|
|
1176
|
+
...item,
|
|
1177
|
+
children: childResult.items
|
|
1178
|
+
});
|
|
1179
|
+
return result;
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
result.push(item);
|
|
1183
|
+
return result;
|
|
1184
|
+
}, []);
|
|
1185
|
+
return {
|
|
1186
|
+
items: nextItems,
|
|
1187
|
+
removedItem
|
|
1188
|
+
};
|
|
1189
|
+
}
|
|
1190
|
+
function insertItemAtParent(items, itemToInsert, parentId, index) {
|
|
1191
|
+
if (!parentId) {
|
|
1192
|
+
const nextItems = [...items];
|
|
1193
|
+
nextItems.splice(Math.max(0, Math.min(index, nextItems.length)), 0, itemToInsert);
|
|
1194
|
+
return nextItems;
|
|
1195
|
+
}
|
|
1196
|
+
return items.map((item) => {
|
|
1197
|
+
if (item.id === parentId) {
|
|
1198
|
+
const children = [...item.children ?? []];
|
|
1199
|
+
children.splice(Math.max(0, Math.min(index, children.length)), 0, itemToInsert);
|
|
1200
|
+
return {
|
|
1201
|
+
...item,
|
|
1202
|
+
children
|
|
1203
|
+
};
|
|
1204
|
+
}
|
|
1205
|
+
if (!item.children?.length) {
|
|
1206
|
+
return item;
|
|
1207
|
+
}
|
|
1208
|
+
return {
|
|
1209
|
+
...item,
|
|
1210
|
+
children: insertItemAtParent(item.children, itemToInsert, parentId, index)
|
|
1211
|
+
};
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
function countChildrenBeforeIndex(items, parentId, visibleIndex) {
|
|
1215
|
+
return items.slice(0, visibleIndex).filter((item) => item.parentId === parentId).length;
|
|
1216
|
+
}
|
|
1217
|
+
function getChildrenCount(items, parentId) {
|
|
1218
|
+
if (!parentId) {
|
|
1219
|
+
return items.length;
|
|
1220
|
+
}
|
|
1221
|
+
for (const item of items) {
|
|
1222
|
+
if (item.id === parentId) {
|
|
1223
|
+
return item.children?.length ?? 0;
|
|
1224
|
+
}
|
|
1225
|
+
if (item.children?.length) {
|
|
1226
|
+
const childCount = getChildrenCount(item.children, parentId);
|
|
1227
|
+
if (childCount > 0) {
|
|
1228
|
+
return childCount;
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
return 0;
|
|
1233
|
+
}
|
|
1234
|
+
function clampDepth(depth, minDepth, maxDepth) {
|
|
1235
|
+
return Math.max(minDepth, Math.min(depth, maxDepth));
|
|
1236
|
+
}
|
|
1237
|
+
function getParentIdForDepth(items, targetIndex, depth) {
|
|
1238
|
+
if (depth <= 0) {
|
|
1239
|
+
return null;
|
|
1240
|
+
}
|
|
1241
|
+
for (let index = targetIndex - 1; index >= 0; index -= 1) {
|
|
1242
|
+
const item = items[index];
|
|
1243
|
+
if (item?.depth === depth - 1) {
|
|
1244
|
+
return item.id;
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
return null;
|
|
1248
|
+
}
|
|
1249
|
+
var treeCollisionDetection = (args) => {
|
|
1250
|
+
const { pointerCoordinates } = args;
|
|
1251
|
+
if (!pointerCoordinates) {
|
|
1252
|
+
return closestCenter(args);
|
|
1253
|
+
}
|
|
1254
|
+
const collisions = [];
|
|
1255
|
+
for (const droppableContainer of args.droppableContainers) {
|
|
1256
|
+
if (droppableContainer.disabled) {
|
|
1257
|
+
continue;
|
|
1258
|
+
}
|
|
1259
|
+
const rect = args.droppableRects.get(droppableContainer.id);
|
|
1260
|
+
if (!rect) {
|
|
1261
|
+
continue;
|
|
1262
|
+
}
|
|
1263
|
+
const centerY = rect.top + rect.height / 2;
|
|
1264
|
+
const pointerIsWithinY = pointerCoordinates.y >= rect.top && pointerCoordinates.y <= rect.bottom;
|
|
1265
|
+
const verticalDistance = pointerIsWithinY ? 0 : Math.min(
|
|
1266
|
+
Math.abs(pointerCoordinates.y - rect.top),
|
|
1267
|
+
Math.abs(pointerCoordinates.y - rect.bottom)
|
|
1268
|
+
);
|
|
1269
|
+
const horizontalDistance = pointerCoordinates.x < rect.left ? rect.left - pointerCoordinates.x : Math.max(0, pointerCoordinates.x - rect.right);
|
|
1270
|
+
collisions.push({
|
|
1271
|
+
id: droppableContainer.id,
|
|
1272
|
+
data: {
|
|
1273
|
+
droppableContainer,
|
|
1274
|
+
value: verticalDistance * 1e3 + Math.abs(pointerCoordinates.y - centerY) + horizontalDistance * 0.01
|
|
1275
|
+
}
|
|
1276
|
+
});
|
|
1277
|
+
}
|
|
1278
|
+
return collisions.sort((a, b) => a.data.value - b.data.value);
|
|
1279
|
+
};
|
|
1280
|
+
function getEventClientCoordinates(event) {
|
|
1281
|
+
if (event instanceof MouseEvent) {
|
|
1282
|
+
return {
|
|
1283
|
+
x: event.clientX,
|
|
1284
|
+
y: event.clientY
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
1287
|
+
if (typeof TouchEvent === "undefined" || !(event instanceof TouchEvent)) {
|
|
1288
|
+
return null;
|
|
1289
|
+
}
|
|
1290
|
+
const touch = event.touches[0] ?? event.changedTouches[0];
|
|
1291
|
+
if (!touch) {
|
|
1292
|
+
return null;
|
|
1293
|
+
}
|
|
1294
|
+
return {
|
|
1295
|
+
x: touch.clientX,
|
|
1296
|
+
y: touch.clientY
|
|
1297
|
+
};
|
|
1298
|
+
}
|
|
1299
|
+
function getItemRectCenter(rect) {
|
|
1300
|
+
if (!rect) {
|
|
1301
|
+
return null;
|
|
1302
|
+
}
|
|
1303
|
+
return {
|
|
1304
|
+
y: rect.top + rect.height / 2
|
|
1305
|
+
};
|
|
1306
|
+
}
|
|
1307
|
+
function getDropEdgeHeight(rect) {
|
|
1308
|
+
return Math.min(
|
|
1309
|
+
TREE_DROP_EDGE_MAX_HEIGHT,
|
|
1310
|
+
Math.max(TREE_DROP_EDGE_MIN_HEIGHT, rect.height * TREE_DROP_EDGE_RATIO)
|
|
1311
|
+
);
|
|
1312
|
+
}
|
|
1313
|
+
function getItemMaxDescendantDepthOffset(item) {
|
|
1314
|
+
if (!item.children?.length) {
|
|
1315
|
+
return 0;
|
|
1316
|
+
}
|
|
1317
|
+
return item.children.reduce(
|
|
1318
|
+
(maxDepthOffset, child) => Math.max(maxDepthOffset, 1 + getItemMaxDescendantDepthOffset(child)),
|
|
1319
|
+
0
|
|
1320
|
+
);
|
|
1321
|
+
}
|
|
1322
|
+
function getIndexAfterVisibleSubtree(flattenedItems, itemIndex) {
|
|
1323
|
+
const item = flattenedItems[itemIndex];
|
|
1324
|
+
if (!item) {
|
|
1325
|
+
return itemIndex;
|
|
1326
|
+
}
|
|
1327
|
+
let nextIndex = itemIndex + 1;
|
|
1328
|
+
while (nextIndex < flattenedItems.length) {
|
|
1329
|
+
const nextItem = flattenedItems[nextIndex];
|
|
1330
|
+
if (!nextItem || nextItem.depth <= item.depth) {
|
|
1331
|
+
break;
|
|
1332
|
+
}
|
|
1333
|
+
nextIndex += 1;
|
|
1334
|
+
}
|
|
1335
|
+
return nextIndex;
|
|
1336
|
+
}
|
|
1337
|
+
function getPointerPlacement({
|
|
1338
|
+
activeItem,
|
|
1339
|
+
activeMaxDepth,
|
|
1340
|
+
dragOffset,
|
|
1341
|
+
indentWidth,
|
|
1342
|
+
overItem,
|
|
1343
|
+
overItemRect,
|
|
1344
|
+
pointerY
|
|
1345
|
+
}) {
|
|
1346
|
+
if (!overItemRect || pointerY === null || pointerY === void 0) {
|
|
1347
|
+
return "after";
|
|
1348
|
+
}
|
|
1349
|
+
const edgeHeight = getDropEdgeHeight(overItemRect);
|
|
1350
|
+
if (pointerY <= overItemRect.top + edgeHeight) {
|
|
1351
|
+
return "before";
|
|
1352
|
+
}
|
|
1353
|
+
if (pointerY >= overItemRect.bottom - edgeHeight) {
|
|
1354
|
+
return "after";
|
|
1355
|
+
}
|
|
1356
|
+
const projectedDepth = activeItem.depth + Math.round(dragOffset / indentWidth);
|
|
1357
|
+
if (projectedDepth > overItem.depth && overItem.depth + 1 <= activeMaxDepth) {
|
|
1358
|
+
return "inside";
|
|
1359
|
+
}
|
|
1360
|
+
const center = getItemRectCenter(overItemRect);
|
|
1361
|
+
return center && pointerY < center.y ? "before" : "after";
|
|
1362
|
+
}
|
|
1363
|
+
function createMoveEvent({
|
|
1364
|
+
activeId,
|
|
1365
|
+
depth,
|
|
1366
|
+
flattenedItemsWithoutActive,
|
|
1367
|
+
items,
|
|
1368
|
+
originalItemMap,
|
|
1369
|
+
placement,
|
|
1370
|
+
targetIndex,
|
|
1371
|
+
toParentId
|
|
1372
|
+
}) {
|
|
1373
|
+
const activeItem = originalItemMap.get(activeId);
|
|
1374
|
+
if (!activeItem) {
|
|
1375
|
+
return null;
|
|
1376
|
+
}
|
|
1377
|
+
const { items: itemsWithoutActive, removedItem } = cloneItemsWithoutItem(items, activeId);
|
|
1378
|
+
if (!removedItem) {
|
|
1379
|
+
return null;
|
|
1380
|
+
}
|
|
1381
|
+
const toIndex = placement === "inside" ? getChildrenCount(itemsWithoutActive, toParentId) : countChildrenBeforeIndex(flattenedItemsWithoutActive, toParentId, targetIndex);
|
|
1382
|
+
const nextItems = insertItemAtParent(itemsWithoutActive, removedItem, toParentId, toIndex);
|
|
1383
|
+
return {
|
|
1384
|
+
item: removedItem,
|
|
1385
|
+
itemId: activeId,
|
|
1386
|
+
fromParentId: activeItem.parentId,
|
|
1387
|
+
toParentId,
|
|
1388
|
+
fromIndex: activeItem.index,
|
|
1389
|
+
toIndex,
|
|
1390
|
+
depth,
|
|
1391
|
+
placement,
|
|
1392
|
+
nextItems
|
|
1393
|
+
};
|
|
1394
|
+
}
|
|
1395
|
+
function getProjectedMove({
|
|
1396
|
+
activeId,
|
|
1397
|
+
canDrop,
|
|
1398
|
+
dragOffset,
|
|
1399
|
+
flattenedItems,
|
|
1400
|
+
indentWidth,
|
|
1401
|
+
items,
|
|
1402
|
+
maxDepth,
|
|
1403
|
+
overId,
|
|
1404
|
+
overItemRect,
|
|
1405
|
+
pointerY
|
|
1406
|
+
}) {
|
|
1407
|
+
if (!activeId || !overId || activeId === overId) {
|
|
1408
|
+
return null;
|
|
1409
|
+
}
|
|
1410
|
+
const originalItemMap = createItemMap(flattenedItems);
|
|
1411
|
+
const activeItem = originalItemMap.get(activeId);
|
|
1412
|
+
const overItem = originalItemMap.get(overId);
|
|
1413
|
+
if (!activeItem || !overItem || activeItem.item.disabled || activeItem.item.draggable === false) {
|
|
1414
|
+
return null;
|
|
1415
|
+
}
|
|
1416
|
+
if (overItem.ancestorIds.includes(activeId)) {
|
|
1417
|
+
return null;
|
|
1418
|
+
}
|
|
1419
|
+
const flattenedItemsWithoutActive = flattenedItems.filter(
|
|
1420
|
+
(item) => item.id !== activeId && !item.ancestorIds.includes(activeId)
|
|
1421
|
+
);
|
|
1422
|
+
const overIndex = flattenedItemsWithoutActive.findIndex((item) => item.id === overId);
|
|
1423
|
+
if (overIndex < 0) {
|
|
1424
|
+
return null;
|
|
1425
|
+
}
|
|
1426
|
+
const activeDescendantDepthOffset = getItemMaxDescendantDepthOffset(activeItem.item);
|
|
1427
|
+
const activeMaxDepth = maxDepth - 1 - activeDescendantDepthOffset;
|
|
1428
|
+
if (activeMaxDepth < 0) {
|
|
1429
|
+
return null;
|
|
1430
|
+
}
|
|
1431
|
+
const offsetDepth = Math.round(dragOffset / indentWidth);
|
|
1432
|
+
const unclampedDepth = activeItem.depth + offsetDepth;
|
|
1433
|
+
const pointerPlacement = getPointerPlacement({
|
|
1434
|
+
activeItem,
|
|
1435
|
+
activeMaxDepth,
|
|
1436
|
+
dragOffset,
|
|
1437
|
+
indentWidth,
|
|
1438
|
+
overItem,
|
|
1439
|
+
overItemRect,
|
|
1440
|
+
pointerY
|
|
1441
|
+
});
|
|
1442
|
+
const placement = pointerPlacement;
|
|
1443
|
+
let targetIndex = placement === "after" ? getIndexAfterVisibleSubtree(flattenedItemsWithoutActive, overIndex) : overIndex;
|
|
1444
|
+
let depth = overItem.depth + 1;
|
|
1445
|
+
let toParentId = overId;
|
|
1446
|
+
if (placement === "inside") {
|
|
1447
|
+
if (overItem.item.disabled || depth > activeMaxDepth) {
|
|
1448
|
+
return null;
|
|
1449
|
+
}
|
|
1450
|
+
targetIndex = overIndex + 1;
|
|
1451
|
+
} else {
|
|
1452
|
+
const previousItem = flattenedItemsWithoutActive[targetIndex - 1];
|
|
1453
|
+
const nextItem = flattenedItemsWithoutActive[targetIndex];
|
|
1454
|
+
const maxDepthForPosition = placement === "after" ? overItem.depth : (previousItem?.depth ?? -1) + 1;
|
|
1455
|
+
const maxProjectedDepth = Math.min(activeMaxDepth, maxDepthForPosition);
|
|
1456
|
+
const minProjectedDepth = nextItem ? nextItem.depth : 0;
|
|
1457
|
+
if (minProjectedDepth > maxProjectedDepth) {
|
|
1458
|
+
return null;
|
|
1459
|
+
}
|
|
1460
|
+
depth = clampDepth(unclampedDepth, minProjectedDepth, maxProjectedDepth);
|
|
1461
|
+
toParentId = getParentIdForDepth(flattenedItemsWithoutActive, targetIndex, depth);
|
|
1462
|
+
}
|
|
1463
|
+
const parentItem = toParentId ? originalItemMap.get(toParentId) : null;
|
|
1464
|
+
if (parentItem?.item.disabled) {
|
|
1465
|
+
return null;
|
|
1466
|
+
}
|
|
1467
|
+
const moveEvent = createMoveEvent({
|
|
1468
|
+
activeId,
|
|
1469
|
+
depth,
|
|
1470
|
+
flattenedItemsWithoutActive,
|
|
1471
|
+
items,
|
|
1472
|
+
originalItemMap,
|
|
1473
|
+
placement,
|
|
1474
|
+
targetIndex,
|
|
1475
|
+
toParentId
|
|
1476
|
+
});
|
|
1477
|
+
if (!moveEvent || canDrop?.(moveEvent) === false) {
|
|
1478
|
+
return null;
|
|
1479
|
+
}
|
|
1480
|
+
if (moveEvent.fromParentId === moveEvent.toParentId && moveEvent.fromIndex === moveEvent.toIndex) {
|
|
1481
|
+
return null;
|
|
1482
|
+
}
|
|
1483
|
+
const indicatorId = placement === "after" ? flattenedItemsWithoutActive[Math.max(0, targetIndex - 1)]?.id ?? overId : overId;
|
|
1484
|
+
return {
|
|
1485
|
+
...moveEvent,
|
|
1486
|
+
indicatorId,
|
|
1487
|
+
overId
|
|
1488
|
+
};
|
|
1489
|
+
}
|
|
1490
|
+
function moveItemWithKeyboard({
|
|
1491
|
+
activeId,
|
|
1492
|
+
canDrop,
|
|
1493
|
+
direction,
|
|
1494
|
+
expandedIdSet,
|
|
1495
|
+
items,
|
|
1496
|
+
maxDepth
|
|
1497
|
+
}) {
|
|
1498
|
+
const flattenedItems = flattenTree(items, expandedIdSet);
|
|
1499
|
+
const itemMap = createItemMap(flattenedItems);
|
|
1500
|
+
const activeItem = itemMap.get(activeId);
|
|
1501
|
+
if (!activeItem || activeItem.item.disabled || activeItem.item.draggable === false) {
|
|
1502
|
+
return null;
|
|
1503
|
+
}
|
|
1504
|
+
const flattenedItemsWithoutActive = flattenedItems.filter(
|
|
1505
|
+
(item) => item.id !== activeId && !item.ancestorIds.includes(activeId)
|
|
1506
|
+
);
|
|
1507
|
+
const activeIndex = flattenedItems.findIndex((item) => item.id === activeId);
|
|
1508
|
+
const currentIndex = flattenedItemsWithoutActive.findIndex((item) => item.id === activeId);
|
|
1509
|
+
const originalItemMap = createItemMap(flattenedItems);
|
|
1510
|
+
const { depth: activeDepth } = activeItem;
|
|
1511
|
+
const activeMaxDepth = maxDepth - 1 - getItemMaxDescendantDepthOffset(activeItem.item);
|
|
1512
|
+
let targetIndex = -1;
|
|
1513
|
+
let depth = activeDepth;
|
|
1514
|
+
let toParentId = activeItem.parentId;
|
|
1515
|
+
let placement = "after";
|
|
1516
|
+
if (direction === "up") {
|
|
1517
|
+
const previousIndex = Math.max(0, activeIndex - 1);
|
|
1518
|
+
const previousItem = flattenedItems[previousIndex];
|
|
1519
|
+
if (!previousItem || previousItem.id === activeId || previousItem.ancestorIds.includes(activeId)) {
|
|
1520
|
+
return null;
|
|
1521
|
+
}
|
|
1522
|
+
targetIndex = flattenedItemsWithoutActive.findIndex((item) => item.id === previousItem.id);
|
|
1523
|
+
depth = Math.min(activeItem.depth, previousItem.depth);
|
|
1524
|
+
toParentId = getParentIdForDepth(flattenedItemsWithoutActive, targetIndex, depth);
|
|
1525
|
+
placement = "before";
|
|
1526
|
+
}
|
|
1527
|
+
if (direction === "down") {
|
|
1528
|
+
const nextItem = flattenedItems.slice(activeIndex + 1).find((item) => item.id !== activeId && !item.ancestorIds.includes(activeId));
|
|
1529
|
+
if (!nextItem) {
|
|
1530
|
+
return null;
|
|
1531
|
+
}
|
|
1532
|
+
const nextIndex = flattenedItemsWithoutActive.findIndex((item) => item.id === nextItem.id);
|
|
1533
|
+
targetIndex = nextIndex + 1;
|
|
1534
|
+
depth = Math.min(activeItem.depth, nextItem.depth);
|
|
1535
|
+
toParentId = getParentIdForDepth(flattenedItemsWithoutActive, targetIndex, depth);
|
|
1536
|
+
placement = "after";
|
|
1537
|
+
}
|
|
1538
|
+
if (direction === "left") {
|
|
1539
|
+
if (!activeItem.parentId) {
|
|
1540
|
+
return null;
|
|
1541
|
+
}
|
|
1542
|
+
const parentItem2 = itemMap.get(activeItem.parentId);
|
|
1543
|
+
if (!parentItem2) {
|
|
1544
|
+
return null;
|
|
1545
|
+
}
|
|
1546
|
+
targetIndex = flattenedItemsWithoutActive.findIndex((item) => item.id === parentItem2.id) + parentItem2.childrenCount;
|
|
1547
|
+
depth = parentItem2.depth;
|
|
1548
|
+
toParentId = parentItem2.parentId;
|
|
1549
|
+
placement = "after";
|
|
1550
|
+
}
|
|
1551
|
+
if (direction === "right") {
|
|
1552
|
+
const previousItem = flattenedItemsWithoutActive[currentIndex >= 0 ? currentIndex - 1 : Math.max(0, activeIndex - 1)];
|
|
1553
|
+
if (!previousItem || previousItem.item.disabled || previousItem.depth + 1 > activeMaxDepth) {
|
|
1554
|
+
return null;
|
|
1555
|
+
}
|
|
1556
|
+
targetIndex = flattenedItemsWithoutActive.findIndex((item) => item.id === previousItem.id) + 1;
|
|
1557
|
+
depth = previousItem.depth + 1;
|
|
1558
|
+
toParentId = previousItem.id;
|
|
1559
|
+
placement = "inside";
|
|
1560
|
+
}
|
|
1561
|
+
if (targetIndex < 0) {
|
|
1562
|
+
return null;
|
|
1563
|
+
}
|
|
1564
|
+
const parentItem = toParentId ? itemMap.get(toParentId) : null;
|
|
1565
|
+
if (parentItem?.item.disabled) {
|
|
1566
|
+
return null;
|
|
1567
|
+
}
|
|
1568
|
+
const moveEvent = createMoveEvent({
|
|
1569
|
+
activeId,
|
|
1570
|
+
depth,
|
|
1571
|
+
flattenedItemsWithoutActive,
|
|
1572
|
+
items,
|
|
1573
|
+
originalItemMap,
|
|
1574
|
+
placement,
|
|
1575
|
+
targetIndex,
|
|
1576
|
+
toParentId
|
|
1577
|
+
});
|
|
1578
|
+
if (!moveEvent || canDrop?.(moveEvent) === false) {
|
|
1579
|
+
return null;
|
|
1580
|
+
}
|
|
1581
|
+
return moveEvent;
|
|
1582
|
+
}
|
|
1583
|
+
function resolveVisual(visual, state) {
|
|
1584
|
+
return typeof visual === "function" ? visual(state) : visual;
|
|
1585
|
+
}
|
|
1586
|
+
function WorkbenchSidebarTreeProvider({
|
|
1587
|
+
children,
|
|
1588
|
+
items,
|
|
1589
|
+
selectedId: selectedIdProp,
|
|
1590
|
+
defaultSelectedId = null,
|
|
1591
|
+
expandedIds: expandedIdsProp,
|
|
1592
|
+
defaultExpandedIds = [],
|
|
1593
|
+
reorderable = false,
|
|
1594
|
+
maxDepth = DEFAULT_TREE_MAX_DEPTH,
|
|
1595
|
+
indentWidth = DEFAULT_TREE_INDENT_WIDTH,
|
|
1596
|
+
canDrop,
|
|
1597
|
+
onItemClick,
|
|
1598
|
+
onItemSelect,
|
|
1599
|
+
onSelectedIdChange,
|
|
1600
|
+
onItemExpandedChange,
|
|
1601
|
+
onExpandedIdsChange,
|
|
1602
|
+
onMove
|
|
1603
|
+
}) {
|
|
1604
|
+
const [uncontrolledSelectedId, setUncontrolledSelectedId] = React6.useState(
|
|
1605
|
+
defaultSelectedId
|
|
1606
|
+
);
|
|
1607
|
+
const [uncontrolledExpandedIds, setUncontrolledExpandedIds] = React6.useState(
|
|
1608
|
+
() => resolveIterableIds(defaultExpandedIds)
|
|
1609
|
+
);
|
|
1610
|
+
const [focusedId, setFocusedId] = React6.useState(null);
|
|
1611
|
+
const [activeId, setActiveId] = React6.useState(null);
|
|
1612
|
+
const [overId, setOverId] = React6.useState(null);
|
|
1613
|
+
const [dragOffset, setDragOffset] = React6.useState(0);
|
|
1614
|
+
const [dragPointerY, setDragPointerY] = React6.useState(null);
|
|
1615
|
+
const [dragOverlayWidth, setDragOverlayWidth] = React6.useState(null);
|
|
1616
|
+
const itemButtonRefs = React6.useRef(/* @__PURE__ */ new Map());
|
|
1617
|
+
const itemNodeRefs = React6.useRef(/* @__PURE__ */ new Map());
|
|
1618
|
+
const dragStartPointerRef = React6.useRef(null);
|
|
1619
|
+
const selectedId = selectedIdProp === void 0 ? uncontrolledSelectedId : selectedIdProp;
|
|
1620
|
+
const expandedIdSet = React6.useMemo(
|
|
1621
|
+
() => resolveSet(expandedIdsProp, uncontrolledExpandedIds),
|
|
1622
|
+
[expandedIdsProp, uncontrolledExpandedIds]
|
|
1623
|
+
);
|
|
1624
|
+
const expandedIds = React6.useMemo(() => Array.from(expandedIdSet), [expandedIdSet]);
|
|
1625
|
+
const flattenedItems = React6.useMemo(
|
|
1626
|
+
() => flattenTree(items, expandedIdSet),
|
|
1627
|
+
[expandedIdSet, items]
|
|
1628
|
+
);
|
|
1629
|
+
const itemMap = React6.useMemo(() => createItemMap(flattenedItems), [flattenedItems]);
|
|
1630
|
+
const projectedMove = React6.useMemo(
|
|
1631
|
+
() => getProjectedMove({
|
|
1632
|
+
activeId,
|
|
1633
|
+
canDrop,
|
|
1634
|
+
dragOffset,
|
|
1635
|
+
flattenedItems,
|
|
1636
|
+
indentWidth,
|
|
1637
|
+
items,
|
|
1638
|
+
maxDepth,
|
|
1639
|
+
overId,
|
|
1640
|
+
overItemRect: overId ? itemNodeRefs.current.get(overId)?.getBoundingClientRect() : null,
|
|
1641
|
+
pointerY: dragPointerY
|
|
1642
|
+
}),
|
|
1643
|
+
[
|
|
1644
|
+
activeId,
|
|
1645
|
+
canDrop,
|
|
1646
|
+
dragOffset,
|
|
1647
|
+
dragPointerY,
|
|
1648
|
+
flattenedItems,
|
|
1649
|
+
indentWidth,
|
|
1650
|
+
items,
|
|
1651
|
+
maxDepth,
|
|
1652
|
+
overId
|
|
1653
|
+
]
|
|
1654
|
+
);
|
|
1655
|
+
const sensors = useSensors(
|
|
1656
|
+
useSensor(PointerSensor, {
|
|
1657
|
+
activationConstraint: {
|
|
1658
|
+
distance: 6
|
|
1659
|
+
}
|
|
1660
|
+
})
|
|
1661
|
+
);
|
|
1662
|
+
React6.useEffect(() => {
|
|
1663
|
+
if (focusedId && itemMap.has(focusedId)) {
|
|
1664
|
+
return;
|
|
1665
|
+
}
|
|
1666
|
+
setFocusedId(
|
|
1667
|
+
selectedId && itemMap.has(selectedId) ? selectedId : flattenedItems[0]?.id ?? null
|
|
1668
|
+
);
|
|
1669
|
+
}, [flattenedItems, focusedId, itemMap, selectedId]);
|
|
1670
|
+
const registerItemButton = React6.useCallback((itemId, node) => {
|
|
1671
|
+
if (node) {
|
|
1672
|
+
itemButtonRefs.current.set(itemId, node);
|
|
1673
|
+
return;
|
|
1674
|
+
}
|
|
1675
|
+
itemButtonRefs.current.delete(itemId);
|
|
1676
|
+
}, []);
|
|
1677
|
+
const registerItemNode = React6.useCallback((itemId, node) => {
|
|
1678
|
+
if (node) {
|
|
1679
|
+
itemNodeRefs.current.set(itemId, node);
|
|
1680
|
+
return;
|
|
1681
|
+
}
|
|
1682
|
+
itemNodeRefs.current.delete(itemId);
|
|
1683
|
+
}, []);
|
|
1684
|
+
const focusItem = React6.useCallback((itemId) => {
|
|
1685
|
+
if (!itemId) {
|
|
1686
|
+
return;
|
|
1687
|
+
}
|
|
1688
|
+
setFocusedId(itemId);
|
|
1689
|
+
itemButtonRefs.current.get(itemId)?.focus();
|
|
1690
|
+
}, []);
|
|
1691
|
+
const getItemState = React6.useCallback(
|
|
1692
|
+
(itemId) => {
|
|
1693
|
+
const flattenedItem = itemMap.get(itemId);
|
|
1694
|
+
if (!flattenedItem) {
|
|
1695
|
+
throw new Error(`WorkbenchSidebarTree item "${itemId}" was not found.`);
|
|
1696
|
+
}
|
|
1697
|
+
return {
|
|
1698
|
+
item: flattenedItem.item,
|
|
1699
|
+
itemId,
|
|
1700
|
+
parentId: flattenedItem.parentId,
|
|
1701
|
+
index: flattenedItem.index,
|
|
1702
|
+
depth: flattenedItem.depth,
|
|
1703
|
+
isDisabled: flattenedItem.item.disabled === true,
|
|
1704
|
+
isDragging: activeId === itemId,
|
|
1705
|
+
isDropTarget: projectedMove?.overId === itemId,
|
|
1706
|
+
isExpanded: expandedIdSet.has(itemId),
|
|
1707
|
+
isExpandable: flattenedItem.childrenCount > 0,
|
|
1708
|
+
isFocused: focusedId === itemId,
|
|
1709
|
+
isSelected: selectedId === itemId
|
|
1710
|
+
};
|
|
1711
|
+
},
|
|
1712
|
+
[activeId, expandedIdSet, focusedId, itemMap, projectedMove?.overId, selectedId]
|
|
1713
|
+
);
|
|
1714
|
+
const getItemEvent = React6.useCallback(
|
|
1715
|
+
(itemId, originalEvent) => {
|
|
1716
|
+
const flattenedItem = itemMap.get(itemId);
|
|
1717
|
+
if (!flattenedItem) {
|
|
1718
|
+
throw new Error(`WorkbenchSidebarTree item "${itemId}" was not found.`);
|
|
1719
|
+
}
|
|
1720
|
+
return {
|
|
1721
|
+
item: flattenedItem.item,
|
|
1722
|
+
itemId,
|
|
1723
|
+
parentId: flattenedItem.parentId,
|
|
1724
|
+
index: flattenedItem.index,
|
|
1725
|
+
depth: flattenedItem.depth,
|
|
1726
|
+
expandedIds,
|
|
1727
|
+
selectedId,
|
|
1728
|
+
originalEvent
|
|
1729
|
+
};
|
|
1730
|
+
},
|
|
1731
|
+
[expandedIds, itemMap, selectedId]
|
|
1732
|
+
);
|
|
1733
|
+
const setItemExpanded = React6.useCallback(
|
|
1734
|
+
(itemId, expanded, originalEvent) => {
|
|
1735
|
+
const flattenedItem = itemMap.get(itemId);
|
|
1736
|
+
if (!flattenedItem || flattenedItem.item.disabled) {
|
|
1737
|
+
return;
|
|
1738
|
+
}
|
|
1739
|
+
if (!flattenedItem.childrenCount && !expanded) {
|
|
1740
|
+
return;
|
|
1741
|
+
}
|
|
1742
|
+
const nextExpandedIdSet = new Set(expandedIdSet);
|
|
1743
|
+
if (expanded) {
|
|
1744
|
+
nextExpandedIdSet.add(itemId);
|
|
1745
|
+
} else {
|
|
1746
|
+
nextExpandedIdSet.delete(itemId);
|
|
1747
|
+
}
|
|
1748
|
+
const nextExpandedIds = Array.from(nextExpandedIdSet);
|
|
1749
|
+
const itemEvent = getItemEvent(itemId, originalEvent);
|
|
1750
|
+
const expandedEvent = {
|
|
1751
|
+
...itemEvent,
|
|
1752
|
+
expanded,
|
|
1753
|
+
expandedIds: nextExpandedIds
|
|
1754
|
+
};
|
|
1755
|
+
if (expandedIdsProp === void 0) {
|
|
1756
|
+
setUncontrolledExpandedIds(nextExpandedIds);
|
|
1757
|
+
}
|
|
1758
|
+
onItemExpandedChange?.(expandedEvent);
|
|
1759
|
+
onExpandedIdsChange?.(nextExpandedIds, expandedEvent);
|
|
1760
|
+
},
|
|
1761
|
+
[
|
|
1762
|
+
expandedIdSet,
|
|
1763
|
+
expandedIdsProp,
|
|
1764
|
+
getItemEvent,
|
|
1765
|
+
itemMap,
|
|
1766
|
+
onExpandedIdsChange,
|
|
1767
|
+
onItemExpandedChange
|
|
1768
|
+
]
|
|
1769
|
+
);
|
|
1770
|
+
const toggleItemExpanded = React6.useCallback(
|
|
1771
|
+
(itemId, originalEvent) => {
|
|
1772
|
+
setItemExpanded(itemId, !expandedIdSet.has(itemId), originalEvent);
|
|
1773
|
+
},
|
|
1774
|
+
[expandedIdSet, setItemExpanded]
|
|
1775
|
+
);
|
|
1776
|
+
const selectItem = React6.useCallback(
|
|
1777
|
+
(itemId, originalEvent) => {
|
|
1778
|
+
const flattenedItem = itemMap.get(itemId);
|
|
1779
|
+
if (!flattenedItem || flattenedItem.item.disabled || flattenedItem.item.selectable === false) {
|
|
1780
|
+
return;
|
|
1781
|
+
}
|
|
1782
|
+
const itemEvent = getItemEvent(itemId, originalEvent);
|
|
1783
|
+
if (selectedIdProp === void 0) {
|
|
1784
|
+
setUncontrolledSelectedId(itemId);
|
|
1785
|
+
}
|
|
1786
|
+
onItemSelect?.(itemEvent);
|
|
1787
|
+
onSelectedIdChange?.(itemId, itemEvent);
|
|
1788
|
+
},
|
|
1789
|
+
[getItemEvent, itemMap, onItemSelect, onSelectedIdChange, selectedIdProp]
|
|
1790
|
+
);
|
|
1791
|
+
const handleItemClick = React6.useCallback(
|
|
1792
|
+
(itemId, originalEvent) => {
|
|
1793
|
+
const flattenedItem = itemMap.get(itemId);
|
|
1794
|
+
if (!flattenedItem || flattenedItem.item.disabled) {
|
|
1795
|
+
return;
|
|
1796
|
+
}
|
|
1797
|
+
setFocusedId(itemId);
|
|
1798
|
+
onItemClick?.(getItemEvent(itemId, originalEvent));
|
|
1799
|
+
selectItem(itemId, originalEvent);
|
|
1800
|
+
},
|
|
1801
|
+
[getItemEvent, itemMap, onItemClick, selectItem]
|
|
1802
|
+
);
|
|
1803
|
+
const commitKeyboardMove = React6.useCallback(
|
|
1804
|
+
(itemId, direction) => {
|
|
1805
|
+
const moveEvent = moveItemWithKeyboard({
|
|
1806
|
+
activeId: itemId,
|
|
1807
|
+
canDrop,
|
|
1808
|
+
direction,
|
|
1809
|
+
expandedIdSet,
|
|
1810
|
+
items,
|
|
1811
|
+
maxDepth
|
|
1812
|
+
});
|
|
1813
|
+
if (!moveEvent) {
|
|
1814
|
+
return;
|
|
1815
|
+
}
|
|
1816
|
+
if (direction === "right") {
|
|
1817
|
+
const parentId = moveEvent.toParentId;
|
|
1818
|
+
if (parentId) {
|
|
1819
|
+
setItemExpanded(parentId, true);
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
onMove?.(moveEvent);
|
|
1823
|
+
},
|
|
1824
|
+
[canDrop, expandedIdSet, items, maxDepth, onMove, setItemExpanded]
|
|
1825
|
+
);
|
|
1826
|
+
const handleItemKeyDown = React6.useCallback(
|
|
1827
|
+
(itemId, event) => {
|
|
1828
|
+
const currentIndex = flattenedItems.findIndex((item) => item.id === itemId);
|
|
1829
|
+
const currentItem = itemMap.get(itemId);
|
|
1830
|
+
if (!currentItem || currentIndex < 0) {
|
|
1831
|
+
return;
|
|
1832
|
+
}
|
|
1833
|
+
if (event.altKey && reorderable) {
|
|
1834
|
+
const keyboardDirectionByKey = {
|
|
1835
|
+
ArrowUp: "up",
|
|
1836
|
+
ArrowDown: "down",
|
|
1837
|
+
ArrowLeft: "left",
|
|
1838
|
+
ArrowRight: "right"
|
|
1839
|
+
};
|
|
1840
|
+
const direction = keyboardDirectionByKey[event.key];
|
|
1841
|
+
if (direction) {
|
|
1842
|
+
event.preventDefault();
|
|
1843
|
+
commitKeyboardMove(itemId, direction);
|
|
1844
|
+
}
|
|
1845
|
+
return;
|
|
1846
|
+
}
|
|
1847
|
+
switch (event.key) {
|
|
1848
|
+
case "ArrowDown":
|
|
1849
|
+
event.preventDefault();
|
|
1850
|
+
focusItem(flattenedItems[currentIndex + 1]?.id ?? itemId);
|
|
1851
|
+
return;
|
|
1852
|
+
case "ArrowUp":
|
|
1853
|
+
event.preventDefault();
|
|
1854
|
+
focusItem(flattenedItems[currentIndex - 1]?.id ?? itemId);
|
|
1855
|
+
return;
|
|
1856
|
+
case "ArrowRight":
|
|
1857
|
+
if (currentItem.childrenCount && !expandedIdSet.has(itemId)) {
|
|
1858
|
+
event.preventDefault();
|
|
1859
|
+
setItemExpanded(itemId, true, event);
|
|
1860
|
+
return;
|
|
1861
|
+
}
|
|
1862
|
+
if (currentItem.childrenCount) {
|
|
1863
|
+
event.preventDefault();
|
|
1864
|
+
focusItem(flattenedItems[currentIndex + 1]?.id ?? itemId);
|
|
1865
|
+
}
|
|
1866
|
+
return;
|
|
1867
|
+
case "ArrowLeft":
|
|
1868
|
+
if (currentItem.childrenCount && expandedIdSet.has(itemId)) {
|
|
1869
|
+
event.preventDefault();
|
|
1870
|
+
setItemExpanded(itemId, false, event);
|
|
1871
|
+
return;
|
|
1872
|
+
}
|
|
1873
|
+
if (currentItem.parentId) {
|
|
1874
|
+
event.preventDefault();
|
|
1875
|
+
focusItem(currentItem.parentId);
|
|
1876
|
+
}
|
|
1877
|
+
return;
|
|
1878
|
+
case "Home":
|
|
1879
|
+
event.preventDefault();
|
|
1880
|
+
focusItem(flattenedItems[0]?.id ?? itemId);
|
|
1881
|
+
return;
|
|
1882
|
+
case "End":
|
|
1883
|
+
event.preventDefault();
|
|
1884
|
+
focusItem(flattenedItems.at(-1)?.id ?? itemId);
|
|
1885
|
+
return;
|
|
1886
|
+
case "Enter":
|
|
1887
|
+
case " ":
|
|
1888
|
+
event.preventDefault();
|
|
1889
|
+
handleItemClick(itemId, event);
|
|
1890
|
+
return;
|
|
1891
|
+
default:
|
|
1892
|
+
}
|
|
1893
|
+
},
|
|
1894
|
+
[
|
|
1895
|
+
commitKeyboardMove,
|
|
1896
|
+
expandedIdSet,
|
|
1897
|
+
flattenedItems,
|
|
1898
|
+
focusItem,
|
|
1899
|
+
handleItemClick,
|
|
1900
|
+
itemMap,
|
|
1901
|
+
reorderable,
|
|
1902
|
+
setItemExpanded
|
|
1903
|
+
]
|
|
1904
|
+
);
|
|
1905
|
+
const handleDragStart = React6.useCallback(
|
|
1906
|
+
(event) => {
|
|
1907
|
+
const itemId = String(event.active.id);
|
|
1908
|
+
const flattenedItem = itemMap.get(itemId);
|
|
1909
|
+
if (!flattenedItem || flattenedItem.item.disabled || flattenedItem.item.draggable === false) {
|
|
1910
|
+
return;
|
|
1911
|
+
}
|
|
1912
|
+
setActiveId(itemId);
|
|
1913
|
+
setOverId(itemId);
|
|
1914
|
+
setDragOffset(0);
|
|
1915
|
+
const itemRect = itemNodeRefs.current.get(itemId)?.getBoundingClientRect();
|
|
1916
|
+
const itemCenter = getItemRectCenter(itemRect);
|
|
1917
|
+
const startPointer = getEventClientCoordinates(event.activatorEvent);
|
|
1918
|
+
dragStartPointerRef.current = startPointer ?? (itemCenter ? { x: 0, y: itemCenter.y } : null);
|
|
1919
|
+
setDragPointerY(dragStartPointerRef.current?.y ?? null);
|
|
1920
|
+
setDragOverlayWidth(itemRect?.width ?? null);
|
|
1921
|
+
},
|
|
1922
|
+
[itemMap]
|
|
1923
|
+
);
|
|
1924
|
+
const handleDragMove = React6.useCallback((event) => {
|
|
1925
|
+
setDragOffset(event.delta.x);
|
|
1926
|
+
setDragPointerY(
|
|
1927
|
+
dragStartPointerRef.current ? dragStartPointerRef.current.y + event.delta.y : null
|
|
1928
|
+
);
|
|
1929
|
+
}, []);
|
|
1930
|
+
const handleDragOver = React6.useCallback((event) => {
|
|
1931
|
+
setOverId(event.over ? String(event.over.id) : null);
|
|
1932
|
+
setDragPointerY(
|
|
1933
|
+
dragStartPointerRef.current ? dragStartPointerRef.current.y + event.delta.y : null
|
|
1934
|
+
);
|
|
1935
|
+
}, []);
|
|
1936
|
+
const handleDragEnd = React6.useCallback(
|
|
1937
|
+
(event) => {
|
|
1938
|
+
const nextOverId = event.over ? String(event.over.id) : null;
|
|
1939
|
+
const nextProjectedMove = getProjectedMove({
|
|
1940
|
+
activeId: String(event.active.id),
|
|
1941
|
+
canDrop,
|
|
1942
|
+
dragOffset: event.delta.x,
|
|
1943
|
+
flattenedItems,
|
|
1944
|
+
indentWidth,
|
|
1945
|
+
items,
|
|
1946
|
+
maxDepth,
|
|
1947
|
+
overId: nextOverId,
|
|
1948
|
+
overItemRect: event.over?.rect ?? (nextOverId ? itemNodeRefs.current.get(nextOverId)?.getBoundingClientRect() : null),
|
|
1949
|
+
pointerY: dragStartPointerRef.current ? dragStartPointerRef.current.y + event.delta.y : null
|
|
1950
|
+
});
|
|
1951
|
+
setActiveId(null);
|
|
1952
|
+
setOverId(null);
|
|
1953
|
+
setDragOffset(0);
|
|
1954
|
+
setDragPointerY(null);
|
|
1955
|
+
setDragOverlayWidth(null);
|
|
1956
|
+
dragStartPointerRef.current = null;
|
|
1957
|
+
if (!nextProjectedMove) {
|
|
1958
|
+
return;
|
|
1959
|
+
}
|
|
1960
|
+
const { overId: overId2, indicatorId, ...moveEvent } = nextProjectedMove;
|
|
1961
|
+
void overId2;
|
|
1962
|
+
void indicatorId;
|
|
1963
|
+
if (moveEvent.placement === "inside" && moveEvent.toParentId) {
|
|
1964
|
+
setItemExpanded(moveEvent.toParentId, true);
|
|
1965
|
+
}
|
|
1966
|
+
onMove?.(moveEvent);
|
|
1967
|
+
},
|
|
1968
|
+
[canDrop, flattenedItems, indentWidth, items, maxDepth, onMove, setItemExpanded]
|
|
1969
|
+
);
|
|
1970
|
+
const handleDragCancel = React6.useCallback(() => {
|
|
1971
|
+
setActiveId(null);
|
|
1972
|
+
setOverId(null);
|
|
1973
|
+
setDragOffset(0);
|
|
1974
|
+
setDragPointerY(null);
|
|
1975
|
+
setDragOverlayWidth(null);
|
|
1976
|
+
dragStartPointerRef.current = null;
|
|
1977
|
+
}, []);
|
|
1978
|
+
const contextValue = React6.useMemo(
|
|
1979
|
+
() => ({
|
|
1980
|
+
items,
|
|
1981
|
+
flattenedItems,
|
|
1982
|
+
itemMap,
|
|
1983
|
+
selectedId,
|
|
1984
|
+
expandedIdSet,
|
|
1985
|
+
expandedIds,
|
|
1986
|
+
focusedId,
|
|
1987
|
+
activeId,
|
|
1988
|
+
overId,
|
|
1989
|
+
projectedMove,
|
|
1990
|
+
dragOverlayWidth,
|
|
1991
|
+
reorderable,
|
|
1992
|
+
indentWidth,
|
|
1993
|
+
maxDepth,
|
|
1994
|
+
registerItemButton,
|
|
1995
|
+
registerItemNode,
|
|
1996
|
+
focusItem,
|
|
1997
|
+
getItemState,
|
|
1998
|
+
getItemEvent,
|
|
1999
|
+
selectItem,
|
|
2000
|
+
toggleItemExpanded,
|
|
2001
|
+
setItemExpanded,
|
|
2002
|
+
handleItemClick,
|
|
2003
|
+
handleItemKeyDown
|
|
2004
|
+
}),
|
|
2005
|
+
[
|
|
2006
|
+
activeId,
|
|
2007
|
+
dragOverlayWidth,
|
|
2008
|
+
expandedIdSet,
|
|
2009
|
+
expandedIds,
|
|
2010
|
+
flattenedItems,
|
|
2011
|
+
focusItem,
|
|
2012
|
+
focusedId,
|
|
2013
|
+
getItemEvent,
|
|
2014
|
+
getItemState,
|
|
2015
|
+
handleItemClick,
|
|
2016
|
+
handleItemKeyDown,
|
|
2017
|
+
indentWidth,
|
|
2018
|
+
itemMap,
|
|
2019
|
+
items,
|
|
2020
|
+
maxDepth,
|
|
2021
|
+
overId,
|
|
2022
|
+
projectedMove,
|
|
2023
|
+
registerItemButton,
|
|
2024
|
+
registerItemNode,
|
|
2025
|
+
reorderable,
|
|
2026
|
+
selectItem,
|
|
2027
|
+
selectedId,
|
|
2028
|
+
setItemExpanded,
|
|
2029
|
+
toggleItemExpanded
|
|
2030
|
+
]
|
|
2031
|
+
);
|
|
2032
|
+
const content = /* @__PURE__ */ jsx8(WorkbenchSidebarTreeContext.Provider, { value: contextValue, children });
|
|
2033
|
+
if (!reorderable) {
|
|
2034
|
+
return content;
|
|
2035
|
+
}
|
|
2036
|
+
return /* @__PURE__ */ jsx8(
|
|
2037
|
+
DndContext,
|
|
2038
|
+
{
|
|
2039
|
+
sensors,
|
|
2040
|
+
collisionDetection: treeCollisionDetection,
|
|
2041
|
+
onDragStart: handleDragStart,
|
|
2042
|
+
onDragMove: handleDragMove,
|
|
2043
|
+
onDragOver: handleDragOver,
|
|
2044
|
+
onDragEnd: handleDragEnd,
|
|
2045
|
+
onDragCancel: handleDragCancel,
|
|
2046
|
+
children: content
|
|
2047
|
+
}
|
|
2048
|
+
);
|
|
2049
|
+
}
|
|
2050
|
+
function WorkbenchSidebarTree({
|
|
2051
|
+
items,
|
|
2052
|
+
selectedId,
|
|
2053
|
+
defaultSelectedId,
|
|
2054
|
+
expandedIds,
|
|
2055
|
+
defaultExpandedIds,
|
|
2056
|
+
reorderable,
|
|
2057
|
+
maxDepth,
|
|
2058
|
+
indentWidth,
|
|
2059
|
+
canDrop,
|
|
2060
|
+
onItemClick,
|
|
2061
|
+
onItemSelect,
|
|
2062
|
+
onSelectedIdChange,
|
|
2063
|
+
onItemExpandedChange,
|
|
2064
|
+
onExpandedIdsChange,
|
|
2065
|
+
onMove,
|
|
2066
|
+
renderItem,
|
|
2067
|
+
className,
|
|
2068
|
+
...props
|
|
2069
|
+
}) {
|
|
2070
|
+
return /* @__PURE__ */ jsx8(
|
|
2071
|
+
WorkbenchSidebarTreeProvider,
|
|
2072
|
+
{
|
|
2073
|
+
items,
|
|
2074
|
+
selectedId,
|
|
2075
|
+
defaultSelectedId,
|
|
2076
|
+
expandedIds,
|
|
2077
|
+
defaultExpandedIds,
|
|
2078
|
+
reorderable,
|
|
2079
|
+
maxDepth,
|
|
2080
|
+
indentWidth,
|
|
2081
|
+
canDrop,
|
|
2082
|
+
onItemClick,
|
|
2083
|
+
onItemSelect,
|
|
2084
|
+
onSelectedIdChange,
|
|
2085
|
+
onItemExpandedChange,
|
|
2086
|
+
onExpandedIdsChange,
|
|
2087
|
+
onMove,
|
|
2088
|
+
children: /* @__PURE__ */ jsx8(WorkbenchSidebarTreeItems, { className, renderItem, ...props })
|
|
2089
|
+
}
|
|
2090
|
+
);
|
|
2091
|
+
}
|
|
2092
|
+
function WorkbenchSidebarTreeItems({
|
|
2093
|
+
className,
|
|
2094
|
+
renderItem,
|
|
2095
|
+
...props
|
|
2096
|
+
}) {
|
|
2097
|
+
const tree = useWorkbenchSidebarTreeContext();
|
|
2098
|
+
const itemIds = React6.useMemo(
|
|
2099
|
+
() => tree.flattenedItems.map((item) => item.id),
|
|
2100
|
+
[tree.flattenedItems]
|
|
2101
|
+
);
|
|
2102
|
+
return /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
2103
|
+
/* @__PURE__ */ jsx8(SortableContext, { items: itemIds, strategy: verticalListSortingStrategy, children: /* @__PURE__ */ jsx8(
|
|
2104
|
+
WorkbenchSidebarMenu,
|
|
2105
|
+
{
|
|
2106
|
+
role: "tree",
|
|
2107
|
+
"data-slot": "workbench-sidebar-tree",
|
|
2108
|
+
"data-sidebar": "tree",
|
|
2109
|
+
className: cn("gap-0.5", className),
|
|
2110
|
+
...props,
|
|
2111
|
+
children: tree.flattenedItems.map((item) => /* @__PURE__ */ jsx8(WorkbenchSidebarTreeRow, { itemId: item.id, renderItem }, item.id))
|
|
2112
|
+
}
|
|
2113
|
+
) }),
|
|
2114
|
+
tree.reorderable ? /* @__PURE__ */ jsx8(WorkbenchSidebarTreeDragOverlay, { renderItem }) : null
|
|
2115
|
+
] });
|
|
2116
|
+
}
|
|
2117
|
+
function WorkbenchSidebarTreeItemContent({
|
|
2118
|
+
buttonProps,
|
|
2119
|
+
disclosureProps,
|
|
2120
|
+
leadingVisual,
|
|
2121
|
+
renderItem,
|
|
2122
|
+
rowProps,
|
|
2123
|
+
state,
|
|
2124
|
+
trailingVisual
|
|
2125
|
+
}) {
|
|
2126
|
+
const hasCustomTrailingAction = Boolean(trailingVisual);
|
|
2127
|
+
const defaultNode = /* @__PURE__ */ jsxs4(WorkbenchSidebarMenuRow, { ...rowProps, children: [
|
|
2128
|
+
disclosureProps.visible ? /* @__PURE__ */ jsx8(WorkbenchSidebarMenuLeadingAction, { ...disclosureProps, children: /* @__PURE__ */ jsx8(ChevronRightIcon, { className: "transition-transform duration-150 ease-out" }) }) : null,
|
|
2129
|
+
/* @__PURE__ */ jsx8(
|
|
2130
|
+
WorkbenchSidebarMenuButton,
|
|
2131
|
+
{
|
|
2132
|
+
...buttonProps,
|
|
2133
|
+
isActive: state.isSelected,
|
|
2134
|
+
tooltip: state.item.tooltip,
|
|
2135
|
+
leadingVisual,
|
|
2136
|
+
trailingVisual: !hasCustomTrailingAction ? null : void 0,
|
|
2137
|
+
trailingVisualVisibility: "hover",
|
|
2138
|
+
children: state.item.label
|
|
2139
|
+
}
|
|
2140
|
+
),
|
|
2141
|
+
hasCustomTrailingAction ? /* @__PURE__ */ jsx8(
|
|
2142
|
+
WorkbenchSidebarMenuTrailingAction,
|
|
2143
|
+
{
|
|
2144
|
+
type: "button",
|
|
2145
|
+
showOnHover: true,
|
|
2146
|
+
onClick: (event) => event.stopPropagation(),
|
|
2147
|
+
children: trailingVisual
|
|
2148
|
+
}
|
|
2149
|
+
) : null
|
|
2150
|
+
] });
|
|
2151
|
+
return renderItem ? renderItem({
|
|
2152
|
+
state,
|
|
2153
|
+
rowProps,
|
|
2154
|
+
buttonProps,
|
|
2155
|
+
disclosureProps,
|
|
2156
|
+
leadingVisual,
|
|
2157
|
+
trailingVisual
|
|
2158
|
+
}) : defaultNode;
|
|
2159
|
+
}
|
|
2160
|
+
function WorkbenchSidebarTreeDragOverlay({
|
|
2161
|
+
renderItem
|
|
2162
|
+
}) {
|
|
2163
|
+
const tree = useWorkbenchSidebarTreeContext();
|
|
2164
|
+
if (!tree.activeId || !tree.itemMap.has(tree.activeId)) {
|
|
2165
|
+
return /* @__PURE__ */ jsx8(DragOverlay, { dropAnimation: null, children: null });
|
|
2166
|
+
}
|
|
2167
|
+
const state = tree.getItemState(tree.activeId);
|
|
2168
|
+
const leadingVisual = resolveVisual(state.item.leadingVisual, state);
|
|
2169
|
+
const trailingVisual = resolveVisual(state.item.trailingVisual, state);
|
|
2170
|
+
const rowProps = {
|
|
2171
|
+
style: {
|
|
2172
|
+
marginLeft: `${state.depth * tree.indentWidth}px`
|
|
2173
|
+
}
|
|
2174
|
+
};
|
|
2175
|
+
const buttonProps = {
|
|
2176
|
+
type: "button",
|
|
2177
|
+
tabIndex: -1,
|
|
2178
|
+
role: "treeitem",
|
|
2179
|
+
"aria-level": state.depth + 1,
|
|
2180
|
+
"aria-selected": state.isSelected,
|
|
2181
|
+
"aria-expanded": state.isExpandable ? state.isExpanded : void 0,
|
|
2182
|
+
"aria-disabled": state.isDisabled || void 0,
|
|
2183
|
+
"data-workbench-sidebar-tree-item-id": state.itemId,
|
|
2184
|
+
"data-tree-item-id": state.itemId,
|
|
2185
|
+
"data-drag-overlay": true,
|
|
2186
|
+
"data-selected": state.isSelected || void 0,
|
|
2187
|
+
"data-expanded": state.isExpanded || void 0,
|
|
2188
|
+
className: "cursor-grabbing bg-sidedock-hover-background text-sidedock-text-hover shadow-lg ring-1 ring-sidedock-border"
|
|
2189
|
+
};
|
|
2190
|
+
const disclosureProps = {
|
|
2191
|
+
type: "button",
|
|
2192
|
+
visible: state.isExpandable,
|
|
2193
|
+
"aria-label": state.isExpanded ? `Collapse ${String(state.item.label)}` : `Expand ${String(state.item.label)}`,
|
|
2194
|
+
"aria-expanded": state.isExpanded,
|
|
2195
|
+
tabIndex: -1,
|
|
2196
|
+
className: "data-[expanded=true]:bg-transparent data-[expanded=true]:[&>svg]:rotate-90 data-[expanded=false]:[&>svg]:rotate-0",
|
|
2197
|
+
"data-expanded": state.isExpanded,
|
|
2198
|
+
onClick: (event) => event.stopPropagation()
|
|
2199
|
+
};
|
|
2200
|
+
return /* @__PURE__ */ jsx8(DragOverlay, { dropAnimation: null, children: /* @__PURE__ */ jsx8(
|
|
2201
|
+
"div",
|
|
2202
|
+
{
|
|
2203
|
+
"data-slot": "workbench-sidebar-tree-drag-overlay",
|
|
2204
|
+
className: "pointer-events-none opacity-[0.85]",
|
|
2205
|
+
style: {
|
|
2206
|
+
width: tree.dragOverlayWidth ?? void 0
|
|
2207
|
+
},
|
|
2208
|
+
children: /* @__PURE__ */ jsx8(
|
|
2209
|
+
WorkbenchSidebarTreeItemContent,
|
|
2210
|
+
{
|
|
2211
|
+
state,
|
|
2212
|
+
rowProps,
|
|
2213
|
+
buttonProps,
|
|
2214
|
+
disclosureProps,
|
|
2215
|
+
leadingVisual,
|
|
2216
|
+
trailingVisual,
|
|
2217
|
+
renderItem
|
|
2218
|
+
}
|
|
2219
|
+
)
|
|
2220
|
+
}
|
|
2221
|
+
) });
|
|
2222
|
+
}
|
|
2223
|
+
function WorkbenchSidebarTreeRow({
|
|
2224
|
+
itemId,
|
|
2225
|
+
renderItem
|
|
2226
|
+
}) {
|
|
2227
|
+
const tree = useWorkbenchSidebarTreeContext();
|
|
2228
|
+
const state = tree.getItemState(itemId);
|
|
2229
|
+
const { attributes, listeners, setNodeRef, isDragging, isSorting } = useSortable({
|
|
2230
|
+
id: itemId,
|
|
2231
|
+
disabled: !tree.reorderable || state.isDisabled || state.item.draggable === false
|
|
2232
|
+
});
|
|
2233
|
+
const isTabbable = tree.focusedId === itemId || !tree.focusedId && (state.isSelected || tree.flattenedItems[0]?.id === itemId);
|
|
2234
|
+
const leadingVisual = resolveVisual(state.item.leadingVisual, state);
|
|
2235
|
+
const trailingVisual = resolveVisual(state.item.trailingVisual, state);
|
|
2236
|
+
const isInsideDropTarget = tree.projectedMove?.placement === "inside" && tree.projectedMove.overId === itemId;
|
|
2237
|
+
const showDropIndicator = tree.projectedMove?.indicatorId === itemId && !isInsideDropTarget;
|
|
2238
|
+
const projectedDepth = showDropIndicator ? tree.projectedMove?.depth : state.depth;
|
|
2239
|
+
const dropIndicatorPlacement = tree.projectedMove?.placement ?? "after";
|
|
2240
|
+
const { registerItemNode } = tree;
|
|
2241
|
+
const setItemNodeRef = React6.useCallback(
|
|
2242
|
+
(node) => {
|
|
2243
|
+
setNodeRef(node);
|
|
2244
|
+
registerItemNode(itemId, node);
|
|
2245
|
+
},
|
|
2246
|
+
[itemId, registerItemNode, setNodeRef]
|
|
2247
|
+
);
|
|
2248
|
+
const rowProps = {
|
|
2249
|
+
style: {
|
|
2250
|
+
marginLeft: `${state.depth * tree.indentWidth}px`
|
|
2251
|
+
}
|
|
2252
|
+
};
|
|
2253
|
+
const buttonProps = {
|
|
2254
|
+
...attributes,
|
|
2255
|
+
...listeners,
|
|
2256
|
+
type: "button",
|
|
2257
|
+
disabled: state.isDisabled,
|
|
2258
|
+
tabIndex: isTabbable ? 0 : -1,
|
|
2259
|
+
role: "treeitem",
|
|
2260
|
+
"aria-level": state.depth + 1,
|
|
2261
|
+
"aria-selected": state.isSelected,
|
|
2262
|
+
"aria-expanded": state.isExpandable ? state.isExpanded : void 0,
|
|
2263
|
+
"aria-disabled": state.isDisabled || void 0,
|
|
2264
|
+
"data-workbench-sidebar-tree-item-id": itemId,
|
|
2265
|
+
"data-tree-item-id": itemId,
|
|
2266
|
+
"data-selected": state.isSelected || void 0,
|
|
2267
|
+
"data-expanded": state.isExpanded || void 0,
|
|
2268
|
+
"data-dragging": isDragging || void 0,
|
|
2269
|
+
"data-drop-inside": isInsideDropTarget || void 0,
|
|
2270
|
+
className: cn(
|
|
2271
|
+
!state.isExpandable && "pl-7",
|
|
2272
|
+
isDragging && "opacity-40",
|
|
2273
|
+
state.isDropTarget && "bg-sidedock-hover-background text-sidedock-text-hover",
|
|
2274
|
+
isInsideDropTarget && "bg-sidedock-active-background text-sidedock-text-active ring-sidedock-border ring-1"
|
|
2275
|
+
),
|
|
2276
|
+
onClick: (event) => tree.handleItemClick(itemId, event),
|
|
2277
|
+
onFocus: () => tree.focusItem(itemId),
|
|
2278
|
+
onKeyDown: (event) => tree.handleItemKeyDown(itemId, event),
|
|
2279
|
+
ref: (node) => tree.registerItemButton(itemId, node)
|
|
2280
|
+
};
|
|
2281
|
+
const disclosureProps = {
|
|
2282
|
+
type: "button",
|
|
2283
|
+
visible: state.isExpandable,
|
|
2284
|
+
"aria-label": state.isExpanded ? `Collapse ${String(state.item.label)}` : `Expand ${String(state.item.label)}`,
|
|
2285
|
+
"aria-expanded": state.isExpanded,
|
|
2286
|
+
tabIndex: -1,
|
|
2287
|
+
className: "data-[expanded=true]:bg-transparent data-[expanded=true]:[&>svg]:rotate-90 data-[expanded=false]:[&>svg]:rotate-0",
|
|
2288
|
+
"data-expanded": state.isExpanded,
|
|
2289
|
+
onClick: (event) => {
|
|
2290
|
+
event.stopPropagation();
|
|
2291
|
+
tree.toggleItemExpanded(itemId, event);
|
|
2292
|
+
}
|
|
2293
|
+
};
|
|
2294
|
+
return /* @__PURE__ */ jsxs4(
|
|
2295
|
+
WorkbenchSidebarMenuItem,
|
|
2296
|
+
{
|
|
2297
|
+
ref: setItemNodeRef,
|
|
2298
|
+
"data-slot": "workbench-sidebar-tree-item",
|
|
2299
|
+
"data-tree-item-id": itemId,
|
|
2300
|
+
"data-depth": state.depth,
|
|
2301
|
+
"data-dragging": isDragging || void 0,
|
|
2302
|
+
"data-drop-inside": isInsideDropTarget || void 0,
|
|
2303
|
+
"data-sorting": isSorting || void 0,
|
|
2304
|
+
children: [
|
|
2305
|
+
state.depth > 0 ? Array.from({ length: state.depth }, (_, depthIndex) => /* @__PURE__ */ jsx8(
|
|
2306
|
+
"span",
|
|
2307
|
+
{
|
|
2308
|
+
"aria-hidden": "true",
|
|
2309
|
+
"data-slot": "workbench-sidebar-tree-depth-line",
|
|
2310
|
+
className: "border-sidedock-border pointer-events-none absolute inset-y-0 z-0 border-l",
|
|
2311
|
+
style: {
|
|
2312
|
+
left: `${8 + depthIndex * tree.indentWidth}px`
|
|
2313
|
+
}
|
|
2314
|
+
},
|
|
2315
|
+
depthIndex
|
|
2316
|
+
)) : null,
|
|
2317
|
+
showDropIndicator ? /* @__PURE__ */ jsx8(
|
|
2318
|
+
"div",
|
|
2319
|
+
{
|
|
2320
|
+
"data-slot": "workbench-sidebar-tree-drop-indicator",
|
|
2321
|
+
"data-placement": dropIndicatorPlacement,
|
|
2322
|
+
className: cn(
|
|
2323
|
+
"bg-sidedock-text-active pointer-events-none absolute right-1 left-1 z-[1] h-0.5 rounded-full",
|
|
2324
|
+
dropIndicatorPlacement === "before" ? "-top-px" : "-bottom-px"
|
|
2325
|
+
),
|
|
2326
|
+
style: {
|
|
2327
|
+
left: `${8 + (projectedDepth ?? state.depth) * tree.indentWidth}px`
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
) : null,
|
|
2331
|
+
/* @__PURE__ */ jsx8(
|
|
2332
|
+
WorkbenchSidebarTreeItemContent,
|
|
2333
|
+
{
|
|
2334
|
+
state,
|
|
2335
|
+
rowProps,
|
|
2336
|
+
buttonProps,
|
|
2337
|
+
disclosureProps,
|
|
2338
|
+
leadingVisual,
|
|
2339
|
+
trailingVisual,
|
|
2340
|
+
renderItem
|
|
2341
|
+
}
|
|
2342
|
+
)
|
|
2343
|
+
]
|
|
2344
|
+
}
|
|
2345
|
+
);
|
|
2346
|
+
}
|
|
2347
|
+
|
|
2348
|
+
// src/layouts/workbench/core/hooks/useWorkbenchPrimarySidebar.tsx
|
|
2349
|
+
import React7 from "react";
|
|
2350
|
+
function useWorkbenchPrimarySidebar2() {
|
|
2351
|
+
const context = React7.useContext(WorkbenchPrimarySidebarContext);
|
|
2352
|
+
if (!context) {
|
|
2353
|
+
throw new Error(
|
|
2354
|
+
"useWorkbenchPrimarySidebar must be used within a WorkbenchPrimarySidebarProvider"
|
|
2355
|
+
);
|
|
2356
|
+
}
|
|
2357
|
+
return context;
|
|
2358
|
+
}
|
|
2359
|
+
|
|
2360
|
+
// src/layouts/workbench/core/components/sidebar/WorkbenchPrimarySidebar.tsx
|
|
2361
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
2362
|
+
function WorkbenchPrimarySidebar(props) {
|
|
2363
|
+
const { isMobile, openMobile, setOpenMobile, state, toggleSidebar } = useWorkbenchPrimarySidebar2();
|
|
2364
|
+
return /* @__PURE__ */ jsx9(
|
|
2365
|
+
WorkbenchSidebarShell,
|
|
2366
|
+
{
|
|
2367
|
+
...props,
|
|
2368
|
+
description: "Displays the primary workbench sidebar on mobile.",
|
|
2369
|
+
isMobile,
|
|
2370
|
+
openMobile,
|
|
2371
|
+
setOpenMobile,
|
|
2372
|
+
side: "left",
|
|
2373
|
+
state,
|
|
2374
|
+
title: "Primary Sidebar",
|
|
2375
|
+
toggleSidebar
|
|
2376
|
+
}
|
|
2377
|
+
);
|
|
2378
|
+
}
|
|
2379
|
+
|
|
2380
|
+
// src/layouts/workbench/core/hooks/useWorkbenchSecondarySidebar.tsx
|
|
2381
|
+
import React8 from "react";
|
|
2382
|
+
function useWorkbenchSecondarySidebar2() {
|
|
2383
|
+
const context = React8.useContext(WorkbenchSecondarySidebarContext);
|
|
2384
|
+
if (!context) {
|
|
2385
|
+
throw new Error(
|
|
2386
|
+
"useWorkbenchSecondarySidebar must be used within a WorkbenchSecondarySidebarProvider"
|
|
2387
|
+
);
|
|
2388
|
+
}
|
|
2389
|
+
return context;
|
|
2390
|
+
}
|
|
2391
|
+
|
|
2392
|
+
// src/layouts/workbench/core/components/sidebar/WorkbenchSecondarySidebar.tsx
|
|
2393
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
2394
|
+
function WorkbenchSecondarySidebar(props) {
|
|
2395
|
+
const { isMobile, openMobile, setOpenMobile, state, toggleSidebar } = useWorkbenchSecondarySidebar2();
|
|
2396
|
+
return /* @__PURE__ */ jsx10(
|
|
2397
|
+
WorkbenchSidebarShell,
|
|
2398
|
+
{
|
|
2399
|
+
...props,
|
|
2400
|
+
description: "Displays the secondary workbench sidebar on mobile.",
|
|
2401
|
+
isMobile,
|
|
2402
|
+
openMobile,
|
|
2403
|
+
setOpenMobile,
|
|
2404
|
+
side: "right",
|
|
2405
|
+
state,
|
|
2406
|
+
title: "Secondary Sidebar",
|
|
2407
|
+
toggleSidebar
|
|
2408
|
+
}
|
|
2409
|
+
);
|
|
2410
|
+
}
|
|
2411
|
+
export {
|
|
2412
|
+
WORKBENCH_RIBBON_BAR_WIDTH,
|
|
2413
|
+
Workbench,
|
|
2414
|
+
WorkbenchContentArea,
|
|
2415
|
+
WorkbenchContextAreaRail,
|
|
2416
|
+
WorkbenchPanelGroup,
|
|
2417
|
+
WorkbenchPrimarySidebar,
|
|
2418
|
+
WorkbenchPrimarySidebarContext,
|
|
2419
|
+
WorkbenchPrimarySidebarProvider,
|
|
2420
|
+
WorkbenchProvider,
|
|
2421
|
+
WorkbenchRibbonBar,
|
|
2422
|
+
WorkbenchRibbonBarButton,
|
|
2423
|
+
WorkbenchRibbonBarContent,
|
|
2424
|
+
WorkbenchRibbonBarFooter,
|
|
2425
|
+
WorkbenchRibbonBarHeader,
|
|
2426
|
+
WorkbenchRibbonBarSeparator,
|
|
2427
|
+
WorkbenchSecondarySidebar,
|
|
2428
|
+
WorkbenchSecondarySidebarContext,
|
|
2429
|
+
WorkbenchSecondarySidebarProvider,
|
|
2430
|
+
WorkbenchSidebarContent,
|
|
2431
|
+
WorkbenchSidebarFooter,
|
|
2432
|
+
WorkbenchSidebarGroup,
|
|
2433
|
+
WorkbenchSidebarGroupAction,
|
|
2434
|
+
WorkbenchSidebarGroupContent,
|
|
2435
|
+
WorkbenchSidebarGroupLabel,
|
|
2436
|
+
WorkbenchSidebarHeader,
|
|
2437
|
+
WorkbenchSidebarMenu,
|
|
2438
|
+
WorkbenchSidebarMenuBadge,
|
|
2439
|
+
WorkbenchSidebarMenuButton,
|
|
2440
|
+
WorkbenchSidebarMenuItem,
|
|
2441
|
+
WorkbenchSidebarMenuLeadingAction,
|
|
2442
|
+
WorkbenchSidebarMenuRow,
|
|
2443
|
+
WorkbenchSidebarMenuSkeleton,
|
|
2444
|
+
WorkbenchSidebarMenuSub,
|
|
2445
|
+
WorkbenchSidebarMenuSubButton,
|
|
2446
|
+
WorkbenchSidebarMenuSubItem,
|
|
2447
|
+
WorkbenchSidebarMenuTrailingAction,
|
|
2448
|
+
WorkbenchSidebarSeparator,
|
|
2449
|
+
WorkbenchSidebarShell,
|
|
2450
|
+
WorkbenchSidebarTree,
|
|
2451
|
+
WorkbenchSidebarTreeProvider,
|
|
2452
|
+
useWorkbenchPrimarySidebar,
|
|
2453
|
+
useWorkbenchSecondarySidebar,
|
|
2454
|
+
useWorkbenchSidebarTree,
|
|
2455
|
+
useWorkbenchSidebarTreeItem
|
|
2456
|
+
};
|
|
2457
|
+
//# sourceMappingURL=index.js.map
|