@galaxy-io/dls 2.10.5 → 2.11.1
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.
|
@@ -11,7 +11,7 @@ export interface ResizablePanelsProps extends AriaAttributes {
|
|
|
11
11
|
/** Persists each uncontrolled panel's size in `localStorage` under this key, by panel `id`. Off when omitted. */
|
|
12
12
|
storageKey?: string;
|
|
13
13
|
/**
|
|
14
|
-
* A hairline on the edge where two panels meet
|
|
14
|
+
* A hairline on the edge where two panels meet (a sized panel's edge facing its handle). Without it the panels meet with no line; the handle overlays the edge either way and takes no space.
|
|
15
15
|
* @default false
|
|
16
16
|
*/
|
|
17
17
|
hasDividers?: boolean;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Orientation } from "../theme/enums.js";
|
|
2
|
-
import { SPACE } from "../theme/tokens/scales.js";
|
|
3
2
|
import { useElementClientSize } from "../hooks/useElementClientSize.js";
|
|
4
3
|
import ResizeHandle from "./ResizeHandle.js";
|
|
5
4
|
import { useLocalStorage } from "../hooks/useLocalStorage.js";
|
|
@@ -21,16 +20,16 @@ import { useMergeRefs } from "@floating-ui/react";
|
|
|
21
20
|
* children are skipped, so a panel can be shown conditionally. A panel with neither `value` nor
|
|
22
21
|
* `defaultValue` is the fluid one; with none, the last panel is.
|
|
23
22
|
*
|
|
24
|
-
* The panels have no frame of their own
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* edge where two panels meet
|
|
23
|
+
* The panels have no frame of their own and meet directly: each handle sits in a zero-size slot
|
|
24
|
+
* between two panels and overlays the edge of the panel it does not resize, so it takes no space
|
|
25
|
+
* and its transparent strip shows that panel's own surface. `hasDividers` draws a hairline on the
|
|
26
|
+
* edge where two panels meet: on a sized panel's edge that faces its handle (so the line sits on
|
|
27
|
+
* the sidebar's edge and the handle's strip lies over the fluid panel beside it), and on the later
|
|
28
|
+
* panel's start edge where two panels meet without a handle.
|
|
28
29
|
*/
|
|
29
30
|
var ResizablePanelsContext = createContext(null);
|
|
30
31
|
/** The storage key while `storageKey` is unset; it lives in a per-instance memory adapter. */
|
|
31
32
|
var RESIZABLE_PANELS_NO_STORAGE_KEY = "gx-resizable-panels:off";
|
|
32
|
-
/** A handle's thickness: the `space[8]` token, in pixels (ResizeHandle's strip). */
|
|
33
|
-
var HANDLE_THICKNESS_PX = Number.parseFloat(SPACE[8]);
|
|
34
33
|
/** A row of panels needs vertical bars; a stack needs horizontal ones (logic, not CSS). */
|
|
35
34
|
var RESIZABLE_PANELS_ORIENTATION_TO_HANDLE_ORIENTATION_MAP = {
|
|
36
35
|
[Orientation.HORIZONTAL]: Orientation.VERTICAL,
|
|
@@ -54,33 +53,64 @@ var Root = /*#__PURE__*/ styled("div")({
|
|
|
54
53
|
class: "gx-ResizablePanels-rov2pu6",
|
|
55
54
|
propsAsIs: false
|
|
56
55
|
});
|
|
57
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* Every panel scrolls its own content; no padding or surface (content brings its own). Its own
|
|
58
|
+
* stacking context keeps content with a high `z-index` from painting over a handle.
|
|
59
|
+
*/
|
|
58
60
|
var Panel = /*#__PURE__*/ styled("div")({
|
|
59
61
|
name: "Panel",
|
|
60
62
|
class: "gx-ResizablePanels-Panel-piht8m9",
|
|
61
63
|
propsAsIs: false
|
|
62
64
|
});
|
|
65
|
+
/** Holds a handle between two panels: zero size on the layout axis, above both panels. */
|
|
66
|
+
var HandleSlot = /*#__PURE__*/ styled("div")({
|
|
67
|
+
name: "HandleSlot",
|
|
68
|
+
class: "gx-ResizablePanels-HandleSlot-h1hgxsmq",
|
|
69
|
+
propsAsIs: false
|
|
70
|
+
});
|
|
71
|
+
var HANDLE_SLOT_ORIENTATION_TO_CSS_MAP = {
|
|
72
|
+
[Orientation.HORIZONTAL]: "gx-ResizablePanels-Orientation_HORIZONTAL-ow20qci",
|
|
73
|
+
[Orientation.VERTICAL]: "gx-ResizablePanels-Orientation_VERTICAL-ot38enr"
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Takes the handle out of flow and stretches it across the slot. The doubled class outranks
|
|
77
|
+
* ResizeHandle's own `position: relative` whatever order the two modules' rules land in.
|
|
78
|
+
*/
|
|
79
|
+
var RESIZABLE_PANELS_ORIENTATION_TO_HANDLE_CSS_MAP = {
|
|
80
|
+
[Orientation.HORIZONTAL]: "gx-ResizablePanels-Orientation_HORIZONTAL-o1ev9pzd",
|
|
81
|
+
[Orientation.VERTICAL]: "gx-ResizablePanels-Orientation_VERTICAL-o16ojr42"
|
|
82
|
+
};
|
|
83
|
+
/** The handle resizes the panel before it: its strip extends over the panel after the slot. */
|
|
84
|
+
var RESIZABLE_PANELS_ORIENTATION_TO_HANDLE_AFTER_CSS_MAP = {
|
|
85
|
+
[Orientation.HORIZONTAL]: "gx-ResizablePanels-Orientation_HORIZONTAL-o1k6jei3",
|
|
86
|
+
[Orientation.VERTICAL]: "gx-ResizablePanels-Orientation_VERTICAL-o1ikvfoe"
|
|
87
|
+
};
|
|
88
|
+
/** The handle resizes the panel after it (`isReversed`): its strip extends over the panel before. */
|
|
89
|
+
var RESIZABLE_PANELS_ORIENTATION_TO_HANDLE_BEFORE_CSS_MAP = {
|
|
90
|
+
[Orientation.HORIZONTAL]: "gx-ResizablePanels-Orientation_HORIZONTAL-oa3x64k",
|
|
91
|
+
[Orientation.VERTICAL]: "gx-ResizablePanels-Orientation_VERTICAL-o1kf7v08"
|
|
92
|
+
};
|
|
63
93
|
var RESIZABLE_PANELS_ORIENTATION_TO_CSS_MAP = {
|
|
64
|
-
[Orientation.HORIZONTAL]: "gx-ResizablePanels-Orientation_HORIZONTAL-
|
|
65
|
-
[Orientation.VERTICAL]: "gx-ResizablePanels-Orientation_VERTICAL-
|
|
94
|
+
[Orientation.HORIZONTAL]: "gx-ResizablePanels-Orientation_HORIZONTAL-o12hjusf",
|
|
95
|
+
[Orientation.VERTICAL]: "gx-ResizablePanels-Orientation_VERTICAL-oqqcrhc"
|
|
66
96
|
};
|
|
67
97
|
/** `min` applies on the layout axis. */
|
|
68
98
|
var RESIZABLE_PANEL_ORIENTATION_TO_CSS_MAP = {
|
|
69
|
-
[Orientation.HORIZONTAL]: "gx-ResizablePanels-Orientation_HORIZONTAL-
|
|
70
|
-
[Orientation.VERTICAL]: "gx-ResizablePanels-Orientation_VERTICAL-
|
|
99
|
+
[Orientation.HORIZONTAL]: "gx-ResizablePanels-Orientation_HORIZONTAL-o153dibu",
|
|
100
|
+
[Orientation.VERTICAL]: "gx-ResizablePanels-Orientation_VERTICAL-o18ydacr"
|
|
71
101
|
};
|
|
72
102
|
/** A sized panel may shrink below its size (toward `min`) when the container is too small. */
|
|
73
|
-
var SIZED_CSS = "gx-ResizablePanels-SIZED_CSS-
|
|
103
|
+
var SIZED_CSS = "gx-ResizablePanels-SIZED_CSS-si9hjxv";
|
|
74
104
|
/** The fluid panel takes the remaining space. */
|
|
75
|
-
var FLUID_CSS = "gx-ResizablePanels-FLUID_CSS-
|
|
105
|
+
var FLUID_CSS = "gx-ResizablePanels-FLUID_CSS-fgrrn8v";
|
|
76
106
|
/** `hasDividers`: the hairline on a panel's start or end edge along the layout axis. */
|
|
77
107
|
var RESIZABLE_PANEL_ORIENTATION_TO_START_DIVIDER_CSS_MAP = {
|
|
78
|
-
[Orientation.HORIZONTAL]: "gx-ResizablePanels-Orientation_HORIZONTAL-
|
|
79
|
-
[Orientation.VERTICAL]: "gx-ResizablePanels-Orientation_VERTICAL-
|
|
108
|
+
[Orientation.HORIZONTAL]: "gx-ResizablePanels-Orientation_HORIZONTAL-okss9ie",
|
|
109
|
+
[Orientation.VERTICAL]: "gx-ResizablePanels-Orientation_VERTICAL-oy9jznf"
|
|
80
110
|
};
|
|
81
111
|
var RESIZABLE_PANEL_ORIENTATION_TO_END_DIVIDER_CSS_MAP = {
|
|
82
|
-
[Orientation.HORIZONTAL]: "gx-ResizablePanels-Orientation_HORIZONTAL-
|
|
83
|
-
[Orientation.VERTICAL]: "gx-ResizablePanels-Orientation_VERTICAL-
|
|
112
|
+
[Orientation.HORIZONTAL]: "gx-ResizablePanels-Orientation_HORIZONTAL-o14ir6tp",
|
|
113
|
+
[Orientation.VERTICAL]: "gx-ResizablePanels-Orientation_VERTICAL-o1kugxp4"
|
|
84
114
|
};
|
|
85
115
|
/** Rounds and keeps `value` within `[min, max]`. */
|
|
86
116
|
function clamp(value, min, max) {
|
|
@@ -133,11 +163,10 @@ var ResizablePanels = forwardRef(function ResizablePanels({ children, orientatio
|
|
|
133
163
|
if (before !== void 0 && !before.isFluid && index - 1 < firstFluidIndex) return index - 1;
|
|
134
164
|
if (!panel.isFluid) return index;
|
|
135
165
|
});
|
|
136
|
-
const handleCount = handleTargets.filter((target) => target !== void 0).length;
|
|
137
166
|
/** A handle's `max`: the panel's own, capped so every fluid panel keeps its `min`. */
|
|
138
167
|
const dynamicMaxOf = (target) => {
|
|
139
168
|
if (available === void 0) return target.max;
|
|
140
|
-
let room = available
|
|
169
|
+
let room = available;
|
|
141
170
|
for (const panel of panels) {
|
|
142
171
|
if (panel === target) continue;
|
|
143
172
|
room -= panel.isFluid ? panel.min : sizeOf(panel);
|
|
@@ -175,15 +204,20 @@ var ResizablePanels = forwardRef(function ResizablePanels({ children, orientatio
|
|
|
175
204
|
const target = targetIndex === void 0 ? void 0 : panels[targetIndex];
|
|
176
205
|
if (target !== void 0) {
|
|
177
206
|
const max = dynamicMaxOf(target);
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
207
|
+
const isReversed = targetIndex === index;
|
|
208
|
+
content.push(/* @__PURE__ */ jsx(HandleSlot, {
|
|
209
|
+
className: HANDLE_SLOT_ORIENTATION_TO_CSS_MAP[orientation],
|
|
210
|
+
children: /* @__PURE__ */ jsx(ResizeHandle, {
|
|
211
|
+
orientation: RESIZABLE_PANELS_ORIENTATION_TO_HANDLE_ORIENTATION_MAP[orientation],
|
|
212
|
+
isReversed,
|
|
213
|
+
value: Math.min(sizeOf(target), max),
|
|
214
|
+
onChange: (next) => setSize(target, next),
|
|
215
|
+
min: target.min,
|
|
216
|
+
max,
|
|
217
|
+
ariaLabel: `Resize ${target.props.ariaLabel ?? target.props.id}`,
|
|
218
|
+
"aria-controls": target.props.id,
|
|
219
|
+
className: cx(RESIZABLE_PANELS_ORIENTATION_TO_HANDLE_CSS_MAP[orientation], isReversed ? RESIZABLE_PANELS_ORIENTATION_TO_HANDLE_BEFORE_CSS_MAP[orientation] : RESIZABLE_PANELS_ORIENTATION_TO_HANDLE_AFTER_CSS_MAP[orientation])
|
|
220
|
+
})
|
|
187
221
|
}, `handle:${panel.props.id}`));
|
|
188
222
|
}
|
|
189
223
|
content.push(panel.element);
|
|
@@ -49,10 +49,19 @@ var SCROLL_AREA_ORIENTATION_TO_SCROLLBAR_CSS_MAP = {
|
|
|
49
49
|
[Orientation.VERTICAL]: "gx-ScrollArea-Orientation_VERTICAL-o174c7co",
|
|
50
50
|
[Orientation.HORIZONTAL]: "gx-ScrollArea-Orientation_HORIZONTAL-okpbxfy"
|
|
51
51
|
};
|
|
52
|
-
/** The 4px thumb, a quiet neutral on every surface
|
|
52
|
+
/** The 4px thumb, a quiet neutral on every surface. */
|
|
53
53
|
var THUMB_CSS = "gx-ScrollArea-THUMB_CSS-tzpebzb";
|
|
54
|
+
/**
|
|
55
|
+
* The thumb's 24px pointer target (`::before`), anchored to the track's outer edge (the root's
|
|
56
|
+
* edge) and growing inward over the content, so it never leaves the root and never adds overflow to
|
|
57
|
+
* a scrolling parent. Along the track it matches the thumb.
|
|
58
|
+
*/
|
|
59
|
+
var SCROLL_AREA_ORIENTATION_TO_THUMB_CSS_MAP = {
|
|
60
|
+
[Orientation.VERTICAL]: "gx-ScrollArea-Orientation_VERTICAL-o1otan2y",
|
|
61
|
+
[Orientation.HORIZONTAL]: "gx-ScrollArea-Orientation_HORIZONTAL-o1rdgqrq"
|
|
62
|
+
};
|
|
54
63
|
/** Where the two scrollbars meet. */
|
|
55
|
-
var CORNER_CSS = "gx-ScrollArea-CORNER_CSS-
|
|
64
|
+
var CORNER_CSS = "gx-ScrollArea-CORNER_CSS-c1pufd3e";
|
|
56
65
|
/** Reads the viewport's scroll geometry into edge flags. */
|
|
57
66
|
function measureEdges(viewport, canScrollHorizontally) {
|
|
58
67
|
const { scrollTop, scrollHeight, clientHeight, scrollWidth, clientWidth } = viewport;
|
|
@@ -122,12 +131,12 @@ var ScrollArea = forwardRef(function ScrollArea({ children, canScrollHorizontall
|
|
|
122
131
|
/* @__PURE__ */ jsx(ScrollAreaPrimitive.Scrollbar, {
|
|
123
132
|
orientation: "vertical",
|
|
124
133
|
className: SCROLL_AREA_ORIENTATION_TO_SCROLLBAR_CSS_MAP[Orientation.VERTICAL],
|
|
125
|
-
children: /* @__PURE__ */ jsx(ScrollAreaPrimitive.Thumb, { className: THUMB_CSS })
|
|
134
|
+
children: /* @__PURE__ */ jsx(ScrollAreaPrimitive.Thumb, { className: cx(THUMB_CSS, SCROLL_AREA_ORIENTATION_TO_THUMB_CSS_MAP[Orientation.VERTICAL]) })
|
|
126
135
|
}),
|
|
127
136
|
canScrollHorizontally && /* @__PURE__ */ jsx(ScrollAreaPrimitive.Scrollbar, {
|
|
128
137
|
orientation: "horizontal",
|
|
129
138
|
className: SCROLL_AREA_ORIENTATION_TO_SCROLLBAR_CSS_MAP[Orientation.HORIZONTAL],
|
|
130
|
-
children: /* @__PURE__ */ jsx(ScrollAreaPrimitive.Thumb, { className: THUMB_CSS })
|
|
139
|
+
children: /* @__PURE__ */ jsx(ScrollAreaPrimitive.Thumb, { className: cx(THUMB_CSS, SCROLL_AREA_ORIENTATION_TO_THUMB_CSS_MAP[Orientation.HORIZONTAL]) })
|
|
131
140
|
}),
|
|
132
141
|
canScrollHorizontally && /* @__PURE__ */ jsx(ScrollAreaPrimitive.Corner, { className: CORNER_CSS })
|
|
133
142
|
]
|