@surfaces-ui/components 0.0.0-stage → 0.2.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 +202 -0
- package/NOTICE +4 -0
- package/README.md +48 -2
- package/dist/appComponents.d.ts +86 -0
- package/dist/appComponents.js +555 -0
- package/dist/appComponents.js.map +1 -0
- package/dist/chart/BulletGraph.d.ts +44 -0
- package/dist/chart/BulletGraph.js +40 -0
- package/dist/chart/BulletGraph.js.map +1 -0
- package/dist/chart/Chart.d.ts +177 -0
- package/dist/chart/Chart.js +279 -0
- package/dist/chart/Chart.js.map +1 -0
- package/dist/chart/Sparkline.d.ts +35 -0
- package/dist/chart/Sparkline.js +37 -0
- package/dist/chart/Sparkline.js.map +1 -0
- package/dist/chart/advice.d.ts +28 -0
- package/dist/chart/advice.js +39 -0
- package/dist/chart/advice.js.map +1 -0
- package/dist/chart/option.d.ts +90 -0
- package/dist/chart/option.js +252 -0
- package/dist/chart/option.js.map +1 -0
- package/dist/controls/Combobox.d.ts +39 -0
- package/dist/controls/Combobox.js +75 -0
- package/dist/controls/Combobox.js.map +1 -0
- package/dist/controls/ConfirmDialog.d.ts +35 -0
- package/dist/controls/ConfirmDialog.js +84 -0
- package/dist/controls/ConfirmDialog.js.map +1 -0
- package/dist/controls/ItemControls.d.ts +115 -0
- package/dist/controls/ItemControls.js +109 -0
- package/dist/controls/ItemControls.js.map +1 -0
- package/dist/controls/Popover.d.ts +31 -0
- package/dist/controls/Popover.js +114 -0
- package/dist/controls/Popover.js.map +1 -0
- package/dist/controls/ResizeHandle.d.ts +48 -0
- package/dist/controls/ResizeHandle.js +91 -0
- package/dist/controls/ResizeHandle.js.map +1 -0
- package/dist/controls/SegmentedControl.d.ts +27 -0
- package/dist/controls/SegmentedControl.js +17 -0
- package/dist/controls/SegmentedControl.js.map +1 -0
- package/dist/controls/StatusBadge.d.ts +17 -0
- package/dist/controls/StatusBadge.js +10 -0
- package/dist/controls/StatusBadge.js.map +1 -0
- package/dist/controls/context.d.ts +17 -0
- package/dist/controls/context.js +2 -0
- package/dist/controls/context.js.map +1 -0
- package/dist/controls/placement.d.ts +43 -0
- package/dist/controls/placement.js +19 -0
- package/dist/controls/placement.js.map +1 -0
- package/dist/controls/resize.d.ts +23 -0
- package/dist/controls/resize.js +49 -0
- package/dist/controls/resize.js.map +1 -0
- package/dist/data/DataSourceProvider.d.ts +11 -0
- package/dist/data/DataSourceProvider.js +21 -0
- package/dist/data/DataSourceProvider.js.map +1 -0
- package/dist/data/export.d.ts +33 -0
- package/dist/data/export.js +77 -0
- package/dist/data/export.js.map +1 -0
- package/dist/data/format.d.ts +44 -0
- package/dist/data/format.js +127 -0
- package/dist/data/format.js.map +1 -0
- package/dist/data/messages.d.ts +13 -0
- package/dist/data/messages.js +2 -0
- package/dist/data/messages.js.map +1 -0
- package/dist/data/useRowWindow.d.ts +70 -0
- package/dist/data/useRowWindow.js +175 -0
- package/dist/data/useRowWindow.js.map +1 -0
- package/dist/discovery/AskData.d.ts +22 -0
- package/dist/discovery/AskData.js +48 -0
- package/dist/discovery/AskData.js.map +1 -0
- package/dist/discovery/ContextBuilder.d.ts +49 -0
- package/dist/discovery/ContextBuilder.js +167 -0
- package/dist/discovery/ContextBuilder.js.map +1 -0
- package/dist/discovery/DataSearch.d.ts +27 -0
- package/dist/discovery/DataSearch.js +73 -0
- package/dist/discovery/DataSearch.js.map +1 -0
- package/dist/discovery/ObjectDetail.d.ts +38 -0
- package/dist/discovery/ObjectDetail.js +129 -0
- package/dist/discovery/ObjectDetail.js.map +1 -0
- package/dist/discovery/RelationshipGraph.d.ts +19 -0
- package/dist/discovery/RelationshipGraph.js +64 -0
- package/dist/discovery/RelationshipGraph.js.map +1 -0
- package/dist/discovery/shared.d.ts +38 -0
- package/dist/discovery/shared.js +64 -0
- package/dist/discovery/shared.js.map +1 -0
- package/dist/editor/SqlEditor.d.ts +41 -0
- package/dist/editor/SqlEditor.js +181 -0
- package/dist/editor/SqlEditor.js.map +1 -0
- package/dist/explore/Explorer.d.ts +110 -0
- package/dist/explore/Explorer.js +471 -0
- package/dist/explore/Explorer.js.map +1 -0
- package/dist/explore/ModelLineage.d.ts +22 -0
- package/dist/explore/ModelLineage.js +70 -0
- package/dist/explore/ModelLineage.js.map +1 -0
- package/dist/explore/ReportBuilder.d.ts +39 -0
- package/dist/explore/ReportBuilder.js +98 -0
- package/dist/explore/ReportBuilder.js.map +1 -0
- package/dist/explore/SemanticModelEditor.d.ts +60 -0
- package/dist/explore/SemanticModelEditor.js +220 -0
- package/dist/explore/SemanticModelEditor.js.map +1 -0
- package/dist/explore/SemanticRows.d.ts +42 -0
- package/dist/explore/SemanticRows.js +117 -0
- package/dist/explore/SemanticRows.js.map +1 -0
- package/dist/explore/SemanticsProvider.d.ts +31 -0
- package/dist/explore/SemanticsProvider.js +72 -0
- package/dist/explore/SemanticsProvider.js.map +1 -0
- package/dist/explore/model.d.ts +151 -0
- package/dist/explore/model.js +344 -0
- package/dist/explore/model.js.map +1 -0
- package/dist/explore/report.d.ts +60 -0
- package/dist/explore/report.js +92 -0
- package/dist/explore/report.js.map +1 -0
- package/dist/explore/semantic-proposal.d.ts +44 -0
- package/dist/explore/semantic-proposal.js +67 -0
- package/dist/explore/semantic-proposal.js.map +1 -0
- package/dist/explore/semantic.d.ts +44 -0
- package/dist/explore/semantic.js +154 -0
- package/dist/explore/semantic.js.map +1 -0
- package/dist/files/FileBrowser.d.ts +42 -0
- package/dist/files/FileBrowser.js +314 -0
- package/dist/files/FileBrowser.js.map +1 -0
- package/dist/files/files.d.ts +65 -0
- package/dist/files/files.js +165 -0
- package/dist/files/files.js.map +1 -0
- package/dist/filter/FilterBar.d.ts +49 -0
- package/dist/filter/FilterBar.js +153 -0
- package/dist/filter/FilterBar.js.map +1 -0
- package/dist/filter/QueryFilters.d.ts +25 -0
- package/dist/filter/QueryFilters.js +58 -0
- package/dist/filter/QueryFilters.js.map +1 -0
- package/dist/form/Form.d.ts +76 -0
- package/dist/form/Form.js +131 -0
- package/dist/form/Form.js.map +1 -0
- package/dist/graph/NodeGraph.d.ts +30 -0
- package/dist/graph/NodeGraph.js +86 -0
- package/dist/graph/NodeGraph.js.map +1 -0
- package/dist/graph/model.d.ts +68 -0
- package/dist/graph/model.js +122 -0
- package/dist/graph/model.js.map +1 -0
- package/dist/grid/DataGrid.d.ts +98 -0
- package/dist/grid/DataGrid.js +399 -0
- package/dist/grid/DataGrid.js.map +1 -0
- package/dist/index.d.ts +84 -0
- package/dist/index.js +86 -0
- package/dist/index.js.map +1 -0
- package/dist/locale/SurfacesText.d.ts +17 -0
- package/dist/locale/SurfacesText.js +17 -0
- package/dist/locale/SurfacesText.js.map +1 -0
- package/dist/locale/locale.d.ts +305 -0
- package/dist/locale/locale.js +359 -0
- package/dist/locale/locale.js.map +1 -0
- package/dist/menu/ContextMenu.d.ts +31 -0
- package/dist/menu/ContextMenu.js +95 -0
- package/dist/menu/ContextMenu.js.map +1 -0
- package/dist/metric/Metric.d.ts +33 -0
- package/dist/metric/Metric.js +63 -0
- package/dist/metric/Metric.js.map +1 -0
- package/dist/metric/useMeasure.d.ts +23 -0
- package/dist/metric/useMeasure.js +43 -0
- package/dist/metric/useMeasure.js.map +1 -0
- package/dist/model/ModelDiagram.d.ts +142 -0
- package/dist/model/ModelDiagram.js +699 -0
- package/dist/model/ModelDiagram.js.map +1 -0
- package/dist/panzoom/usePanZoom.d.ts +117 -0
- package/dist/panzoom/usePanZoom.js +313 -0
- package/dist/panzoom/usePanZoom.js.map +1 -0
- package/dist/pipeline/DatasetReview.d.ts +48 -0
- package/dist/pipeline/DatasetReview.js +157 -0
- package/dist/pipeline/DatasetReview.js.map +1 -0
- package/dist/pipeline/IngestWizard.d.ts +51 -0
- package/dist/pipeline/IngestWizard.js +79 -0
- package/dist/pipeline/IngestWizard.js.map +1 -0
- package/dist/pipeline/Pipeline.d.ts +171 -0
- package/dist/pipeline/Pipeline.js +203 -0
- package/dist/pipeline/Pipeline.js.map +1 -0
- package/dist/pipeline/PipelineView.d.ts +63 -0
- package/dist/pipeline/PipelineView.js +239 -0
- package/dist/pipeline/PipelineView.js.map +1 -0
- package/dist/pivot/PivotTable.d.ts +94 -0
- package/dist/pivot/PivotTable.js +171 -0
- package/dist/pivot/PivotTable.js.map +1 -0
- package/dist/plan/QueryPlan.d.ts +29 -0
- package/dist/plan/QueryPlan.js +79 -0
- package/dist/plan/QueryPlan.js.map +1 -0
- package/dist/result/QueryResult.d.ts +51 -0
- package/dist/result/QueryResult.js +255 -0
- package/dist/result/QueryResult.js.map +1 -0
- package/dist/review/ActionReceipt.d.ts +52 -0
- package/dist/review/ActionReceipt.js +32 -0
- package/dist/review/ActionReceipt.js.map +1 -0
- package/dist/review/PiiReview.d.ts +37 -0
- package/dist/review/PiiReview.js +29 -0
- package/dist/review/PiiReview.js.map +1 -0
- package/dist/review/PlanReview.d.ts +42 -0
- package/dist/review/PlanReview.js +37 -0
- package/dist/review/PlanReview.js.map +1 -0
- package/dist/review/StepFlow.d.ts +25 -0
- package/dist/review/StepFlow.js +21 -0
- package/dist/review/StepFlow.js.map +1 -0
- package/dist/review/pii.d.ts +21 -0
- package/dist/review/pii.js +67 -0
- package/dist/review/pii.js.map +1 -0
- package/dist/rows/RowList.d.ts +41 -0
- package/dist/rows/RowList.js +71 -0
- package/dist/rows/RowList.js.map +1 -0
- package/dist/schema/ObjectBrowser.d.ts +78 -0
- package/dist/schema/ObjectBrowser.js +467 -0
- package/dist/schema/ObjectBrowser.js.map +1 -0
- package/dist/schema/ObjectInfo.d.ts +25 -0
- package/dist/schema/ObjectInfo.js +69 -0
- package/dist/schema/ObjectInfo.js.map +1 -0
- package/dist/schema/SchemaExplorer.d.ts +32 -0
- package/dist/schema/SchemaExplorer.js +175 -0
- package/dist/schema/SchemaExplorer.js.map +1 -0
- package/dist/schema/refs.d.ts +32 -0
- package/dist/schema/refs.js +65 -0
- package/dist/schema/refs.js.map +1 -0
- package/dist/site/Site.d.ts +191 -0
- package/dist/site/Site.js +138 -0
- package/dist/site/Site.js.map +1 -0
- package/dist/source/ConnectionBuilder.d.ts +54 -0
- package/dist/source/ConnectionBuilder.js +115 -0
- package/dist/source/ConnectionBuilder.js.map +1 -0
- package/dist/source/SourceList.d.ts +17 -0
- package/dist/source/SourceList.js +71 -0
- package/dist/source/SourceList.js.map +1 -0
- package/dist/styles.css +9882 -0
- package/dist/styles.layer.css +9886 -0
- package/dist/table/DataTable.d.ts +72 -0
- package/dist/table/DataTable.js +68 -0
- package/dist/table/DataTable.js.map +1 -0
- package/dist/table/Pagination.d.ts +20 -0
- package/dist/table/Pagination.js +16 -0
- package/dist/table/Pagination.js.map +1 -0
- package/dist/table/SelectionBar.d.ts +43 -0
- package/dist/table/SelectionBar.js +18 -0
- package/dist/table/SelectionBar.js.map +1 -0
- package/dist/text/Markdown.d.ts +71 -0
- package/dist/text/Markdown.js +187 -0
- package/dist/text/Markdown.js.map +1 -0
- package/dist/text/highlight.d.ts +23 -0
- package/dist/text/highlight.js +196 -0
- package/dist/text/highlight.js.map +1 -0
- package/dist/theme/ThemePicker.d.ts +16 -0
- package/dist/theme/ThemePicker.js +49 -0
- package/dist/theme/ThemePicker.js.map +1 -0
- package/dist/theme/ThemeProvider.d.ts +43 -0
- package/dist/theme/ThemeProvider.js +107 -0
- package/dist/theme/ThemeProvider.js.map +1 -0
- package/dist/workspace/NavBar.d.ts +23 -0
- package/dist/workspace/NavBar.js +171 -0
- package/dist/workspace/NavBar.js.map +1 -0
- package/dist/workspace/SideNav.d.ts +61 -0
- package/dist/workspace/SideNav.js +149 -0
- package/dist/workspace/SideNav.js.map +1 -0
- package/dist/workspace/Workspace.d.ts +50 -0
- package/dist/workspace/Workspace.js +243 -0
- package/dist/workspace/Workspace.js.map +1 -0
- package/dist/workspace/icons.d.ts +34 -0
- package/dist/workspace/icons.js +37 -0
- package/dist/workspace/icons.js.map +1 -0
- package/dist/workspace/layout.d.ts +74 -0
- package/dist/workspace/layout.js +276 -0
- package/dist/workspace/layout.js.map +1 -0
- package/package.json +85 -3
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useCallback, useContext, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { useContextMenu } from "../menu/ContextMenu.js";
|
|
4
|
+
import { WorkspaceIcon } from "./icons.js";
|
|
5
|
+
import { MAX_COLUMNS, MAX_ROWS, collapsePanel, expandPanel, hidePanel, movePanel, movePanelToNewColumn, normalizeLayout, placeOf, resizeColumns, resizeRows, shiftPanel, showPanel } from "./layout.js";
|
|
6
|
+
/** True inside a workspace, so a workspace drawn within another knows to keep its rail to icons. */
|
|
7
|
+
const Nested = createContext(false);
|
|
8
|
+
const sameDrop = (a, b) => !!a && a.kind === b.kind && (a.kind === "row" ? a.column === b.column && a.row === b.row : a.at === b.at);
|
|
9
|
+
/** How far a pointer travels, in pixels, before a press on a heading becomes a drag. */
|
|
10
|
+
const DRAG_START = 6;
|
|
11
|
+
/** One step of a keyboard resize, as a share of the whole. */
|
|
12
|
+
const KEY_STEP = 0.04;
|
|
13
|
+
/**
|
|
14
|
+
* Panels in columns that a person arranges: drag a panel by its heading to
|
|
15
|
+
* another column, to a place in a stack, or to an edge for a column of its
|
|
16
|
+
* own; drag a divider to resize; hide a panel and bring it back from the
|
|
17
|
+
* rail. Everything a drag does, the "Move" menu in each heading and the arrow
|
|
18
|
+
* keys on a divider do too, so the workspace works without a pointer. The
|
|
19
|
+
* layout is plain data (`WorkspaceLayout`), so a host can keep it and an
|
|
20
|
+
* agent can set it.
|
|
21
|
+
*/
|
|
22
|
+
export function Workspace({ label, panels, layout: given, defaultLayout, onLayoutChange, rail = "right", railLabels: givenLabels, defaultRailLabels = false, onRailLabelsChange, height = "32rem", className }) {
|
|
23
|
+
const nested = useContext(Nested);
|
|
24
|
+
const [keptLabels, setKeptLabels] = useState(defaultRailLabels);
|
|
25
|
+
// Two rails with names, one inside the other, leave too little for the panels.
|
|
26
|
+
const railLabels = !nested && (givenLabels ?? keptLabels);
|
|
27
|
+
const root = useRef(null);
|
|
28
|
+
// The rail's tooltip: shown the moment a button is hovered or focused, not after the browser's delay.
|
|
29
|
+
const [tip, setTip] = useState();
|
|
30
|
+
const showTip = (text) => (event) => {
|
|
31
|
+
const frame = root.current?.getBoundingClientRect();
|
|
32
|
+
const rail = event.currentTarget.closest(".sf-workspace-rail");
|
|
33
|
+
if (!frame || !rail)
|
|
34
|
+
return;
|
|
35
|
+
const button = event.currentTarget.getBoundingClientRect();
|
|
36
|
+
const bar = rail.getBoundingClientRect();
|
|
37
|
+
// Beside a rail that stands, on the side the panels are; under a rail that lies along the top.
|
|
38
|
+
const standing = bar.height >= bar.width;
|
|
39
|
+
const style = !standing
|
|
40
|
+
? { top: button.bottom - frame.top, left: button.left + button.width / 2 - frame.left, transform: "translate(-50%, 0)", marginTop: "var(--sf-space-1)" }
|
|
41
|
+
: rail.getAttribute("data-side") === "left"
|
|
42
|
+
? { top: button.top + button.height / 2 - frame.top, left: bar.right - frame.left, transform: "translate(0, -50%)" }
|
|
43
|
+
: { top: button.top + button.height / 2 - frame.top, right: frame.right - bar.left, transform: "translate(0, -50%)" };
|
|
44
|
+
setTip({ text, style });
|
|
45
|
+
};
|
|
46
|
+
const hideTip = () => setTip(undefined);
|
|
47
|
+
const tipOn = (text) => ({
|
|
48
|
+
onPointerEnter: showTip(text),
|
|
49
|
+
onPointerLeave: hideTip,
|
|
50
|
+
onFocus: showTip(text),
|
|
51
|
+
onBlur: hideTip,
|
|
52
|
+
onKeyDown: (event) => {
|
|
53
|
+
if (event.key === "Escape")
|
|
54
|
+
hideTip();
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
const ids = useMemo(() => panels.map((p) => p.id), [panels]);
|
|
58
|
+
const idsKey = ids.join("\u0000");
|
|
59
|
+
const [kept, setKept] = useState(defaultLayout);
|
|
60
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: idsKey stands for ids.
|
|
61
|
+
const layout = useMemo(() => normalizeLayout(given ?? kept, ids), [given, kept, idsKey]);
|
|
62
|
+
const latest = useRef(layout);
|
|
63
|
+
latest.current = layout;
|
|
64
|
+
const change = useCallback((next) => {
|
|
65
|
+
if (JSON.stringify(next) === JSON.stringify(latest.current))
|
|
66
|
+
return;
|
|
67
|
+
setKept(next);
|
|
68
|
+
onLayoutChange?.(next);
|
|
69
|
+
}, [onLayoutChange]);
|
|
70
|
+
const byId = useMemo(() => new Map(panels.map((p) => [p.id, p])), [panels]);
|
|
71
|
+
const grid = useRef(null);
|
|
72
|
+
const [dragging, setDragging] = useState();
|
|
73
|
+
const [over, setOver] = useState();
|
|
74
|
+
const [said, setSaid] = useState("");
|
|
75
|
+
const dragged = useRef(undefined);
|
|
76
|
+
const endDrag = () => {
|
|
77
|
+
dragged.current = undefined;
|
|
78
|
+
setDragging(undefined);
|
|
79
|
+
setOver(undefined);
|
|
80
|
+
};
|
|
81
|
+
const drop = (target) => {
|
|
82
|
+
const id = dragged.current;
|
|
83
|
+
if (id)
|
|
84
|
+
change(target.kind === "row" ? movePanel(latest.current, id, target.column, target.row) : movePanelToNewColumn(latest.current, id, target.at));
|
|
85
|
+
endDrag();
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Dragging a panel by its heading. It is followed with pointer events, not
|
|
89
|
+
* the browser's own drag and drop, so a finger and a pen move a panel the
|
|
90
|
+
* way a mouse does. The drag begins once the pointer has travelled a little,
|
|
91
|
+
* so a press on the heading is still a press; what is under the pointer is
|
|
92
|
+
* looked up as it moves; Escape gives up.
|
|
93
|
+
*/
|
|
94
|
+
const [ghost, setGhost] = useState();
|
|
95
|
+
const overRef = useRef(undefined);
|
|
96
|
+
const startDrag = (event, id, title) => {
|
|
97
|
+
if (event.button !== 0 || event.target.closest("button, select, input, a"))
|
|
98
|
+
return;
|
|
99
|
+
const from = { x: event.clientX, y: event.clientY };
|
|
100
|
+
let moving = false;
|
|
101
|
+
const stop = (dropped) => {
|
|
102
|
+
window.removeEventListener("pointermove", move);
|
|
103
|
+
window.removeEventListener("pointerup", up);
|
|
104
|
+
window.removeEventListener("pointercancel", cancel);
|
|
105
|
+
window.removeEventListener("keydown", key, true);
|
|
106
|
+
const target = overRef.current;
|
|
107
|
+
overRef.current = undefined;
|
|
108
|
+
setGhost(undefined);
|
|
109
|
+
if (moving && dropped && target)
|
|
110
|
+
drop(target);
|
|
111
|
+
else
|
|
112
|
+
endDrag();
|
|
113
|
+
};
|
|
114
|
+
const move = (e) => {
|
|
115
|
+
if (!moving) {
|
|
116
|
+
if (Math.hypot(e.clientX - from.x, e.clientY - from.y) < DRAG_START)
|
|
117
|
+
return;
|
|
118
|
+
moving = true;
|
|
119
|
+
dragged.current = id;
|
|
120
|
+
setDragging(id);
|
|
121
|
+
}
|
|
122
|
+
e.preventDefault();
|
|
123
|
+
setGhost({ x: e.clientX, y: e.clientY, title });
|
|
124
|
+
// The zone under the pointer, if it is one of this workspace's own (not a workspace drawn inside a panel).
|
|
125
|
+
const under = document.elementFromPoint(e.clientX, e.clientY)?.closest("[data-drop]");
|
|
126
|
+
const target = under && under.closest(".sf-workspace") === root.current ? JSON.parse(under.dataset.drop ?? "null") : null;
|
|
127
|
+
overRef.current = target ?? undefined;
|
|
128
|
+
setOver((now) => (target ? (sameDrop(now, target) ? now : target) : undefined));
|
|
129
|
+
};
|
|
130
|
+
const up = () => stop(true);
|
|
131
|
+
const cancel = () => stop(false);
|
|
132
|
+
const key = (e) => {
|
|
133
|
+
if (e.key !== "Escape")
|
|
134
|
+
return;
|
|
135
|
+
e.preventDefault();
|
|
136
|
+
e.stopPropagation();
|
|
137
|
+
stop(false);
|
|
138
|
+
};
|
|
139
|
+
window.addEventListener("pointermove", move, { passive: false });
|
|
140
|
+
window.addEventListener("pointerup", up);
|
|
141
|
+
window.addEventListener("pointercancel", cancel);
|
|
142
|
+
window.addEventListener("keydown", key, true);
|
|
143
|
+
};
|
|
144
|
+
/** A place a dragged panel can be dropped. Only drawn while a panel is being dragged. */
|
|
145
|
+
const zone = (target, className, name) => (_jsx("div", { className: className, "data-drop": JSON.stringify(target), "data-over": sameDrop(over, target) || undefined, "aria-hidden": "true", children: _jsx("span", { children: name }) }));
|
|
146
|
+
/** A divider a person drags or moves with the arrow keys. */
|
|
147
|
+
const divider = (orientation, name, now, resize) => {
|
|
148
|
+
const start = (event) => {
|
|
149
|
+
const box = (orientation === "vertical" ? grid.current : event.currentTarget.closest(".sf-workspace-column"))?.getBoundingClientRect();
|
|
150
|
+
const along = orientation === "vertical" ? box?.width : box?.height;
|
|
151
|
+
if (!along)
|
|
152
|
+
return;
|
|
153
|
+
event.preventDefault();
|
|
154
|
+
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
155
|
+
let last = orientation === "vertical" ? event.clientX : event.clientY;
|
|
156
|
+
const move = (e) => {
|
|
157
|
+
const at = orientation === "vertical" ? e.clientX : e.clientY;
|
|
158
|
+
resize((at - last) / along);
|
|
159
|
+
last = at;
|
|
160
|
+
};
|
|
161
|
+
const stop = () => {
|
|
162
|
+
window.removeEventListener("pointermove", move);
|
|
163
|
+
window.removeEventListener("pointerup", stop);
|
|
164
|
+
window.removeEventListener("pointercancel", stop);
|
|
165
|
+
};
|
|
166
|
+
window.addEventListener("pointermove", move);
|
|
167
|
+
window.addEventListener("pointerup", stop);
|
|
168
|
+
window.addEventListener("pointercancel", stop);
|
|
169
|
+
};
|
|
170
|
+
const key = (event) => {
|
|
171
|
+
const less = orientation === "vertical" ? "ArrowLeft" : "ArrowUp";
|
|
172
|
+
const more = orientation === "vertical" ? "ArrowRight" : "ArrowDown";
|
|
173
|
+
if (event.key !== less && event.key !== more)
|
|
174
|
+
return;
|
|
175
|
+
event.preventDefault();
|
|
176
|
+
resize(event.key === more ? KEY_STEP : -KEY_STEP);
|
|
177
|
+
};
|
|
178
|
+
return (_jsx("div", { className: "sf-workspace-divider", role: "separator", tabIndex: 0, "aria-orientation": orientation, "aria-label": name, "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": Math.round(now * 100), onPointerDown: start, onKeyDown: key }));
|
|
179
|
+
};
|
|
180
|
+
const move = (id, title, how) => {
|
|
181
|
+
const before = latest.current;
|
|
182
|
+
const next = how === "hide"
|
|
183
|
+
? hidePanel(before, id)
|
|
184
|
+
: how === "new-left"
|
|
185
|
+
? movePanelToNewColumn(before, id, 0)
|
|
186
|
+
: how === "new-right"
|
|
187
|
+
? movePanelToNewColumn(before, id, before.columns.length)
|
|
188
|
+
: shiftPanel(before, id, how);
|
|
189
|
+
const place = placeOf(next, id);
|
|
190
|
+
setSaid(JSON.stringify(next) === JSON.stringify(before) ? `${title} cannot move that way.` : place ? `${title} is now in column ${place.column + 1} of ${next.columns.length}, place ${place.row + 1}.` : `${title} is hidden. The panels rail brings it back.`);
|
|
191
|
+
change(next);
|
|
192
|
+
};
|
|
193
|
+
const menu = useContextMenu();
|
|
194
|
+
/** Everything a drag can do to a panel, as a menu. A way that would change nothing is greyed out. */
|
|
195
|
+
const moves = (id, title) => {
|
|
196
|
+
const now = JSON.stringify(latest.current);
|
|
197
|
+
const item = (label, how, next) => ({ label, disabled: JSON.stringify(next) === now, onSelect: () => move(id, title, how) });
|
|
198
|
+
const at = latest.current;
|
|
199
|
+
return [
|
|
200
|
+
item("Move left", "left", shiftPanel(at, id, "left")),
|
|
201
|
+
item("Move right", "right", shiftPanel(at, id, "right")),
|
|
202
|
+
item("Move up", "up", shiftPanel(at, id, "up")),
|
|
203
|
+
item("Move down", "down", shiftPanel(at, id, "down")),
|
|
204
|
+
{ separator: true },
|
|
205
|
+
item("To a new column on the left", "new-left", movePanelToNewColumn(at, id, 0)),
|
|
206
|
+
item("To a new column on the right", "new-right", movePanelToNewColumn(at, id, at.columns.length)),
|
|
207
|
+
{ separator: true },
|
|
208
|
+
item("Hide", "hide", hidePanel(at, id)),
|
|
209
|
+
];
|
|
210
|
+
};
|
|
211
|
+
const columnCount = layout.columns.length;
|
|
212
|
+
const railBar = rail && (_jsxs("div", { className: "sf-workspace-rail", role: "toolbar", "aria-label": `${label}: show or hide panels`, "aria-orientation": "vertical", "data-side": rail, "data-labels": railLabels || undefined, children: [panels.map((panel) => {
|
|
213
|
+
const shown = !layout.hidden.includes(panel.id);
|
|
214
|
+
const only = shown && layout.columns.flat().length <= 1;
|
|
215
|
+
return (_jsxs("button", { type: "button", className: "sf-workspace-rail-button", "aria-pressed": shown, "aria-label": panel.title, "aria-disabled": only || undefined, ...tipOn(only ? `${panel.title}: the only panel showing` : shown ? `Hide ${panel.title}` : `Show ${panel.title}`), onClick: () => {
|
|
216
|
+
if (only)
|
|
217
|
+
return;
|
|
218
|
+
setTip(undefined);
|
|
219
|
+
setSaid(shown ? `${panel.title} is hidden.` : `${panel.title} is showing.`);
|
|
220
|
+
change(shown ? hidePanel(latest.current, panel.id) : showPanel(latest.current, panel.id));
|
|
221
|
+
}, children: [_jsx(WorkspaceIcon, { icon: panel.icon, title: panel.title }), railLabels && _jsx("span", { className: "sf-workspace-rail-label", children: panel.shortTitle ?? panel.title })] }, panel.id));
|
|
222
|
+
}), !nested && (_jsx("button", { type: "button", className: "sf-workspace-rail-size", "aria-pressed": railLabels, "aria-label": "Show panel names on the rail", ...tipOn(railLabels ? "Icons only" : "Show names"), onClick: () => {
|
|
223
|
+
setTip(undefined);
|
|
224
|
+
setKeptLabels(!railLabels);
|
|
225
|
+
onRailLabelsChange?.(!railLabels);
|
|
226
|
+
}, children: _jsx("span", { "aria-hidden": "true", children: (rail === "left") === railLabels ? "«" : "»" }) }))] }));
|
|
227
|
+
return (_jsxs("div", { ref: root, className: `sf-workspace sf-container${className ? ` ${className}` : ""}`, role: "group", "aria-label": label, style: { "--sf-workspace-height": typeof height === "number" ? `${height}px` : height }, children: [_jsxs("div", { className: "sf-workspace-frame", children: [rail === "left" && railBar, _jsxs("div", { className: "sf-workspace-grid", ref: grid, "data-dragging": dragging ? true : undefined, children: [dragging && columnCount < MAX_COLUMNS && zone({ kind: "column", at: 0 }, "sf-workspace-drop-column", "New column"), layout.columns.map((column, c) => (_jsxs("div", { className: "sf-workspace-column-wrap", style: { flexGrow: layout.columnWidths[c], flexBasis: 0 }, children: [_jsx("div", { className: "sf-workspace-column", children: column.map((id, r) => {
|
|
228
|
+
const panel = byId.get(id);
|
|
229
|
+
if (!panel)
|
|
230
|
+
return null;
|
|
231
|
+
const folded = layout.collapsed.includes(id);
|
|
232
|
+
const nextFolded = layout.collapsed.includes(column[r + 1] ?? "");
|
|
233
|
+
const canDropHere = dragging && (dragged.current === undefined || placeOf(layout, dragging)?.column === c || column.length < MAX_ROWS);
|
|
234
|
+
return (_jsxs("div", { className: "sf-workspace-cell", "data-folded": folded || undefined, style: folded ? undefined : { flexGrow: layout.rowHeights[c]?.[r] ?? 1, flexBasis: 0 }, children: [canDropHere && zone({ kind: "row", column: c, row: r }, "sf-workspace-drop-row", "Drop here"), _jsxs("section", { className: "sf-workspace-panel", "aria-label": panel.title, "data-dragging": dragging === id || undefined, "data-folded": folded || undefined, children: [_jsxs("header", { className: "sf-workspace-panel-head", onPointerDown: (event) => startDrag(event, id, panel.title), onContextMenu: (event) => menu.open(event, `Move ${panel.title}`, moves(id, panel.title)), children: [_jsx("span", { className: "sf-workspace-grip", "aria-hidden": "true", children: "\u283F" }), column.length > 1 && (_jsx("button", { type: "button", className: "sf-workspace-fold", "aria-expanded": !folded, "aria-label": folded ? `Open ${panel.title}` : `Fold ${panel.title} to its heading`, onClick: () => {
|
|
235
|
+
setSaid(folded ? `${panel.title} is open.` : `${panel.title} is folded.`);
|
|
236
|
+
change(folded ? expandPanel(latest.current, id) : collapsePanel(latest.current, id));
|
|
237
|
+
}, children: _jsx("span", { "aria-hidden": "true", children: folded ? "▸" : "▾" }) })), _jsx("h3", { className: "sf-workspace-panel-title", children: panel.title }), _jsx("button", { type: "button", className: "sf-workspace-menu-button", "aria-label": `Move ${panel.title}`, "aria-haspopup": "menu", onClick: (event) => menu.open(event, `Move ${panel.title}`, moves(id, panel.title)), children: _jsx("span", { "aria-hidden": "true", children: "\u22EF" }) })] }), _jsx("div", { className: "sf-workspace-panel-body", hidden: folded, children: _jsx(Nested.Provider, { value: true, children: panel.content }) })] }), !dragging && r < column.length - 1 && !folded && !nextFolded && divider("horizontal", `Resize ${panel.title} and the panel below it`, layout.rowHeights[c]?.[r] ?? 0.5, (delta) => change(resizeRows(latest.current, c, r, delta))), dragging && r === column.length - 1 && canDropHere && zone({ kind: "row", column: c, row: column.length }, "sf-workspace-drop-row", "Drop here")] }, id));
|
|
238
|
+
}) }), c < columnCount - 1 &&
|
|
239
|
+
(dragging
|
|
240
|
+
? columnCount < MAX_COLUMNS && zone({ kind: "column", at: c + 1 }, "sf-workspace-drop-column", "New column")
|
|
241
|
+
: divider("vertical", `Resize column ${c + 1} and column ${c + 2}`, layout.columnWidths[c] ?? 0.5, (delta) => change(resizeColumns(latest.current, c, delta))))] }, column.join("\u0000")))), dragging && columnCount < MAX_COLUMNS && zone({ kind: "column", at: columnCount }, "sf-workspace-drop-column", "New column")] }), rail === "right" && railBar] }), tip && (_jsx("div", { className: "sf-workspace-tip", "aria-hidden": "true", style: tip.style, children: tip.text })), ghost && (_jsx("div", { className: "sf-workspace-ghost", "aria-hidden": "true", style: { left: ghost.x, top: ghost.y }, children: ghost.title })), menu.element, _jsx("p", { className: "sf-workspace-said", role: "status", children: said })] }));
|
|
242
|
+
}
|
|
243
|
+
//# sourceMappingURL=Workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Workspace.js","sourceRoot":"","sources":["../../src/workspace/Workspace.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA8F,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtL,OAAO,EAAiB,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,aAAa,EAA0B,MAAM,YAAY,CAAC;AACnE,OAAO,EAAmB,WAAW,EAAE,QAAQ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zB,CACP,CAAC,EACD,QAAQ,IAAI,WAAW,GAAG,WAAW,IAAI,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,0BAA0B,EAAE,YAAY,CAAC,IACzH,EACL,IAAI,KAAK,OAAO,IAAI,OAAO,IACtB,EAEL,GAAG,IAAI,CACN,cAAK,SAAS,EAAC,kBAAkB,iBAAa,MAAM,EAAC,KAAK,EAAE,GAAG,CAAC,KAAK,YAClE,GAAG,CAAC,IAAI,GACL,CACP,EACA,KAAK,IAAI,CACR,cAAK,SAAS,EAAC,oBAAoB,iBAAa,MAAM,EAAC,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,YAC1F,KAAK,CAAC,KAAK,GACR,CACP,EACA,IAAI,CAAC,OAAO,EACb,YAAG,SAAS,EAAC,mBAAmB,EAAC,IAAI,EAAC,QAAQ,YAC3C,IAAI,GACH,IACA,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { type CSSProperties, type FocusEvent, type KeyboardEvent, type PointerEvent, type ReactNode, createContext, useCallback, useContext, useMemo, useRef, useState } from \"react\";\nimport { type MenuItem, useContextMenu } from \"../menu/ContextMenu.js\";\nimport { WorkspaceIcon, type WorkspaceIconName } from \"./icons.js\";\nimport { type FullLayout, MAX_COLUMNS, MAX_ROWS, type WorkspaceLayout, collapsePanel, expandPanel, hidePanel, movePanel, movePanelToNewColumn, normalizeLayout, placeOf, resizeColumns, resizeRows, shiftPanel, showPanel } from \"./layout.js\";\n\nexport interface WorkspacePanel {\n id: string;\n /** Shown in the panel's heading, and on the rail unless `shortTitle` is given. One to three words. */\n title: string;\n /** A shorter name for the rail, where there is room for about ten characters a line: \"Data\" for \"Data model\". */\n shortTitle?: string;\n /** The rail's icon: one of the built-in names, or your own node. Left out, the title's first letter. */\n icon?: WorkspaceIconName | ReactNode;\n content: ReactNode;\n}\n\nexport interface WorkspaceProps {\n /** What the workspace is, for assistive technology: \"Playground panels\". */\n label: string;\n panels: WorkspacePanel[];\n /** Where the panels sit. Give it with `onLayoutChange` to hold the layout yourself; otherwise the workspace keeps it. */\n layout?: WorkspaceLayout;\n /** Where the panels start when the workspace keeps the layout. Defaults to one column. */\n defaultLayout?: WorkspaceLayout;\n /** Called with the whole layout when a person moves, resizes, shows or hides a panel. */\n onLayoutChange?(layout: FullLayout): void;\n /** Which side the rail of panel toggles sits on; `false` leaves it out. Defaults to the right. */\n rail?: \"left\" | \"right\" | false;\n /**\n * Whether the rail shows a short name under each icon. The rail is icons\n * only unless this is set, with each panel's name in a tooltip that shows\n * at once on hover or focus. A person switches between the two with the\n * button at the rail's foot. Give it with `onRailLabelsChange` to hold the\n * choice yourself. A workspace inside another is always icons only.\n */\n railLabels?: boolean;\n /** Whether names show to begin with, when the workspace holds the choice. Defaults to false. */\n defaultRailLabels?: boolean;\n onRailLabelsChange?(labels: boolean): void;\n /** A CSS height. A workspace needs one: its panels scroll inside it. Defaults to 32rem. */\n height?: string | number;\n className?: string;\n}\n\n/** True inside a workspace, so a workspace drawn within another knows to keep its rail to icons. */\nconst Nested = createContext(false);\n\ntype Drop = { kind: \"row\"; column: number; row: number } | { kind: \"column\"; at: number };\nconst sameDrop = (a: Drop | undefined, b: Drop) => !!a && a.kind === b.kind && (a.kind === \"row\" ? a.column === (b as typeof a).column && a.row === (b as typeof a).row : a.at === (b as typeof a).at);\n\n/** How far a pointer travels, in pixels, before a press on a heading becomes a drag. */\nconst DRAG_START = 6;\n\n/** One step of a keyboard resize, as a share of the whole. */\nconst KEY_STEP = 0.04;\n\n/**\n * Panels in columns that a person arranges: drag a panel by its heading to\n * another column, to a place in a stack, or to an edge for a column of its\n * own; drag a divider to resize; hide a panel and bring it back from the\n * rail. Everything a drag does, the \"Move\" menu in each heading and the arrow\n * keys on a divider do too, so the workspace works without a pointer. The\n * layout is plain data (`WorkspaceLayout`), so a host can keep it and an\n * agent can set it.\n */\nexport function Workspace({ label, panels, layout: given, defaultLayout, onLayoutChange, rail = \"right\", railLabels: givenLabels, defaultRailLabels = false, onRailLabelsChange, height = \"32rem\", className }: WorkspaceProps) {\n const nested = useContext(Nested);\n const [keptLabels, setKeptLabels] = useState(defaultRailLabels);\n // Two rails with names, one inside the other, leave too little for the panels.\n const railLabels = !nested && (givenLabels ?? keptLabels);\n const root = useRef<HTMLDivElement>(null);\n // The rail's tooltip: shown the moment a button is hovered or focused, not after the browser's delay.\n const [tip, setTip] = useState<{ text: string; style: CSSProperties }>();\n const showTip = (text: string) => (event: PointerEvent<HTMLElement> | FocusEvent<HTMLElement>) => {\n const frame = root.current?.getBoundingClientRect();\n const rail = event.currentTarget.closest(\".sf-workspace-rail\");\n if (!frame || !rail) return;\n const button = event.currentTarget.getBoundingClientRect();\n const bar = rail.getBoundingClientRect();\n // Beside a rail that stands, on the side the panels are; under a rail that lies along the top.\n const standing = bar.height >= bar.width;\n const style: CSSProperties = !standing\n ? { top: button.bottom - frame.top, left: button.left + button.width / 2 - frame.left, transform: \"translate(-50%, 0)\", marginTop: \"var(--sf-space-1)\" }\n : rail.getAttribute(\"data-side\") === \"left\"\n ? { top: button.top + button.height / 2 - frame.top, left: bar.right - frame.left, transform: \"translate(0, -50%)\" }\n : { top: button.top + button.height / 2 - frame.top, right: frame.right - bar.left, transform: \"translate(0, -50%)\" };\n setTip({ text, style });\n };\n const hideTip = () => setTip(undefined);\n const tipOn = (text: string) => ({\n onPointerEnter: showTip(text),\n onPointerLeave: hideTip,\n onFocus: showTip(text),\n onBlur: hideTip,\n onKeyDown: (event: KeyboardEvent<HTMLElement>) => {\n if (event.key === \"Escape\") hideTip();\n },\n });\n const ids = useMemo(() => panels.map((p) => p.id), [panels]);\n const idsKey = ids.join(\"\\u0000\");\n const [kept, setKept] = useState<WorkspaceLayout | undefined>(defaultLayout);\n // biome-ignore lint/correctness/useExhaustiveDependencies: idsKey stands for ids.\n const layout = useMemo(() => normalizeLayout(given ?? kept, ids), [given, kept, idsKey]);\n const latest = useRef(layout);\n latest.current = layout;\n const change = useCallback(\n (next: FullLayout) => {\n if (JSON.stringify(next) === JSON.stringify(latest.current)) return;\n setKept(next);\n onLayoutChange?.(next);\n },\n [onLayoutChange],\n );\n\n const byId = useMemo(() => new Map(panels.map((p) => [p.id, p])), [panels]);\n const grid = useRef<HTMLDivElement>(null);\n const [dragging, setDragging] = useState<string>();\n const [over, setOver] = useState<Drop>();\n const [said, setSaid] = useState(\"\");\n const dragged = useRef<string | undefined>(undefined);\n\n const endDrag = () => {\n dragged.current = undefined;\n setDragging(undefined);\n setOver(undefined);\n };\n const drop = (target: Drop) => {\n const id = dragged.current;\n if (id) change(target.kind === \"row\" ? movePanel(latest.current, id, target.column, target.row) : movePanelToNewColumn(latest.current, id, target.at));\n endDrag();\n };\n /**\n * Dragging a panel by its heading. It is followed with pointer events, not\n * the browser's own drag and drop, so a finger and a pen move a panel the\n * way a mouse does. The drag begins once the pointer has travelled a little,\n * so a press on the heading is still a press; what is under the pointer is\n * looked up as it moves; Escape gives up.\n */\n const [ghost, setGhost] = useState<{ x: number; y: number; title: string }>();\n const overRef = useRef<Drop | undefined>(undefined);\n const startDrag = (event: PointerEvent<HTMLElement>, id: string, title: string) => {\n if (event.button !== 0 || (event.target as HTMLElement).closest(\"button, select, input, a\")) return;\n const from = { x: event.clientX, y: event.clientY };\n let moving = false;\n const stop = (dropped: boolean) => {\n window.removeEventListener(\"pointermove\", move);\n window.removeEventListener(\"pointerup\", up);\n window.removeEventListener(\"pointercancel\", cancel);\n window.removeEventListener(\"keydown\", key, true);\n const target = overRef.current;\n overRef.current = undefined;\n setGhost(undefined);\n if (moving && dropped && target) drop(target);\n else endDrag();\n };\n const move = (e: globalThis.PointerEvent) => {\n if (!moving) {\n if (Math.hypot(e.clientX - from.x, e.clientY - from.y) < DRAG_START) return;\n moving = true;\n dragged.current = id;\n setDragging(id);\n }\n e.preventDefault();\n setGhost({ x: e.clientX, y: e.clientY, title });\n // The zone under the pointer, if it is one of this workspace's own (not a workspace drawn inside a panel).\n const under = document.elementFromPoint(e.clientX, e.clientY)?.closest<HTMLElement>(\"[data-drop]\");\n const target = under && under.closest(\".sf-workspace\") === root.current ? (JSON.parse(under.dataset.drop ?? \"null\") as Drop | null) : null;\n overRef.current = target ?? undefined;\n setOver((now) => (target ? (sameDrop(now, target) ? now : target) : undefined));\n };\n const up = () => stop(true);\n const cancel = () => stop(false);\n const key = (e: globalThis.KeyboardEvent) => {\n if (e.key !== \"Escape\") return;\n e.preventDefault();\n e.stopPropagation();\n stop(false);\n };\n window.addEventListener(\"pointermove\", move, { passive: false });\n window.addEventListener(\"pointerup\", up);\n window.addEventListener(\"pointercancel\", cancel);\n window.addEventListener(\"keydown\", key, true);\n };\n\n /** A place a dragged panel can be dropped. Only drawn while a panel is being dragged. */\n const zone = (target: Drop, className: string, name: string) => (\n <div className={className} data-drop={JSON.stringify(target)} data-over={sameDrop(over, target) || undefined} aria-hidden=\"true\">\n <span>{name}</span>\n </div>\n );\n\n /** A divider a person drags or moves with the arrow keys. */\n const divider = (orientation: \"vertical\" | \"horizontal\", name: string, now: number, resize: (delta: number) => void) => {\n const start = (event: PointerEvent<HTMLDivElement>) => {\n const box = (orientation === \"vertical\" ? grid.current : event.currentTarget.closest(\".sf-workspace-column\"))?.getBoundingClientRect();\n const along = orientation === \"vertical\" ? box?.width : box?.height;\n if (!along) return;\n event.preventDefault();\n event.currentTarget.setPointerCapture?.(event.pointerId);\n let last = orientation === \"vertical\" ? event.clientX : event.clientY;\n const move = (e: globalThis.PointerEvent) => {\n const at = orientation === \"vertical\" ? e.clientX : e.clientY;\n resize((at - last) / along);\n last = at;\n };\n const stop = () => {\n window.removeEventListener(\"pointermove\", move);\n window.removeEventListener(\"pointerup\", stop);\n window.removeEventListener(\"pointercancel\", stop);\n };\n window.addEventListener(\"pointermove\", move);\n window.addEventListener(\"pointerup\", stop);\n window.addEventListener(\"pointercancel\", stop);\n };\n const key = (event: KeyboardEvent<HTMLDivElement>) => {\n const less = orientation === \"vertical\" ? \"ArrowLeft\" : \"ArrowUp\";\n const more = orientation === \"vertical\" ? \"ArrowRight\" : \"ArrowDown\";\n if (event.key !== less && event.key !== more) return;\n event.preventDefault();\n resize(event.key === more ? KEY_STEP : -KEY_STEP);\n };\n return (\n // biome-ignore lint/a11y/useSemanticElements: a focusable separator is the ARIA pattern for a splitter; <hr> cannot be focused or dragged.\n <div\n className=\"sf-workspace-divider\"\n role=\"separator\"\n tabIndex={0}\n aria-orientation={orientation}\n aria-label={name}\n aria-valuemin={0}\n aria-valuemax={100}\n aria-valuenow={Math.round(now * 100)}\n onPointerDown={start}\n onKeyDown={key}\n />\n );\n };\n\n const move = (id: string, title: string, how: string) => {\n const before = latest.current;\n const next =\n how === \"hide\"\n ? hidePanel(before, id)\n : how === \"new-left\"\n ? movePanelToNewColumn(before, id, 0)\n : how === \"new-right\"\n ? movePanelToNewColumn(before, id, before.columns.length)\n : shiftPanel(before, id, how as \"left\" | \"right\" | \"up\" | \"down\");\n const place = placeOf(next, id);\n setSaid(JSON.stringify(next) === JSON.stringify(before) ? `${title} cannot move that way.` : place ? `${title} is now in column ${place.column + 1} of ${next.columns.length}, place ${place.row + 1}.` : `${title} is hidden. The panels rail brings it back.`);\n change(next);\n };\n\n const menu = useContextMenu();\n /** Everything a drag can do to a panel, as a menu. A way that would change nothing is greyed out. */\n const moves = (id: string, title: string): MenuItem[] => {\n const now = JSON.stringify(latest.current);\n const item = (label: string, how: string, next: FullLayout): MenuItem => ({ label, disabled: JSON.stringify(next) === now, onSelect: () => move(id, title, how) });\n const at = latest.current;\n return [\n item(\"Move left\", \"left\", shiftPanel(at, id, \"left\")),\n item(\"Move right\", \"right\", shiftPanel(at, id, \"right\")),\n item(\"Move up\", \"up\", shiftPanel(at, id, \"up\")),\n item(\"Move down\", \"down\", shiftPanel(at, id, \"down\")),\n { separator: true },\n item(\"To a new column on the left\", \"new-left\", movePanelToNewColumn(at, id, 0)),\n item(\"To a new column on the right\", \"new-right\", movePanelToNewColumn(at, id, at.columns.length)),\n { separator: true },\n item(\"Hide\", \"hide\", hidePanel(at, id)),\n ];\n };\n\n const columnCount = layout.columns.length;\n const railBar = rail && (\n <div className=\"sf-workspace-rail\" role=\"toolbar\" aria-label={`${label}: show or hide panels`} aria-orientation=\"vertical\" data-side={rail} data-labels={railLabels || undefined}>\n {panels.map((panel) => {\n const shown = !layout.hidden.includes(panel.id);\n const only = shown && layout.columns.flat().length <= 1;\n return (\n <button\n key={panel.id}\n type=\"button\"\n className=\"sf-workspace-rail-button\"\n aria-pressed={shown}\n // The whole title is the button's name; the rail may show a shorter one.\n aria-label={panel.title}\n // Not `disabled`: a disabled button cannot be hovered or focused, so it could not say why it does nothing.\n aria-disabled={only || undefined}\n {...tipOn(only ? `${panel.title}: the only panel showing` : shown ? `Hide ${panel.title}` : `Show ${panel.title}`)}\n onClick={() => {\n if (only) return;\n setTip(undefined);\n setSaid(shown ? `${panel.title} is hidden.` : `${panel.title} is showing.`);\n change(shown ? hidePanel(latest.current, panel.id) : showPanel(latest.current, panel.id));\n }}\n >\n <WorkspaceIcon icon={panel.icon} title={panel.title} />\n {railLabels && <span className=\"sf-workspace-rail-label\">{panel.shortTitle ?? panel.title}</span>}\n </button>\n );\n })}\n {!nested && (\n <button\n type=\"button\"\n className=\"sf-workspace-rail-size\"\n aria-pressed={railLabels}\n aria-label=\"Show panel names on the rail\"\n {...tipOn(railLabels ? \"Icons only\" : \"Show names\")}\n onClick={() => {\n setTip(undefined);\n setKeptLabels(!railLabels);\n onRailLabelsChange?.(!railLabels);\n }}\n >\n <span aria-hidden=\"true\">{(rail === \"left\") === railLabels ? \"«\" : \"»\"}</span>\n </button>\n )}\n </div>\n );\n\n return (\n <div ref={root} className={`sf-workspace sf-container${className ? ` ${className}` : \"\"}`} role=\"group\" aria-label={label} style={{ \"--sf-workspace-height\": typeof height === \"number\" ? `${height}px` : height } as CSSProperties}>\n {/* The frame, not the workspace itself, is laid out: a container's own box cannot answer its own size query. */}\n <div className=\"sf-workspace-frame\">\n {rail === \"left\" && railBar}\n <div className=\"sf-workspace-grid\" ref={grid} data-dragging={dragging ? true : undefined}>\n {dragging && columnCount < MAX_COLUMNS && zone({ kind: \"column\", at: 0 }, \"sf-workspace-drop-column\", \"New column\")}\n {layout.columns.map((column, c) => (\n <div key={column.join(\"\\u0000\")} className=\"sf-workspace-column-wrap\" style={{ flexGrow: layout.columnWidths[c], flexBasis: 0 }}>\n <div className=\"sf-workspace-column\">\n {column.map((id, r) => {\n const panel = byId.get(id);\n if (!panel) return null;\n const folded = layout.collapsed.includes(id);\n const nextFolded = layout.collapsed.includes(column[r + 1] ?? \"\");\n const canDropHere = dragging && (dragged.current === undefined || placeOf(layout, dragging)?.column === c || column.length < MAX_ROWS);\n return (\n <div key={id} className=\"sf-workspace-cell\" data-folded={folded || undefined} style={folded ? undefined : { flexGrow: layout.rowHeights[c]?.[r] ?? 1, flexBasis: 0 }}>\n {canDropHere && zone({ kind: \"row\", column: c, row: r }, \"sf-workspace-drop-row\", \"Drop here\")}\n <section className=\"sf-workspace-panel\" aria-label={panel.title} data-dragging={dragging === id || undefined} data-folded={folded || undefined}>\n <header\n className=\"sf-workspace-panel-head\"\n onPointerDown={(event) => startDrag(event, id, panel.title)}\n onContextMenu={(event) => menu.open(event, `Move ${panel.title}`, moves(id, panel.title))}\n >\n <span className=\"sf-workspace-grip\" aria-hidden=\"true\">\n ⠿\n </span>\n {column.length > 1 && (\n <button\n type=\"button\"\n className=\"sf-workspace-fold\"\n aria-expanded={!folded}\n aria-label={folded ? `Open ${panel.title}` : `Fold ${panel.title} to its heading`}\n onClick={() => {\n setSaid(folded ? `${panel.title} is open.` : `${panel.title} is folded.`);\n change(folded ? expandPanel(latest.current, id) : collapsePanel(latest.current, id));\n }}\n >\n <span aria-hidden=\"true\">{folded ? \"▸\" : \"▾\"}</span>\n </button>\n )}\n <h3 className=\"sf-workspace-panel-title\">{panel.title}</h3>\n <button\n type=\"button\"\n className=\"sf-workspace-menu-button\"\n aria-label={`Move ${panel.title}`}\n aria-haspopup=\"menu\"\n onClick={(event) => menu.open(event, `Move ${panel.title}`, moves(id, panel.title))}\n >\n <span aria-hidden=\"true\">⋯</span>\n </button>\n </header>\n {/* A folded panel keeps its content, hidden, so what a person typed there is still there when it opens. */}\n <div className=\"sf-workspace-panel-body\" hidden={folded}>\n <Nested.Provider value={true}>{panel.content}</Nested.Provider>\n </div>\n </section>\n {!dragging && r < column.length - 1 && !folded && !nextFolded && divider(\"horizontal\", `Resize ${panel.title} and the panel below it`, layout.rowHeights[c]?.[r] ?? 0.5, (delta) => change(resizeRows(latest.current, c, r, delta)))}\n {dragging && r === column.length - 1 && canDropHere && zone({ kind: \"row\", column: c, row: column.length }, \"sf-workspace-drop-row\", \"Drop here\")}\n </div>\n );\n })}\n </div>\n {c < columnCount - 1 &&\n (dragging\n ? columnCount < MAX_COLUMNS && zone({ kind: \"column\", at: c + 1 }, \"sf-workspace-drop-column\", \"New column\")\n : divider(\"vertical\", `Resize column ${c + 1} and column ${c + 2}`, layout.columnWidths[c] ?? 0.5, (delta) => change(resizeColumns(latest.current, c, delta))))}\n </div>\n ))}\n {dragging && columnCount < MAX_COLUMNS && zone({ kind: \"column\", at: columnCount }, \"sf-workspace-drop-column\", \"New column\")}\n </div>\n {rail === \"right\" && railBar}\n </div>\n {/* The buttons carry their names for assistive technology; this is the same words for the eye. */}\n {tip && (\n <div className=\"sf-workspace-tip\" aria-hidden=\"true\" style={tip.style}>\n {tip.text}\n </div>\n )}\n {ghost && (\n <div className=\"sf-workspace-ghost\" aria-hidden=\"true\" style={{ left: ghost.x, top: ghost.y }}>\n {ghost.title}\n </div>\n )}\n {menu.element}\n <p className=\"sf-workspace-said\" role=\"status\">\n {said}\n </p>\n </div>\n );\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Small outline icons for a workspace's rail, drawn in the text colour. A
|
|
4
|
+
* panel names one; a panel that names none gets its first letter instead, so
|
|
5
|
+
* every button on the rail can be told apart.
|
|
6
|
+
*/
|
|
7
|
+
declare const PATHS: {
|
|
8
|
+
readonly surface: "M4 5h16v14H4z M4 10h16 M10 10v9";
|
|
9
|
+
readonly agent: "M4 5h16v11H10l-5 4v-4H4z";
|
|
10
|
+
readonly components: "M4 5h16v4H4z M4 12h11v3H4z M4 18h14v2H4z";
|
|
11
|
+
readonly table: "M3 5h18v14H3z M3 10h18 M3 15h18 M9 5v14";
|
|
12
|
+
readonly code: "M9 4c-2 0-3 1-3 3v2c0 1.2-.8 2.2-2 3 1.2.8 2 1.8 2 3v2c0 2 1 3 3 3 M15 4c2 0 3 1 3 3v2c0 1.2.8 2.2 2 3-1.2.8-2 1.8-2 3v2c0 2-1 3-3 3";
|
|
13
|
+
readonly data: "M5 6c0-1.7 3.1-3 7-3s7 1.3 7 3-3.1 3-7 3-7-1.3-7-3z M5 6v12c0 1.7 3.1 3 7 3s7-1.3 7-3V6 M5 12c0 1.7 3.1 3 7 3s7-1.3 7-3";
|
|
14
|
+
readonly history: "M12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16z M12 8v4l3 2";
|
|
15
|
+
readonly save: "M5 4h11l3 3v13H5z M8 4v5h7V4 M8 20v-6h8v6";
|
|
16
|
+
readonly search: "M11 5a6 6 0 1 0 0 12 6 6 0 0 0 0-12z M20 20l-4.6-4.6";
|
|
17
|
+
readonly map: "M6 4a2 2 0 1 0 0 4 2 2 0 0 0 0-4z M18 6a2 2 0 1 0 0 4 2 2 0 0 0 0-4z M10 16a2 2 0 1 0 0 4 2 2 0 0 0 0-4z M8 6.4l8 1.2 M6.8 7.9l2.6 8.2 M16.8 9.6l-5.6 6.8";
|
|
18
|
+
readonly chart: "M4 4v16h16 M8 16v-5 M12 16V8 M16 16v-9";
|
|
19
|
+
readonly grid: "M4 4h7v7H4z M13 4h7v7h-7z M4 13h7v7H4z M13 13h7v7h-7z";
|
|
20
|
+
readonly settings: "M4 7h9 M19 7h1 M4 17h3 M13 17h7 M16 5a2 2 0 1 0 0 4 2 2 0 0 0 0-4z M10 15a2 2 0 1 0 0 4 2 2 0 0 0 0-4z";
|
|
21
|
+
readonly note: "M7 3h8l4 4v14H7z M15 3v4h4 M10 12h6 M10 16h6";
|
|
22
|
+
readonly folder: "M3 6h6l2 2h10v11H3z";
|
|
23
|
+
readonly person: "M12 4a3.5 3.5 0 1 0 0 7 3.5 3.5 0 0 0 0-7z M5.5 20c0-3.6 2.9-6.5 6.5-6.5s6.5 2.9 6.5 6.5";
|
|
24
|
+
readonly bell: "M18 16v-5a6 6 0 0 0-12 0v5l-2 2h16z M10 21a2 2 0 0 0 4 0";
|
|
25
|
+
readonly people: "M9 4a3.5 3.5 0 1 0 0 7 3.5 3.5 0 0 0 0-7z M2.5 20c0-3.6 2.9-6.5 6.5-6.5s6.5 2.9 6.5 6.5 M16 4.4a3.5 3.5 0 0 1 0 6.2 M18 14c2 .9 3.5 3.2 3.5 6";
|
|
26
|
+
};
|
|
27
|
+
export type WorkspaceIconName = keyof typeof PATHS;
|
|
28
|
+
export declare const WORKSPACE_ICONS: WorkspaceIconName[];
|
|
29
|
+
/** A panel's icon: the named drawing, the panel's own node, or the first letter of its title. */
|
|
30
|
+
export declare function WorkspaceIcon({ icon, title }: {
|
|
31
|
+
icon?: WorkspaceIconName | ReactNode;
|
|
32
|
+
title: string;
|
|
33
|
+
}): import("react").JSX.Element;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Small outline icons for a workspace's rail, drawn in the text colour. A
|
|
4
|
+
* panel names one; a panel that names none gets its first letter instead, so
|
|
5
|
+
* every button on the rail can be told apart.
|
|
6
|
+
*/
|
|
7
|
+
const PATHS = {
|
|
8
|
+
surface: "M4 5h16v14H4z M4 10h16 M10 10v9",
|
|
9
|
+
agent: "M4 5h16v11H10l-5 4v-4H4z",
|
|
10
|
+
components: "M4 5h16v4H4z M4 12h11v3H4z M4 18h14v2H4z",
|
|
11
|
+
table: "M3 5h18v14H3z M3 10h18 M3 15h18 M9 5v14",
|
|
12
|
+
code: "M9 4c-2 0-3 1-3 3v2c0 1.2-.8 2.2-2 3 1.2.8 2 1.8 2 3v2c0 2 1 3 3 3 M15 4c2 0 3 1 3 3v2c0 1.2.8 2.2 2 3-1.2.8-2 1.8-2 3v2c0 2-1 3-3 3",
|
|
13
|
+
data: "M5 6c0-1.7 3.1-3 7-3s7 1.3 7 3-3.1 3-7 3-7-1.3-7-3z M5 6v12c0 1.7 3.1 3 7 3s7-1.3 7-3V6 M5 12c0 1.7 3.1 3 7 3s7-1.3 7-3",
|
|
14
|
+
history: "M12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16z M12 8v4l3 2",
|
|
15
|
+
save: "M5 4h11l3 3v13H5z M8 4v5h7V4 M8 20v-6h8v6",
|
|
16
|
+
search: "M11 5a6 6 0 1 0 0 12 6 6 0 0 0 0-12z M20 20l-4.6-4.6",
|
|
17
|
+
map: "M6 4a2 2 0 1 0 0 4 2 2 0 0 0 0-4z M18 6a2 2 0 1 0 0 4 2 2 0 0 0 0-4z M10 16a2 2 0 1 0 0 4 2 2 0 0 0 0-4z M8 6.4l8 1.2 M6.8 7.9l2.6 8.2 M16.8 9.6l-5.6 6.8",
|
|
18
|
+
chart: "M4 4v16h16 M8 16v-5 M12 16V8 M16 16v-9",
|
|
19
|
+
grid: "M4 4h7v7H4z M13 4h7v7h-7z M4 13h7v7H4z M13 13h7v7h-7z",
|
|
20
|
+
settings: "M4 7h9 M19 7h1 M4 17h3 M13 17h7 M16 5a2 2 0 1 0 0 4 2 2 0 0 0 0-4z M10 15a2 2 0 1 0 0 4 2 2 0 0 0 0-4z",
|
|
21
|
+
note: "M7 3h8l4 4v14H7z M15 3v4h4 M10 12h6 M10 16h6",
|
|
22
|
+
folder: "M3 6h6l2 2h10v11H3z",
|
|
23
|
+
person: "M12 4a3.5 3.5 0 1 0 0 7 3.5 3.5 0 0 0 0-7z M5.5 20c0-3.6 2.9-6.5 6.5-6.5s6.5 2.9 6.5 6.5",
|
|
24
|
+
bell: "M18 16v-5a6 6 0 0 0-12 0v5l-2 2h16z M10 21a2 2 0 0 0 4 0",
|
|
25
|
+
people: "M9 4a3.5 3.5 0 1 0 0 7 3.5 3.5 0 0 0 0-7z M2.5 20c0-3.6 2.9-6.5 6.5-6.5s6.5 2.9 6.5 6.5 M16 4.4a3.5 3.5 0 0 1 0 6.2 M18 14c2 .9 3.5 3.2 3.5 6",
|
|
26
|
+
};
|
|
27
|
+
export const WORKSPACE_ICONS = Object.keys(PATHS);
|
|
28
|
+
/** A panel's icon: the named drawing, the panel's own node, or the first letter of its title. */
|
|
29
|
+
export function WorkspaceIcon({ icon, title }) {
|
|
30
|
+
if (typeof icon === "string" && icon in PATHS) {
|
|
31
|
+
return (_jsx("svg", { className: "sf-workspace-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: PATHS[icon] }) }));
|
|
32
|
+
}
|
|
33
|
+
if (icon !== undefined && icon !== null && typeof icon !== "string")
|
|
34
|
+
return _jsx("span", { className: "sf-workspace-icon", children: icon });
|
|
35
|
+
return (_jsx("span", { className: "sf-workspace-icon sf-workspace-icon-letter", "aria-hidden": "true", children: (title.trim()[0] ?? "?").toUpperCase() }));
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=icons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icons.js","sourceRoot":"","sources":["../../src/workspace/icons.tsx"],"names":[],"mappings":";AAEA;;;;GAIG;AACH,MAAM,KAAK,GAAG;IACZ,OAAO,EAAE,iCAAiC;IAC1C,KAAK,EAAE,0BAA0B;IACjC,UAAU,EAAE,0CAA0C;IACtD,KAAK,EAAE,yCAAyC;IAChD,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CACR,CAAC;AACJ,CAAC","sourcesContent":["import type { ReactNode } from \"react\";\n\n/**\n * Small outline icons for a workspace's rail, drawn in the text colour. A\n * panel names one; a panel that names none gets its first letter instead, so\n * every button on the rail can be told apart.\n */\nconst PATHS = {\n surface: \"M4 5h16v14H4z M4 10h16 M10 10v9\",\n agent: \"M4 5h16v11H10l-5 4v-4H4z\",\n components: \"M4 5h16v4H4z M4 12h11v3H4z M4 18h14v2H4z\",\n table: \"M3 5h18v14H3z M3 10h18 M3 15h18 M9 5v14\",\n code: \"M9 4c-2 0-3 1-3 3v2c0 1.2-.8 2.2-2 3 1.2.8 2 1.8 2 3v2c0 2 1 3 3 3 M15 4c2 0 3 1 3 3v2c0 1.2.8 2.2 2 3-1.2.8-2 1.8-2 3v2c0 2-1 3-3 3\",\n data: \"M5 6c0-1.7 3.1-3 7-3s7 1.3 7 3-3.1 3-7 3-7-1.3-7-3z M5 6v12c0 1.7 3.1 3 7 3s7-1.3 7-3V6 M5 12c0 1.7 3.1 3 7 3s7-1.3 7-3\",\n history: \"M12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16z M12 8v4l3 2\",\n save: \"M5 4h11l3 3v13H5z M8 4v5h7V4 M8 20v-6h8v6\",\n search: \"M11 5a6 6 0 1 0 0 12 6 6 0 0 0 0-12z M20 20l-4.6-4.6\",\n map: \"M6 4a2 2 0 1 0 0 4 2 2 0 0 0 0-4z M18 6a2 2 0 1 0 0 4 2 2 0 0 0 0-4z M10 16a2 2 0 1 0 0 4 2 2 0 0 0 0-4z M8 6.4l8 1.2 M6.8 7.9l2.6 8.2 M16.8 9.6l-5.6 6.8\",\n chart: \"M4 4v16h16 M8 16v-5 M12 16V8 M16 16v-9\",\n grid: \"M4 4h7v7H4z M13 4h7v7h-7z M4 13h7v7H4z M13 13h7v7h-7z\",\n settings: \"M4 7h9 M19 7h1 M4 17h3 M13 17h7 M16 5a2 2 0 1 0 0 4 2 2 0 0 0 0-4z M10 15a2 2 0 1 0 0 4 2 2 0 0 0 0-4z\",\n note: \"M7 3h8l4 4v14H7z M15 3v4h4 M10 12h6 M10 16h6\",\n folder: \"M3 6h6l2 2h10v11H3z\",\n person: \"M12 4a3.5 3.5 0 1 0 0 7 3.5 3.5 0 0 0 0-7z M5.5 20c0-3.6 2.9-6.5 6.5-6.5s6.5 2.9 6.5 6.5\",\n bell: \"M18 16v-5a6 6 0 0 0-12 0v5l-2 2h16z M10 21a2 2 0 0 0 4 0\",\n people: \"M9 4a3.5 3.5 0 1 0 0 7 3.5 3.5 0 0 0 0-7z M2.5 20c0-3.6 2.9-6.5 6.5-6.5s6.5 2.9 6.5 6.5 M16 4.4a3.5 3.5 0 0 1 0 6.2 M18 14c2 .9 3.5 3.2 3.5 6\",\n} as const;\n\nexport type WorkspaceIconName = keyof typeof PATHS;\nexport const WORKSPACE_ICONS = Object.keys(PATHS) as WorkspaceIconName[];\n\n/** A panel's icon: the named drawing, the panel's own node, or the first letter of its title. */\nexport function WorkspaceIcon({ icon, title }: { icon?: WorkspaceIconName | ReactNode; title: string }) {\n if (typeof icon === \"string\" && icon in PATHS) {\n return (\n <svg className=\"sf-workspace-icon\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" focusable=\"false\">\n <path d={PATHS[icon as WorkspaceIconName]} />\n </svg>\n );\n }\n if (icon !== undefined && icon !== null && typeof icon !== \"string\") return <span className=\"sf-workspace-icon\">{icon}</span>;\n return (\n <span className=\"sf-workspace-icon sf-workspace-icon-letter\" aria-hidden=\"true\">\n {(title.trim()[0] ?? \"?\").toUpperCase()}\n </span>\n );\n}\n"]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a workspace's panels sit: columns from left to right, each a stack of
|
|
3
|
+
* panels from top to bottom, with the share of the width each column takes
|
|
4
|
+
* and the share of its column's height each panel takes. Plain data, so a
|
|
5
|
+
* host can keep it, a person can change it by hand, and an agent can set it
|
|
6
|
+
* ("search on the left, the map on the right" is `columns: [["search"], ["map"]]`).
|
|
7
|
+
*/
|
|
8
|
+
export interface WorkspaceLayout {
|
|
9
|
+
/** Panel ids: `columns[column][row]`. */
|
|
10
|
+
columns: string[][];
|
|
11
|
+
/** One share per column, adding up to 1. Left out, columns are equal. */
|
|
12
|
+
columnWidths?: number[];
|
|
13
|
+
/** One share per panel of each column, each column adding up to 1. Left out, panels are equal. */
|
|
14
|
+
rowHeights?: number[][];
|
|
15
|
+
/** Panels that exist but are not shown. The rail brings them back. */
|
|
16
|
+
hidden?: string[];
|
|
17
|
+
/** Panels folded to their heading, so the others in their column have the room. */
|
|
18
|
+
collapsed?: string[];
|
|
19
|
+
/** Where each hidden panel was, so it comes back to the same place. `sole` says it had a column to itself. */
|
|
20
|
+
places?: Record<string, {
|
|
21
|
+
column: number;
|
|
22
|
+
row: number;
|
|
23
|
+
sole?: boolean;
|
|
24
|
+
}>;
|
|
25
|
+
}
|
|
26
|
+
/** A layout with every share filled in. */
|
|
27
|
+
export type FullLayout = Required<WorkspaceLayout>;
|
|
28
|
+
export declare const MAX_COLUMNS = 4;
|
|
29
|
+
export declare const MAX_ROWS = 4;
|
|
30
|
+
/** The smallest share a column or a panel can be resized to. */
|
|
31
|
+
export declare const MIN_SHARE = 0.12;
|
|
32
|
+
/** How many panels of one column are open at once before the rest fold to their headings. */
|
|
33
|
+
export declare const MAX_OPEN_ROWS = 2;
|
|
34
|
+
/**
|
|
35
|
+
* A layout that can be drawn. Unknown and repeated ids are dropped; a panel
|
|
36
|
+
* the layout does not place is added to the last column (or a new one when
|
|
37
|
+
* that is full); empty columns go; columns and rows past the limits are
|
|
38
|
+
* folded into the last one allowed; shares are filled in. With `ids`, the
|
|
39
|
+
* layout is checked against the panels that exist. Safe to call on anything,
|
|
40
|
+
* including a layout from an agent or from storage.
|
|
41
|
+
*/
|
|
42
|
+
export declare function normalizeLayout(layout: Partial<WorkspaceLayout> | undefined, ids?: string[]): FullLayout;
|
|
43
|
+
/** Opens a folded panel. If its column then has too many open, the others fold. */
|
|
44
|
+
export declare function expandPanel(layout: WorkspaceLayout, id: string): FullLayout;
|
|
45
|
+
/** Folds a panel to its heading. The only open panel of a column stays open. */
|
|
46
|
+
export declare function collapsePanel(layout: WorkspaceLayout, id: string): FullLayout;
|
|
47
|
+
/** Where a panel is, or undefined when it is hidden or unknown. */
|
|
48
|
+
export declare function placeOf(layout: WorkspaceLayout, id: string): {
|
|
49
|
+
column: number;
|
|
50
|
+
row: number;
|
|
51
|
+
} | undefined;
|
|
52
|
+
/** Moves a panel to a row of a column that exists. Dropping it where it already is changes nothing. */
|
|
53
|
+
export declare function movePanel(layout: WorkspaceLayout, id: string, toColumn: number, toRow: number): FullLayout;
|
|
54
|
+
/** Moves a panel into a new column of its own, placed before the column at `insertAt`. */
|
|
55
|
+
export declare function movePanelToNewColumn(layout: WorkspaceLayout, id: string, insertAt: number): FullLayout;
|
|
56
|
+
/**
|
|
57
|
+
* Moves a panel one step, for a keyboard or a menu: up or down within its
|
|
58
|
+
* column, or left or right into the next column (a new column at the edge).
|
|
59
|
+
*/
|
|
60
|
+
export declare function shiftPanel(layout: WorkspaceLayout, id: string, direction: "left" | "right" | "up" | "down"): FullLayout;
|
|
61
|
+
/** Takes a panel off the workspace, remembering where it was. The last panel showing stays. */
|
|
62
|
+
export declare function hidePanel(layout: WorkspaceLayout, id: string): FullLayout;
|
|
63
|
+
/**
|
|
64
|
+
* Brings a hidden panel back. It returns to where it was: its own column
|
|
65
|
+
* again if it had one, or its place in the column it shared. Otherwise it joins the last column while that holds fewer
|
|
66
|
+
* than `MAX_OPEN_ROWS`, and takes a new column after that, so opening a third
|
|
67
|
+
* and fourth panel does not squeeze them all into one column. With no room
|
|
68
|
+
* for a column it joins the emptiest one, and that column's other panels fold.
|
|
69
|
+
*/
|
|
70
|
+
export declare function showPanel(layout: WorkspaceLayout, id: string): FullLayout;
|
|
71
|
+
/** Moves the divider after column `index` by `delta`, a share of the workspace's width. */
|
|
72
|
+
export declare function resizeColumns(layout: WorkspaceLayout, index: number, delta: number): FullLayout;
|
|
73
|
+
/** Moves the divider after row `index` of a column by `delta`, a share of the column's height. */
|
|
74
|
+
export declare function resizeRows(layout: WorkspaceLayout, column: number, index: number, delta: number): FullLayout;
|