@stll/workspace-ui 0.10.5 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/view-switcher.d.ts +6 -2
- package/dist/view-switcher.js +31 -7
- package/package.json +3 -3
package/dist/view-switcher.d.ts
CHANGED
|
@@ -25,8 +25,12 @@ export type WorkspaceViewSwitcherProps<View extends WorkspaceViewSwitcherItem> =
|
|
|
25
25
|
onViewChange: (viewId: string) => void;
|
|
26
26
|
onViewContextMenu?: (view: View, event: React.MouseEvent<HTMLElement>) => void;
|
|
27
27
|
onViewDoubleClick?: (view: View, event: React.MouseEvent<HTMLElement>) => void;
|
|
28
|
-
|
|
28
|
+
actionMenu?: {
|
|
29
|
+
label: string;
|
|
30
|
+
renderItems: (view: View) => React.ReactNode;
|
|
31
|
+
onOpenChange?: (view: View, open: boolean) => void;
|
|
32
|
+
};
|
|
29
33
|
renderIcon: (view: View) => React.ReactNode;
|
|
30
34
|
};
|
|
31
|
-
export declare const WorkspaceViewSwitcher: <View extends WorkspaceViewSwitcherItem>({ activeViewId, ariaLabel, direction, reorder, views, addControl, editing, onViewChange, onViewContextMenu, onViewDoubleClick,
|
|
35
|
+
export declare const WorkspaceViewSwitcher: <View extends WorkspaceViewSwitcherItem>({ activeViewId, ariaLabel, direction, reorder, views, addControl, editing, onViewChange, onViewContextMenu, onViewDoubleClick, actionMenu, renderIcon }: WorkspaceViewSwitcherProps<View>) => import("react").JSX.Element;
|
|
32
36
|
//#endregion
|
package/dist/view-switcher.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { reorderWorkspaceViewIds, toWorkspaceViewDropPosition } from "./view-switcher.logic.js";
|
|
3
|
+
import { EllipsisVerticalIcon } from "lucide-react";
|
|
4
|
+
import { Button } from "@stll/ui/button";
|
|
5
|
+
import { Menu, MenuPopup, MenuTrigger } from "@stll/ui/menu";
|
|
3
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
7
|
import { cn } from "@stll/ui/utils";
|
|
5
8
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
@@ -19,13 +22,34 @@ const useLatestCallback = (callback) => {
|
|
|
19
22
|
}, [callback]);
|
|
20
23
|
return useCallback((...args) => latest.current(...args), []);
|
|
21
24
|
};
|
|
22
|
-
const WorkspaceViewSwitcher = ({ activeViewId, ariaLabel, direction, reorder, views, addControl, editing, onViewChange, onViewContextMenu, onViewDoubleClick,
|
|
25
|
+
const WorkspaceViewSwitcher = ({ activeViewId, ariaLabel, direction, reorder, views, addControl, editing, onViewChange, onViewContextMenu, onViewDoubleClick, actionMenu, renderIcon }) => {
|
|
26
|
+
const [openMenuId, setOpenMenuId] = useState(null);
|
|
23
27
|
const canReorder = reorder !== null;
|
|
24
|
-
const viewTabs = views.map((view) =>
|
|
25
|
-
view
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
const viewTabs = views.map((view) => {
|
|
29
|
+
const items = actionMenu?.renderItems(view);
|
|
30
|
+
return {
|
|
31
|
+
view,
|
|
32
|
+
actions: actionMenu && items !== null && items !== void 0 && typeof items !== "boolean" ? /* @__PURE__ */ jsxs(Menu, {
|
|
33
|
+
onOpenChange: (open) => {
|
|
34
|
+
setOpenMenuId((currentId) => {
|
|
35
|
+
if (open) return view.id;
|
|
36
|
+
return currentId === view.id ? null : currentId;
|
|
37
|
+
});
|
|
38
|
+
actionMenu.onOpenChange?.(view, open);
|
|
39
|
+
},
|
|
40
|
+
children: [/* @__PURE__ */ jsx(MenuTrigger, {
|
|
41
|
+
"aria-label": actionMenu.label,
|
|
42
|
+
render: /* @__PURE__ */ jsx(Button, {
|
|
43
|
+
draggable: false,
|
|
44
|
+
size: "icon-xs",
|
|
45
|
+
variant: "ghost"
|
|
46
|
+
}),
|
|
47
|
+
children: /* @__PURE__ */ jsx(EllipsisVerticalIcon, {})
|
|
48
|
+
}), /* @__PURE__ */ jsx(MenuPopup, { children: items })]
|
|
49
|
+
}) : null
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
const reserveActionSpace = viewTabs.some(({ actions }) => actions !== null);
|
|
29
53
|
const [instanceId] = useState(Symbol);
|
|
30
54
|
const [stripContainer, setStripContainer] = useState(null);
|
|
31
55
|
useEffect(() => {
|
|
@@ -78,7 +102,7 @@ const WorkspaceViewSwitcher = ({ activeViewId, ariaLabel, direction, reorder, vi
|
|
|
78
102
|
direction,
|
|
79
103
|
getDragData: reorder?.getDragData,
|
|
80
104
|
getDropData: reorder?.getDropData,
|
|
81
|
-
isDragBlocked: reorder?.isBlocked ?? false,
|
|
105
|
+
isDragBlocked: openMenuId !== null || (reorder?.isBlocked ?? false),
|
|
82
106
|
instanceId,
|
|
83
107
|
onContextMenu: onViewContextMenu,
|
|
84
108
|
onDoubleClick: onViewDoubleClick,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/workspace-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Reusable workspace presentation components and view helpers for Stella.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"calculations",
|
|
@@ -117,9 +117,9 @@
|
|
|
117
117
|
},
|
|
118
118
|
"dependencies": {
|
|
119
119
|
"@stll/calculations": "^0.1.1",
|
|
120
|
-
"@stll/conditions": "^0.
|
|
120
|
+
"@stll/conditions": "^0.4.0",
|
|
121
121
|
"@stll/money": "^0.2.0",
|
|
122
|
-
"@stll/ui": "^0.
|
|
122
|
+
"@stll/ui": "^0.28.0",
|
|
123
123
|
"better-result": "3.0.1",
|
|
124
124
|
"lucide-react": "1.41.0",
|
|
125
125
|
"temporal-polyfill": "1.0.4",
|