@zag-js/popper 0.2.1 → 0.2.3
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.d.ts +11 -0
- package/dist/auto-update.js +144 -0
- package/dist/auto-update.mjs +6 -0
- package/dist/chunk-A2YMJLJJ.mjs +121 -0
- package/dist/chunk-I46LTIWB.mjs +51 -0
- package/dist/chunk-L7FW633C.mjs +114 -0
- package/dist/chunk-X5LLREVI.mjs +57 -0
- package/dist/get-placement.d.ts +8 -0
- package/dist/get-placement.js +301 -0
- package/dist/get-placement.mjs +10 -0
- package/dist/get-styles.d.ts +37 -0
- package/dist/get-styles.js +83 -0
- package/dist/get-styles.mjs +7 -0
- package/dist/index.d.ts +4 -108
- package/dist/index.js +22 -18
- package/dist/index.mjs +9 -311
- package/dist/middleware.d.ts +31 -0
- package/dist/middleware.js +83 -0
- package/dist/middleware.mjs +10 -0
- package/dist/types.d.ts +67 -0
- package/dist/types.js +18 -0
- package/dist/types.mjs +0 -0
- package/package.json +19 -9
package/dist/index.mjs
CHANGED
|
@@ -1,314 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var isBoolean = (v) => v === true || v === false;
|
|
11
|
-
|
|
12
|
-
// src/auto-update.ts
|
|
13
|
-
import { getOverflowAncestors } from "@floating-ui/dom";
|
|
14
|
-
|
|
15
|
-
// ../dom/dist/index.mjs
|
|
16
|
-
var runIfFn = (v, ...a) => {
|
|
17
|
-
const res = typeof v === "function" ? v(...a) : v;
|
|
18
|
-
return res != null ? res : void 0;
|
|
19
|
-
};
|
|
20
|
-
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
21
|
-
function isHTMLElement(v) {
|
|
22
|
-
return typeof v === "object" && (v == null ? void 0 : v.nodeType) === Node.ELEMENT_NODE && typeof (v == null ? void 0 : v.nodeName) === "string";
|
|
23
|
-
}
|
|
24
|
-
var isRef = (v) => hasProp(v, "current");
|
|
25
|
-
function addDomEvent(target, eventName, handler, options) {
|
|
26
|
-
const node = isRef(target) ? target.current : runIfFn(target);
|
|
27
|
-
node == null ? void 0 : node.addEventListener(eventName, handler, options);
|
|
28
|
-
return () => {
|
|
29
|
-
node == null ? void 0 : node.removeEventListener(eventName, handler, options);
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
function getObservedElements() {
|
|
33
|
-
;
|
|
34
|
-
globalThis.__rectObserverMap__ = globalThis.__rectObserverMap__ || /* @__PURE__ */ new Map();
|
|
35
|
-
return globalThis.__rectObserverMap__;
|
|
36
|
-
}
|
|
37
|
-
function observeElementRect(el, fn) {
|
|
38
|
-
const observedElements = getObservedElements();
|
|
39
|
-
const data = observedElements.get(el);
|
|
40
|
-
if (!data) {
|
|
41
|
-
observedElements.set(el, { rect: {}, callbacks: [fn] });
|
|
42
|
-
if (observedElements.size === 1) {
|
|
43
|
-
rafId = requestAnimationFrame(runLoop);
|
|
44
|
-
}
|
|
45
|
-
} else {
|
|
46
|
-
data.callbacks.push(fn);
|
|
47
|
-
fn(el.getBoundingClientRect());
|
|
48
|
-
}
|
|
49
|
-
return function unobserve() {
|
|
50
|
-
const data2 = observedElements.get(el);
|
|
51
|
-
if (!data2)
|
|
52
|
-
return;
|
|
53
|
-
const index = data2.callbacks.indexOf(fn);
|
|
54
|
-
if (index > -1) {
|
|
55
|
-
data2.callbacks.splice(index, 1);
|
|
56
|
-
}
|
|
57
|
-
if (data2.callbacks.length === 0) {
|
|
58
|
-
observedElements.delete(el);
|
|
59
|
-
if (observedElements.size === 0) {
|
|
60
|
-
cancelAnimationFrame(rafId);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
var rafId;
|
|
66
|
-
function runLoop() {
|
|
67
|
-
const observedElements = getObservedElements();
|
|
68
|
-
const changedRectsData = [];
|
|
69
|
-
observedElements.forEach((data, element) => {
|
|
70
|
-
const newRect = element.getBoundingClientRect();
|
|
71
|
-
if (!isEqual(data.rect, newRect)) {
|
|
72
|
-
data.rect = newRect;
|
|
73
|
-
changedRectsData.push(data);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
changedRectsData.forEach((data) => {
|
|
77
|
-
data.callbacks.forEach((callback) => callback(data.rect));
|
|
78
|
-
});
|
|
79
|
-
rafId = requestAnimationFrame(runLoop);
|
|
80
|
-
}
|
|
81
|
-
function isEqual(rect1, rect2) {
|
|
82
|
-
return rect1.width === rect2.width && rect1.height === rect2.height && rect1.top === rect2.top && rect1.right === rect2.right && rect1.bottom === rect2.bottom && rect1.left === rect2.left;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// src/auto-update.ts
|
|
86
|
-
function resolveOptions(option) {
|
|
87
|
-
var _a, _b, _c;
|
|
88
|
-
const bool = isBoolean(option);
|
|
89
|
-
return {
|
|
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
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
function autoUpdate(reference, floating, update, options = false) {
|
|
96
|
-
const { ancestorScroll, ancestorResize, referenceResize } = resolveOptions(options);
|
|
97
|
-
const useAncestors = ancestorScroll || ancestorResize;
|
|
98
|
-
const ancestors = [];
|
|
99
|
-
if (useAncestors && isHTMLElement(reference)) {
|
|
100
|
-
ancestors.push(...getOverflowAncestors(reference));
|
|
101
|
-
}
|
|
102
|
-
function addResizeListeners() {
|
|
103
|
-
let cleanups = [observeElementRect(floating, update)];
|
|
104
|
-
if (referenceResize && isHTMLElement(reference)) {
|
|
105
|
-
cleanups.push(observeElementRect(reference, update));
|
|
106
|
-
}
|
|
107
|
-
cleanups.push(callAll(...ancestors.map((el) => addDomEvent(el, "resize", update))));
|
|
108
|
-
return () => cleanups.forEach((fn) => fn());
|
|
109
|
-
}
|
|
110
|
-
function addScrollListeners() {
|
|
111
|
-
return callAll(...ancestors.map((el) => addDomEvent(el, "scroll", update, { passive: true })));
|
|
112
|
-
}
|
|
113
|
-
return callAll(addResizeListeners(), addScrollListeners());
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// src/middleware.ts
|
|
117
|
-
var toVar = (value) => ({ variable: value, reference: `var(${value})` });
|
|
118
|
-
var cssVars = {
|
|
119
|
-
arrowSize: toVar("--arrow-size"),
|
|
120
|
-
arrowSizeHalf: toVar("--arrow-size-half"),
|
|
121
|
-
arrowBg: toVar("--arrow-background"),
|
|
122
|
-
transformOrigin: toVar("--transform-origin"),
|
|
123
|
-
arrowOffset: toVar("--arrow-offset")
|
|
124
|
-
};
|
|
125
|
-
var getTransformOrigin = (arrow2) => ({
|
|
126
|
-
top: "bottom center",
|
|
127
|
-
"top-start": arrow2 ? `${arrow2.x}px bottom` : "left bottom",
|
|
128
|
-
"top-end": arrow2 ? `${arrow2.x}px bottom` : "right bottom",
|
|
129
|
-
bottom: "top center",
|
|
130
|
-
"bottom-start": arrow2 ? `${arrow2.x}px top` : "top left",
|
|
131
|
-
"bottom-end": arrow2 ? `${arrow2.x}px top` : "top right",
|
|
132
|
-
left: "right center",
|
|
133
|
-
"left-start": arrow2 ? `right ${arrow2.y}px` : "right top",
|
|
134
|
-
"left-end": arrow2 ? `right ${arrow2.y}px` : "right bottom",
|
|
135
|
-
right: "left center",
|
|
136
|
-
"right-start": arrow2 ? `left ${arrow2.y}px` : "left top",
|
|
137
|
-
"right-end": arrow2 ? `left ${arrow2.y}px` : "left bottom"
|
|
138
|
-
});
|
|
139
|
-
var transformOrigin = {
|
|
140
|
-
name: "transformOrigin",
|
|
141
|
-
fn({ placement, elements, middlewareData }) {
|
|
142
|
-
const { arrow: arrow2 } = middlewareData;
|
|
143
|
-
const transformOrigin2 = getTransformOrigin(arrow2)[placement];
|
|
144
|
-
const { floating } = elements;
|
|
145
|
-
floating.style.setProperty(cssVars.transformOrigin.variable, transformOrigin2);
|
|
146
|
-
return {
|
|
147
|
-
data: { transformOrigin: transformOrigin2 }
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
var shiftArrow = (opts) => ({
|
|
152
|
-
name: "shiftArrow",
|
|
153
|
-
fn({ placement, middlewareData }) {
|
|
154
|
-
const { element: arrow2 } = opts;
|
|
155
|
-
if (middlewareData.arrow) {
|
|
156
|
-
const { x, y } = middlewareData.arrow;
|
|
157
|
-
const dir = placement.split("-")[0];
|
|
158
|
-
Object.assign(arrow2.style, {
|
|
159
|
-
left: x != null ? `${x}px` : "",
|
|
160
|
-
top: y != null ? `${y}px` : "",
|
|
161
|
-
[dir]: `calc(100% + ${cssVars.arrowOffset.reference})`
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
return {};
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
// src/get-placement.ts
|
|
169
|
-
var defaultOptions = {
|
|
170
|
-
strategy: "absolute",
|
|
171
|
-
placement: "bottom",
|
|
172
|
-
listeners: true,
|
|
173
|
-
gutter: 8,
|
|
174
|
-
flip: true,
|
|
175
|
-
sameWidth: false,
|
|
176
|
-
overflowPadding: 8
|
|
177
|
-
};
|
|
178
|
-
function getPlacement(reference, floating, opts = {}) {
|
|
179
|
-
if (!floating || !reference)
|
|
180
|
-
return;
|
|
181
|
-
const options = Object.assign({}, defaultOptions, opts);
|
|
182
|
-
const arrowEl = floating.querySelector("[data-part=arrow]");
|
|
183
|
-
const middleware = [];
|
|
184
|
-
const boundary = typeof options.boundary === "function" ? options.boundary() : options.boundary;
|
|
185
|
-
if (options.flip) {
|
|
186
|
-
middleware.push(
|
|
187
|
-
flip({
|
|
188
|
-
boundary,
|
|
189
|
-
padding: options.overflowPadding
|
|
190
|
-
})
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
if (options.gutter || options.offset) {
|
|
194
|
-
const arrowOffset = arrowEl ? arrowEl.offsetHeight / 2 : 0;
|
|
195
|
-
const data = options.gutter ? { mainAxis: options.gutter } : options.offset;
|
|
196
|
-
if ((data == null ? void 0 : data.mainAxis) != null)
|
|
197
|
-
data.mainAxis += arrowOffset;
|
|
198
|
-
middleware.push(offset(data));
|
|
199
|
-
}
|
|
200
|
-
middleware.push(
|
|
201
|
-
shift({
|
|
202
|
-
boundary,
|
|
203
|
-
crossAxis: options.overlap,
|
|
204
|
-
padding: options.overflowPadding
|
|
205
|
-
})
|
|
206
|
-
);
|
|
207
|
-
if (arrowEl) {
|
|
208
|
-
middleware.push(
|
|
209
|
-
arrow({ element: arrowEl, padding: 8 }),
|
|
210
|
-
shiftArrow({ element: arrowEl })
|
|
211
|
-
);
|
|
212
|
-
}
|
|
213
|
-
middleware.push(transformOrigin);
|
|
214
|
-
middleware.push(
|
|
215
|
-
size({
|
|
216
|
-
padding: options.overflowPadding,
|
|
217
|
-
apply({ rects, availableHeight, availableWidth }) {
|
|
218
|
-
const referenceWidth = Math.round(rects.reference.width);
|
|
219
|
-
floating.style.setProperty("--reference-width", `${referenceWidth}px`);
|
|
220
|
-
floating.style.setProperty("--available-width", `${availableWidth}px`);
|
|
221
|
-
floating.style.setProperty("--available-height", `${availableHeight}px`);
|
|
222
|
-
if (options.sameWidth) {
|
|
223
|
-
Object.assign(floating.style, {
|
|
224
|
-
width: `${referenceWidth}px`,
|
|
225
|
-
minWidth: "unset"
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
if (options.fitViewport) {
|
|
229
|
-
Object.assign(floating.style, {
|
|
230
|
-
maxWidth: `${availableWidth}px`,
|
|
231
|
-
maxHeight: `${availableHeight}px`
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
})
|
|
236
|
-
);
|
|
237
|
-
function compute(config = {}) {
|
|
238
|
-
if (!reference || !floating)
|
|
239
|
-
return;
|
|
240
|
-
const { placement, strategy } = options;
|
|
241
|
-
computePosition(reference, floating, {
|
|
242
|
-
placement,
|
|
243
|
-
middleware,
|
|
244
|
-
strategy,
|
|
245
|
-
...config
|
|
246
|
-
}).then((data) => {
|
|
247
|
-
var _a;
|
|
248
|
-
const x = Math.round(data.x);
|
|
249
|
-
const y = Math.round(data.y);
|
|
250
|
-
Object.assign(floating.style, {
|
|
251
|
-
position: data.strategy,
|
|
252
|
-
top: "0",
|
|
253
|
-
left: "0",
|
|
254
|
-
transform: `translate3d(${x}px, ${y}px, 0)`
|
|
255
|
-
});
|
|
256
|
-
(_a = options.onComplete) == null ? void 0 : _a.call(options, { ...data, compute });
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
compute();
|
|
260
|
-
return callAll(
|
|
261
|
-
options.listeners ? autoUpdate(reference, floating, compute, options.listeners) : void 0,
|
|
262
|
-
options.onCleanup
|
|
263
|
-
);
|
|
264
|
-
}
|
|
265
|
-
function getBasePlacement(placement) {
|
|
266
|
-
return placement.split("-")[0];
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
// src/get-styles.ts
|
|
270
|
-
var UNMEASURED_FLOATING_STYLE = {
|
|
271
|
-
position: "fixed",
|
|
272
|
-
top: 0,
|
|
273
|
-
left: 0,
|
|
274
|
-
opacity: 0,
|
|
275
|
-
transform: "translate3d(0, -200%, 0)",
|
|
276
|
-
pointerEvents: "none"
|
|
277
|
-
};
|
|
278
|
-
var ARROW_FLOATING_STYLE = {
|
|
279
|
-
bottom: "rotate(45deg)",
|
|
280
|
-
left: "rotate(135deg)",
|
|
281
|
-
top: "rotate(225deg)",
|
|
282
|
-
right: "rotate(315deg)"
|
|
283
|
-
};
|
|
284
|
-
function getPlacementStyles(options) {
|
|
285
|
-
const { measured, strategy = "absolute", placement = "bottom" } = options;
|
|
286
|
-
return {
|
|
287
|
-
arrow: {
|
|
288
|
-
position: "absolute",
|
|
289
|
-
width: cssVars.arrowSize.reference,
|
|
290
|
-
height: cssVars.arrowSize.reference,
|
|
291
|
-
[cssVars.arrowSizeHalf.variable]: `calc(${cssVars.arrowSize.reference} / 2)`,
|
|
292
|
-
[cssVars.arrowOffset.variable]: `calc(${cssVars.arrowSizeHalf.reference} * -1)`,
|
|
293
|
-
opacity: !measured ? 0 : void 0
|
|
294
|
-
},
|
|
295
|
-
arrowTip: {
|
|
296
|
-
transform: ARROW_FLOATING_STYLE[placement.split("-")[0]],
|
|
297
|
-
background: cssVars.arrowBg.reference,
|
|
298
|
-
top: "0",
|
|
299
|
-
left: "0",
|
|
300
|
-
width: "100%",
|
|
301
|
-
height: "100%",
|
|
302
|
-
position: "absolute",
|
|
303
|
-
zIndex: "inherit"
|
|
304
|
-
},
|
|
305
|
-
floating: {
|
|
306
|
-
position: strategy,
|
|
307
|
-
minWidth: "max-content",
|
|
308
|
-
...!measured && UNMEASURED_FLOATING_STYLE
|
|
309
|
-
}
|
|
310
|
-
};
|
|
311
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
getBasePlacement,
|
|
3
|
+
getPlacement
|
|
4
|
+
} from "./chunk-L7FW633C.mjs";
|
|
5
|
+
import "./chunk-A2YMJLJJ.mjs";
|
|
6
|
+
import {
|
|
7
|
+
getPlacementStyles
|
|
8
|
+
} from "./chunk-I46LTIWB.mjs";
|
|
9
|
+
import "./chunk-X5LLREVI.mjs";
|
|
312
10
|
export {
|
|
313
11
|
getBasePlacement,
|
|
314
12
|
getPlacement,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Middleware } from '@floating-ui/dom';
|
|
2
|
+
|
|
3
|
+
declare const cssVars: {
|
|
4
|
+
arrowSize: {
|
|
5
|
+
variable: string;
|
|
6
|
+
reference: string;
|
|
7
|
+
};
|
|
8
|
+
arrowSizeHalf: {
|
|
9
|
+
variable: string;
|
|
10
|
+
reference: string;
|
|
11
|
+
};
|
|
12
|
+
arrowBg: {
|
|
13
|
+
variable: string;
|
|
14
|
+
reference: string;
|
|
15
|
+
};
|
|
16
|
+
transformOrigin: {
|
|
17
|
+
variable: string;
|
|
18
|
+
reference: string;
|
|
19
|
+
};
|
|
20
|
+
arrowOffset: {
|
|
21
|
+
variable: string;
|
|
22
|
+
reference: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
declare const transformOrigin: Middleware;
|
|
26
|
+
type ArrowOptions = {
|
|
27
|
+
element: HTMLElement;
|
|
28
|
+
};
|
|
29
|
+
declare const shiftArrow: (opts: ArrowOptions) => Middleware;
|
|
30
|
+
|
|
31
|
+
export { cssVars, shiftArrow, transformOrigin };
|
|
@@ -0,0 +1,83 @@
|
|
|
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/middleware.ts
|
|
21
|
+
var middleware_exports = {};
|
|
22
|
+
__export(middleware_exports, {
|
|
23
|
+
cssVars: () => cssVars,
|
|
24
|
+
shiftArrow: () => shiftArrow,
|
|
25
|
+
transformOrigin: () => transformOrigin
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(middleware_exports);
|
|
28
|
+
var toVar = (value) => ({ variable: value, reference: `var(${value})` });
|
|
29
|
+
var cssVars = {
|
|
30
|
+
arrowSize: toVar("--arrow-size"),
|
|
31
|
+
arrowSizeHalf: toVar("--arrow-size-half"),
|
|
32
|
+
arrowBg: toVar("--arrow-background"),
|
|
33
|
+
transformOrigin: toVar("--transform-origin"),
|
|
34
|
+
arrowOffset: toVar("--arrow-offset")
|
|
35
|
+
};
|
|
36
|
+
var getTransformOrigin = (arrow) => ({
|
|
37
|
+
top: "bottom center",
|
|
38
|
+
"top-start": arrow ? `${arrow.x}px bottom` : "left bottom",
|
|
39
|
+
"top-end": arrow ? `${arrow.x}px bottom` : "right bottom",
|
|
40
|
+
bottom: "top center",
|
|
41
|
+
"bottom-start": arrow ? `${arrow.x}px top` : "top left",
|
|
42
|
+
"bottom-end": arrow ? `${arrow.x}px top` : "top right",
|
|
43
|
+
left: "right center",
|
|
44
|
+
"left-start": arrow ? `right ${arrow.y}px` : "right top",
|
|
45
|
+
"left-end": arrow ? `right ${arrow.y}px` : "right bottom",
|
|
46
|
+
right: "left center",
|
|
47
|
+
"right-start": arrow ? `left ${arrow.y}px` : "left top",
|
|
48
|
+
"right-end": arrow ? `left ${arrow.y}px` : "left bottom"
|
|
49
|
+
});
|
|
50
|
+
var transformOrigin = {
|
|
51
|
+
name: "transformOrigin",
|
|
52
|
+
fn({ placement, elements, middlewareData }) {
|
|
53
|
+
const { arrow } = middlewareData;
|
|
54
|
+
const transformOrigin2 = getTransformOrigin(arrow)[placement];
|
|
55
|
+
const { floating } = elements;
|
|
56
|
+
floating.style.setProperty(cssVars.transformOrigin.variable, transformOrigin2);
|
|
57
|
+
return {
|
|
58
|
+
data: { transformOrigin: transformOrigin2 }
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var shiftArrow = (opts) => ({
|
|
63
|
+
name: "shiftArrow",
|
|
64
|
+
fn({ placement, middlewareData }) {
|
|
65
|
+
const { element: arrow } = opts;
|
|
66
|
+
if (middlewareData.arrow) {
|
|
67
|
+
const { x, y } = middlewareData.arrow;
|
|
68
|
+
const dir = placement.split("-")[0];
|
|
69
|
+
Object.assign(arrow.style, {
|
|
70
|
+
left: x != null ? `${x}px` : "",
|
|
71
|
+
top: y != null ? `${y}px` : "",
|
|
72
|
+
[dir]: `calc(100% + ${cssVars.arrowOffset.reference})`
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return {};
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
79
|
+
0 && (module.exports = {
|
|
80
|
+
cssVars,
|
|
81
|
+
shiftArrow,
|
|
82
|
+
transformOrigin
|
|
83
|
+
});
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Placement, Boundary, ComputePositionReturn, ComputePositionConfig } from '@floating-ui/dom';
|
|
2
|
+
export { Placement } from '@floating-ui/dom';
|
|
3
|
+
import { AutoUpdateOptions } from './auto-update.js';
|
|
4
|
+
|
|
5
|
+
type PositioningOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* The strategy to use for positioning
|
|
8
|
+
*/
|
|
9
|
+
strategy?: "absolute" | "fixed";
|
|
10
|
+
/**
|
|
11
|
+
* The initial placement of the floating element
|
|
12
|
+
*/
|
|
13
|
+
placement?: Placement;
|
|
14
|
+
/**
|
|
15
|
+
* The offset of the floating element
|
|
16
|
+
*/
|
|
17
|
+
offset?: {
|
|
18
|
+
mainAxis?: number;
|
|
19
|
+
crossAxis?: number;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The main axis offset or gap between the reference and floating elements
|
|
23
|
+
*/
|
|
24
|
+
gutter?: number;
|
|
25
|
+
/**
|
|
26
|
+
* The virtual padding around the viewport edges to check for overflow
|
|
27
|
+
*/
|
|
28
|
+
overflowPadding?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Whether to flip the placement
|
|
31
|
+
*/
|
|
32
|
+
flip?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Whether the floating element can overlap the reference element
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
overlap?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Whether to make the floating element same width as the reference element
|
|
40
|
+
*/
|
|
41
|
+
sameWidth?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the popover should fit the viewport.
|
|
44
|
+
*/
|
|
45
|
+
fitViewport?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* The overflow boundary of the reference element
|
|
48
|
+
*/
|
|
49
|
+
boundary?: Boundary | (() => Boundary);
|
|
50
|
+
/**
|
|
51
|
+
* Options to activate auto-update listeners
|
|
52
|
+
*/
|
|
53
|
+
listeners?: boolean | AutoUpdateOptions;
|
|
54
|
+
/**
|
|
55
|
+
* Function called when the placement is computed
|
|
56
|
+
*/
|
|
57
|
+
onComplete?(data: ComputePositionReturn & {
|
|
58
|
+
compute: (config?: Omit<ComputePositionConfig, "platform">) => void;
|
|
59
|
+
}): void;
|
|
60
|
+
/**
|
|
61
|
+
* Function called on cleanup of all listeners
|
|
62
|
+
*/
|
|
63
|
+
onCleanup?: VoidFunction;
|
|
64
|
+
};
|
|
65
|
+
type BasePlacement = "top" | "right" | "bottom" | "left";
|
|
66
|
+
|
|
67
|
+
export { BasePlacement, 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,10 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/popper",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Dynamic positioning logic for ui machines",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/index.mjs",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
5
|
"keywords": [
|
|
9
6
|
"js",
|
|
10
7
|
"utils",
|
|
@@ -25,16 +22,29 @@
|
|
|
25
22
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
26
23
|
},
|
|
27
24
|
"dependencies": {
|
|
28
|
-
"@floating-ui/dom": "1.0
|
|
25
|
+
"@floating-ui/dom": "1.1.0"
|
|
29
26
|
},
|
|
30
27
|
"devDependencies": {
|
|
31
|
-
"
|
|
32
|
-
"@zag-js/utils": "0.
|
|
28
|
+
"clean-package": "2.2.0",
|
|
29
|
+
"@zag-js/dom-utils": "0.2.4",
|
|
30
|
+
"@zag-js/utils": "0.3.3"
|
|
31
|
+
},
|
|
32
|
+
"clean-package": "../../../clean-package.config.json",
|
|
33
|
+
"main": "dist/index.js",
|
|
34
|
+
"module": "dist/index.mjs",
|
|
35
|
+
"types": "dist/index.d.ts",
|
|
36
|
+
"exports": {
|
|
37
|
+
".": {
|
|
38
|
+
"types": "./dist/index.d.ts",
|
|
39
|
+
"import": "./dist/index.mjs",
|
|
40
|
+
"require": "./dist/index.js"
|
|
41
|
+
},
|
|
42
|
+
"./package.json": "./package.json"
|
|
33
43
|
},
|
|
34
44
|
"scripts": {
|
|
35
|
-
"build-fast": "tsup src
|
|
45
|
+
"build-fast": "tsup src",
|
|
36
46
|
"start": "pnpm build --watch",
|
|
37
|
-
"build": "tsup src
|
|
47
|
+
"build": "tsup src --dts",
|
|
38
48
|
"test": "jest --config ../../../jest.config.js --rootDir . --passWithNoTests",
|
|
39
49
|
"lint": "eslint src --ext .ts,.tsx",
|
|
40
50
|
"test-ci": "pnpm test --ci --runInBand",
|