@zag-js/popper 1.34.0 → 1.35.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/get-anchor.d.mts +7 -0
- package/dist/get-anchor.d.ts +7 -0
- package/dist/get-anchor.js +66 -0
- package/dist/get-anchor.mjs +40 -0
- package/dist/get-placement.d.mts +8 -0
- package/dist/get-placement.d.ts +8 -0
- package/dist/get-placement.js +237 -0
- package/dist/get-placement.mjs +212 -0
- package/dist/get-styles.d.mts +41 -0
- package/dist/get-styles.d.ts +41 -0
- package/dist/get-styles.js +73 -0
- package/dist/get-styles.mjs +48 -0
- package/dist/index.d.mts +5 -187
- package/dist/index.d.ts +5 -187
- package/dist/index.js +34 -378
- package/dist/index.mjs +9 -376
- package/dist/middleware.d.mts +35 -0
- package/dist/middleware.d.ts +35 -0
- package/dist/middleware.js +108 -0
- package/dist/middleware.mjs +80 -0
- package/dist/placement.d.mts +12 -0
- package/dist/placement.d.ts +12 -0
- package/dist/placement.js +43 -0
- package/dist/placement.mjs +16 -0
- package/dist/types.d.mts +122 -0
- package/dist/types.d.ts +122 -0
- package/dist/types.js +18 -0
- package/dist/types.mjs +0 -0
- package/package.json +3 -3
|
@@ -0,0 +1,43 @@
|
|
|
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 __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/placement.ts
|
|
21
|
+
var placement_exports = {};
|
|
22
|
+
__export(placement_exports, {
|
|
23
|
+
getPlacementDetails: () => getPlacementDetails,
|
|
24
|
+
getPlacementSide: () => getPlacementSide,
|
|
25
|
+
isValidPlacement: () => isValidPlacement
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(placement_exports);
|
|
28
|
+
function isValidPlacement(v) {
|
|
29
|
+
return /^(?:top|bottom|left|right)(?:-(?:start|end))?$/.test(v);
|
|
30
|
+
}
|
|
31
|
+
function getPlacementDetails(placement) {
|
|
32
|
+
const [side, align] = placement.split("-");
|
|
33
|
+
return { side, align, hasAlign: align != null };
|
|
34
|
+
}
|
|
35
|
+
function getPlacementSide(placement) {
|
|
36
|
+
return placement.split("-")[0];
|
|
37
|
+
}
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
getPlacementDetails,
|
|
41
|
+
getPlacementSide,
|
|
42
|
+
isValidPlacement
|
|
43
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/placement.ts
|
|
2
|
+
function isValidPlacement(v) {
|
|
3
|
+
return /^(?:top|bottom|left|right)(?:-(?:start|end))?$/.test(v);
|
|
4
|
+
}
|
|
5
|
+
function getPlacementDetails(placement) {
|
|
6
|
+
const [side, align] = placement.split("-");
|
|
7
|
+
return { side, align, hasAlign: align != null };
|
|
8
|
+
}
|
|
9
|
+
function getPlacementSide(placement) {
|
|
10
|
+
return placement.split("-")[0];
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
getPlacementDetails,
|
|
14
|
+
getPlacementSide,
|
|
15
|
+
isValidPlacement
|
|
16
|
+
};
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { VirtualElement, Placement, Boundary, AutoUpdateOptions, ComputePositionReturn } from '@floating-ui/dom';
|
|
2
|
+
export { AutoUpdateOptions, Boundary, ComputePositionReturn, Placement } from '@floating-ui/dom';
|
|
3
|
+
|
|
4
|
+
type MaybeRectElement = HTMLElement | VirtualElement | null;
|
|
5
|
+
type MaybeElement = HTMLElement | null;
|
|
6
|
+
type MaybeFn<T> = T | (() => T);
|
|
7
|
+
type PlacementSide = "top" | "right" | "bottom" | "left";
|
|
8
|
+
type PlacementAlign = "start" | "center" | "end";
|
|
9
|
+
interface AnchorRect {
|
|
10
|
+
x?: number | undefined;
|
|
11
|
+
y?: number | undefined;
|
|
12
|
+
width?: number | undefined;
|
|
13
|
+
height?: number | undefined;
|
|
14
|
+
}
|
|
15
|
+
interface PositioningOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Whether the popover should be hidden when the reference element is detached
|
|
18
|
+
*/
|
|
19
|
+
hideWhenDetached?: boolean | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* The strategy to use for positioning
|
|
22
|
+
*/
|
|
23
|
+
strategy?: "absolute" | "fixed" | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* The initial placement of the floating element
|
|
26
|
+
*/
|
|
27
|
+
placement?: Placement | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* The offset of the floating element
|
|
30
|
+
*/
|
|
31
|
+
offset?: {
|
|
32
|
+
mainAxis?: number | undefined;
|
|
33
|
+
crossAxis?: number | undefined;
|
|
34
|
+
} | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* The main axis offset or gap between the reference and floating elements
|
|
37
|
+
*/
|
|
38
|
+
gutter?: number | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* The secondary axis offset or gap between the reference and floating elements
|
|
41
|
+
*/
|
|
42
|
+
shift?: number | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* The virtual padding around the viewport edges to check for overflow
|
|
45
|
+
*/
|
|
46
|
+
overflowPadding?: number | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* The minimum padding between the arrow and the floating element's corner.
|
|
49
|
+
* @default 4
|
|
50
|
+
*/
|
|
51
|
+
arrowPadding?: number | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Whether to flip the placement
|
|
54
|
+
*/
|
|
55
|
+
flip?: boolean | Placement[] | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Whether the popover should slide when it overflows.
|
|
58
|
+
*/
|
|
59
|
+
slide?: boolean | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Whether the floating element can overlap the reference element
|
|
62
|
+
* @default false
|
|
63
|
+
*/
|
|
64
|
+
overlap?: boolean | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Whether to make the floating element same width as the reference element
|
|
67
|
+
*/
|
|
68
|
+
sameWidth?: boolean | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Whether the popover should fit the viewport.
|
|
71
|
+
*/
|
|
72
|
+
fitViewport?: boolean | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* Whether to use the size middleware from Floating UI.
|
|
75
|
+
* It computes and sets CSS variables (`--reference-width`, `--reference-height`, `--available-width`, `--available-height`) used by `sameWidth` and `fitViewport`.
|
|
76
|
+
*
|
|
77
|
+
* Disabling it improves scroll performance with heavy content by avoiding layout thrashing on each update.
|
|
78
|
+
* Only applies when both `sameWidth` and `fitViewport` are false — the middleware is always used when either is enabled.
|
|
79
|
+
* @default true
|
|
80
|
+
*/
|
|
81
|
+
sizeMiddleware?: boolean | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* The overflow boundary of the reference element
|
|
84
|
+
* Accepts a function returning a Boundary, a Boundary directly,
|
|
85
|
+
* or the shorthand string 'clipping-ancestors' which maps to Floating UI's 'clippingAncestors'.
|
|
86
|
+
*/
|
|
87
|
+
boundary?: (() => Boundary) | Boundary | "clipping-ancestors" | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Options to activate auto-update listeners
|
|
90
|
+
*/
|
|
91
|
+
listeners?: boolean | AutoUpdateOptions | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* Function called when the placement is computed
|
|
94
|
+
*/
|
|
95
|
+
onComplete?: ((data: ComputePositionReturn) => void) | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* Function called when the floating element is positioned or not
|
|
98
|
+
*/
|
|
99
|
+
onPositioned?: ((data: {
|
|
100
|
+
placed: boolean;
|
|
101
|
+
}) => void) | undefined;
|
|
102
|
+
/**
|
|
103
|
+
* Function that returns the anchor element.
|
|
104
|
+
* Useful when you want to use a different element as the anchor.
|
|
105
|
+
*/
|
|
106
|
+
getAnchorElement?: (() => HTMLElement | VirtualElement | null) | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* Function that returns the anchor rect
|
|
109
|
+
* @deprecated Use `getAnchorElement` instead
|
|
110
|
+
*/
|
|
111
|
+
getAnchorRect?: ((element: HTMLElement | VirtualElement | null) => AnchorRect | null) | undefined;
|
|
112
|
+
/**
|
|
113
|
+
* A callback that will be called when the popover needs to calculate its
|
|
114
|
+
* position.
|
|
115
|
+
*/
|
|
116
|
+
updatePosition?: ((data: {
|
|
117
|
+
updatePosition: () => Promise<void>;
|
|
118
|
+
floatingElement: HTMLElement | null;
|
|
119
|
+
}) => void | Promise<void>) | undefined;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export type { AnchorRect, MaybeElement, MaybeFn, MaybeRectElement, PlacementAlign, PlacementSide, PositioningOptions };
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { VirtualElement, Placement, Boundary, AutoUpdateOptions, ComputePositionReturn } from '@floating-ui/dom';
|
|
2
|
+
export { AutoUpdateOptions, Boundary, ComputePositionReturn, Placement } from '@floating-ui/dom';
|
|
3
|
+
|
|
4
|
+
type MaybeRectElement = HTMLElement | VirtualElement | null;
|
|
5
|
+
type MaybeElement = HTMLElement | null;
|
|
6
|
+
type MaybeFn<T> = T | (() => T);
|
|
7
|
+
type PlacementSide = "top" | "right" | "bottom" | "left";
|
|
8
|
+
type PlacementAlign = "start" | "center" | "end";
|
|
9
|
+
interface AnchorRect {
|
|
10
|
+
x?: number | undefined;
|
|
11
|
+
y?: number | undefined;
|
|
12
|
+
width?: number | undefined;
|
|
13
|
+
height?: number | undefined;
|
|
14
|
+
}
|
|
15
|
+
interface PositioningOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Whether the popover should be hidden when the reference element is detached
|
|
18
|
+
*/
|
|
19
|
+
hideWhenDetached?: boolean | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* The strategy to use for positioning
|
|
22
|
+
*/
|
|
23
|
+
strategy?: "absolute" | "fixed" | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* The initial placement of the floating element
|
|
26
|
+
*/
|
|
27
|
+
placement?: Placement | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* The offset of the floating element
|
|
30
|
+
*/
|
|
31
|
+
offset?: {
|
|
32
|
+
mainAxis?: number | undefined;
|
|
33
|
+
crossAxis?: number | undefined;
|
|
34
|
+
} | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* The main axis offset or gap between the reference and floating elements
|
|
37
|
+
*/
|
|
38
|
+
gutter?: number | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* The secondary axis offset or gap between the reference and floating elements
|
|
41
|
+
*/
|
|
42
|
+
shift?: number | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* The virtual padding around the viewport edges to check for overflow
|
|
45
|
+
*/
|
|
46
|
+
overflowPadding?: number | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* The minimum padding between the arrow and the floating element's corner.
|
|
49
|
+
* @default 4
|
|
50
|
+
*/
|
|
51
|
+
arrowPadding?: number | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Whether to flip the placement
|
|
54
|
+
*/
|
|
55
|
+
flip?: boolean | Placement[] | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Whether the popover should slide when it overflows.
|
|
58
|
+
*/
|
|
59
|
+
slide?: boolean | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Whether the floating element can overlap the reference element
|
|
62
|
+
* @default false
|
|
63
|
+
*/
|
|
64
|
+
overlap?: boolean | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Whether to make the floating element same width as the reference element
|
|
67
|
+
*/
|
|
68
|
+
sameWidth?: boolean | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Whether the popover should fit the viewport.
|
|
71
|
+
*/
|
|
72
|
+
fitViewport?: boolean | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* Whether to use the size middleware from Floating UI.
|
|
75
|
+
* It computes and sets CSS variables (`--reference-width`, `--reference-height`, `--available-width`, `--available-height`) used by `sameWidth` and `fitViewport`.
|
|
76
|
+
*
|
|
77
|
+
* Disabling it improves scroll performance with heavy content by avoiding layout thrashing on each update.
|
|
78
|
+
* Only applies when both `sameWidth` and `fitViewport` are false — the middleware is always used when either is enabled.
|
|
79
|
+
* @default true
|
|
80
|
+
*/
|
|
81
|
+
sizeMiddleware?: boolean | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* The overflow boundary of the reference element
|
|
84
|
+
* Accepts a function returning a Boundary, a Boundary directly,
|
|
85
|
+
* or the shorthand string 'clipping-ancestors' which maps to Floating UI's 'clippingAncestors'.
|
|
86
|
+
*/
|
|
87
|
+
boundary?: (() => Boundary) | Boundary | "clipping-ancestors" | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Options to activate auto-update listeners
|
|
90
|
+
*/
|
|
91
|
+
listeners?: boolean | AutoUpdateOptions | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* Function called when the placement is computed
|
|
94
|
+
*/
|
|
95
|
+
onComplete?: ((data: ComputePositionReturn) => void) | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* Function called when the floating element is positioned or not
|
|
98
|
+
*/
|
|
99
|
+
onPositioned?: ((data: {
|
|
100
|
+
placed: boolean;
|
|
101
|
+
}) => void) | undefined;
|
|
102
|
+
/**
|
|
103
|
+
* Function that returns the anchor element.
|
|
104
|
+
* Useful when you want to use a different element as the anchor.
|
|
105
|
+
*/
|
|
106
|
+
getAnchorElement?: (() => HTMLElement | VirtualElement | null) | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* Function that returns the anchor rect
|
|
109
|
+
* @deprecated Use `getAnchorElement` instead
|
|
110
|
+
*/
|
|
111
|
+
getAnchorRect?: ((element: HTMLElement | VirtualElement | null) => AnchorRect | null) | undefined;
|
|
112
|
+
/**
|
|
113
|
+
* A callback that will be called when the popover needs to calculate its
|
|
114
|
+
* position.
|
|
115
|
+
*/
|
|
116
|
+
updatePosition?: ((data: {
|
|
117
|
+
updatePosition: () => Promise<void>;
|
|
118
|
+
floatingElement: HTMLElement | null;
|
|
119
|
+
}) => void | Promise<void>) | undefined;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export type { AnchorRect, MaybeElement, MaybeFn, MaybeRectElement, PlacementAlign, PlacementSide, PositioningOptions };
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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
ADDED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/popper",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.35.0",
|
|
4
4
|
"description": "Dynamic positioning logic for ui machines",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@floating-ui/dom": "^1.7.5",
|
|
26
|
-
"@zag-js/dom-query": "1.
|
|
27
|
-
"@zag-js/utils": "1.
|
|
26
|
+
"@zag-js/dom-query": "1.35.0",
|
|
27
|
+
"@zag-js/utils": "1.35.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"clean-package": "2.2.0"
|