react-resizable-panels 2.0.8 → 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 CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.0.9
4
+
5
+ - Fix Flex stacking context bug (#301)
6
+ - Fix case where pointer event listeners were sometimes added to the document unnecessarily
7
+
3
8
  ## 2.0.8
4
9
 
5
10
  - `Panel`/`PanelGroup`/`PanelResizeHandle`` pass "id" prop through to DOM (#299)
@@ -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;
@@ -304,6 +303,114 @@ function intersects(rectOne, rectTwo, strict) {
304
303
  }
305
304
  }
306
305
 
306
+ // Forked from NPM stacking-order@2.0.0
307
+
308
+ /**
309
+ * Determine which of two nodes appears in front of the other —
310
+ * if `a` is in front, returns 1, otherwise returns -1
311
+ * @param {HTMLElement} a
312
+ * @param {HTMLElement} b
313
+ */
314
+ function compare(a, b) {
315
+ if (a === b) throw new Error("Cannot compare node with itself");
316
+ const ancestors = {
317
+ a: get_ancestors(a),
318
+ b: get_ancestors(b)
319
+ };
320
+ let common_ancestor;
321
+
322
+ // remove shared ancestors
323
+ while (ancestors.a.at(-1) === ancestors.b.at(-1)) {
324
+ a = ancestors.a.pop();
325
+ b = ancestors.b.pop();
326
+ common_ancestor = a;
327
+ }
328
+ assert(common_ancestor);
329
+ const z_indexes = {
330
+ a: get_z_index(find_stacking_context(ancestors.a)),
331
+ b: get_z_index(find_stacking_context(ancestors.b))
332
+ };
333
+ if (z_indexes.a === z_indexes.b) {
334
+ const children = common_ancestor.childNodes;
335
+ const furthest_ancestors = {
336
+ a: ancestors.a.at(-1),
337
+ b: ancestors.b.at(-1)
338
+ };
339
+ let i = children.length;
340
+ while (i--) {
341
+ const child = children[i];
342
+ if (child === furthest_ancestors.a) return 1;
343
+ if (child === furthest_ancestors.b) return -1;
344
+ }
345
+ }
346
+ return Math.sign(z_indexes.a - z_indexes.b);
347
+ }
348
+ const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;
349
+
350
+ /** @param {HTMLElement} node */
351
+ function is_flex_item(node) {
352
+ const display = getComputedStyle(get_parent(node)).display;
353
+ return display === "flex" || display === "inline-flex";
354
+ }
355
+
356
+ /** @param {HTMLElement} node */
357
+ function creates_stacking_context(node) {
358
+ const style = getComputedStyle(node);
359
+
360
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context
361
+ if (style.position === "fixed") return true;
362
+ // Forked to fix upstream bug https://github.com/Rich-Harris/stacking-order/issues/3
363
+ // if (
364
+ // (style.zIndex !== "auto" && style.position !== "static") ||
365
+ // is_flex_item(node)
366
+ // )
367
+ if (style.zIndex !== "auto" && (style.position !== "static" || is_flex_item(node))) return true;
368
+ if (+style.opacity < 1) return true;
369
+ if ("transform" in style && style.transform !== "none") return true;
370
+ if ("webkitTransform" in style && style.webkitTransform !== "none") return true;
371
+ if ("mixBlendMode" in style && style.mixBlendMode !== "normal") return true;
372
+ if ("filter" in style && style.filter !== "none") return true;
373
+ if ("webkitFilter" in style && style.webkitFilter !== "none") return true;
374
+ if ("isolation" in style && style.isolation === "isolate") return true;
375
+ if (props.test(style.willChange)) return true;
376
+ // @ts-expect-error
377
+ if (style.webkitOverflowScrolling === "touch") return true;
378
+ return false;
379
+ }
380
+
381
+ /** @param {HTMLElement[]} nodes */
382
+ function find_stacking_context(nodes) {
383
+ let i = nodes.length;
384
+ while (i--) {
385
+ const node = nodes[i];
386
+ assert(node);
387
+ if (creates_stacking_context(node)) return node;
388
+ }
389
+ return null;
390
+ }
391
+
392
+ /** @param {HTMLElement} node */
393
+ function get_z_index(node) {
394
+ return node && Number(getComputedStyle(node).zIndex) || 0;
395
+ }
396
+
397
+ /** @param {HTMLElement} node */
398
+ function get_ancestors(node) {
399
+ const ancestors = [];
400
+ while (node) {
401
+ ancestors.push(node);
402
+ node = get_parent(node);
403
+ }
404
+ return ancestors; // [ node, ... <body>, <html>, document ]
405
+ }
406
+
407
+ /** @param {HTMLElement} node */
408
+ function get_parent(node) {
409
+ var _node$parentNode;
410
+ // @ts-ignore
411
+ return ((_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 ? void 0 : _node$parentNode.host) || node.parentNode;
412
+ }
413
+
307
414
  const EXCEEDED_HORIZONTAL_MIN = 0b0001;
308
415
  const EXCEEDED_HORIZONTAL_MAX = 0b0010;
309
416
  const EXCEEDED_VERTICAL_MIN = 0b0100;
@@ -445,7 +552,7 @@ function recalculateIntersectingHandles({
445
552
  // Calculating stacking order has a cost, so we should avoid it if possible
446
553
  // That is why we only check potentially intersecting handles,
447
554
  // and why we skip if the event target is within the handle's DOM
448
- stackingOrder.compare(targetElement, dragHandleElement) > 0) {
555
+ compare(targetElement, dragHandleElement) > 0) {
449
556
  // If the target is above the drag handle, then we also need to confirm they overlap
450
557
  // If they are beside each other (e.g. a panel and its drag handle) then the handle is still interactive
451
558
  //
@@ -516,7 +623,7 @@ function updateListeners() {
516
623
  window.removeEventListener("mouseup", handlePointerUp);
517
624
  window.removeEventListener("touchcancel", handlePointerUp);
518
625
  window.removeEventListener("touchend", handlePointerUp);
519
- if (registerResizeHandle.length > 0) {
626
+ if (registeredResizeHandlers.size > 0) {
520
627
  if (isPointerDown) {
521
628
  if (intersectingHandles.length > 0) {
522
629
  ownerDocumentCounts.forEach((count, ownerDocument) => {
@@ -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;
@@ -310,6 +309,114 @@ function intersects(rectOne, rectTwo, strict) {
310
309
  }
311
310
  }
312
311
 
312
+ // Forked from NPM stacking-order@2.0.0
313
+
314
+ /**
315
+ * Determine which of two nodes appears in front of the other —
316
+ * if `a` is in front, returns 1, otherwise returns -1
317
+ * @param {HTMLElement} a
318
+ * @param {HTMLElement} b
319
+ */
320
+ function compare(a, b) {
321
+ if (a === b) throw new Error("Cannot compare node with itself");
322
+ const ancestors = {
323
+ a: get_ancestors(a),
324
+ b: get_ancestors(b)
325
+ };
326
+ let common_ancestor;
327
+
328
+ // remove shared ancestors
329
+ while (ancestors.a.at(-1) === ancestors.b.at(-1)) {
330
+ a = ancestors.a.pop();
331
+ b = ancestors.b.pop();
332
+ common_ancestor = a;
333
+ }
334
+ assert(common_ancestor);
335
+ const z_indexes = {
336
+ a: get_z_index(find_stacking_context(ancestors.a)),
337
+ b: get_z_index(find_stacking_context(ancestors.b))
338
+ };
339
+ if (z_indexes.a === z_indexes.b) {
340
+ const children = common_ancestor.childNodes;
341
+ const furthest_ancestors = {
342
+ a: ancestors.a.at(-1),
343
+ b: ancestors.b.at(-1)
344
+ };
345
+ let i = children.length;
346
+ while (i--) {
347
+ const child = children[i];
348
+ if (child === furthest_ancestors.a) return 1;
349
+ if (child === furthest_ancestors.b) return -1;
350
+ }
351
+ }
352
+ return Math.sign(z_indexes.a - z_indexes.b);
353
+ }
354
+ const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;
355
+
356
+ /** @param {HTMLElement} node */
357
+ function is_flex_item(node) {
358
+ const display = getComputedStyle(get_parent(node)).display;
359
+ return display === "flex" || display === "inline-flex";
360
+ }
361
+
362
+ /** @param {HTMLElement} node */
363
+ function creates_stacking_context(node) {
364
+ const style = getComputedStyle(node);
365
+
366
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context
367
+ if (style.position === "fixed") return true;
368
+ // Forked to fix upstream bug https://github.com/Rich-Harris/stacking-order/issues/3
369
+ // if (
370
+ // (style.zIndex !== "auto" && style.position !== "static") ||
371
+ // is_flex_item(node)
372
+ // )
373
+ if (style.zIndex !== "auto" && (style.position !== "static" || is_flex_item(node))) return true;
374
+ if (+style.opacity < 1) return true;
375
+ if ("transform" in style && style.transform !== "none") return true;
376
+ if ("webkitTransform" in style && style.webkitTransform !== "none") return true;
377
+ if ("mixBlendMode" in style && style.mixBlendMode !== "normal") return true;
378
+ if ("filter" in style && style.filter !== "none") return true;
379
+ if ("webkitFilter" in style && style.webkitFilter !== "none") return true;
380
+ if ("isolation" in style && style.isolation === "isolate") return true;
381
+ if (props.test(style.willChange)) return true;
382
+ // @ts-expect-error
383
+ if (style.webkitOverflowScrolling === "touch") return true;
384
+ return false;
385
+ }
386
+
387
+ /** @param {HTMLElement[]} nodes */
388
+ function find_stacking_context(nodes) {
389
+ let i = nodes.length;
390
+ while (i--) {
391
+ const node = nodes[i];
392
+ assert(node);
393
+ if (creates_stacking_context(node)) return node;
394
+ }
395
+ return null;
396
+ }
397
+
398
+ /** @param {HTMLElement} node */
399
+ function get_z_index(node) {
400
+ return node && Number(getComputedStyle(node).zIndex) || 0;
401
+ }
402
+
403
+ /** @param {HTMLElement} node */
404
+ function get_ancestors(node) {
405
+ const ancestors = [];
406
+ while (node) {
407
+ ancestors.push(node);
408
+ node = get_parent(node);
409
+ }
410
+ return ancestors; // [ node, ... <body>, <html>, document ]
411
+ }
412
+
413
+ /** @param {HTMLElement} node */
414
+ function get_parent(node) {
415
+ var _node$parentNode;
416
+ // @ts-ignore
417
+ return ((_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 ? void 0 : _node$parentNode.host) || node.parentNode;
418
+ }
419
+
313
420
  const EXCEEDED_HORIZONTAL_MIN = 0b0001;
314
421
  const EXCEEDED_HORIZONTAL_MAX = 0b0010;
315
422
  const EXCEEDED_VERTICAL_MIN = 0b0100;
@@ -451,7 +558,7 @@ function recalculateIntersectingHandles({
451
558
  // Calculating stacking order has a cost, so we should avoid it if possible
452
559
  // That is why we only check potentially intersecting handles,
453
560
  // and why we skip if the event target is within the handle's DOM
454
- stackingOrder.compare(targetElement, dragHandleElement) > 0) {
561
+ compare(targetElement, dragHandleElement) > 0) {
455
562
  // If the target is above the drag handle, then we also need to confirm they overlap
456
563
  // If they are beside each other (e.g. a panel and its drag handle) then the handle is still interactive
457
564
  //
@@ -522,7 +629,7 @@ function updateListeners() {
522
629
  window.removeEventListener("mouseup", handlePointerUp);
523
630
  window.removeEventListener("touchcancel", handlePointerUp);
524
631
  window.removeEventListener("touchend", handlePointerUp);
525
- if (registerResizeHandle.length > 0) {
632
+ if (registeredResizeHandlers.size > 0) {
526
633
  if (isPointerDown) {
527
634
  if (intersectingHandles.length > 0) {
528
635
  ownerDocumentCounts.forEach((count, ownerDocument) => {
@@ -1,5 +1,4 @@
1
1
  import * as React from 'react';
2
- import { compare } from 'stacking-order';
3
2
 
4
3
  // This module exists to work around Webpack issue https://github.com/webpack/webpack/issues/14814
5
4
 
@@ -286,6 +285,114 @@ function intersects(rectOne, rectTwo, strict) {
286
285
  }
287
286
  }
288
287
 
288
+ // Forked from NPM stacking-order@2.0.0
289
+
290
+ /**
291
+ * Determine which of two nodes appears in front of the other —
292
+ * if `a` is in front, returns 1, otherwise returns -1
293
+ * @param {HTMLElement} a
294
+ * @param {HTMLElement} b
295
+ */
296
+ function compare(a, b) {
297
+ if (a === b) throw new Error("Cannot compare node with itself");
298
+ const ancestors = {
299
+ a: get_ancestors(a),
300
+ b: get_ancestors(b)
301
+ };
302
+ let common_ancestor;
303
+
304
+ // remove shared ancestors
305
+ while (ancestors.a.at(-1) === ancestors.b.at(-1)) {
306
+ a = ancestors.a.pop();
307
+ b = ancestors.b.pop();
308
+ common_ancestor = a;
309
+ }
310
+ assert(common_ancestor);
311
+ const z_indexes = {
312
+ a: get_z_index(find_stacking_context(ancestors.a)),
313
+ b: get_z_index(find_stacking_context(ancestors.b))
314
+ };
315
+ if (z_indexes.a === z_indexes.b) {
316
+ const children = common_ancestor.childNodes;
317
+ const furthest_ancestors = {
318
+ a: ancestors.a.at(-1),
319
+ b: ancestors.b.at(-1)
320
+ };
321
+ let i = children.length;
322
+ while (i--) {
323
+ const child = children[i];
324
+ if (child === furthest_ancestors.a) return 1;
325
+ if (child === furthest_ancestors.b) return -1;
326
+ }
327
+ }
328
+ return Math.sign(z_indexes.a - z_indexes.b);
329
+ }
330
+ const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;
331
+
332
+ /** @param {HTMLElement} node */
333
+ function is_flex_item(node) {
334
+ const display = getComputedStyle(get_parent(node)).display;
335
+ return display === "flex" || display === "inline-flex";
336
+ }
337
+
338
+ /** @param {HTMLElement} node */
339
+ function creates_stacking_context(node) {
340
+ const style = getComputedStyle(node);
341
+
342
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context
343
+ if (style.position === "fixed") return true;
344
+ // Forked to fix upstream bug https://github.com/Rich-Harris/stacking-order/issues/3
345
+ // if (
346
+ // (style.zIndex !== "auto" && style.position !== "static") ||
347
+ // is_flex_item(node)
348
+ // )
349
+ if (style.zIndex !== "auto" && (style.position !== "static" || is_flex_item(node))) return true;
350
+ if (+style.opacity < 1) return true;
351
+ if ("transform" in style && style.transform !== "none") return true;
352
+ if ("webkitTransform" in style && style.webkitTransform !== "none") return true;
353
+ if ("mixBlendMode" in style && style.mixBlendMode !== "normal") return true;
354
+ if ("filter" in style && style.filter !== "none") return true;
355
+ if ("webkitFilter" in style && style.webkitFilter !== "none") return true;
356
+ if ("isolation" in style && style.isolation === "isolate") return true;
357
+ if (props.test(style.willChange)) return true;
358
+ // @ts-expect-error
359
+ if (style.webkitOverflowScrolling === "touch") return true;
360
+ return false;
361
+ }
362
+
363
+ /** @param {HTMLElement[]} nodes */
364
+ function find_stacking_context(nodes) {
365
+ let i = nodes.length;
366
+ while (i--) {
367
+ const node = nodes[i];
368
+ assert(node);
369
+ if (creates_stacking_context(node)) return node;
370
+ }
371
+ return null;
372
+ }
373
+
374
+ /** @param {HTMLElement} node */
375
+ function get_z_index(node) {
376
+ return node && Number(getComputedStyle(node).zIndex) || 0;
377
+ }
378
+
379
+ /** @param {HTMLElement} node */
380
+ function get_ancestors(node) {
381
+ const ancestors = [];
382
+ while (node) {
383
+ ancestors.push(node);
384
+ node = get_parent(node);
385
+ }
386
+ return ancestors; // [ node, ... <body>, <html>, document ]
387
+ }
388
+
389
+ /** @param {HTMLElement} node */
390
+ function get_parent(node) {
391
+ var _node$parentNode;
392
+ // @ts-ignore
393
+ return ((_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 ? void 0 : _node$parentNode.host) || node.parentNode;
394
+ }
395
+
289
396
  const EXCEEDED_HORIZONTAL_MIN = 0b0001;
290
397
  const EXCEEDED_HORIZONTAL_MAX = 0b0010;
291
398
  const EXCEEDED_VERTICAL_MIN = 0b0100;
@@ -498,7 +605,7 @@ function updateListeners() {
498
605
  window.removeEventListener("mouseup", handlePointerUp);
499
606
  window.removeEventListener("touchcancel", handlePointerUp);
500
607
  window.removeEventListener("touchend", handlePointerUp);
501
- if (registerResizeHandle.length > 0) {
608
+ if (registeredResizeHandlers.size > 0) {
502
609
  if (isPointerDown) {
503
610
  if (intersectingHandles.length > 0) {
504
611
  ownerDocumentCounts.forEach((count, ownerDocument) => {
@@ -1,5 +1,4 @@
1
1
  import * as React from 'react';
2
- import { compare } from 'stacking-order';
3
2
 
4
3
  // This module exists to work around Webpack issue https://github.com/webpack/webpack/issues/14814
5
4
 
@@ -280,6 +279,114 @@ function intersects(rectOne, rectTwo, strict) {
280
279
  }
281
280
  }
282
281
 
282
+ // Forked from NPM stacking-order@2.0.0
283
+
284
+ /**
285
+ * Determine which of two nodes appears in front of the other —
286
+ * if `a` is in front, returns 1, otherwise returns -1
287
+ * @param {HTMLElement} a
288
+ * @param {HTMLElement} b
289
+ */
290
+ function compare(a, b) {
291
+ if (a === b) throw new Error("Cannot compare node with itself");
292
+ const ancestors = {
293
+ a: get_ancestors(a),
294
+ b: get_ancestors(b)
295
+ };
296
+ let common_ancestor;
297
+
298
+ // remove shared ancestors
299
+ while (ancestors.a.at(-1) === ancestors.b.at(-1)) {
300
+ a = ancestors.a.pop();
301
+ b = ancestors.b.pop();
302
+ common_ancestor = a;
303
+ }
304
+ assert(common_ancestor);
305
+ const z_indexes = {
306
+ a: get_z_index(find_stacking_context(ancestors.a)),
307
+ b: get_z_index(find_stacking_context(ancestors.b))
308
+ };
309
+ if (z_indexes.a === z_indexes.b) {
310
+ const children = common_ancestor.childNodes;
311
+ const furthest_ancestors = {
312
+ a: ancestors.a.at(-1),
313
+ b: ancestors.b.at(-1)
314
+ };
315
+ let i = children.length;
316
+ while (i--) {
317
+ const child = children[i];
318
+ if (child === furthest_ancestors.a) return 1;
319
+ if (child === furthest_ancestors.b) return -1;
320
+ }
321
+ }
322
+ return Math.sign(z_indexes.a - z_indexes.b);
323
+ }
324
+ const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;
325
+
326
+ /** @param {HTMLElement} node */
327
+ function is_flex_item(node) {
328
+ const display = getComputedStyle(get_parent(node)).display;
329
+ return display === "flex" || display === "inline-flex";
330
+ }
331
+
332
+ /** @param {HTMLElement} node */
333
+ function creates_stacking_context(node) {
334
+ const style = getComputedStyle(node);
335
+
336
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context
337
+ if (style.position === "fixed") return true;
338
+ // Forked to fix upstream bug https://github.com/Rich-Harris/stacking-order/issues/3
339
+ // if (
340
+ // (style.zIndex !== "auto" && style.position !== "static") ||
341
+ // is_flex_item(node)
342
+ // )
343
+ if (style.zIndex !== "auto" && (style.position !== "static" || is_flex_item(node))) return true;
344
+ if (+style.opacity < 1) return true;
345
+ if ("transform" in style && style.transform !== "none") return true;
346
+ if ("webkitTransform" in style && style.webkitTransform !== "none") return true;
347
+ if ("mixBlendMode" in style && style.mixBlendMode !== "normal") return true;
348
+ if ("filter" in style && style.filter !== "none") return true;
349
+ if ("webkitFilter" in style && style.webkitFilter !== "none") return true;
350
+ if ("isolation" in style && style.isolation === "isolate") return true;
351
+ if (props.test(style.willChange)) return true;
352
+ // @ts-expect-error
353
+ if (style.webkitOverflowScrolling === "touch") return true;
354
+ return false;
355
+ }
356
+
357
+ /** @param {HTMLElement[]} nodes */
358
+ function find_stacking_context(nodes) {
359
+ let i = nodes.length;
360
+ while (i--) {
361
+ const node = nodes[i];
362
+ assert(node);
363
+ if (creates_stacking_context(node)) return node;
364
+ }
365
+ return null;
366
+ }
367
+
368
+ /** @param {HTMLElement} node */
369
+ function get_z_index(node) {
370
+ return node && Number(getComputedStyle(node).zIndex) || 0;
371
+ }
372
+
373
+ /** @param {HTMLElement} node */
374
+ function get_ancestors(node) {
375
+ const ancestors = [];
376
+ while (node) {
377
+ ancestors.push(node);
378
+ node = get_parent(node);
379
+ }
380
+ return ancestors; // [ node, ... <body>, <html>, document ]
381
+ }
382
+
383
+ /** @param {HTMLElement} node */
384
+ function get_parent(node) {
385
+ var _node$parentNode;
386
+ // @ts-ignore
387
+ return ((_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 ? void 0 : _node$parentNode.host) || node.parentNode;
388
+ }
389
+
283
390
  const EXCEEDED_HORIZONTAL_MIN = 0b0001;
284
391
  const EXCEEDED_HORIZONTAL_MAX = 0b0010;
285
392
  const EXCEEDED_VERTICAL_MIN = 0b0100;
@@ -492,7 +599,7 @@ function updateListeners() {
492
599
  window.removeEventListener("mouseup", handlePointerUp);
493
600
  window.removeEventListener("touchcancel", handlePointerUp);
494
601
  window.removeEventListener("touchend", handlePointerUp);
495
- if (registerResizeHandle.length > 0) {
602
+ if (registeredResizeHandlers.size > 0) {
496
603
  if (isPointerDown) {
497
604
  if (intersectingHandles.length > 0) {
498
605
  ownerDocumentCounts.forEach((count, ownerDocument) => {
@@ -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;
@@ -306,6 +305,114 @@ function intersects(rectOne, rectTwo, strict) {
306
305
  }
307
306
  }
308
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
+
309
416
  const EXCEEDED_HORIZONTAL_MIN = 0b0001;
310
417
  const EXCEEDED_HORIZONTAL_MAX = 0b0010;
311
418
  const EXCEEDED_VERTICAL_MIN = 0b0100;
@@ -447,7 +554,7 @@ function recalculateIntersectingHandles({
447
554
  // Calculating stacking order has a cost, so we should avoid it if possible
448
555
  // That is why we only check potentially intersecting handles,
449
556
  // and why we skip if the event target is within the handle's DOM
450
- stackingOrder.compare(targetElement, dragHandleElement) > 0) {
557
+ compare(targetElement, dragHandleElement) > 0) {
451
558
  // If the target is above the drag handle, then we also need to confirm they overlap
452
559
  // If they are beside each other (e.g. a panel and its drag handle) then the handle is still interactive
453
560
  //
@@ -518,7 +625,7 @@ function updateListeners() {
518
625
  window.removeEventListener("mouseup", handlePointerUp);
519
626
  window.removeEventListener("touchcancel", handlePointerUp);
520
627
  window.removeEventListener("touchend", handlePointerUp);
521
- if (registerResizeHandle.length > 0) {
628
+ if (registeredResizeHandlers.size > 0) {
522
629
  if (isPointerDown) {
523
630
  if (intersectingHandles.length > 0) {
524
631
  ownerDocumentCounts.forEach((count, ownerDocument) => {