@zag-js/popper 0.2.7 → 0.8.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/auto-update.js +2 -2
- package/dist/auto-update.mjs +1 -1
- package/dist/{chunk-6B3BV5TE.mjs → chunk-EC2KMZAZ.mjs} +20 -4
- package/dist/{chunk-AVEWKGZP.mjs → chunk-MLNMIWN3.mjs} +2 -2
- package/dist/get-placement.d.ts +8 -3
- package/dist/get-placement.js +19 -3
- package/dist/get-placement.mjs +2 -2
- package/dist/index.js +19 -3
- package/dist/index.mjs +2 -2
- package/package.json +3 -3
package/dist/auto-update.js
CHANGED
|
@@ -49,9 +49,9 @@ function autoUpdate(reference, floating, update, options = false) {
|
|
|
49
49
|
ancestors.push(...(0, import_dom.getOverflowAncestors)(reference));
|
|
50
50
|
}
|
|
51
51
|
function addResizeListeners() {
|
|
52
|
-
let cleanups = [(0, import_element_rect.trackElementRect)(floating,
|
|
52
|
+
let cleanups = [(0, import_element_rect.trackElementRect)(floating, { scope: "size", onChange: update })];
|
|
53
53
|
if (referenceResize && isHTMLElement(reference)) {
|
|
54
|
-
cleanups.push((0, import_element_rect.trackElementRect)(reference, update));
|
|
54
|
+
cleanups.push((0, import_element_rect.trackElementRect)(reference, { onChange: update }));
|
|
55
55
|
}
|
|
56
56
|
cleanups.push(callAll(...ancestors.map((el) => addDomEvent(el, "resize", update))));
|
|
57
57
|
return () => cleanups.forEach((fn) => fn());
|
package/dist/auto-update.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
autoUpdate
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-MLNMIWN3.mjs";
|
|
4
4
|
import {
|
|
5
5
|
shiftArrow,
|
|
6
6
|
transformOrigin
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
|
|
9
9
|
// src/get-placement.ts
|
|
10
10
|
import { arrow, computePosition, flip, offset, shift, size } from "@floating-ui/dom";
|
|
11
|
+
import { raf } from "@zag-js/dom-query";
|
|
11
12
|
import { callAll } from "@zag-js/utils";
|
|
12
13
|
var defaultOptions = {
|
|
13
14
|
strategy: "absolute",
|
|
@@ -18,7 +19,7 @@ var defaultOptions = {
|
|
|
18
19
|
sameWidth: false,
|
|
19
20
|
overflowPadding: 8
|
|
20
21
|
};
|
|
21
|
-
function
|
|
22
|
+
function getPlacementImpl(reference, floating, opts = {}) {
|
|
22
23
|
if (!floating || !reference)
|
|
23
24
|
return;
|
|
24
25
|
const options = Object.assign({}, defaultOptions, opts);
|
|
@@ -107,8 +108,23 @@ function getPlacement(reference, floating, opts = {}) {
|
|
|
107
108
|
function getBasePlacement(placement) {
|
|
108
109
|
return placement.split("-")[0];
|
|
109
110
|
}
|
|
111
|
+
function getPlacement(referenceOrFn, floatingOrFn, opts = {}) {
|
|
112
|
+
const { defer, ...restOptions } = opts;
|
|
113
|
+
const func = defer ? raf : (v) => v();
|
|
114
|
+
const cleanups = [];
|
|
115
|
+
cleanups.push(
|
|
116
|
+
func(() => {
|
|
117
|
+
const reference = typeof referenceOrFn === "function" ? referenceOrFn() : referenceOrFn;
|
|
118
|
+
const floating = typeof floatingOrFn === "function" ? floatingOrFn() : floatingOrFn;
|
|
119
|
+
cleanups.push(getPlacementImpl(reference, floating, restOptions));
|
|
120
|
+
})
|
|
121
|
+
);
|
|
122
|
+
return () => {
|
|
123
|
+
cleanups.forEach((fn) => fn?.());
|
|
124
|
+
};
|
|
125
|
+
}
|
|
110
126
|
|
|
111
127
|
export {
|
|
112
|
-
|
|
113
|
-
|
|
128
|
+
getBasePlacement,
|
|
129
|
+
getPlacement
|
|
114
130
|
};
|
|
@@ -25,9 +25,9 @@ function autoUpdate(reference, floating, update, options = false) {
|
|
|
25
25
|
ancestors.push(...getOverflowAncestors(reference));
|
|
26
26
|
}
|
|
27
27
|
function addResizeListeners() {
|
|
28
|
-
let cleanups = [trackElementRect(floating,
|
|
28
|
+
let cleanups = [trackElementRect(floating, { scope: "size", onChange: update })];
|
|
29
29
|
if (referenceResize && isHTMLElement(reference)) {
|
|
30
|
-
cleanups.push(trackElementRect(reference, update));
|
|
30
|
+
cleanups.push(trackElementRect(reference, { onChange: update }));
|
|
31
31
|
}
|
|
32
32
|
cleanups.push(callAll(...ancestors.map((el) => addDomEvent(el, "resize", update))));
|
|
33
33
|
return () => cleanups.forEach((fn) => fn());
|
package/dist/get-placement.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Placement, VirtualElement } from '@floating-ui/dom';
|
|
2
|
+
import { BasePlacement, PositioningOptions } from './types.js';
|
|
3
3
|
import './auto-update.js';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
type MaybeRectElement = HTMLElement | VirtualElement | null;
|
|
6
|
+
type MaybeElement = HTMLElement | null;
|
|
7
|
+
type MaybeFn<T> = T | (() => T);
|
|
6
8
|
declare function getBasePlacement(placement: Placement): BasePlacement;
|
|
9
|
+
declare function getPlacement(referenceOrFn: MaybeFn<MaybeRectElement>, floatingOrFn: MaybeFn<MaybeElement>, opts?: PositioningOptions & {
|
|
10
|
+
defer?: boolean;
|
|
11
|
+
}): () => void;
|
|
7
12
|
|
|
8
13
|
export { getBasePlacement, getPlacement };
|
package/dist/get-placement.js
CHANGED
|
@@ -25,6 +25,7 @@ __export(get_placement_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(get_placement_exports);
|
|
27
27
|
var import_dom2 = require("@floating-ui/dom");
|
|
28
|
+
var import_dom_query = require("@zag-js/dom-query");
|
|
28
29
|
var import_utils = require("@zag-js/utils");
|
|
29
30
|
|
|
30
31
|
// src/auto-update.ts
|
|
@@ -54,9 +55,9 @@ function autoUpdate(reference, floating, update, options = false) {
|
|
|
54
55
|
ancestors.push(...(0, import_dom.getOverflowAncestors)(reference));
|
|
55
56
|
}
|
|
56
57
|
function addResizeListeners() {
|
|
57
|
-
let cleanups = [(0, import_element_rect.trackElementRect)(floating,
|
|
58
|
+
let cleanups = [(0, import_element_rect.trackElementRect)(floating, { scope: "size", onChange: update })];
|
|
58
59
|
if (referenceResize && isHTMLElement(reference)) {
|
|
59
|
-
cleanups.push((0, import_element_rect.trackElementRect)(reference, update));
|
|
60
|
+
cleanups.push((0, import_element_rect.trackElementRect)(reference, { onChange: update }));
|
|
60
61
|
}
|
|
61
62
|
cleanups.push(callAll(...ancestors.map((el) => addDomEvent(el, "resize", update))));
|
|
62
63
|
return () => cleanups.forEach((fn) => fn());
|
|
@@ -129,7 +130,7 @@ var defaultOptions = {
|
|
|
129
130
|
sameWidth: false,
|
|
130
131
|
overflowPadding: 8
|
|
131
132
|
};
|
|
132
|
-
function
|
|
133
|
+
function getPlacementImpl(reference, floating, opts = {}) {
|
|
133
134
|
if (!floating || !reference)
|
|
134
135
|
return;
|
|
135
136
|
const options = Object.assign({}, defaultOptions, opts);
|
|
@@ -218,6 +219,21 @@ function getPlacement(reference, floating, opts = {}) {
|
|
|
218
219
|
function getBasePlacement(placement) {
|
|
219
220
|
return placement.split("-")[0];
|
|
220
221
|
}
|
|
222
|
+
function getPlacement(referenceOrFn, floatingOrFn, opts = {}) {
|
|
223
|
+
const { defer, ...restOptions } = opts;
|
|
224
|
+
const func = defer ? import_dom_query.raf : (v) => v();
|
|
225
|
+
const cleanups = [];
|
|
226
|
+
cleanups.push(
|
|
227
|
+
func(() => {
|
|
228
|
+
const reference = typeof referenceOrFn === "function" ? referenceOrFn() : referenceOrFn;
|
|
229
|
+
const floating = typeof floatingOrFn === "function" ? floatingOrFn() : floatingOrFn;
|
|
230
|
+
cleanups.push(getPlacementImpl(reference, floating, restOptions));
|
|
231
|
+
})
|
|
232
|
+
);
|
|
233
|
+
return () => {
|
|
234
|
+
cleanups.forEach((fn) => fn?.());
|
|
235
|
+
};
|
|
236
|
+
}
|
|
221
237
|
// Annotate the CommonJS export names for ESM import in node:
|
|
222
238
|
0 && (module.exports = {
|
|
223
239
|
getBasePlacement,
|
package/dist/get-placement.mjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -28,6 +28,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
28
28
|
|
|
29
29
|
// src/get-placement.ts
|
|
30
30
|
var import_dom2 = require("@floating-ui/dom");
|
|
31
|
+
var import_dom_query = require("@zag-js/dom-query");
|
|
31
32
|
var import_utils = require("@zag-js/utils");
|
|
32
33
|
|
|
33
34
|
// src/auto-update.ts
|
|
@@ -57,9 +58,9 @@ function autoUpdate(reference, floating, update, options = false) {
|
|
|
57
58
|
ancestors.push(...(0, import_dom.getOverflowAncestors)(reference));
|
|
58
59
|
}
|
|
59
60
|
function addResizeListeners() {
|
|
60
|
-
let cleanups = [(0, import_element_rect.trackElementRect)(floating,
|
|
61
|
+
let cleanups = [(0, import_element_rect.trackElementRect)(floating, { scope: "size", onChange: update })];
|
|
61
62
|
if (referenceResize && isHTMLElement(reference)) {
|
|
62
|
-
cleanups.push((0, import_element_rect.trackElementRect)(reference, update));
|
|
63
|
+
cleanups.push((0, import_element_rect.trackElementRect)(reference, { onChange: update }));
|
|
63
64
|
}
|
|
64
65
|
cleanups.push(callAll(...ancestors.map((el) => addDomEvent(el, "resize", update))));
|
|
65
66
|
return () => cleanups.forEach((fn) => fn());
|
|
@@ -132,7 +133,7 @@ var defaultOptions = {
|
|
|
132
133
|
sameWidth: false,
|
|
133
134
|
overflowPadding: 8
|
|
134
135
|
};
|
|
135
|
-
function
|
|
136
|
+
function getPlacementImpl(reference, floating, opts = {}) {
|
|
136
137
|
if (!floating || !reference)
|
|
137
138
|
return;
|
|
138
139
|
const options = Object.assign({}, defaultOptions, opts);
|
|
@@ -221,6 +222,21 @@ function getPlacement(reference, floating, opts = {}) {
|
|
|
221
222
|
function getBasePlacement(placement) {
|
|
222
223
|
return placement.split("-")[0];
|
|
223
224
|
}
|
|
225
|
+
function getPlacement(referenceOrFn, floatingOrFn, opts = {}) {
|
|
226
|
+
const { defer, ...restOptions } = opts;
|
|
227
|
+
const func = defer ? import_dom_query.raf : (v) => v();
|
|
228
|
+
const cleanups = [];
|
|
229
|
+
cleanups.push(
|
|
230
|
+
func(() => {
|
|
231
|
+
const reference = typeof referenceOrFn === "function" ? referenceOrFn() : referenceOrFn;
|
|
232
|
+
const floating = typeof floatingOrFn === "function" ? floatingOrFn() : floatingOrFn;
|
|
233
|
+
cleanups.push(getPlacementImpl(reference, floating, restOptions));
|
|
234
|
+
})
|
|
235
|
+
);
|
|
236
|
+
return () => {
|
|
237
|
+
cleanups.forEach((fn) => fn?.());
|
|
238
|
+
};
|
|
239
|
+
}
|
|
224
240
|
|
|
225
241
|
// src/get-styles.ts
|
|
226
242
|
var ARROW_FLOATING_STYLE = {
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/popper",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Dynamic positioning logic for ui machines",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@floating-ui/dom": "1.2.
|
|
25
|
+
"@floating-ui/dom": "1.2.6",
|
|
26
26
|
"@zag-js/dom-query": "0.1.4",
|
|
27
|
-
"@zag-js/element-rect": "0.
|
|
27
|
+
"@zag-js/element-rect": "0.8.0",
|
|
28
28
|
"@zag-js/utils": "0.3.4"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|