@zag-js/popper 0.1.9 → 0.1.10
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.js +43 -31
- package/dist/index.mjs +43 -31
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -209,10 +209,12 @@ function getPlacement(reference, floating, opts = {}) {
|
|
|
209
209
|
const arrowEl = floating.querySelector("[data-part=arrow]");
|
|
210
210
|
const middleware = [];
|
|
211
211
|
if (options.flip) {
|
|
212
|
-
middleware.push(
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
212
|
+
middleware.push(
|
|
213
|
+
(0, import_dom2.flip)({
|
|
214
|
+
boundary: options.boundary,
|
|
215
|
+
padding: options.overflowPadding
|
|
216
|
+
})
|
|
217
|
+
);
|
|
216
218
|
}
|
|
217
219
|
if (options.gutter || options.offset) {
|
|
218
220
|
const arrowOffset = arrowEl ? arrowEl.offsetHeight / 2 : 0;
|
|
@@ -221,36 +223,43 @@ function getPlacement(reference, floating, opts = {}) {
|
|
|
221
223
|
data.mainAxis += arrowOffset;
|
|
222
224
|
middleware.push((0, import_dom2.offset)(data));
|
|
223
225
|
}
|
|
224
|
-
middleware.push(
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
226
|
+
middleware.push(
|
|
227
|
+
(0, import_dom2.shift)({
|
|
228
|
+
boundary: options.boundary,
|
|
229
|
+
crossAxis: options.overlap,
|
|
230
|
+
padding: options.overflowPadding
|
|
231
|
+
})
|
|
232
|
+
);
|
|
229
233
|
if (arrowEl) {
|
|
230
|
-
middleware.push(
|
|
234
|
+
middleware.push(
|
|
235
|
+
(0, import_dom2.arrow)({ element: arrowEl, padding: 8 }),
|
|
236
|
+
shiftArrow({ element: arrowEl })
|
|
237
|
+
);
|
|
231
238
|
}
|
|
232
239
|
middleware.push(transformOrigin);
|
|
233
|
-
middleware.push(
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
240
|
+
middleware.push(
|
|
241
|
+
(0, import_dom2.size)({
|
|
242
|
+
padding: options.overflowPadding,
|
|
243
|
+
apply({ rects, availableHeight, availableWidth }) {
|
|
244
|
+
const referenceWidth = Math.round(rects.reference.width);
|
|
245
|
+
floating.style.setProperty("--reference-width", `${referenceWidth}px`);
|
|
246
|
+
floating.style.setProperty("--available-width", `${availableWidth}px`);
|
|
247
|
+
floating.style.setProperty("--available-height", `${availableHeight}px`);
|
|
248
|
+
if (options.sameWidth) {
|
|
249
|
+
Object.assign(floating.style, {
|
|
250
|
+
width: `${referenceWidth}px`,
|
|
251
|
+
minWidth: "unset"
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
if (options.fitViewport) {
|
|
255
|
+
Object.assign(floating.style, {
|
|
256
|
+
maxWidth: `${availableWidth}px`,
|
|
257
|
+
maxHeight: `${availableHeight}px`
|
|
258
|
+
});
|
|
259
|
+
}
|
|
251
260
|
}
|
|
252
|
-
}
|
|
253
|
-
|
|
261
|
+
})
|
|
262
|
+
);
|
|
254
263
|
function compute(config = {}) {
|
|
255
264
|
if (!reference || !floating)
|
|
256
265
|
return;
|
|
@@ -274,7 +283,10 @@ function getPlacement(reference, floating, opts = {}) {
|
|
|
274
283
|
});
|
|
275
284
|
}
|
|
276
285
|
compute();
|
|
277
|
-
return callAll(
|
|
286
|
+
return callAll(
|
|
287
|
+
options.listeners ? autoUpdate(reference, floating, compute, options.listeners) : void 0,
|
|
288
|
+
options.onCleanup
|
|
289
|
+
);
|
|
278
290
|
}
|
|
279
291
|
function getBasePlacement(placement) {
|
|
280
292
|
return placement.split("-")[0];
|
package/dist/index.mjs
CHANGED
|
@@ -181,10 +181,12 @@ function getPlacement(reference, floating, opts = {}) {
|
|
|
181
181
|
const arrowEl = floating.querySelector("[data-part=arrow]");
|
|
182
182
|
const middleware = [];
|
|
183
183
|
if (options.flip) {
|
|
184
|
-
middleware.push(
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
184
|
+
middleware.push(
|
|
185
|
+
flip({
|
|
186
|
+
boundary: options.boundary,
|
|
187
|
+
padding: options.overflowPadding
|
|
188
|
+
})
|
|
189
|
+
);
|
|
188
190
|
}
|
|
189
191
|
if (options.gutter || options.offset) {
|
|
190
192
|
const arrowOffset = arrowEl ? arrowEl.offsetHeight / 2 : 0;
|
|
@@ -193,36 +195,43 @@ function getPlacement(reference, floating, opts = {}) {
|
|
|
193
195
|
data.mainAxis += arrowOffset;
|
|
194
196
|
middleware.push(offset(data));
|
|
195
197
|
}
|
|
196
|
-
middleware.push(
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
198
|
+
middleware.push(
|
|
199
|
+
shift({
|
|
200
|
+
boundary: options.boundary,
|
|
201
|
+
crossAxis: options.overlap,
|
|
202
|
+
padding: options.overflowPadding
|
|
203
|
+
})
|
|
204
|
+
);
|
|
201
205
|
if (arrowEl) {
|
|
202
|
-
middleware.push(
|
|
206
|
+
middleware.push(
|
|
207
|
+
arrow({ element: arrowEl, padding: 8 }),
|
|
208
|
+
shiftArrow({ element: arrowEl })
|
|
209
|
+
);
|
|
203
210
|
}
|
|
204
211
|
middleware.push(transformOrigin);
|
|
205
|
-
middleware.push(
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
212
|
+
middleware.push(
|
|
213
|
+
size({
|
|
214
|
+
padding: options.overflowPadding,
|
|
215
|
+
apply({ rects, availableHeight, availableWidth }) {
|
|
216
|
+
const referenceWidth = Math.round(rects.reference.width);
|
|
217
|
+
floating.style.setProperty("--reference-width", `${referenceWidth}px`);
|
|
218
|
+
floating.style.setProperty("--available-width", `${availableWidth}px`);
|
|
219
|
+
floating.style.setProperty("--available-height", `${availableHeight}px`);
|
|
220
|
+
if (options.sameWidth) {
|
|
221
|
+
Object.assign(floating.style, {
|
|
222
|
+
width: `${referenceWidth}px`,
|
|
223
|
+
minWidth: "unset"
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
if (options.fitViewport) {
|
|
227
|
+
Object.assign(floating.style, {
|
|
228
|
+
maxWidth: `${availableWidth}px`,
|
|
229
|
+
maxHeight: `${availableHeight}px`
|
|
230
|
+
});
|
|
231
|
+
}
|
|
223
232
|
}
|
|
224
|
-
}
|
|
225
|
-
|
|
233
|
+
})
|
|
234
|
+
);
|
|
226
235
|
function compute(config = {}) {
|
|
227
236
|
if (!reference || !floating)
|
|
228
237
|
return;
|
|
@@ -246,7 +255,10 @@ function getPlacement(reference, floating, opts = {}) {
|
|
|
246
255
|
});
|
|
247
256
|
}
|
|
248
257
|
compute();
|
|
249
|
-
return callAll(
|
|
258
|
+
return callAll(
|
|
259
|
+
options.listeners ? autoUpdate(reference, floating, compute, options.listeners) : void 0,
|
|
260
|
+
options.onCleanup
|
|
261
|
+
);
|
|
250
262
|
}
|
|
251
263
|
function getBasePlacement(placement) {
|
|
252
264
|
return placement.split("-")[0];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/popper",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "Dynamic positioning logic for ui machines",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@floating-ui/dom": "0.
|
|
28
|
+
"@floating-ui/dom": "1.0.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@zag-js/dom-utils": "0.1.
|
|
31
|
+
"@zag-js/dom-utils": "0.1.9",
|
|
32
32
|
"@zag-js/utils": "0.1.3"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|