react-tiling-workspace 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +147 -2
- package/dist/components/LayoutPickerDialog-C-Sb3uOl.cjs +517 -0
- package/dist/components/LayoutPickerDialog-C-Sb3uOl.cjs.map +1 -0
- package/dist/components/LayoutPickerDialog-STglqYFI.mjs +500 -0
- package/dist/components/LayoutPickerDialog-STglqYFI.mjs.map +1 -0
- package/dist/components/icons-0kjsH_LJ.cjs +144 -0
- package/dist/components/icons-0kjsH_LJ.cjs.map +1 -0
- package/dist/components/icons-BgtEPXL8.mjs +97 -0
- package/dist/components/icons-BgtEPXL8.mjs.map +1 -0
- package/dist/components/layout-picker.cjs +5 -0
- package/dist/components/layout-picker.d.cts +22 -0
- package/dist/components/layout-picker.d.mts +22 -0
- package/dist/components/layout-picker.mjs +2 -0
- package/dist/components/mobile.cjs +575 -0
- package/dist/components/mobile.cjs.map +1 -0
- package/dist/components/mobile.d.cts +42 -0
- package/dist/components/mobile.d.mts +42 -0
- package/dist/components/mobile.mjs +574 -0
- package/dist/components/mobile.mjs.map +1 -0
- package/dist/components/topbar.cjs +94 -0
- package/dist/components/topbar.cjs.map +1 -0
- package/dist/components/topbar.d.cts +38 -0
- package/dist/components/topbar.d.mts +38 -0
- package/dist/components/topbar.mjs +93 -0
- package/dist/components/topbar.mjs.map +1 -0
- package/dist/components/types-DkwWFcD5.d.mts +32 -0
- package/dist/components/types-qsXC_48o.d.cts +32 -0
- package/dist/index.cjs +3336 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +243 -0
- package/dist/index.d.mts +243 -0
- package/dist/index.mjs +3320 -0
- package/dist/index.mjs.map +1 -0
- package/dist/server/server.cjs +104 -0
- package/dist/server/server.cjs.map +1 -0
- package/dist/server/server.d.cts +71 -0
- package/dist/server/server.d.mts +71 -0
- package/dist/server/server.mjs +95 -0
- package/dist/server/server.mjs.map +1 -0
- package/dist/server/shortcuts.cjs +32 -0
- package/dist/server/shortcuts.cjs.map +1 -0
- package/dist/server/shortcuts.d.cts +6 -0
- package/dist/server/shortcuts.d.mts +6 -0
- package/dist/server/shortcuts.mjs +31 -0
- package/dist/server/shortcuts.mjs.map +1 -0
- package/dist/theme.css +119 -0
- package/package.json +113 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sahil Poonia (NLarge)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,148 @@
|
|
|
1
|
-
#
|
|
1
|
+
# react-tiling-workspace
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A standalone, Tailwind-friendly React tiling workspace with a recursive, draggable/resizable split tree, layout presets, CSS variable theming, and a GPU-composited SVG liquid-morphing mobile bottom bar.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Recursive Drag & Drop Tiling**: Drag panel headers to any edge to create nested horizontal (side-by-side) or vertical (stacked) splits. Drag to the top bar to minimize.
|
|
8
|
+
- **Resizable, Foldable Splits**: Resize split siblings, fold panels, maximize and restore panels. When a panel snaps closed, unaffected siblings keep their size while the open neighbor absorbs the freed space. Panels switch to a compact, clickable rail or bar when their available width or height is too small to use comfortably; titles and actions remain visible where space permits, and clicking restores reading size by borrowing from the sibling with the most spare room. Layout trees are limited to four split levels.
|
|
9
|
+
- **Layout Picker Dialog**: Built-in preset arrangements (1–7 panels) with `onSaveAsDefault` and custom footer slots.
|
|
10
|
+
- **Keyboard Shortcuts**: `1–9` focus/restore panels, `F` fold, `M` maximize/restore, `X` minimize, `R` reset layout.
|
|
11
|
+
- **Liquid-Morphing Mobile Bottom Bar**: Responsive `<1024px` navigation with a sliding active indicator and SVG-filleted floating submenu pill (`prefers-reduced-motion` aware).
|
|
12
|
+
- **Zero Runtime Dependencies**: Only `react` and `react-dom` peer dependencies; inline SVG icons and `--rtw-*` CSS custom properties.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install react-tiling-workspace
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Import the default theme variables once in your app CSS:
|
|
21
|
+
|
|
22
|
+
```css
|
|
23
|
+
@import "react-tiling-workspace/theme.css";
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import { TilingWorkspace, type WorkspacePanelDef } from "react-tiling-workspace";
|
|
30
|
+
|
|
31
|
+
const panels: WorkspacePanelDef[] = [
|
|
32
|
+
{ id: "tasks", title: "Tasks", icon: <TasksIcon />, content: <Tasks /> },
|
|
33
|
+
{ id: "notes", title: "Notes", icon: <NotesIcon />, content: <Notes /> },
|
|
34
|
+
{ id: "activity", title: "Activity", icon: <ActivityIcon />, content: <Activity /> },
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
export function App() {
|
|
38
|
+
return (
|
|
39
|
+
<TilingWorkspace
|
|
40
|
+
panels={panels}
|
|
41
|
+
defaultLayout={{
|
|
42
|
+
type: "split",
|
|
43
|
+
direction: "horizontal",
|
|
44
|
+
children: [
|
|
45
|
+
{ type: "panel", id: "tasks" },
|
|
46
|
+
{
|
|
47
|
+
type: "split",
|
|
48
|
+
direction: "vertical",
|
|
49
|
+
children: [
|
|
50
|
+
{ type: "panel", id: "notes" },
|
|
51
|
+
{ type: "panel", id: "activity" },
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
}}
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Each split must contain at least two children. Panel IDs must be unique and refer to declared panels; trees deeper than four split nodes on any root-to-panel path are rejected. Controlled layouts use `WorkspaceLayoutState` with the same recursive node under `tree`, alongside panel `folds` and `maximizedId`. `LayoutPreset.layout` uses the same split shape, with panel leaves expressed as zero-based `{ type: "panel", index }` positions in the active panel order.
|
|
62
|
+
|
|
63
|
+
## Layout Persistence
|
|
64
|
+
|
|
65
|
+
Uncontrolled layouts are saved to `localStorage` under `react-tiling-workspace.layout.v2` by default. Pass a custom `storageKey` to isolate workspaces, or `storageKey={null}` to disable persistence. Persisted trees are validated against the current panel IDs and depth limit before being restored. For controlled state, pass `layout` and update it from `onLayoutChange`.
|
|
66
|
+
|
|
67
|
+
## Next.js App Router
|
|
68
|
+
|
|
69
|
+
The main entry is a Client Component because the workspace uses interaction, browser storage, and event handlers. Server Components can still provide panel content and icons as React element slots:
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
// app/workspace/page.tsx — Server Component
|
|
73
|
+
import { TilingWorkspace, type WorkspacePanelDef } from "react-tiling-workspace";
|
|
74
|
+
import { TasksView } from "./TasksView";
|
|
75
|
+
import { TasksIcon } from "./TasksIcon";
|
|
76
|
+
|
|
77
|
+
const panels: WorkspacePanelDef[] = [
|
|
78
|
+
{ id: "tasks", title: "Tasks", icon: <TasksIcon />, content: <TasksView /> },
|
|
79
|
+
];
|
|
80
|
+
|
|
81
|
+
export default function WorkspacePage() {
|
|
82
|
+
return <TilingWorkspace panels={panels} />;
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Keep callback props (for example `onSaveAsDefault` and mobile action handlers) inside a Client Component. For server-safe layout helpers and shortcut metadata without importing the interactive UI, use `react-tiling-workspace/server`; shortcut metadata is also available from `react-tiling-workspace/shortcuts`.
|
|
87
|
+
|
|
88
|
+
Optional UI pieces have their own client entry points: `react-tiling-workspace/mobile`, `react-tiling-workspace/layout-picker`, and `react-tiling-workspace/topbar`. Import only the standalone component you use instead of the full workspace entry.
|
|
89
|
+
|
|
90
|
+
## Integrating Keyboard Shortcuts
|
|
91
|
+
|
|
92
|
+
The default shortcuts are exported as metadata so a host app can show them in its own help UI. Disable the workspace's built-in key handling when the host already owns those keys, then connect its command ref to the host's shortcut manager:
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
import { useRef } from "react";
|
|
96
|
+
import {
|
|
97
|
+
TilingWorkspace,
|
|
98
|
+
type WorkspaceCommands,
|
|
99
|
+
type WorkspacePanelDef,
|
|
100
|
+
} from "react-tiling-workspace";
|
|
101
|
+
|
|
102
|
+
export function Workspace({ panels }: { panels: WorkspacePanelDef[] }) {
|
|
103
|
+
const commandsRef = useRef<WorkspaceCommands<string>>(null);
|
|
104
|
+
return (
|
|
105
|
+
<TilingWorkspace
|
|
106
|
+
panels={panels}
|
|
107
|
+
commandsRef={commandsRef}
|
|
108
|
+
keyboardShortcuts={false}
|
|
109
|
+
/>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Use `DEFAULT_WORKSPACE_SHORTCUTS` to populate the existing shortcut UI and call methods such as `commandsRef.current?.toggleFold()` from that UI's registered handlers.
|
|
115
|
+
|
|
116
|
+
## CSS Variable Theming
|
|
117
|
+
|
|
118
|
+
Override any `--rtw-*` variable on `:root` or a wrapper container:
|
|
119
|
+
|
|
120
|
+
```css
|
|
121
|
+
:root {
|
|
122
|
+
--rtw-accent: #1e4d3b;
|
|
123
|
+
--rtw-accent-hover: #163a2c;
|
|
124
|
+
--rtw-bg: #eef2ef;
|
|
125
|
+
--rtw-surface: #fbfdfb;
|
|
126
|
+
--rtw-border: #d6e0da;
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Local Development & Demo
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Build the React client, server helpers, optional UI entries, and theme.css
|
|
134
|
+
npm install
|
|
135
|
+
npm run build
|
|
136
|
+
|
|
137
|
+
# Run the development playground (workspace preview, viewport sizes, themes, and source)
|
|
138
|
+
npm --prefix demo install
|
|
139
|
+
npm run demo:dev
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
`npm run dev` starts the demo's Vite server. The playground is for developing and inspecting the workspace component; the product website is maintained separately. Use `npm run dev:lib` to watch the library build, or `npm run dev:server` to watch the server-safe entry.
|
|
143
|
+
|
|
144
|
+
## Releases
|
|
145
|
+
|
|
146
|
+
Push a stable tag matching the `package.json` version (for example, `v1.2.3`) to run [the publish workflow](.github/workflows/publish.yml). It installs dependencies, type-checks, runs the test/build suite, builds the demo, and publishes the package to npm. Configure npm trusted publishing for this repository and the `publish.yml` workflow before creating a release tag.
|
|
147
|
+
|
|
148
|
+
To notify a separate products-site repository after publishing, set the `PRODUCTS_REPOSITORY` Actions variable to its `owner/repository` name and add a `PRODUCTS_REPOSITORY_DISPATCH_TOKEN` Actions secret using a fine-grained token with **Contents: read and write** permission on that repository. The site repository must handle the `npm-package-published` `repository_dispatch` event, update the package version and lockfile, and open a pull request. If the variable is unset, the package is published without notifying another repository.
|
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
let react = require("react");
|
|
3
|
+
const require_icons = require("./icons-0kjsH_LJ.cjs");
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
// src/layout.ts
|
|
6
|
+
function layoutTemplateSignature(template) {
|
|
7
|
+
if (template.type === "panel") return "p";
|
|
8
|
+
return `${template.direction === "horizontal" ? "h" : "v"}(${template.children.map(layoutTemplateSignature).join(",")})`;
|
|
9
|
+
}
|
|
10
|
+
// src/components/TooltipSlot.tsx
|
|
11
|
+
function TooltipSlot({ renderTooltip, label, shortcut, side = "bottom", children }) {
|
|
12
|
+
if (!renderTooltip) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children });
|
|
13
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: renderTooltip({
|
|
14
|
+
label,
|
|
15
|
+
shortcut,
|
|
16
|
+
side,
|
|
17
|
+
children
|
|
18
|
+
}) });
|
|
19
|
+
}
|
|
20
|
+
// src/components/LayoutPickerDialog.tsx
|
|
21
|
+
function columnsTemplate(columns) {
|
|
22
|
+
let index = 0;
|
|
23
|
+
const columnNodes = columns.map((rowCount) => {
|
|
24
|
+
const panels = Array.from({ length: rowCount }, () => ({
|
|
25
|
+
type: "panel",
|
|
26
|
+
index: index++
|
|
27
|
+
}));
|
|
28
|
+
return panels.length === 1 ? panels[0] : {
|
|
29
|
+
type: "split",
|
|
30
|
+
direction: "vertical",
|
|
31
|
+
children: panels
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
return columnNodes.length === 1 ? columnNodes[0] : {
|
|
35
|
+
type: "split",
|
|
36
|
+
direction: "horizontal",
|
|
37
|
+
children: columnNodes
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function rowsTemplate(rows) {
|
|
41
|
+
let index = 0;
|
|
42
|
+
const rowNodes = rows.map((colCount) => {
|
|
43
|
+
const panels = Array.from({ length: colCount }, () => ({
|
|
44
|
+
type: "panel",
|
|
45
|
+
index: index++
|
|
46
|
+
}));
|
|
47
|
+
return panels.length === 1 ? panels[0] : {
|
|
48
|
+
type: "split",
|
|
49
|
+
direction: "horizontal",
|
|
50
|
+
children: panels
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
return rowNodes.length === 1 ? rowNodes[0] : {
|
|
54
|
+
type: "split",
|
|
55
|
+
direction: "vertical",
|
|
56
|
+
children: rowNodes
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const DEFAULT_LAYOUT_PRESETS = {
|
|
60
|
+
1: [{
|
|
61
|
+
id: "1-single",
|
|
62
|
+
label: "Single Focus",
|
|
63
|
+
layout: columnsTemplate([1])
|
|
64
|
+
}],
|
|
65
|
+
2: [{
|
|
66
|
+
id: "2-cols",
|
|
67
|
+
label: "Split Columns",
|
|
68
|
+
layout: columnsTemplate([1, 1])
|
|
69
|
+
}, {
|
|
70
|
+
id: "2-rows",
|
|
71
|
+
label: "Stacked Rows",
|
|
72
|
+
layout: columnsTemplate([2])
|
|
73
|
+
}],
|
|
74
|
+
3: [
|
|
75
|
+
{
|
|
76
|
+
id: "3-cols",
|
|
77
|
+
label: "Three Columns",
|
|
78
|
+
layout: columnsTemplate([
|
|
79
|
+
1,
|
|
80
|
+
1,
|
|
81
|
+
1
|
|
82
|
+
])
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: "3-1-2",
|
|
86
|
+
label: "Focus + Two Stacked",
|
|
87
|
+
layout: columnsTemplate([1, 2])
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
id: "3-2-1",
|
|
91
|
+
label: "Two Stacked + Focus",
|
|
92
|
+
layout: columnsTemplate([2, 1])
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
id: "3-top-2",
|
|
96
|
+
label: "Hero + Two Below",
|
|
97
|
+
layout: rowsTemplate([1, 2])
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
id: "3-2-bottom",
|
|
101
|
+
label: "Two Above + Wide",
|
|
102
|
+
layout: rowsTemplate([2, 1])
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
id: "3-rows",
|
|
106
|
+
label: "Three Stacked",
|
|
107
|
+
layout: columnsTemplate([3])
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
4: [
|
|
111
|
+
{
|
|
112
|
+
id: "4-studio",
|
|
113
|
+
label: "Studio Trio",
|
|
114
|
+
layout: columnsTemplate([
|
|
115
|
+
1,
|
|
116
|
+
2,
|
|
117
|
+
1
|
|
118
|
+
])
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
id: "4-grid",
|
|
122
|
+
label: "2 × 2 Grid",
|
|
123
|
+
layout: columnsTemplate([2, 2])
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
id: "4-1-1-2",
|
|
127
|
+
label: "Two Cols + Stacked",
|
|
128
|
+
layout: columnsTemplate([
|
|
129
|
+
1,
|
|
130
|
+
1,
|
|
131
|
+
2
|
|
132
|
+
])
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
id: "4-top-3",
|
|
136
|
+
label: "Top Banner + Three",
|
|
137
|
+
layout: rowsTemplate([1, 3])
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
id: "4-1-3",
|
|
141
|
+
label: "Focus + Three Rail",
|
|
142
|
+
layout: columnsTemplate([1, 3])
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
id: "4-cols",
|
|
146
|
+
label: "Four Columns",
|
|
147
|
+
layout: columnsTemplate([
|
|
148
|
+
1,
|
|
149
|
+
1,
|
|
150
|
+
1,
|
|
151
|
+
1
|
|
152
|
+
])
|
|
153
|
+
}
|
|
154
|
+
],
|
|
155
|
+
5: [
|
|
156
|
+
{
|
|
157
|
+
id: "5-1-2-2",
|
|
158
|
+
label: "Focus + 2 × 2",
|
|
159
|
+
layout: columnsTemplate([
|
|
160
|
+
1,
|
|
161
|
+
2,
|
|
162
|
+
2
|
|
163
|
+
])
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
id: "5-2-1-2",
|
|
167
|
+
label: "Command Center",
|
|
168
|
+
layout: columnsTemplate([
|
|
169
|
+
2,
|
|
170
|
+
1,
|
|
171
|
+
2
|
|
172
|
+
])
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
id: "5-2-2-1",
|
|
176
|
+
label: "2 × 2 + Focus",
|
|
177
|
+
layout: columnsTemplate([
|
|
178
|
+
2,
|
|
179
|
+
2,
|
|
180
|
+
1
|
|
181
|
+
])
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
id: "5-top-2-2",
|
|
185
|
+
label: "Header + 2 × 2",
|
|
186
|
+
layout: rowsTemplate([
|
|
187
|
+
1,
|
|
188
|
+
2,
|
|
189
|
+
2
|
|
190
|
+
])
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
id: "5-2-3",
|
|
194
|
+
label: "Two Left + Three Right",
|
|
195
|
+
layout: columnsTemplate([2, 3])
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
id: "5-cols",
|
|
199
|
+
label: "Five Columns",
|
|
200
|
+
layout: columnsTemplate([
|
|
201
|
+
1,
|
|
202
|
+
1,
|
|
203
|
+
1,
|
|
204
|
+
1,
|
|
205
|
+
1
|
|
206
|
+
])
|
|
207
|
+
}
|
|
208
|
+
],
|
|
209
|
+
6: [
|
|
210
|
+
{
|
|
211
|
+
id: "6-3x2",
|
|
212
|
+
label: "3 × 2 Grid",
|
|
213
|
+
layout: columnsTemplate([
|
|
214
|
+
2,
|
|
215
|
+
2,
|
|
216
|
+
2
|
|
217
|
+
])
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
id: "6-2x3",
|
|
221
|
+
label: "2 × 3 Grid",
|
|
222
|
+
layout: columnsTemplate([3, 3])
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
id: "6-1-2-3",
|
|
226
|
+
label: "Cascade 1-2-3",
|
|
227
|
+
layout: columnsTemplate([
|
|
228
|
+
1,
|
|
229
|
+
2,
|
|
230
|
+
3
|
|
231
|
+
])
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
id: "6-1-1-2-2",
|
|
235
|
+
label: "Two Cols + 2 × 2",
|
|
236
|
+
layout: columnsTemplate([
|
|
237
|
+
1,
|
|
238
|
+
1,
|
|
239
|
+
2,
|
|
240
|
+
2
|
|
241
|
+
])
|
|
242
|
+
}
|
|
243
|
+
],
|
|
244
|
+
7: [
|
|
245
|
+
{
|
|
246
|
+
id: "7-2-2-3",
|
|
247
|
+
label: "2 + 2 + 3 Studio",
|
|
248
|
+
layout: columnsTemplate([
|
|
249
|
+
2,
|
|
250
|
+
2,
|
|
251
|
+
3
|
|
252
|
+
])
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
id: "7-3-2-2",
|
|
256
|
+
label: "3 + 2 + 2 Studio",
|
|
257
|
+
layout: columnsTemplate([
|
|
258
|
+
3,
|
|
259
|
+
2,
|
|
260
|
+
2
|
|
261
|
+
])
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
id: "7-2-3-2",
|
|
265
|
+
label: "2 + 3 + 2 Center",
|
|
266
|
+
layout: columnsTemplate([
|
|
267
|
+
2,
|
|
268
|
+
3,
|
|
269
|
+
2
|
|
270
|
+
])
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
id: "7-1-2-2-2",
|
|
274
|
+
label: "Focus + Three Pairs",
|
|
275
|
+
layout: columnsTemplate([
|
|
276
|
+
1,
|
|
277
|
+
2,
|
|
278
|
+
2,
|
|
279
|
+
2
|
|
280
|
+
])
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
id: "7-3-4",
|
|
284
|
+
label: "3 Left + 4 Right",
|
|
285
|
+
layout: columnsTemplate([3, 4])
|
|
286
|
+
}
|
|
287
|
+
]
|
|
288
|
+
};
|
|
289
|
+
function generateFallbackPresets(count) {
|
|
290
|
+
if (count <= 1) return DEFAULT_LAYOUT_PRESETS[1];
|
|
291
|
+
if (count > 5) {
|
|
292
|
+
const makeBalancedColumns = (columnCount) => {
|
|
293
|
+
const base = Math.floor(count / columnCount);
|
|
294
|
+
const extraPanels = count % columnCount;
|
|
295
|
+
return Array.from({ length: columnCount }, (_, index) => base + (index < extraPanels ? 1 : 0));
|
|
296
|
+
};
|
|
297
|
+
const gridColumns = makeBalancedColumns(Math.ceil(Math.sqrt(count)));
|
|
298
|
+
const twoColumns = makeBalancedColumns(2);
|
|
299
|
+
return [{
|
|
300
|
+
id: `${count}-grid`,
|
|
301
|
+
label: `${gridColumns.join(" + ")} Grid`,
|
|
302
|
+
layout: columnsTemplate(gridColumns)
|
|
303
|
+
}, {
|
|
304
|
+
id: `${count}-2cols`,
|
|
305
|
+
label: `${twoColumns.join(" + ")} Split`,
|
|
306
|
+
layout: columnsTemplate(twoColumns)
|
|
307
|
+
}];
|
|
308
|
+
}
|
|
309
|
+
const cols = Array.from({ length: count }, () => 1);
|
|
310
|
+
const half = Math.ceil(count / 2);
|
|
311
|
+
const twoCols = [half, count - half].filter((n) => n > 0);
|
|
312
|
+
return [
|
|
313
|
+
{
|
|
314
|
+
id: `${count}-cols`,
|
|
315
|
+
label: `${count} Columns`,
|
|
316
|
+
layout: columnsTemplate(cols)
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
id: `${count}-2cols`,
|
|
320
|
+
label: `${twoCols.join(" + ")} Split`,
|
|
321
|
+
layout: columnsTemplate(twoCols)
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
id: `${count}-rows`,
|
|
325
|
+
label: `${count} Stacked`,
|
|
326
|
+
layout: columnsTemplate([count])
|
|
327
|
+
}
|
|
328
|
+
];
|
|
329
|
+
}
|
|
330
|
+
function LayoutPickerDialog({ currentOpenCount, currentSignature, maxPanels = 7, presets: customPresets = DEFAULT_LAYOUT_PRESETS, onApplyLayout, onSaveAsDefault, renderFooterExtra, renderTooltip, open: controlledOpen, onOpenChange, iconOnly = false, trigger }) {
|
|
331
|
+
const maxSections = Math.max(1, maxPanels);
|
|
332
|
+
const sectionCounts = Array.from({ length: maxSections }, (_, i) => i + 1);
|
|
333
|
+
const [uncontrolledOpen, setUncontrolledOpen] = (0, react.useState)(false);
|
|
334
|
+
const open = controlledOpen ?? uncontrolledOpen;
|
|
335
|
+
const setOpen = (next) => {
|
|
336
|
+
if (controlledOpen === void 0) setUncontrolledOpen(next);
|
|
337
|
+
onOpenChange?.(next);
|
|
338
|
+
};
|
|
339
|
+
const [savingDefault, setSavingDefault] = (0, react.useState)(false);
|
|
340
|
+
const [selectedCount, setSelectedCount] = (0, react.useState)(() => Math.min(maxSections, Math.max(1, currentOpenCount || Math.min(4, maxSections))));
|
|
341
|
+
(0, react.useEffect)(() => {
|
|
342
|
+
if (!open) return;
|
|
343
|
+
setSelectedCount(Math.min(maxSections, Math.max(1, currentOpenCount || Math.min(4, maxSections))));
|
|
344
|
+
}, [
|
|
345
|
+
open,
|
|
346
|
+
currentOpenCount,
|
|
347
|
+
maxSections
|
|
348
|
+
]);
|
|
349
|
+
(0, react.useEffect)(() => {
|
|
350
|
+
if (!open) return;
|
|
351
|
+
function handleKeyDown(event) {
|
|
352
|
+
if (event.key === "Escape") setOpen(false);
|
|
353
|
+
}
|
|
354
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
355
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
356
|
+
}, [open]);
|
|
357
|
+
const presets = customPresets[selectedCount] ?? generateFallbackPresets(selectedCount);
|
|
358
|
+
const renderPreview = (node, current, key = "root") => {
|
|
359
|
+
if (node.type === "panel") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
360
|
+
className: `flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden rounded-[6px] border transition-colors duration-150 ${current ? "border-[var(--rtw-accent,#6366f1)]/45 bg-[var(--rtw-surface,#ffffff)] shadow-[0_1px_2px_rgba(15,23,42,0.06)]" : "border-[var(--rtw-border-strong,#c9d3e2)]/85 bg-[var(--rtw-surface,#ffffff)] shadow-[0_1px_2px_rgba(15,23,42,0.03)] group-hover:border-[var(--rtw-accent,#6366f1)]/45"}`,
|
|
361
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
362
|
+
className: `flex h-[8px] w-full shrink-0 items-center border-b px-1.5 transition-colors duration-150 ${current ? "border-[var(--rtw-accent,#6366f1)]/20 bg-[var(--rtw-accent-tint,rgba(99,102,241,0.14))]" : "border-[var(--rtw-border-muted,#eaedf4)] bg-[var(--rtw-surface-header,#f8fafc)] group-hover:bg-[var(--rtw-accent-tint,rgba(99,102,241,0.08))]"}`,
|
|
363
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: `h-[2.5px] w-3.5 rounded-full transition-colors duration-150 ${current ? "bg-[var(--rtw-accent,#6366f1)]/60" : "bg-[var(--rtw-border-strong,#c9d3e2)] group-hover:bg-[var(--rtw-accent,#6366f1)]/45"}` })
|
|
364
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
365
|
+
className: "flex min-h-0 flex-1 items-center justify-center overflow-hidden p-1",
|
|
366
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
367
|
+
className: `text-[11px] font-semibold leading-none tabular-nums transition-colors duration-150 ${current ? "text-[var(--rtw-accent,#6366f1)]/85" : "text-[var(--rtw-text-faint,#94a3b8)]/80 group-hover:text-[var(--rtw-text-subtle,#64748b)]"}`,
|
|
368
|
+
children: node.index + 1
|
|
369
|
+
})
|
|
370
|
+
})]
|
|
371
|
+
}, key);
|
|
372
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
373
|
+
className: `flex min-h-0 min-w-0 flex-1 gap-2 ${node.direction === "horizontal" ? "flex-row" : "flex-col"}`,
|
|
374
|
+
children: node.children.map((child, index) => renderPreview(child, current, `${key}-${index}`))
|
|
375
|
+
}, key);
|
|
376
|
+
};
|
|
377
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [trigger === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltipSlot, {
|
|
378
|
+
renderTooltip,
|
|
379
|
+
label: "Choose workspace layout",
|
|
380
|
+
side: "bottom",
|
|
381
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
382
|
+
type: "button",
|
|
383
|
+
onClick: () => setOpen(true),
|
|
384
|
+
"aria-label": "Choose workspace layout",
|
|
385
|
+
title: renderTooltip ? void 0 : "Choose workspace layout",
|
|
386
|
+
className: iconOnly ? "inline-flex size-8 cursor-pointer items-center justify-center rounded-lg text-[var(--rtw-text-muted,#475569)] transition-colors hover:bg-[var(--rtw-surface-subtle,#edf1f7)] hover:text-[var(--rtw-text-strong,#0f172a)]" : "inline-flex h-8 cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-lg border border-[var(--rtw-border,#dfe5ef)] bg-[var(--rtw-surface-header,#f8fafc)] px-2.5 text-xs font-medium text-[var(--rtw-text,#1e293b)] transition-colors hover:border-[var(--rtw-border-strong,#c9d3e2)] hover:bg-[var(--rtw-surface-subtle,#edf1f7)]",
|
|
387
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_icons.LayoutIcon, { className: "size-3.5 text-[var(--rtw-accent,#6366f1)]" }), !iconOnly && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "Layouts" })]
|
|
388
|
+
})
|
|
389
|
+
}) : trigger, open && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
390
|
+
role: "dialog",
|
|
391
|
+
"aria-modal": "true",
|
|
392
|
+
"aria-labelledby": "rtw-layout-picker-title",
|
|
393
|
+
className: "rtw-animate-backdrop fixed inset-0 z-50 flex items-center justify-center bg-black/45 p-4 backdrop-blur-sm",
|
|
394
|
+
onClick: () => setOpen(false),
|
|
395
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
396
|
+
className: "rtw-animate-modal flex max-h-[calc(100dvh-2rem)] w-full max-w-6xl flex-col overflow-hidden rounded-[var(--rtw-radius-dialog,1rem)] border border-[var(--rtw-border,#dfe5ef)] bg-[var(--rtw-surface,#ffffff)] shadow-[var(--rtw-shadow-dialog)]",
|
|
397
|
+
onClick: (e) => e.stopPropagation(),
|
|
398
|
+
children: [
|
|
399
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
400
|
+
className: "flex shrink-0 items-center justify-between border-b border-[var(--rtw-border-muted,#eaedf4)] bg-[var(--rtw-surface-header,#f8fafc)] px-6 py-4",
|
|
401
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
402
|
+
className: "flex items-center gap-3",
|
|
403
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
404
|
+
className: "grid size-9 place-items-center rounded-xl bg-[var(--rtw-accent-tint,rgba(99,102,241,0.12))] text-[var(--rtw-accent,#6366f1)]",
|
|
405
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_icons.LayoutIcon, { className: "size-4.5" })
|
|
406
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
|
|
407
|
+
id: "rtw-layout-picker-title",
|
|
408
|
+
className: "text-sm font-semibold tracking-[-0.01em] text-[var(--rtw-text-strong,#0f172a)]",
|
|
409
|
+
children: "Workspace Layouts"
|
|
410
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
411
|
+
className: "text-xs text-[var(--rtw-text-subtle,#64748b)]",
|
|
412
|
+
children: "Choose a panel count and click any layout to arrange your workspace."
|
|
413
|
+
})] })]
|
|
414
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
415
|
+
type: "button",
|
|
416
|
+
onClick: () => setOpen(false),
|
|
417
|
+
"aria-label": "Close layout dialog",
|
|
418
|
+
className: "flex size-8 cursor-pointer items-center justify-center rounded-lg text-[var(--rtw-text-subtle,#64748b)] transition-colors hover:bg-[var(--rtw-surface-hover,#e5ebf3)] hover:text-[var(--rtw-text-strong,#0f172a)]",
|
|
419
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_icons.CloseIcon, { className: "size-4" })
|
|
420
|
+
})]
|
|
421
|
+
}),
|
|
422
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
423
|
+
className: "space-y-5 overflow-y-auto p-6",
|
|
424
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
425
|
+
className: "flex flex-wrap items-center justify-between gap-3",
|
|
426
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
427
|
+
className: "flex items-center gap-2",
|
|
428
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
429
|
+
className: "text-xs font-medium text-[var(--rtw-text-muted,#475569)]",
|
|
430
|
+
children: "Visible panels"
|
|
431
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
432
|
+
className: "rounded-md bg-[var(--rtw-surface-subtle,#edf1f7)] px-1.5 py-0.5 text-[11px] font-medium tabular-nums text-[var(--rtw-text-subtle,#64748b)]",
|
|
433
|
+
children: [
|
|
434
|
+
presets.length,
|
|
435
|
+
" ",
|
|
436
|
+
presets.length === 1 ? "layout" : "layouts"
|
|
437
|
+
]
|
|
438
|
+
})]
|
|
439
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
440
|
+
role: "group",
|
|
441
|
+
"aria-label": "Number of panels",
|
|
442
|
+
className: "inline-flex items-center gap-0.5 rounded-xl border border-[var(--rtw-border,#dfe5ef)] bg-[var(--rtw-surface-subtle,#edf1f7)] p-1",
|
|
443
|
+
children: sectionCounts.map((count) => {
|
|
444
|
+
const isSelected = selectedCount === count;
|
|
445
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
446
|
+
type: "button",
|
|
447
|
+
onClick: () => setSelectedCount(count),
|
|
448
|
+
"aria-pressed": isSelected,
|
|
449
|
+
className: `flex h-7 min-w-9 cursor-pointer items-center justify-center rounded-lg px-2.5 text-xs font-semibold tabular-nums transition-all duration-150 ${isSelected ? "bg-[var(--rtw-accent,#6366f1)] text-[var(--rtw-accent-foreground,#ffffff)] shadow-sm" : "text-[var(--rtw-text-muted,#475569)] hover:bg-[var(--rtw-surface-hover,#e5ebf3)]/60 hover:text-[var(--rtw-text-strong,#0f172a)]"}`,
|
|
450
|
+
children: count
|
|
451
|
+
}, count);
|
|
452
|
+
})
|
|
453
|
+
})]
|
|
454
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
455
|
+
className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3",
|
|
456
|
+
children: presets.map((preset) => {
|
|
457
|
+
const isCurrent = layoutTemplateSignature(preset.layout) === currentSignature;
|
|
458
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
459
|
+
type: "button",
|
|
460
|
+
"aria-label": `Apply ${preset.label}`,
|
|
461
|
+
"aria-pressed": isCurrent,
|
|
462
|
+
title: preset.label,
|
|
463
|
+
onClick: () => {
|
|
464
|
+
onApplyLayout(preset.layout);
|
|
465
|
+
setOpen(false);
|
|
466
|
+
},
|
|
467
|
+
className: `group relative flex aspect-[16/10] w-full cursor-pointer overflow-hidden rounded-xl border p-3 text-left transition-all duration-150 ${isCurrent ? "border-[var(--rtw-accent,#6366f1)] bg-[var(--rtw-accent-tint,rgba(99,102,241,0.08))] ring-2 ring-[var(--rtw-accent-ring,rgba(99,102,241,0.48))] shadow-sm" : "border-[var(--rtw-border,#dfe5ef)] bg-[var(--rtw-bg,#f1f4f9)] hover:-translate-y-0.5 hover:border-[var(--rtw-accent,#6366f1)]/60 hover:bg-[var(--rtw-surface-subtle,#edf1f7)] hover:shadow-md"}`,
|
|
468
|
+
children: [renderPreview(preset.layout, isCurrent), isCurrent && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
469
|
+
"aria-hidden": "true",
|
|
470
|
+
className: "absolute right-2 top-2 z-10 grid size-5 place-items-center rounded-full bg-[var(--rtw-accent,#6366f1)] text-[var(--rtw-accent-foreground,#ffffff)] shadow-sm ring-2 ring-[var(--rtw-surface,#ffffff)]",
|
|
471
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_icons.CheckIcon, { className: "size-3" })
|
|
472
|
+
})]
|
|
473
|
+
}, preset.id);
|
|
474
|
+
})
|
|
475
|
+
})]
|
|
476
|
+
}),
|
|
477
|
+
(onSaveAsDefault || renderFooterExtra) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
478
|
+
className: "flex shrink-0 flex-wrap items-center justify-between gap-2 border-t border-[var(--rtw-border-muted,#eaedf4)] bg-[var(--rtw-surface-header,#f8fafc)] px-6 py-3.5",
|
|
479
|
+
children: [onSaveAsDefault ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
480
|
+
type: "button",
|
|
481
|
+
disabled: savingDefault,
|
|
482
|
+
onClick: async () => {
|
|
483
|
+
setSavingDefault(true);
|
|
484
|
+
try {
|
|
485
|
+
await onSaveAsDefault();
|
|
486
|
+
} finally {
|
|
487
|
+
setSavingDefault(false);
|
|
488
|
+
}
|
|
489
|
+
},
|
|
490
|
+
className: "inline-flex h-8 cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-lg border border-[var(--rtw-border-strong,#c9d3e2)] bg-[var(--rtw-surface,#ffffff)] px-3 text-xs font-medium text-[var(--rtw-text,#1e293b)] transition-colors hover:border-[var(--rtw-accent,#6366f1)]/60 hover:text-[var(--rtw-accent,#6366f1)] disabled:opacity-50",
|
|
491
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_icons.BookmarkIcon, { className: "size-3.5 text-[var(--rtw-accent,#6366f1)]" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: savingDefault ? "Saving…" : "Save current as default" })]
|
|
492
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {}), renderFooterExtra?.({ close: () => setOpen(false) })]
|
|
493
|
+
})
|
|
494
|
+
]
|
|
495
|
+
})
|
|
496
|
+
})] });
|
|
497
|
+
}
|
|
498
|
+
Object.defineProperty(exports, "DEFAULT_LAYOUT_PRESETS", {
|
|
499
|
+
enumerable: true,
|
|
500
|
+
get: function() {
|
|
501
|
+
return DEFAULT_LAYOUT_PRESETS;
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
Object.defineProperty(exports, "LayoutPickerDialog", {
|
|
505
|
+
enumerable: true,
|
|
506
|
+
get: function() {
|
|
507
|
+
return LayoutPickerDialog;
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
Object.defineProperty(exports, "TooltipSlot", {
|
|
511
|
+
enumerable: true,
|
|
512
|
+
get: function() {
|
|
513
|
+
return TooltipSlot;
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
//# sourceMappingURL=LayoutPickerDialog-C-Sb3uOl.cjs.map
|