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.
Files changed (92) hide show
  1. package/README.md +121 -0
  2. package/dist/GridLayout-CmzKfbPP.js +1295 -0
  3. package/dist/GridLayout-CmzKfbPP.js.map +1 -0
  4. package/dist/GridLayout-Dx3Qofl0.cjs +2 -0
  5. package/dist/GridLayout-Dx3Qofl0.cjs.map +1 -0
  6. package/dist/PanelSystemContext.d.ts +25 -0
  7. package/dist/components/grid/GridLayerList.d.ts +10 -0
  8. package/dist/components/grid/GridLayerResizeHandles.d.ts +22 -0
  9. package/dist/components/grid/GridLayout.d.ts +11 -0
  10. package/dist/components/grid/GridTrackResizeHandle.d.ts +18 -0
  11. package/dist/components/paneling/FloatingPanelFrame.d.ts +32 -0
  12. package/dist/components/panels/DropSuggestOverlay.d.ts +13 -0
  13. package/dist/components/panels/PanelGroupView.d.ts +20 -0
  14. package/dist/components/resizer/HorizontalDivider.d.ts +14 -0
  15. package/dist/components/resizer/ResizeHandle.d.ts +24 -0
  16. package/dist/components/tabs/TabBar.d.ts +22 -0
  17. package/dist/components/tabs/TabBarTab.d.ts +20 -0
  18. package/dist/components/tabs/TabDragOverlay.d.ts +5 -0
  19. package/dist/components/window/DialogOverlay.d.ts +17 -0
  20. package/dist/components/window/Drawer.d.ts +22 -0
  21. package/dist/components/window/DrawerLayers.d.ts +9 -0
  22. package/dist/components/window/PopupLayerPortal.d.ts +10 -0
  23. package/dist/config/PanelContentDeclaration.d.ts +79 -0
  24. package/dist/config/index.d.ts +32 -0
  25. package/dist/config/panelRouter.d.ts +57 -0
  26. package/dist/config.cjs +2 -0
  27. package/dist/config.cjs.map +1 -0
  28. package/dist/config.js +210 -0
  29. package/dist/config.js.map +1 -0
  30. package/dist/constants/styles.d.ts +181 -0
  31. package/dist/floating/index.d.ts +8 -0
  32. package/dist/floating.cjs +2 -0
  33. package/dist/floating.cjs.map +1 -0
  34. package/dist/floating.js +67 -0
  35. package/dist/floating.js.map +1 -0
  36. package/dist/hooks/useCSSMatrix.d.ts +47 -0
  37. package/dist/hooks/useClonedElementPreview.d.ts +7 -0
  38. package/dist/hooks/useDocumentPointerEvents.d.ts +37 -0
  39. package/dist/hooks/useEffectEvent.d.ts +17 -0
  40. package/dist/hooks/useElementComponentWrapper.d.ts +18 -0
  41. package/dist/hooks/useIntersectionObserver.d.ts +20 -0
  42. package/dist/hooks/useIsomorphicLayoutEffect.d.ts +23 -0
  43. package/dist/hooks/useResizeObserver.d.ts +15 -0
  44. package/dist/index.cjs +3 -0
  45. package/dist/index.cjs.map +1 -0
  46. package/dist/index.d.ts +20 -0
  47. package/dist/index.js +1863 -0
  48. package/dist/index.js.map +1 -0
  49. package/dist/modules/grid/GridLayoutContext.d.ts +34 -0
  50. package/dist/modules/grid/LayerInstanceContext.d.ts +26 -0
  51. package/dist/modules/grid/useGridPlacements.d.ts +7 -0
  52. package/dist/modules/grid/useGridTracks.d.ts +26 -0
  53. package/dist/modules/grid/useLayerDragHandle.d.ts +2 -0
  54. package/dist/modules/grid/useLayerInteractions.d.ts +12 -0
  55. package/dist/modules/keybindings/KeybindingsProvider.d.ts +17 -0
  56. package/dist/modules/panels/dom/DomRegistry.d.ts +19 -0
  57. package/dist/modules/panels/index.d.ts +11 -0
  58. package/dist/modules/panels/interactions/InteractionsContext.d.ts +50 -0
  59. package/dist/modules/panels/interactions/InteractionsContext.test.d.ts +1 -0
  60. package/dist/modules/panels/interactions/dnd.d.ts +5 -0
  61. package/dist/modules/panels/keybindings/KeybindingsInstaller.d.ts +5 -0
  62. package/dist/modules/panels/layout/adapter.d.ts +21 -0
  63. package/dist/modules/panels/rendering/GroupContainer.d.ts +11 -0
  64. package/dist/modules/panels/rendering/RenderBridge.d.ts +8 -0
  65. package/dist/modules/panels/rendering/RenderContext.d.ts +19 -0
  66. package/dist/modules/panels/state/PanelSplitHandles.d.ts +8 -0
  67. package/dist/modules/panels/state/PanelSystemContext.d.ts +148 -0
  68. package/dist/modules/panels/state/StateContext.d.ts +5 -0
  69. package/dist/modules/panels/state/cleanup.d.ts +11 -0
  70. package/dist/modules/panels/state/commands.d.ts +16 -0
  71. package/dist/modules/panels/state/focus/Context.d.ts +14 -0
  72. package/dist/modules/panels/state/focus/logic.d.ts +9 -0
  73. package/dist/modules/panels/state/groups/Context.d.ts +19 -0
  74. package/dist/modules/panels/state/groups/logic.d.ts +11 -0
  75. package/dist/modules/panels/state/splitLimits.d.ts +15 -0
  76. package/dist/modules/panels/state/tree/Context.d.ts +16 -0
  77. package/dist/modules/panels/state/tree/logic.d.ts +42 -0
  78. package/dist/modules/panels/state/types.d.ts +135 -0
  79. package/dist/modules/panels/system/PanelSystem.d.ts +6 -0
  80. package/dist/modules/resizer/useResizeDrag.d.ts +26 -0
  81. package/dist/modules/window/useDrawerState.d.ts +6 -0
  82. package/dist/styles-BMEhL6I0.cjs +2 -0
  83. package/dist/styles-BMEhL6I0.cjs.map +1 -0
  84. package/dist/styles-BnvLfp6e.js +49 -0
  85. package/dist/styles-BnvLfp6e.js.map +1 -0
  86. package/dist/types.d.ts +114 -0
  87. package/dist/utils/CSSMatrix.d.ts +42 -0
  88. package/dist/utils/dialogUtils.d.ts +18 -0
  89. package/dist/utils/math.d.ts +5 -0
  90. package/dist/utils/polyfills/createDialogPolyfill.d.ts +8 -0
  91. package/dist/utils/typedActions.d.ts +37 -0
  92. 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