@noya-app/noya-designsystem 0.1.68 → 0.1.70
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/.turbo/turbo-build.log +9 -9
- package/CHANGELOG.md +19 -0
- package/dist/index.css +1 -1
- package/dist/index.d.mts +23 -1
- package/dist/index.d.ts +23 -1
- package/dist/index.js +152 -83
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +152 -83
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
- package/src/components/Button.tsx +2 -1
- package/src/components/Collection.tsx +9 -0
- package/src/components/DraggableMenuButton.tsx +5 -0
- package/src/components/InputField.tsx +2 -2
- package/src/components/List.tsx +14 -3
- package/src/components/Stepper.tsx +35 -12
- package/src/components/TreeView.tsx +25 -1
- package/src/components/workspace/DrawerWorkspaceLayout.tsx +97 -55
- package/src/components/workspace/PanelWorkspaceLayout.tsx +12 -4
- package/src/components/workspace/VerticalTabMenu.tsx +1 -1
- package/src/components/workspace/WorkspaceLayout.tsx +7 -0
- package/src/components/workspace/types.ts +7 -0
- package/src/index.css +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noya-app/noya-designsystem",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.70",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
"@base-ui-components/react": "1.0.0-beta.4",
|
|
24
24
|
"@dnd-kit/core": "6.3.1",
|
|
25
25
|
"@dnd-kit/sortable": "10.0.0",
|
|
26
|
-
"@noya-app/noya-colorpicker": "0.1.
|
|
27
|
-
"@noya-app/noya-utils": "0.1.
|
|
28
|
-
"@noya-app/noya-geometry": "0.1.
|
|
29
|
-
"@noya-app/noya-icons": "0.1.
|
|
26
|
+
"@noya-app/noya-colorpicker": "0.1.30",
|
|
27
|
+
"@noya-app/noya-utils": "0.1.9",
|
|
28
|
+
"@noya-app/noya-geometry": "0.1.16",
|
|
29
|
+
"@noya-app/noya-icons": "0.1.15",
|
|
30
30
|
"@noya-app/noya-keymap": "0.1.4",
|
|
31
|
-
"@noya-app/noya-tailwind-config": "0.1.
|
|
31
|
+
"@noya-app/noya-tailwind-config": "0.1.8",
|
|
32
32
|
"radix-ui": "1.4.2",
|
|
33
33
|
"@radix-ui/react-compose-refs": "^1.0.0",
|
|
34
34
|
"@radix-ui/primitive": "^1.0.1",
|
|
@@ -14,7 +14,7 @@ import { Spacer } from "./Spacer";
|
|
|
14
14
|
import { Tooltip } from "./Tooltip";
|
|
15
15
|
import type { MenuItemIcon } from "./internal/Menu";
|
|
16
16
|
|
|
17
|
-
type ButtonVariant = "normal" | "thin" | "floating" | "none" | "ghost";
|
|
17
|
+
type ButtonVariant = "normal" | "thin" | "floating" | "none" | "ghost" | "link";
|
|
18
18
|
|
|
19
19
|
type ButtonSize = "small" | "normal" | "large" | "floating";
|
|
20
20
|
|
|
@@ -36,6 +36,7 @@ const variantStyles: Record<ButtonVariant, string> = {
|
|
|
36
36
|
thin: "n-bg-transparent n-text-text hover:n-bg-input-background-light",
|
|
37
37
|
none: "n-bg-transparent n-text-text hover:n-bg-input-background-light",
|
|
38
38
|
ghost: "n-bg-transparent n-text-text hover:n-bg-input-background-light",
|
|
39
|
+
link: "n-bg-transparent n-text-text hover:n-bg-input-background-light",
|
|
39
40
|
};
|
|
40
41
|
|
|
41
42
|
const sizeStyles: Record<ButtonSize | "thin" | "none", string> = {
|
|
@@ -82,6 +82,10 @@ export interface CollectionProps<T, M extends string = string> {
|
|
|
82
82
|
scrollable?: boolean;
|
|
83
83
|
itemStyle?: CSSProperties;
|
|
84
84
|
itemClassName?: string;
|
|
85
|
+
/** Optional per-item style */
|
|
86
|
+
getItemStyle?: (item: T, selected: boolean) => CSSProperties | undefined;
|
|
87
|
+
/** Optional per-item className */
|
|
88
|
+
getItemClassName?: (item: T, selected: boolean) => string | undefined;
|
|
85
89
|
itemRoleDescription?: string;
|
|
86
90
|
/** Position of the detail content. Defaults to 'end'. */
|
|
87
91
|
detailPosition?: "end" | "below";
|
|
@@ -89,6 +93,11 @@ export interface CollectionProps<T, M extends string = string> {
|
|
|
89
93
|
size?: CollectionItemSize;
|
|
90
94
|
/** Size of the thumbnail. Defaults to 'auto', which will be based on the size prop. */
|
|
91
95
|
thumbnailSize?: CollectionThumbnailSize;
|
|
96
|
+
/**
|
|
97
|
+
* Position of the disclosure chevron for expandable lists.
|
|
98
|
+
* @default 'start'
|
|
99
|
+
*/
|
|
100
|
+
chevronPosition?: "start" | "end";
|
|
92
101
|
/** For testing: Override the hover state with a specific item ID */
|
|
93
102
|
testHoveredId?: string;
|
|
94
103
|
/** For testing: Override the renaming state with a specific item ID */
|
|
@@ -70,6 +70,11 @@ export const DraggableMenuButton = memoGeneric(function DraggableMenuButton<
|
|
|
70
70
|
(event: React.PointerEvent) => {
|
|
71
71
|
if (open || !downPosition) {
|
|
72
72
|
setDownPosition(null);
|
|
73
|
+
|
|
74
|
+
// if the button was clicked directly, close the menu
|
|
75
|
+
if (open && event.target === event.currentTarget) {
|
|
76
|
+
setOpen(false);
|
|
77
|
+
}
|
|
73
78
|
return;
|
|
74
79
|
}
|
|
75
80
|
|
|
@@ -552,8 +552,8 @@ function InputFieldRoot({
|
|
|
552
552
|
[onFocusChange]
|
|
553
553
|
);
|
|
554
554
|
|
|
555
|
-
const startWidth = measuredStartSize?.width
|
|
556
|
-
const endWidth = measuredEndSize?.width
|
|
555
|
+
const startWidth = startWidthProp ?? measuredStartSize?.width;
|
|
556
|
+
const endWidth = endWidthProp ?? measuredEndSize?.width;
|
|
557
557
|
|
|
558
558
|
const contextValue = useMemo(
|
|
559
559
|
(): InputFieldContextValue => ({
|
package/src/components/List.tsx
CHANGED
|
@@ -88,6 +88,9 @@ export const List = memoGeneric(
|
|
|
88
88
|
sharedDragProps,
|
|
89
89
|
virtualized,
|
|
90
90
|
renameSelectsBeforeDot,
|
|
91
|
+
chevronPosition = "start",
|
|
92
|
+
getItemStyle,
|
|
93
|
+
getItemClassName,
|
|
91
94
|
} = props;
|
|
92
95
|
|
|
93
96
|
const [internalHoveredId, setHoveredId] = useState<string>();
|
|
@@ -249,6 +252,9 @@ export const List = memoGeneric(
|
|
|
249
252
|
</div>
|
|
250
253
|
);
|
|
251
254
|
}
|
|
255
|
+
const perItemStyle = getItemStyle?.(item, isSelected);
|
|
256
|
+
const perItemClassName = getItemClassName?.(item, isSelected);
|
|
257
|
+
|
|
252
258
|
return (
|
|
253
259
|
<ViewComponent.Row
|
|
254
260
|
as={typeof href === "string" ? LinkComponent : undefined}
|
|
@@ -260,13 +266,18 @@ export const List = memoGeneric(
|
|
|
260
266
|
aria-roledescription={itemRoleDescription}
|
|
261
267
|
aria-label={getName(item)}
|
|
262
268
|
aria-selected={isSelected}
|
|
263
|
-
className={itemClassName}
|
|
269
|
+
className={cx(itemClassName, perItemClassName)}
|
|
264
270
|
testRelativeDropPosition={
|
|
265
271
|
testShowDropIndicatorId === id ? "inside" : undefined
|
|
266
272
|
}
|
|
267
|
-
chevronClassName={cx(
|
|
273
|
+
chevronClassName={cx(
|
|
274
|
+
expandable && chevronPosition !== "end" && "n-relative n-left-2"
|
|
275
|
+
)}
|
|
268
276
|
chevronAs={href ? "div" : undefined}
|
|
269
|
-
|
|
277
|
+
{...(expandable ? { chevronPosition } : {})}
|
|
278
|
+
style={
|
|
279
|
+
perItemStyle ? { ...itemStyle, ...perItemStyle } : itemStyle
|
|
280
|
+
}
|
|
270
281
|
hovered={isHovered}
|
|
271
282
|
selected={isSelected}
|
|
272
283
|
expanded={expanded}
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
import { clamp } from "@noya-app/noya-utils";
|
|
4
4
|
import React, { FocusEventHandler, memo, useCallback, useMemo } from "react";
|
|
5
5
|
import { useLabel } from "../hooks/useLabel";
|
|
6
|
+
import { cssVars } from "../theme";
|
|
6
7
|
import { cx } from "../utils/classNames";
|
|
7
|
-
import {
|
|
8
|
+
import { IconButton } from "./IconButton";
|
|
8
9
|
import { InputField } from "./InputField";
|
|
9
10
|
|
|
10
11
|
type ColorScheme = "primary" | "secondary";
|
|
@@ -65,12 +66,39 @@ export const Stepper = memo(function Stepper({
|
|
|
65
66
|
onFocus={onFocus}
|
|
66
67
|
onBlur={onBlur}
|
|
67
68
|
>
|
|
68
|
-
<
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
<InputField.Root
|
|
70
|
+
className="n-flex-1"
|
|
71
|
+
startWidth={17}
|
|
72
|
+
startClassName="-n-ml-[3px]"
|
|
73
|
+
endWidth={17}
|
|
74
|
+
endClassName="-n-mr-[3px]"
|
|
75
|
+
start={
|
|
76
|
+
<IconButton
|
|
77
|
+
iconName="MinusIcon"
|
|
78
|
+
disabled={readOnly}
|
|
79
|
+
onClick={() => handleValueChange(value - step)}
|
|
80
|
+
className="n-w-[21px] n-h-[21px]"
|
|
81
|
+
style={{
|
|
82
|
+
outline: `1px solid ${cssVars.colors.dividerStrong}`,
|
|
83
|
+
outlineOffset: "-1px",
|
|
84
|
+
background: cssVars.colors.background,
|
|
85
|
+
}}
|
|
86
|
+
/>
|
|
87
|
+
}
|
|
88
|
+
end={
|
|
89
|
+
<IconButton
|
|
90
|
+
iconName="PlusIcon"
|
|
91
|
+
disabled={readOnly}
|
|
92
|
+
onClick={() => handleValueChange(value + step)}
|
|
93
|
+
className="n-w-[21px] n-h-[21px]"
|
|
94
|
+
style={{
|
|
95
|
+
outline: `1px solid ${cssVars.colors.dividerStrong}`,
|
|
96
|
+
outlineOffset: "-1px",
|
|
97
|
+
background: cssVars.colors.background,
|
|
98
|
+
}}
|
|
99
|
+
/>
|
|
100
|
+
}
|
|
101
|
+
>
|
|
74
102
|
<InputField.NumberInput
|
|
75
103
|
value={value}
|
|
76
104
|
onChange={handleValueChange}
|
|
@@ -78,11 +106,6 @@ export const Stepper = memo(function Stepper({
|
|
|
78
106
|
readOnly={readOnly}
|
|
79
107
|
/>
|
|
80
108
|
</InputField.Root>
|
|
81
|
-
<Button
|
|
82
|
-
icon="PlusIcon"
|
|
83
|
-
disabled={readOnly}
|
|
84
|
-
onClick={() => handleValueChange(value + step)}
|
|
85
|
-
/>
|
|
86
109
|
</div>
|
|
87
110
|
);
|
|
88
111
|
});
|
|
@@ -21,6 +21,7 @@ type TreeRowBaseProps = {
|
|
|
21
21
|
expanded?: boolean;
|
|
22
22
|
chevronClassName?: string;
|
|
23
23
|
chevronAs?: React.ElementType;
|
|
24
|
+
chevronPosition?: "start" | "end";
|
|
24
25
|
onClickChevron?: ({ altKey }: { altKey: boolean }) => void;
|
|
25
26
|
onDoubleClick?: () => void;
|
|
26
27
|
};
|
|
@@ -35,6 +36,7 @@ const TreeRow = forwardRefGeneric(function TreeRow<MenuItemType extends string>(
|
|
|
35
36
|
onClickChevron,
|
|
36
37
|
chevronClassName,
|
|
37
38
|
chevronAs,
|
|
39
|
+
chevronPosition = "start",
|
|
38
40
|
children,
|
|
39
41
|
...rest
|
|
40
42
|
}: TreeViewRowProps<MenuItemType>,
|
|
@@ -55,7 +57,7 @@ const TreeRow = forwardRefGeneric(function TreeRow<MenuItemType extends string>(
|
|
|
55
57
|
|
|
56
58
|
return (
|
|
57
59
|
<ListView.Row ref={forwardedRef} {...rest}>
|
|
58
|
-
{expandable && (
|
|
60
|
+
{expandable && chevronPosition !== "end" && (
|
|
59
61
|
<>
|
|
60
62
|
{expanded === undefined ? (
|
|
61
63
|
<Spacer.Horizontal size={19} />
|
|
@@ -78,6 +80,28 @@ const TreeRow = forwardRefGeneric(function TreeRow<MenuItemType extends string>(
|
|
|
78
80
|
</>
|
|
79
81
|
)}
|
|
80
82
|
{children}
|
|
83
|
+
{expandable && chevronPosition === "end" && (
|
|
84
|
+
<>
|
|
85
|
+
<Spacer.Horizontal size={6} />
|
|
86
|
+
{expanded === undefined ? (
|
|
87
|
+
<>
|
|
88
|
+
{/* Right-side padding not needed for end chevron since no text needs to be aligned */}
|
|
89
|
+
</>
|
|
90
|
+
) : (
|
|
91
|
+
<>
|
|
92
|
+
<IconButton
|
|
93
|
+
as={chevronAs}
|
|
94
|
+
className={chevronClassName}
|
|
95
|
+
iconName={expanded ? "ChevronDownIcon2" : "ChevronRightIcon2"}
|
|
96
|
+
onClick={handleClickChevron}
|
|
97
|
+
selected={rest.selected}
|
|
98
|
+
/>
|
|
99
|
+
{/* Right-side padding for end chevron */}
|
|
100
|
+
<Spacer.Horizontal size={8} />
|
|
101
|
+
</>
|
|
102
|
+
)}
|
|
103
|
+
</>
|
|
104
|
+
)}
|
|
81
105
|
</ListView.Row>
|
|
82
106
|
);
|
|
83
107
|
});
|
|
@@ -6,8 +6,9 @@ import { DividerVertical } from "../Divider";
|
|
|
6
6
|
import { Drawer } from "../Drawer";
|
|
7
7
|
import { isSelectableMenuItem, MenuItem } from "../internal/Menu";
|
|
8
8
|
import { EDITOR_PANEL_GROUP_ID, RIGHT_SIDEBAR_ID } from "./constants";
|
|
9
|
-
import { LayoutProps, PanelLayoutState } from "./types";
|
|
9
|
+
import { LayoutProps, PanelLayoutState, SidebarRef } from "./types";
|
|
10
10
|
import { VerticalTabMenu } from "./VerticalTabMenu";
|
|
11
|
+
import { Button } from "../Button";
|
|
11
12
|
|
|
12
13
|
export const DrawerWorkspaceLayout = memoGeneric(function DrawerWorkspaceLayout<
|
|
13
14
|
LeftTab extends string = string,
|
|
@@ -24,6 +25,7 @@ export const DrawerWorkspaceLayout = memoGeneric(function DrawerWorkspaceLayout<
|
|
|
24
25
|
rightTabValue,
|
|
25
26
|
onChangeRightTab,
|
|
26
27
|
onChangeLeftTab,
|
|
28
|
+
compactDrawerMenu,
|
|
27
29
|
}: LayoutProps<LeftTab, RightTab>) {
|
|
28
30
|
const portalContainer = useRef<HTMLDivElement>(null);
|
|
29
31
|
|
|
@@ -44,6 +46,14 @@ export const DrawerWorkspaceLayout = memoGeneric(function DrawerWorkspaceLayout<
|
|
|
44
46
|
|
|
45
47
|
const hasTabs = allTabItems.length > 0;
|
|
46
48
|
|
|
49
|
+
// Determine if we should use the compact top-row menu variant.
|
|
50
|
+
const allSelectableTabItems = useMemo(
|
|
51
|
+
() => allTabItems.filter(isSelectableMenuItem),
|
|
52
|
+
[allTabItems]
|
|
53
|
+
);
|
|
54
|
+
const useCompactInToolbar =
|
|
55
|
+
!!compactDrawerMenu && allSelectableTabItems.length <= 1;
|
|
56
|
+
|
|
47
57
|
const leftSelectableTabItems = useMemo(
|
|
48
58
|
() => (leftTabItems ?? []).filter(isSelectableMenuItem),
|
|
49
59
|
[leftTabItems]
|
|
@@ -54,6 +64,39 @@ export const DrawerWorkspaceLayout = memoGeneric(function DrawerWorkspaceLayout<
|
|
|
54
64
|
[rightTabItems]
|
|
55
65
|
);
|
|
56
66
|
|
|
67
|
+
// Shared helpers for expanding/collapsing drawers
|
|
68
|
+
const toggleSidebar = (ref: React.RefObject<SidebarRef | null>) => {
|
|
69
|
+
if (ref.current?.isExpanded()) {
|
|
70
|
+
ref.current?.collapse();
|
|
71
|
+
} else {
|
|
72
|
+
ref.current?.expand();
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const ensureExpanded = (ref: React.RefObject<SidebarRef | null>) => {
|
|
77
|
+
if (!ref.current?.isExpanded()) {
|
|
78
|
+
ref.current?.expand();
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const handleSelectTab = (value: LeftTab | RightTab) => {
|
|
83
|
+
if (leftSelectableTabItems.some((item) => item.value === value)) {
|
|
84
|
+
if (value === leftTabValue) {
|
|
85
|
+
toggleSidebar(leftSidebarRef);
|
|
86
|
+
} else {
|
|
87
|
+
ensureExpanded(leftSidebarRef);
|
|
88
|
+
onChangeLeftTab?.(value as LeftTab);
|
|
89
|
+
}
|
|
90
|
+
} else if (rightSelectableTabItems.some((item) => item.value === value)) {
|
|
91
|
+
if (value === rightTabValue) {
|
|
92
|
+
toggleSidebar(rightSidebarRef);
|
|
93
|
+
} else {
|
|
94
|
+
ensureExpanded(rightSidebarRef);
|
|
95
|
+
onChangeRightTab?.(value as RightTab);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
57
100
|
const { activeValue, isSidebarCollapsed } =
|
|
58
101
|
leftSelectableTabItems.length > 0 && !leftSidebarCollapsed
|
|
59
102
|
? { activeValue: leftTabValue, isSidebarCollapsed: leftSidebarCollapsed }
|
|
@@ -70,60 +113,60 @@ export const DrawerWorkspaceLayout = memoGeneric(function DrawerWorkspaceLayout<
|
|
|
70
113
|
id={EDITOR_PANEL_GROUP_ID}
|
|
71
114
|
className="n-flex n-flex-1 n-relative focus:n-outline-none"
|
|
72
115
|
>
|
|
73
|
-
{hasTabs && (
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
rightSidebarRef.current?.collapse();
|
|
100
|
-
} else {
|
|
101
|
-
rightSidebarRef.current?.expand();
|
|
102
|
-
}
|
|
103
|
-
} else {
|
|
104
|
-
if (!rightSidebarRef.current?.isExpanded()) {
|
|
105
|
-
rightSidebarRef.current?.expand();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
onChangeRightTab?.(value as RightTab);
|
|
116
|
+
{hasTabs && !useCompactInToolbar && (
|
|
117
|
+
<>
|
|
118
|
+
<VerticalTabMenu
|
|
119
|
+
tooltipSide="right"
|
|
120
|
+
items={allTabItems}
|
|
121
|
+
activeValue={activeValue}
|
|
122
|
+
isSidebarCollapsed={isSidebarCollapsed}
|
|
123
|
+
onChange={(value) => handleSelectTab(value as LeftTab | RightTab)}
|
|
124
|
+
/>
|
|
125
|
+
<DividerVertical className="n-h-full" />
|
|
126
|
+
</>
|
|
127
|
+
)}
|
|
128
|
+
|
|
129
|
+
{useCompactInToolbar && (
|
|
130
|
+
<div className="n-absolute n-top-0 n-left-0 n-h-[calc(var(--n-toolbar-height)+1px)] n-w-[calc(var(--n-toolbar-height)+1px)] n-bg-sidebar-background n-border-r n-border-b n-border-divider-strong n-z-10 n-flex n-items-center n-justify-center">
|
|
131
|
+
{allSelectableTabItems[0] && (
|
|
132
|
+
<Button
|
|
133
|
+
variant="none"
|
|
134
|
+
className="n-rounded"
|
|
135
|
+
style={{
|
|
136
|
+
width: "var(--n-input-height)",
|
|
137
|
+
height: "var(--n-input-height)",
|
|
138
|
+
}}
|
|
139
|
+
icon={allSelectableTabItems[0].icon}
|
|
140
|
+
tooltip={
|
|
141
|
+
allSelectableTabItems[0].tooltip ?? allSelectableTabItems[0].title
|
|
109
142
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
143
|
+
active={(() => {
|
|
144
|
+
const value = allSelectableTabItems[0].value as LeftTab | RightTab;
|
|
145
|
+
const isLeftItem = leftSelectableTabItems.some((i) => i.value === value);
|
|
146
|
+
const isRightItem = rightSelectableTabItems.some((i) => i.value === value);
|
|
147
|
+
return isLeftItem ? !leftSidebarCollapsed : isRightItem ? !rightSidebarCollapsed : false;
|
|
148
|
+
})()}
|
|
149
|
+
onClick={() => {
|
|
150
|
+
const value = allSelectableTabItems[0].value as LeftTab | RightTab;
|
|
151
|
+
handleSelectTab(value);
|
|
152
|
+
}}
|
|
153
|
+
/>
|
|
154
|
+
)}
|
|
155
|
+
</div>
|
|
113
156
|
)}
|
|
114
|
-
|
|
157
|
+
|
|
115
158
|
<div className="n-flex-1 n-flex n-relative">{centerPanel}</div>
|
|
159
|
+
|
|
116
160
|
{leftPanel && (
|
|
117
161
|
<Drawer
|
|
118
162
|
ref={leftSidebarRef}
|
|
119
163
|
className="n-flex-1"
|
|
120
|
-
style={
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}}
|
|
164
|
+
style={
|
|
165
|
+
useCompactInToolbar
|
|
166
|
+
? undefined
|
|
167
|
+
: { left: 48, maxWidth: "calc(100% - 48px)" }
|
|
168
|
+
}
|
|
169
|
+
overlayStyle={useCompactInToolbar ? undefined : { left: 48 }}
|
|
127
170
|
open={!leftSidebarCollapsed}
|
|
128
171
|
positioning="absolute"
|
|
129
172
|
side="left"
|
|
@@ -144,13 +187,12 @@ export const DrawerWorkspaceLayout = memoGeneric(function DrawerWorkspaceLayout<
|
|
|
144
187
|
id={RIGHT_SIDEBAR_ID}
|
|
145
188
|
ref={rightSidebarRef}
|
|
146
189
|
className="n-flex-1"
|
|
147
|
-
style={
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}}
|
|
190
|
+
style={
|
|
191
|
+
useCompactInToolbar
|
|
192
|
+
? undefined
|
|
193
|
+
: { left: 48, maxWidth: "calc(100% - 48px)" }
|
|
194
|
+
}
|
|
195
|
+
overlayStyle={useCompactInToolbar ? undefined : { left: 48 }}
|
|
154
196
|
open={!rightSidebarCollapsed}
|
|
155
197
|
positioning="absolute"
|
|
156
198
|
side="left"
|
|
@@ -52,6 +52,7 @@ export const PanelWorkspaceLayout = memoGeneric(function PanelWorkspaceLayout<
|
|
|
52
52
|
rightTabValue,
|
|
53
53
|
onChangeLeftTab,
|
|
54
54
|
onChangeRightTab,
|
|
55
|
+
compactDrawerMenu,
|
|
55
56
|
}: LayoutProps<LeftTab, RightTab>) {
|
|
56
57
|
const panelGroupRef = useRef<ImperativePanelGroupHandle>(null);
|
|
57
58
|
|
|
@@ -159,6 +160,13 @@ export const PanelWorkspaceLayout = memoGeneric(function PanelWorkspaceLayout<
|
|
|
159
160
|
[setData, propertyKey]
|
|
160
161
|
);
|
|
161
162
|
|
|
163
|
+
const showLeftTabs =
|
|
164
|
+
!!leftSidebarOptions.showTabs &&
|
|
165
|
+
!!leftTabItems &&
|
|
166
|
+
// When compact drawer UI is enabled, only show the rail when the
|
|
167
|
+
// sidebar is collapsed (for large screens/panel layout).
|
|
168
|
+
(!compactDrawerMenu || leftSidebarCollapsed);
|
|
169
|
+
|
|
162
170
|
return (
|
|
163
171
|
<PanelGroup
|
|
164
172
|
ref={panelGroupRef}
|
|
@@ -171,7 +179,7 @@ export const PanelWorkspaceLayout = memoGeneric(function PanelWorkspaceLayout<
|
|
|
171
179
|
>
|
|
172
180
|
{leftPanel && (
|
|
173
181
|
<>
|
|
174
|
-
{
|
|
182
|
+
{showLeftTabs && (
|
|
175
183
|
<VerticalTabMenu
|
|
176
184
|
tooltipSide="right"
|
|
177
185
|
items={leftTabItems}
|
|
@@ -180,9 +188,9 @@ export const PanelWorkspaceLayout = memoGeneric(function PanelWorkspaceLayout<
|
|
|
180
188
|
onChange={handleLeftTabChange}
|
|
181
189
|
/>
|
|
182
190
|
)}
|
|
183
|
-
{
|
|
184
|
-
|
|
185
|
-
|
|
191
|
+
{showLeftTabs && !leftSidebarCollapsed && (
|
|
192
|
+
<DividerVertical className="n-h-full" />
|
|
193
|
+
)}
|
|
186
194
|
<Panel
|
|
187
195
|
id={LEFT_SIDEBAR_ID}
|
|
188
196
|
className="n-relative"
|
|
@@ -31,7 +31,7 @@ export const VerticalTabMenu = memoGeneric(function VerticalTabMenu<
|
|
|
31
31
|
|
|
32
32
|
return (
|
|
33
33
|
<div
|
|
34
|
-
className="n-w-[
|
|
34
|
+
className="n-w-[calc(var(--n-toolbar-height)+1px)] n-h-full n-bg-sidebar-background n-flex n-flex-col n-items-center n-py-3 n-gap-3"
|
|
35
35
|
style={style}
|
|
36
36
|
>
|
|
37
37
|
<ToolbarMenu
|
|
@@ -57,6 +57,11 @@ export interface WorkspaceLayoutProps<
|
|
|
57
57
|
sideType?: SideType;
|
|
58
58
|
sideTypeBreakpoint?: number;
|
|
59
59
|
detectSize?: DetectSizeType;
|
|
60
|
+
/**
|
|
61
|
+
* Use a compact top-row menu in Drawer (mobile) layout instead of a
|
|
62
|
+
* full-height left menu. Useful when there is only a single icon.
|
|
63
|
+
*/
|
|
64
|
+
compactDrawerMenu?: boolean;
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
export type WorkspaceLayoutRef = {
|
|
@@ -147,6 +152,7 @@ export const WorkspaceLayout = forwardRefGeneric(function WorkspaceLayout<
|
|
|
147
152
|
showTabs: rightShowTabs = true,
|
|
148
153
|
} = {},
|
|
149
154
|
theme,
|
|
155
|
+
compactDrawerMenu,
|
|
150
156
|
}: WorkspaceLayoutProps<LeftTab, RightTab>,
|
|
151
157
|
forwardedRef: React.ForwardedRef<WorkspaceLayoutRef>
|
|
152
158
|
) {
|
|
@@ -446,6 +452,7 @@ export const WorkspaceLayout = forwardRefGeneric(function WorkspaceLayout<
|
|
|
446
452
|
autoSavePrefix={autoSavePrefix}
|
|
447
453
|
leftSidebarRef={leftSidebarRef}
|
|
448
454
|
rightSidebarRef={rightSidebarRef}
|
|
455
|
+
compactDrawerMenu={compactDrawerMenu}
|
|
449
456
|
/>
|
|
450
457
|
)}
|
|
451
458
|
</div>
|
|
@@ -51,6 +51,13 @@ export type LayoutProps<
|
|
|
51
51
|
autoSavePrefix?: string;
|
|
52
52
|
leftSidebarRef: React.RefObject<SidebarRef | null>;
|
|
53
53
|
rightSidebarRef: React.RefObject<SidebarRef | null>;
|
|
54
|
+
/**
|
|
55
|
+
* When using the Drawer (mobile) layout, render the vertical tab menu
|
|
56
|
+
* in a compact top row whose height equals the toolbar height.
|
|
57
|
+
* Intended for scenarios with a single icon to avoid reserving
|
|
58
|
+
* full-height left-side space.
|
|
59
|
+
*/
|
|
60
|
+
compactDrawerMenu?: boolean;
|
|
54
61
|
};
|
|
55
62
|
|
|
56
63
|
export type WorkspaceLayoutGroup = {
|
package/src/index.css
CHANGED
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
--n-active-background: var(--n-indigo-150);
|
|
92
92
|
--n-thumbnail-background: #f0efff;
|
|
93
93
|
--n-thumbnail-shadow: #d3ceed66;
|
|
94
|
-
--n-banner-info-background: var(--n-indigo-
|
|
94
|
+
--n-banner-info-background: var(--n-indigo-25);
|
|
95
95
|
--n-banner-info-border: var(--n-divider-strong);
|
|
96
96
|
--n-banner-info-text: #6579aa;
|
|
97
97
|
--n-banner-error-background: #ffe2e2;
|