@zag-js/popper 0.10.5 → 0.11.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/index.d.mts +106 -0
- package/dist/index.d.ts +106 -3
- package/dist/index.js +277 -7
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +253 -2
- package/dist/index.mjs.map +1 -0
- package/package.json +6 -6
- package/dist/auto-update.d.ts +0 -8
- package/dist/auto-update.js +0 -45
- package/dist/auto-update.mjs +0 -41
- package/dist/get-placement.d.ts +0 -10
- package/dist/get-placement.js +0 -126
- package/dist/get-placement.mjs +0 -121
- package/dist/get-styles.d.ts +0 -29
- package/dist/get-styles.js +0 -42
- package/dist/get-styles.mjs +0 -38
- package/dist/middleware.d.ts +0 -29
- package/dist/middleware.js +0 -58
- package/dist/middleware.mjs +0 -52
- package/dist/types.d.ts +0 -62
package/dist/get-styles.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { Placement } from "@floating-ui/dom";
|
|
2
|
-
type Options = {
|
|
3
|
-
placement?: Placement;
|
|
4
|
-
};
|
|
5
|
-
export declare function getPlacementStyles(options: Options): {
|
|
6
|
-
arrow: {
|
|
7
|
-
readonly [x: string]: string;
|
|
8
|
-
readonly position: "absolute";
|
|
9
|
-
readonly width: string;
|
|
10
|
-
readonly height: string;
|
|
11
|
-
};
|
|
12
|
-
arrowTip: {
|
|
13
|
-
readonly transform: any;
|
|
14
|
-
readonly background: string;
|
|
15
|
-
readonly top: "0";
|
|
16
|
-
readonly left: "0";
|
|
17
|
-
readonly width: "100%";
|
|
18
|
-
readonly height: "100%";
|
|
19
|
-
readonly position: "absolute";
|
|
20
|
-
readonly zIndex: "inherit";
|
|
21
|
-
};
|
|
22
|
-
floating: {
|
|
23
|
-
readonly position: "absolute";
|
|
24
|
-
readonly minWidth: "max-content";
|
|
25
|
-
readonly top: "0px";
|
|
26
|
-
readonly left: "0px";
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
export {};
|
package/dist/get-styles.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
|
-
const middleware = require('./middleware.js');
|
|
6
|
-
|
|
7
|
-
const ARROW_FLOATING_STYLE = {
|
|
8
|
-
bottom: "rotate(45deg)",
|
|
9
|
-
left: "rotate(135deg)",
|
|
10
|
-
top: "rotate(225deg)",
|
|
11
|
-
right: "rotate(315deg)"
|
|
12
|
-
};
|
|
13
|
-
function getPlacementStyles(options) {
|
|
14
|
-
const { placement = "bottom" } = options;
|
|
15
|
-
return {
|
|
16
|
-
arrow: {
|
|
17
|
-
position: "absolute",
|
|
18
|
-
width: middleware.cssVars.arrowSize.reference,
|
|
19
|
-
height: middleware.cssVars.arrowSize.reference,
|
|
20
|
-
[middleware.cssVars.arrowSizeHalf.variable]: `calc(${middleware.cssVars.arrowSize.reference} / 2)`,
|
|
21
|
-
[middleware.cssVars.arrowOffset.variable]: `calc(${middleware.cssVars.arrowSizeHalf.reference} * -1)`
|
|
22
|
-
},
|
|
23
|
-
arrowTip: {
|
|
24
|
-
transform: ARROW_FLOATING_STYLE[placement.split("-")[0]],
|
|
25
|
-
background: middleware.cssVars.arrowBg.reference,
|
|
26
|
-
top: "0",
|
|
27
|
-
left: "0",
|
|
28
|
-
width: "100%",
|
|
29
|
-
height: "100%",
|
|
30
|
-
position: "absolute",
|
|
31
|
-
zIndex: "inherit"
|
|
32
|
-
},
|
|
33
|
-
floating: {
|
|
34
|
-
position: "absolute",
|
|
35
|
-
minWidth: "max-content",
|
|
36
|
-
top: "0px",
|
|
37
|
-
left: "0px"
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
exports.getPlacementStyles = getPlacementStyles;
|
package/dist/get-styles.mjs
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { cssVars } from './middleware.mjs';
|
|
2
|
-
|
|
3
|
-
const ARROW_FLOATING_STYLE = {
|
|
4
|
-
bottom: "rotate(45deg)",
|
|
5
|
-
left: "rotate(135deg)",
|
|
6
|
-
top: "rotate(225deg)",
|
|
7
|
-
right: "rotate(315deg)"
|
|
8
|
-
};
|
|
9
|
-
function getPlacementStyles(options) {
|
|
10
|
-
const { placement = "bottom" } = options;
|
|
11
|
-
return {
|
|
12
|
-
arrow: {
|
|
13
|
-
position: "absolute",
|
|
14
|
-
width: cssVars.arrowSize.reference,
|
|
15
|
-
height: cssVars.arrowSize.reference,
|
|
16
|
-
[cssVars.arrowSizeHalf.variable]: `calc(${cssVars.arrowSize.reference} / 2)`,
|
|
17
|
-
[cssVars.arrowOffset.variable]: `calc(${cssVars.arrowSizeHalf.reference} * -1)`
|
|
18
|
-
},
|
|
19
|
-
arrowTip: {
|
|
20
|
-
transform: ARROW_FLOATING_STYLE[placement.split("-")[0]],
|
|
21
|
-
background: cssVars.arrowBg.reference,
|
|
22
|
-
top: "0",
|
|
23
|
-
left: "0",
|
|
24
|
-
width: "100%",
|
|
25
|
-
height: "100%",
|
|
26
|
-
position: "absolute",
|
|
27
|
-
zIndex: "inherit"
|
|
28
|
-
},
|
|
29
|
-
floating: {
|
|
30
|
-
position: "absolute",
|
|
31
|
-
minWidth: "max-content",
|
|
32
|
-
top: "0px",
|
|
33
|
-
left: "0px"
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export { getPlacementStyles };
|
package/dist/middleware.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { Middleware } from "@floating-ui/dom";
|
|
2
|
-
export declare const cssVars: {
|
|
3
|
-
arrowSize: {
|
|
4
|
-
variable: string;
|
|
5
|
-
reference: string;
|
|
6
|
-
};
|
|
7
|
-
arrowSizeHalf: {
|
|
8
|
-
variable: string;
|
|
9
|
-
reference: string;
|
|
10
|
-
};
|
|
11
|
-
arrowBg: {
|
|
12
|
-
variable: string;
|
|
13
|
-
reference: string;
|
|
14
|
-
};
|
|
15
|
-
transformOrigin: {
|
|
16
|
-
variable: string;
|
|
17
|
-
reference: string;
|
|
18
|
-
};
|
|
19
|
-
arrowOffset: {
|
|
20
|
-
variable: string;
|
|
21
|
-
reference: string;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
export declare const transformOrigin: Middleware;
|
|
25
|
-
type ArrowOptions = {
|
|
26
|
-
element: HTMLElement;
|
|
27
|
-
};
|
|
28
|
-
export declare const shiftArrow: (opts: ArrowOptions) => Middleware;
|
|
29
|
-
export {};
|
package/dist/middleware.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
|
-
const toVar = (value) => ({ variable: value, reference: `var(${value})` });
|
|
6
|
-
const cssVars = {
|
|
7
|
-
arrowSize: toVar("--arrow-size"),
|
|
8
|
-
arrowSizeHalf: toVar("--arrow-size-half"),
|
|
9
|
-
arrowBg: toVar("--arrow-background"),
|
|
10
|
-
transformOrigin: toVar("--transform-origin"),
|
|
11
|
-
arrowOffset: toVar("--arrow-offset")
|
|
12
|
-
};
|
|
13
|
-
const getTransformOrigin = (arrow) => ({
|
|
14
|
-
top: "bottom center",
|
|
15
|
-
"top-start": arrow ? `${arrow.x}px bottom` : "left bottom",
|
|
16
|
-
"top-end": arrow ? `${arrow.x}px bottom` : "right bottom",
|
|
17
|
-
bottom: "top center",
|
|
18
|
-
"bottom-start": arrow ? `${arrow.x}px top` : "top left",
|
|
19
|
-
"bottom-end": arrow ? `${arrow.x}px top` : "top right",
|
|
20
|
-
left: "right center",
|
|
21
|
-
"left-start": arrow ? `right ${arrow.y}px` : "right top",
|
|
22
|
-
"left-end": arrow ? `right ${arrow.y}px` : "right bottom",
|
|
23
|
-
right: "left center",
|
|
24
|
-
"right-start": arrow ? `left ${arrow.y}px` : "left top",
|
|
25
|
-
"right-end": arrow ? `left ${arrow.y}px` : "left bottom"
|
|
26
|
-
});
|
|
27
|
-
const transformOrigin = {
|
|
28
|
-
name: "transformOrigin",
|
|
29
|
-
fn({ placement, elements, middlewareData }) {
|
|
30
|
-
const { arrow } = middlewareData;
|
|
31
|
-
const transformOrigin2 = getTransformOrigin(arrow)[placement];
|
|
32
|
-
const { floating } = elements;
|
|
33
|
-
floating.style.setProperty(cssVars.transformOrigin.variable, transformOrigin2);
|
|
34
|
-
return {
|
|
35
|
-
data: { transformOrigin: transformOrigin2 }
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
const shiftArrow = (opts) => ({
|
|
40
|
-
name: "shiftArrow",
|
|
41
|
-
fn({ placement, middlewareData }) {
|
|
42
|
-
const { element: arrow } = opts;
|
|
43
|
-
if (middlewareData.arrow) {
|
|
44
|
-
const { x, y } = middlewareData.arrow;
|
|
45
|
-
const dir = placement.split("-")[0];
|
|
46
|
-
Object.assign(arrow.style, {
|
|
47
|
-
left: x != null ? `${x}px` : "",
|
|
48
|
-
top: y != null ? `${y}px` : "",
|
|
49
|
-
[dir]: `calc(100% + ${cssVars.arrowOffset.reference})`
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
return {};
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
exports.cssVars = cssVars;
|
|
57
|
-
exports.shiftArrow = shiftArrow;
|
|
58
|
-
exports.transformOrigin = transformOrigin;
|
package/dist/middleware.mjs
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
const toVar = (value) => ({ variable: value, reference: `var(${value})` });
|
|
2
|
-
const cssVars = {
|
|
3
|
-
arrowSize: toVar("--arrow-size"),
|
|
4
|
-
arrowSizeHalf: toVar("--arrow-size-half"),
|
|
5
|
-
arrowBg: toVar("--arrow-background"),
|
|
6
|
-
transformOrigin: toVar("--transform-origin"),
|
|
7
|
-
arrowOffset: toVar("--arrow-offset")
|
|
8
|
-
};
|
|
9
|
-
const getTransformOrigin = (arrow) => ({
|
|
10
|
-
top: "bottom center",
|
|
11
|
-
"top-start": arrow ? `${arrow.x}px bottom` : "left bottom",
|
|
12
|
-
"top-end": arrow ? `${arrow.x}px bottom` : "right bottom",
|
|
13
|
-
bottom: "top center",
|
|
14
|
-
"bottom-start": arrow ? `${arrow.x}px top` : "top left",
|
|
15
|
-
"bottom-end": arrow ? `${arrow.x}px top` : "top right",
|
|
16
|
-
left: "right center",
|
|
17
|
-
"left-start": arrow ? `right ${arrow.y}px` : "right top",
|
|
18
|
-
"left-end": arrow ? `right ${arrow.y}px` : "right bottom",
|
|
19
|
-
right: "left center",
|
|
20
|
-
"right-start": arrow ? `left ${arrow.y}px` : "left top",
|
|
21
|
-
"right-end": arrow ? `left ${arrow.y}px` : "left bottom"
|
|
22
|
-
});
|
|
23
|
-
const transformOrigin = {
|
|
24
|
-
name: "transformOrigin",
|
|
25
|
-
fn({ placement, elements, middlewareData }) {
|
|
26
|
-
const { arrow } = middlewareData;
|
|
27
|
-
const transformOrigin2 = getTransformOrigin(arrow)[placement];
|
|
28
|
-
const { floating } = elements;
|
|
29
|
-
floating.style.setProperty(cssVars.transformOrigin.variable, transformOrigin2);
|
|
30
|
-
return {
|
|
31
|
-
data: { transformOrigin: transformOrigin2 }
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const shiftArrow = (opts) => ({
|
|
36
|
-
name: "shiftArrow",
|
|
37
|
-
fn({ placement, middlewareData }) {
|
|
38
|
-
const { element: arrow } = opts;
|
|
39
|
-
if (middlewareData.arrow) {
|
|
40
|
-
const { x, y } = middlewareData.arrow;
|
|
41
|
-
const dir = placement.split("-")[0];
|
|
42
|
-
Object.assign(arrow.style, {
|
|
43
|
-
left: x != null ? `${x}px` : "",
|
|
44
|
-
top: y != null ? `${y}px` : "",
|
|
45
|
-
[dir]: `calc(100% + ${cssVars.arrowOffset.reference})`
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
return {};
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
export { cssVars, shiftArrow, transformOrigin };
|
package/dist/types.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import type { Boundary, ComputePositionReturn, Placement } from "@floating-ui/dom";
|
|
2
|
-
import type { AutoUpdateOptions } from "./auto-update";
|
|
3
|
-
export type { Placement };
|
|
4
|
-
export type PositioningOptions = {
|
|
5
|
-
/**
|
|
6
|
-
* The strategy to use for positioning
|
|
7
|
-
*/
|
|
8
|
-
strategy?: "absolute" | "fixed";
|
|
9
|
-
/**
|
|
10
|
-
* The initial placement of the floating element
|
|
11
|
-
*/
|
|
12
|
-
placement?: Placement;
|
|
13
|
-
/**
|
|
14
|
-
* The offset of the floating element
|
|
15
|
-
*/
|
|
16
|
-
offset?: {
|
|
17
|
-
mainAxis?: number;
|
|
18
|
-
crossAxis?: number;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* The main axis offset or gap between the reference and floating elements
|
|
22
|
-
*/
|
|
23
|
-
gutter?: number;
|
|
24
|
-
/**
|
|
25
|
-
* The virtual padding around the viewport edges to check for overflow
|
|
26
|
-
*/
|
|
27
|
-
overflowPadding?: number;
|
|
28
|
-
/**
|
|
29
|
-
* Whether to flip the placement
|
|
30
|
-
*/
|
|
31
|
-
flip?: boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Whether the floating element can overlap the reference element
|
|
34
|
-
* @default false
|
|
35
|
-
*/
|
|
36
|
-
overlap?: boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Whether to make the floating element same width as the reference element
|
|
39
|
-
*/
|
|
40
|
-
sameWidth?: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Whether the popover should fit the viewport.
|
|
43
|
-
*/
|
|
44
|
-
fitViewport?: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* The overflow boundary of the reference element
|
|
47
|
-
*/
|
|
48
|
-
boundary?: Boundary | (() => Boundary);
|
|
49
|
-
/**
|
|
50
|
-
* Options to activate auto-update listeners
|
|
51
|
-
*/
|
|
52
|
-
listeners?: boolean | AutoUpdateOptions;
|
|
53
|
-
/**
|
|
54
|
-
* Function called when the placement is computed
|
|
55
|
-
*/
|
|
56
|
-
onComplete?(data: ComputePositionReturn): void;
|
|
57
|
-
/**
|
|
58
|
-
* Function called on cleanup of all listeners
|
|
59
|
-
*/
|
|
60
|
-
onCleanup?: VoidFunction;
|
|
61
|
-
};
|
|
62
|
-
export type BasePlacement = "top" | "right" | "bottom" | "left";
|