@zag-js/splitter 1.38.1 → 1.39.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/dist/chunk-QZ7TP4HQ.mjs +7 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -1
- package/dist/index.mjs +5 -1
- package/dist/splitter.anatomy.mjs +2 -0
- package/dist/splitter.connect.d.mts +1 -0
- package/dist/splitter.connect.d.ts +1 -0
- package/dist/splitter.connect.js +7 -3
- package/dist/splitter.connect.mjs +9 -3
- package/dist/splitter.dom.d.mts +1 -0
- package/dist/splitter.dom.d.ts +1 -0
- package/dist/splitter.dom.mjs +2 -0
- package/dist/splitter.machine.d.mts +1 -0
- package/dist/splitter.machine.d.ts +1 -0
- package/dist/splitter.machine.js +53 -0
- package/dist/splitter.machine.mjs +56 -1
- package/dist/splitter.props.d.mts +1 -0
- package/dist/splitter.props.d.ts +1 -0
- package/dist/splitter.props.js +2 -1
- package/dist/splitter.props.mjs +4 -1
- package/dist/splitter.types.d.mts +6 -0
- package/dist/splitter.types.d.ts +6 -0
- package/dist/utils/aria.d.mts +1 -0
- package/dist/utils/aria.d.ts +1 -0
- package/dist/utils/aria.mjs +2 -0
- package/dist/utils/fuzzy.mjs +2 -0
- package/dist/utils/intersects.d.mts +6 -0
- package/dist/utils/intersects.d.ts +6 -0
- package/dist/utils/intersects.js +40 -0
- package/dist/utils/intersects.mjs +16 -0
- package/dist/utils/panel.d.mts +1 -0
- package/dist/utils/panel.d.ts +1 -0
- package/dist/utils/panel.mjs +2 -0
- package/dist/utils/registry.d.mts +64 -0
- package/dist/utils/registry.d.ts +64 -0
- package/dist/utils/registry.js +206 -0
- package/dist/utils/registry.mjs +182 -0
- package/dist/utils/resize-by-delta.d.mts +1 -0
- package/dist/utils/resize-by-delta.d.ts +1 -0
- package/dist/utils/resize-by-delta.mjs +2 -0
- package/dist/utils/resize-panel.d.mts +1 -0
- package/dist/utils/resize-panel.d.ts +1 -0
- package/dist/utils/resize-panel.mjs +2 -0
- package/dist/utils/stacking-order.d.mts +9 -0
- package/dist/utils/stacking-order.d.ts +9 -0
- package/dist/utils/stacking-order.js +99 -0
- package/dist/utils/stacking-order.mjs +76 -0
- package/dist/utils/validate-sizes.d.mts +1 -0
- package/dist/utils/validate-sizes.d.ts +1 -0
- package/dist/utils/validate-sizes.mjs +2 -0
- package/package.json +6 -6
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import "../chunk-QZ7TP4HQ.mjs";
|
|
2
|
+
|
|
3
|
+
// src/utils/stacking-order.ts
|
|
4
|
+
import { getAncestorElements, getComputedStyle, getParentElement } from "@zag-js/dom-query";
|
|
5
|
+
import { ensure, hasProp } from "@zag-js/utils";
|
|
6
|
+
function compareStackingOrder(a, b) {
|
|
7
|
+
if (a === b) throw new Error("Cannot compare node with itself");
|
|
8
|
+
const ancestors = {
|
|
9
|
+
a: getAncestorElements(a),
|
|
10
|
+
b: getAncestorElements(b)
|
|
11
|
+
};
|
|
12
|
+
let commonAncestor = null;
|
|
13
|
+
while (ancestors.a.at(-1) === ancestors.b.at(-1)) {
|
|
14
|
+
const currentA = ancestors.a.pop();
|
|
15
|
+
ancestors.b.pop();
|
|
16
|
+
commonAncestor = currentA;
|
|
17
|
+
}
|
|
18
|
+
ensure(
|
|
19
|
+
commonAncestor,
|
|
20
|
+
() => "[stacking-order] Stacking order can only be calculated for elements with a common ancestor"
|
|
21
|
+
);
|
|
22
|
+
const zIndexes = {
|
|
23
|
+
a: getZIndex(findStackingContext(ancestors.a)),
|
|
24
|
+
b: getZIndex(findStackingContext(ancestors.b))
|
|
25
|
+
};
|
|
26
|
+
if (zIndexes.a === zIndexes.b) {
|
|
27
|
+
const children = commonAncestor.childNodes;
|
|
28
|
+
const furthestAncestors = {
|
|
29
|
+
a: ancestors.a.at(-1),
|
|
30
|
+
b: ancestors.b.at(-1)
|
|
31
|
+
};
|
|
32
|
+
let i = children.length;
|
|
33
|
+
while (i--) {
|
|
34
|
+
const child = children[i];
|
|
35
|
+
if (child === furthestAncestors.a) return 1;
|
|
36
|
+
if (child === furthestAncestors.b) return -1;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return Math.sign(zIndexes.a - zIndexes.b);
|
|
40
|
+
}
|
|
41
|
+
var STACKING_PROPS_REGEX = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;
|
|
42
|
+
function isFlexItem(node) {
|
|
43
|
+
const parent = getParentElement(node);
|
|
44
|
+
const display = getComputedStyle(parent ?? node).display;
|
|
45
|
+
return display === "flex" || display === "inline-flex";
|
|
46
|
+
}
|
|
47
|
+
function createsStackingContext(node) {
|
|
48
|
+
const style = getComputedStyle(node);
|
|
49
|
+
if (style.position === "fixed") return true;
|
|
50
|
+
if (style.zIndex !== "auto" && (style.position !== "static" || isFlexItem(node))) return true;
|
|
51
|
+
if (+style.opacity < 1) return true;
|
|
52
|
+
if (hasProp(style, "transform") && style.transform !== "none") return true;
|
|
53
|
+
if (hasProp(style, "webkitTransform") && style.webkitTransform !== "none") return true;
|
|
54
|
+
if (hasProp(style, "mixBlendMode") && style.mixBlendMode !== "normal") return true;
|
|
55
|
+
if (hasProp(style, "filter") && style.filter !== "none") return true;
|
|
56
|
+
if (hasProp(style, "webkitFilter") && style.webkitFilter !== "none") return true;
|
|
57
|
+
if (hasProp(style, "isolation") && style.isolation === "isolate") return true;
|
|
58
|
+
if (STACKING_PROPS_REGEX.test(style.willChange)) return true;
|
|
59
|
+
if (style.webkitOverflowScrolling === "touch") return true;
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
function findStackingContext(nodes) {
|
|
63
|
+
let i = nodes.length;
|
|
64
|
+
while (i--) {
|
|
65
|
+
const node = nodes[i];
|
|
66
|
+
ensure(node, () => "[stacking-order] missing node in findStackingContext");
|
|
67
|
+
if (createsStackingContext(node)) return node;
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
var getZIndex = (node) => {
|
|
72
|
+
return node && Number(getComputedStyle(node).zIndex) || 0;
|
|
73
|
+
};
|
|
74
|
+
export {
|
|
75
|
+
compareStackingOrder
|
|
76
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/splitter",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.39.0",
|
|
4
4
|
"description": "Core logic for the splitter widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@zag-js/anatomy": "1.
|
|
31
|
-
"@zag-js/core": "1.
|
|
32
|
-
"@zag-js/
|
|
33
|
-
"@zag-js/
|
|
34
|
-
"@zag-js/utils": "1.
|
|
30
|
+
"@zag-js/anatomy": "1.39.0",
|
|
31
|
+
"@zag-js/core": "1.39.0",
|
|
32
|
+
"@zag-js/dom-query": "1.39.0",
|
|
33
|
+
"@zag-js/types": "1.39.0",
|
|
34
|
+
"@zag-js/utils": "1.39.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"clean-package": "2.2.0"
|