@zag-js/popper 0.10.2 → 0.10.4
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/auto-update.d.ts +4 -7
- package/dist/auto-update.js +14 -36
- package/dist/auto-update.mjs +40 -5
- package/dist/get-placement.d.ts +5 -8
- package/dist/get-placement.js +29 -144
- package/dist/get-placement.mjs +120 -9
- package/dist/get-styles.d.ts +3 -5
- package/dist/get-styles.js +11 -44
- package/dist/get-styles.mjs +37 -6
- package/dist/index.d.ts +3 -5
- package/dist/index.js +7 -276
- package/dist/index.mjs +2 -14
- package/dist/middleware.d.ts +5 -7
- package/dist/middleware.js +12 -37
- package/dist/middleware.mjs +51 -9
- package/dist/types.d.ts +5 -8
- package/package.json +6 -11
- package/src/get-placement.ts +1 -1
- package/dist/chunk-EC2KMZAZ.mjs +0 -130
- package/dist/chunk-MLNMIWN3.mjs +0 -43
- package/dist/chunk-V4C4UQPN.mjs +0 -43
- package/dist/chunk-X5LLREVI.mjs +0 -57
- package/dist/types.js +0 -18
- package/dist/types.mjs +0 -0
package/dist/chunk-MLNMIWN3.mjs
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// src/auto-update.ts
|
|
2
|
-
import { getOverflowAncestors } from "@floating-ui/dom";
|
|
3
|
-
import { trackElementRect } from "@zag-js/element-rect";
|
|
4
|
-
var callAll = (...fns) => () => fns.forEach((fn) => fn());
|
|
5
|
-
var isHTMLElement = (el) => {
|
|
6
|
-
return typeof el === "object" && el !== null && el.nodeType === 1;
|
|
7
|
-
};
|
|
8
|
-
var addDomEvent = (el, type, fn, options) => {
|
|
9
|
-
el.addEventListener(type, fn, options);
|
|
10
|
-
return () => el.removeEventListener(type, fn, options);
|
|
11
|
-
};
|
|
12
|
-
function resolveOptions(option) {
|
|
13
|
-
const bool = typeof option === "boolean";
|
|
14
|
-
return {
|
|
15
|
-
ancestorResize: bool ? option : option.ancestorResize ?? true,
|
|
16
|
-
ancestorScroll: bool ? option : option.ancestorScroll ?? true,
|
|
17
|
-
referenceResize: bool ? option : option.referenceResize ?? true
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
function autoUpdate(reference, floating, update, options = false) {
|
|
21
|
-
const { ancestorScroll, ancestorResize, referenceResize } = resolveOptions(options);
|
|
22
|
-
const useAncestors = ancestorScroll || ancestorResize;
|
|
23
|
-
const ancestors = [];
|
|
24
|
-
if (useAncestors && isHTMLElement(reference)) {
|
|
25
|
-
ancestors.push(...getOverflowAncestors(reference));
|
|
26
|
-
}
|
|
27
|
-
function addResizeListeners() {
|
|
28
|
-
let cleanups = [trackElementRect(floating, { scope: "size", onChange: update })];
|
|
29
|
-
if (referenceResize && isHTMLElement(reference)) {
|
|
30
|
-
cleanups.push(trackElementRect(reference, { onChange: update }));
|
|
31
|
-
}
|
|
32
|
-
cleanups.push(callAll(...ancestors.map((el) => addDomEvent(el, "resize", update))));
|
|
33
|
-
return () => cleanups.forEach((fn) => fn());
|
|
34
|
-
}
|
|
35
|
-
function addScrollListeners() {
|
|
36
|
-
return callAll(...ancestors.map((el) => addDomEvent(el, "scroll", update, { passive: true })));
|
|
37
|
-
}
|
|
38
|
-
return callAll(addResizeListeners(), addScrollListeners());
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export {
|
|
42
|
-
autoUpdate
|
|
43
|
-
};
|
package/dist/chunk-V4C4UQPN.mjs
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
cssVars
|
|
3
|
-
} from "./chunk-X5LLREVI.mjs";
|
|
4
|
-
|
|
5
|
-
// src/get-styles.ts
|
|
6
|
-
var ARROW_FLOATING_STYLE = {
|
|
7
|
-
bottom: "rotate(45deg)",
|
|
8
|
-
left: "rotate(135deg)",
|
|
9
|
-
top: "rotate(225deg)",
|
|
10
|
-
right: "rotate(315deg)"
|
|
11
|
-
};
|
|
12
|
-
function getPlacementStyles(options) {
|
|
13
|
-
const { placement = "bottom" } = options;
|
|
14
|
-
return {
|
|
15
|
-
arrow: {
|
|
16
|
-
position: "absolute",
|
|
17
|
-
width: cssVars.arrowSize.reference,
|
|
18
|
-
height: cssVars.arrowSize.reference,
|
|
19
|
-
[cssVars.arrowSizeHalf.variable]: `calc(${cssVars.arrowSize.reference} / 2)`,
|
|
20
|
-
[cssVars.arrowOffset.variable]: `calc(${cssVars.arrowSizeHalf.reference} * -1)`
|
|
21
|
-
},
|
|
22
|
-
arrowTip: {
|
|
23
|
-
transform: ARROW_FLOATING_STYLE[placement.split("-")[0]],
|
|
24
|
-
background: cssVars.arrowBg.reference,
|
|
25
|
-
top: "0",
|
|
26
|
-
left: "0",
|
|
27
|
-
width: "100%",
|
|
28
|
-
height: "100%",
|
|
29
|
-
position: "absolute",
|
|
30
|
-
zIndex: "inherit"
|
|
31
|
-
},
|
|
32
|
-
floating: {
|
|
33
|
-
position: "absolute",
|
|
34
|
-
minWidth: "max-content",
|
|
35
|
-
top: "0px",
|
|
36
|
-
left: "0px"
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export {
|
|
42
|
-
getPlacementStyles
|
|
43
|
-
};
|
package/dist/chunk-X5LLREVI.mjs
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// src/middleware.ts
|
|
2
|
-
var toVar = (value) => ({ variable: value, reference: `var(${value})` });
|
|
3
|
-
var cssVars = {
|
|
4
|
-
arrowSize: toVar("--arrow-size"),
|
|
5
|
-
arrowSizeHalf: toVar("--arrow-size-half"),
|
|
6
|
-
arrowBg: toVar("--arrow-background"),
|
|
7
|
-
transformOrigin: toVar("--transform-origin"),
|
|
8
|
-
arrowOffset: toVar("--arrow-offset")
|
|
9
|
-
};
|
|
10
|
-
var getTransformOrigin = (arrow) => ({
|
|
11
|
-
top: "bottom center",
|
|
12
|
-
"top-start": arrow ? `${arrow.x}px bottom` : "left bottom",
|
|
13
|
-
"top-end": arrow ? `${arrow.x}px bottom` : "right bottom",
|
|
14
|
-
bottom: "top center",
|
|
15
|
-
"bottom-start": arrow ? `${arrow.x}px top` : "top left",
|
|
16
|
-
"bottom-end": arrow ? `${arrow.x}px top` : "top right",
|
|
17
|
-
left: "right center",
|
|
18
|
-
"left-start": arrow ? `right ${arrow.y}px` : "right top",
|
|
19
|
-
"left-end": arrow ? `right ${arrow.y}px` : "right bottom",
|
|
20
|
-
right: "left center",
|
|
21
|
-
"right-start": arrow ? `left ${arrow.y}px` : "left top",
|
|
22
|
-
"right-end": arrow ? `left ${arrow.y}px` : "left bottom"
|
|
23
|
-
});
|
|
24
|
-
var transformOrigin = {
|
|
25
|
-
name: "transformOrigin",
|
|
26
|
-
fn({ placement, elements, middlewareData }) {
|
|
27
|
-
const { arrow } = middlewareData;
|
|
28
|
-
const transformOrigin2 = getTransformOrigin(arrow)[placement];
|
|
29
|
-
const { floating } = elements;
|
|
30
|
-
floating.style.setProperty(cssVars.transformOrigin.variable, transformOrigin2);
|
|
31
|
-
return {
|
|
32
|
-
data: { transformOrigin: transformOrigin2 }
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var shiftArrow = (opts) => ({
|
|
37
|
-
name: "shiftArrow",
|
|
38
|
-
fn({ placement, middlewareData }) {
|
|
39
|
-
const { element: arrow } = opts;
|
|
40
|
-
if (middlewareData.arrow) {
|
|
41
|
-
const { x, y } = middlewareData.arrow;
|
|
42
|
-
const dir = placement.split("-")[0];
|
|
43
|
-
Object.assign(arrow.style, {
|
|
44
|
-
left: x != null ? `${x}px` : "",
|
|
45
|
-
top: y != null ? `${y}px` : "",
|
|
46
|
-
[dir]: `calc(100% + ${cssVars.arrowOffset.reference})`
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
return {};
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
export {
|
|
54
|
-
cssVars,
|
|
55
|
-
transformOrigin,
|
|
56
|
-
shiftArrow
|
|
57
|
-
};
|
package/dist/types.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
|
|
16
|
-
// src/types.ts
|
|
17
|
-
var types_exports = {};
|
|
18
|
-
module.exports = __toCommonJS(types_exports);
|
package/dist/types.mjs
DELETED
|
File without changes
|