@zag-js/popper 0.1.10 → 0.1.12
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 +13 -42
- package/package.json +7 -7
- package/dist/index.mjs +0 -314
package/dist/index.js
CHANGED
|
@@ -1,35 +1,7 @@
|
|
|
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/index.ts
|
|
21
|
-
var src_exports = {};
|
|
22
|
-
__export(src_exports, {
|
|
23
|
-
getBasePlacement: () => getBasePlacement,
|
|
24
|
-
getPlacement: () => getPlacement,
|
|
25
|
-
getPlacementStyles: () => getPlacementStyles
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(src_exports);
|
|
28
|
-
|
|
29
1
|
// src/get-placement.ts
|
|
30
|
-
|
|
2
|
+
import { arrow, computePosition, flip, offset, shift, size } from "@floating-ui/dom";
|
|
31
3
|
|
|
32
|
-
// ../core/dist/index.
|
|
4
|
+
// ../core/dist/index.js
|
|
33
5
|
var callAll = (...fns) => (...a) => {
|
|
34
6
|
fns.forEach(function(fn) {
|
|
35
7
|
fn == null ? void 0 : fn(...a);
|
|
@@ -38,9 +10,9 @@ var callAll = (...fns) => (...a) => {
|
|
|
38
10
|
var isBoolean = (v) => v === true || v === false;
|
|
39
11
|
|
|
40
12
|
// src/auto-update.ts
|
|
41
|
-
|
|
13
|
+
import { getOverflowAncestors } from "@floating-ui/dom";
|
|
42
14
|
|
|
43
|
-
// ../dom/dist/index.
|
|
15
|
+
// ../dom/dist/index.js
|
|
44
16
|
var runIfFn = (v, ...a) => {
|
|
45
17
|
const res = typeof v === "function" ? v(...a) : v;
|
|
46
18
|
return res ?? void 0;
|
|
@@ -124,7 +96,7 @@ function autoUpdate(reference, floating, update, options = false) {
|
|
|
124
96
|
const useAncestors = ancestorScroll || ancestorResize;
|
|
125
97
|
const ancestors = [];
|
|
126
98
|
if (useAncestors && isHTMLElement(reference)) {
|
|
127
|
-
ancestors.push(...
|
|
99
|
+
ancestors.push(...getOverflowAncestors(reference));
|
|
128
100
|
}
|
|
129
101
|
function addResizeListeners() {
|
|
130
102
|
let cleanups = [observeElementRect(floating, update)];
|
|
@@ -210,7 +182,7 @@ function getPlacement(reference, floating, opts = {}) {
|
|
|
210
182
|
const middleware = [];
|
|
211
183
|
if (options.flip) {
|
|
212
184
|
middleware.push(
|
|
213
|
-
|
|
185
|
+
flip({
|
|
214
186
|
boundary: options.boundary,
|
|
215
187
|
padding: options.overflowPadding
|
|
216
188
|
})
|
|
@@ -221,10 +193,10 @@ function getPlacement(reference, floating, opts = {}) {
|
|
|
221
193
|
const data = options.gutter ? { mainAxis: options.gutter } : options.offset;
|
|
222
194
|
if ((data == null ? void 0 : data.mainAxis) != null)
|
|
223
195
|
data.mainAxis += arrowOffset;
|
|
224
|
-
middleware.push(
|
|
196
|
+
middleware.push(offset(data));
|
|
225
197
|
}
|
|
226
198
|
middleware.push(
|
|
227
|
-
|
|
199
|
+
shift({
|
|
228
200
|
boundary: options.boundary,
|
|
229
201
|
crossAxis: options.overlap,
|
|
230
202
|
padding: options.overflowPadding
|
|
@@ -232,13 +204,13 @@ function getPlacement(reference, floating, opts = {}) {
|
|
|
232
204
|
);
|
|
233
205
|
if (arrowEl) {
|
|
234
206
|
middleware.push(
|
|
235
|
-
|
|
207
|
+
arrow({ element: arrowEl, padding: 8 }),
|
|
236
208
|
shiftArrow({ element: arrowEl })
|
|
237
209
|
);
|
|
238
210
|
}
|
|
239
211
|
middleware.push(transformOrigin);
|
|
240
212
|
middleware.push(
|
|
241
|
-
|
|
213
|
+
size({
|
|
242
214
|
padding: options.overflowPadding,
|
|
243
215
|
apply({ rects, availableHeight, availableWidth }) {
|
|
244
216
|
const referenceWidth = Math.round(rects.reference.width);
|
|
@@ -264,7 +236,7 @@ function getPlacement(reference, floating, opts = {}) {
|
|
|
264
236
|
if (!reference || !floating)
|
|
265
237
|
return;
|
|
266
238
|
const { placement, strategy } = options;
|
|
267
|
-
|
|
239
|
+
computePosition(reference, floating, {
|
|
268
240
|
placement,
|
|
269
241
|
middleware,
|
|
270
242
|
strategy,
|
|
@@ -335,9 +307,8 @@ function getPlacementStyles(options) {
|
|
|
335
307
|
}
|
|
336
308
|
};
|
|
337
309
|
}
|
|
338
|
-
|
|
339
|
-
0 && (module.exports = {
|
|
310
|
+
export {
|
|
340
311
|
getBasePlacement,
|
|
341
312
|
getPlacement,
|
|
342
313
|
getPlacementStyles
|
|
343
|
-
}
|
|
314
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
+
"type": "module",
|
|
2
3
|
"name": "@zag-js/popper",
|
|
3
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.12",
|
|
4
5
|
"description": "Dynamic positioning logic for ui machines",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"js",
|
|
@@ -11,7 +12,6 @@
|
|
|
11
12
|
"homepage": "https://github.com/chakra-ui/zag#readme",
|
|
12
13
|
"license": "MIT",
|
|
13
14
|
"main": "dist/index.js",
|
|
14
|
-
"module": "dist/index.mjs",
|
|
15
15
|
"types": "dist/index.d.ts",
|
|
16
16
|
"repository": "https://github.com/chakra-ui/zag/tree/main/packages/utilities/popper",
|
|
17
17
|
"sideEffects": false,
|
|
@@ -25,16 +25,16 @@
|
|
|
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.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@zag-js/dom-utils": "0.1.
|
|
32
|
-
"@zag-js/utils": "0.1.
|
|
31
|
+
"@zag-js/dom-utils": "0.1.12",
|
|
32
|
+
"@zag-js/utils": "0.1.5"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
|
-
"build-fast": "tsup src/index.ts --format=esm
|
|
35
|
+
"build-fast": "tsup src/index.ts --format=esm",
|
|
36
36
|
"start": "pnpm build --watch",
|
|
37
|
-
"build": "tsup src/index.ts --format=esm
|
|
37
|
+
"build": "tsup src/index.ts --format=esm --dts",
|
|
38
38
|
"test": "jest --config ../../../jest.config.js --rootDir . --passWithNoTests",
|
|
39
39
|
"lint": "eslint src --ext .ts,.tsx",
|
|
40
40
|
"test-ci": "pnpm test --ci --runInBand",
|
package/dist/index.mjs
DELETED
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
// src/get-placement.ts
|
|
2
|
-
import { arrow, computePosition, flip, offset, shift, size } from "@floating-ui/dom";
|
|
3
|
-
|
|
4
|
-
// ../core/dist/index.mjs
|
|
5
|
-
var callAll = (...fns) => (...a) => {
|
|
6
|
-
fns.forEach(function(fn) {
|
|
7
|
-
fn == null ? void 0 : fn(...a);
|
|
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 ?? 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
|
-
const bool = isBoolean(option);
|
|
88
|
-
return {
|
|
89
|
-
ancestorResize: bool ? option : option.ancestorResize ?? true,
|
|
90
|
-
ancestorScroll: bool ? option : option.ancestorScroll ?? true,
|
|
91
|
-
referenceResize: bool ? option : option.referenceResize ?? true
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
function autoUpdate(reference, floating, update, options = false) {
|
|
95
|
-
const { ancestorScroll, ancestorResize, referenceResize } = resolveOptions(options);
|
|
96
|
-
const useAncestors = ancestorScroll || ancestorResize;
|
|
97
|
-
const ancestors = [];
|
|
98
|
-
if (useAncestors && isHTMLElement(reference)) {
|
|
99
|
-
ancestors.push(...getOverflowAncestors(reference));
|
|
100
|
-
}
|
|
101
|
-
function addResizeListeners() {
|
|
102
|
-
let cleanups = [observeElementRect(floating, update)];
|
|
103
|
-
if (referenceResize && isHTMLElement(reference)) {
|
|
104
|
-
cleanups.push(observeElementRect(reference, update));
|
|
105
|
-
}
|
|
106
|
-
cleanups.push(callAll(...ancestors.map((el) => addDomEvent(el, "resize", update))));
|
|
107
|
-
return () => cleanups.forEach((fn) => fn());
|
|
108
|
-
}
|
|
109
|
-
function addScrollListeners() {
|
|
110
|
-
return callAll(...ancestors.map((el) => addDomEvent(el, "scroll", update, { passive: true })));
|
|
111
|
-
}
|
|
112
|
-
return callAll(addResizeListeners(), addScrollListeners());
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// src/middleware.ts
|
|
116
|
-
var toVar = (value) => ({ variable: value, reference: `var(${value})` });
|
|
117
|
-
var cssVars = {
|
|
118
|
-
arrowSize: toVar("--arrow-size"),
|
|
119
|
-
arrowSizeHalf: toVar("--arrow-size-half"),
|
|
120
|
-
arrowBg: toVar("--arrow-background"),
|
|
121
|
-
transformOrigin: toVar("--transform-origin"),
|
|
122
|
-
arrowOffset: toVar("--arrow-offset")
|
|
123
|
-
};
|
|
124
|
-
var getTransformOrigin = (arrow2) => ({
|
|
125
|
-
top: "bottom center",
|
|
126
|
-
"top-start": arrow2 ? `${arrow2.x}px bottom` : "left bottom",
|
|
127
|
-
"top-end": arrow2 ? `${arrow2.x}px bottom` : "right bottom",
|
|
128
|
-
bottom: "top center",
|
|
129
|
-
"bottom-start": arrow2 ? `${arrow2.x}px top` : "top left",
|
|
130
|
-
"bottom-end": arrow2 ? `${arrow2.x}px top` : "top right",
|
|
131
|
-
left: "right center",
|
|
132
|
-
"left-start": arrow2 ? `right ${arrow2.y}px` : "right top",
|
|
133
|
-
"left-end": arrow2 ? `right ${arrow2.y}px` : "right bottom",
|
|
134
|
-
right: "left center",
|
|
135
|
-
"right-start": arrow2 ? `left ${arrow2.y}px` : "left top",
|
|
136
|
-
"right-end": arrow2 ? `left ${arrow2.y}px` : "left bottom"
|
|
137
|
-
});
|
|
138
|
-
var transformOrigin = {
|
|
139
|
-
name: "transformOrigin",
|
|
140
|
-
fn({ placement, elements, middlewareData }) {
|
|
141
|
-
const { arrow: arrow2 } = middlewareData;
|
|
142
|
-
const transformOrigin2 = getTransformOrigin(arrow2)[placement];
|
|
143
|
-
const { floating } = elements;
|
|
144
|
-
floating.style.setProperty(cssVars.transformOrigin.variable, transformOrigin2);
|
|
145
|
-
return {
|
|
146
|
-
data: { transformOrigin: transformOrigin2 }
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
var shiftArrow = (opts) => ({
|
|
151
|
-
name: "shiftArrow",
|
|
152
|
-
fn({ placement, middlewareData }) {
|
|
153
|
-
const { element: arrow2 } = opts;
|
|
154
|
-
if (middlewareData.arrow) {
|
|
155
|
-
const { x, y } = middlewareData.arrow;
|
|
156
|
-
const dir = placement.split("-")[0];
|
|
157
|
-
Object.assign(arrow2.style, {
|
|
158
|
-
left: x != null ? `${x}px` : "",
|
|
159
|
-
top: y != null ? `${y}px` : "",
|
|
160
|
-
[dir]: `calc(100% + ${cssVars.arrowOffset.reference})`
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
return {};
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
// src/get-placement.ts
|
|
168
|
-
var defaultOptions = {
|
|
169
|
-
strategy: "absolute",
|
|
170
|
-
placement: "bottom",
|
|
171
|
-
listeners: true,
|
|
172
|
-
gutter: 8,
|
|
173
|
-
flip: true,
|
|
174
|
-
sameWidth: false,
|
|
175
|
-
overflowPadding: 8
|
|
176
|
-
};
|
|
177
|
-
function getPlacement(reference, floating, opts = {}) {
|
|
178
|
-
if (!floating || !reference)
|
|
179
|
-
return;
|
|
180
|
-
const options = Object.assign({}, defaultOptions, opts);
|
|
181
|
-
const arrowEl = floating.querySelector("[data-part=arrow]");
|
|
182
|
-
const middleware = [];
|
|
183
|
-
if (options.flip) {
|
|
184
|
-
middleware.push(
|
|
185
|
-
flip({
|
|
186
|
-
boundary: options.boundary,
|
|
187
|
-
padding: options.overflowPadding
|
|
188
|
-
})
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
if (options.gutter || options.offset) {
|
|
192
|
-
const arrowOffset = arrowEl ? arrowEl.offsetHeight / 2 : 0;
|
|
193
|
-
const data = options.gutter ? { mainAxis: options.gutter } : options.offset;
|
|
194
|
-
if ((data == null ? void 0 : data.mainAxis) != null)
|
|
195
|
-
data.mainAxis += arrowOffset;
|
|
196
|
-
middleware.push(offset(data));
|
|
197
|
-
}
|
|
198
|
-
middleware.push(
|
|
199
|
-
shift({
|
|
200
|
-
boundary: options.boundary,
|
|
201
|
-
crossAxis: options.overlap,
|
|
202
|
-
padding: options.overflowPadding
|
|
203
|
-
})
|
|
204
|
-
);
|
|
205
|
-
if (arrowEl) {
|
|
206
|
-
middleware.push(
|
|
207
|
-
arrow({ element: arrowEl, padding: 8 }),
|
|
208
|
-
shiftArrow({ element: arrowEl })
|
|
209
|
-
);
|
|
210
|
-
}
|
|
211
|
-
middleware.push(transformOrigin);
|
|
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
|
-
}
|
|
232
|
-
}
|
|
233
|
-
})
|
|
234
|
-
);
|
|
235
|
-
function compute(config = {}) {
|
|
236
|
-
if (!reference || !floating)
|
|
237
|
-
return;
|
|
238
|
-
const { placement, strategy } = options;
|
|
239
|
-
computePosition(reference, floating, {
|
|
240
|
-
placement,
|
|
241
|
-
middleware,
|
|
242
|
-
strategy,
|
|
243
|
-
...config
|
|
244
|
-
}).then((data) => {
|
|
245
|
-
var _a;
|
|
246
|
-
const x = Math.round(data.x);
|
|
247
|
-
const y = Math.round(data.y);
|
|
248
|
-
Object.assign(floating.style, {
|
|
249
|
-
position: data.strategy,
|
|
250
|
-
top: "0",
|
|
251
|
-
left: "0",
|
|
252
|
-
transform: `translate3d(${x}px, ${y}px, 0)`
|
|
253
|
-
});
|
|
254
|
-
(_a = options.onComplete) == null ? void 0 : _a.call(options, { ...data, compute });
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
compute();
|
|
258
|
-
return callAll(
|
|
259
|
-
options.listeners ? autoUpdate(reference, floating, compute, options.listeners) : void 0,
|
|
260
|
-
options.onCleanup
|
|
261
|
-
);
|
|
262
|
-
}
|
|
263
|
-
function getBasePlacement(placement) {
|
|
264
|
-
return placement.split("-")[0];
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
// src/get-styles.ts
|
|
268
|
-
var UNMEASURED_FLOATING_STYLE = {
|
|
269
|
-
position: "fixed",
|
|
270
|
-
top: 0,
|
|
271
|
-
left: 0,
|
|
272
|
-
opacity: 0,
|
|
273
|
-
transform: "translate3d(0, -200%, 0)",
|
|
274
|
-
pointerEvents: "none"
|
|
275
|
-
};
|
|
276
|
-
var ARROW_FLOATING_STYLE = {
|
|
277
|
-
bottom: "rotate(45deg)",
|
|
278
|
-
left: "rotate(135deg)",
|
|
279
|
-
top: "rotate(225deg)",
|
|
280
|
-
right: "rotate(315deg)"
|
|
281
|
-
};
|
|
282
|
-
function getPlacementStyles(options) {
|
|
283
|
-
const { measured, strategy = "absolute", placement = "bottom" } = options;
|
|
284
|
-
return {
|
|
285
|
-
arrow: {
|
|
286
|
-
position: "absolute",
|
|
287
|
-
width: cssVars.arrowSize.reference,
|
|
288
|
-
height: cssVars.arrowSize.reference,
|
|
289
|
-
[cssVars.arrowSizeHalf.variable]: `calc(${cssVars.arrowSize.reference} / 2)`,
|
|
290
|
-
[cssVars.arrowOffset.variable]: `calc(${cssVars.arrowSizeHalf.reference} * -1)`,
|
|
291
|
-
opacity: !measured ? 0 : void 0
|
|
292
|
-
},
|
|
293
|
-
innerArrow: {
|
|
294
|
-
transform: ARROW_FLOATING_STYLE[placement.split("-")[0]],
|
|
295
|
-
background: cssVars.arrowBg.reference,
|
|
296
|
-
top: "0",
|
|
297
|
-
left: "0",
|
|
298
|
-
width: "100%",
|
|
299
|
-
height: "100%",
|
|
300
|
-
position: "absolute",
|
|
301
|
-
zIndex: "inherit"
|
|
302
|
-
},
|
|
303
|
-
floating: {
|
|
304
|
-
position: strategy,
|
|
305
|
-
minWidth: "max-content",
|
|
306
|
-
...!measured && UNMEASURED_FLOATING_STYLE
|
|
307
|
-
}
|
|
308
|
-
};
|
|
309
|
-
}
|
|
310
|
-
export {
|
|
311
|
-
getBasePlacement,
|
|
312
|
-
getPlacement,
|
|
313
|
-
getPlacementStyles
|
|
314
|
-
};
|