react-panel-layout 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/README.md +121 -0
- package/dist/GridLayout-CmzKfbPP.js +1295 -0
- package/dist/GridLayout-CmzKfbPP.js.map +1 -0
- package/dist/GridLayout-Dx3Qofl0.cjs +2 -0
- package/dist/GridLayout-Dx3Qofl0.cjs.map +1 -0
- package/dist/PanelSystemContext.d.ts +25 -0
- package/dist/components/grid/GridLayerList.d.ts +10 -0
- package/dist/components/grid/GridLayerResizeHandles.d.ts +22 -0
- package/dist/components/grid/GridLayout.d.ts +11 -0
- package/dist/components/grid/GridTrackResizeHandle.d.ts +18 -0
- package/dist/components/paneling/FloatingPanelFrame.d.ts +32 -0
- package/dist/components/panels/DropSuggestOverlay.d.ts +13 -0
- package/dist/components/panels/PanelGroupView.d.ts +20 -0
- package/dist/components/resizer/HorizontalDivider.d.ts +14 -0
- package/dist/components/resizer/ResizeHandle.d.ts +24 -0
- package/dist/components/tabs/TabBar.d.ts +22 -0
- package/dist/components/tabs/TabBarTab.d.ts +20 -0
- package/dist/components/tabs/TabDragOverlay.d.ts +5 -0
- package/dist/components/window/DialogOverlay.d.ts +17 -0
- package/dist/components/window/Drawer.d.ts +22 -0
- package/dist/components/window/DrawerLayers.d.ts +9 -0
- package/dist/components/window/PopupLayerPortal.d.ts +10 -0
- package/dist/config/PanelContentDeclaration.d.ts +79 -0
- package/dist/config/index.d.ts +32 -0
- package/dist/config/panelRouter.d.ts +57 -0
- package/dist/config.cjs +2 -0
- package/dist/config.cjs.map +1 -0
- package/dist/config.js +210 -0
- package/dist/config.js.map +1 -0
- package/dist/constants/styles.d.ts +181 -0
- package/dist/floating/index.d.ts +8 -0
- package/dist/floating.cjs +2 -0
- package/dist/floating.cjs.map +1 -0
- package/dist/floating.js +67 -0
- package/dist/floating.js.map +1 -0
- package/dist/hooks/useCSSMatrix.d.ts +47 -0
- package/dist/hooks/useClonedElementPreview.d.ts +7 -0
- package/dist/hooks/useDocumentPointerEvents.d.ts +37 -0
- package/dist/hooks/useEffectEvent.d.ts +17 -0
- package/dist/hooks/useElementComponentWrapper.d.ts +18 -0
- package/dist/hooks/useIntersectionObserver.d.ts +20 -0
- package/dist/hooks/useIsomorphicLayoutEffect.d.ts +23 -0
- package/dist/hooks/useResizeObserver.d.ts +15 -0
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +1863 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/grid/GridLayoutContext.d.ts +34 -0
- package/dist/modules/grid/LayerInstanceContext.d.ts +26 -0
- package/dist/modules/grid/useGridPlacements.d.ts +7 -0
- package/dist/modules/grid/useGridTracks.d.ts +26 -0
- package/dist/modules/grid/useLayerDragHandle.d.ts +2 -0
- package/dist/modules/grid/useLayerInteractions.d.ts +12 -0
- package/dist/modules/keybindings/KeybindingsProvider.d.ts +17 -0
- package/dist/modules/panels/dom/DomRegistry.d.ts +19 -0
- package/dist/modules/panels/index.d.ts +11 -0
- package/dist/modules/panels/interactions/InteractionsContext.d.ts +50 -0
- package/dist/modules/panels/interactions/InteractionsContext.test.d.ts +1 -0
- package/dist/modules/panels/interactions/dnd.d.ts +5 -0
- package/dist/modules/panels/keybindings/KeybindingsInstaller.d.ts +5 -0
- package/dist/modules/panels/layout/adapter.d.ts +21 -0
- package/dist/modules/panels/rendering/GroupContainer.d.ts +11 -0
- package/dist/modules/panels/rendering/RenderBridge.d.ts +8 -0
- package/dist/modules/panels/rendering/RenderContext.d.ts +19 -0
- package/dist/modules/panels/state/PanelSplitHandles.d.ts +8 -0
- package/dist/modules/panels/state/PanelSystemContext.d.ts +148 -0
- package/dist/modules/panels/state/StateContext.d.ts +5 -0
- package/dist/modules/panels/state/cleanup.d.ts +11 -0
- package/dist/modules/panels/state/commands.d.ts +16 -0
- package/dist/modules/panels/state/focus/Context.d.ts +14 -0
- package/dist/modules/panels/state/focus/logic.d.ts +9 -0
- package/dist/modules/panels/state/groups/Context.d.ts +19 -0
- package/dist/modules/panels/state/groups/logic.d.ts +11 -0
- package/dist/modules/panels/state/splitLimits.d.ts +15 -0
- package/dist/modules/panels/state/tree/Context.d.ts +16 -0
- package/dist/modules/panels/state/tree/logic.d.ts +42 -0
- package/dist/modules/panels/state/types.d.ts +135 -0
- package/dist/modules/panels/system/PanelSystem.d.ts +6 -0
- package/dist/modules/resizer/useResizeDrag.d.ts +26 -0
- package/dist/modules/window/useDrawerState.d.ts +6 -0
- package/dist/styles-BMEhL6I0.cjs +2 -0
- package/dist/styles-BMEhL6I0.cjs.map +1 -0
- package/dist/styles-BnvLfp6e.js +49 -0
- package/dist/styles-BnvLfp6e.js.map +1 -0
- package/dist/types.d.ts +114 -0
- package/dist/utils/CSSMatrix.d.ts +42 -0
- package/dist/utils/dialogUtils.d.ts +18 -0
- package/dist/utils/math.d.ts +5 -0
- package/dist/utils/polyfills/createDialogPolyfill.d.ts +8 -0
- package/dist/utils/typedActions.d.ts +37 -0
- package/package.json +78 -0
package/README.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# React Panel Layout
|
|
2
|
+
|
|
3
|
+
> A flexible and customizable panel layout system for React applications
|
|
4
|
+
|
|
5
|
+
## 🎨 Live Demo
|
|
6
|
+
|
|
7
|
+
**[View Live Demo →](https://trkbt10.github.io/react-panel-layout/)**
|
|
8
|
+
|
|
9
|
+
Explore interactive examples of all components, including:
|
|
10
|
+
- Panel layouts with resizable grids
|
|
11
|
+
- Tab systems with drag & drop
|
|
12
|
+
- Floating panels and overlays
|
|
13
|
+
- Various UI patterns and configurations
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Panel System – Customizing Look & Feel
|
|
18
|
+
|
|
19
|
+
This library ships with a default, raised-style tab bar and matching panel shell. You can change both the appearance and structure without forking by providing your own React components and/or CSS variables (design tokens).
|
|
20
|
+
|
|
21
|
+
### Quick Start
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { PanelSystem, buildInitialState } from "react-panel-layout";
|
|
25
|
+
|
|
26
|
+
const state = buildInitialState([{ id: "welcome", title: "Welcome", render: () => <div>Welcome</div> }]);
|
|
27
|
+
|
|
28
|
+
<PanelSystem
|
|
29
|
+
initialState={state}
|
|
30
|
+
createGroupId={() => "g_2"}
|
|
31
|
+
layoutMode="grid"
|
|
32
|
+
gridTracksInteractive={false}
|
|
33
|
+
dragThresholdPx={6}
|
|
34
|
+
/>;
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Provide Your Own Tab Bar
|
|
38
|
+
|
|
39
|
+
Pass a React component via `tabBarComponent`. Your component receives the following props:
|
|
40
|
+
|
|
41
|
+
- `group`: the current group model
|
|
42
|
+
- `onClickTab(tabId)`: activate a tab
|
|
43
|
+
- `onStartDrag?(tabId, groupId, e)`: start tab drag
|
|
44
|
+
- `rootRef?`: assign to the tabbar root element (DnD uses this ref)
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
import type { TabBarRenderProps } from "react-panel-layout";
|
|
48
|
+
|
|
49
|
+
const MyTabBar: React.FC<TabBarRenderProps> = ({ group, onClickTab, onStartDrag, rootRef }) => (
|
|
50
|
+
<div ref={rootRef} role="tablist">
|
|
51
|
+
{group.tabs.map((t, i) => (
|
|
52
|
+
<button
|
|
53
|
+
key={t.id + i}
|
|
54
|
+
role="tab"
|
|
55
|
+
aria-selected={group.activeTabId === t.id}
|
|
56
|
+
onClick={() => onClickTab(t.id)}
|
|
57
|
+
onPointerDown={(e) => onStartDrag?.(t.id, group.id, e)}
|
|
58
|
+
>
|
|
59
|
+
{t.title}
|
|
60
|
+
</button>
|
|
61
|
+
))}
|
|
62
|
+
</div>
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
<PanelSystem tabBarComponent={MyTabBar} {...commonProps} />;
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Provide Your Own Panel Shell
|
|
69
|
+
|
|
70
|
+
Pass a React component via `panelGroupComponent`. Your component receives:
|
|
71
|
+
|
|
72
|
+
- `group`: the current group model
|
|
73
|
+
- `tabbar`: render node for the tab bar
|
|
74
|
+
- `content`: active tab content rendered via context (already memoized)
|
|
75
|
+
- `onContentPointerDown?`: pointer handler for content drag-to-split
|
|
76
|
+
- `groupRef?`, `contentRef?`: assign to wrappers so DnD can compute hit testing
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
import type { PanelGroupRenderProps } from "react-panel-layout";
|
|
80
|
+
|
|
81
|
+
const MyPanelShell: React.FC<PanelGroupRenderProps> = ({
|
|
82
|
+
group,
|
|
83
|
+
tabbar,
|
|
84
|
+
content,
|
|
85
|
+
onContentPointerDown,
|
|
86
|
+
groupRef,
|
|
87
|
+
contentRef,
|
|
88
|
+
}) => (
|
|
89
|
+
<section ref={groupRef} data-group-id={group.id}>
|
|
90
|
+
{tabbar}
|
|
91
|
+
<div ref={contentRef} onPointerDown={onContentPointerDown}>
|
|
92
|
+
{content}
|
|
93
|
+
</div>
|
|
94
|
+
</section>
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
<PanelSystem panelGroupComponent={MyPanelShell} {...commonProps} />;
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Design Tokens (Colors, Sizes)
|
|
101
|
+
|
|
102
|
+
Customize the appearance using CSS variables. Override them in your stylesheet to match your design system.
|
|
103
|
+
|
|
104
|
+
```css
|
|
105
|
+
:root {
|
|
106
|
+
--rpl-color-primary: #3b82f6;
|
|
107
|
+
--rpl-color-tabbar-bg: #202227;
|
|
108
|
+
--rpl-color-tab-active-bg: #2f323a;
|
|
109
|
+
--rpl-radius-tab: 8px;
|
|
110
|
+
--rpl-size-tab-font: 14px;
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
All available CSS variables are documented in [docs/design-tokens.md](./docs/design-tokens.md).
|
|
115
|
+
|
|
116
|
+
**Quick Examples:**
|
|
117
|
+
|
|
118
|
+
- Brand colors: Set `--rpl-color-primary` to your brand color
|
|
119
|
+
- Larger UI: Increase `--rpl-size-tab-font` and spacing variables
|
|
120
|
+
- Light theme: Override color variables for light backgrounds
|
|
121
|
+
- VS Code style: See examples in the design tokens documentation
|