@aiquants/resize-panels 1.9.0 → 2.0.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 +129 -22
- package/dist/GlobalDebugOverlay-Cf3GOn2A.cjs +1 -0
- package/dist/{GlobalDebugOverlay-Do70T2l6.js → GlobalDebugOverlay-DQtUdNeF.js} +28 -28
- package/dist/debugOverlayStore-D7FT6zPE.js +135 -0
- package/dist/debugOverlayStore-DY09saU8.cjs +1 -0
- package/dist/index-DZ0itiBD.js +1299 -0
- package/dist/index-DqATP_BA.cjs +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -29
- package/dist/index.js +25 -13
- package/dist/src/GlobalDebugOverlay.d.ts.map +1 -0
- package/dist/src/Panel.d.ts +46 -0
- package/dist/src/Panel.d.ts.map +1 -0
- package/dist/src/PanelDebugInfo.d.ts +34 -0
- package/dist/src/PanelDebugInfo.d.ts.map +1 -0
- package/dist/src/PanelGroup.d.ts.map +1 -0
- package/dist/src/PanelResizeHandle.d.ts.map +1 -0
- package/dist/src/allocateLayout.d.ts +60 -0
- package/dist/src/allocateLayout.d.ts.map +1 -0
- package/dist/src/context.d.ts.map +1 -0
- package/dist/{debugOverlayStore.d.ts → src/debugOverlayStore.d.ts} +10 -2
- package/dist/src/debugOverlayStore.d.ts.map +1 -0
- package/dist/src/hooks.d.ts +48 -0
- package/dist/src/hooks.d.ts.map +1 -0
- package/dist/src/index.d.ts +32 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/reducer.d.ts +49 -0
- package/dist/src/reducer.d.ts.map +1 -0
- package/dist/src/roundHalfToEven.d.ts.map +1 -0
- package/dist/{types.d.ts → src/types.d.ts} +164 -60
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/utils/simple-logger.d.ts.map +1 -0
- package/dist/src/utils.d.ts +164 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/styles/resize-panels.standalone.css +1 -1
- package/dist/tests/support/dom-harness.d.ts +89 -0
- package/dist/tests/support/dom-harness.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/GlobalDebugOverlay.tsx +3 -3
- package/src/Panel.tsx +203 -541
- package/src/PanelDebugInfo.tsx +52 -106
- package/src/PanelGroup.tsx +27 -42
- package/src/PanelResizeHandle.tsx +470 -509
- package/src/allocateLayout.ts +412 -0
- package/src/debugOverlayStore.ts +19 -15
- package/src/hooks.ts +187 -779
- package/src/index.ts +12 -3
- package/src/reducer.ts +364 -1126
- package/src/types.ts +149 -63
- package/src/utils.ts +205 -164
- package/dist/GlobalDebugOverlay-sEQN6exo.cjs +0 -1
- package/dist/GlobalDebugOverlay.d.ts.map +0 -1
- package/dist/Panel.d.ts +0 -7
- package/dist/Panel.d.ts.map +0 -1
- package/dist/PanelDebugInfo.d.ts +0 -26
- package/dist/PanelDebugInfo.d.ts.map +0 -1
- package/dist/PanelGroup.d.ts.map +0 -1
- package/dist/PanelResizeHandle.d.ts.map +0 -1
- package/dist/context.d.ts.map +0 -1
- package/dist/debugOverlayStore-Cntyxboe.js +0 -141
- package/dist/debugOverlayStore-Dkl-fHoa.cjs +0 -1
- package/dist/debugOverlayStore.d.ts.map +0 -1
- package/dist/hooks.d.ts +0 -45
- package/dist/hooks.d.ts.map +0 -1
- package/dist/index-B6YGX2DH.js +0 -2009
- package/dist/index-DssZUxGw.cjs +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/reducer.d.ts +0 -39
- package/dist/reducer.d.ts.map +0 -1
- package/dist/roundHalfToEven.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/utils/simple-logger.d.ts.map +0 -1
- package/dist/utils.d.ts +0 -61
- package/dist/utils.d.ts.map +0 -1
- /package/dist/{GlobalDebugOverlay.d.ts → src/GlobalDebugOverlay.d.ts} +0 -0
- /package/dist/{PanelGroup.d.ts → src/PanelGroup.d.ts} +0 -0
- /package/dist/{PanelResizeHandle.d.ts → src/PanelResizeHandle.d.ts} +0 -0
- /package/dist/{context.d.ts → src/context.d.ts} +0 -0
- /package/dist/{roundHalfToEven.d.ts → src/roundHalfToEven.d.ts} +0 -0
- /package/dist/{utils → src/utils}/simple-logger.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
# @aiquants/resize-panels
|
|
2
2
|
|
|
3
|
-
Resizable panel layout components for React
|
|
3
|
+
Resizable panel layout components for React, built on one rule: **there is a single function that decides panel sizes, and the handle is the boundary rather than a thing positioned near it.**
|
|
4
|
+
|
|
5
|
+
Every state change — first paint, container resize, drag, collapse, restored layout — runs the same allocator, so the panels always fill the container exactly and the handle can never drift away from the edge it moves.
|
|
4
6
|
|
|
5
7
|
## Key Features
|
|
6
8
|
|
|
7
|
-
- **
|
|
8
|
-
- **
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
11
|
-
- **
|
|
12
|
-
- **Auto-Persistence**:
|
|
13
|
-
- **Debug & Visualization**:
|
|
9
|
+
- **One allocator, one geometry**: `allocatePanelSizes` distributes the container among the panels (proportional water-filling with per-panel minimum/maximum bounds). `Σ panel sizes == the group's content box` holds after every transition the declared bounds allow, and the reducer logs a breach of that invariant rather than letting it pass silently — a container the minimums overflow, or that the maximums cannot reach, is reported as a constraint violation instead.
|
|
10
|
+
- **A handle that cannot drift**: the resize handle renders a zero-length in-flow flex item at the boundary and draws its hit area symmetrically around it. Nothing computes its position, so it stays on the boundary in LTR and RTL, horizontal and vertical, with group padding, and during every frame of a live container resize. A drag divides the pointer's travel by the group's visual scale, so the grab point stays under the cursor even below a transformed ancestor.
|
|
11
|
+
- **Predictable proportions**: a flexible panel's size is a weight — only the ratio between weights matters, unless the panel declares `flexAdjustPriority`, which reads the same number as a claim on that share of the container. A dragged layout becomes a fixed point of the allocator, so it survives the next resize as a ratio instead of snapping back.
|
|
12
|
+
- **Directional Collapsible Control**: declarative `collapsible` settings (`from: 'start' | 'end' | 'both'`) and the `usePanelControls` hook support collapsing/expanding from drags and from UI controls; expanding restores the layout the panel had before it closed.
|
|
13
|
+
- **Keyboard & Touch Accessibility**: handles are `role="separator"` widgets whose `aria-valuenow` / `aria-valuemin` / `aria-valuemax` publish the boundary and the travel *this* handle can reach, collapsing included; a collapsed neighbour is reported as length 0 rather than making the values disappear. Arrow keys resize (5x step with Shift), reopen a collapsed neighbour from the side it closed towards and collapse a panel the pair's travel cannot shrink further, while a handle with nowhere to go leaves the key to the page. A drag needs the primary button and survives multi-touch and `pointercancel`.
|
|
14
|
+
- **Auto-Persistence**: set `autoSaveId` to store each panel's open length and collapsed flag in `localStorage` next to its panel id, so a layout saved by a different set of panels is rejected instead of being applied by position.
|
|
15
|
+
- **Debug & Visualization**: enable `showDebugInfo` to inspect allocations through the per-panel `PanelDebugInfo` badge and a global overlay (lazily imported; production bundles without it create no per-panel observers at all). A constraint violation needs no flag: the group draws its own placeholder over the panels whenever the allocator reports one.
|
|
14
16
|
|
|
15
17
|
## Installation
|
|
16
18
|
|
|
@@ -41,7 +43,7 @@ export const Example = () => {
|
|
|
41
43
|
const baseId = useId()
|
|
42
44
|
|
|
43
45
|
return (
|
|
44
|
-
<PanelGroup id={`${baseId}-group`} direction="horizontal"
|
|
46
|
+
<PanelGroup id={`${baseId}-group`} direction="horizontal" style={{ height: "24rem" }}>
|
|
45
47
|
<Panel id={`${baseId}-left`} defaultSize={{ value: 200, unit: "pixels" }} className="bg-slate-100">
|
|
46
48
|
Left Panel
|
|
47
49
|
</Panel>
|
|
@@ -59,7 +61,7 @@ export const Example = () => {
|
|
|
59
61
|
Specify `collapsible={{ from: "start" }}` or `collapsible={{ from: "end" }}` on a `Panel` to enable automatic collapse/expand when dragging the corresponding handle to container boundaries. Set `defaultCollapsed` to set initial state to collapsed. Use `collapsible={{ from: "both" }}` to allow collapsing from either edge.
|
|
60
62
|
|
|
61
63
|
```tsx
|
|
62
|
-
<PanelGroup direction="horizontal"
|
|
64
|
+
<PanelGroup direction="horizontal" style={{ height: "24rem" }}>
|
|
63
65
|
<Panel id="sidebar" defaultSize={{ value: 240, unit: "pixels" }} collapsible={{ from: "end" }}>
|
|
64
66
|
Sidebar
|
|
65
67
|
</Panel>
|
|
@@ -98,7 +100,7 @@ const PanelToggleButtons = ({ panelId, label }: { panelId: string; label: string
|
|
|
98
100
|
}
|
|
99
101
|
|
|
100
102
|
export const Example = () => (
|
|
101
|
-
<PanelGroup direction="horizontal"
|
|
103
|
+
<PanelGroup direction="horizontal" style={{ height: "24rem" }}>
|
|
102
104
|
<Panel id="sidebar" defaultSize={{ value: 240, unit: "pixels" }} collapsible={{ from: "end" }}>
|
|
103
105
|
<PanelToggleButtons panelId="sidebar" label="Sidebar" />
|
|
104
106
|
</Panel>
|
|
@@ -124,7 +126,7 @@ export const Example = () => (
|
|
|
124
126
|
| `direction` | `'horizontal' \| 'vertical'` | Panel layout orientation |
|
|
125
127
|
| `className` / `style` | `string` / `React.CSSProperties` | Additional styling for the container |
|
|
126
128
|
| `children` | `React.ReactNode` | `Panel` and `PanelResizeHandle` child elements |
|
|
127
|
-
| `showDebugInfo` | `boolean` | Enables `PanelDebugInfo` and global debug overlay |
|
|
129
|
+
| `showDebugInfo` | `boolean` | Enables the per-panel `PanelDebugInfo` badge and the global debug overlay |
|
|
128
130
|
| `onLayout` | `(sizes: number[]) => void` | Callback emitting updated pixel size arrays on resize/init |
|
|
129
131
|
| `autoSaveId` | `string` | Key used to automatically persist and restore panel sizes in `localStorage` |
|
|
130
132
|
|
|
@@ -132,14 +134,27 @@ export const Example = () => (
|
|
|
132
134
|
|
|
133
135
|
| Property | Type | Description |
|
|
134
136
|
| --- | --- | --- |
|
|
135
|
-
| `id` | `string` | Panel identifier.
|
|
136
|
-
| `defaultSize` | `{ value: number; unit: 'pixels' \| 'percentage' } \| number` | Initial panel size (numbers parsed as percentages) |
|
|
137
|
+
| `id` | `string` | Panel identifier (reflected in `data-panel-id`). Optional — a `useId`-derived id is generated when omitted — but fixed at mount: a later change is ignored with a warning |
|
|
138
|
+
| `defaultSize` | `{ value: number; unit: 'pixels' \| 'percentage' } \| number` | Initial panel size (numbers parsed as percentages; `50%` when omitted) |
|
|
137
139
|
| `minSize` / `maxSize` | `FlexibleSize` | Panel size boundaries (pixels or percentages) |
|
|
138
140
|
| `collapsible` | `{ from: 'start' \| 'end' \| 'both' }` | Declarative collapsible edge configuration |
|
|
139
141
|
| `defaultCollapsed` | `boolean` | Whether the panel starts collapsed |
|
|
140
|
-
| `pixelAdjustPriority` | `number` |
|
|
142
|
+
| `pixelAdjustPriority` | `number` | Order in which pixel panels are served when space is scarce (higher first) |
|
|
143
|
+
| `flexAdjustPriority` | `number` | Serving order among flexible panels (higher first); declaring it also reads `defaultSize` as an absolute claim on that share of the container |
|
|
144
|
+
| `contentOverflow` | `React.CSSProperties["overflow"]` | Overflow of the panel's content wrapper (`auto` by default) |
|
|
141
145
|
| `className` / `style` | `string` / `React.CSSProperties` | Panel container styles |
|
|
142
146
|
|
|
147
|
+
`Panel` and `PanelGroup` forward any other DOM attribute (`data-testid`, `aria-*`, event handlers) to their
|
|
148
|
+
element, except the ones they compute themselves: `Panel` owns `aria-hidden`, which follows the collapsed state,
|
|
149
|
+
and its own `data-panel-*` attributes, while `PanelGroup` owns `data-panel-group-id` and
|
|
150
|
+
`data-panel-group-direction` — the first is what `getPanelGroupElement` looks up, the second is what marks an
|
|
151
|
+
element as a group for `findOwningGroup` and therefore for every handle. `aria-hidden` is removed
|
|
152
|
+
from `PanelProps` to state that ownership, but TypeScript does not type-check JSX attribute names containing a
|
|
153
|
+
hyphen, so neither it nor a `data-panel-*` / `data-panel-group-*` of your own is rejected at compile time: what
|
|
154
|
+
enforces the contract is the runtime override, which applies these attributes after everything you forwarded. A
|
|
155
|
+
`data-panel-group-id` you pass disappears altogether when the group itself has no `id`. Both elements merge your
|
|
156
|
+
`className` with their own (`panel` / `panel-group`) instead of replacing it.
|
|
157
|
+
|
|
143
158
|
### PanelResizeHandle Properties
|
|
144
159
|
|
|
145
160
|
| Property | Type | Description |
|
|
@@ -157,23 +172,82 @@ export const Example = () => (
|
|
|
157
172
|
| `className` / `style` | `string` / `React.CSSProperties` | Additional styling for the resize handle |
|
|
158
173
|
| `children` | `React.ReactNode` | Custom indicator element rendered inside handle (overrides default indicator) |
|
|
159
174
|
|
|
160
|
-
> Handles render as `<button>` elements accessible via arrow keys (`←`/`→` for horizontal, `↑`/`↓` for vertical)
|
|
175
|
+
> Handles render as `<button role="separator">` elements accessible via arrow keys (`←`/`→` for horizontal, `↑`/`↓` for vertical); holding `Shift` increases the step 5x. Under `dir="rtl"` the drag and keyboard directions follow the visual layout. The handle sits inside a zero-length anchor placed by flex layout, so its hit area is centred on the panel boundary without any position arithmetic.
|
|
176
|
+
|
|
177
|
+
`PanelResizeHandle` forwards any other DOM attribute to its `<button>`, and calls your `onPointerDown` /
|
|
178
|
+
`onKeyDown` before its own handling — calling `preventDefault()` in them stops the library's gesture from starting.
|
|
179
|
+
The attributes it computes from the layout (`role`, `aria-orientation`, `aria-valuenow` / `aria-valuemin` /
|
|
180
|
+
`aria-valuemax`, `aria-disabled`, `aria-hidden`) are removed from `PanelResizeHandleProps`, though only `role` is
|
|
181
|
+
actually caught by the compiler — the hyphenated names are not type-checked in JSX, and it is the runtime override
|
|
182
|
+
that keeps them the library's. `aria-label` stays yours and replaces the built-in description, and `title` defaults
|
|
183
|
+
to that same description.
|
|
184
|
+
|
|
185
|
+
Your `style` reaches the button between two library layers. The handle's resolved dimensions are published as CSS
|
|
186
|
+
custom properties — `--rp-handle-thickness`, `--rp-indicator-thickness`, `--rp-indicator-length`,
|
|
187
|
+
`--rp-indicator-bar-thickness`, `--rp-indicator-bar-length` — *before* it, so decorations of your own can be sized
|
|
188
|
+
from the same numbers and may redefine them; the declarations that keep the hit area centred on the boundary
|
|
189
|
+
(`position: absolute`, `zIndex: 20`, `touchAction: none`, the logical insets and the thickness / cross-axis `100%`
|
|
190
|
+
box) are applied *after* it and take no override. While the group reports a constraint violation, every handle is
|
|
191
|
+
hidden (`display: none` on its anchor) as well as disabled.
|
|
161
192
|
|
|
162
193
|
## Hooks & Utilities
|
|
163
194
|
|
|
164
|
-
- `useResizablePanels`:
|
|
165
|
-
- `usePanelGroup`:
|
|
166
|
-
- `usePanelControls`:
|
|
167
|
-
- `
|
|
195
|
+
- `useResizablePanels`: the hook behind `PanelGroup`. It measures the container, keeps the panel order equal to DOM order, notifies `onLayout`, persists the layout and returns the group's base style — it never computes a panel size.
|
|
196
|
+
- `usePanelGroup` / `PanelGroupContext`: context accessor, and the context itself, for the panel list, the container length, the constraint violation and `layoutOrderKey` — the document order of the panels and handle anchors, which changes even when only a handle moved to another boundary.
|
|
197
|
+
- `usePanelControls`: `collapse`, `expand` and `toggle` for a given panel id.
|
|
198
|
+
- `allocatePanelSizes`, `resolvePanelBounds`, `isPixelPanel`: the layout calculation itself, exported for tests and for hosts that drive their own container.
|
|
199
|
+
- `panelReducer`, `initialPanelGroupLayoutState`, `getPanelPreferenceInPixels`, `findLayoutInvariantBreach`: the state machine around the allocator, the length a layout should persist, and the `Σ sizes == container` check.
|
|
200
|
+
- `getContainerSize`: measure one axis of an element in layout pixels; it returns `{ content, border }`, and `content` (padding and borders removed) is the length the allocator fills.
|
|
201
|
+
- `findOwningGroup`, `getGroupLayoutElements`: resolve the group that owns an element, and that group's panels and handle anchors in document order — across wrapper elements, `display: contents` included, while skipping both a nested group's own elements and any `data-panel-id` that belongs to a panel's content rather than to this group.
|
|
202
|
+
- `saveLayout` & `loadLayout`: persist or restore a layout (`{ id, size, collapsed }[]`).
|
|
203
|
+
- `clamp`, `getConstraintInPixels`, `normalizeSizeConfig`, `percentageToPixels`, `toRoundedPercentage`, `calculateSnapThreshold`: the unit conversions and thresholds the components share.
|
|
168
204
|
- `getPanelElement`, `getPanelGroupElement`, `getResizeHandleElement`: DOM element query helpers via `data-*` attributes.
|
|
169
205
|
|
|
206
|
+
Every public type (`PanelProps`, `PanelGroupProps`, `PanelResizeHandleProps`, `PanelLayoutData`, `PanelRegistration`, `PersistedPanelSize`, `PanelGroupLayoutState`, `PanelAction`, `LayoutAllocation`, `PanelBounds`, `ContainerAxisMeasurement`, …) is re-exported from the package root; `docs/specs` (`00-architecture-overview.md` §8) lists the surface in full.
|
|
207
|
+
|
|
208
|
+
## How sizes are decided
|
|
209
|
+
|
|
210
|
+
| Panel kind | What it declares | What it gets |
|
|
211
|
+
| --- | --- | --- |
|
|
212
|
+
| Flexible (`percentage`, or a bare number) | a weight — only the ratio between such weights matters | its share of what is left after the panels with an absolute target, clamped to its bounds |
|
|
213
|
+
| Flexible with `flexAdjustPriority` | the same number, read as a claim on that share of the container | that claim, served after the pixel panels and clamped to its bounds |
|
|
214
|
+
| Pixel (`pixels`) | an absolute length | that length, clamped to its bounds, once the panels ahead of it in `pixelAdjustPriority` order have been served |
|
|
215
|
+
|
|
216
|
+
Scarcity and surplus are two ends of one order. While space is scarce, targets are served in that order — pixel
|
|
217
|
+
panels by `pixelAdjustPriority`, then flexible panels by `flexAdjustPriority` — so the panel last in line is the
|
|
218
|
+
one that falls short of its target, even when every declared minimum would fit. While space is left over, it is
|
|
219
|
+
offered to the ratio panels by weight, then to the prioritized flexible panels by weight, then to the pixel panels
|
|
220
|
+
in `pixelAdjustPriority` order up to their `maxSize`, and last, in equal parts, to the flexible panels that have a
|
|
221
|
+
weight of 0 and no `flexAdjustPriority`. A sidebar declared in pixels therefore grows past its declared length when
|
|
222
|
+
nothing else can absorb the surplus: give it a `maxSize` to pin it. When a clamp bites, the residue is
|
|
223
|
+
redistributed among the remaining panels of the same stage in their own ratio, and the container ends up exactly
|
|
224
|
+
filled as long as one panel can still take the surplus; when none can, the gap is reported — as a constraint
|
|
225
|
+
violation when the panels' maximums cannot reach the container, and as a logged invariant breach otherwise. The
|
|
226
|
+
full statement, including the proofs of ratio preservation, continuity and the drag fixed point, is in `docs/specs`
|
|
227
|
+
(`11-layout-allocator.md`).
|
|
228
|
+
|
|
170
229
|
## Layout Persistence
|
|
171
230
|
|
|
172
|
-
When `autoSaveId` is provided to `PanelGroup`,
|
|
231
|
+
When `autoSaveId` is provided to `PanelGroup`, the layout is written to `localStorage` under the key
|
|
232
|
+
`panel-layout-<autoSaveId>` as `{ id, size, collapsed }[]`, 200ms after the layout stops changing: a change arriving
|
|
233
|
+
inside that window restarts the timer rather than forcing a write, so a drag never runs synchronous storage I/O once
|
|
234
|
+
per frame. The one write outside that timer is the flush on unmount, which hands over the entries still pending so
|
|
235
|
+
the last layout is not lost to a navigation. The stored `size` is the panel's preference — the length it occupies
|
|
236
|
+
while open — not its allocated size, so a panel saved while collapsed still knows what to reopen to. On the next
|
|
237
|
+
mount, and again whenever `autoSaveId` changes, the payload is applied only if it names exactly the panels that are
|
|
238
|
+
present; a payload from a different panel set is ignored rather than applied by position.
|
|
239
|
+
Restoring into a container of a different length scales a flexible panel by ratio, because its stored length is
|
|
240
|
+
re-read as a share of the current container, while a pixel panel restores the absolute length it had.
|
|
173
241
|
|
|
174
242
|
## Debugging & Inspection
|
|
175
243
|
|
|
176
|
-
Enabling `showDebugInfo` on `PanelGroup` renders
|
|
244
|
+
Enabling `showDebugInfo` on `PanelGroup` renders inspection metrics over each `Panel` (container length, allocated
|
|
245
|
+
size, preference, resolved bounds) along with a global inspector: a header counting the groups, panels and resize
|
|
246
|
+
handles on the page, then one card per group carrying its direction and container box and, for every panel, the
|
|
247
|
+
state size next to the measured size, both percentages, the preference, the unit, the declared bounds and the two
|
|
248
|
+
priorities. Individual handle measurements and constraint violations are not part of that overlay; a violation is
|
|
249
|
+
shown by the placeholder the group draws over its panels, with or without the flag. Debug components are lazily
|
|
250
|
+
imported (`React.lazy`); without the flag no per-panel `ResizeObserver` is created.
|
|
177
251
|
|
|
178
252
|
## Styling (CSS)
|
|
179
253
|
|
|
@@ -196,6 +270,39 @@ The package provides two CSS consumption options:
|
|
|
196
270
|
|
|
197
271
|
Dark mode activates based on the `.dark` class on `<html>`.
|
|
198
272
|
|
|
273
|
+
### Style ownership
|
|
274
|
+
|
|
275
|
+
Your `className` and `style` reach all three components, but the declarations the layout itself depends on are
|
|
276
|
+
applied *after* them and do not accept an override:
|
|
277
|
+
|
|
278
|
+
- **Group**: `display: flex`, `flexDirection`, `alignItems: stretch`, `gap: 0px`, `position: relative`,
|
|
279
|
+
`boxSizing: border-box`, `writingMode: horizontal-tb`. The presentation defaults (`width`, `height`, `minWidth`,
|
|
280
|
+
`minHeight`, `overflow`) are yours to change.
|
|
281
|
+
- **Panel**: the flex triple (`flexBasis` / `flexGrow` / `flexShrink`), `order: 0`, `margin: 0`, `display: flex`,
|
|
282
|
+
`flexDirection: column`, `position: relative`, `boxSizing: border-box`, `minWidth` and `minHeight: 0`,
|
|
283
|
+
`maxWidth` and `maxHeight: none`, the cross-axis `100%`, and `display: none` while collapsed. The presentation
|
|
284
|
+
defaults you can override are `overflow: hidden` and `isolation: isolate`.
|
|
285
|
+
- **Handle button**: `position: absolute`, `zIndex: 20`, `touchAction: none`, the logical inset that centres it on
|
|
286
|
+
the boundary, its primary-axis thickness and its cross-axis `100%`. The `--rp-*` custom properties are placed
|
|
287
|
+
before your `style`, so those you may redefine.
|
|
288
|
+
|
|
289
|
+
Both halves of that list are written to the `style` attribute, so a presentation default is overridable by your
|
|
290
|
+
`style` **only** — a utility class loses to the inline declaration it would replace, which is why the examples
|
|
291
|
+
above give the group its height through `style` rather than an `h-*` class. Every property the components do not
|
|
292
|
+
write inline (colour, padding, borders, radius, …) stays entirely yours to set by class.
|
|
293
|
+
|
|
294
|
+
A panel owns `maxWidth` / `maxHeight` because a single utility class (`max-w-*` and friends) would otherwise draw
|
|
295
|
+
it shorter than the length the allocator handed out, leaving state and rendering disagreeing with the handle stuck.
|
|
296
|
+
It defaults to `isolation: isolate` so that a `z-index` used inside a panel cannot rise above the handles; a panel
|
|
297
|
+
whose content must escape its own box — a `position: fixed` maximised overlay, say — opts out with
|
|
298
|
+
`style={{ isolation: "auto" }}` and accepts that the content may then cover a handle. That trade-off is inherent to
|
|
299
|
+
stacking contexts: nothing can both take part in the panel's own stacking order and paint above its siblings.
|
|
300
|
+
|
|
301
|
+
A panel renders its children inside an in-flow `flex: 1 1 auto` wrapper, so padding you set on a panel behaves
|
|
302
|
+
normally; `contentOverflow` chooses how that wrapper scrolls. The group keeps `overflow: hidden` so that a handle
|
|
303
|
+
straddling a boundary cannot raise a scrollbar — at the cost that when an edge panel collapses, the outer half of
|
|
304
|
+
the handle now sitting on the group's own edge is clipped (its centre stays on the boundary).
|
|
305
|
+
|
|
199
306
|
## Demo App
|
|
200
307
|
|
|
201
308
|
Run the included workspace demo app:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),A=require("react"),P=require("react-dom"),x=require("./debugOverlayStore-DY09saU8.cjs"),R=require("./index-DqATP_BA.cjs"),n=(o,i)=>typeof o!="number"||!Number.isFinite(o)?"—":`${(o<0?0:o).toFixed(8)}${i}`,T={position:"fixed",left:"50%",bottom:"20px",transform:"translate(-50%, 0)",zIndex:100,maxWidth:"min(90vw, 1120px)",width:"100%",borderRadius:"14px",backgroundColor:"rgba(15, 23, 42, 0.72)",color:"#e2e8f0",fontFamily:"monospace",fontSize:"11px",lineHeight:1.6,boxShadow:"0 22px 45px rgba(15,23,42,0.45)",border:"1px solid rgba(148, 163, 184, 0.22)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",pointerEvents:"auto",overflow:"auto"},Y={display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:"12px"},w={display:"flex",flexDirection:"column",gap:"4px"},D={padding:"6px 10px",borderRadius:"9999px",border:"1px solid rgba(148, 163, 184, 0.35)",color:"#e2e8f0",fontWeight:600,fontSize:"10px",letterSpacing:"0.03em",textTransform:"uppercase",cursor:"pointer",transition:"background-color 0.18s ease, border-color 0.18s ease"},C={padding:"10px 12px",borderRadius:"10px",backgroundColor:"rgba(30, 41, 59, 0.55)",border:"1px solid rgba(148, 163, 184, 0.18)",display:"flex",flexDirection:"column",gap:"10px"},N={padding:"8px 10px",borderRadius:"8px",backgroundColor:"rgba(15, 23, 42, 0.55)",border:"1px solid rgba(148, 163, 184, 0.16)",display:"flex",flexDirection:"column",gap:"4px"},p={display:"flex",justifyContent:"space-between",alignItems:"center",gap:"6px"},k={display:"grid",gridTemplateColumns:"auto 1fr",gap:"2px 10px",color:"#e2e8f0"},G={padding:"2px 6px",borderRadius:"9999px",fontSize:"10px",textTransform:"uppercase"},I=({groupId:o})=>x.useDebugOverlayOwnerId()!==o?null:e.jsx(u,{}),u=()=>{const i=x.useDebugOverlaySnapshot().groups,[t,g]=A.useState(!0);if(i.length===0||typeof document>"u")return null;const b=i.reduce((s,a)=>s+a.panels.length,0),h=i.reduce((s,a)=>s+(a.handles?.length??0),0),f=()=>g(s=>!s),m=e.jsxs("div",{style:{...T,padding:t?"10px 18px":"14px 18px",maxHeight:t?"52px":"min(65vh, 520px)",transition:"max-height 0.24s ease, padding 0.24s ease"},children:[e.jsxs("div",{style:{...Y,marginBottom:t?0:"12px"},children:[e.jsxs("div",{style:w,children:[e.jsx("span",{style:{fontWeight:700,fontSize:"12px",letterSpacing:"0.03em"},children:"Panel Overview"}),e.jsxs("span",{style:{color:"#cbd5f5"},children:["groups: ",i.length," / panels: ",b," / resizers: ",h]})]}),e.jsx("button",{type:"button",onClick:f,style:{...D,backgroundColor:t?"rgba(59, 130, 246, 0.2)":"rgba(71, 85, 105, 0.45)"},title:t?"Panel Overview を開く":"Panel Overview を閉じる",children:t?"開く":"閉じる"})]}),!t&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",maxHeight:"45vh",overflowY:"auto",paddingRight:"6px"},children:i.map((s,a)=>{const l=s.direction==="horizontal"?s.containerSize.width:s.containerSize.height;return e.jsxs("div",{style:C,children:[e.jsxs("div",{style:{...p,flexWrap:"wrap",gap:"10px",color:"#dbeafe"},children:[e.jsxs("span",{style:{fontWeight:600,fontSize:"11px",letterSpacing:"0.02em",textTransform:"uppercase"},children:["group ",a+1,": ",s.displayName]}),e.jsxs("span",{children:["direction: ",s.direction," / container: ",n(s.containerSize.width,"px")," × ",n(s.containerSize.height,"px")]})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(220px, 1fr))",gap:"10px"},children:s.panels.map((r,y)=>{const d=r.measuredPixelSize??r.size,S=r.size,j=n(S,"px"),v=l>0?r.size/l*100:void 0,E=r.measuredPercentageSize!==void 0?r.measuredPercentageSize:l>0?d/l*100:void 0,c=r.collapsed||d<=R.PANEL_SNAP_THRESHOLD,O=r.collapsed?"collapsed":c?"hidden":"visible",z=n(v,"%"),L=n(E,"%"),_=n(d,"px");return e.jsxs("div",{style:N,children:[e.jsxs("div",{style:p,children:[e.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},children:r.id}),e.jsx("span",{style:{...G,backgroundColor:r.collapsed?"rgba(251, 113, 133, 0.25)":c?"rgba(250, 204, 21, 0.25)":"rgba(74, 222, 128, 0.25)",color:r.collapsed?"#fecdd3":c?"#fef08a":"#bbf7d0"},children:O})]}),e.jsxs("div",{style:k,children:[e.jsx("span",{children:"size (state):"}),e.jsx("span",{children:j}),e.jsx("span",{children:"size (measured):"}),e.jsx("span",{children:_}),e.jsx("span",{children:"percentage (state):"}),e.jsx("span",{children:z}),e.jsx("span",{children:"preference:"}),e.jsx("span",{children:r.sizeUnit==="pixels"?n(r.preferredPixelSize,"px"):n(r.preferredPercentageSize,"%")}),e.jsx("span",{children:"percentage (measured):"}),e.jsx("span",{children:L}),e.jsx("span",{children:"unit:"}),e.jsx("span",{children:r.sizeUnit}),e.jsx("span",{children:"min:"}),e.jsx("span",{children:r.minSize!==void 0?JSON.stringify(r.minSize):"—"}),e.jsx("span",{children:"max:"}),e.jsx("span",{children:r.maxSize!==void 0?JSON.stringify(r.maxSize):"—"}),e.jsx("span",{children:"priority:"}),e.jsx("span",{children:r.pixelAdjustPriority??"—"}),e.jsx("span",{children:"flex priority:"}),e.jsx("span",{children:r.flexAdjustPriority??"—"})]})]},r.id||y)})})]},s.groupId)})})]});return P.createPortal(m,document.body)};exports.GlobalDebugOverlay=u;exports.GlobalDebugOverlayGate=I;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
2
|
import { useState as A } from "react";
|
|
3
3
|
import { createPortal as P } from "react-dom";
|
|
4
|
-
import { useDebugOverlayOwnerId as R, useDebugOverlaySnapshot as T } from "./debugOverlayStore-
|
|
5
|
-
import { P as Y } from "./index-
|
|
6
|
-
const
|
|
4
|
+
import { useDebugOverlayOwnerId as R, useDebugOverlaySnapshot as T } from "./debugOverlayStore-D7FT6zPE.js";
|
|
5
|
+
import { P as Y } from "./index-DZ0itiBD.js";
|
|
6
|
+
const s = (a, n) => typeof a != "number" || !Number.isFinite(a) ? "—" : `${(a < 0 ? 0 : a).toFixed(8)}${n}`, w = {
|
|
7
7
|
position: "fixed",
|
|
8
8
|
left: "50%",
|
|
9
9
|
bottom: "20px",
|
|
@@ -75,11 +75,11 @@ const a = (s, n) => typeof s != "number" || !Number.isFinite(s) ? "—" : `${(s
|
|
|
75
75
|
borderRadius: "9999px",
|
|
76
76
|
fontSize: "10px",
|
|
77
77
|
textTransform: "uppercase"
|
|
78
|
-
},
|
|
78
|
+
}, J = ({ groupId: a }) => R() !== a ? null : /* @__PURE__ */ e(W, {}), W = () => {
|
|
79
79
|
const n = T().groups, [o, g] = A(!0);
|
|
80
80
|
if (n.length === 0 || typeof document > "u")
|
|
81
81
|
return null;
|
|
82
|
-
const u = n.reduce((
|
|
82
|
+
const u = n.reduce((i, d) => i + d.panels.length, 0), h = n.reduce((i, d) => i + (d.handles?.length ?? 0), 0), m = () => g((i) => !i), f = /* @__PURE__ */ t(
|
|
83
83
|
"div",
|
|
84
84
|
{
|
|
85
85
|
style: {
|
|
@@ -145,8 +145,8 @@ const a = (s, n) => typeof s != "number" || !Number.isFinite(s) ? "—" : `${(s
|
|
|
145
145
|
overflowY: "auto",
|
|
146
146
|
paddingRight: "6px"
|
|
147
147
|
},
|
|
148
|
-
children: n.map((
|
|
149
|
-
const l =
|
|
148
|
+
children: n.map((i, d) => {
|
|
149
|
+
const l = i.direction === "horizontal" ? i.containerSize.width : i.containerSize.height;
|
|
150
150
|
return /* @__PURE__ */ t("div", { style: k, children: [
|
|
151
151
|
/* @__PURE__ */ t(
|
|
152
152
|
"div",
|
|
@@ -171,17 +171,17 @@ const a = (s, n) => typeof s != "number" || !Number.isFinite(s) ? "—" : `${(s
|
|
|
171
171
|
"group ",
|
|
172
172
|
d + 1,
|
|
173
173
|
": ",
|
|
174
|
-
|
|
174
|
+
i.displayName
|
|
175
175
|
]
|
|
176
176
|
}
|
|
177
177
|
),
|
|
178
178
|
/* @__PURE__ */ t("span", { children: [
|
|
179
179
|
"direction: ",
|
|
180
|
-
|
|
180
|
+
i.direction,
|
|
181
181
|
" / container: ",
|
|
182
|
-
|
|
182
|
+
s(i.containerSize.width, "px"),
|
|
183
183
|
" × ",
|
|
184
|
-
|
|
184
|
+
s(i.containerSize.height, "px")
|
|
185
185
|
] })
|
|
186
186
|
]
|
|
187
187
|
}
|
|
@@ -194,18 +194,18 @@ const a = (s, n) => typeof s != "number" || !Number.isFinite(s) ? "—" : `${(s
|
|
|
194
194
|
gridTemplateColumns: "repeat(auto-fill, minmax(220px, 1fr))",
|
|
195
195
|
gap: "10px"
|
|
196
196
|
},
|
|
197
|
-
children:
|
|
198
|
-
const
|
|
197
|
+
children: i.panels.map((r, b) => {
|
|
198
|
+
const p = r.measuredPixelSize ?? r.size, y = r.size, S = s(y, "px"), v = l > 0 ? r.size / l * 100 : void 0, E = r.measuredPercentageSize !== void 0 ? r.measuredPercentageSize : l > 0 ? p / l * 100 : void 0, c = r.collapsed || p <= Y, z = r.collapsed ? "collapsed" : c ? "hidden" : "visible", L = s(v, "%"), O = s(E, "%"), _ = s(p, "px");
|
|
199
199
|
return /* @__PURE__ */ t("div", { style: I, children: [
|
|
200
200
|
/* @__PURE__ */ t("div", { style: x, children: [
|
|
201
|
-
/* @__PURE__ */ e("span", { style: { flex: 1, minWidth: 0, overflow: "hidden", textOverflow: "ellipsis" }, children:
|
|
201
|
+
/* @__PURE__ */ e("span", { style: { flex: 1, minWidth: 0, overflow: "hidden", textOverflow: "ellipsis" }, children: r.id }),
|
|
202
202
|
/* @__PURE__ */ e(
|
|
203
203
|
"span",
|
|
204
204
|
{
|
|
205
205
|
style: {
|
|
206
206
|
...H,
|
|
207
|
-
backgroundColor:
|
|
208
|
-
color:
|
|
207
|
+
backgroundColor: r.collapsed ? "rgba(251, 113, 133, 0.25)" : c ? "rgba(250, 204, 21, 0.25)" : "rgba(74, 222, 128, 0.25)",
|
|
208
|
+
color: r.collapsed ? "#fecdd3" : c ? "#fef08a" : "#bbf7d0"
|
|
209
209
|
},
|
|
210
210
|
children: z
|
|
211
211
|
}
|
|
@@ -217,27 +217,27 @@ const a = (s, n) => typeof s != "number" || !Number.isFinite(s) ? "—" : `${(s
|
|
|
217
217
|
/* @__PURE__ */ e("span", { children: "size (measured):" }),
|
|
218
218
|
/* @__PURE__ */ e("span", { children: _ }),
|
|
219
219
|
/* @__PURE__ */ e("span", { children: "percentage (state):" }),
|
|
220
|
-
/* @__PURE__ */ e("span", { children: O }),
|
|
221
|
-
/* @__PURE__ */ e("span", { children: "percentage (measured):" }),
|
|
222
220
|
/* @__PURE__ */ e("span", { children: L }),
|
|
221
|
+
/* @__PURE__ */ e("span", { children: "preference:" }),
|
|
222
|
+
/* @__PURE__ */ e("span", { children: r.sizeUnit === "pixels" ? s(r.preferredPixelSize, "px") : s(r.preferredPercentageSize, "%") }),
|
|
223
|
+
/* @__PURE__ */ e("span", { children: "percentage (measured):" }),
|
|
224
|
+
/* @__PURE__ */ e("span", { children: O }),
|
|
223
225
|
/* @__PURE__ */ e("span", { children: "unit:" }),
|
|
224
|
-
/* @__PURE__ */ e("span", { children:
|
|
226
|
+
/* @__PURE__ */ e("span", { children: r.sizeUnit }),
|
|
225
227
|
/* @__PURE__ */ e("span", { children: "min:" }),
|
|
226
|
-
/* @__PURE__ */ e("span", { children:
|
|
227
|
-
/* @__PURE__ */ e("span", { children: "auto min:" }),
|
|
228
|
-
/* @__PURE__ */ e("span", { children: i.autoMinSize !== void 0 ? JSON.stringify(i.autoMinSize) : "—" }),
|
|
228
|
+
/* @__PURE__ */ e("span", { children: r.minSize !== void 0 ? JSON.stringify(r.minSize) : "—" }),
|
|
229
229
|
/* @__PURE__ */ e("span", { children: "max:" }),
|
|
230
|
-
/* @__PURE__ */ e("span", { children:
|
|
230
|
+
/* @__PURE__ */ e("span", { children: r.maxSize !== void 0 ? JSON.stringify(r.maxSize) : "—" }),
|
|
231
231
|
/* @__PURE__ */ e("span", { children: "priority:" }),
|
|
232
|
-
/* @__PURE__ */ e("span", { children:
|
|
232
|
+
/* @__PURE__ */ e("span", { children: r.pixelAdjustPriority ?? "—" }),
|
|
233
233
|
/* @__PURE__ */ e("span", { children: "flex priority:" }),
|
|
234
|
-
/* @__PURE__ */ e("span", { children:
|
|
234
|
+
/* @__PURE__ */ e("span", { children: r.flexAdjustPriority ?? "—" })
|
|
235
235
|
] })
|
|
236
|
-
] },
|
|
236
|
+
] }, r.id || b);
|
|
237
237
|
})
|
|
238
238
|
}
|
|
239
239
|
)
|
|
240
|
-
] },
|
|
240
|
+
] }, i.groupId);
|
|
241
241
|
})
|
|
242
242
|
}
|
|
243
243
|
)
|
|
@@ -248,5 +248,5 @@ const a = (s, n) => typeof s != "number" || !Number.isFinite(s) ? "—" : `${(s
|
|
|
248
248
|
};
|
|
249
249
|
export {
|
|
250
250
|
W as GlobalDebugOverlay,
|
|
251
|
-
|
|
251
|
+
J as GlobalDebugOverlayGate
|
|
252
252
|
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { useSyncExternalStore as x } from "react";
|
|
2
|
+
const k = (l) => JSON.stringify(
|
|
3
|
+
l.map((e) => ({
|
|
4
|
+
id: e.id,
|
|
5
|
+
size: e.size,
|
|
6
|
+
sizeUnit: e.sizeUnit,
|
|
7
|
+
preferredPercentageSize: e.preferredPercentageSize,
|
|
8
|
+
preferredPixelSize: e.preferredPixelSize,
|
|
9
|
+
minSize: e.minSize ?? null,
|
|
10
|
+
maxSize: e.maxSize ?? null,
|
|
11
|
+
collapseFromStart: e.collapseFromStart,
|
|
12
|
+
collapseFromEnd: e.collapseFromEnd,
|
|
13
|
+
collapsed: e.collapsed,
|
|
14
|
+
collapsedByDirection: e.collapsedByDirection,
|
|
15
|
+
preferenceBeforeCollapse: e.preferenceBeforeCollapse,
|
|
16
|
+
pixelAdjustPriority: e.pixelAdjustPriority ?? null,
|
|
17
|
+
flexAdjustPriority: e.flexAdjustPriority ?? null,
|
|
18
|
+
measuredPixelSize: e.measuredPixelSize ?? null,
|
|
19
|
+
measuredPercentageSize: e.measuredPercentageSize ?? null
|
|
20
|
+
}))
|
|
21
|
+
), H = (l) => JSON.stringify(
|
|
22
|
+
l.map((e) => ({
|
|
23
|
+
id: e.id,
|
|
24
|
+
thickness: e.thickness,
|
|
25
|
+
visible: e.visible,
|
|
26
|
+
direction: e.direction,
|
|
27
|
+
startPanelId: e.startPanelId ?? null,
|
|
28
|
+
endPanelId: e.endPanelId ?? null
|
|
29
|
+
}))
|
|
30
|
+
), N = () => {
|
|
31
|
+
const l = /* @__PURE__ */ new Set(), e = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Set();
|
|
32
|
+
let c = null, v = 0, u = !0, h = [], P = {
|
|
33
|
+
ownerId: null,
|
|
34
|
+
groups: h
|
|
35
|
+
};
|
|
36
|
+
const y = () => {
|
|
37
|
+
for (const s of l)
|
|
38
|
+
s();
|
|
39
|
+
}, S = () => {
|
|
40
|
+
u = !0, y();
|
|
41
|
+
}, p = () => {
|
|
42
|
+
const s = c;
|
|
43
|
+
if (s && d.has(s))
|
|
44
|
+
return !1;
|
|
45
|
+
c = null;
|
|
46
|
+
const r = d.values().next();
|
|
47
|
+
return r.done || (c = r.value), s !== c;
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
subscribe: (s) => (l.add(s), () => {
|
|
51
|
+
l.delete(s);
|
|
52
|
+
}),
|
|
53
|
+
getSnapshot: () => (p() && (u = !0), u && (h = Array.from(e.values()).sort((r, n) => r.index - n.index).map(({ serializedPanels: r, serializedHandles: n, ...f }) => f), P = {
|
|
54
|
+
ownerId: c,
|
|
55
|
+
groups: h
|
|
56
|
+
}, u = !1), P),
|
|
57
|
+
getOwnerId: () => (p() && (u = !0), c),
|
|
58
|
+
enableGroup: (s) => {
|
|
59
|
+
const r = d.size;
|
|
60
|
+
d.add(s), d.size !== r && p() && S();
|
|
61
|
+
},
|
|
62
|
+
disableGroup: (s) => {
|
|
63
|
+
d.delete(s) && p() && S();
|
|
64
|
+
},
|
|
65
|
+
updateGroup: (s, r) => {
|
|
66
|
+
const n = e.get(s), f = n?.index ?? v++, b = k(r.panels), m = H(r.handles), G = n?.displayName !== r.displayName, O = n?.direction !== r.direction, w = n ? n.containerSize.width !== r.containerSize.width || n.containerSize.height !== r.containerSize.height : !0;
|
|
67
|
+
let g = n?.serializedPanels !== b;
|
|
68
|
+
if (!g && n)
|
|
69
|
+
if (n.panels.length !== r.panels.length)
|
|
70
|
+
g = !0;
|
|
71
|
+
else
|
|
72
|
+
for (let o = 0; o < r.panels.length; o += 1) {
|
|
73
|
+
const i = n.panels[o], t = r.panels[o];
|
|
74
|
+
if (!(i && t)) {
|
|
75
|
+
g = !0;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
if (i.id !== t.id || i.size !== t.size || i.preferredPercentageSize !== t.preferredPercentageSize || i.preferredPixelSize !== t.preferredPixelSize || i.collapsed !== t.collapsed || i.measuredPixelSize !== t.measuredPixelSize || i.measuredPercentageSize !== t.measuredPercentageSize) {
|
|
79
|
+
g = !0;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
let z = n?.serializedHandles !== m;
|
|
84
|
+
if (!z && n)
|
|
85
|
+
if (n.handles.length !== r.handles.length)
|
|
86
|
+
z = !0;
|
|
87
|
+
else
|
|
88
|
+
for (let o = 0; o < r.handles.length; o += 1) {
|
|
89
|
+
const i = n.handles[o], t = r.handles[o];
|
|
90
|
+
if (!(i && t)) {
|
|
91
|
+
z = !0;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
if (i.id !== t.id || i.thickness !== t.thickness || i.visible !== t.visible || i.direction !== t.direction || i.startPanelId !== t.startPanelId || i.endPanelId !== t.endPanelId) {
|
|
95
|
+
z = !0;
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (!n && r.panels.length === 0 && r.handles.length === 0 || n && !G && !O && !w && !g && !z)
|
|
100
|
+
return;
|
|
101
|
+
const C = r.panels.map((o) => ({ ...o })), I = r.handles.map((o) => ({ ...o })), D = { ...r.containerSize };
|
|
102
|
+
e.set(s, {
|
|
103
|
+
groupId: s,
|
|
104
|
+
displayName: r.displayName,
|
|
105
|
+
direction: r.direction,
|
|
106
|
+
containerSize: D,
|
|
107
|
+
panels: C,
|
|
108
|
+
handles: I,
|
|
109
|
+
index: f,
|
|
110
|
+
serializedPanels: b,
|
|
111
|
+
serializedHandles: m
|
|
112
|
+
}), S();
|
|
113
|
+
},
|
|
114
|
+
removeGroup: (s) => {
|
|
115
|
+
const r = e.delete(s), n = d.delete(s), f = p();
|
|
116
|
+
(r || n || f) && S();
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}, a = N(), M = () => x(a.subscribe, a.getOwnerId, a.getOwnerId), q = () => x(a.subscribe, a.getSnapshot, a.getSnapshot), K = (l) => {
|
|
120
|
+
a.enableGroup(l);
|
|
121
|
+
}, L = (l) => {
|
|
122
|
+
a.disableGroup(l);
|
|
123
|
+
}, Q = (l, e) => {
|
|
124
|
+
a.updateGroup(l, e);
|
|
125
|
+
}, R = (l) => {
|
|
126
|
+
a.removeGroup(l);
|
|
127
|
+
};
|
|
128
|
+
export {
|
|
129
|
+
L as disableDebugOverlayGroup,
|
|
130
|
+
K as enableDebugOverlayGroup,
|
|
131
|
+
R as removeDebugOverlayGroup,
|
|
132
|
+
Q as updateDebugOverlayGroup,
|
|
133
|
+
M as useDebugOverlayOwnerId,
|
|
134
|
+
q as useDebugOverlaySnapshot
|
|
135
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react"),k=l=>JSON.stringify(l.map(e=>({id:e.id,size:e.size,sizeUnit:e.sizeUnit,preferredPercentageSize:e.preferredPercentageSize,preferredPixelSize:e.preferredPixelSize,minSize:e.minSize??null,maxSize:e.maxSize??null,collapseFromStart:e.collapseFromStart,collapseFromEnd:e.collapseFromEnd,collapsed:e.collapsed,collapsedByDirection:e.collapsedByDirection,preferenceBeforeCollapse:e.preferenceBeforeCollapse,pixelAdjustPriority:e.pixelAdjustPriority??null,flexAdjustPriority:e.flexAdjustPriority??null,measuredPixelSize:e.measuredPixelSize??null,measuredPercentageSize:e.measuredPercentageSize??null}))),H=l=>JSON.stringify(l.map(e=>({id:e.id,thickness:e.thickness,visible:e.visible,direction:e.direction,startPanelId:e.startPanelId??null,endPanelId:e.endPanelId??null}))),N=()=>{const l=new Set,e=new Map,d=new Set;let c=null,v=0,u=!0,z=[],h={ownerId:null,groups:z};const x=()=>{for(const s of l)s()},b=()=>{u=!0,x()},g=()=>{const s=c;if(s&&d.has(s))return!1;c=null;const r=d.values().next();return r.done||(c=r.value),s!==c};return{subscribe:s=>(l.add(s),()=>{l.delete(s)}),getSnapshot:()=>(g()&&(u=!0),u&&(z=Array.from(e.values()).sort((r,n)=>r.index-n.index).map(({serializedPanels:r,serializedHandles:n,...p})=>p),h={ownerId:c,groups:z},u=!1),h),getOwnerId:()=>(g()&&(u=!0),c),enableGroup:s=>{const r=d.size;d.add(s),d.size!==r&&g()&&b()},disableGroup:s=>{d.delete(s)&&g()&&b()},updateGroup:(s,r)=>{const n=e.get(s),p=n?.index??v++,P=k(r.panels),m=H(r.handles),O=n?.displayName!==r.displayName,G=n?.direction!==r.direction,w=n?n.containerSize.width!==r.containerSize.width||n.containerSize.height!==r.containerSize.height:!0;let S=n?.serializedPanels!==P;if(!S&&n)if(n.panels.length!==r.panels.length)S=!0;else for(let o=0;o<r.panels.length;o+=1){const i=n.panels[o],t=r.panels[o];if(!(i&&t)){S=!0;break}if(i.id!==t.id||i.size!==t.size||i.preferredPercentageSize!==t.preferredPercentageSize||i.preferredPixelSize!==t.preferredPixelSize||i.collapsed!==t.collapsed||i.measuredPixelSize!==t.measuredPixelSize||i.measuredPercentageSize!==t.measuredPercentageSize){S=!0;break}}let f=n?.serializedHandles!==m;if(!f&&n)if(n.handles.length!==r.handles.length)f=!0;else for(let o=0;o<r.handles.length;o+=1){const i=n.handles[o],t=r.handles[o];if(!(i&&t)){f=!0;break}if(i.id!==t.id||i.thickness!==t.thickness||i.visible!==t.visible||i.direction!==t.direction||i.startPanelId!==t.startPanelId||i.endPanelId!==t.endPanelId){f=!0;break}}if(!n&&r.panels.length===0&&r.handles.length===0||n&&!O&&!G&&!w&&!S&&!f)return;const D=r.panels.map(o=>({...o})),I=r.handles.map(o=>({...o})),C={...r.containerSize};e.set(s,{groupId:s,displayName:r.displayName,direction:r.direction,containerSize:C,panels:D,handles:I,index:p,serializedPanels:P,serializedHandles:m}),b()},removeGroup:s=>{const r=e.delete(s),n=d.delete(s),p=g();(r||n||p)&&b()}}},a=N(),j=()=>y.useSyncExternalStore(a.subscribe,a.getOwnerId,a.getOwnerId),A=()=>y.useSyncExternalStore(a.subscribe,a.getSnapshot,a.getSnapshot),B=l=>{a.enableGroup(l)},E=l=>{a.disableGroup(l)},F=(l,e)=>{a.updateGroup(l,e)},J=l=>{a.removeGroup(l)};exports.disableDebugOverlayGroup=E;exports.enableDebugOverlayGroup=B;exports.removeDebugOverlayGroup=J;exports.updateDebugOverlayGroup=F;exports.useDebugOverlayOwnerId=j;exports.useDebugOverlaySnapshot=A;
|