react-resizable-panels 2.0.8-rc.1 → 2.0.9
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/CHANGELOG.md +10 -0
- package/dist/react-resizable-panels.browser.cjs.js +114 -4
- package/dist/react-resizable-panels.browser.development.cjs.js +114 -4
- package/dist/react-resizable-panels.browser.development.esm.js +113 -3
- package/dist/react-resizable-panels.browser.esm.js +113 -3
- package/dist/react-resizable-panels.cjs.js +114 -4
- package/dist/react-resizable-panels.development.cjs.js +114 -4
- package/dist/react-resizable-panels.development.esm.js +113 -3
- package/dist/react-resizable-panels.development.node.cjs.js +114 -4
- package/dist/react-resizable-panels.development.node.esm.js +113 -3
- package/dist/react-resizable-panels.esm.js +113 -3
- package/dist/react-resizable-panels.node.cjs.js +114 -4
- package/dist/react-resizable-panels.node.esm.js +113 -3
- package/package.json +1 -4
- package/src/Panel.test.tsx +32 -0
- package/src/Panel.ts +1 -0
- package/src/PanelGroup.test.tsx +36 -0
- package/src/PanelGroup.ts +4 -1
- package/src/PanelResizeHandle.test.tsx +36 -0
- package/src/PanelResizeHandle.ts +1 -0
- package/src/PanelResizeHandleRegistry.ts +2 -2
- package/src/vendor/stacking-order.ts +130 -0
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
|
-
var stackingOrder = require('stacking-order');
|
|
7
6
|
|
|
8
7
|
function _interopNamespace(e) {
|
|
9
8
|
if (e && e.__esModule) return e;
|
|
@@ -182,6 +181,7 @@ function PanelWithForwardedRef({
|
|
|
182
181
|
...rest,
|
|
183
182
|
children,
|
|
184
183
|
className: classNameFromProps,
|
|
184
|
+
id: idFromProps,
|
|
185
185
|
style: {
|
|
186
186
|
...style,
|
|
187
187
|
...styleFromProps
|
|
@@ -305,6 +305,114 @@ function intersects(rectOne, rectTwo, strict) {
|
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
+
// Forked from NPM stacking-order@2.0.0
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Determine which of two nodes appears in front of the other —
|
|
312
|
+
* if `a` is in front, returns 1, otherwise returns -1
|
|
313
|
+
* @param {HTMLElement} a
|
|
314
|
+
* @param {HTMLElement} b
|
|
315
|
+
*/
|
|
316
|
+
function compare(a, b) {
|
|
317
|
+
if (a === b) throw new Error("Cannot compare node with itself");
|
|
318
|
+
const ancestors = {
|
|
319
|
+
a: get_ancestors(a),
|
|
320
|
+
b: get_ancestors(b)
|
|
321
|
+
};
|
|
322
|
+
let common_ancestor;
|
|
323
|
+
|
|
324
|
+
// remove shared ancestors
|
|
325
|
+
while (ancestors.a.at(-1) === ancestors.b.at(-1)) {
|
|
326
|
+
a = ancestors.a.pop();
|
|
327
|
+
b = ancestors.b.pop();
|
|
328
|
+
common_ancestor = a;
|
|
329
|
+
}
|
|
330
|
+
assert(common_ancestor);
|
|
331
|
+
const z_indexes = {
|
|
332
|
+
a: get_z_index(find_stacking_context(ancestors.a)),
|
|
333
|
+
b: get_z_index(find_stacking_context(ancestors.b))
|
|
334
|
+
};
|
|
335
|
+
if (z_indexes.a === z_indexes.b) {
|
|
336
|
+
const children = common_ancestor.childNodes;
|
|
337
|
+
const furthest_ancestors = {
|
|
338
|
+
a: ancestors.a.at(-1),
|
|
339
|
+
b: ancestors.b.at(-1)
|
|
340
|
+
};
|
|
341
|
+
let i = children.length;
|
|
342
|
+
while (i--) {
|
|
343
|
+
const child = children[i];
|
|
344
|
+
if (child === furthest_ancestors.a) return 1;
|
|
345
|
+
if (child === furthest_ancestors.b) return -1;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
return Math.sign(z_indexes.a - z_indexes.b);
|
|
349
|
+
}
|
|
350
|
+
const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;
|
|
351
|
+
|
|
352
|
+
/** @param {HTMLElement} node */
|
|
353
|
+
function is_flex_item(node) {
|
|
354
|
+
const display = getComputedStyle(get_parent(node)).display;
|
|
355
|
+
return display === "flex" || display === "inline-flex";
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/** @param {HTMLElement} node */
|
|
359
|
+
function creates_stacking_context(node) {
|
|
360
|
+
const style = getComputedStyle(node);
|
|
361
|
+
|
|
362
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context
|
|
363
|
+
if (style.position === "fixed") return true;
|
|
364
|
+
// Forked to fix upstream bug https://github.com/Rich-Harris/stacking-order/issues/3
|
|
365
|
+
// if (
|
|
366
|
+
// (style.zIndex !== "auto" && style.position !== "static") ||
|
|
367
|
+
// is_flex_item(node)
|
|
368
|
+
// )
|
|
369
|
+
if (style.zIndex !== "auto" && (style.position !== "static" || is_flex_item(node))) return true;
|
|
370
|
+
if (+style.opacity < 1) return true;
|
|
371
|
+
if ("transform" in style && style.transform !== "none") return true;
|
|
372
|
+
if ("webkitTransform" in style && style.webkitTransform !== "none") return true;
|
|
373
|
+
if ("mixBlendMode" in style && style.mixBlendMode !== "normal") return true;
|
|
374
|
+
if ("filter" in style && style.filter !== "none") return true;
|
|
375
|
+
if ("webkitFilter" in style && style.webkitFilter !== "none") return true;
|
|
376
|
+
if ("isolation" in style && style.isolation === "isolate") return true;
|
|
377
|
+
if (props.test(style.willChange)) return true;
|
|
378
|
+
// @ts-expect-error
|
|
379
|
+
if (style.webkitOverflowScrolling === "touch") return true;
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/** @param {HTMLElement[]} nodes */
|
|
384
|
+
function find_stacking_context(nodes) {
|
|
385
|
+
let i = nodes.length;
|
|
386
|
+
while (i--) {
|
|
387
|
+
const node = nodes[i];
|
|
388
|
+
assert(node);
|
|
389
|
+
if (creates_stacking_context(node)) return node;
|
|
390
|
+
}
|
|
391
|
+
return null;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/** @param {HTMLElement} node */
|
|
395
|
+
function get_z_index(node) {
|
|
396
|
+
return node && Number(getComputedStyle(node).zIndex) || 0;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/** @param {HTMLElement} node */
|
|
400
|
+
function get_ancestors(node) {
|
|
401
|
+
const ancestors = [];
|
|
402
|
+
while (node) {
|
|
403
|
+
ancestors.push(node);
|
|
404
|
+
node = get_parent(node);
|
|
405
|
+
}
|
|
406
|
+
return ancestors; // [ node, ... <body>, <html>, document ]
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/** @param {HTMLElement} node */
|
|
410
|
+
function get_parent(node) {
|
|
411
|
+
var _node$parentNode;
|
|
412
|
+
// @ts-ignore
|
|
413
|
+
return ((_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 ? void 0 : _node$parentNode.host) || node.parentNode;
|
|
414
|
+
}
|
|
415
|
+
|
|
308
416
|
const EXCEEDED_HORIZONTAL_MIN = 0b0001;
|
|
309
417
|
const EXCEEDED_HORIZONTAL_MAX = 0b0010;
|
|
310
418
|
const EXCEEDED_VERTICAL_MIN = 0b0100;
|
|
@@ -446,7 +554,7 @@ function recalculateIntersectingHandles({
|
|
|
446
554
|
// Calculating stacking order has a cost, so we should avoid it if possible
|
|
447
555
|
// That is why we only check potentially intersecting handles,
|
|
448
556
|
// and why we skip if the event target is within the handle's DOM
|
|
449
|
-
|
|
557
|
+
compare(targetElement, dragHandleElement) > 0) {
|
|
450
558
|
// If the target is above the drag handle, then we also need to confirm they overlap
|
|
451
559
|
// If they are beside each other (e.g. a panel and its drag handle) then the handle is still interactive
|
|
452
560
|
//
|
|
@@ -517,7 +625,7 @@ function updateListeners() {
|
|
|
517
625
|
window.removeEventListener("mouseup", handlePointerUp);
|
|
518
626
|
window.removeEventListener("touchcancel", handlePointerUp);
|
|
519
627
|
window.removeEventListener("touchend", handlePointerUp);
|
|
520
|
-
if (
|
|
628
|
+
if (registeredResizeHandlers.size > 0) {
|
|
521
629
|
if (isPointerDown) {
|
|
522
630
|
if (intersectingHandles.length > 0) {
|
|
523
631
|
ownerDocumentCounts.forEach((count, ownerDocument) => {
|
|
@@ -1974,11 +2082,12 @@ function PanelGroupWithForwardedRef({
|
|
|
1974
2082
|
...rest,
|
|
1975
2083
|
children,
|
|
1976
2084
|
className: classNameFromProps,
|
|
2085
|
+
id: idFromProps,
|
|
2086
|
+
ref: panelGroupElementRef,
|
|
1977
2087
|
style: {
|
|
1978
2088
|
...style,
|
|
1979
2089
|
...styleFromProps
|
|
1980
2090
|
},
|
|
1981
|
-
ref: panelGroupElementRef,
|
|
1982
2091
|
// CSS selectors
|
|
1983
2092
|
"data-panel-group": "",
|
|
1984
2093
|
"data-panel-group-direction": direction,
|
|
@@ -2182,6 +2291,7 @@ function PanelResizeHandle({
|
|
|
2182
2291
|
...rest,
|
|
2183
2292
|
children,
|
|
2184
2293
|
className: classNameFromProps,
|
|
2294
|
+
id: idFromProps,
|
|
2185
2295
|
onBlur: () => setIsFocused(false),
|
|
2186
2296
|
onFocus: () => setIsFocused(true),
|
|
2187
2297
|
ref: elementRef,
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
|
-
var stackingOrder = require('stacking-order');
|
|
7
6
|
|
|
8
7
|
function _interopNamespace(e) {
|
|
9
8
|
if (e && e.__esModule) return e;
|
|
@@ -193,6 +192,7 @@ function PanelWithForwardedRef({
|
|
|
193
192
|
...rest,
|
|
194
193
|
children,
|
|
195
194
|
className: classNameFromProps,
|
|
195
|
+
id: idFromProps,
|
|
196
196
|
style: {
|
|
197
197
|
...style,
|
|
198
198
|
...styleFromProps
|
|
@@ -316,6 +316,114 @@ function intersects(rectOne, rectTwo, strict) {
|
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
318
|
|
|
319
|
+
// Forked from NPM stacking-order@2.0.0
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Determine which of two nodes appears in front of the other —
|
|
323
|
+
* if `a` is in front, returns 1, otherwise returns -1
|
|
324
|
+
* @param {HTMLElement} a
|
|
325
|
+
* @param {HTMLElement} b
|
|
326
|
+
*/
|
|
327
|
+
function compare(a, b) {
|
|
328
|
+
if (a === b) throw new Error("Cannot compare node with itself");
|
|
329
|
+
const ancestors = {
|
|
330
|
+
a: get_ancestors(a),
|
|
331
|
+
b: get_ancestors(b)
|
|
332
|
+
};
|
|
333
|
+
let common_ancestor;
|
|
334
|
+
|
|
335
|
+
// remove shared ancestors
|
|
336
|
+
while (ancestors.a.at(-1) === ancestors.b.at(-1)) {
|
|
337
|
+
a = ancestors.a.pop();
|
|
338
|
+
b = ancestors.b.pop();
|
|
339
|
+
common_ancestor = a;
|
|
340
|
+
}
|
|
341
|
+
assert(common_ancestor);
|
|
342
|
+
const z_indexes = {
|
|
343
|
+
a: get_z_index(find_stacking_context(ancestors.a)),
|
|
344
|
+
b: get_z_index(find_stacking_context(ancestors.b))
|
|
345
|
+
};
|
|
346
|
+
if (z_indexes.a === z_indexes.b) {
|
|
347
|
+
const children = common_ancestor.childNodes;
|
|
348
|
+
const furthest_ancestors = {
|
|
349
|
+
a: ancestors.a.at(-1),
|
|
350
|
+
b: ancestors.b.at(-1)
|
|
351
|
+
};
|
|
352
|
+
let i = children.length;
|
|
353
|
+
while (i--) {
|
|
354
|
+
const child = children[i];
|
|
355
|
+
if (child === furthest_ancestors.a) return 1;
|
|
356
|
+
if (child === furthest_ancestors.b) return -1;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return Math.sign(z_indexes.a - z_indexes.b);
|
|
360
|
+
}
|
|
361
|
+
const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;
|
|
362
|
+
|
|
363
|
+
/** @param {HTMLElement} node */
|
|
364
|
+
function is_flex_item(node) {
|
|
365
|
+
const display = getComputedStyle(get_parent(node)).display;
|
|
366
|
+
return display === "flex" || display === "inline-flex";
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/** @param {HTMLElement} node */
|
|
370
|
+
function creates_stacking_context(node) {
|
|
371
|
+
const style = getComputedStyle(node);
|
|
372
|
+
|
|
373
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context
|
|
374
|
+
if (style.position === "fixed") return true;
|
|
375
|
+
// Forked to fix upstream bug https://github.com/Rich-Harris/stacking-order/issues/3
|
|
376
|
+
// if (
|
|
377
|
+
// (style.zIndex !== "auto" && style.position !== "static") ||
|
|
378
|
+
// is_flex_item(node)
|
|
379
|
+
// )
|
|
380
|
+
if (style.zIndex !== "auto" && (style.position !== "static" || is_flex_item(node))) return true;
|
|
381
|
+
if (+style.opacity < 1) return true;
|
|
382
|
+
if ("transform" in style && style.transform !== "none") return true;
|
|
383
|
+
if ("webkitTransform" in style && style.webkitTransform !== "none") return true;
|
|
384
|
+
if ("mixBlendMode" in style && style.mixBlendMode !== "normal") return true;
|
|
385
|
+
if ("filter" in style && style.filter !== "none") return true;
|
|
386
|
+
if ("webkitFilter" in style && style.webkitFilter !== "none") return true;
|
|
387
|
+
if ("isolation" in style && style.isolation === "isolate") return true;
|
|
388
|
+
if (props.test(style.willChange)) return true;
|
|
389
|
+
// @ts-expect-error
|
|
390
|
+
if (style.webkitOverflowScrolling === "touch") return true;
|
|
391
|
+
return false;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/** @param {HTMLElement[]} nodes */
|
|
395
|
+
function find_stacking_context(nodes) {
|
|
396
|
+
let i = nodes.length;
|
|
397
|
+
while (i--) {
|
|
398
|
+
const node = nodes[i];
|
|
399
|
+
assert(node);
|
|
400
|
+
if (creates_stacking_context(node)) return node;
|
|
401
|
+
}
|
|
402
|
+
return null;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/** @param {HTMLElement} node */
|
|
406
|
+
function get_z_index(node) {
|
|
407
|
+
return node && Number(getComputedStyle(node).zIndex) || 0;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/** @param {HTMLElement} node */
|
|
411
|
+
function get_ancestors(node) {
|
|
412
|
+
const ancestors = [];
|
|
413
|
+
while (node) {
|
|
414
|
+
ancestors.push(node);
|
|
415
|
+
node = get_parent(node);
|
|
416
|
+
}
|
|
417
|
+
return ancestors; // [ node, ... <body>, <html>, document ]
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/** @param {HTMLElement} node */
|
|
421
|
+
function get_parent(node) {
|
|
422
|
+
var _node$parentNode;
|
|
423
|
+
// @ts-ignore
|
|
424
|
+
return ((_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 ? void 0 : _node$parentNode.host) || node.parentNode;
|
|
425
|
+
}
|
|
426
|
+
|
|
319
427
|
const EXCEEDED_HORIZONTAL_MIN = 0b0001;
|
|
320
428
|
const EXCEEDED_HORIZONTAL_MAX = 0b0010;
|
|
321
429
|
const EXCEEDED_VERTICAL_MIN = 0b0100;
|
|
@@ -457,7 +565,7 @@ function recalculateIntersectingHandles({
|
|
|
457
565
|
// Calculating stacking order has a cost, so we should avoid it if possible
|
|
458
566
|
// That is why we only check potentially intersecting handles,
|
|
459
567
|
// and why we skip if the event target is within the handle's DOM
|
|
460
|
-
|
|
568
|
+
compare(targetElement, dragHandleElement) > 0) {
|
|
461
569
|
// If the target is above the drag handle, then we also need to confirm they overlap
|
|
462
570
|
// If they are beside each other (e.g. a panel and its drag handle) then the handle is still interactive
|
|
463
571
|
//
|
|
@@ -528,7 +636,7 @@ function updateListeners() {
|
|
|
528
636
|
window.removeEventListener("mouseup", handlePointerUp);
|
|
529
637
|
window.removeEventListener("touchcancel", handlePointerUp);
|
|
530
638
|
window.removeEventListener("touchend", handlePointerUp);
|
|
531
|
-
if (
|
|
639
|
+
if (registeredResizeHandlers.size > 0) {
|
|
532
640
|
if (isPointerDown) {
|
|
533
641
|
if (intersectingHandles.length > 0) {
|
|
534
642
|
ownerDocumentCounts.forEach((count, ownerDocument) => {
|
|
@@ -2085,11 +2193,12 @@ function PanelGroupWithForwardedRef({
|
|
|
2085
2193
|
...rest,
|
|
2086
2194
|
children,
|
|
2087
2195
|
className: classNameFromProps,
|
|
2196
|
+
id: idFromProps,
|
|
2197
|
+
ref: panelGroupElementRef,
|
|
2088
2198
|
style: {
|
|
2089
2199
|
...style,
|
|
2090
2200
|
...styleFromProps
|
|
2091
2201
|
},
|
|
2092
|
-
ref: panelGroupElementRef,
|
|
2093
2202
|
// CSS selectors
|
|
2094
2203
|
"data-panel-group": "",
|
|
2095
2204
|
"data-panel-group-direction": direction,
|
|
@@ -2293,6 +2402,7 @@ function PanelResizeHandle({
|
|
|
2293
2402
|
...rest,
|
|
2294
2403
|
children,
|
|
2295
2404
|
className: classNameFromProps,
|
|
2405
|
+
id: idFromProps,
|
|
2296
2406
|
onBlur: () => setIsFocused(false),
|
|
2297
2407
|
onFocus: () => setIsFocused(true),
|
|
2298
2408
|
ref: elementRef,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { compare } from 'stacking-order';
|
|
3
2
|
|
|
4
3
|
const isBrowser = typeof window !== "undefined";
|
|
5
4
|
|
|
@@ -169,6 +168,7 @@ function PanelWithForwardedRef({
|
|
|
169
168
|
...rest,
|
|
170
169
|
children,
|
|
171
170
|
className: classNameFromProps,
|
|
171
|
+
id: idFromProps,
|
|
172
172
|
style: {
|
|
173
173
|
...style,
|
|
174
174
|
...styleFromProps
|
|
@@ -292,6 +292,114 @@ function intersects(rectOne, rectTwo, strict) {
|
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
294
|
|
|
295
|
+
// Forked from NPM stacking-order@2.0.0
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Determine which of two nodes appears in front of the other —
|
|
299
|
+
* if `a` is in front, returns 1, otherwise returns -1
|
|
300
|
+
* @param {HTMLElement} a
|
|
301
|
+
* @param {HTMLElement} b
|
|
302
|
+
*/
|
|
303
|
+
function compare(a, b) {
|
|
304
|
+
if (a === b) throw new Error("Cannot compare node with itself");
|
|
305
|
+
const ancestors = {
|
|
306
|
+
a: get_ancestors(a),
|
|
307
|
+
b: get_ancestors(b)
|
|
308
|
+
};
|
|
309
|
+
let common_ancestor;
|
|
310
|
+
|
|
311
|
+
// remove shared ancestors
|
|
312
|
+
while (ancestors.a.at(-1) === ancestors.b.at(-1)) {
|
|
313
|
+
a = ancestors.a.pop();
|
|
314
|
+
b = ancestors.b.pop();
|
|
315
|
+
common_ancestor = a;
|
|
316
|
+
}
|
|
317
|
+
assert(common_ancestor);
|
|
318
|
+
const z_indexes = {
|
|
319
|
+
a: get_z_index(find_stacking_context(ancestors.a)),
|
|
320
|
+
b: get_z_index(find_stacking_context(ancestors.b))
|
|
321
|
+
};
|
|
322
|
+
if (z_indexes.a === z_indexes.b) {
|
|
323
|
+
const children = common_ancestor.childNodes;
|
|
324
|
+
const furthest_ancestors = {
|
|
325
|
+
a: ancestors.a.at(-1),
|
|
326
|
+
b: ancestors.b.at(-1)
|
|
327
|
+
};
|
|
328
|
+
let i = children.length;
|
|
329
|
+
while (i--) {
|
|
330
|
+
const child = children[i];
|
|
331
|
+
if (child === furthest_ancestors.a) return 1;
|
|
332
|
+
if (child === furthest_ancestors.b) return -1;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return Math.sign(z_indexes.a - z_indexes.b);
|
|
336
|
+
}
|
|
337
|
+
const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;
|
|
338
|
+
|
|
339
|
+
/** @param {HTMLElement} node */
|
|
340
|
+
function is_flex_item(node) {
|
|
341
|
+
const display = getComputedStyle(get_parent(node)).display;
|
|
342
|
+
return display === "flex" || display === "inline-flex";
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/** @param {HTMLElement} node */
|
|
346
|
+
function creates_stacking_context(node) {
|
|
347
|
+
const style = getComputedStyle(node);
|
|
348
|
+
|
|
349
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context
|
|
350
|
+
if (style.position === "fixed") return true;
|
|
351
|
+
// Forked to fix upstream bug https://github.com/Rich-Harris/stacking-order/issues/3
|
|
352
|
+
// if (
|
|
353
|
+
// (style.zIndex !== "auto" && style.position !== "static") ||
|
|
354
|
+
// is_flex_item(node)
|
|
355
|
+
// )
|
|
356
|
+
if (style.zIndex !== "auto" && (style.position !== "static" || is_flex_item(node))) return true;
|
|
357
|
+
if (+style.opacity < 1) return true;
|
|
358
|
+
if ("transform" in style && style.transform !== "none") return true;
|
|
359
|
+
if ("webkitTransform" in style && style.webkitTransform !== "none") return true;
|
|
360
|
+
if ("mixBlendMode" in style && style.mixBlendMode !== "normal") return true;
|
|
361
|
+
if ("filter" in style && style.filter !== "none") return true;
|
|
362
|
+
if ("webkitFilter" in style && style.webkitFilter !== "none") return true;
|
|
363
|
+
if ("isolation" in style && style.isolation === "isolate") return true;
|
|
364
|
+
if (props.test(style.willChange)) return true;
|
|
365
|
+
// @ts-expect-error
|
|
366
|
+
if (style.webkitOverflowScrolling === "touch") return true;
|
|
367
|
+
return false;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/** @param {HTMLElement[]} nodes */
|
|
371
|
+
function find_stacking_context(nodes) {
|
|
372
|
+
let i = nodes.length;
|
|
373
|
+
while (i--) {
|
|
374
|
+
const node = nodes[i];
|
|
375
|
+
assert(node);
|
|
376
|
+
if (creates_stacking_context(node)) return node;
|
|
377
|
+
}
|
|
378
|
+
return null;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/** @param {HTMLElement} node */
|
|
382
|
+
function get_z_index(node) {
|
|
383
|
+
return node && Number(getComputedStyle(node).zIndex) || 0;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/** @param {HTMLElement} node */
|
|
387
|
+
function get_ancestors(node) {
|
|
388
|
+
const ancestors = [];
|
|
389
|
+
while (node) {
|
|
390
|
+
ancestors.push(node);
|
|
391
|
+
node = get_parent(node);
|
|
392
|
+
}
|
|
393
|
+
return ancestors; // [ node, ... <body>, <html>, document ]
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/** @param {HTMLElement} node */
|
|
397
|
+
function get_parent(node) {
|
|
398
|
+
var _node$parentNode;
|
|
399
|
+
// @ts-ignore
|
|
400
|
+
return ((_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 ? void 0 : _node$parentNode.host) || node.parentNode;
|
|
401
|
+
}
|
|
402
|
+
|
|
295
403
|
const EXCEEDED_HORIZONTAL_MIN = 0b0001;
|
|
296
404
|
const EXCEEDED_HORIZONTAL_MAX = 0b0010;
|
|
297
405
|
const EXCEEDED_VERTICAL_MIN = 0b0100;
|
|
@@ -504,7 +612,7 @@ function updateListeners() {
|
|
|
504
612
|
window.removeEventListener("mouseup", handlePointerUp);
|
|
505
613
|
window.removeEventListener("touchcancel", handlePointerUp);
|
|
506
614
|
window.removeEventListener("touchend", handlePointerUp);
|
|
507
|
-
if (
|
|
615
|
+
if (registeredResizeHandlers.size > 0) {
|
|
508
616
|
if (isPointerDown) {
|
|
509
617
|
if (intersectingHandles.length > 0) {
|
|
510
618
|
ownerDocumentCounts.forEach((count, ownerDocument) => {
|
|
@@ -2061,11 +2169,12 @@ function PanelGroupWithForwardedRef({
|
|
|
2061
2169
|
...rest,
|
|
2062
2170
|
children,
|
|
2063
2171
|
className: classNameFromProps,
|
|
2172
|
+
id: idFromProps,
|
|
2173
|
+
ref: panelGroupElementRef,
|
|
2064
2174
|
style: {
|
|
2065
2175
|
...style,
|
|
2066
2176
|
...styleFromProps
|
|
2067
2177
|
},
|
|
2068
|
-
ref: panelGroupElementRef,
|
|
2069
2178
|
// CSS selectors
|
|
2070
2179
|
"data-panel-group": "",
|
|
2071
2180
|
"data-panel-group-direction": direction,
|
|
@@ -2269,6 +2378,7 @@ function PanelResizeHandle({
|
|
|
2269
2378
|
...rest,
|
|
2270
2379
|
children,
|
|
2271
2380
|
className: classNameFromProps,
|
|
2381
|
+
id: idFromProps,
|
|
2272
2382
|
onBlur: () => setIsFocused(false),
|
|
2273
2383
|
onFocus: () => setIsFocused(true),
|
|
2274
2384
|
ref: elementRef,
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
|
-
var stackingOrder = require('stacking-order');
|
|
7
6
|
|
|
8
7
|
function _interopNamespace(e) {
|
|
9
8
|
if (e && e.__esModule) return e;
|
|
@@ -155,6 +154,7 @@ function PanelWithForwardedRef({
|
|
|
155
154
|
...rest,
|
|
156
155
|
children,
|
|
157
156
|
className: classNameFromProps,
|
|
157
|
+
id: idFromProps,
|
|
158
158
|
style: {
|
|
159
159
|
...style,
|
|
160
160
|
...styleFromProps
|
|
@@ -278,6 +278,114 @@ function intersects(rectOne, rectTwo, strict) {
|
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
+
// Forked from NPM stacking-order@2.0.0
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Determine which of two nodes appears in front of the other —
|
|
285
|
+
* if `a` is in front, returns 1, otherwise returns -1
|
|
286
|
+
* @param {HTMLElement} a
|
|
287
|
+
* @param {HTMLElement} b
|
|
288
|
+
*/
|
|
289
|
+
function compare(a, b) {
|
|
290
|
+
if (a === b) throw new Error("Cannot compare node with itself");
|
|
291
|
+
const ancestors = {
|
|
292
|
+
a: get_ancestors(a),
|
|
293
|
+
b: get_ancestors(b)
|
|
294
|
+
};
|
|
295
|
+
let common_ancestor;
|
|
296
|
+
|
|
297
|
+
// remove shared ancestors
|
|
298
|
+
while (ancestors.a.at(-1) === ancestors.b.at(-1)) {
|
|
299
|
+
a = ancestors.a.pop();
|
|
300
|
+
b = ancestors.b.pop();
|
|
301
|
+
common_ancestor = a;
|
|
302
|
+
}
|
|
303
|
+
assert(common_ancestor);
|
|
304
|
+
const z_indexes = {
|
|
305
|
+
a: get_z_index(find_stacking_context(ancestors.a)),
|
|
306
|
+
b: get_z_index(find_stacking_context(ancestors.b))
|
|
307
|
+
};
|
|
308
|
+
if (z_indexes.a === z_indexes.b) {
|
|
309
|
+
const children = common_ancestor.childNodes;
|
|
310
|
+
const furthest_ancestors = {
|
|
311
|
+
a: ancestors.a.at(-1),
|
|
312
|
+
b: ancestors.b.at(-1)
|
|
313
|
+
};
|
|
314
|
+
let i = children.length;
|
|
315
|
+
while (i--) {
|
|
316
|
+
const child = children[i];
|
|
317
|
+
if (child === furthest_ancestors.a) return 1;
|
|
318
|
+
if (child === furthest_ancestors.b) return -1;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return Math.sign(z_indexes.a - z_indexes.b);
|
|
322
|
+
}
|
|
323
|
+
const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;
|
|
324
|
+
|
|
325
|
+
/** @param {HTMLElement} node */
|
|
326
|
+
function is_flex_item(node) {
|
|
327
|
+
const display = getComputedStyle(get_parent(node)).display;
|
|
328
|
+
return display === "flex" || display === "inline-flex";
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/** @param {HTMLElement} node */
|
|
332
|
+
function creates_stacking_context(node) {
|
|
333
|
+
const style = getComputedStyle(node);
|
|
334
|
+
|
|
335
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context
|
|
336
|
+
if (style.position === "fixed") return true;
|
|
337
|
+
// Forked to fix upstream bug https://github.com/Rich-Harris/stacking-order/issues/3
|
|
338
|
+
// if (
|
|
339
|
+
// (style.zIndex !== "auto" && style.position !== "static") ||
|
|
340
|
+
// is_flex_item(node)
|
|
341
|
+
// )
|
|
342
|
+
if (style.zIndex !== "auto" && (style.position !== "static" || is_flex_item(node))) return true;
|
|
343
|
+
if (+style.opacity < 1) return true;
|
|
344
|
+
if ("transform" in style && style.transform !== "none") return true;
|
|
345
|
+
if ("webkitTransform" in style && style.webkitTransform !== "none") return true;
|
|
346
|
+
if ("mixBlendMode" in style && style.mixBlendMode !== "normal") return true;
|
|
347
|
+
if ("filter" in style && style.filter !== "none") return true;
|
|
348
|
+
if ("webkitFilter" in style && style.webkitFilter !== "none") return true;
|
|
349
|
+
if ("isolation" in style && style.isolation === "isolate") return true;
|
|
350
|
+
if (props.test(style.willChange)) return true;
|
|
351
|
+
// @ts-expect-error
|
|
352
|
+
if (style.webkitOverflowScrolling === "touch") return true;
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/** @param {HTMLElement[]} nodes */
|
|
357
|
+
function find_stacking_context(nodes) {
|
|
358
|
+
let i = nodes.length;
|
|
359
|
+
while (i--) {
|
|
360
|
+
const node = nodes[i];
|
|
361
|
+
assert(node);
|
|
362
|
+
if (creates_stacking_context(node)) return node;
|
|
363
|
+
}
|
|
364
|
+
return null;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/** @param {HTMLElement} node */
|
|
368
|
+
function get_z_index(node) {
|
|
369
|
+
return node && Number(getComputedStyle(node).zIndex) || 0;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/** @param {HTMLElement} node */
|
|
373
|
+
function get_ancestors(node) {
|
|
374
|
+
const ancestors = [];
|
|
375
|
+
while (node) {
|
|
376
|
+
ancestors.push(node);
|
|
377
|
+
node = get_parent(node);
|
|
378
|
+
}
|
|
379
|
+
return ancestors; // [ node, ... <body>, <html>, document ]
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/** @param {HTMLElement} node */
|
|
383
|
+
function get_parent(node) {
|
|
384
|
+
var _node$parentNode;
|
|
385
|
+
// @ts-ignore
|
|
386
|
+
return ((_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 ? void 0 : _node$parentNode.host) || node.parentNode;
|
|
387
|
+
}
|
|
388
|
+
|
|
281
389
|
const EXCEEDED_HORIZONTAL_MIN = 0b0001;
|
|
282
390
|
const EXCEEDED_HORIZONTAL_MAX = 0b0010;
|
|
283
391
|
const EXCEEDED_VERTICAL_MIN = 0b0100;
|
|
@@ -419,7 +527,7 @@ function recalculateIntersectingHandles({
|
|
|
419
527
|
// Calculating stacking order has a cost, so we should avoid it if possible
|
|
420
528
|
// That is why we only check potentially intersecting handles,
|
|
421
529
|
// and why we skip if the event target is within the handle's DOM
|
|
422
|
-
|
|
530
|
+
compare(targetElement, dragHandleElement) > 0) {
|
|
423
531
|
// If the target is above the drag handle, then we also need to confirm they overlap
|
|
424
532
|
// If they are beside each other (e.g. a panel and its drag handle) then the handle is still interactive
|
|
425
533
|
//
|
|
@@ -490,7 +598,7 @@ function updateListeners() {
|
|
|
490
598
|
window.removeEventListener("mouseup", handlePointerUp);
|
|
491
599
|
window.removeEventListener("touchcancel", handlePointerUp);
|
|
492
600
|
window.removeEventListener("touchend", handlePointerUp);
|
|
493
|
-
if (
|
|
601
|
+
if (registeredResizeHandlers.size > 0) {
|
|
494
602
|
if (isPointerDown) {
|
|
495
603
|
if (intersectingHandles.length > 0) {
|
|
496
604
|
ownerDocumentCounts.forEach((count, ownerDocument) => {
|
|
@@ -1853,11 +1961,12 @@ function PanelGroupWithForwardedRef({
|
|
|
1853
1961
|
...rest,
|
|
1854
1962
|
children,
|
|
1855
1963
|
className: classNameFromProps,
|
|
1964
|
+
id: idFromProps,
|
|
1965
|
+
ref: panelGroupElementRef,
|
|
1856
1966
|
style: {
|
|
1857
1967
|
...style,
|
|
1858
1968
|
...styleFromProps
|
|
1859
1969
|
},
|
|
1860
|
-
ref: panelGroupElementRef,
|
|
1861
1970
|
// CSS selectors
|
|
1862
1971
|
"data-panel-group": "",
|
|
1863
1972
|
"data-panel-group-direction": direction,
|
|
@@ -2058,6 +2167,7 @@ function PanelResizeHandle({
|
|
|
2058
2167
|
...rest,
|
|
2059
2168
|
children,
|
|
2060
2169
|
className: classNameFromProps,
|
|
2170
|
+
id: idFromProps,
|
|
2061
2171
|
onBlur: () => setIsFocused(false),
|
|
2062
2172
|
onFocus: () => setIsFocused(true),
|
|
2063
2173
|
ref: elementRef,
|