@zag-js/popper 0.1.13 → 0.2.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/dist/index.d.ts +6 -6
- package/dist/index.js +9 -7
- package/dist/index.mjs +9 -7
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Placement, Boundary, ComputePositionReturn, ComputePositionConfig, VirtualElement } from '@floating-ui/dom';
|
|
2
2
|
export { Placement } from '@floating-ui/dom';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
type AutoUpdateOptions = {
|
|
5
5
|
ancestorScroll?: boolean;
|
|
6
6
|
ancestorResize?: boolean;
|
|
7
7
|
referenceResize?: boolean;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
type PositioningOptions = {
|
|
11
11
|
/**
|
|
12
12
|
* The strategy to use for positioning
|
|
13
13
|
*/
|
|
@@ -51,7 +51,7 @@ declare type PositioningOptions = {
|
|
|
51
51
|
/**
|
|
52
52
|
* The overflow boundary of the reference element
|
|
53
53
|
*/
|
|
54
|
-
boundary?: Boundary;
|
|
54
|
+
boundary?: Boundary | (() => Boundary);
|
|
55
55
|
/**
|
|
56
56
|
* Options to activate auto-update listeners
|
|
57
57
|
*/
|
|
@@ -67,12 +67,12 @@ declare type PositioningOptions = {
|
|
|
67
67
|
*/
|
|
68
68
|
onCleanup?: VoidFunction;
|
|
69
69
|
};
|
|
70
|
-
|
|
70
|
+
type BasePlacement = "top" | "right" | "bottom" | "left";
|
|
71
71
|
|
|
72
72
|
declare function getPlacement(reference: HTMLElement | VirtualElement | null, floating: HTMLElement | null, opts?: PositioningOptions): (() => void) | undefined;
|
|
73
73
|
declare function getBasePlacement(placement: Placement): BasePlacement;
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
type Options = {
|
|
76
76
|
measured: boolean;
|
|
77
77
|
strategy?: "absolute" | "fixed";
|
|
78
78
|
placement?: Placement;
|
|
@@ -85,7 +85,7 @@ declare function getPlacementStyles(options: Options): {
|
|
|
85
85
|
readonly height: string;
|
|
86
86
|
readonly opacity: 0 | undefined;
|
|
87
87
|
};
|
|
88
|
-
|
|
88
|
+
arrowTip: {
|
|
89
89
|
readonly transform: any;
|
|
90
90
|
readonly background: string;
|
|
91
91
|
readonly top: "0";
|
package/dist/index.js
CHANGED
|
@@ -43,7 +43,7 @@ var import_dom = require("@floating-ui/dom");
|
|
|
43
43
|
// ../dom/dist/index.mjs
|
|
44
44
|
var runIfFn = (v, ...a) => {
|
|
45
45
|
const res = typeof v === "function" ? v(...a) : v;
|
|
46
|
-
return res
|
|
46
|
+
return res != null ? res : void 0;
|
|
47
47
|
};
|
|
48
48
|
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
49
49
|
function isHTMLElement(v) {
|
|
@@ -112,11 +112,12 @@ function isEqual(rect1, rect2) {
|
|
|
112
112
|
|
|
113
113
|
// src/auto-update.ts
|
|
114
114
|
function resolveOptions(option) {
|
|
115
|
+
var _a, _b, _c;
|
|
115
116
|
const bool = isBoolean(option);
|
|
116
117
|
return {
|
|
117
|
-
ancestorResize: bool ? option : option.ancestorResize
|
|
118
|
-
ancestorScroll: bool ? option : option.ancestorScroll
|
|
119
|
-
referenceResize: bool ? option : option.referenceResize
|
|
118
|
+
ancestorResize: bool ? option : (_a = option.ancestorResize) != null ? _a : true,
|
|
119
|
+
ancestorScroll: bool ? option : (_b = option.ancestorScroll) != null ? _b : true,
|
|
120
|
+
referenceResize: bool ? option : (_c = option.referenceResize) != null ? _c : true
|
|
120
121
|
};
|
|
121
122
|
}
|
|
122
123
|
function autoUpdate(reference, floating, update, options = false) {
|
|
@@ -208,10 +209,11 @@ function getPlacement(reference, floating, opts = {}) {
|
|
|
208
209
|
const options = Object.assign({}, defaultOptions, opts);
|
|
209
210
|
const arrowEl = floating.querySelector("[data-part=arrow]");
|
|
210
211
|
const middleware = [];
|
|
212
|
+
const boundary = typeof options.boundary === "function" ? options.boundary() : options.boundary;
|
|
211
213
|
if (options.flip) {
|
|
212
214
|
middleware.push(
|
|
213
215
|
(0, import_dom2.flip)({
|
|
214
|
-
boundary
|
|
216
|
+
boundary,
|
|
215
217
|
padding: options.overflowPadding
|
|
216
218
|
})
|
|
217
219
|
);
|
|
@@ -225,7 +227,7 @@ function getPlacement(reference, floating, opts = {}) {
|
|
|
225
227
|
}
|
|
226
228
|
middleware.push(
|
|
227
229
|
(0, import_dom2.shift)({
|
|
228
|
-
boundary
|
|
230
|
+
boundary,
|
|
229
231
|
crossAxis: options.overlap,
|
|
230
232
|
padding: options.overflowPadding
|
|
231
233
|
})
|
|
@@ -318,7 +320,7 @@ function getPlacementStyles(options) {
|
|
|
318
320
|
[cssVars.arrowOffset.variable]: `calc(${cssVars.arrowSizeHalf.reference} * -1)`,
|
|
319
321
|
opacity: !measured ? 0 : void 0
|
|
320
322
|
},
|
|
321
|
-
|
|
323
|
+
arrowTip: {
|
|
322
324
|
transform: ARROW_FLOATING_STYLE[placement.split("-")[0]],
|
|
323
325
|
background: cssVars.arrowBg.reference,
|
|
324
326
|
top: "0",
|
package/dist/index.mjs
CHANGED
|
@@ -15,7 +15,7 @@ import { getOverflowAncestors } from "@floating-ui/dom";
|
|
|
15
15
|
// ../dom/dist/index.mjs
|
|
16
16
|
var runIfFn = (v, ...a) => {
|
|
17
17
|
const res = typeof v === "function" ? v(...a) : v;
|
|
18
|
-
return res
|
|
18
|
+
return res != null ? res : void 0;
|
|
19
19
|
};
|
|
20
20
|
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
21
21
|
function isHTMLElement(v) {
|
|
@@ -84,11 +84,12 @@ function isEqual(rect1, rect2) {
|
|
|
84
84
|
|
|
85
85
|
// src/auto-update.ts
|
|
86
86
|
function resolveOptions(option) {
|
|
87
|
+
var _a, _b, _c;
|
|
87
88
|
const bool = isBoolean(option);
|
|
88
89
|
return {
|
|
89
|
-
ancestorResize: bool ? option : option.ancestorResize
|
|
90
|
-
ancestorScroll: bool ? option : option.ancestorScroll
|
|
91
|
-
referenceResize: bool ? option : option.referenceResize
|
|
90
|
+
ancestorResize: bool ? option : (_a = option.ancestorResize) != null ? _a : true,
|
|
91
|
+
ancestorScroll: bool ? option : (_b = option.ancestorScroll) != null ? _b : true,
|
|
92
|
+
referenceResize: bool ? option : (_c = option.referenceResize) != null ? _c : true
|
|
92
93
|
};
|
|
93
94
|
}
|
|
94
95
|
function autoUpdate(reference, floating, update, options = false) {
|
|
@@ -180,10 +181,11 @@ function getPlacement(reference, floating, opts = {}) {
|
|
|
180
181
|
const options = Object.assign({}, defaultOptions, opts);
|
|
181
182
|
const arrowEl = floating.querySelector("[data-part=arrow]");
|
|
182
183
|
const middleware = [];
|
|
184
|
+
const boundary = typeof options.boundary === "function" ? options.boundary() : options.boundary;
|
|
183
185
|
if (options.flip) {
|
|
184
186
|
middleware.push(
|
|
185
187
|
flip({
|
|
186
|
-
boundary
|
|
188
|
+
boundary,
|
|
187
189
|
padding: options.overflowPadding
|
|
188
190
|
})
|
|
189
191
|
);
|
|
@@ -197,7 +199,7 @@ function getPlacement(reference, floating, opts = {}) {
|
|
|
197
199
|
}
|
|
198
200
|
middleware.push(
|
|
199
201
|
shift({
|
|
200
|
-
boundary
|
|
202
|
+
boundary,
|
|
201
203
|
crossAxis: options.overlap,
|
|
202
204
|
padding: options.overflowPadding
|
|
203
205
|
})
|
|
@@ -290,7 +292,7 @@ function getPlacementStyles(options) {
|
|
|
290
292
|
[cssVars.arrowOffset.variable]: `calc(${cssVars.arrowSizeHalf.reference} * -1)`,
|
|
291
293
|
opacity: !measured ? 0 : void 0
|
|
292
294
|
},
|
|
293
|
-
|
|
295
|
+
arrowTip: {
|
|
294
296
|
transform: ARROW_FLOATING_STYLE[placement.split("-")[0]],
|
|
295
297
|
background: cssVars.arrowBg.reference,
|
|
296
298
|
top: "0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/popper",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Dynamic positioning logic for ui machines",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@floating-ui/dom": "1.0.
|
|
28
|
+
"@floating-ui/dom": "1.0.10"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@zag-js/dom-utils": "0.1
|
|
32
|
-
"@zag-js/utils": "0.1
|
|
31
|
+
"@zag-js/dom-utils": "0.2.1",
|
|
32
|
+
"@zag-js/utils": "0.3.1"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build-fast": "tsup src/index.ts --format=esm,cjs",
|