@octanejs/resizable-panels 0.0.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.
- package/LICENSE.upstream +21 -0
- package/README.md +22 -0
- package/UPSTREAM.md +64 -0
- package/package.json +61 -0
- package/src/components/group/Group.tsrx +244 -0
- package/src/components/group/GroupContext.ts +25 -0
- package/src/components/group/auto-save/getStorageKey.ts +3 -0
- package/src/components/group/auto-save/readLegacyLayout.ts +37 -0
- package/src/components/group/sortByElementOffset.ts +20 -0
- package/src/components/group/types.ts +50 -0
- package/src/components/group/useDefaultLayout.ts +152 -0
- package/src/components/group/useGroupCallbackRef.ts +6 -0
- package/src/components/group/useGroupContext.ts +12 -0
- package/src/components/group/useGroupImperativeHandle.ts +46 -0
- package/src/components/group/useGroupRef.ts +6 -0
- package/src/components/panel/Panel.tsrx +130 -0
- package/src/components/panel/types.ts +66 -0
- package/src/components/panel/usePanelCallbackRef.ts +6 -0
- package/src/components/panel/usePanelImperativeHandle.ts +42 -0
- package/src/components/panel/usePanelRef.ts +6 -0
- package/src/components/separator/Separator.tsrx +126 -0
- package/src/components/separator/types.ts +22 -0
- package/src/constants.ts +25 -0
- package/src/global/cursor/getCursorStyle.ts +102 -0
- package/src/global/cursor/supportsAdvancedCursorStyles.ts +25 -0
- package/src/global/cursor/updateCursorStyle.ts +77 -0
- package/src/global/dom/calculateAvailableGroupSize.ts +11 -0
- package/src/global/dom/calculateHitRegions.ts +200 -0
- package/src/global/dom/calculatePanelConstraints.ts +84 -0
- package/src/global/event-handlers/onDocumentContextMenu.ts +9 -0
- package/src/global/event-handlers/onDocumentDoubleClick.ts +31 -0
- package/src/global/event-handlers/onDocumentKeyDown.ts +133 -0
- package/src/global/event-handlers/onDocumentPointerDown.ts +56 -0
- package/src/global/event-handlers/onDocumentPointerLeave.ts +21 -0
- package/src/global/event-handlers/onDocumentPointerMove.ts +89 -0
- package/src/global/event-handlers/onDocumentPointerOut.ts +19 -0
- package/src/global/event-handlers/onDocumentPointerUp.ts +14 -0
- package/src/global/mountGroup.ts +213 -0
- package/src/global/mutable-state/groups.ts +104 -0
- package/src/global/mutable-state/interactions.ts +49 -0
- package/src/global/mutable-state/types.ts +31 -0
- package/src/global/styles/convertEmToPixels.ts +6 -0
- package/src/global/styles/convertRemToPixels.ts +6 -0
- package/src/global/styles/convertVhToPixels.ts +3 -0
- package/src/global/styles/convertVwToPixels.ts +3 -0
- package/src/global/styles/parseSizeAndUnit.ts +28 -0
- package/src/global/styles/sizeStyleToPixels.ts +48 -0
- package/src/global/utils/adjustLayoutByDelta.ts +339 -0
- package/src/global/utils/adjustLayoutForSeparator.ts +54 -0
- package/src/global/utils/calculateDefaultLayout.ts +37 -0
- package/src/global/utils/calculateSeparatorAriaValues.ts +67 -0
- package/src/global/utils/compareLayoutNumbers.ts +9 -0
- package/src/global/utils/completeActivePointerResize.ts +37 -0
- package/src/global/utils/doRectsIntersect.ts +5 -0
- package/src/global/utils/findClosestHitRegion.ts +43 -0
- package/src/global/utils/findClosestRect.ts +36 -0
- package/src/global/utils/findMatchingHitRegions.ts +41 -0
- package/src/global/utils/findSeparatorGroup.ts +13 -0
- package/src/global/utils/formatLayoutNumber.ts +3 -0
- package/src/global/utils/getDistanceBetweenPointAndRect.ts +14 -0
- package/src/global/utils/getImperativeGroupMethods.ts +68 -0
- package/src/global/utils/getImperativePanelMethods.ts +228 -0
- package/src/global/utils/isCoarsePointer.ts +8 -0
- package/src/global/utils/isViableHitTarget.ts +53 -0
- package/src/global/utils/layoutNumbersEqual.ts +5 -0
- package/src/global/utils/layoutsEqual.ts +17 -0
- package/src/global/utils/notifyPanelOnResize.ts +33 -0
- package/src/global/utils/objectsEqual.ts +14 -0
- package/src/global/utils/preserveFixedPanelSizes.ts +74 -0
- package/src/global/utils/updateActiveHitRegion.ts +132 -0
- package/src/global/utils/validateLayoutKeys.ts +19 -0
- package/src/global/utils/validatePanelGroupLayout.ts +92 -0
- package/src/global/utils/validatePanelSize.ts +41 -0
- package/src/hooks/useForceUpdate.ts +8 -0
- package/src/hooks/useId.ts +6 -0
- package/src/hooks/useIsomorphicLayoutEffect.ts +4 -0
- package/src/hooks/useMergedRefs.ts +18 -0
- package/src/hooks/useStableArray.ts +15 -0
- package/src/hooks/useStableCallback.ts +18 -0
- package/src/hooks/useStableObject.ts +15 -0
- package/src/index.tsrx +12 -0
- package/src/internal.ts +23 -0
- package/src/types.ts +18 -0
- package/src/utils/EventEmitter.ts +72 -0
- package/src/utils/assert.ts +8 -0
- package/src/utils/isArrayEqual.ts +12 -0
- package/src/utils/isHTMLElement.ts +9 -0
- package/src/utils/isShadowRoot.ts +9 -0
- package/src/utils/parseNumericStyleValue.ts +15 -0
- package/src/vendor/stacking-order.ts +133 -0
- package/status.json +11 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// Forked from NPM stacking-order@2.0.0
|
|
2
|
+
// - github.com/Rich-Harris/stacking-order/issues/3
|
|
3
|
+
// - github.com/Rich-Harris/stacking-order/issues/6
|
|
4
|
+
|
|
5
|
+
import { assert } from '../utils/assert';
|
|
6
|
+
import { isShadowRoot } from '../utils/isShadowRoot';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Determine which of two nodes appears in front of the other —
|
|
10
|
+
* if `a` is in front, returns 1, otherwise returns -1
|
|
11
|
+
* @param {HTMLElement | SVGElement} a
|
|
12
|
+
* @param {HTMLElement | SVGElement} b
|
|
13
|
+
*/
|
|
14
|
+
export function compare(a: HTMLElement | SVGElement, b: HTMLElement | SVGElement): number {
|
|
15
|
+
if (a === b) throw new Error('Cannot compare node with itself');
|
|
16
|
+
|
|
17
|
+
const ancestors = {
|
|
18
|
+
a: get_ancestors(a),
|
|
19
|
+
b: get_ancestors(b),
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
let common_ancestor;
|
|
23
|
+
|
|
24
|
+
// remove shared ancestors
|
|
25
|
+
while (ancestors.a.at(-1) === ancestors.b.at(-1)) {
|
|
26
|
+
common_ancestor = ancestors.a.pop() as HTMLElement;
|
|
27
|
+
ancestors.b.pop();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
assert(
|
|
31
|
+
common_ancestor,
|
|
32
|
+
'Stacking order can only be calculated for elements with a common ancestor',
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const z_indexes = {
|
|
36
|
+
a: get_z_index(find_stacking_context(ancestors.a)),
|
|
37
|
+
b: get_z_index(find_stacking_context(ancestors.b)),
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
if (z_indexes.a === z_indexes.b) {
|
|
41
|
+
const children = common_ancestor.childNodes;
|
|
42
|
+
|
|
43
|
+
const furthest_ancestors = {
|
|
44
|
+
a: ancestors.a.at(-1),
|
|
45
|
+
b: ancestors.b.at(-1),
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
let i = children.length;
|
|
49
|
+
while (i--) {
|
|
50
|
+
const child = children[i];
|
|
51
|
+
if (child === furthest_ancestors.a) return 1;
|
|
52
|
+
if (child === furthest_ancestors.b) return -1;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return Math.sign(z_indexes.a - z_indexes.b);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const props =
|
|
60
|
+
/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;
|
|
61
|
+
|
|
62
|
+
/** @param {HTMLElement | SVGElement} node */
|
|
63
|
+
function is_flex_item(node: HTMLElement | SVGElement) {
|
|
64
|
+
// @ts-expect-error ParentNode vs Element
|
|
65
|
+
const display = getComputedStyle(get_parent(node) ?? node).display;
|
|
66
|
+
return display === 'flex' || display === 'inline-flex';
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** @param {HTMLElement | SVGElement} node */
|
|
70
|
+
function creates_stacking_context(node: HTMLElement | SVGElement) {
|
|
71
|
+
const style = getComputedStyle(node);
|
|
72
|
+
|
|
73
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context
|
|
74
|
+
if (style.position === 'fixed') return true;
|
|
75
|
+
// Forked to fix upstream bug https://github.com/Rich-Harris/stacking-order/issues/3
|
|
76
|
+
// if (
|
|
77
|
+
// (style.zIndex !== "auto" && style.position !== "static") ||
|
|
78
|
+
// is_flex_item(node)
|
|
79
|
+
// )
|
|
80
|
+
if (style.zIndex !== 'auto' && (style.position !== 'static' || is_flex_item(node))) return true;
|
|
81
|
+
if (+style.opacity < 1) return true;
|
|
82
|
+
if ('transform' in style && style.transform !== 'none') return true;
|
|
83
|
+
if ('webkitTransform' in style && style.webkitTransform !== 'none') return true;
|
|
84
|
+
if ('mixBlendMode' in style && style.mixBlendMode !== 'normal') return true;
|
|
85
|
+
if ('filter' in style && style.filter !== 'none') return true;
|
|
86
|
+
if ('webkitFilter' in style && style.webkitFilter !== 'none') return true;
|
|
87
|
+
if ('isolation' in style && style.isolation === 'isolate') return true;
|
|
88
|
+
if (props.test(style.willChange)) return true;
|
|
89
|
+
// @ts-expect-error Unrecognized prop
|
|
90
|
+
if (style.webkitOverflowScrolling === 'touch') return true;
|
|
91
|
+
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** @param {(HTMLElement| SVGElement)[]} nodes */
|
|
96
|
+
function find_stacking_context(nodes: (HTMLElement | SVGElement)[]) {
|
|
97
|
+
let i = nodes.length;
|
|
98
|
+
|
|
99
|
+
while (i--) {
|
|
100
|
+
const node = nodes[i];
|
|
101
|
+
assert(node, 'Missing node');
|
|
102
|
+
if (creates_stacking_context(node)) return node;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** @param {HTMLElement | SVGElement} node */
|
|
109
|
+
function get_z_index(node: HTMLElement | SVGElement | null) {
|
|
110
|
+
return (node && Number(getComputedStyle(node).zIndex)) || 0;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** @param {HTMLElement} node */
|
|
114
|
+
function get_ancestors(node: HTMLElement | SVGElement | null) {
|
|
115
|
+
const ancestors = [];
|
|
116
|
+
|
|
117
|
+
while (node) {
|
|
118
|
+
ancestors.push(node);
|
|
119
|
+
// @ts-expect-error ParentNode vs Element
|
|
120
|
+
node = get_parent(node);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return ancestors; // [ node, ... <body>, <html>, document ]
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** @param {HTMLElement} node */
|
|
127
|
+
function get_parent(node: HTMLElement) {
|
|
128
|
+
const { parentNode } = node;
|
|
129
|
+
if (isShadowRoot(parentNode)) {
|
|
130
|
+
return parentNode.host;
|
|
131
|
+
}
|
|
132
|
+
return parentNode;
|
|
133
|
+
}
|
package/status.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"upstream": { "package": "react-resizable-panels", "version": "4.12.2" },
|
|
3
|
+
"surface": "Group, Panel, Separator, persistence hooks, refs, imperative APIs, layout constraints, pointer and keyboard interaction, ARIA, cursor handling, and ResizeObserver behavior are implemented against react-resizable-panels 4.12.2.",
|
|
4
|
+
"divergences": [
|
|
5
|
+
"useId(undefined) fallback cannot reproduce React's mocked ':r123:' seam; adapted upstream case asserts a non-empty Octane id and is recorded as react-resizable-panels-useId-fallback."
|
|
6
|
+
],
|
|
7
|
+
"ssr": "Deterministic server rendering and live hydration adoption are covered by dedicated executable projects.",
|
|
8
|
+
"verified": "2026-08-02",
|
|
9
|
+
"parityEvidence": "packages/resizable-panels/audit/react-parity.json",
|
|
10
|
+
"docs": ["docs/plans/2026-08-02-004-feat-react-resizable-panels-binding-plan.md"]
|
|
11
|
+
}
|