@stll/workspace-ui 0.10.5 → 0.11.1
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.
|
@@ -120,7 +120,7 @@ const ConditionGutter = ({ index, combinator, onCombinator }) => {
|
|
|
120
120
|
value: combinator,
|
|
121
121
|
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
122
122
|
"aria-label": labels.match,
|
|
123
|
-
className: "h-7 min-h-0 w-20 min-w-0 shrink-0
|
|
123
|
+
className: "h-7 min-h-0 w-20 min-w-0 shrink-0",
|
|
124
124
|
size: "sm",
|
|
125
125
|
children: /* @__PURE__ */ jsx(SelectValue, {})
|
|
126
126
|
}), /* @__PURE__ */ jsxs(SelectPopup, { children: [/* @__PURE__ */ jsx(SelectItem, {
|
|
@@ -218,7 +218,7 @@ const LeafRow = ({ node, capabilities, index, combinator, onChange, onRemove, on
|
|
|
218
218
|
},
|
|
219
219
|
value: String(fieldIndex),
|
|
220
220
|
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
221
|
-
className: "h-7 min-h-0 w-auto max-w-56
|
|
221
|
+
className: "h-7 min-h-0 w-auto max-w-56",
|
|
222
222
|
size: "sm",
|
|
223
223
|
children: /* @__PURE__ */ jsx(SelectValue, {
|
|
224
224
|
placeholder: labels.fieldPlaceholder,
|
|
@@ -332,7 +332,7 @@ const OperatorSelect = ({ field, node, operator, operators, onChange }) => {
|
|
|
332
332
|
},
|
|
333
333
|
value: operator,
|
|
334
334
|
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
335
|
-
className: "h-7 min-h-0 w-auto min-w-24
|
|
335
|
+
className: "h-7 min-h-0 w-auto min-w-24",
|
|
336
336
|
size: "sm",
|
|
337
337
|
children: /* @__PURE__ */ jsx(SelectValue, { children: () => labels.operator(field.valueType, operator) })
|
|
338
338
|
}), /* @__PURE__ */ jsx(SelectPopup, {
|
|
@@ -357,7 +357,7 @@ const OperatorSelectFormula = ({ node, operand, operator, operators, onChange })
|
|
|
357
357
|
},
|
|
358
358
|
value: operator,
|
|
359
359
|
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
360
|
-
className: "h-7 min-h-0 w-auto min-w-24
|
|
360
|
+
className: "h-7 min-h-0 w-auto min-w-24",
|
|
361
361
|
size: "sm",
|
|
362
362
|
children: /* @__PURE__ */ jsx(SelectValue, { children: () => labels.operator(FORMULA_VALUE_TYPE, operator) })
|
|
363
363
|
}), /* @__PURE__ */ jsx(SelectPopup, {
|
|
@@ -405,7 +405,7 @@ const LeafValueEditor = ({ capabilities, editorKind, field, node, operator, onCh
|
|
|
405
405
|
},
|
|
406
406
|
value: isMultiValue(operator) ? leafValueList(node) : leafValueString(node),
|
|
407
407
|
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
408
|
-
className: "h-7 min-h-0 w-auto min-w-28
|
|
408
|
+
className: "h-7 min-h-0 w-auto min-w-28",
|
|
409
409
|
size: "sm",
|
|
410
410
|
children: /* @__PURE__ */ jsx(SelectValue, { placeholder: labels.valuePlaceholder })
|
|
411
411
|
}), /* @__PURE__ */ jsx(SelectPopup, {
|
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.1",
|
|
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.29.0",
|
|
123
123
|
"better-result": "3.0.1",
|
|
124
124
|
"lucide-react": "1.41.0",
|
|
125
125
|
"temporal-polyfill": "1.0.4",
|