@retikolo/drag-drop-content-types-strapi 2.0.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/README.md +77 -0
- package/dist/_chunks/Settings-BUJ6OWyE.js +3632 -0
- package/dist/_chunks/Settings-Cx22s5Bk.mjs +3615 -0
- package/dist/_chunks/en-I3-CH3Sy.js +31 -0
- package/dist/_chunks/en-bxpER_P-.mjs +31 -0
- package/dist/_chunks/fr-C8Qw4iPZ.js +4 -0
- package/dist/_chunks/fr-hkSxFuzl.mjs +4 -0
- package/dist/_chunks/index-CxWC49Ye.mjs +477 -0
- package/dist/_chunks/index-D5Ne-GrP.js +478 -0
- package/dist/admin/index.js +3 -0
- package/dist/admin/index.mjs +4 -0
- package/dist/admin/src/components/Initializer.d.ts +5 -0
- package/dist/admin/src/components/PluginIcon.d.ts +2 -0
- package/dist/admin/src/components/SettingsTextField.d.ts +14 -0
- package/dist/admin/src/components/SettingsToggleField.d.ts +13 -0
- package/dist/admin/src/components/SortModal/CustomItem.d.ts +12 -0
- package/dist/admin/src/components/SortModal/SortMenu.d.ts +3 -0
- package/dist/admin/src/components/SortModal/SortableList.d.ts +3 -0
- package/dist/admin/src/components/SortModal/SortableListItem.d.ts +7 -0
- package/dist/admin/src/components/SortModal/index.d.ts +2 -0
- package/dist/admin/src/components/SortModal/utils.d.ts +2 -0
- package/dist/admin/src/components/TooltipIconButton.d.ts +11 -0
- package/dist/admin/src/index.d.ts +13 -0
- package/dist/admin/src/pages/App.d.ts +2 -0
- package/dist/admin/src/pages/HomePage.d.ts +2 -0
- package/dist/admin/src/pages/Settings.d.ts +2 -0
- package/dist/admin/src/permissions.d.ts +7 -0
- package/dist/admin/src/pluginId.d.ts +1 -0
- package/dist/admin/src/utils/getTranslation.d.ts +2 -0
- package/dist/admin/src/utils/strapi.d.ts +13 -0
- package/dist/admin/src/utils/useQueryParams.d.ts +7 -0
- package/dist/server/index.js +266 -0
- package/dist/server/index.mjs +267 -0
- package/dist/server/src/bootstrap.d.ts +5 -0
- package/dist/server/src/config/index.d.ts +5 -0
- package/dist/server/src/content-types/index.d.ts +2 -0
- package/dist/server/src/controllers/dragdrop.d.ts +9 -0
- package/dist/server/src/controllers/index.d.ts +16 -0
- package/dist/server/src/controllers/settings.d.ts +8 -0
- package/dist/server/src/destroy.d.ts +5 -0
- package/dist/server/src/index.d.ts +79 -0
- package/dist/server/src/middlewares/index.d.ts +2 -0
- package/dist/server/src/policies/index.d.ts +2 -0
- package/dist/server/src/register.d.ts +5 -0
- package/dist/server/src/routes/dragdrop.d.ts +13 -0
- package/dist/server/src/routes/index.d.ts +26 -0
- package/dist/server/src/routes/settings.d.ts +12 -0
- package/dist/server/src/services/dragdrop.d.ts +21 -0
- package/dist/server/src/services/index.d.ts +21 -0
- package/dist/server/src/services/settings.d.ts +8 -0
- package/package.json +98 -0
|
@@ -0,0 +1,3632 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const admin = require("@strapi/strapi/admin");
|
|
6
|
+
const designSystem = require("@strapi/design-system");
|
|
7
|
+
const icons = require("@strapi/icons");
|
|
8
|
+
const reactIntl = require("react-intl");
|
|
9
|
+
const index$1 = require("./index-D5Ne-GrP.js");
|
|
10
|
+
const ReactDOM = require("react-dom");
|
|
11
|
+
function _interopNamespace(e) {
|
|
12
|
+
if (e && e.__esModule) return e;
|
|
13
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
14
|
+
if (e) {
|
|
15
|
+
for (const k in e) {
|
|
16
|
+
if (k !== "default") {
|
|
17
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
18
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: () => e[k]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
n.default = e;
|
|
26
|
+
return Object.freeze(n);
|
|
27
|
+
}
|
|
28
|
+
const React__namespace = /* @__PURE__ */ _interopNamespace(React);
|
|
29
|
+
const ReactDOM__namespace = /* @__PURE__ */ _interopNamespace(ReactDOM);
|
|
30
|
+
function _extends() {
|
|
31
|
+
return _extends = Object.assign ? Object.assign.bind() : function(n) {
|
|
32
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
33
|
+
var t = arguments[e];
|
|
34
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
35
|
+
}
|
|
36
|
+
return n;
|
|
37
|
+
}, _extends.apply(null, arguments);
|
|
38
|
+
}
|
|
39
|
+
function $e42e1063c40fb3ef$export$b9ecd428b558ff10(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
|
|
40
|
+
return function handleEvent(event) {
|
|
41
|
+
originalEventHandler === null || originalEventHandler === void 0 || originalEventHandler(event);
|
|
42
|
+
if (checkForDefaultPrevented === false || !event.defaultPrevented) return ourEventHandler === null || ourEventHandler === void 0 ? void 0 : ourEventHandler(event);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function $6ed0406888f73fc4$var$setRef(ref, value) {
|
|
46
|
+
if (typeof ref === "function") ref(value);
|
|
47
|
+
else if (ref !== null && ref !== void 0) ref.current = value;
|
|
48
|
+
}
|
|
49
|
+
function $6ed0406888f73fc4$export$43e446d32b3d21af(...refs) {
|
|
50
|
+
return (node) => refs.forEach(
|
|
51
|
+
(ref) => $6ed0406888f73fc4$var$setRef(ref, node)
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
function $6ed0406888f73fc4$export$c7b2cbe3552a0d05(...refs) {
|
|
55
|
+
return React.useCallback($6ed0406888f73fc4$export$43e446d32b3d21af(...refs), refs);
|
|
56
|
+
}
|
|
57
|
+
function $c512c27ab02ef895$export$50c7b4e9d9f19c1(scopeName, createContextScopeDeps = []) {
|
|
58
|
+
let defaultContexts = [];
|
|
59
|
+
function $c512c27ab02ef895$export$fd42f52fd3ae1109(rootComponentName, defaultContext) {
|
|
60
|
+
const BaseContext = /* @__PURE__ */ React.createContext(defaultContext);
|
|
61
|
+
const index2 = defaultContexts.length;
|
|
62
|
+
defaultContexts = [
|
|
63
|
+
...defaultContexts,
|
|
64
|
+
defaultContext
|
|
65
|
+
];
|
|
66
|
+
function Provider(props) {
|
|
67
|
+
const { scope, children, ...context } = props;
|
|
68
|
+
const Context = (scope === null || scope === void 0 ? void 0 : scope[scopeName][index2]) || BaseContext;
|
|
69
|
+
const value = React.useMemo(
|
|
70
|
+
() => context,
|
|
71
|
+
Object.values(context)
|
|
72
|
+
);
|
|
73
|
+
return /* @__PURE__ */ React.createElement(Context.Provider, {
|
|
74
|
+
value
|
|
75
|
+
}, children);
|
|
76
|
+
}
|
|
77
|
+
function useContext(consumerName, scope) {
|
|
78
|
+
const Context = (scope === null || scope === void 0 ? void 0 : scope[scopeName][index2]) || BaseContext;
|
|
79
|
+
const context = React.useContext(Context);
|
|
80
|
+
if (context) return context;
|
|
81
|
+
if (defaultContext !== void 0) return defaultContext;
|
|
82
|
+
throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
|
|
83
|
+
}
|
|
84
|
+
Provider.displayName = rootComponentName + "Provider";
|
|
85
|
+
return [
|
|
86
|
+
Provider,
|
|
87
|
+
useContext
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
const createScope = () => {
|
|
91
|
+
const scopeContexts = defaultContexts.map((defaultContext) => {
|
|
92
|
+
return /* @__PURE__ */ React.createContext(defaultContext);
|
|
93
|
+
});
|
|
94
|
+
return function useScope(scope) {
|
|
95
|
+
const contexts = (scope === null || scope === void 0 ? void 0 : scope[scopeName]) || scopeContexts;
|
|
96
|
+
return React.useMemo(
|
|
97
|
+
() => ({
|
|
98
|
+
[`__scope${scopeName}`]: {
|
|
99
|
+
...scope,
|
|
100
|
+
[scopeName]: contexts
|
|
101
|
+
}
|
|
102
|
+
}),
|
|
103
|
+
[
|
|
104
|
+
scope,
|
|
105
|
+
contexts
|
|
106
|
+
]
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
createScope.scopeName = scopeName;
|
|
111
|
+
return [
|
|
112
|
+
$c512c27ab02ef895$export$fd42f52fd3ae1109,
|
|
113
|
+
$c512c27ab02ef895$var$composeContextScopes(createScope, ...createContextScopeDeps)
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
function $c512c27ab02ef895$var$composeContextScopes(...scopes) {
|
|
117
|
+
const baseScope = scopes[0];
|
|
118
|
+
if (scopes.length === 1) return baseScope;
|
|
119
|
+
const createScope1 = () => {
|
|
120
|
+
const scopeHooks = scopes.map(
|
|
121
|
+
(createScope) => ({
|
|
122
|
+
useScope: createScope(),
|
|
123
|
+
scopeName: createScope.scopeName
|
|
124
|
+
})
|
|
125
|
+
);
|
|
126
|
+
return function useComposedScopes(overrideScopes) {
|
|
127
|
+
const nextScopes1 = scopeHooks.reduce((nextScopes, { useScope, scopeName }) => {
|
|
128
|
+
const scopeProps = useScope(overrideScopes);
|
|
129
|
+
const currentScope = scopeProps[`__scope${scopeName}`];
|
|
130
|
+
return {
|
|
131
|
+
...nextScopes,
|
|
132
|
+
...currentScope
|
|
133
|
+
};
|
|
134
|
+
}, {});
|
|
135
|
+
return React.useMemo(
|
|
136
|
+
() => ({
|
|
137
|
+
[`__scope${baseScope.scopeName}`]: nextScopes1
|
|
138
|
+
}),
|
|
139
|
+
[
|
|
140
|
+
nextScopes1
|
|
141
|
+
]
|
|
142
|
+
);
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
createScope1.scopeName = baseScope.scopeName;
|
|
146
|
+
return createScope1;
|
|
147
|
+
}
|
|
148
|
+
const $5e63c961fc1ce211$export$8c6ed5c666ac1360 = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
|
|
149
|
+
const { children, ...slotProps } = props;
|
|
150
|
+
const childrenArray = React.Children.toArray(children);
|
|
151
|
+
const slottable = childrenArray.find($5e63c961fc1ce211$var$isSlottable);
|
|
152
|
+
if (slottable) {
|
|
153
|
+
const newElement = slottable.props.children;
|
|
154
|
+
const newChildren = childrenArray.map((child) => {
|
|
155
|
+
if (child === slottable) {
|
|
156
|
+
if (React.Children.count(newElement) > 1) return React.Children.only(null);
|
|
157
|
+
return /* @__PURE__ */ React.isValidElement(newElement) ? newElement.props.children : null;
|
|
158
|
+
} else return child;
|
|
159
|
+
});
|
|
160
|
+
return /* @__PURE__ */ React.createElement($5e63c961fc1ce211$var$SlotClone, _extends({}, slotProps, {
|
|
161
|
+
ref: forwardedRef
|
|
162
|
+
}), /* @__PURE__ */ React.isValidElement(newElement) ? /* @__PURE__ */ React.cloneElement(newElement, void 0, newChildren) : null);
|
|
163
|
+
}
|
|
164
|
+
return /* @__PURE__ */ React.createElement($5e63c961fc1ce211$var$SlotClone, _extends({}, slotProps, {
|
|
165
|
+
ref: forwardedRef
|
|
166
|
+
}), children);
|
|
167
|
+
});
|
|
168
|
+
$5e63c961fc1ce211$export$8c6ed5c666ac1360.displayName = "Slot";
|
|
169
|
+
const $5e63c961fc1ce211$var$SlotClone = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
|
|
170
|
+
const { children, ...slotProps } = props;
|
|
171
|
+
if (/* @__PURE__ */ React.isValidElement(children)) return /* @__PURE__ */ React.cloneElement(children, {
|
|
172
|
+
...$5e63c961fc1ce211$var$mergeProps(slotProps, children.props),
|
|
173
|
+
ref: forwardedRef ? $6ed0406888f73fc4$export$43e446d32b3d21af(forwardedRef, children.ref) : children.ref
|
|
174
|
+
});
|
|
175
|
+
return React.Children.count(children) > 1 ? React.Children.only(null) : null;
|
|
176
|
+
});
|
|
177
|
+
$5e63c961fc1ce211$var$SlotClone.displayName = "SlotClone";
|
|
178
|
+
const $5e63c961fc1ce211$export$d9f1ccf0bdb05d45 = ({ children }) => {
|
|
179
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
|
|
180
|
+
};
|
|
181
|
+
function $5e63c961fc1ce211$var$isSlottable(child) {
|
|
182
|
+
return /* @__PURE__ */ React.isValidElement(child) && child.type === $5e63c961fc1ce211$export$d9f1ccf0bdb05d45;
|
|
183
|
+
}
|
|
184
|
+
function $5e63c961fc1ce211$var$mergeProps(slotProps, childProps) {
|
|
185
|
+
const overrideProps = {
|
|
186
|
+
...childProps
|
|
187
|
+
};
|
|
188
|
+
for (const propName in childProps) {
|
|
189
|
+
const slotPropValue = slotProps[propName];
|
|
190
|
+
const childPropValue = childProps[propName];
|
|
191
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
192
|
+
if (isHandler) {
|
|
193
|
+
if (slotPropValue && childPropValue) overrideProps[propName] = (...args) => {
|
|
194
|
+
childPropValue(...args);
|
|
195
|
+
slotPropValue(...args);
|
|
196
|
+
};
|
|
197
|
+
else if (slotPropValue) overrideProps[propName] = slotPropValue;
|
|
198
|
+
} else if (propName === "style") overrideProps[propName] = {
|
|
199
|
+
...slotPropValue,
|
|
200
|
+
...childPropValue
|
|
201
|
+
};
|
|
202
|
+
else if (propName === "className") overrideProps[propName] = [
|
|
203
|
+
slotPropValue,
|
|
204
|
+
childPropValue
|
|
205
|
+
].filter(Boolean).join(" ");
|
|
206
|
+
}
|
|
207
|
+
return {
|
|
208
|
+
...slotProps,
|
|
209
|
+
...overrideProps
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
const $8927f6f2acc4f386$var$NODES = [
|
|
213
|
+
"a",
|
|
214
|
+
"button",
|
|
215
|
+
"div",
|
|
216
|
+
"form",
|
|
217
|
+
"h2",
|
|
218
|
+
"h3",
|
|
219
|
+
"img",
|
|
220
|
+
"input",
|
|
221
|
+
"label",
|
|
222
|
+
"li",
|
|
223
|
+
"nav",
|
|
224
|
+
"ol",
|
|
225
|
+
"p",
|
|
226
|
+
"span",
|
|
227
|
+
"svg",
|
|
228
|
+
"ul"
|
|
229
|
+
];
|
|
230
|
+
const $8927f6f2acc4f386$export$250ffa63cdc0d034 = $8927f6f2acc4f386$var$NODES.reduce((primitive, node) => {
|
|
231
|
+
const Node2 = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
|
|
232
|
+
const { asChild, ...primitiveProps } = props;
|
|
233
|
+
const Comp = asChild ? $5e63c961fc1ce211$export$8c6ed5c666ac1360 : node;
|
|
234
|
+
React.useEffect(() => {
|
|
235
|
+
window[Symbol.for("radix-ui")] = true;
|
|
236
|
+
}, []);
|
|
237
|
+
return /* @__PURE__ */ React.createElement(Comp, _extends({}, primitiveProps, {
|
|
238
|
+
ref: forwardedRef
|
|
239
|
+
}));
|
|
240
|
+
});
|
|
241
|
+
Node2.displayName = `Primitive.${node}`;
|
|
242
|
+
return {
|
|
243
|
+
...primitive,
|
|
244
|
+
[node]: Node2
|
|
245
|
+
};
|
|
246
|
+
}, {});
|
|
247
|
+
function $8927f6f2acc4f386$export$6d1a0317bde7de7f(target, event) {
|
|
248
|
+
if (target) ReactDOM.flushSync(
|
|
249
|
+
() => target.dispatchEvent(event)
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
function $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(callback) {
|
|
253
|
+
const callbackRef = React.useRef(callback);
|
|
254
|
+
React.useEffect(() => {
|
|
255
|
+
callbackRef.current = callback;
|
|
256
|
+
});
|
|
257
|
+
return React.useMemo(
|
|
258
|
+
() => (...args) => {
|
|
259
|
+
var _callbackRef$current;
|
|
260
|
+
return (_callbackRef$current = callbackRef.current) === null || _callbackRef$current === void 0 ? void 0 : _callbackRef$current.call(callbackRef, ...args);
|
|
261
|
+
},
|
|
262
|
+
[]
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
function $addc16e1bbe58fd0$export$3a72a57244d6e765(onEscapeKeyDownProp, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) {
|
|
266
|
+
const onEscapeKeyDown = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onEscapeKeyDownProp);
|
|
267
|
+
React.useEffect(() => {
|
|
268
|
+
const handleKeyDown = (event) => {
|
|
269
|
+
if (event.key === "Escape") onEscapeKeyDown(event);
|
|
270
|
+
};
|
|
271
|
+
ownerDocument.addEventListener("keydown", handleKeyDown);
|
|
272
|
+
return () => ownerDocument.removeEventListener("keydown", handleKeyDown);
|
|
273
|
+
}, [
|
|
274
|
+
onEscapeKeyDown,
|
|
275
|
+
ownerDocument
|
|
276
|
+
]);
|
|
277
|
+
}
|
|
278
|
+
const $5cb92bef7577960e$var$CONTEXT_UPDATE = "dismissableLayer.update";
|
|
279
|
+
const $5cb92bef7577960e$var$POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside";
|
|
280
|
+
const $5cb92bef7577960e$var$FOCUS_OUTSIDE = "dismissableLayer.focusOutside";
|
|
281
|
+
let $5cb92bef7577960e$var$originalBodyPointerEvents;
|
|
282
|
+
const $5cb92bef7577960e$var$DismissableLayerContext = /* @__PURE__ */ React.createContext({
|
|
283
|
+
layers: /* @__PURE__ */ new Set(),
|
|
284
|
+
layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
|
|
285
|
+
branches: /* @__PURE__ */ new Set()
|
|
286
|
+
});
|
|
287
|
+
const $5cb92bef7577960e$export$177fb62ff3ec1f22 = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
|
|
288
|
+
var _node$ownerDocument;
|
|
289
|
+
const { disableOutsidePointerEvents = false, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, onDismiss, ...layerProps } = props;
|
|
290
|
+
const context = React.useContext($5cb92bef7577960e$var$DismissableLayerContext);
|
|
291
|
+
const [node1, setNode] = React.useState(null);
|
|
292
|
+
const ownerDocument = (_node$ownerDocument = node1 === null || node1 === void 0 ? void 0 : node1.ownerDocument) !== null && _node$ownerDocument !== void 0 ? _node$ownerDocument : globalThis === null || globalThis === void 0 ? void 0 : globalThis.document;
|
|
293
|
+
const [, force] = React.useState({});
|
|
294
|
+
const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(
|
|
295
|
+
forwardedRef,
|
|
296
|
+
(node) => setNode(node)
|
|
297
|
+
);
|
|
298
|
+
const layers = Array.from(context.layers);
|
|
299
|
+
const [highestLayerWithOutsidePointerEventsDisabled] = [
|
|
300
|
+
...context.layersWithOutsidePointerEventsDisabled
|
|
301
|
+
].slice(-1);
|
|
302
|
+
const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);
|
|
303
|
+
const index2 = node1 ? layers.indexOf(node1) : -1;
|
|
304
|
+
const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
|
|
305
|
+
const isPointerEventsEnabled = index2 >= highestLayerWithOutsidePointerEventsDisabledIndex;
|
|
306
|
+
const pointerDownOutside = $5cb92bef7577960e$var$usePointerDownOutside((event) => {
|
|
307
|
+
const target = event.target;
|
|
308
|
+
const isPointerDownOnBranch = [
|
|
309
|
+
...context.branches
|
|
310
|
+
].some(
|
|
311
|
+
(branch) => branch.contains(target)
|
|
312
|
+
);
|
|
313
|
+
if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
|
|
314
|
+
onPointerDownOutside === null || onPointerDownOutside === void 0 || onPointerDownOutside(event);
|
|
315
|
+
onInteractOutside === null || onInteractOutside === void 0 || onInteractOutside(event);
|
|
316
|
+
if (!event.defaultPrevented) onDismiss === null || onDismiss === void 0 || onDismiss();
|
|
317
|
+
}, ownerDocument);
|
|
318
|
+
const focusOutside = $5cb92bef7577960e$var$useFocusOutside((event) => {
|
|
319
|
+
const target = event.target;
|
|
320
|
+
const isFocusInBranch = [
|
|
321
|
+
...context.branches
|
|
322
|
+
].some(
|
|
323
|
+
(branch) => branch.contains(target)
|
|
324
|
+
);
|
|
325
|
+
if (isFocusInBranch) return;
|
|
326
|
+
onFocusOutside === null || onFocusOutside === void 0 || onFocusOutside(event);
|
|
327
|
+
onInteractOutside === null || onInteractOutside === void 0 || onInteractOutside(event);
|
|
328
|
+
if (!event.defaultPrevented) onDismiss === null || onDismiss === void 0 || onDismiss();
|
|
329
|
+
}, ownerDocument);
|
|
330
|
+
$addc16e1bbe58fd0$export$3a72a57244d6e765((event) => {
|
|
331
|
+
const isHighestLayer = index2 === context.layers.size - 1;
|
|
332
|
+
if (!isHighestLayer) return;
|
|
333
|
+
onEscapeKeyDown === null || onEscapeKeyDown === void 0 || onEscapeKeyDown(event);
|
|
334
|
+
if (!event.defaultPrevented && onDismiss) {
|
|
335
|
+
event.preventDefault();
|
|
336
|
+
onDismiss();
|
|
337
|
+
}
|
|
338
|
+
}, ownerDocument);
|
|
339
|
+
React.useEffect(() => {
|
|
340
|
+
if (!node1) return;
|
|
341
|
+
if (disableOutsidePointerEvents) {
|
|
342
|
+
if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
|
|
343
|
+
$5cb92bef7577960e$var$originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
|
|
344
|
+
ownerDocument.body.style.pointerEvents = "none";
|
|
345
|
+
}
|
|
346
|
+
context.layersWithOutsidePointerEventsDisabled.add(node1);
|
|
347
|
+
}
|
|
348
|
+
context.layers.add(node1);
|
|
349
|
+
$5cb92bef7577960e$var$dispatchUpdate();
|
|
350
|
+
return () => {
|
|
351
|
+
if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) ownerDocument.body.style.pointerEvents = $5cb92bef7577960e$var$originalBodyPointerEvents;
|
|
352
|
+
};
|
|
353
|
+
}, [
|
|
354
|
+
node1,
|
|
355
|
+
ownerDocument,
|
|
356
|
+
disableOutsidePointerEvents,
|
|
357
|
+
context
|
|
358
|
+
]);
|
|
359
|
+
React.useEffect(() => {
|
|
360
|
+
return () => {
|
|
361
|
+
if (!node1) return;
|
|
362
|
+
context.layers.delete(node1);
|
|
363
|
+
context.layersWithOutsidePointerEventsDisabled.delete(node1);
|
|
364
|
+
$5cb92bef7577960e$var$dispatchUpdate();
|
|
365
|
+
};
|
|
366
|
+
}, [
|
|
367
|
+
node1,
|
|
368
|
+
context
|
|
369
|
+
]);
|
|
370
|
+
React.useEffect(() => {
|
|
371
|
+
const handleUpdate = () => force({});
|
|
372
|
+
document.addEventListener($5cb92bef7577960e$var$CONTEXT_UPDATE, handleUpdate);
|
|
373
|
+
return () => document.removeEventListener($5cb92bef7577960e$var$CONTEXT_UPDATE, handleUpdate);
|
|
374
|
+
}, []);
|
|
375
|
+
return /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({}, layerProps, {
|
|
376
|
+
ref: composedRefs,
|
|
377
|
+
style: {
|
|
378
|
+
pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
|
|
379
|
+
...props.style
|
|
380
|
+
},
|
|
381
|
+
onFocusCapture: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onFocusCapture, focusOutside.onFocusCapture),
|
|
382
|
+
onBlurCapture: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onBlurCapture, focusOutside.onBlurCapture),
|
|
383
|
+
onPointerDownCapture: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onPointerDownCapture, pointerDownOutside.onPointerDownCapture)
|
|
384
|
+
}));
|
|
385
|
+
});
|
|
386
|
+
function $5cb92bef7577960e$var$usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) {
|
|
387
|
+
const handlePointerDownOutside = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onPointerDownOutside);
|
|
388
|
+
const isPointerInsideReactTreeRef = React.useRef(false);
|
|
389
|
+
const handleClickRef = React.useRef(() => {
|
|
390
|
+
});
|
|
391
|
+
React.useEffect(() => {
|
|
392
|
+
const handlePointerDown = (event) => {
|
|
393
|
+
if (event.target && !isPointerInsideReactTreeRef.current) {
|
|
394
|
+
let handleAndDispatchPointerDownOutsideEvent = function() {
|
|
395
|
+
$5cb92bef7577960e$var$handleAndDispatchCustomEvent($5cb92bef7577960e$var$POINTER_DOWN_OUTSIDE, handlePointerDownOutside, eventDetail, {
|
|
396
|
+
discrete: true
|
|
397
|
+
});
|
|
398
|
+
};
|
|
399
|
+
const eventDetail = {
|
|
400
|
+
originalEvent: event
|
|
401
|
+
};
|
|
402
|
+
if (event.pointerType === "touch") {
|
|
403
|
+
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
404
|
+
handleClickRef.current = handleAndDispatchPointerDownOutsideEvent;
|
|
405
|
+
ownerDocument.addEventListener("click", handleClickRef.current, {
|
|
406
|
+
once: true
|
|
407
|
+
});
|
|
408
|
+
} else handleAndDispatchPointerDownOutsideEvent();
|
|
409
|
+
} else
|
|
410
|
+
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
411
|
+
isPointerInsideReactTreeRef.current = false;
|
|
412
|
+
};
|
|
413
|
+
const timerId = window.setTimeout(() => {
|
|
414
|
+
ownerDocument.addEventListener("pointerdown", handlePointerDown);
|
|
415
|
+
}, 0);
|
|
416
|
+
return () => {
|
|
417
|
+
window.clearTimeout(timerId);
|
|
418
|
+
ownerDocument.removeEventListener("pointerdown", handlePointerDown);
|
|
419
|
+
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
420
|
+
};
|
|
421
|
+
}, [
|
|
422
|
+
ownerDocument,
|
|
423
|
+
handlePointerDownOutside
|
|
424
|
+
]);
|
|
425
|
+
return {
|
|
426
|
+
// ensures we check React component tree (not just DOM tree)
|
|
427
|
+
onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
function $5cb92bef7577960e$var$useFocusOutside(onFocusOutside, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) {
|
|
431
|
+
const handleFocusOutside = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onFocusOutside);
|
|
432
|
+
const isFocusInsideReactTreeRef = React.useRef(false);
|
|
433
|
+
React.useEffect(() => {
|
|
434
|
+
const handleFocus = (event) => {
|
|
435
|
+
if (event.target && !isFocusInsideReactTreeRef.current) {
|
|
436
|
+
const eventDetail = {
|
|
437
|
+
originalEvent: event
|
|
438
|
+
};
|
|
439
|
+
$5cb92bef7577960e$var$handleAndDispatchCustomEvent($5cb92bef7577960e$var$FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
|
|
440
|
+
discrete: false
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
ownerDocument.addEventListener("focusin", handleFocus);
|
|
445
|
+
return () => ownerDocument.removeEventListener("focusin", handleFocus);
|
|
446
|
+
}, [
|
|
447
|
+
ownerDocument,
|
|
448
|
+
handleFocusOutside
|
|
449
|
+
]);
|
|
450
|
+
return {
|
|
451
|
+
onFocusCapture: () => isFocusInsideReactTreeRef.current = true,
|
|
452
|
+
onBlurCapture: () => isFocusInsideReactTreeRef.current = false
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
function $5cb92bef7577960e$var$dispatchUpdate() {
|
|
456
|
+
const event = new CustomEvent($5cb92bef7577960e$var$CONTEXT_UPDATE);
|
|
457
|
+
document.dispatchEvent(event);
|
|
458
|
+
}
|
|
459
|
+
function $5cb92bef7577960e$var$handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
|
|
460
|
+
const target = detail.originalEvent.target;
|
|
461
|
+
const event = new CustomEvent(name, {
|
|
462
|
+
bubbles: false,
|
|
463
|
+
cancelable: true,
|
|
464
|
+
detail
|
|
465
|
+
});
|
|
466
|
+
if (handler) target.addEventListener(name, handler, {
|
|
467
|
+
once: true
|
|
468
|
+
});
|
|
469
|
+
if (discrete) $8927f6f2acc4f386$export$6d1a0317bde7de7f(target, event);
|
|
470
|
+
else target.dispatchEvent(event);
|
|
471
|
+
}
|
|
472
|
+
const $9f79659886946c16$export$e5c5a5f917a5871c = Boolean(globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) ? React.useLayoutEffect : () => {
|
|
473
|
+
};
|
|
474
|
+
const $1746a345f3d73bb7$var$useReactId = React__namespace["useId".toString()] || (() => void 0);
|
|
475
|
+
let $1746a345f3d73bb7$var$count = 0;
|
|
476
|
+
function $1746a345f3d73bb7$export$f680877a34711e37(deterministicId) {
|
|
477
|
+
const [id, setId] = React__namespace.useState($1746a345f3d73bb7$var$useReactId());
|
|
478
|
+
$9f79659886946c16$export$e5c5a5f917a5871c(() => {
|
|
479
|
+
setId(
|
|
480
|
+
(reactId) => reactId !== null && reactId !== void 0 ? reactId : String($1746a345f3d73bb7$var$count++)
|
|
481
|
+
);
|
|
482
|
+
}, [
|
|
483
|
+
deterministicId
|
|
484
|
+
]);
|
|
485
|
+
return id ? `radix-${id}` : "";
|
|
486
|
+
}
|
|
487
|
+
const sides = ["top", "right", "bottom", "left"];
|
|
488
|
+
const min = Math.min;
|
|
489
|
+
const max = Math.max;
|
|
490
|
+
const round = Math.round;
|
|
491
|
+
const floor = Math.floor;
|
|
492
|
+
const createCoords = (v) => ({
|
|
493
|
+
x: v,
|
|
494
|
+
y: v
|
|
495
|
+
});
|
|
496
|
+
const oppositeSideMap = {
|
|
497
|
+
left: "right",
|
|
498
|
+
right: "left",
|
|
499
|
+
bottom: "top",
|
|
500
|
+
top: "bottom"
|
|
501
|
+
};
|
|
502
|
+
const oppositeAlignmentMap = {
|
|
503
|
+
start: "end",
|
|
504
|
+
end: "start"
|
|
505
|
+
};
|
|
506
|
+
function clamp(start, value, end) {
|
|
507
|
+
return max(start, min(value, end));
|
|
508
|
+
}
|
|
509
|
+
function evaluate(value, param) {
|
|
510
|
+
return typeof value === "function" ? value(param) : value;
|
|
511
|
+
}
|
|
512
|
+
function getSide(placement) {
|
|
513
|
+
return placement.split("-")[0];
|
|
514
|
+
}
|
|
515
|
+
function getAlignment(placement) {
|
|
516
|
+
return placement.split("-")[1];
|
|
517
|
+
}
|
|
518
|
+
function getOppositeAxis(axis) {
|
|
519
|
+
return axis === "x" ? "y" : "x";
|
|
520
|
+
}
|
|
521
|
+
function getAxisLength(axis) {
|
|
522
|
+
return axis === "y" ? "height" : "width";
|
|
523
|
+
}
|
|
524
|
+
const yAxisSides = /* @__PURE__ */ new Set(["top", "bottom"]);
|
|
525
|
+
function getSideAxis(placement) {
|
|
526
|
+
return yAxisSides.has(getSide(placement)) ? "y" : "x";
|
|
527
|
+
}
|
|
528
|
+
function getAlignmentAxis(placement) {
|
|
529
|
+
return getOppositeAxis(getSideAxis(placement));
|
|
530
|
+
}
|
|
531
|
+
function getAlignmentSides(placement, rects, rtl) {
|
|
532
|
+
if (rtl === void 0) {
|
|
533
|
+
rtl = false;
|
|
534
|
+
}
|
|
535
|
+
const alignment = getAlignment(placement);
|
|
536
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
537
|
+
const length = getAxisLength(alignmentAxis);
|
|
538
|
+
let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
|
|
539
|
+
if (rects.reference[length] > rects.floating[length]) {
|
|
540
|
+
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
541
|
+
}
|
|
542
|
+
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
|
543
|
+
}
|
|
544
|
+
function getExpandedPlacements(placement) {
|
|
545
|
+
const oppositePlacement = getOppositePlacement(placement);
|
|
546
|
+
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
547
|
+
}
|
|
548
|
+
function getOppositeAlignmentPlacement(placement) {
|
|
549
|
+
return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
|
|
550
|
+
}
|
|
551
|
+
const lrPlacement = ["left", "right"];
|
|
552
|
+
const rlPlacement = ["right", "left"];
|
|
553
|
+
const tbPlacement = ["top", "bottom"];
|
|
554
|
+
const btPlacement = ["bottom", "top"];
|
|
555
|
+
function getSideList(side, isStart, rtl) {
|
|
556
|
+
switch (side) {
|
|
557
|
+
case "top":
|
|
558
|
+
case "bottom":
|
|
559
|
+
if (rtl) return isStart ? rlPlacement : lrPlacement;
|
|
560
|
+
return isStart ? lrPlacement : rlPlacement;
|
|
561
|
+
case "left":
|
|
562
|
+
case "right":
|
|
563
|
+
return isStart ? tbPlacement : btPlacement;
|
|
564
|
+
default:
|
|
565
|
+
return [];
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
569
|
+
const alignment = getAlignment(placement);
|
|
570
|
+
let list = getSideList(getSide(placement), direction === "start", rtl);
|
|
571
|
+
if (alignment) {
|
|
572
|
+
list = list.map((side) => side + "-" + alignment);
|
|
573
|
+
if (flipAlignment) {
|
|
574
|
+
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
return list;
|
|
578
|
+
}
|
|
579
|
+
function getOppositePlacement(placement) {
|
|
580
|
+
return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
|
|
581
|
+
}
|
|
582
|
+
function expandPaddingObject(padding) {
|
|
583
|
+
return {
|
|
584
|
+
top: 0,
|
|
585
|
+
right: 0,
|
|
586
|
+
bottom: 0,
|
|
587
|
+
left: 0,
|
|
588
|
+
...padding
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
function getPaddingObject(padding) {
|
|
592
|
+
return typeof padding !== "number" ? expandPaddingObject(padding) : {
|
|
593
|
+
top: padding,
|
|
594
|
+
right: padding,
|
|
595
|
+
bottom: padding,
|
|
596
|
+
left: padding
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
function rectToClientRect(rect) {
|
|
600
|
+
const {
|
|
601
|
+
x,
|
|
602
|
+
y,
|
|
603
|
+
width,
|
|
604
|
+
height
|
|
605
|
+
} = rect;
|
|
606
|
+
return {
|
|
607
|
+
width,
|
|
608
|
+
height,
|
|
609
|
+
top: y,
|
|
610
|
+
left: x,
|
|
611
|
+
right: x + width,
|
|
612
|
+
bottom: y + height,
|
|
613
|
+
x,
|
|
614
|
+
y
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
618
|
+
let {
|
|
619
|
+
reference,
|
|
620
|
+
floating
|
|
621
|
+
} = _ref;
|
|
622
|
+
const sideAxis = getSideAxis(placement);
|
|
623
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
624
|
+
const alignLength = getAxisLength(alignmentAxis);
|
|
625
|
+
const side = getSide(placement);
|
|
626
|
+
const isVertical = sideAxis === "y";
|
|
627
|
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
628
|
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
629
|
+
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
|
630
|
+
let coords;
|
|
631
|
+
switch (side) {
|
|
632
|
+
case "top":
|
|
633
|
+
coords = {
|
|
634
|
+
x: commonX,
|
|
635
|
+
y: reference.y - floating.height
|
|
636
|
+
};
|
|
637
|
+
break;
|
|
638
|
+
case "bottom":
|
|
639
|
+
coords = {
|
|
640
|
+
x: commonX,
|
|
641
|
+
y: reference.y + reference.height
|
|
642
|
+
};
|
|
643
|
+
break;
|
|
644
|
+
case "right":
|
|
645
|
+
coords = {
|
|
646
|
+
x: reference.x + reference.width,
|
|
647
|
+
y: commonY
|
|
648
|
+
};
|
|
649
|
+
break;
|
|
650
|
+
case "left":
|
|
651
|
+
coords = {
|
|
652
|
+
x: reference.x - floating.width,
|
|
653
|
+
y: commonY
|
|
654
|
+
};
|
|
655
|
+
break;
|
|
656
|
+
default:
|
|
657
|
+
coords = {
|
|
658
|
+
x: reference.x,
|
|
659
|
+
y: reference.y
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
switch (getAlignment(placement)) {
|
|
663
|
+
case "start":
|
|
664
|
+
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
665
|
+
break;
|
|
666
|
+
case "end":
|
|
667
|
+
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
668
|
+
break;
|
|
669
|
+
}
|
|
670
|
+
return coords;
|
|
671
|
+
}
|
|
672
|
+
async function detectOverflow(state, options) {
|
|
673
|
+
var _await$platform$isEle;
|
|
674
|
+
if (options === void 0) {
|
|
675
|
+
options = {};
|
|
676
|
+
}
|
|
677
|
+
const {
|
|
678
|
+
x,
|
|
679
|
+
y,
|
|
680
|
+
platform: platform2,
|
|
681
|
+
rects,
|
|
682
|
+
elements,
|
|
683
|
+
strategy
|
|
684
|
+
} = state;
|
|
685
|
+
const {
|
|
686
|
+
boundary = "clippingAncestors",
|
|
687
|
+
rootBoundary = "viewport",
|
|
688
|
+
elementContext = "floating",
|
|
689
|
+
altBoundary = false,
|
|
690
|
+
padding = 0
|
|
691
|
+
} = evaluate(options, state);
|
|
692
|
+
const paddingObject = getPaddingObject(padding);
|
|
693
|
+
const altContext = elementContext === "floating" ? "reference" : "floating";
|
|
694
|
+
const element = elements[altBoundary ? altContext : elementContext];
|
|
695
|
+
const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
|
|
696
|
+
element: ((_await$platform$isEle = await (platform2.isElement == null ? void 0 : platform2.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)),
|
|
697
|
+
boundary,
|
|
698
|
+
rootBoundary,
|
|
699
|
+
strategy
|
|
700
|
+
}));
|
|
701
|
+
const rect = elementContext === "floating" ? {
|
|
702
|
+
x,
|
|
703
|
+
y,
|
|
704
|
+
width: rects.floating.width,
|
|
705
|
+
height: rects.floating.height
|
|
706
|
+
} : rects.reference;
|
|
707
|
+
const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
|
|
708
|
+
const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
|
|
709
|
+
x: 1,
|
|
710
|
+
y: 1
|
|
711
|
+
} : {
|
|
712
|
+
x: 1,
|
|
713
|
+
y: 1
|
|
714
|
+
};
|
|
715
|
+
const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
716
|
+
elements,
|
|
717
|
+
rect,
|
|
718
|
+
offsetParent,
|
|
719
|
+
strategy
|
|
720
|
+
}) : rect);
|
|
721
|
+
return {
|
|
722
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
723
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
724
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
725
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
const computePosition$1 = async (reference, floating, config) => {
|
|
729
|
+
const {
|
|
730
|
+
placement = "bottom",
|
|
731
|
+
strategy = "absolute",
|
|
732
|
+
middleware = [],
|
|
733
|
+
platform: platform2
|
|
734
|
+
} = config;
|
|
735
|
+
const validMiddleware = middleware.filter(Boolean);
|
|
736
|
+
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
|
|
737
|
+
let rects = await platform2.getElementRects({
|
|
738
|
+
reference,
|
|
739
|
+
floating,
|
|
740
|
+
strategy
|
|
741
|
+
});
|
|
742
|
+
let {
|
|
743
|
+
x,
|
|
744
|
+
y
|
|
745
|
+
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
746
|
+
let statefulPlacement = placement;
|
|
747
|
+
let middlewareData = {};
|
|
748
|
+
let resetCount = 0;
|
|
749
|
+
for (let i = 0; i < validMiddleware.length; i++) {
|
|
750
|
+
var _platform$detectOverf;
|
|
751
|
+
const {
|
|
752
|
+
name,
|
|
753
|
+
fn
|
|
754
|
+
} = validMiddleware[i];
|
|
755
|
+
const {
|
|
756
|
+
x: nextX,
|
|
757
|
+
y: nextY,
|
|
758
|
+
data,
|
|
759
|
+
reset
|
|
760
|
+
} = await fn({
|
|
761
|
+
x,
|
|
762
|
+
y,
|
|
763
|
+
initialPlacement: placement,
|
|
764
|
+
placement: statefulPlacement,
|
|
765
|
+
strategy,
|
|
766
|
+
middlewareData,
|
|
767
|
+
rects,
|
|
768
|
+
platform: {
|
|
769
|
+
...platform2,
|
|
770
|
+
detectOverflow: (_platform$detectOverf = platform2.detectOverflow) != null ? _platform$detectOverf : detectOverflow
|
|
771
|
+
},
|
|
772
|
+
elements: {
|
|
773
|
+
reference,
|
|
774
|
+
floating
|
|
775
|
+
}
|
|
776
|
+
});
|
|
777
|
+
x = nextX != null ? nextX : x;
|
|
778
|
+
y = nextY != null ? nextY : y;
|
|
779
|
+
middlewareData = {
|
|
780
|
+
...middlewareData,
|
|
781
|
+
[name]: {
|
|
782
|
+
...middlewareData[name],
|
|
783
|
+
...data
|
|
784
|
+
}
|
|
785
|
+
};
|
|
786
|
+
if (reset && resetCount <= 50) {
|
|
787
|
+
resetCount++;
|
|
788
|
+
if (typeof reset === "object") {
|
|
789
|
+
if (reset.placement) {
|
|
790
|
+
statefulPlacement = reset.placement;
|
|
791
|
+
}
|
|
792
|
+
if (reset.rects) {
|
|
793
|
+
rects = reset.rects === true ? await platform2.getElementRects({
|
|
794
|
+
reference,
|
|
795
|
+
floating,
|
|
796
|
+
strategy
|
|
797
|
+
}) : reset.rects;
|
|
798
|
+
}
|
|
799
|
+
({
|
|
800
|
+
x,
|
|
801
|
+
y
|
|
802
|
+
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
803
|
+
}
|
|
804
|
+
i = -1;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
return {
|
|
808
|
+
x,
|
|
809
|
+
y,
|
|
810
|
+
placement: statefulPlacement,
|
|
811
|
+
strategy,
|
|
812
|
+
middlewareData
|
|
813
|
+
};
|
|
814
|
+
};
|
|
815
|
+
const arrow$3 = (options) => ({
|
|
816
|
+
name: "arrow",
|
|
817
|
+
options,
|
|
818
|
+
async fn(state) {
|
|
819
|
+
const {
|
|
820
|
+
x,
|
|
821
|
+
y,
|
|
822
|
+
placement,
|
|
823
|
+
rects,
|
|
824
|
+
platform: platform2,
|
|
825
|
+
elements,
|
|
826
|
+
middlewareData
|
|
827
|
+
} = state;
|
|
828
|
+
const {
|
|
829
|
+
element,
|
|
830
|
+
padding = 0
|
|
831
|
+
} = evaluate(options, state) || {};
|
|
832
|
+
if (element == null) {
|
|
833
|
+
return {};
|
|
834
|
+
}
|
|
835
|
+
const paddingObject = getPaddingObject(padding);
|
|
836
|
+
const coords = {
|
|
837
|
+
x,
|
|
838
|
+
y
|
|
839
|
+
};
|
|
840
|
+
const axis = getAlignmentAxis(placement);
|
|
841
|
+
const length = getAxisLength(axis);
|
|
842
|
+
const arrowDimensions = await platform2.getDimensions(element);
|
|
843
|
+
const isYAxis = axis === "y";
|
|
844
|
+
const minProp = isYAxis ? "top" : "left";
|
|
845
|
+
const maxProp = isYAxis ? "bottom" : "right";
|
|
846
|
+
const clientProp = isYAxis ? "clientHeight" : "clientWidth";
|
|
847
|
+
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
848
|
+
const startDiff = coords[axis] - rects.reference[axis];
|
|
849
|
+
const arrowOffsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(element));
|
|
850
|
+
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
|
851
|
+
if (!clientSize || !await (platform2.isElement == null ? void 0 : platform2.isElement(arrowOffsetParent))) {
|
|
852
|
+
clientSize = elements.floating[clientProp] || rects.floating[length];
|
|
853
|
+
}
|
|
854
|
+
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
855
|
+
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
|
856
|
+
const minPadding = min(paddingObject[minProp], largestPossiblePadding);
|
|
857
|
+
const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
|
|
858
|
+
const min$1 = minPadding;
|
|
859
|
+
const max2 = clientSize - arrowDimensions[length] - maxPadding;
|
|
860
|
+
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
861
|
+
const offset2 = clamp(min$1, center, max2);
|
|
862
|
+
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset2 && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
|
863
|
+
const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max2 : 0;
|
|
864
|
+
return {
|
|
865
|
+
[axis]: coords[axis] + alignmentOffset,
|
|
866
|
+
data: {
|
|
867
|
+
[axis]: offset2,
|
|
868
|
+
centerOffset: center - offset2 - alignmentOffset,
|
|
869
|
+
...shouldAddOffset && {
|
|
870
|
+
alignmentOffset
|
|
871
|
+
}
|
|
872
|
+
},
|
|
873
|
+
reset: shouldAddOffset
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
});
|
|
877
|
+
const flip$2 = function(options) {
|
|
878
|
+
if (options === void 0) {
|
|
879
|
+
options = {};
|
|
880
|
+
}
|
|
881
|
+
return {
|
|
882
|
+
name: "flip",
|
|
883
|
+
options,
|
|
884
|
+
async fn(state) {
|
|
885
|
+
var _middlewareData$arrow, _middlewareData$flip;
|
|
886
|
+
const {
|
|
887
|
+
placement,
|
|
888
|
+
middlewareData,
|
|
889
|
+
rects,
|
|
890
|
+
initialPlacement,
|
|
891
|
+
platform: platform2,
|
|
892
|
+
elements
|
|
893
|
+
} = state;
|
|
894
|
+
const {
|
|
895
|
+
mainAxis: checkMainAxis = true,
|
|
896
|
+
crossAxis: checkCrossAxis = true,
|
|
897
|
+
fallbackPlacements: specifiedFallbackPlacements,
|
|
898
|
+
fallbackStrategy = "bestFit",
|
|
899
|
+
fallbackAxisSideDirection = "none",
|
|
900
|
+
flipAlignment = true,
|
|
901
|
+
...detectOverflowOptions
|
|
902
|
+
} = evaluate(options, state);
|
|
903
|
+
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
904
|
+
return {};
|
|
905
|
+
}
|
|
906
|
+
const side = getSide(placement);
|
|
907
|
+
const initialSideAxis = getSideAxis(initialPlacement);
|
|
908
|
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
909
|
+
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
|
|
910
|
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
911
|
+
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
|
|
912
|
+
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
|
|
913
|
+
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
914
|
+
}
|
|
915
|
+
const placements = [initialPlacement, ...fallbackPlacements];
|
|
916
|
+
const overflow = await platform2.detectOverflow(state, detectOverflowOptions);
|
|
917
|
+
const overflows = [];
|
|
918
|
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
919
|
+
if (checkMainAxis) {
|
|
920
|
+
overflows.push(overflow[side]);
|
|
921
|
+
}
|
|
922
|
+
if (checkCrossAxis) {
|
|
923
|
+
const sides2 = getAlignmentSides(placement, rects, rtl);
|
|
924
|
+
overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
|
|
925
|
+
}
|
|
926
|
+
overflowsData = [...overflowsData, {
|
|
927
|
+
placement,
|
|
928
|
+
overflows
|
|
929
|
+
}];
|
|
930
|
+
if (!overflows.every((side2) => side2 <= 0)) {
|
|
931
|
+
var _middlewareData$flip2, _overflowsData$filter;
|
|
932
|
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
933
|
+
const nextPlacement = placements[nextIndex];
|
|
934
|
+
if (nextPlacement) {
|
|
935
|
+
const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
|
|
936
|
+
if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
|
|
937
|
+
// overflows the main axis.
|
|
938
|
+
overflowsData.every((d) => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
|
|
939
|
+
return {
|
|
940
|
+
data: {
|
|
941
|
+
index: nextIndex,
|
|
942
|
+
overflows: overflowsData
|
|
943
|
+
},
|
|
944
|
+
reset: {
|
|
945
|
+
placement: nextPlacement
|
|
946
|
+
}
|
|
947
|
+
};
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
let resetPlacement = (_overflowsData$filter = overflowsData.filter((d) => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
|
|
951
|
+
if (!resetPlacement) {
|
|
952
|
+
switch (fallbackStrategy) {
|
|
953
|
+
case "bestFit": {
|
|
954
|
+
var _overflowsData$filter2;
|
|
955
|
+
const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => {
|
|
956
|
+
if (hasFallbackAxisSideDirection) {
|
|
957
|
+
const currentSideAxis = getSideAxis(d.placement);
|
|
958
|
+
return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
|
|
959
|
+
// reading directions favoring greater width.
|
|
960
|
+
currentSideAxis === "y";
|
|
961
|
+
}
|
|
962
|
+
return true;
|
|
963
|
+
}).map((d) => [d.placement, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
|
|
964
|
+
if (placement2) {
|
|
965
|
+
resetPlacement = placement2;
|
|
966
|
+
}
|
|
967
|
+
break;
|
|
968
|
+
}
|
|
969
|
+
case "initialPlacement":
|
|
970
|
+
resetPlacement = initialPlacement;
|
|
971
|
+
break;
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
if (placement !== resetPlacement) {
|
|
975
|
+
return {
|
|
976
|
+
reset: {
|
|
977
|
+
placement: resetPlacement
|
|
978
|
+
}
|
|
979
|
+
};
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
return {};
|
|
983
|
+
}
|
|
984
|
+
};
|
|
985
|
+
};
|
|
986
|
+
function getSideOffsets(overflow, rect) {
|
|
987
|
+
return {
|
|
988
|
+
top: overflow.top - rect.height,
|
|
989
|
+
right: overflow.right - rect.width,
|
|
990
|
+
bottom: overflow.bottom - rect.height,
|
|
991
|
+
left: overflow.left - rect.width
|
|
992
|
+
};
|
|
993
|
+
}
|
|
994
|
+
function isAnySideFullyClipped(overflow) {
|
|
995
|
+
return sides.some((side) => overflow[side] >= 0);
|
|
996
|
+
}
|
|
997
|
+
const hide$2 = function(options) {
|
|
998
|
+
if (options === void 0) {
|
|
999
|
+
options = {};
|
|
1000
|
+
}
|
|
1001
|
+
return {
|
|
1002
|
+
name: "hide",
|
|
1003
|
+
options,
|
|
1004
|
+
async fn(state) {
|
|
1005
|
+
const {
|
|
1006
|
+
rects,
|
|
1007
|
+
platform: platform2
|
|
1008
|
+
} = state;
|
|
1009
|
+
const {
|
|
1010
|
+
strategy = "referenceHidden",
|
|
1011
|
+
...detectOverflowOptions
|
|
1012
|
+
} = evaluate(options, state);
|
|
1013
|
+
switch (strategy) {
|
|
1014
|
+
case "referenceHidden": {
|
|
1015
|
+
const overflow = await platform2.detectOverflow(state, {
|
|
1016
|
+
...detectOverflowOptions,
|
|
1017
|
+
elementContext: "reference"
|
|
1018
|
+
});
|
|
1019
|
+
const offsets = getSideOffsets(overflow, rects.reference);
|
|
1020
|
+
return {
|
|
1021
|
+
data: {
|
|
1022
|
+
referenceHiddenOffsets: offsets,
|
|
1023
|
+
referenceHidden: isAnySideFullyClipped(offsets)
|
|
1024
|
+
}
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
1027
|
+
case "escaped": {
|
|
1028
|
+
const overflow = await platform2.detectOverflow(state, {
|
|
1029
|
+
...detectOverflowOptions,
|
|
1030
|
+
altBoundary: true
|
|
1031
|
+
});
|
|
1032
|
+
const offsets = getSideOffsets(overflow, rects.floating);
|
|
1033
|
+
return {
|
|
1034
|
+
data: {
|
|
1035
|
+
escapedOffsets: offsets,
|
|
1036
|
+
escaped: isAnySideFullyClipped(offsets)
|
|
1037
|
+
}
|
|
1038
|
+
};
|
|
1039
|
+
}
|
|
1040
|
+
default: {
|
|
1041
|
+
return {};
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
};
|
|
1046
|
+
};
|
|
1047
|
+
const originSides = /* @__PURE__ */ new Set(["left", "top"]);
|
|
1048
|
+
async function convertValueToCoords(state, options) {
|
|
1049
|
+
const {
|
|
1050
|
+
placement,
|
|
1051
|
+
platform: platform2,
|
|
1052
|
+
elements
|
|
1053
|
+
} = state;
|
|
1054
|
+
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
|
|
1055
|
+
const side = getSide(placement);
|
|
1056
|
+
const alignment = getAlignment(placement);
|
|
1057
|
+
const isVertical = getSideAxis(placement) === "y";
|
|
1058
|
+
const mainAxisMulti = originSides.has(side) ? -1 : 1;
|
|
1059
|
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
1060
|
+
const rawValue = evaluate(options, state);
|
|
1061
|
+
let {
|
|
1062
|
+
mainAxis,
|
|
1063
|
+
crossAxis,
|
|
1064
|
+
alignmentAxis
|
|
1065
|
+
} = typeof rawValue === "number" ? {
|
|
1066
|
+
mainAxis: rawValue,
|
|
1067
|
+
crossAxis: 0,
|
|
1068
|
+
alignmentAxis: null
|
|
1069
|
+
} : {
|
|
1070
|
+
mainAxis: rawValue.mainAxis || 0,
|
|
1071
|
+
crossAxis: rawValue.crossAxis || 0,
|
|
1072
|
+
alignmentAxis: rawValue.alignmentAxis
|
|
1073
|
+
};
|
|
1074
|
+
if (alignment && typeof alignmentAxis === "number") {
|
|
1075
|
+
crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
|
|
1076
|
+
}
|
|
1077
|
+
return isVertical ? {
|
|
1078
|
+
x: crossAxis * crossAxisMulti,
|
|
1079
|
+
y: mainAxis * mainAxisMulti
|
|
1080
|
+
} : {
|
|
1081
|
+
x: mainAxis * mainAxisMulti,
|
|
1082
|
+
y: crossAxis * crossAxisMulti
|
|
1083
|
+
};
|
|
1084
|
+
}
|
|
1085
|
+
const offset$2 = function(options) {
|
|
1086
|
+
if (options === void 0) {
|
|
1087
|
+
options = 0;
|
|
1088
|
+
}
|
|
1089
|
+
return {
|
|
1090
|
+
name: "offset",
|
|
1091
|
+
options,
|
|
1092
|
+
async fn(state) {
|
|
1093
|
+
var _middlewareData$offse, _middlewareData$arrow;
|
|
1094
|
+
const {
|
|
1095
|
+
x,
|
|
1096
|
+
y,
|
|
1097
|
+
placement,
|
|
1098
|
+
middlewareData
|
|
1099
|
+
} = state;
|
|
1100
|
+
const diffCoords = await convertValueToCoords(state, options);
|
|
1101
|
+
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
1102
|
+
return {};
|
|
1103
|
+
}
|
|
1104
|
+
return {
|
|
1105
|
+
x: x + diffCoords.x,
|
|
1106
|
+
y: y + diffCoords.y,
|
|
1107
|
+
data: {
|
|
1108
|
+
...diffCoords,
|
|
1109
|
+
placement
|
|
1110
|
+
}
|
|
1111
|
+
};
|
|
1112
|
+
}
|
|
1113
|
+
};
|
|
1114
|
+
};
|
|
1115
|
+
const shift$2 = function(options) {
|
|
1116
|
+
if (options === void 0) {
|
|
1117
|
+
options = {};
|
|
1118
|
+
}
|
|
1119
|
+
return {
|
|
1120
|
+
name: "shift",
|
|
1121
|
+
options,
|
|
1122
|
+
async fn(state) {
|
|
1123
|
+
const {
|
|
1124
|
+
x,
|
|
1125
|
+
y,
|
|
1126
|
+
placement,
|
|
1127
|
+
platform: platform2
|
|
1128
|
+
} = state;
|
|
1129
|
+
const {
|
|
1130
|
+
mainAxis: checkMainAxis = true,
|
|
1131
|
+
crossAxis: checkCrossAxis = false,
|
|
1132
|
+
limiter = {
|
|
1133
|
+
fn: (_ref) => {
|
|
1134
|
+
let {
|
|
1135
|
+
x: x2,
|
|
1136
|
+
y: y2
|
|
1137
|
+
} = _ref;
|
|
1138
|
+
return {
|
|
1139
|
+
x: x2,
|
|
1140
|
+
y: y2
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1143
|
+
},
|
|
1144
|
+
...detectOverflowOptions
|
|
1145
|
+
} = evaluate(options, state);
|
|
1146
|
+
const coords = {
|
|
1147
|
+
x,
|
|
1148
|
+
y
|
|
1149
|
+
};
|
|
1150
|
+
const overflow = await platform2.detectOverflow(state, detectOverflowOptions);
|
|
1151
|
+
const crossAxis = getSideAxis(getSide(placement));
|
|
1152
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
1153
|
+
let mainAxisCoord = coords[mainAxis];
|
|
1154
|
+
let crossAxisCoord = coords[crossAxis];
|
|
1155
|
+
if (checkMainAxis) {
|
|
1156
|
+
const minSide = mainAxis === "y" ? "top" : "left";
|
|
1157
|
+
const maxSide = mainAxis === "y" ? "bottom" : "right";
|
|
1158
|
+
const min2 = mainAxisCoord + overflow[minSide];
|
|
1159
|
+
const max2 = mainAxisCoord - overflow[maxSide];
|
|
1160
|
+
mainAxisCoord = clamp(min2, mainAxisCoord, max2);
|
|
1161
|
+
}
|
|
1162
|
+
if (checkCrossAxis) {
|
|
1163
|
+
const minSide = crossAxis === "y" ? "top" : "left";
|
|
1164
|
+
const maxSide = crossAxis === "y" ? "bottom" : "right";
|
|
1165
|
+
const min2 = crossAxisCoord + overflow[minSide];
|
|
1166
|
+
const max2 = crossAxisCoord - overflow[maxSide];
|
|
1167
|
+
crossAxisCoord = clamp(min2, crossAxisCoord, max2);
|
|
1168
|
+
}
|
|
1169
|
+
const limitedCoords = limiter.fn({
|
|
1170
|
+
...state,
|
|
1171
|
+
[mainAxis]: mainAxisCoord,
|
|
1172
|
+
[crossAxis]: crossAxisCoord
|
|
1173
|
+
});
|
|
1174
|
+
return {
|
|
1175
|
+
...limitedCoords,
|
|
1176
|
+
data: {
|
|
1177
|
+
x: limitedCoords.x - x,
|
|
1178
|
+
y: limitedCoords.y - y,
|
|
1179
|
+
enabled: {
|
|
1180
|
+
[mainAxis]: checkMainAxis,
|
|
1181
|
+
[crossAxis]: checkCrossAxis
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
};
|
|
1185
|
+
}
|
|
1186
|
+
};
|
|
1187
|
+
};
|
|
1188
|
+
const limitShift$2 = function(options) {
|
|
1189
|
+
if (options === void 0) {
|
|
1190
|
+
options = {};
|
|
1191
|
+
}
|
|
1192
|
+
return {
|
|
1193
|
+
options,
|
|
1194
|
+
fn(state) {
|
|
1195
|
+
const {
|
|
1196
|
+
x,
|
|
1197
|
+
y,
|
|
1198
|
+
placement,
|
|
1199
|
+
rects,
|
|
1200
|
+
middlewareData
|
|
1201
|
+
} = state;
|
|
1202
|
+
const {
|
|
1203
|
+
offset: offset2 = 0,
|
|
1204
|
+
mainAxis: checkMainAxis = true,
|
|
1205
|
+
crossAxis: checkCrossAxis = true
|
|
1206
|
+
} = evaluate(options, state);
|
|
1207
|
+
const coords = {
|
|
1208
|
+
x,
|
|
1209
|
+
y
|
|
1210
|
+
};
|
|
1211
|
+
const crossAxis = getSideAxis(placement);
|
|
1212
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
1213
|
+
let mainAxisCoord = coords[mainAxis];
|
|
1214
|
+
let crossAxisCoord = coords[crossAxis];
|
|
1215
|
+
const rawOffset = evaluate(offset2, state);
|
|
1216
|
+
const computedOffset = typeof rawOffset === "number" ? {
|
|
1217
|
+
mainAxis: rawOffset,
|
|
1218
|
+
crossAxis: 0
|
|
1219
|
+
} : {
|
|
1220
|
+
mainAxis: 0,
|
|
1221
|
+
crossAxis: 0,
|
|
1222
|
+
...rawOffset
|
|
1223
|
+
};
|
|
1224
|
+
if (checkMainAxis) {
|
|
1225
|
+
const len = mainAxis === "y" ? "height" : "width";
|
|
1226
|
+
const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
|
|
1227
|
+
const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
|
|
1228
|
+
if (mainAxisCoord < limitMin) {
|
|
1229
|
+
mainAxisCoord = limitMin;
|
|
1230
|
+
} else if (mainAxisCoord > limitMax) {
|
|
1231
|
+
mainAxisCoord = limitMax;
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
if (checkCrossAxis) {
|
|
1235
|
+
var _middlewareData$offse, _middlewareData$offse2;
|
|
1236
|
+
const len = mainAxis === "y" ? "width" : "height";
|
|
1237
|
+
const isOriginSide = originSides.has(getSide(placement));
|
|
1238
|
+
const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
|
|
1239
|
+
const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
|
|
1240
|
+
if (crossAxisCoord < limitMin) {
|
|
1241
|
+
crossAxisCoord = limitMin;
|
|
1242
|
+
} else if (crossAxisCoord > limitMax) {
|
|
1243
|
+
crossAxisCoord = limitMax;
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
return {
|
|
1247
|
+
[mainAxis]: mainAxisCoord,
|
|
1248
|
+
[crossAxis]: crossAxisCoord
|
|
1249
|
+
};
|
|
1250
|
+
}
|
|
1251
|
+
};
|
|
1252
|
+
};
|
|
1253
|
+
const size$2 = function(options) {
|
|
1254
|
+
if (options === void 0) {
|
|
1255
|
+
options = {};
|
|
1256
|
+
}
|
|
1257
|
+
return {
|
|
1258
|
+
name: "size",
|
|
1259
|
+
options,
|
|
1260
|
+
async fn(state) {
|
|
1261
|
+
var _state$middlewareData, _state$middlewareData2;
|
|
1262
|
+
const {
|
|
1263
|
+
placement,
|
|
1264
|
+
rects,
|
|
1265
|
+
platform: platform2,
|
|
1266
|
+
elements
|
|
1267
|
+
} = state;
|
|
1268
|
+
const {
|
|
1269
|
+
apply = () => {
|
|
1270
|
+
},
|
|
1271
|
+
...detectOverflowOptions
|
|
1272
|
+
} = evaluate(options, state);
|
|
1273
|
+
const overflow = await platform2.detectOverflow(state, detectOverflowOptions);
|
|
1274
|
+
const side = getSide(placement);
|
|
1275
|
+
const alignment = getAlignment(placement);
|
|
1276
|
+
const isYAxis = getSideAxis(placement) === "y";
|
|
1277
|
+
const {
|
|
1278
|
+
width,
|
|
1279
|
+
height
|
|
1280
|
+
} = rects.floating;
|
|
1281
|
+
let heightSide;
|
|
1282
|
+
let widthSide;
|
|
1283
|
+
if (side === "top" || side === "bottom") {
|
|
1284
|
+
heightSide = side;
|
|
1285
|
+
widthSide = alignment === (await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
|
|
1286
|
+
} else {
|
|
1287
|
+
widthSide = side;
|
|
1288
|
+
heightSide = alignment === "end" ? "top" : "bottom";
|
|
1289
|
+
}
|
|
1290
|
+
const maximumClippingHeight = height - overflow.top - overflow.bottom;
|
|
1291
|
+
const maximumClippingWidth = width - overflow.left - overflow.right;
|
|
1292
|
+
const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
|
|
1293
|
+
const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
|
|
1294
|
+
const noShift = !state.middlewareData.shift;
|
|
1295
|
+
let availableHeight = overflowAvailableHeight;
|
|
1296
|
+
let availableWidth = overflowAvailableWidth;
|
|
1297
|
+
if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
|
|
1298
|
+
availableWidth = maximumClippingWidth;
|
|
1299
|
+
}
|
|
1300
|
+
if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
|
|
1301
|
+
availableHeight = maximumClippingHeight;
|
|
1302
|
+
}
|
|
1303
|
+
if (noShift && !alignment) {
|
|
1304
|
+
const xMin = max(overflow.left, 0);
|
|
1305
|
+
const xMax = max(overflow.right, 0);
|
|
1306
|
+
const yMin = max(overflow.top, 0);
|
|
1307
|
+
const yMax = max(overflow.bottom, 0);
|
|
1308
|
+
if (isYAxis) {
|
|
1309
|
+
availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
|
|
1310
|
+
} else {
|
|
1311
|
+
availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
await apply({
|
|
1315
|
+
...state,
|
|
1316
|
+
availableWidth,
|
|
1317
|
+
availableHeight
|
|
1318
|
+
});
|
|
1319
|
+
const nextDimensions = await platform2.getDimensions(elements.floating);
|
|
1320
|
+
if (width !== nextDimensions.width || height !== nextDimensions.height) {
|
|
1321
|
+
return {
|
|
1322
|
+
reset: {
|
|
1323
|
+
rects: true
|
|
1324
|
+
}
|
|
1325
|
+
};
|
|
1326
|
+
}
|
|
1327
|
+
return {};
|
|
1328
|
+
}
|
|
1329
|
+
};
|
|
1330
|
+
};
|
|
1331
|
+
function hasWindow() {
|
|
1332
|
+
return typeof window !== "undefined";
|
|
1333
|
+
}
|
|
1334
|
+
function getNodeName(node) {
|
|
1335
|
+
if (isNode(node)) {
|
|
1336
|
+
return (node.nodeName || "").toLowerCase();
|
|
1337
|
+
}
|
|
1338
|
+
return "#document";
|
|
1339
|
+
}
|
|
1340
|
+
function getWindow(node) {
|
|
1341
|
+
var _node$ownerDocument;
|
|
1342
|
+
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
1343
|
+
}
|
|
1344
|
+
function getDocumentElement(node) {
|
|
1345
|
+
var _ref;
|
|
1346
|
+
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
1347
|
+
}
|
|
1348
|
+
function isNode(value) {
|
|
1349
|
+
if (!hasWindow()) {
|
|
1350
|
+
return false;
|
|
1351
|
+
}
|
|
1352
|
+
return value instanceof Node || value instanceof getWindow(value).Node;
|
|
1353
|
+
}
|
|
1354
|
+
function isElement(value) {
|
|
1355
|
+
if (!hasWindow()) {
|
|
1356
|
+
return false;
|
|
1357
|
+
}
|
|
1358
|
+
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
1359
|
+
}
|
|
1360
|
+
function isHTMLElement(value) {
|
|
1361
|
+
if (!hasWindow()) {
|
|
1362
|
+
return false;
|
|
1363
|
+
}
|
|
1364
|
+
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
1365
|
+
}
|
|
1366
|
+
function isShadowRoot(value) {
|
|
1367
|
+
if (!hasWindow() || typeof ShadowRoot === "undefined") {
|
|
1368
|
+
return false;
|
|
1369
|
+
}
|
|
1370
|
+
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
1371
|
+
}
|
|
1372
|
+
const invalidOverflowDisplayValues = /* @__PURE__ */ new Set(["inline", "contents"]);
|
|
1373
|
+
function isOverflowElement(element) {
|
|
1374
|
+
const {
|
|
1375
|
+
overflow,
|
|
1376
|
+
overflowX,
|
|
1377
|
+
overflowY,
|
|
1378
|
+
display
|
|
1379
|
+
} = getComputedStyle$1(element);
|
|
1380
|
+
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
|
|
1381
|
+
}
|
|
1382
|
+
const tableElements = /* @__PURE__ */ new Set(["table", "td", "th"]);
|
|
1383
|
+
function isTableElement(element) {
|
|
1384
|
+
return tableElements.has(getNodeName(element));
|
|
1385
|
+
}
|
|
1386
|
+
const topLayerSelectors = [":popover-open", ":modal"];
|
|
1387
|
+
function isTopLayer(element) {
|
|
1388
|
+
return topLayerSelectors.some((selector) => {
|
|
1389
|
+
try {
|
|
1390
|
+
return element.matches(selector);
|
|
1391
|
+
} catch (_e) {
|
|
1392
|
+
return false;
|
|
1393
|
+
}
|
|
1394
|
+
});
|
|
1395
|
+
}
|
|
1396
|
+
const transformProperties = ["transform", "translate", "scale", "rotate", "perspective"];
|
|
1397
|
+
const willChangeValues = ["transform", "translate", "scale", "rotate", "perspective", "filter"];
|
|
1398
|
+
const containValues = ["paint", "layout", "strict", "content"];
|
|
1399
|
+
function isContainingBlock(elementOrCss) {
|
|
1400
|
+
const webkit = isWebKit();
|
|
1401
|
+
const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
|
|
1402
|
+
return transformProperties.some((value) => css[value] ? css[value] !== "none" : false) || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || willChangeValues.some((value) => (css.willChange || "").includes(value)) || containValues.some((value) => (css.contain || "").includes(value));
|
|
1403
|
+
}
|
|
1404
|
+
function getContainingBlock(element) {
|
|
1405
|
+
let currentNode = getParentNode(element);
|
|
1406
|
+
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1407
|
+
if (isContainingBlock(currentNode)) {
|
|
1408
|
+
return currentNode;
|
|
1409
|
+
} else if (isTopLayer(currentNode)) {
|
|
1410
|
+
return null;
|
|
1411
|
+
}
|
|
1412
|
+
currentNode = getParentNode(currentNode);
|
|
1413
|
+
}
|
|
1414
|
+
return null;
|
|
1415
|
+
}
|
|
1416
|
+
function isWebKit() {
|
|
1417
|
+
if (typeof CSS === "undefined" || !CSS.supports) return false;
|
|
1418
|
+
return CSS.supports("-webkit-backdrop-filter", "none");
|
|
1419
|
+
}
|
|
1420
|
+
const lastTraversableNodeNames = /* @__PURE__ */ new Set(["html", "body", "#document"]);
|
|
1421
|
+
function isLastTraversableNode(node) {
|
|
1422
|
+
return lastTraversableNodeNames.has(getNodeName(node));
|
|
1423
|
+
}
|
|
1424
|
+
function getComputedStyle$1(element) {
|
|
1425
|
+
return getWindow(element).getComputedStyle(element);
|
|
1426
|
+
}
|
|
1427
|
+
function getNodeScroll(element) {
|
|
1428
|
+
if (isElement(element)) {
|
|
1429
|
+
return {
|
|
1430
|
+
scrollLeft: element.scrollLeft,
|
|
1431
|
+
scrollTop: element.scrollTop
|
|
1432
|
+
};
|
|
1433
|
+
}
|
|
1434
|
+
return {
|
|
1435
|
+
scrollLeft: element.scrollX,
|
|
1436
|
+
scrollTop: element.scrollY
|
|
1437
|
+
};
|
|
1438
|
+
}
|
|
1439
|
+
function getParentNode(node) {
|
|
1440
|
+
if (getNodeName(node) === "html") {
|
|
1441
|
+
return node;
|
|
1442
|
+
}
|
|
1443
|
+
const result = (
|
|
1444
|
+
// Step into the shadow DOM of the parent of a slotted node.
|
|
1445
|
+
node.assignedSlot || // DOM Element detected.
|
|
1446
|
+
node.parentNode || // ShadowRoot detected.
|
|
1447
|
+
isShadowRoot(node) && node.host || // Fallback.
|
|
1448
|
+
getDocumentElement(node)
|
|
1449
|
+
);
|
|
1450
|
+
return isShadowRoot(result) ? result.host : result;
|
|
1451
|
+
}
|
|
1452
|
+
function getNearestOverflowAncestor(node) {
|
|
1453
|
+
const parentNode = getParentNode(node);
|
|
1454
|
+
if (isLastTraversableNode(parentNode)) {
|
|
1455
|
+
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
|
1456
|
+
}
|
|
1457
|
+
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
1458
|
+
return parentNode;
|
|
1459
|
+
}
|
|
1460
|
+
return getNearestOverflowAncestor(parentNode);
|
|
1461
|
+
}
|
|
1462
|
+
function getOverflowAncestors(node, list, traverseIframes) {
|
|
1463
|
+
var _node$ownerDocument2;
|
|
1464
|
+
if (list === void 0) {
|
|
1465
|
+
list = [];
|
|
1466
|
+
}
|
|
1467
|
+
if (traverseIframes === void 0) {
|
|
1468
|
+
traverseIframes = true;
|
|
1469
|
+
}
|
|
1470
|
+
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
1471
|
+
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
|
1472
|
+
const win = getWindow(scrollableAncestor);
|
|
1473
|
+
if (isBody) {
|
|
1474
|
+
const frameElement = getFrameElement(win);
|
|
1475
|
+
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
|
1476
|
+
}
|
|
1477
|
+
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
|
1478
|
+
}
|
|
1479
|
+
function getFrameElement(win) {
|
|
1480
|
+
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
|
1481
|
+
}
|
|
1482
|
+
function getCssDimensions(element) {
|
|
1483
|
+
const css = getComputedStyle$1(element);
|
|
1484
|
+
let width = parseFloat(css.width) || 0;
|
|
1485
|
+
let height = parseFloat(css.height) || 0;
|
|
1486
|
+
const hasOffset = isHTMLElement(element);
|
|
1487
|
+
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
1488
|
+
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
1489
|
+
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
1490
|
+
if (shouldFallback) {
|
|
1491
|
+
width = offsetWidth;
|
|
1492
|
+
height = offsetHeight;
|
|
1493
|
+
}
|
|
1494
|
+
return {
|
|
1495
|
+
width,
|
|
1496
|
+
height,
|
|
1497
|
+
$: shouldFallback
|
|
1498
|
+
};
|
|
1499
|
+
}
|
|
1500
|
+
function unwrapElement(element) {
|
|
1501
|
+
return !isElement(element) ? element.contextElement : element;
|
|
1502
|
+
}
|
|
1503
|
+
function getScale(element) {
|
|
1504
|
+
const domElement = unwrapElement(element);
|
|
1505
|
+
if (!isHTMLElement(domElement)) {
|
|
1506
|
+
return createCoords(1);
|
|
1507
|
+
}
|
|
1508
|
+
const rect = domElement.getBoundingClientRect();
|
|
1509
|
+
const {
|
|
1510
|
+
width,
|
|
1511
|
+
height,
|
|
1512
|
+
$
|
|
1513
|
+
} = getCssDimensions(domElement);
|
|
1514
|
+
let x = ($ ? round(rect.width) : rect.width) / width;
|
|
1515
|
+
let y = ($ ? round(rect.height) : rect.height) / height;
|
|
1516
|
+
if (!x || !Number.isFinite(x)) {
|
|
1517
|
+
x = 1;
|
|
1518
|
+
}
|
|
1519
|
+
if (!y || !Number.isFinite(y)) {
|
|
1520
|
+
y = 1;
|
|
1521
|
+
}
|
|
1522
|
+
return {
|
|
1523
|
+
x,
|
|
1524
|
+
y
|
|
1525
|
+
};
|
|
1526
|
+
}
|
|
1527
|
+
const noOffsets = /* @__PURE__ */ createCoords(0);
|
|
1528
|
+
function getVisualOffsets(element) {
|
|
1529
|
+
const win = getWindow(element);
|
|
1530
|
+
if (!isWebKit() || !win.visualViewport) {
|
|
1531
|
+
return noOffsets;
|
|
1532
|
+
}
|
|
1533
|
+
return {
|
|
1534
|
+
x: win.visualViewport.offsetLeft,
|
|
1535
|
+
y: win.visualViewport.offsetTop
|
|
1536
|
+
};
|
|
1537
|
+
}
|
|
1538
|
+
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
1539
|
+
if (isFixed === void 0) {
|
|
1540
|
+
isFixed = false;
|
|
1541
|
+
}
|
|
1542
|
+
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
|
1543
|
+
return false;
|
|
1544
|
+
}
|
|
1545
|
+
return isFixed;
|
|
1546
|
+
}
|
|
1547
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
1548
|
+
if (includeScale === void 0) {
|
|
1549
|
+
includeScale = false;
|
|
1550
|
+
}
|
|
1551
|
+
if (isFixedStrategy === void 0) {
|
|
1552
|
+
isFixedStrategy = false;
|
|
1553
|
+
}
|
|
1554
|
+
const clientRect = element.getBoundingClientRect();
|
|
1555
|
+
const domElement = unwrapElement(element);
|
|
1556
|
+
let scale = createCoords(1);
|
|
1557
|
+
if (includeScale) {
|
|
1558
|
+
if (offsetParent) {
|
|
1559
|
+
if (isElement(offsetParent)) {
|
|
1560
|
+
scale = getScale(offsetParent);
|
|
1561
|
+
}
|
|
1562
|
+
} else {
|
|
1563
|
+
scale = getScale(element);
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
|
1567
|
+
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
|
1568
|
+
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
|
1569
|
+
let width = clientRect.width / scale.x;
|
|
1570
|
+
let height = clientRect.height / scale.y;
|
|
1571
|
+
if (domElement) {
|
|
1572
|
+
const win = getWindow(domElement);
|
|
1573
|
+
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
1574
|
+
let currentWin = win;
|
|
1575
|
+
let currentIFrame = getFrameElement(currentWin);
|
|
1576
|
+
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
|
1577
|
+
const iframeScale = getScale(currentIFrame);
|
|
1578
|
+
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
1579
|
+
const css = getComputedStyle$1(currentIFrame);
|
|
1580
|
+
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
1581
|
+
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
1582
|
+
x *= iframeScale.x;
|
|
1583
|
+
y *= iframeScale.y;
|
|
1584
|
+
width *= iframeScale.x;
|
|
1585
|
+
height *= iframeScale.y;
|
|
1586
|
+
x += left;
|
|
1587
|
+
y += top;
|
|
1588
|
+
currentWin = getWindow(currentIFrame);
|
|
1589
|
+
currentIFrame = getFrameElement(currentWin);
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
return rectToClientRect({
|
|
1593
|
+
width,
|
|
1594
|
+
height,
|
|
1595
|
+
x,
|
|
1596
|
+
y
|
|
1597
|
+
});
|
|
1598
|
+
}
|
|
1599
|
+
function getWindowScrollBarX(element, rect) {
|
|
1600
|
+
const leftScroll = getNodeScroll(element).scrollLeft;
|
|
1601
|
+
if (!rect) {
|
|
1602
|
+
return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
|
|
1603
|
+
}
|
|
1604
|
+
return rect.left + leftScroll;
|
|
1605
|
+
}
|
|
1606
|
+
function getHTMLOffset(documentElement, scroll) {
|
|
1607
|
+
const htmlRect = documentElement.getBoundingClientRect();
|
|
1608
|
+
const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
|
|
1609
|
+
const y = htmlRect.top + scroll.scrollTop;
|
|
1610
|
+
return {
|
|
1611
|
+
x,
|
|
1612
|
+
y
|
|
1613
|
+
};
|
|
1614
|
+
}
|
|
1615
|
+
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
1616
|
+
let {
|
|
1617
|
+
elements,
|
|
1618
|
+
rect,
|
|
1619
|
+
offsetParent,
|
|
1620
|
+
strategy
|
|
1621
|
+
} = _ref;
|
|
1622
|
+
const isFixed = strategy === "fixed";
|
|
1623
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
1624
|
+
const topLayer = elements ? isTopLayer(elements.floating) : false;
|
|
1625
|
+
if (offsetParent === documentElement || topLayer && isFixed) {
|
|
1626
|
+
return rect;
|
|
1627
|
+
}
|
|
1628
|
+
let scroll = {
|
|
1629
|
+
scrollLeft: 0,
|
|
1630
|
+
scrollTop: 0
|
|
1631
|
+
};
|
|
1632
|
+
let scale = createCoords(1);
|
|
1633
|
+
const offsets = createCoords(0);
|
|
1634
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1635
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
1636
|
+
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
|
1637
|
+
scroll = getNodeScroll(offsetParent);
|
|
1638
|
+
}
|
|
1639
|
+
if (isHTMLElement(offsetParent)) {
|
|
1640
|
+
const offsetRect = getBoundingClientRect(offsetParent);
|
|
1641
|
+
scale = getScale(offsetParent);
|
|
1642
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1643
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
1647
|
+
return {
|
|
1648
|
+
width: rect.width * scale.x,
|
|
1649
|
+
height: rect.height * scale.y,
|
|
1650
|
+
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
|
|
1651
|
+
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
|
|
1652
|
+
};
|
|
1653
|
+
}
|
|
1654
|
+
function getClientRects(element) {
|
|
1655
|
+
return Array.from(element.getClientRects());
|
|
1656
|
+
}
|
|
1657
|
+
function getDocumentRect(element) {
|
|
1658
|
+
const html = getDocumentElement(element);
|
|
1659
|
+
const scroll = getNodeScroll(element);
|
|
1660
|
+
const body = element.ownerDocument.body;
|
|
1661
|
+
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
|
1662
|
+
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
|
1663
|
+
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
1664
|
+
const y = -scroll.scrollTop;
|
|
1665
|
+
if (getComputedStyle$1(body).direction === "rtl") {
|
|
1666
|
+
x += max(html.clientWidth, body.clientWidth) - width;
|
|
1667
|
+
}
|
|
1668
|
+
return {
|
|
1669
|
+
width,
|
|
1670
|
+
height,
|
|
1671
|
+
x,
|
|
1672
|
+
y
|
|
1673
|
+
};
|
|
1674
|
+
}
|
|
1675
|
+
const SCROLLBAR_MAX = 25;
|
|
1676
|
+
function getViewportRect(element, strategy) {
|
|
1677
|
+
const win = getWindow(element);
|
|
1678
|
+
const html = getDocumentElement(element);
|
|
1679
|
+
const visualViewport = win.visualViewport;
|
|
1680
|
+
let width = html.clientWidth;
|
|
1681
|
+
let height = html.clientHeight;
|
|
1682
|
+
let x = 0;
|
|
1683
|
+
let y = 0;
|
|
1684
|
+
if (visualViewport) {
|
|
1685
|
+
width = visualViewport.width;
|
|
1686
|
+
height = visualViewport.height;
|
|
1687
|
+
const visualViewportBased = isWebKit();
|
|
1688
|
+
if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
|
|
1689
|
+
x = visualViewport.offsetLeft;
|
|
1690
|
+
y = visualViewport.offsetTop;
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
const windowScrollbarX = getWindowScrollBarX(html);
|
|
1694
|
+
if (windowScrollbarX <= 0) {
|
|
1695
|
+
const doc = html.ownerDocument;
|
|
1696
|
+
const body = doc.body;
|
|
1697
|
+
const bodyStyles = getComputedStyle(body);
|
|
1698
|
+
const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
|
|
1699
|
+
const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
|
|
1700
|
+
if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
|
|
1701
|
+
width -= clippingStableScrollbarWidth;
|
|
1702
|
+
}
|
|
1703
|
+
} else if (windowScrollbarX <= SCROLLBAR_MAX) {
|
|
1704
|
+
width += windowScrollbarX;
|
|
1705
|
+
}
|
|
1706
|
+
return {
|
|
1707
|
+
width,
|
|
1708
|
+
height,
|
|
1709
|
+
x,
|
|
1710
|
+
y
|
|
1711
|
+
};
|
|
1712
|
+
}
|
|
1713
|
+
const absoluteOrFixed = /* @__PURE__ */ new Set(["absolute", "fixed"]);
|
|
1714
|
+
function getInnerBoundingClientRect(element, strategy) {
|
|
1715
|
+
const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
|
|
1716
|
+
const top = clientRect.top + element.clientTop;
|
|
1717
|
+
const left = clientRect.left + element.clientLeft;
|
|
1718
|
+
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
|
1719
|
+
const width = element.clientWidth * scale.x;
|
|
1720
|
+
const height = element.clientHeight * scale.y;
|
|
1721
|
+
const x = left * scale.x;
|
|
1722
|
+
const y = top * scale.y;
|
|
1723
|
+
return {
|
|
1724
|
+
width,
|
|
1725
|
+
height,
|
|
1726
|
+
x,
|
|
1727
|
+
y
|
|
1728
|
+
};
|
|
1729
|
+
}
|
|
1730
|
+
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
|
1731
|
+
let rect;
|
|
1732
|
+
if (clippingAncestor === "viewport") {
|
|
1733
|
+
rect = getViewportRect(element, strategy);
|
|
1734
|
+
} else if (clippingAncestor === "document") {
|
|
1735
|
+
rect = getDocumentRect(getDocumentElement(element));
|
|
1736
|
+
} else if (isElement(clippingAncestor)) {
|
|
1737
|
+
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
1738
|
+
} else {
|
|
1739
|
+
const visualOffsets = getVisualOffsets(element);
|
|
1740
|
+
rect = {
|
|
1741
|
+
x: clippingAncestor.x - visualOffsets.x,
|
|
1742
|
+
y: clippingAncestor.y - visualOffsets.y,
|
|
1743
|
+
width: clippingAncestor.width,
|
|
1744
|
+
height: clippingAncestor.height
|
|
1745
|
+
};
|
|
1746
|
+
}
|
|
1747
|
+
return rectToClientRect(rect);
|
|
1748
|
+
}
|
|
1749
|
+
function hasFixedPositionAncestor(element, stopNode) {
|
|
1750
|
+
const parentNode = getParentNode(element);
|
|
1751
|
+
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
|
1752
|
+
return false;
|
|
1753
|
+
}
|
|
1754
|
+
return getComputedStyle$1(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
|
|
1755
|
+
}
|
|
1756
|
+
function getClippingElementAncestors(element, cache) {
|
|
1757
|
+
const cachedResult = cache.get(element);
|
|
1758
|
+
if (cachedResult) {
|
|
1759
|
+
return cachedResult;
|
|
1760
|
+
}
|
|
1761
|
+
let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
|
|
1762
|
+
let currentContainingBlockComputedStyle = null;
|
|
1763
|
+
const elementIsFixed = getComputedStyle$1(element).position === "fixed";
|
|
1764
|
+
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
1765
|
+
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1766
|
+
const computedStyle = getComputedStyle$1(currentNode);
|
|
1767
|
+
const currentNodeIsContaining = isContainingBlock(currentNode);
|
|
1768
|
+
if (!currentNodeIsContaining && computedStyle.position === "fixed") {
|
|
1769
|
+
currentContainingBlockComputedStyle = null;
|
|
1770
|
+
}
|
|
1771
|
+
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
|
1772
|
+
if (shouldDropCurrentNode) {
|
|
1773
|
+
result = result.filter((ancestor) => ancestor !== currentNode);
|
|
1774
|
+
} else {
|
|
1775
|
+
currentContainingBlockComputedStyle = computedStyle;
|
|
1776
|
+
}
|
|
1777
|
+
currentNode = getParentNode(currentNode);
|
|
1778
|
+
}
|
|
1779
|
+
cache.set(element, result);
|
|
1780
|
+
return result;
|
|
1781
|
+
}
|
|
1782
|
+
function getClippingRect(_ref) {
|
|
1783
|
+
let {
|
|
1784
|
+
element,
|
|
1785
|
+
boundary,
|
|
1786
|
+
rootBoundary,
|
|
1787
|
+
strategy
|
|
1788
|
+
} = _ref;
|
|
1789
|
+
const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
1790
|
+
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
1791
|
+
const firstClippingAncestor = clippingAncestors[0];
|
|
1792
|
+
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
1793
|
+
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
|
1794
|
+
accRect.top = max(rect.top, accRect.top);
|
|
1795
|
+
accRect.right = min(rect.right, accRect.right);
|
|
1796
|
+
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
1797
|
+
accRect.left = max(rect.left, accRect.left);
|
|
1798
|
+
return accRect;
|
|
1799
|
+
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
|
1800
|
+
return {
|
|
1801
|
+
width: clippingRect.right - clippingRect.left,
|
|
1802
|
+
height: clippingRect.bottom - clippingRect.top,
|
|
1803
|
+
x: clippingRect.left,
|
|
1804
|
+
y: clippingRect.top
|
|
1805
|
+
};
|
|
1806
|
+
}
|
|
1807
|
+
function getDimensions(element) {
|
|
1808
|
+
const {
|
|
1809
|
+
width,
|
|
1810
|
+
height
|
|
1811
|
+
} = getCssDimensions(element);
|
|
1812
|
+
return {
|
|
1813
|
+
width,
|
|
1814
|
+
height
|
|
1815
|
+
};
|
|
1816
|
+
}
|
|
1817
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
1818
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1819
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
1820
|
+
const isFixed = strategy === "fixed";
|
|
1821
|
+
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
|
1822
|
+
let scroll = {
|
|
1823
|
+
scrollLeft: 0,
|
|
1824
|
+
scrollTop: 0
|
|
1825
|
+
};
|
|
1826
|
+
const offsets = createCoords(0);
|
|
1827
|
+
function setLeftRTLScrollbarOffset() {
|
|
1828
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
1829
|
+
}
|
|
1830
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
1831
|
+
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
|
1832
|
+
scroll = getNodeScroll(offsetParent);
|
|
1833
|
+
}
|
|
1834
|
+
if (isOffsetParentAnElement) {
|
|
1835
|
+
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
1836
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1837
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1838
|
+
} else if (documentElement) {
|
|
1839
|
+
setLeftRTLScrollbarOffset();
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
if (isFixed && !isOffsetParentAnElement && documentElement) {
|
|
1843
|
+
setLeftRTLScrollbarOffset();
|
|
1844
|
+
}
|
|
1845
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
1846
|
+
const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
|
|
1847
|
+
const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
|
|
1848
|
+
return {
|
|
1849
|
+
x,
|
|
1850
|
+
y,
|
|
1851
|
+
width: rect.width,
|
|
1852
|
+
height: rect.height
|
|
1853
|
+
};
|
|
1854
|
+
}
|
|
1855
|
+
function isStaticPositioned(element) {
|
|
1856
|
+
return getComputedStyle$1(element).position === "static";
|
|
1857
|
+
}
|
|
1858
|
+
function getTrueOffsetParent(element, polyfill) {
|
|
1859
|
+
if (!isHTMLElement(element) || getComputedStyle$1(element).position === "fixed") {
|
|
1860
|
+
return null;
|
|
1861
|
+
}
|
|
1862
|
+
if (polyfill) {
|
|
1863
|
+
return polyfill(element);
|
|
1864
|
+
}
|
|
1865
|
+
let rawOffsetParent = element.offsetParent;
|
|
1866
|
+
if (getDocumentElement(element) === rawOffsetParent) {
|
|
1867
|
+
rawOffsetParent = rawOffsetParent.ownerDocument.body;
|
|
1868
|
+
}
|
|
1869
|
+
return rawOffsetParent;
|
|
1870
|
+
}
|
|
1871
|
+
function getOffsetParent(element, polyfill) {
|
|
1872
|
+
const win = getWindow(element);
|
|
1873
|
+
if (isTopLayer(element)) {
|
|
1874
|
+
return win;
|
|
1875
|
+
}
|
|
1876
|
+
if (!isHTMLElement(element)) {
|
|
1877
|
+
let svgOffsetParent = getParentNode(element);
|
|
1878
|
+
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
|
|
1879
|
+
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
|
|
1880
|
+
return svgOffsetParent;
|
|
1881
|
+
}
|
|
1882
|
+
svgOffsetParent = getParentNode(svgOffsetParent);
|
|
1883
|
+
}
|
|
1884
|
+
return win;
|
|
1885
|
+
}
|
|
1886
|
+
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
1887
|
+
while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
|
|
1888
|
+
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
1889
|
+
}
|
|
1890
|
+
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
|
|
1891
|
+
return win;
|
|
1892
|
+
}
|
|
1893
|
+
return offsetParent || getContainingBlock(element) || win;
|
|
1894
|
+
}
|
|
1895
|
+
const getElementRects = async function(data) {
|
|
1896
|
+
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
1897
|
+
const getDimensionsFn = this.getDimensions;
|
|
1898
|
+
const floatingDimensions = await getDimensionsFn(data.floating);
|
|
1899
|
+
return {
|
|
1900
|
+
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
|
1901
|
+
floating: {
|
|
1902
|
+
x: 0,
|
|
1903
|
+
y: 0,
|
|
1904
|
+
width: floatingDimensions.width,
|
|
1905
|
+
height: floatingDimensions.height
|
|
1906
|
+
}
|
|
1907
|
+
};
|
|
1908
|
+
};
|
|
1909
|
+
function isRTL(element) {
|
|
1910
|
+
return getComputedStyle$1(element).direction === "rtl";
|
|
1911
|
+
}
|
|
1912
|
+
const platform = {
|
|
1913
|
+
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
1914
|
+
getDocumentElement,
|
|
1915
|
+
getClippingRect,
|
|
1916
|
+
getOffsetParent,
|
|
1917
|
+
getElementRects,
|
|
1918
|
+
getClientRects,
|
|
1919
|
+
getDimensions,
|
|
1920
|
+
getScale,
|
|
1921
|
+
isElement,
|
|
1922
|
+
isRTL
|
|
1923
|
+
};
|
|
1924
|
+
function rectsAreEqual(a, b) {
|
|
1925
|
+
return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
|
|
1926
|
+
}
|
|
1927
|
+
function observeMove(element, onMove) {
|
|
1928
|
+
let io = null;
|
|
1929
|
+
let timeoutId;
|
|
1930
|
+
const root = getDocumentElement(element);
|
|
1931
|
+
function cleanup() {
|
|
1932
|
+
var _io;
|
|
1933
|
+
clearTimeout(timeoutId);
|
|
1934
|
+
(_io = io) == null || _io.disconnect();
|
|
1935
|
+
io = null;
|
|
1936
|
+
}
|
|
1937
|
+
function refresh(skip, threshold) {
|
|
1938
|
+
if (skip === void 0) {
|
|
1939
|
+
skip = false;
|
|
1940
|
+
}
|
|
1941
|
+
if (threshold === void 0) {
|
|
1942
|
+
threshold = 1;
|
|
1943
|
+
}
|
|
1944
|
+
cleanup();
|
|
1945
|
+
const elementRectForRootMargin = element.getBoundingClientRect();
|
|
1946
|
+
const {
|
|
1947
|
+
left,
|
|
1948
|
+
top,
|
|
1949
|
+
width,
|
|
1950
|
+
height
|
|
1951
|
+
} = elementRectForRootMargin;
|
|
1952
|
+
if (!skip) {
|
|
1953
|
+
onMove();
|
|
1954
|
+
}
|
|
1955
|
+
if (!width || !height) {
|
|
1956
|
+
return;
|
|
1957
|
+
}
|
|
1958
|
+
const insetTop = floor(top);
|
|
1959
|
+
const insetRight = floor(root.clientWidth - (left + width));
|
|
1960
|
+
const insetBottom = floor(root.clientHeight - (top + height));
|
|
1961
|
+
const insetLeft = floor(left);
|
|
1962
|
+
const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
|
|
1963
|
+
const options = {
|
|
1964
|
+
rootMargin,
|
|
1965
|
+
threshold: max(0, min(1, threshold)) || 1
|
|
1966
|
+
};
|
|
1967
|
+
let isFirstUpdate = true;
|
|
1968
|
+
function handleObserve(entries) {
|
|
1969
|
+
const ratio = entries[0].intersectionRatio;
|
|
1970
|
+
if (ratio !== threshold) {
|
|
1971
|
+
if (!isFirstUpdate) {
|
|
1972
|
+
return refresh();
|
|
1973
|
+
}
|
|
1974
|
+
if (!ratio) {
|
|
1975
|
+
timeoutId = setTimeout(() => {
|
|
1976
|
+
refresh(false, 1e-7);
|
|
1977
|
+
}, 1e3);
|
|
1978
|
+
} else {
|
|
1979
|
+
refresh(false, ratio);
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
|
|
1983
|
+
refresh();
|
|
1984
|
+
}
|
|
1985
|
+
isFirstUpdate = false;
|
|
1986
|
+
}
|
|
1987
|
+
try {
|
|
1988
|
+
io = new IntersectionObserver(handleObserve, {
|
|
1989
|
+
...options,
|
|
1990
|
+
// Handle <iframe>s
|
|
1991
|
+
root: root.ownerDocument
|
|
1992
|
+
});
|
|
1993
|
+
} catch (_e) {
|
|
1994
|
+
io = new IntersectionObserver(handleObserve, options);
|
|
1995
|
+
}
|
|
1996
|
+
io.observe(element);
|
|
1997
|
+
}
|
|
1998
|
+
refresh(true);
|
|
1999
|
+
return cleanup;
|
|
2000
|
+
}
|
|
2001
|
+
function autoUpdate(reference, floating, update, options) {
|
|
2002
|
+
if (options === void 0) {
|
|
2003
|
+
options = {};
|
|
2004
|
+
}
|
|
2005
|
+
const {
|
|
2006
|
+
ancestorScroll = true,
|
|
2007
|
+
ancestorResize = true,
|
|
2008
|
+
elementResize = typeof ResizeObserver === "function",
|
|
2009
|
+
layoutShift = typeof IntersectionObserver === "function",
|
|
2010
|
+
animationFrame = false
|
|
2011
|
+
} = options;
|
|
2012
|
+
const referenceEl = unwrapElement(reference);
|
|
2013
|
+
const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...getOverflowAncestors(floating)] : [];
|
|
2014
|
+
ancestors.forEach((ancestor) => {
|
|
2015
|
+
ancestorScroll && ancestor.addEventListener("scroll", update, {
|
|
2016
|
+
passive: true
|
|
2017
|
+
});
|
|
2018
|
+
ancestorResize && ancestor.addEventListener("resize", update);
|
|
2019
|
+
});
|
|
2020
|
+
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
|
|
2021
|
+
let reobserveFrame = -1;
|
|
2022
|
+
let resizeObserver = null;
|
|
2023
|
+
if (elementResize) {
|
|
2024
|
+
resizeObserver = new ResizeObserver((_ref) => {
|
|
2025
|
+
let [firstEntry] = _ref;
|
|
2026
|
+
if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
|
|
2027
|
+
resizeObserver.unobserve(floating);
|
|
2028
|
+
cancelAnimationFrame(reobserveFrame);
|
|
2029
|
+
reobserveFrame = requestAnimationFrame(() => {
|
|
2030
|
+
var _resizeObserver;
|
|
2031
|
+
(_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
|
|
2032
|
+
});
|
|
2033
|
+
}
|
|
2034
|
+
update();
|
|
2035
|
+
});
|
|
2036
|
+
if (referenceEl && !animationFrame) {
|
|
2037
|
+
resizeObserver.observe(referenceEl);
|
|
2038
|
+
}
|
|
2039
|
+
resizeObserver.observe(floating);
|
|
2040
|
+
}
|
|
2041
|
+
let frameId;
|
|
2042
|
+
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
|
2043
|
+
if (animationFrame) {
|
|
2044
|
+
frameLoop();
|
|
2045
|
+
}
|
|
2046
|
+
function frameLoop() {
|
|
2047
|
+
const nextRefRect = getBoundingClientRect(reference);
|
|
2048
|
+
if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
|
|
2049
|
+
update();
|
|
2050
|
+
}
|
|
2051
|
+
prevRefRect = nextRefRect;
|
|
2052
|
+
frameId = requestAnimationFrame(frameLoop);
|
|
2053
|
+
}
|
|
2054
|
+
update();
|
|
2055
|
+
return () => {
|
|
2056
|
+
var _resizeObserver2;
|
|
2057
|
+
ancestors.forEach((ancestor) => {
|
|
2058
|
+
ancestorScroll && ancestor.removeEventListener("scroll", update);
|
|
2059
|
+
ancestorResize && ancestor.removeEventListener("resize", update);
|
|
2060
|
+
});
|
|
2061
|
+
cleanupIo == null || cleanupIo();
|
|
2062
|
+
(_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
|
|
2063
|
+
resizeObserver = null;
|
|
2064
|
+
if (animationFrame) {
|
|
2065
|
+
cancelAnimationFrame(frameId);
|
|
2066
|
+
}
|
|
2067
|
+
};
|
|
2068
|
+
}
|
|
2069
|
+
const offset$1 = offset$2;
|
|
2070
|
+
const shift$1 = shift$2;
|
|
2071
|
+
const flip$1 = flip$2;
|
|
2072
|
+
const size$1 = size$2;
|
|
2073
|
+
const hide$1 = hide$2;
|
|
2074
|
+
const arrow$2 = arrow$3;
|
|
2075
|
+
const limitShift$1 = limitShift$2;
|
|
2076
|
+
const computePosition = (reference, floating, options) => {
|
|
2077
|
+
const cache = /* @__PURE__ */ new Map();
|
|
2078
|
+
const mergedOptions = {
|
|
2079
|
+
platform,
|
|
2080
|
+
...options
|
|
2081
|
+
};
|
|
2082
|
+
const platformWithCache = {
|
|
2083
|
+
...mergedOptions.platform,
|
|
2084
|
+
_c: cache
|
|
2085
|
+
};
|
|
2086
|
+
return computePosition$1(reference, floating, {
|
|
2087
|
+
...mergedOptions,
|
|
2088
|
+
platform: platformWithCache
|
|
2089
|
+
});
|
|
2090
|
+
};
|
|
2091
|
+
var index = typeof document !== "undefined" ? React.useLayoutEffect : React.useEffect;
|
|
2092
|
+
function deepEqual(a, b) {
|
|
2093
|
+
if (a === b) {
|
|
2094
|
+
return true;
|
|
2095
|
+
}
|
|
2096
|
+
if (typeof a !== typeof b) {
|
|
2097
|
+
return false;
|
|
2098
|
+
}
|
|
2099
|
+
if (typeof a === "function" && a.toString() === b.toString()) {
|
|
2100
|
+
return true;
|
|
2101
|
+
}
|
|
2102
|
+
let length;
|
|
2103
|
+
let i;
|
|
2104
|
+
let keys;
|
|
2105
|
+
if (a && b && typeof a === "object") {
|
|
2106
|
+
if (Array.isArray(a)) {
|
|
2107
|
+
length = a.length;
|
|
2108
|
+
if (length !== b.length) return false;
|
|
2109
|
+
for (i = length; i-- !== 0; ) {
|
|
2110
|
+
if (!deepEqual(a[i], b[i])) {
|
|
2111
|
+
return false;
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
return true;
|
|
2115
|
+
}
|
|
2116
|
+
keys = Object.keys(a);
|
|
2117
|
+
length = keys.length;
|
|
2118
|
+
if (length !== Object.keys(b).length) {
|
|
2119
|
+
return false;
|
|
2120
|
+
}
|
|
2121
|
+
for (i = length; i-- !== 0; ) {
|
|
2122
|
+
if (!{}.hasOwnProperty.call(b, keys[i])) {
|
|
2123
|
+
return false;
|
|
2124
|
+
}
|
|
2125
|
+
}
|
|
2126
|
+
for (i = length; i-- !== 0; ) {
|
|
2127
|
+
const key = keys[i];
|
|
2128
|
+
if (key === "_owner" && a.$$typeof) {
|
|
2129
|
+
continue;
|
|
2130
|
+
}
|
|
2131
|
+
if (!deepEqual(a[key], b[key])) {
|
|
2132
|
+
return false;
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
return true;
|
|
2136
|
+
}
|
|
2137
|
+
return a !== a && b !== b;
|
|
2138
|
+
}
|
|
2139
|
+
function getDPR(element) {
|
|
2140
|
+
if (typeof window === "undefined") {
|
|
2141
|
+
return 1;
|
|
2142
|
+
}
|
|
2143
|
+
const win = element.ownerDocument.defaultView || window;
|
|
2144
|
+
return win.devicePixelRatio || 1;
|
|
2145
|
+
}
|
|
2146
|
+
function roundByDPR(element, value) {
|
|
2147
|
+
const dpr = getDPR(element);
|
|
2148
|
+
return Math.round(value * dpr) / dpr;
|
|
2149
|
+
}
|
|
2150
|
+
function useLatestRef(value) {
|
|
2151
|
+
const ref = React__namespace.useRef(value);
|
|
2152
|
+
index(() => {
|
|
2153
|
+
ref.current = value;
|
|
2154
|
+
});
|
|
2155
|
+
return ref;
|
|
2156
|
+
}
|
|
2157
|
+
function useFloating(options) {
|
|
2158
|
+
if (options === void 0) {
|
|
2159
|
+
options = {};
|
|
2160
|
+
}
|
|
2161
|
+
const {
|
|
2162
|
+
placement = "bottom",
|
|
2163
|
+
strategy = "absolute",
|
|
2164
|
+
middleware = [],
|
|
2165
|
+
platform: platform2,
|
|
2166
|
+
elements: {
|
|
2167
|
+
reference: externalReference,
|
|
2168
|
+
floating: externalFloating
|
|
2169
|
+
} = {},
|
|
2170
|
+
transform = true,
|
|
2171
|
+
whileElementsMounted,
|
|
2172
|
+
open
|
|
2173
|
+
} = options;
|
|
2174
|
+
const [data, setData] = React__namespace.useState({
|
|
2175
|
+
x: 0,
|
|
2176
|
+
y: 0,
|
|
2177
|
+
strategy,
|
|
2178
|
+
placement,
|
|
2179
|
+
middlewareData: {},
|
|
2180
|
+
isPositioned: false
|
|
2181
|
+
});
|
|
2182
|
+
const [latestMiddleware, setLatestMiddleware] = React__namespace.useState(middleware);
|
|
2183
|
+
if (!deepEqual(latestMiddleware, middleware)) {
|
|
2184
|
+
setLatestMiddleware(middleware);
|
|
2185
|
+
}
|
|
2186
|
+
const [_reference, _setReference] = React__namespace.useState(null);
|
|
2187
|
+
const [_floating, _setFloating] = React__namespace.useState(null);
|
|
2188
|
+
const setReference = React__namespace.useCallback((node) => {
|
|
2189
|
+
if (node !== referenceRef.current) {
|
|
2190
|
+
referenceRef.current = node;
|
|
2191
|
+
_setReference(node);
|
|
2192
|
+
}
|
|
2193
|
+
}, []);
|
|
2194
|
+
const setFloating = React__namespace.useCallback((node) => {
|
|
2195
|
+
if (node !== floatingRef.current) {
|
|
2196
|
+
floatingRef.current = node;
|
|
2197
|
+
_setFloating(node);
|
|
2198
|
+
}
|
|
2199
|
+
}, []);
|
|
2200
|
+
const referenceEl = externalReference || _reference;
|
|
2201
|
+
const floatingEl = externalFloating || _floating;
|
|
2202
|
+
const referenceRef = React__namespace.useRef(null);
|
|
2203
|
+
const floatingRef = React__namespace.useRef(null);
|
|
2204
|
+
const dataRef = React__namespace.useRef(data);
|
|
2205
|
+
const hasWhileElementsMounted = whileElementsMounted != null;
|
|
2206
|
+
const whileElementsMountedRef = useLatestRef(whileElementsMounted);
|
|
2207
|
+
const platformRef = useLatestRef(platform2);
|
|
2208
|
+
const update = React__namespace.useCallback(() => {
|
|
2209
|
+
if (!referenceRef.current || !floatingRef.current) {
|
|
2210
|
+
return;
|
|
2211
|
+
}
|
|
2212
|
+
const config = {
|
|
2213
|
+
placement,
|
|
2214
|
+
strategy,
|
|
2215
|
+
middleware: latestMiddleware
|
|
2216
|
+
};
|
|
2217
|
+
if (platformRef.current) {
|
|
2218
|
+
config.platform = platformRef.current;
|
|
2219
|
+
}
|
|
2220
|
+
computePosition(referenceRef.current, floatingRef.current, config).then((data2) => {
|
|
2221
|
+
const fullData = {
|
|
2222
|
+
...data2,
|
|
2223
|
+
isPositioned: true
|
|
2224
|
+
};
|
|
2225
|
+
if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
|
|
2226
|
+
dataRef.current = fullData;
|
|
2227
|
+
ReactDOM__namespace.flushSync(() => {
|
|
2228
|
+
setData(fullData);
|
|
2229
|
+
});
|
|
2230
|
+
}
|
|
2231
|
+
});
|
|
2232
|
+
}, [latestMiddleware, placement, strategy, platformRef]);
|
|
2233
|
+
index(() => {
|
|
2234
|
+
if (open === false && dataRef.current.isPositioned) {
|
|
2235
|
+
dataRef.current.isPositioned = false;
|
|
2236
|
+
setData((data2) => ({
|
|
2237
|
+
...data2,
|
|
2238
|
+
isPositioned: false
|
|
2239
|
+
}));
|
|
2240
|
+
}
|
|
2241
|
+
}, [open]);
|
|
2242
|
+
const isMountedRef = React__namespace.useRef(false);
|
|
2243
|
+
index(() => {
|
|
2244
|
+
isMountedRef.current = true;
|
|
2245
|
+
return () => {
|
|
2246
|
+
isMountedRef.current = false;
|
|
2247
|
+
};
|
|
2248
|
+
}, []);
|
|
2249
|
+
index(() => {
|
|
2250
|
+
if (referenceEl) referenceRef.current = referenceEl;
|
|
2251
|
+
if (floatingEl) floatingRef.current = floatingEl;
|
|
2252
|
+
if (referenceEl && floatingEl) {
|
|
2253
|
+
if (whileElementsMountedRef.current) {
|
|
2254
|
+
return whileElementsMountedRef.current(referenceEl, floatingEl, update);
|
|
2255
|
+
}
|
|
2256
|
+
update();
|
|
2257
|
+
}
|
|
2258
|
+
}, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]);
|
|
2259
|
+
const refs = React__namespace.useMemo(() => ({
|
|
2260
|
+
reference: referenceRef,
|
|
2261
|
+
floating: floatingRef,
|
|
2262
|
+
setReference,
|
|
2263
|
+
setFloating
|
|
2264
|
+
}), [setReference, setFloating]);
|
|
2265
|
+
const elements = React__namespace.useMemo(() => ({
|
|
2266
|
+
reference: referenceEl,
|
|
2267
|
+
floating: floatingEl
|
|
2268
|
+
}), [referenceEl, floatingEl]);
|
|
2269
|
+
const floatingStyles = React__namespace.useMemo(() => {
|
|
2270
|
+
const initialStyles = {
|
|
2271
|
+
position: strategy,
|
|
2272
|
+
left: 0,
|
|
2273
|
+
top: 0
|
|
2274
|
+
};
|
|
2275
|
+
if (!elements.floating) {
|
|
2276
|
+
return initialStyles;
|
|
2277
|
+
}
|
|
2278
|
+
const x = roundByDPR(elements.floating, data.x);
|
|
2279
|
+
const y = roundByDPR(elements.floating, data.y);
|
|
2280
|
+
if (transform) {
|
|
2281
|
+
return {
|
|
2282
|
+
...initialStyles,
|
|
2283
|
+
transform: "translate(" + x + "px, " + y + "px)",
|
|
2284
|
+
...getDPR(elements.floating) >= 1.5 && {
|
|
2285
|
+
willChange: "transform"
|
|
2286
|
+
}
|
|
2287
|
+
};
|
|
2288
|
+
}
|
|
2289
|
+
return {
|
|
2290
|
+
position: strategy,
|
|
2291
|
+
left: x,
|
|
2292
|
+
top: y
|
|
2293
|
+
};
|
|
2294
|
+
}, [strategy, transform, elements.floating, data.x, data.y]);
|
|
2295
|
+
return React__namespace.useMemo(() => ({
|
|
2296
|
+
...data,
|
|
2297
|
+
update,
|
|
2298
|
+
refs,
|
|
2299
|
+
elements,
|
|
2300
|
+
floatingStyles
|
|
2301
|
+
}), [data, update, refs, elements, floatingStyles]);
|
|
2302
|
+
}
|
|
2303
|
+
const arrow$1 = (options) => {
|
|
2304
|
+
function isRef(value) {
|
|
2305
|
+
return {}.hasOwnProperty.call(value, "current");
|
|
2306
|
+
}
|
|
2307
|
+
return {
|
|
2308
|
+
name: "arrow",
|
|
2309
|
+
options,
|
|
2310
|
+
fn(state) {
|
|
2311
|
+
const {
|
|
2312
|
+
element,
|
|
2313
|
+
padding
|
|
2314
|
+
} = typeof options === "function" ? options(state) : options;
|
|
2315
|
+
if (element && isRef(element)) {
|
|
2316
|
+
if (element.current != null) {
|
|
2317
|
+
return arrow$2({
|
|
2318
|
+
element: element.current,
|
|
2319
|
+
padding
|
|
2320
|
+
}).fn(state);
|
|
2321
|
+
}
|
|
2322
|
+
return {};
|
|
2323
|
+
}
|
|
2324
|
+
if (element) {
|
|
2325
|
+
return arrow$2({
|
|
2326
|
+
element,
|
|
2327
|
+
padding
|
|
2328
|
+
}).fn(state);
|
|
2329
|
+
}
|
|
2330
|
+
return {};
|
|
2331
|
+
}
|
|
2332
|
+
};
|
|
2333
|
+
};
|
|
2334
|
+
const offset = (options, deps) => ({
|
|
2335
|
+
...offset$1(options),
|
|
2336
|
+
options: [options, deps]
|
|
2337
|
+
});
|
|
2338
|
+
const shift = (options, deps) => ({
|
|
2339
|
+
...shift$1(options),
|
|
2340
|
+
options: [options, deps]
|
|
2341
|
+
});
|
|
2342
|
+
const limitShift = (options, deps) => ({
|
|
2343
|
+
...limitShift$1(options),
|
|
2344
|
+
options: [options, deps]
|
|
2345
|
+
});
|
|
2346
|
+
const flip = (options, deps) => ({
|
|
2347
|
+
...flip$1(options),
|
|
2348
|
+
options: [options, deps]
|
|
2349
|
+
});
|
|
2350
|
+
const size = (options, deps) => ({
|
|
2351
|
+
...size$1(options),
|
|
2352
|
+
options: [options, deps]
|
|
2353
|
+
});
|
|
2354
|
+
const hide = (options, deps) => ({
|
|
2355
|
+
...hide$1(options),
|
|
2356
|
+
options: [options, deps]
|
|
2357
|
+
});
|
|
2358
|
+
const arrow = (options, deps) => ({
|
|
2359
|
+
...arrow$1(options),
|
|
2360
|
+
options: [options, deps]
|
|
2361
|
+
});
|
|
2362
|
+
const $7e8f5cd07187803e$export$21b07c8f274aebd5 = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
|
|
2363
|
+
const { children, width = 10, height = 5, ...arrowProps } = props;
|
|
2364
|
+
return /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.svg, _extends({}, arrowProps, {
|
|
2365
|
+
ref: forwardedRef,
|
|
2366
|
+
width,
|
|
2367
|
+
height,
|
|
2368
|
+
viewBox: "0 0 30 10",
|
|
2369
|
+
preserveAspectRatio: "none"
|
|
2370
|
+
}), props.asChild ? children : /* @__PURE__ */ React.createElement("polygon", {
|
|
2371
|
+
points: "0,0 30,0 15,10"
|
|
2372
|
+
}));
|
|
2373
|
+
});
|
|
2374
|
+
const $7e8f5cd07187803e$export$be92b6f5f03c0fe9 = $7e8f5cd07187803e$export$21b07c8f274aebd5;
|
|
2375
|
+
function $db6c3485150b8e66$export$1ab7ae714698c4b8(element) {
|
|
2376
|
+
const [size2, setSize] = React.useState(void 0);
|
|
2377
|
+
$9f79659886946c16$export$e5c5a5f917a5871c(() => {
|
|
2378
|
+
if (element) {
|
|
2379
|
+
setSize({
|
|
2380
|
+
width: element.offsetWidth,
|
|
2381
|
+
height: element.offsetHeight
|
|
2382
|
+
});
|
|
2383
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
2384
|
+
if (!Array.isArray(entries)) return;
|
|
2385
|
+
if (!entries.length) return;
|
|
2386
|
+
const entry = entries[0];
|
|
2387
|
+
let width;
|
|
2388
|
+
let height;
|
|
2389
|
+
if ("borderBoxSize" in entry) {
|
|
2390
|
+
const borderSizeEntry = entry["borderBoxSize"];
|
|
2391
|
+
const borderSize = Array.isArray(borderSizeEntry) ? borderSizeEntry[0] : borderSizeEntry;
|
|
2392
|
+
width = borderSize["inlineSize"];
|
|
2393
|
+
height = borderSize["blockSize"];
|
|
2394
|
+
} else {
|
|
2395
|
+
width = element.offsetWidth;
|
|
2396
|
+
height = element.offsetHeight;
|
|
2397
|
+
}
|
|
2398
|
+
setSize({
|
|
2399
|
+
width,
|
|
2400
|
+
height
|
|
2401
|
+
});
|
|
2402
|
+
});
|
|
2403
|
+
resizeObserver.observe(element, {
|
|
2404
|
+
box: "border-box"
|
|
2405
|
+
});
|
|
2406
|
+
return () => resizeObserver.unobserve(element);
|
|
2407
|
+
} else
|
|
2408
|
+
setSize(void 0);
|
|
2409
|
+
}, [
|
|
2410
|
+
element
|
|
2411
|
+
]);
|
|
2412
|
+
return size2;
|
|
2413
|
+
}
|
|
2414
|
+
const $cf1ac5d9fe0e8206$var$POPPER_NAME = "Popper";
|
|
2415
|
+
const [$cf1ac5d9fe0e8206$var$createPopperContext, $cf1ac5d9fe0e8206$export$722aac194ae923] = $c512c27ab02ef895$export$50c7b4e9d9f19c1($cf1ac5d9fe0e8206$var$POPPER_NAME);
|
|
2416
|
+
const [$cf1ac5d9fe0e8206$var$PopperProvider, $cf1ac5d9fe0e8206$var$usePopperContext] = $cf1ac5d9fe0e8206$var$createPopperContext($cf1ac5d9fe0e8206$var$POPPER_NAME);
|
|
2417
|
+
const $cf1ac5d9fe0e8206$export$badac9ada3a0bdf9 = (props) => {
|
|
2418
|
+
const { __scopePopper, children } = props;
|
|
2419
|
+
const [anchor, setAnchor] = React.useState(null);
|
|
2420
|
+
return /* @__PURE__ */ React.createElement($cf1ac5d9fe0e8206$var$PopperProvider, {
|
|
2421
|
+
scope: __scopePopper,
|
|
2422
|
+
anchor,
|
|
2423
|
+
onAnchorChange: setAnchor
|
|
2424
|
+
}, children);
|
|
2425
|
+
};
|
|
2426
|
+
const $cf1ac5d9fe0e8206$var$ANCHOR_NAME = "PopperAnchor";
|
|
2427
|
+
const $cf1ac5d9fe0e8206$export$ecd4e1ccab6ed6d = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
|
|
2428
|
+
const { __scopePopper, virtualRef, ...anchorProps } = props;
|
|
2429
|
+
const context = $cf1ac5d9fe0e8206$var$usePopperContext($cf1ac5d9fe0e8206$var$ANCHOR_NAME, __scopePopper);
|
|
2430
|
+
const ref = React.useRef(null);
|
|
2431
|
+
const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, ref);
|
|
2432
|
+
React.useEffect(() => {
|
|
2433
|
+
context.onAnchorChange((virtualRef === null || virtualRef === void 0 ? void 0 : virtualRef.current) || ref.current);
|
|
2434
|
+
});
|
|
2435
|
+
return virtualRef ? null : /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({}, anchorProps, {
|
|
2436
|
+
ref: composedRefs
|
|
2437
|
+
}));
|
|
2438
|
+
});
|
|
2439
|
+
const $cf1ac5d9fe0e8206$var$CONTENT_NAME = "PopperContent";
|
|
2440
|
+
const [$cf1ac5d9fe0e8206$var$PopperContentProvider, $cf1ac5d9fe0e8206$var$useContentContext] = $cf1ac5d9fe0e8206$var$createPopperContext($cf1ac5d9fe0e8206$var$CONTENT_NAME);
|
|
2441
|
+
const $cf1ac5d9fe0e8206$export$bc4ae5855d3c4fc = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
|
|
2442
|
+
var _arrowSize$width, _arrowSize$height, _middlewareData$arrow, _middlewareData$arrow2, _middlewareData$arrow3, _middlewareData$trans, _middlewareData$trans2, _middlewareData$hide;
|
|
2443
|
+
const { __scopePopper, side = "bottom", sideOffset = 0, align = "center", alignOffset = 0, arrowPadding = 0, avoidCollisions = true, collisionBoundary = [], collisionPadding: collisionPaddingProp = 0, sticky = "partial", hideWhenDetached = false, updatePositionStrategy = "optimized", onPlaced, ...contentProps } = props;
|
|
2444
|
+
const context = $cf1ac5d9fe0e8206$var$usePopperContext($cf1ac5d9fe0e8206$var$CONTENT_NAME, __scopePopper);
|
|
2445
|
+
const [content, setContent] = React.useState(null);
|
|
2446
|
+
const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(
|
|
2447
|
+
forwardedRef,
|
|
2448
|
+
(node) => setContent(node)
|
|
2449
|
+
);
|
|
2450
|
+
const [arrow$12, setArrow] = React.useState(null);
|
|
2451
|
+
const arrowSize = $db6c3485150b8e66$export$1ab7ae714698c4b8(arrow$12);
|
|
2452
|
+
const arrowWidth = (_arrowSize$width = arrowSize === null || arrowSize === void 0 ? void 0 : arrowSize.width) !== null && _arrowSize$width !== void 0 ? _arrowSize$width : 0;
|
|
2453
|
+
const arrowHeight = (_arrowSize$height = arrowSize === null || arrowSize === void 0 ? void 0 : arrowSize.height) !== null && _arrowSize$height !== void 0 ? _arrowSize$height : 0;
|
|
2454
|
+
const desiredPlacement = side + (align !== "center" ? "-" + align : "");
|
|
2455
|
+
const collisionPadding = typeof collisionPaddingProp === "number" ? collisionPaddingProp : {
|
|
2456
|
+
top: 0,
|
|
2457
|
+
right: 0,
|
|
2458
|
+
bottom: 0,
|
|
2459
|
+
left: 0,
|
|
2460
|
+
...collisionPaddingProp
|
|
2461
|
+
};
|
|
2462
|
+
const boundary = Array.isArray(collisionBoundary) ? collisionBoundary : [
|
|
2463
|
+
collisionBoundary
|
|
2464
|
+
];
|
|
2465
|
+
const hasExplicitBoundaries = boundary.length > 0;
|
|
2466
|
+
const detectOverflowOptions = {
|
|
2467
|
+
padding: collisionPadding,
|
|
2468
|
+
boundary: boundary.filter($cf1ac5d9fe0e8206$var$isNotNull),
|
|
2469
|
+
// with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
|
|
2470
|
+
altBoundary: hasExplicitBoundaries
|
|
2471
|
+
};
|
|
2472
|
+
const { refs, floatingStyles, placement, isPositioned, middlewareData } = useFloating({
|
|
2473
|
+
// default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
|
|
2474
|
+
strategy: "fixed",
|
|
2475
|
+
placement: desiredPlacement,
|
|
2476
|
+
whileElementsMounted: (...args) => {
|
|
2477
|
+
const cleanup = autoUpdate(...args, {
|
|
2478
|
+
animationFrame: updatePositionStrategy === "always"
|
|
2479
|
+
});
|
|
2480
|
+
return cleanup;
|
|
2481
|
+
},
|
|
2482
|
+
elements: {
|
|
2483
|
+
reference: context.anchor
|
|
2484
|
+
},
|
|
2485
|
+
middleware: [
|
|
2486
|
+
offset({
|
|
2487
|
+
mainAxis: sideOffset + arrowHeight,
|
|
2488
|
+
alignmentAxis: alignOffset
|
|
2489
|
+
}),
|
|
2490
|
+
avoidCollisions && shift({
|
|
2491
|
+
mainAxis: true,
|
|
2492
|
+
crossAxis: false,
|
|
2493
|
+
limiter: sticky === "partial" ? limitShift() : void 0,
|
|
2494
|
+
...detectOverflowOptions
|
|
2495
|
+
}),
|
|
2496
|
+
avoidCollisions && flip({
|
|
2497
|
+
...detectOverflowOptions
|
|
2498
|
+
}),
|
|
2499
|
+
size({
|
|
2500
|
+
...detectOverflowOptions,
|
|
2501
|
+
apply: ({ elements, rects, availableWidth, availableHeight }) => {
|
|
2502
|
+
const { width: anchorWidth, height: anchorHeight } = rects.reference;
|
|
2503
|
+
const contentStyle = elements.floating.style;
|
|
2504
|
+
contentStyle.setProperty("--radix-popper-available-width", `${availableWidth}px`);
|
|
2505
|
+
contentStyle.setProperty("--radix-popper-available-height", `${availableHeight}px`);
|
|
2506
|
+
contentStyle.setProperty("--radix-popper-anchor-width", `${anchorWidth}px`);
|
|
2507
|
+
contentStyle.setProperty("--radix-popper-anchor-height", `${anchorHeight}px`);
|
|
2508
|
+
}
|
|
2509
|
+
}),
|
|
2510
|
+
arrow$12 && arrow({
|
|
2511
|
+
element: arrow$12,
|
|
2512
|
+
padding: arrowPadding
|
|
2513
|
+
}),
|
|
2514
|
+
$cf1ac5d9fe0e8206$var$transformOrigin({
|
|
2515
|
+
arrowWidth,
|
|
2516
|
+
arrowHeight
|
|
2517
|
+
}),
|
|
2518
|
+
hideWhenDetached && hide({
|
|
2519
|
+
strategy: "referenceHidden",
|
|
2520
|
+
...detectOverflowOptions
|
|
2521
|
+
})
|
|
2522
|
+
]
|
|
2523
|
+
});
|
|
2524
|
+
const [placedSide, placedAlign] = $cf1ac5d9fe0e8206$var$getSideAndAlignFromPlacement(placement);
|
|
2525
|
+
const handlePlaced = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onPlaced);
|
|
2526
|
+
$9f79659886946c16$export$e5c5a5f917a5871c(() => {
|
|
2527
|
+
if (isPositioned) handlePlaced === null || handlePlaced === void 0 || handlePlaced();
|
|
2528
|
+
}, [
|
|
2529
|
+
isPositioned,
|
|
2530
|
+
handlePlaced
|
|
2531
|
+
]);
|
|
2532
|
+
const arrowX = (_middlewareData$arrow = middlewareData.arrow) === null || _middlewareData$arrow === void 0 ? void 0 : _middlewareData$arrow.x;
|
|
2533
|
+
const arrowY = (_middlewareData$arrow2 = middlewareData.arrow) === null || _middlewareData$arrow2 === void 0 ? void 0 : _middlewareData$arrow2.y;
|
|
2534
|
+
const cannotCenterArrow = ((_middlewareData$arrow3 = middlewareData.arrow) === null || _middlewareData$arrow3 === void 0 ? void 0 : _middlewareData$arrow3.centerOffset) !== 0;
|
|
2535
|
+
const [contentZIndex, setContentZIndex] = React.useState();
|
|
2536
|
+
$9f79659886946c16$export$e5c5a5f917a5871c(() => {
|
|
2537
|
+
if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
|
|
2538
|
+
}, [
|
|
2539
|
+
content
|
|
2540
|
+
]);
|
|
2541
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
2542
|
+
ref: refs.setFloating,
|
|
2543
|
+
"data-radix-popper-content-wrapper": "",
|
|
2544
|
+
style: {
|
|
2545
|
+
...floatingStyles,
|
|
2546
|
+
transform: isPositioned ? floatingStyles.transform : "translate(0, -200%)",
|
|
2547
|
+
// keep off the page when measuring
|
|
2548
|
+
minWidth: "max-content",
|
|
2549
|
+
zIndex: contentZIndex,
|
|
2550
|
+
["--radix-popper-transform-origin"]: [
|
|
2551
|
+
(_middlewareData$trans = middlewareData.transformOrigin) === null || _middlewareData$trans === void 0 ? void 0 : _middlewareData$trans.x,
|
|
2552
|
+
(_middlewareData$trans2 = middlewareData.transformOrigin) === null || _middlewareData$trans2 === void 0 ? void 0 : _middlewareData$trans2.y
|
|
2553
|
+
].join(" ")
|
|
2554
|
+
},
|
|
2555
|
+
dir: props.dir
|
|
2556
|
+
}, /* @__PURE__ */ React.createElement($cf1ac5d9fe0e8206$var$PopperContentProvider, {
|
|
2557
|
+
scope: __scopePopper,
|
|
2558
|
+
placedSide,
|
|
2559
|
+
onArrowChange: setArrow,
|
|
2560
|
+
arrowX,
|
|
2561
|
+
arrowY,
|
|
2562
|
+
shouldHideArrow: cannotCenterArrow
|
|
2563
|
+
}, /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
|
|
2564
|
+
"data-side": placedSide,
|
|
2565
|
+
"data-align": placedAlign
|
|
2566
|
+
}, contentProps, {
|
|
2567
|
+
ref: composedRefs,
|
|
2568
|
+
style: {
|
|
2569
|
+
...contentProps.style,
|
|
2570
|
+
// if the PopperContent hasn't been placed yet (not all measurements done)
|
|
2571
|
+
// we prevent animations so that users's animation don't kick in too early referring wrong sides
|
|
2572
|
+
animation: !isPositioned ? "none" : void 0,
|
|
2573
|
+
// hide the content if using the hide middleware and should be hidden
|
|
2574
|
+
opacity: (_middlewareData$hide = middlewareData.hide) !== null && _middlewareData$hide !== void 0 && _middlewareData$hide.referenceHidden ? 0 : void 0
|
|
2575
|
+
}
|
|
2576
|
+
}))));
|
|
2577
|
+
});
|
|
2578
|
+
const $cf1ac5d9fe0e8206$var$ARROW_NAME = "PopperArrow";
|
|
2579
|
+
const $cf1ac5d9fe0e8206$var$OPPOSITE_SIDE = {
|
|
2580
|
+
top: "bottom",
|
|
2581
|
+
right: "left",
|
|
2582
|
+
bottom: "top",
|
|
2583
|
+
left: "right"
|
|
2584
|
+
};
|
|
2585
|
+
const $cf1ac5d9fe0e8206$export$79d62cd4e10a3fd0 = /* @__PURE__ */ React.forwardRef(function $cf1ac5d9fe0e8206$export$79d62cd4e10a3fd02(props, forwardedRef) {
|
|
2586
|
+
const { __scopePopper, ...arrowProps } = props;
|
|
2587
|
+
const contentContext = $cf1ac5d9fe0e8206$var$useContentContext($cf1ac5d9fe0e8206$var$ARROW_NAME, __scopePopper);
|
|
2588
|
+
const baseSide = $cf1ac5d9fe0e8206$var$OPPOSITE_SIDE[contentContext.placedSide];
|
|
2589
|
+
return (
|
|
2590
|
+
// we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)
|
|
2591
|
+
// doesn't report size as we'd expect on SVG elements.
|
|
2592
|
+
// it reports their bounding box which is effectively the largest path inside the SVG.
|
|
2593
|
+
/* @__PURE__ */ React.createElement("span", {
|
|
2594
|
+
ref: contentContext.onArrowChange,
|
|
2595
|
+
style: {
|
|
2596
|
+
position: "absolute",
|
|
2597
|
+
left: contentContext.arrowX,
|
|
2598
|
+
top: contentContext.arrowY,
|
|
2599
|
+
[baseSide]: 0,
|
|
2600
|
+
transformOrigin: {
|
|
2601
|
+
top: "",
|
|
2602
|
+
right: "0 0",
|
|
2603
|
+
bottom: "center 0",
|
|
2604
|
+
left: "100% 0"
|
|
2605
|
+
}[contentContext.placedSide],
|
|
2606
|
+
transform: {
|
|
2607
|
+
top: "translateY(100%)",
|
|
2608
|
+
right: "translateY(50%) rotate(90deg) translateX(-50%)",
|
|
2609
|
+
bottom: `rotate(180deg)`,
|
|
2610
|
+
left: "translateY(50%) rotate(-90deg) translateX(50%)"
|
|
2611
|
+
}[contentContext.placedSide],
|
|
2612
|
+
visibility: contentContext.shouldHideArrow ? "hidden" : void 0
|
|
2613
|
+
}
|
|
2614
|
+
}, /* @__PURE__ */ React.createElement($7e8f5cd07187803e$export$be92b6f5f03c0fe9, _extends({}, arrowProps, {
|
|
2615
|
+
ref: forwardedRef,
|
|
2616
|
+
style: {
|
|
2617
|
+
...arrowProps.style,
|
|
2618
|
+
// ensures the element can be measured correctly (mostly for if SVG)
|
|
2619
|
+
display: "block"
|
|
2620
|
+
}
|
|
2621
|
+
})))
|
|
2622
|
+
);
|
|
2623
|
+
});
|
|
2624
|
+
/* @__PURE__ */ Object.assign($cf1ac5d9fe0e8206$export$79d62cd4e10a3fd0, {
|
|
2625
|
+
displayName: $cf1ac5d9fe0e8206$var$ARROW_NAME
|
|
2626
|
+
});
|
|
2627
|
+
function $cf1ac5d9fe0e8206$var$isNotNull(value) {
|
|
2628
|
+
return value !== null;
|
|
2629
|
+
}
|
|
2630
|
+
const $cf1ac5d9fe0e8206$var$transformOrigin = (options) => ({
|
|
2631
|
+
name: "transformOrigin",
|
|
2632
|
+
options,
|
|
2633
|
+
fn(data) {
|
|
2634
|
+
var _middlewareData$arrow4, _middlewareData$arrow5, _middlewareData$arrow6, _middlewareData$arrow7, _middlewareData$arrow8;
|
|
2635
|
+
const { placement, rects, middlewareData } = data;
|
|
2636
|
+
const cannotCenterArrow = ((_middlewareData$arrow4 = middlewareData.arrow) === null || _middlewareData$arrow4 === void 0 ? void 0 : _middlewareData$arrow4.centerOffset) !== 0;
|
|
2637
|
+
const isArrowHidden = cannotCenterArrow;
|
|
2638
|
+
const arrowWidth = isArrowHidden ? 0 : options.arrowWidth;
|
|
2639
|
+
const arrowHeight = isArrowHidden ? 0 : options.arrowHeight;
|
|
2640
|
+
const [placedSide, placedAlign] = $cf1ac5d9fe0e8206$var$getSideAndAlignFromPlacement(placement);
|
|
2641
|
+
const noArrowAlign = {
|
|
2642
|
+
start: "0%",
|
|
2643
|
+
center: "50%",
|
|
2644
|
+
end: "100%"
|
|
2645
|
+
}[placedAlign];
|
|
2646
|
+
const arrowXCenter = ((_middlewareData$arrow5 = (_middlewareData$arrow6 = middlewareData.arrow) === null || _middlewareData$arrow6 === void 0 ? void 0 : _middlewareData$arrow6.x) !== null && _middlewareData$arrow5 !== void 0 ? _middlewareData$arrow5 : 0) + arrowWidth / 2;
|
|
2647
|
+
const arrowYCenter = ((_middlewareData$arrow7 = (_middlewareData$arrow8 = middlewareData.arrow) === null || _middlewareData$arrow8 === void 0 ? void 0 : _middlewareData$arrow8.y) !== null && _middlewareData$arrow7 !== void 0 ? _middlewareData$arrow7 : 0) + arrowHeight / 2;
|
|
2648
|
+
let x = "";
|
|
2649
|
+
let y = "";
|
|
2650
|
+
if (placedSide === "bottom") {
|
|
2651
|
+
x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
|
|
2652
|
+
y = `${-arrowHeight}px`;
|
|
2653
|
+
} else if (placedSide === "top") {
|
|
2654
|
+
x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
|
|
2655
|
+
y = `${rects.floating.height + arrowHeight}px`;
|
|
2656
|
+
} else if (placedSide === "right") {
|
|
2657
|
+
x = `${-arrowHeight}px`;
|
|
2658
|
+
y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
|
|
2659
|
+
} else if (placedSide === "left") {
|
|
2660
|
+
x = `${rects.floating.width + arrowHeight}px`;
|
|
2661
|
+
y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
|
|
2662
|
+
}
|
|
2663
|
+
return {
|
|
2664
|
+
data: {
|
|
2665
|
+
x,
|
|
2666
|
+
y
|
|
2667
|
+
}
|
|
2668
|
+
};
|
|
2669
|
+
}
|
|
2670
|
+
});
|
|
2671
|
+
function $cf1ac5d9fe0e8206$var$getSideAndAlignFromPlacement(placement) {
|
|
2672
|
+
const [side, align = "center"] = placement.split("-");
|
|
2673
|
+
return [
|
|
2674
|
+
side,
|
|
2675
|
+
align
|
|
2676
|
+
];
|
|
2677
|
+
}
|
|
2678
|
+
const $cf1ac5d9fe0e8206$export$be92b6f5f03c0fe9 = $cf1ac5d9fe0e8206$export$badac9ada3a0bdf9;
|
|
2679
|
+
const $cf1ac5d9fe0e8206$export$b688253958b8dfe7 = $cf1ac5d9fe0e8206$export$ecd4e1ccab6ed6d;
|
|
2680
|
+
const $cf1ac5d9fe0e8206$export$7c6e2c02157bb7d2 = $cf1ac5d9fe0e8206$export$bc4ae5855d3c4fc;
|
|
2681
|
+
const $cf1ac5d9fe0e8206$export$21b07c8f274aebd5 = $cf1ac5d9fe0e8206$export$79d62cd4e10a3fd0;
|
|
2682
|
+
const $f1701beae083dbae$export$602eac185826482c = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
|
|
2683
|
+
var _globalThis$document;
|
|
2684
|
+
const { container = globalThis === null || globalThis === void 0 ? void 0 : (_globalThis$document = globalThis.document) === null || _globalThis$document === void 0 ? void 0 : _globalThis$document.body, ...portalProps } = props;
|
|
2685
|
+
return container ? /* @__PURE__ */ ReactDOM__namespace.default.createPortal(/* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({}, portalProps, {
|
|
2686
|
+
ref: forwardedRef
|
|
2687
|
+
})), container) : null;
|
|
2688
|
+
});
|
|
2689
|
+
function $fe963b355347cc68$export$3e6543de14f8614f(initialState, machine) {
|
|
2690
|
+
return React.useReducer((state, event) => {
|
|
2691
|
+
const nextState = machine[state][event];
|
|
2692
|
+
return nextState !== null && nextState !== void 0 ? nextState : state;
|
|
2693
|
+
}, initialState);
|
|
2694
|
+
}
|
|
2695
|
+
const $921a889cee6df7e8$export$99c2b779aa4e8b8b = (props) => {
|
|
2696
|
+
const { present, children } = props;
|
|
2697
|
+
const presence = $921a889cee6df7e8$var$usePresence(present);
|
|
2698
|
+
const child = typeof children === "function" ? children({
|
|
2699
|
+
present: presence.isPresent
|
|
2700
|
+
}) : React.Children.only(children);
|
|
2701
|
+
const ref = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(presence.ref, child.ref);
|
|
2702
|
+
const forceMount = typeof children === "function";
|
|
2703
|
+
return forceMount || presence.isPresent ? /* @__PURE__ */ React.cloneElement(child, {
|
|
2704
|
+
ref
|
|
2705
|
+
}) : null;
|
|
2706
|
+
};
|
|
2707
|
+
$921a889cee6df7e8$export$99c2b779aa4e8b8b.displayName = "Presence";
|
|
2708
|
+
function $921a889cee6df7e8$var$usePresence(present) {
|
|
2709
|
+
const [node1, setNode] = React.useState();
|
|
2710
|
+
const stylesRef = React.useRef({});
|
|
2711
|
+
const prevPresentRef = React.useRef(present);
|
|
2712
|
+
const prevAnimationNameRef = React.useRef("none");
|
|
2713
|
+
const initialState = present ? "mounted" : "unmounted";
|
|
2714
|
+
const [state, send] = $fe963b355347cc68$export$3e6543de14f8614f(initialState, {
|
|
2715
|
+
mounted: {
|
|
2716
|
+
UNMOUNT: "unmounted",
|
|
2717
|
+
ANIMATION_OUT: "unmountSuspended"
|
|
2718
|
+
},
|
|
2719
|
+
unmountSuspended: {
|
|
2720
|
+
MOUNT: "mounted",
|
|
2721
|
+
ANIMATION_END: "unmounted"
|
|
2722
|
+
},
|
|
2723
|
+
unmounted: {
|
|
2724
|
+
MOUNT: "mounted"
|
|
2725
|
+
}
|
|
2726
|
+
});
|
|
2727
|
+
React.useEffect(() => {
|
|
2728
|
+
const currentAnimationName = $921a889cee6df7e8$var$getAnimationName(stylesRef.current);
|
|
2729
|
+
prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none";
|
|
2730
|
+
}, [
|
|
2731
|
+
state
|
|
2732
|
+
]);
|
|
2733
|
+
$9f79659886946c16$export$e5c5a5f917a5871c(() => {
|
|
2734
|
+
const styles = stylesRef.current;
|
|
2735
|
+
const wasPresent = prevPresentRef.current;
|
|
2736
|
+
const hasPresentChanged = wasPresent !== present;
|
|
2737
|
+
if (hasPresentChanged) {
|
|
2738
|
+
const prevAnimationName = prevAnimationNameRef.current;
|
|
2739
|
+
const currentAnimationName = $921a889cee6df7e8$var$getAnimationName(styles);
|
|
2740
|
+
if (present) send("MOUNT");
|
|
2741
|
+
else if (currentAnimationName === "none" || (styles === null || styles === void 0 ? void 0 : styles.display) === "none")
|
|
2742
|
+
send("UNMOUNT");
|
|
2743
|
+
else {
|
|
2744
|
+
const isAnimating = prevAnimationName !== currentAnimationName;
|
|
2745
|
+
if (wasPresent && isAnimating) send("ANIMATION_OUT");
|
|
2746
|
+
else send("UNMOUNT");
|
|
2747
|
+
}
|
|
2748
|
+
prevPresentRef.current = present;
|
|
2749
|
+
}
|
|
2750
|
+
}, [
|
|
2751
|
+
present,
|
|
2752
|
+
send
|
|
2753
|
+
]);
|
|
2754
|
+
$9f79659886946c16$export$e5c5a5f917a5871c(() => {
|
|
2755
|
+
if (node1) {
|
|
2756
|
+
const handleAnimationEnd = (event) => {
|
|
2757
|
+
const currentAnimationName = $921a889cee6df7e8$var$getAnimationName(stylesRef.current);
|
|
2758
|
+
const isCurrentAnimation = currentAnimationName.includes(event.animationName);
|
|
2759
|
+
if (event.target === node1 && isCurrentAnimation)
|
|
2760
|
+
ReactDOM.flushSync(
|
|
2761
|
+
() => send("ANIMATION_END")
|
|
2762
|
+
);
|
|
2763
|
+
};
|
|
2764
|
+
const handleAnimationStart = (event) => {
|
|
2765
|
+
if (event.target === node1)
|
|
2766
|
+
prevAnimationNameRef.current = $921a889cee6df7e8$var$getAnimationName(stylesRef.current);
|
|
2767
|
+
};
|
|
2768
|
+
node1.addEventListener("animationstart", handleAnimationStart);
|
|
2769
|
+
node1.addEventListener("animationcancel", handleAnimationEnd);
|
|
2770
|
+
node1.addEventListener("animationend", handleAnimationEnd);
|
|
2771
|
+
return () => {
|
|
2772
|
+
node1.removeEventListener("animationstart", handleAnimationStart);
|
|
2773
|
+
node1.removeEventListener("animationcancel", handleAnimationEnd);
|
|
2774
|
+
node1.removeEventListener("animationend", handleAnimationEnd);
|
|
2775
|
+
};
|
|
2776
|
+
} else
|
|
2777
|
+
send("ANIMATION_END");
|
|
2778
|
+
}, [
|
|
2779
|
+
node1,
|
|
2780
|
+
send
|
|
2781
|
+
]);
|
|
2782
|
+
return {
|
|
2783
|
+
isPresent: [
|
|
2784
|
+
"mounted",
|
|
2785
|
+
"unmountSuspended"
|
|
2786
|
+
].includes(state),
|
|
2787
|
+
ref: React.useCallback((node) => {
|
|
2788
|
+
if (node) stylesRef.current = getComputedStyle(node);
|
|
2789
|
+
setNode(node);
|
|
2790
|
+
}, [])
|
|
2791
|
+
};
|
|
2792
|
+
}
|
|
2793
|
+
function $921a889cee6df7e8$var$getAnimationName(styles) {
|
|
2794
|
+
return (styles === null || styles === void 0 ? void 0 : styles.animationName) || "none";
|
|
2795
|
+
}
|
|
2796
|
+
function $71cd76cc60e0454e$export$6f32135080cb4c3({ prop, defaultProp, onChange = () => {
|
|
2797
|
+
} }) {
|
|
2798
|
+
const [uncontrolledProp, setUncontrolledProp] = $71cd76cc60e0454e$var$useUncontrolledState({
|
|
2799
|
+
defaultProp,
|
|
2800
|
+
onChange
|
|
2801
|
+
});
|
|
2802
|
+
const isControlled = prop !== void 0;
|
|
2803
|
+
const value1 = isControlled ? prop : uncontrolledProp;
|
|
2804
|
+
const handleChange = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onChange);
|
|
2805
|
+
const setValue = React.useCallback((nextValue) => {
|
|
2806
|
+
if (isControlled) {
|
|
2807
|
+
const setter = nextValue;
|
|
2808
|
+
const value = typeof nextValue === "function" ? setter(prop) : nextValue;
|
|
2809
|
+
if (value !== prop) handleChange(value);
|
|
2810
|
+
} else setUncontrolledProp(nextValue);
|
|
2811
|
+
}, [
|
|
2812
|
+
isControlled,
|
|
2813
|
+
prop,
|
|
2814
|
+
setUncontrolledProp,
|
|
2815
|
+
handleChange
|
|
2816
|
+
]);
|
|
2817
|
+
return [
|
|
2818
|
+
value1,
|
|
2819
|
+
setValue
|
|
2820
|
+
];
|
|
2821
|
+
}
|
|
2822
|
+
function $71cd76cc60e0454e$var$useUncontrolledState({ defaultProp, onChange }) {
|
|
2823
|
+
const uncontrolledState = React.useState(defaultProp);
|
|
2824
|
+
const [value] = uncontrolledState;
|
|
2825
|
+
const prevValueRef = React.useRef(value);
|
|
2826
|
+
const handleChange = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onChange);
|
|
2827
|
+
React.useEffect(() => {
|
|
2828
|
+
if (prevValueRef.current !== value) {
|
|
2829
|
+
handleChange(value);
|
|
2830
|
+
prevValueRef.current = value;
|
|
2831
|
+
}
|
|
2832
|
+
}, [
|
|
2833
|
+
value,
|
|
2834
|
+
prevValueRef,
|
|
2835
|
+
handleChange
|
|
2836
|
+
]);
|
|
2837
|
+
return uncontrolledState;
|
|
2838
|
+
}
|
|
2839
|
+
const $ea1ef594cf570d83$export$439d29a4e110a164 = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
|
|
2840
|
+
return /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends({}, props, {
|
|
2841
|
+
ref: forwardedRef,
|
|
2842
|
+
style: {
|
|
2843
|
+
// See: https://github.com/twbs/bootstrap/blob/master/scss/mixins/_screen-reader.scss
|
|
2844
|
+
position: "absolute",
|
|
2845
|
+
border: 0,
|
|
2846
|
+
width: 1,
|
|
2847
|
+
height: 1,
|
|
2848
|
+
padding: 0,
|
|
2849
|
+
margin: -1,
|
|
2850
|
+
overflow: "hidden",
|
|
2851
|
+
clip: "rect(0, 0, 0, 0)",
|
|
2852
|
+
whiteSpace: "nowrap",
|
|
2853
|
+
wordWrap: "normal",
|
|
2854
|
+
...props.style
|
|
2855
|
+
}
|
|
2856
|
+
}));
|
|
2857
|
+
});
|
|
2858
|
+
const $ea1ef594cf570d83$export$be92b6f5f03c0fe9 = $ea1ef594cf570d83$export$439d29a4e110a164;
|
|
2859
|
+
const [$a093c7e1ec25a057$var$createTooltipContext] = $c512c27ab02ef895$export$50c7b4e9d9f19c1("Tooltip", [
|
|
2860
|
+
$cf1ac5d9fe0e8206$export$722aac194ae923
|
|
2861
|
+
]);
|
|
2862
|
+
const $a093c7e1ec25a057$var$usePopperScope = $cf1ac5d9fe0e8206$export$722aac194ae923();
|
|
2863
|
+
const $a093c7e1ec25a057$var$PROVIDER_NAME = "TooltipProvider";
|
|
2864
|
+
const $a093c7e1ec25a057$var$DEFAULT_DELAY_DURATION = 700;
|
|
2865
|
+
const $a093c7e1ec25a057$var$TOOLTIP_OPEN = "tooltip.open";
|
|
2866
|
+
const [$a093c7e1ec25a057$var$TooltipProviderContextProvider, $a093c7e1ec25a057$var$useTooltipProviderContext] = $a093c7e1ec25a057$var$createTooltipContext($a093c7e1ec25a057$var$PROVIDER_NAME);
|
|
2867
|
+
const $a093c7e1ec25a057$export$f78649fb9ca566b8 = (props) => {
|
|
2868
|
+
const { __scopeTooltip, delayDuration = $a093c7e1ec25a057$var$DEFAULT_DELAY_DURATION, skipDelayDuration = 300, disableHoverableContent = false, children } = props;
|
|
2869
|
+
const [isOpenDelayed, setIsOpenDelayed] = React.useState(true);
|
|
2870
|
+
const isPointerInTransitRef = React.useRef(false);
|
|
2871
|
+
const skipDelayTimerRef = React.useRef(0);
|
|
2872
|
+
React.useEffect(() => {
|
|
2873
|
+
const skipDelayTimer = skipDelayTimerRef.current;
|
|
2874
|
+
return () => window.clearTimeout(skipDelayTimer);
|
|
2875
|
+
}, []);
|
|
2876
|
+
return /* @__PURE__ */ React.createElement($a093c7e1ec25a057$var$TooltipProviderContextProvider, {
|
|
2877
|
+
scope: __scopeTooltip,
|
|
2878
|
+
isOpenDelayed,
|
|
2879
|
+
delayDuration,
|
|
2880
|
+
onOpen: React.useCallback(() => {
|
|
2881
|
+
window.clearTimeout(skipDelayTimerRef.current);
|
|
2882
|
+
setIsOpenDelayed(false);
|
|
2883
|
+
}, []),
|
|
2884
|
+
onClose: React.useCallback(() => {
|
|
2885
|
+
window.clearTimeout(skipDelayTimerRef.current);
|
|
2886
|
+
skipDelayTimerRef.current = window.setTimeout(
|
|
2887
|
+
() => setIsOpenDelayed(true),
|
|
2888
|
+
skipDelayDuration
|
|
2889
|
+
);
|
|
2890
|
+
}, [
|
|
2891
|
+
skipDelayDuration
|
|
2892
|
+
]),
|
|
2893
|
+
isPointerInTransitRef,
|
|
2894
|
+
onPointerInTransitChange: React.useCallback((inTransit) => {
|
|
2895
|
+
isPointerInTransitRef.current = inTransit;
|
|
2896
|
+
}, []),
|
|
2897
|
+
disableHoverableContent
|
|
2898
|
+
}, children);
|
|
2899
|
+
};
|
|
2900
|
+
const $a093c7e1ec25a057$var$TOOLTIP_NAME = "Tooltip";
|
|
2901
|
+
const [$a093c7e1ec25a057$var$TooltipContextProvider, $a093c7e1ec25a057$var$useTooltipContext] = $a093c7e1ec25a057$var$createTooltipContext($a093c7e1ec25a057$var$TOOLTIP_NAME);
|
|
2902
|
+
const $a093c7e1ec25a057$export$28c660c63b792dea = (props) => {
|
|
2903
|
+
const { __scopeTooltip, children, open: openProp, defaultOpen = false, onOpenChange, disableHoverableContent: disableHoverableContentProp, delayDuration: delayDurationProp } = props;
|
|
2904
|
+
const providerContext = $a093c7e1ec25a057$var$useTooltipProviderContext($a093c7e1ec25a057$var$TOOLTIP_NAME, props.__scopeTooltip);
|
|
2905
|
+
const popperScope = $a093c7e1ec25a057$var$usePopperScope(__scopeTooltip);
|
|
2906
|
+
const [trigger, setTrigger] = React.useState(null);
|
|
2907
|
+
const contentId = $1746a345f3d73bb7$export$f680877a34711e37();
|
|
2908
|
+
const openTimerRef = React.useRef(0);
|
|
2909
|
+
const disableHoverableContent = disableHoverableContentProp !== null && disableHoverableContentProp !== void 0 ? disableHoverableContentProp : providerContext.disableHoverableContent;
|
|
2910
|
+
const delayDuration = delayDurationProp !== null && delayDurationProp !== void 0 ? delayDurationProp : providerContext.delayDuration;
|
|
2911
|
+
const wasOpenDelayedRef = React.useRef(false);
|
|
2912
|
+
const [open1 = false, setOpen] = $71cd76cc60e0454e$export$6f32135080cb4c3({
|
|
2913
|
+
prop: openProp,
|
|
2914
|
+
defaultProp: defaultOpen,
|
|
2915
|
+
onChange: (open) => {
|
|
2916
|
+
if (open) {
|
|
2917
|
+
providerContext.onOpen();
|
|
2918
|
+
document.dispatchEvent(new CustomEvent($a093c7e1ec25a057$var$TOOLTIP_OPEN));
|
|
2919
|
+
} else providerContext.onClose();
|
|
2920
|
+
onOpenChange === null || onOpenChange === void 0 || onOpenChange(open);
|
|
2921
|
+
}
|
|
2922
|
+
});
|
|
2923
|
+
const stateAttribute = React.useMemo(() => {
|
|
2924
|
+
return open1 ? wasOpenDelayedRef.current ? "delayed-open" : "instant-open" : "closed";
|
|
2925
|
+
}, [
|
|
2926
|
+
open1
|
|
2927
|
+
]);
|
|
2928
|
+
const handleOpen = React.useCallback(() => {
|
|
2929
|
+
window.clearTimeout(openTimerRef.current);
|
|
2930
|
+
wasOpenDelayedRef.current = false;
|
|
2931
|
+
setOpen(true);
|
|
2932
|
+
}, [
|
|
2933
|
+
setOpen
|
|
2934
|
+
]);
|
|
2935
|
+
const handleClose = React.useCallback(() => {
|
|
2936
|
+
window.clearTimeout(openTimerRef.current);
|
|
2937
|
+
setOpen(false);
|
|
2938
|
+
}, [
|
|
2939
|
+
setOpen
|
|
2940
|
+
]);
|
|
2941
|
+
const handleDelayedOpen = React.useCallback(() => {
|
|
2942
|
+
window.clearTimeout(openTimerRef.current);
|
|
2943
|
+
openTimerRef.current = window.setTimeout(() => {
|
|
2944
|
+
wasOpenDelayedRef.current = true;
|
|
2945
|
+
setOpen(true);
|
|
2946
|
+
}, delayDuration);
|
|
2947
|
+
}, [
|
|
2948
|
+
delayDuration,
|
|
2949
|
+
setOpen
|
|
2950
|
+
]);
|
|
2951
|
+
React.useEffect(() => {
|
|
2952
|
+
return () => window.clearTimeout(openTimerRef.current);
|
|
2953
|
+
}, []);
|
|
2954
|
+
return /* @__PURE__ */ React.createElement($cf1ac5d9fe0e8206$export$be92b6f5f03c0fe9, popperScope, /* @__PURE__ */ React.createElement($a093c7e1ec25a057$var$TooltipContextProvider, {
|
|
2955
|
+
scope: __scopeTooltip,
|
|
2956
|
+
contentId,
|
|
2957
|
+
open: open1,
|
|
2958
|
+
stateAttribute,
|
|
2959
|
+
trigger,
|
|
2960
|
+
onTriggerChange: setTrigger,
|
|
2961
|
+
onTriggerEnter: React.useCallback(() => {
|
|
2962
|
+
if (providerContext.isOpenDelayed) handleDelayedOpen();
|
|
2963
|
+
else handleOpen();
|
|
2964
|
+
}, [
|
|
2965
|
+
providerContext.isOpenDelayed,
|
|
2966
|
+
handleDelayedOpen,
|
|
2967
|
+
handleOpen
|
|
2968
|
+
]),
|
|
2969
|
+
onTriggerLeave: React.useCallback(() => {
|
|
2970
|
+
if (disableHoverableContent) handleClose();
|
|
2971
|
+
else
|
|
2972
|
+
window.clearTimeout(openTimerRef.current);
|
|
2973
|
+
}, [
|
|
2974
|
+
handleClose,
|
|
2975
|
+
disableHoverableContent
|
|
2976
|
+
]),
|
|
2977
|
+
onOpen: handleOpen,
|
|
2978
|
+
onClose: handleClose,
|
|
2979
|
+
disableHoverableContent
|
|
2980
|
+
}, children));
|
|
2981
|
+
};
|
|
2982
|
+
const $a093c7e1ec25a057$var$TRIGGER_NAME = "TooltipTrigger";
|
|
2983
|
+
const $a093c7e1ec25a057$export$8c610744efcf8a1d = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
|
|
2984
|
+
const { __scopeTooltip, ...triggerProps } = props;
|
|
2985
|
+
const context = $a093c7e1ec25a057$var$useTooltipContext($a093c7e1ec25a057$var$TRIGGER_NAME, __scopeTooltip);
|
|
2986
|
+
const providerContext = $a093c7e1ec25a057$var$useTooltipProviderContext($a093c7e1ec25a057$var$TRIGGER_NAME, __scopeTooltip);
|
|
2987
|
+
const popperScope = $a093c7e1ec25a057$var$usePopperScope(__scopeTooltip);
|
|
2988
|
+
const ref = React.useRef(null);
|
|
2989
|
+
const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, ref, context.onTriggerChange);
|
|
2990
|
+
const isPointerDownRef = React.useRef(false);
|
|
2991
|
+
const hasPointerMoveOpenedRef = React.useRef(false);
|
|
2992
|
+
const handlePointerUp = React.useCallback(
|
|
2993
|
+
() => isPointerDownRef.current = false,
|
|
2994
|
+
[]
|
|
2995
|
+
);
|
|
2996
|
+
React.useEffect(() => {
|
|
2997
|
+
return () => document.removeEventListener("pointerup", handlePointerUp);
|
|
2998
|
+
}, [
|
|
2999
|
+
handlePointerUp
|
|
3000
|
+
]);
|
|
3001
|
+
return /* @__PURE__ */ React.createElement($cf1ac5d9fe0e8206$export$b688253958b8dfe7, _extends({
|
|
3002
|
+
asChild: true
|
|
3003
|
+
}, popperScope), /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.button, _extends({
|
|
3004
|
+
// We purposefully avoid adding `type=button` here because tooltip triggers are also
|
|
3005
|
+
// commonly anchors and the anchor `type` attribute signifies MIME type.
|
|
3006
|
+
"aria-describedby": context.open ? context.contentId : void 0,
|
|
3007
|
+
"data-state": context.stateAttribute
|
|
3008
|
+
}, triggerProps, {
|
|
3009
|
+
ref: composedRefs,
|
|
3010
|
+
onPointerMove: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onPointerMove, (event) => {
|
|
3011
|
+
if (event.pointerType === "touch") return;
|
|
3012
|
+
if (!hasPointerMoveOpenedRef.current && !providerContext.isPointerInTransitRef.current) {
|
|
3013
|
+
context.onTriggerEnter();
|
|
3014
|
+
hasPointerMoveOpenedRef.current = true;
|
|
3015
|
+
}
|
|
3016
|
+
}),
|
|
3017
|
+
onPointerLeave: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onPointerLeave, () => {
|
|
3018
|
+
context.onTriggerLeave();
|
|
3019
|
+
hasPointerMoveOpenedRef.current = false;
|
|
3020
|
+
}),
|
|
3021
|
+
onPointerDown: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onPointerDown, () => {
|
|
3022
|
+
isPointerDownRef.current = true;
|
|
3023
|
+
document.addEventListener("pointerup", handlePointerUp, {
|
|
3024
|
+
once: true
|
|
3025
|
+
});
|
|
3026
|
+
}),
|
|
3027
|
+
onFocus: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onFocus, () => {
|
|
3028
|
+
if (!isPointerDownRef.current) context.onOpen();
|
|
3029
|
+
}),
|
|
3030
|
+
onBlur: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onBlur, context.onClose),
|
|
3031
|
+
onClick: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onClick, context.onClose)
|
|
3032
|
+
})));
|
|
3033
|
+
});
|
|
3034
|
+
const $a093c7e1ec25a057$var$PORTAL_NAME = "TooltipPortal";
|
|
3035
|
+
const [$a093c7e1ec25a057$var$PortalProvider, $a093c7e1ec25a057$var$usePortalContext] = $a093c7e1ec25a057$var$createTooltipContext($a093c7e1ec25a057$var$PORTAL_NAME, {
|
|
3036
|
+
forceMount: void 0
|
|
3037
|
+
});
|
|
3038
|
+
const $a093c7e1ec25a057$export$7b36b8f925ab7497 = (props) => {
|
|
3039
|
+
const { __scopeTooltip, forceMount, children, container } = props;
|
|
3040
|
+
const context = $a093c7e1ec25a057$var$useTooltipContext($a093c7e1ec25a057$var$PORTAL_NAME, __scopeTooltip);
|
|
3041
|
+
return /* @__PURE__ */ React.createElement($a093c7e1ec25a057$var$PortalProvider, {
|
|
3042
|
+
scope: __scopeTooltip,
|
|
3043
|
+
forceMount
|
|
3044
|
+
}, /* @__PURE__ */ React.createElement($921a889cee6df7e8$export$99c2b779aa4e8b8b, {
|
|
3045
|
+
present: forceMount || context.open
|
|
3046
|
+
}, /* @__PURE__ */ React.createElement($f1701beae083dbae$export$602eac185826482c, {
|
|
3047
|
+
asChild: true,
|
|
3048
|
+
container
|
|
3049
|
+
}, children)));
|
|
3050
|
+
};
|
|
3051
|
+
const $a093c7e1ec25a057$var$CONTENT_NAME = "TooltipContent";
|
|
3052
|
+
const $a093c7e1ec25a057$export$e9003e2be37ec060 = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
|
|
3053
|
+
const portalContext = $a093c7e1ec25a057$var$usePortalContext($a093c7e1ec25a057$var$CONTENT_NAME, props.__scopeTooltip);
|
|
3054
|
+
const { forceMount = portalContext.forceMount, side = "top", ...contentProps } = props;
|
|
3055
|
+
const context = $a093c7e1ec25a057$var$useTooltipContext($a093c7e1ec25a057$var$CONTENT_NAME, props.__scopeTooltip);
|
|
3056
|
+
return /* @__PURE__ */ React.createElement($921a889cee6df7e8$export$99c2b779aa4e8b8b, {
|
|
3057
|
+
present: forceMount || context.open
|
|
3058
|
+
}, context.disableHoverableContent ? /* @__PURE__ */ React.createElement($a093c7e1ec25a057$var$TooltipContentImpl, _extends({
|
|
3059
|
+
side
|
|
3060
|
+
}, contentProps, {
|
|
3061
|
+
ref: forwardedRef
|
|
3062
|
+
})) : /* @__PURE__ */ React.createElement($a093c7e1ec25a057$var$TooltipContentHoverable, _extends({
|
|
3063
|
+
side
|
|
3064
|
+
}, contentProps, {
|
|
3065
|
+
ref: forwardedRef
|
|
3066
|
+
})));
|
|
3067
|
+
});
|
|
3068
|
+
const $a093c7e1ec25a057$var$TooltipContentHoverable = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
|
|
3069
|
+
const context = $a093c7e1ec25a057$var$useTooltipContext($a093c7e1ec25a057$var$CONTENT_NAME, props.__scopeTooltip);
|
|
3070
|
+
const providerContext = $a093c7e1ec25a057$var$useTooltipProviderContext($a093c7e1ec25a057$var$CONTENT_NAME, props.__scopeTooltip);
|
|
3071
|
+
const ref = React.useRef(null);
|
|
3072
|
+
const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, ref);
|
|
3073
|
+
const [pointerGraceArea, setPointerGraceArea] = React.useState(null);
|
|
3074
|
+
const { trigger, onClose } = context;
|
|
3075
|
+
const content = ref.current;
|
|
3076
|
+
const { onPointerInTransitChange } = providerContext;
|
|
3077
|
+
const handleRemoveGraceArea = React.useCallback(() => {
|
|
3078
|
+
setPointerGraceArea(null);
|
|
3079
|
+
onPointerInTransitChange(false);
|
|
3080
|
+
}, [
|
|
3081
|
+
onPointerInTransitChange
|
|
3082
|
+
]);
|
|
3083
|
+
const handleCreateGraceArea = React.useCallback((event, hoverTarget) => {
|
|
3084
|
+
const currentTarget = event.currentTarget;
|
|
3085
|
+
const exitPoint = {
|
|
3086
|
+
x: event.clientX,
|
|
3087
|
+
y: event.clientY
|
|
3088
|
+
};
|
|
3089
|
+
const exitSide = $a093c7e1ec25a057$var$getExitSideFromRect(exitPoint, currentTarget.getBoundingClientRect());
|
|
3090
|
+
const paddedExitPoints = $a093c7e1ec25a057$var$getPaddedExitPoints(exitPoint, exitSide);
|
|
3091
|
+
const hoverTargetPoints = $a093c7e1ec25a057$var$getPointsFromRect(hoverTarget.getBoundingClientRect());
|
|
3092
|
+
const graceArea = $a093c7e1ec25a057$var$getHull([
|
|
3093
|
+
...paddedExitPoints,
|
|
3094
|
+
...hoverTargetPoints
|
|
3095
|
+
]);
|
|
3096
|
+
setPointerGraceArea(graceArea);
|
|
3097
|
+
onPointerInTransitChange(true);
|
|
3098
|
+
}, [
|
|
3099
|
+
onPointerInTransitChange
|
|
3100
|
+
]);
|
|
3101
|
+
React.useEffect(() => {
|
|
3102
|
+
return () => handleRemoveGraceArea();
|
|
3103
|
+
}, [
|
|
3104
|
+
handleRemoveGraceArea
|
|
3105
|
+
]);
|
|
3106
|
+
React.useEffect(() => {
|
|
3107
|
+
if (trigger && content) {
|
|
3108
|
+
const handleTriggerLeave = (event) => handleCreateGraceArea(event, content);
|
|
3109
|
+
const handleContentLeave = (event) => handleCreateGraceArea(event, trigger);
|
|
3110
|
+
trigger.addEventListener("pointerleave", handleTriggerLeave);
|
|
3111
|
+
content.addEventListener("pointerleave", handleContentLeave);
|
|
3112
|
+
return () => {
|
|
3113
|
+
trigger.removeEventListener("pointerleave", handleTriggerLeave);
|
|
3114
|
+
content.removeEventListener("pointerleave", handleContentLeave);
|
|
3115
|
+
};
|
|
3116
|
+
}
|
|
3117
|
+
}, [
|
|
3118
|
+
trigger,
|
|
3119
|
+
content,
|
|
3120
|
+
handleCreateGraceArea,
|
|
3121
|
+
handleRemoveGraceArea
|
|
3122
|
+
]);
|
|
3123
|
+
React.useEffect(() => {
|
|
3124
|
+
if (pointerGraceArea) {
|
|
3125
|
+
const handleTrackPointerGrace = (event) => {
|
|
3126
|
+
const target = event.target;
|
|
3127
|
+
const pointerPosition = {
|
|
3128
|
+
x: event.clientX,
|
|
3129
|
+
y: event.clientY
|
|
3130
|
+
};
|
|
3131
|
+
const hasEnteredTarget = (trigger === null || trigger === void 0 ? void 0 : trigger.contains(target)) || (content === null || content === void 0 ? void 0 : content.contains(target));
|
|
3132
|
+
const isPointerOutsideGraceArea = !$a093c7e1ec25a057$var$isPointInPolygon(pointerPosition, pointerGraceArea);
|
|
3133
|
+
if (hasEnteredTarget) handleRemoveGraceArea();
|
|
3134
|
+
else if (isPointerOutsideGraceArea) {
|
|
3135
|
+
handleRemoveGraceArea();
|
|
3136
|
+
onClose();
|
|
3137
|
+
}
|
|
3138
|
+
};
|
|
3139
|
+
document.addEventListener("pointermove", handleTrackPointerGrace);
|
|
3140
|
+
return () => document.removeEventListener("pointermove", handleTrackPointerGrace);
|
|
3141
|
+
}
|
|
3142
|
+
}, [
|
|
3143
|
+
trigger,
|
|
3144
|
+
content,
|
|
3145
|
+
pointerGraceArea,
|
|
3146
|
+
onClose,
|
|
3147
|
+
handleRemoveGraceArea
|
|
3148
|
+
]);
|
|
3149
|
+
return /* @__PURE__ */ React.createElement($a093c7e1ec25a057$var$TooltipContentImpl, _extends({}, props, {
|
|
3150
|
+
ref: composedRefs
|
|
3151
|
+
}));
|
|
3152
|
+
});
|
|
3153
|
+
const [$a093c7e1ec25a057$var$VisuallyHiddenContentContextProvider, $a093c7e1ec25a057$var$useVisuallyHiddenContentContext] = $a093c7e1ec25a057$var$createTooltipContext($a093c7e1ec25a057$var$TOOLTIP_NAME, {
|
|
3154
|
+
isInside: false
|
|
3155
|
+
});
|
|
3156
|
+
const $a093c7e1ec25a057$var$TooltipContentImpl = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
|
|
3157
|
+
const { __scopeTooltip, children, "aria-label": ariaLabel, onEscapeKeyDown, onPointerDownOutside, ...contentProps } = props;
|
|
3158
|
+
const context = $a093c7e1ec25a057$var$useTooltipContext($a093c7e1ec25a057$var$CONTENT_NAME, __scopeTooltip);
|
|
3159
|
+
const popperScope = $a093c7e1ec25a057$var$usePopperScope(__scopeTooltip);
|
|
3160
|
+
const { onClose } = context;
|
|
3161
|
+
React.useEffect(() => {
|
|
3162
|
+
document.addEventListener($a093c7e1ec25a057$var$TOOLTIP_OPEN, onClose);
|
|
3163
|
+
return () => document.removeEventListener($a093c7e1ec25a057$var$TOOLTIP_OPEN, onClose);
|
|
3164
|
+
}, [
|
|
3165
|
+
onClose
|
|
3166
|
+
]);
|
|
3167
|
+
React.useEffect(() => {
|
|
3168
|
+
if (context.trigger) {
|
|
3169
|
+
const handleScroll = (event) => {
|
|
3170
|
+
const target = event.target;
|
|
3171
|
+
if (target !== null && target !== void 0 && target.contains(context.trigger)) onClose();
|
|
3172
|
+
};
|
|
3173
|
+
window.addEventListener("scroll", handleScroll, {
|
|
3174
|
+
capture: true
|
|
3175
|
+
});
|
|
3176
|
+
return () => window.removeEventListener("scroll", handleScroll, {
|
|
3177
|
+
capture: true
|
|
3178
|
+
});
|
|
3179
|
+
}
|
|
3180
|
+
}, [
|
|
3181
|
+
context.trigger,
|
|
3182
|
+
onClose
|
|
3183
|
+
]);
|
|
3184
|
+
return /* @__PURE__ */ React.createElement($5cb92bef7577960e$export$177fb62ff3ec1f22, {
|
|
3185
|
+
asChild: true,
|
|
3186
|
+
disableOutsidePointerEvents: false,
|
|
3187
|
+
onEscapeKeyDown,
|
|
3188
|
+
onPointerDownOutside,
|
|
3189
|
+
onFocusOutside: (event) => event.preventDefault(),
|
|
3190
|
+
onDismiss: onClose
|
|
3191
|
+
}, /* @__PURE__ */ React.createElement($cf1ac5d9fe0e8206$export$7c6e2c02157bb7d2, _extends({
|
|
3192
|
+
"data-state": context.stateAttribute
|
|
3193
|
+
}, popperScope, contentProps, {
|
|
3194
|
+
ref: forwardedRef,
|
|
3195
|
+
style: {
|
|
3196
|
+
...contentProps.style,
|
|
3197
|
+
"--radix-tooltip-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
3198
|
+
"--radix-tooltip-content-available-width": "var(--radix-popper-available-width)",
|
|
3199
|
+
"--radix-tooltip-content-available-height": "var(--radix-popper-available-height)",
|
|
3200
|
+
"--radix-tooltip-trigger-width": "var(--radix-popper-anchor-width)",
|
|
3201
|
+
"--radix-tooltip-trigger-height": "var(--radix-popper-anchor-height)"
|
|
3202
|
+
}
|
|
3203
|
+
}), /* @__PURE__ */ React.createElement($5e63c961fc1ce211$export$d9f1ccf0bdb05d45, null, children), /* @__PURE__ */ React.createElement($a093c7e1ec25a057$var$VisuallyHiddenContentContextProvider, {
|
|
3204
|
+
scope: __scopeTooltip,
|
|
3205
|
+
isInside: true
|
|
3206
|
+
}, /* @__PURE__ */ React.createElement($ea1ef594cf570d83$export$be92b6f5f03c0fe9, {
|
|
3207
|
+
id: context.contentId,
|
|
3208
|
+
role: "tooltip"
|
|
3209
|
+
}, ariaLabel || children))));
|
|
3210
|
+
});
|
|
3211
|
+
const $a093c7e1ec25a057$var$ARROW_NAME = "TooltipArrow";
|
|
3212
|
+
const $a093c7e1ec25a057$export$c27ee0ad710f7559 = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
|
|
3213
|
+
const { __scopeTooltip, ...arrowProps } = props;
|
|
3214
|
+
const popperScope = $a093c7e1ec25a057$var$usePopperScope(__scopeTooltip);
|
|
3215
|
+
const visuallyHiddenContentContext = $a093c7e1ec25a057$var$useVisuallyHiddenContentContext($a093c7e1ec25a057$var$ARROW_NAME, __scopeTooltip);
|
|
3216
|
+
return visuallyHiddenContentContext.isInside ? null : /* @__PURE__ */ React.createElement($cf1ac5d9fe0e8206$export$21b07c8f274aebd5, _extends({}, popperScope, arrowProps, {
|
|
3217
|
+
ref: forwardedRef
|
|
3218
|
+
}));
|
|
3219
|
+
});
|
|
3220
|
+
function $a093c7e1ec25a057$var$getExitSideFromRect(point, rect) {
|
|
3221
|
+
const top = Math.abs(rect.top - point.y);
|
|
3222
|
+
const bottom = Math.abs(rect.bottom - point.y);
|
|
3223
|
+
const right = Math.abs(rect.right - point.x);
|
|
3224
|
+
const left = Math.abs(rect.left - point.x);
|
|
3225
|
+
switch (Math.min(top, bottom, right, left)) {
|
|
3226
|
+
case left:
|
|
3227
|
+
return "left";
|
|
3228
|
+
case right:
|
|
3229
|
+
return "right";
|
|
3230
|
+
case top:
|
|
3231
|
+
return "top";
|
|
3232
|
+
case bottom:
|
|
3233
|
+
return "bottom";
|
|
3234
|
+
default:
|
|
3235
|
+
throw new Error("unreachable");
|
|
3236
|
+
}
|
|
3237
|
+
}
|
|
3238
|
+
function $a093c7e1ec25a057$var$getPaddedExitPoints(exitPoint, exitSide, padding = 5) {
|
|
3239
|
+
const paddedExitPoints = [];
|
|
3240
|
+
switch (exitSide) {
|
|
3241
|
+
case "top":
|
|
3242
|
+
paddedExitPoints.push({
|
|
3243
|
+
x: exitPoint.x - padding,
|
|
3244
|
+
y: exitPoint.y + padding
|
|
3245
|
+
}, {
|
|
3246
|
+
x: exitPoint.x + padding,
|
|
3247
|
+
y: exitPoint.y + padding
|
|
3248
|
+
});
|
|
3249
|
+
break;
|
|
3250
|
+
case "bottom":
|
|
3251
|
+
paddedExitPoints.push({
|
|
3252
|
+
x: exitPoint.x - padding,
|
|
3253
|
+
y: exitPoint.y - padding
|
|
3254
|
+
}, {
|
|
3255
|
+
x: exitPoint.x + padding,
|
|
3256
|
+
y: exitPoint.y - padding
|
|
3257
|
+
});
|
|
3258
|
+
break;
|
|
3259
|
+
case "left":
|
|
3260
|
+
paddedExitPoints.push({
|
|
3261
|
+
x: exitPoint.x + padding,
|
|
3262
|
+
y: exitPoint.y - padding
|
|
3263
|
+
}, {
|
|
3264
|
+
x: exitPoint.x + padding,
|
|
3265
|
+
y: exitPoint.y + padding
|
|
3266
|
+
});
|
|
3267
|
+
break;
|
|
3268
|
+
case "right":
|
|
3269
|
+
paddedExitPoints.push({
|
|
3270
|
+
x: exitPoint.x - padding,
|
|
3271
|
+
y: exitPoint.y - padding
|
|
3272
|
+
}, {
|
|
3273
|
+
x: exitPoint.x - padding,
|
|
3274
|
+
y: exitPoint.y + padding
|
|
3275
|
+
});
|
|
3276
|
+
break;
|
|
3277
|
+
}
|
|
3278
|
+
return paddedExitPoints;
|
|
3279
|
+
}
|
|
3280
|
+
function $a093c7e1ec25a057$var$getPointsFromRect(rect) {
|
|
3281
|
+
const { top, right, bottom, left } = rect;
|
|
3282
|
+
return [
|
|
3283
|
+
{
|
|
3284
|
+
x: left,
|
|
3285
|
+
y: top
|
|
3286
|
+
},
|
|
3287
|
+
{
|
|
3288
|
+
x: right,
|
|
3289
|
+
y: top
|
|
3290
|
+
},
|
|
3291
|
+
{
|
|
3292
|
+
x: right,
|
|
3293
|
+
y: bottom
|
|
3294
|
+
},
|
|
3295
|
+
{
|
|
3296
|
+
x: left,
|
|
3297
|
+
y: bottom
|
|
3298
|
+
}
|
|
3299
|
+
];
|
|
3300
|
+
}
|
|
3301
|
+
function $a093c7e1ec25a057$var$isPointInPolygon(point, polygon) {
|
|
3302
|
+
const { x, y } = point;
|
|
3303
|
+
let inside = false;
|
|
3304
|
+
for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
|
|
3305
|
+
const xi = polygon[i].x;
|
|
3306
|
+
const yi = polygon[i].y;
|
|
3307
|
+
const xj = polygon[j].x;
|
|
3308
|
+
const yj = polygon[j].y;
|
|
3309
|
+
const intersect = yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi;
|
|
3310
|
+
if (intersect) inside = !inside;
|
|
3311
|
+
}
|
|
3312
|
+
return inside;
|
|
3313
|
+
}
|
|
3314
|
+
function $a093c7e1ec25a057$var$getHull(points) {
|
|
3315
|
+
const newPoints = points.slice();
|
|
3316
|
+
newPoints.sort((a, b) => {
|
|
3317
|
+
if (a.x < b.x) return -1;
|
|
3318
|
+
else if (a.x > b.x) return 1;
|
|
3319
|
+
else if (a.y < b.y) return -1;
|
|
3320
|
+
else if (a.y > b.y) return 1;
|
|
3321
|
+
else return 0;
|
|
3322
|
+
});
|
|
3323
|
+
return $a093c7e1ec25a057$var$getHullPresorted(newPoints);
|
|
3324
|
+
}
|
|
3325
|
+
function $a093c7e1ec25a057$var$getHullPresorted(points) {
|
|
3326
|
+
if (points.length <= 1) return points.slice();
|
|
3327
|
+
const upperHull = [];
|
|
3328
|
+
for (let i = 0; i < points.length; i++) {
|
|
3329
|
+
const p = points[i];
|
|
3330
|
+
while (upperHull.length >= 2) {
|
|
3331
|
+
const q = upperHull[upperHull.length - 1];
|
|
3332
|
+
const r = upperHull[upperHull.length - 2];
|
|
3333
|
+
if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x)) upperHull.pop();
|
|
3334
|
+
else break;
|
|
3335
|
+
}
|
|
3336
|
+
upperHull.push(p);
|
|
3337
|
+
}
|
|
3338
|
+
upperHull.pop();
|
|
3339
|
+
const lowerHull = [];
|
|
3340
|
+
for (let i1 = points.length - 1; i1 >= 0; i1--) {
|
|
3341
|
+
const p = points[i1];
|
|
3342
|
+
while (lowerHull.length >= 2) {
|
|
3343
|
+
const q = lowerHull[lowerHull.length - 1];
|
|
3344
|
+
const r = lowerHull[lowerHull.length - 2];
|
|
3345
|
+
if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x)) lowerHull.pop();
|
|
3346
|
+
else break;
|
|
3347
|
+
}
|
|
3348
|
+
lowerHull.push(p);
|
|
3349
|
+
}
|
|
3350
|
+
lowerHull.pop();
|
|
3351
|
+
if (upperHull.length === 1 && lowerHull.length === 1 && upperHull[0].x === lowerHull[0].x && upperHull[0].y === lowerHull[0].y) return upperHull;
|
|
3352
|
+
else return upperHull.concat(lowerHull);
|
|
3353
|
+
}
|
|
3354
|
+
const $a093c7e1ec25a057$export$2881499e37b75b9a = $a093c7e1ec25a057$export$f78649fb9ca566b8;
|
|
3355
|
+
const $a093c7e1ec25a057$export$be92b6f5f03c0fe9 = $a093c7e1ec25a057$export$28c660c63b792dea;
|
|
3356
|
+
const $a093c7e1ec25a057$export$41fb9f06171c75f4 = $a093c7e1ec25a057$export$8c610744efcf8a1d;
|
|
3357
|
+
const $a093c7e1ec25a057$export$602eac185826482c = $a093c7e1ec25a057$export$7b36b8f925ab7497;
|
|
3358
|
+
const $a093c7e1ec25a057$export$7c6e2c02157bb7d2 = $a093c7e1ec25a057$export$e9003e2be37ec060;
|
|
3359
|
+
const $a093c7e1ec25a057$export$21b07c8f274aebd5 = $a093c7e1ec25a057$export$c27ee0ad710f7559;
|
|
3360
|
+
const TooltipIconButton = ({ children, label, variant, onClick, disabled, showBorder = false }) => {
|
|
3361
|
+
if (!label)
|
|
3362
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.IconButton, { variant, onClick, disabled, withTooltip: false, children });
|
|
3363
|
+
const tooltipContent = showBorder ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3364
|
+
designSystem.Box,
|
|
3365
|
+
{
|
|
3366
|
+
padding: 4,
|
|
3367
|
+
margin: 2,
|
|
3368
|
+
background: "neutral0",
|
|
3369
|
+
hasRadius: true,
|
|
3370
|
+
shadow: "filterShadow",
|
|
3371
|
+
children: [
|
|
3372
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: label }),
|
|
3373
|
+
/* @__PURE__ */ jsxRuntime.jsx($a093c7e1ec25a057$export$21b07c8f274aebd5, {})
|
|
3374
|
+
]
|
|
3375
|
+
}
|
|
3376
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3377
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: label }),
|
|
3378
|
+
/* @__PURE__ */ jsxRuntime.jsx($a093c7e1ec25a057$export$21b07c8f274aebd5, {})
|
|
3379
|
+
] });
|
|
3380
|
+
return /* @__PURE__ */ jsxRuntime.jsx($a093c7e1ec25a057$export$2881499e37b75b9a, { children: /* @__PURE__ */ jsxRuntime.jsxs($a093c7e1ec25a057$export$be92b6f5f03c0fe9, { children: [
|
|
3381
|
+
/* @__PURE__ */ jsxRuntime.jsx($a093c7e1ec25a057$export$41fb9f06171c75f4, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.IconButton, { variant, onClick, disabled, withTooltip: false, children }) }),
|
|
3382
|
+
/* @__PURE__ */ jsxRuntime.jsx($a093c7e1ec25a057$export$602eac185826482c, { children: /* @__PURE__ */ jsxRuntime.jsx($a093c7e1ec25a057$export$7c6e2c02157bb7d2, { sideOffset: 5, children: tooltipContent }) })
|
|
3383
|
+
] }) });
|
|
3384
|
+
};
|
|
3385
|
+
const SettingsTextField = (props) => {
|
|
3386
|
+
const {
|
|
3387
|
+
fieldName,
|
|
3388
|
+
displayName,
|
|
3389
|
+
required,
|
|
3390
|
+
value,
|
|
3391
|
+
updateItem,
|
|
3392
|
+
type,
|
|
3393
|
+
hasLabel = false,
|
|
3394
|
+
hasHint = false,
|
|
3395
|
+
hasTooltip = false,
|
|
3396
|
+
hasPlaceholder = false
|
|
3397
|
+
} = props;
|
|
3398
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
3399
|
+
const [hasError, setHasError] = React.useState(false);
|
|
3400
|
+
const onItemChange = (newValue) => {
|
|
3401
|
+
setHasError(required && !newValue);
|
|
3402
|
+
updateItem(fieldName, newValue);
|
|
3403
|
+
};
|
|
3404
|
+
const label = hasLabel ? formatMessage({ id: index$1.getTranslation(`plugin.settings.${displayName}.label`) }) : "";
|
|
3405
|
+
const hint = hasHint ? formatMessage({ id: index$1.getTranslation(`plugin.settings.${displayName}.hint`) }) : "";
|
|
3406
|
+
const tooltip = hasTooltip ? formatMessage({ id: index$1.getTranslation(`plugin.settings.${displayName}.tooltip`) }) : "";
|
|
3407
|
+
const placeholder = hasPlaceholder ? formatMessage({ id: index$1.getTranslation(`plugin.settings.${displayName}.tooltip`) }) : "";
|
|
3408
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3409
|
+
designSystem.Field.Root,
|
|
3410
|
+
{
|
|
3411
|
+
name: `field_${displayName}`,
|
|
3412
|
+
required,
|
|
3413
|
+
error: hasError ? formatMessage({ id: index$1.getTranslation("plugin.settings.errors.required") }) : "",
|
|
3414
|
+
hint,
|
|
3415
|
+
children: [
|
|
3416
|
+
label && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: label }),
|
|
3417
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", children: [
|
|
3418
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { width: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3419
|
+
designSystem.TextInput,
|
|
3420
|
+
{
|
|
3421
|
+
name: displayName,
|
|
3422
|
+
placeholder,
|
|
3423
|
+
type,
|
|
3424
|
+
onChange: (e) => onItemChange(e.target.value),
|
|
3425
|
+
value
|
|
3426
|
+
}
|
|
3427
|
+
) }),
|
|
3428
|
+
tooltip && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginLeft: 2, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipIconButton, { label: tooltip, showBorder: true, variant: "ghost", children: /* @__PURE__ */ jsxRuntime.jsx(icons.Information, {}) }) })
|
|
3429
|
+
] }),
|
|
3430
|
+
hint && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {}),
|
|
3431
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
|
|
3432
|
+
]
|
|
3433
|
+
}
|
|
3434
|
+
);
|
|
3435
|
+
};
|
|
3436
|
+
const SettingsToggleField = (props) => {
|
|
3437
|
+
const {
|
|
3438
|
+
fieldName,
|
|
3439
|
+
displayName,
|
|
3440
|
+
required,
|
|
3441
|
+
value,
|
|
3442
|
+
updateItem,
|
|
3443
|
+
type,
|
|
3444
|
+
hasLabel = false,
|
|
3445
|
+
hasHint = false,
|
|
3446
|
+
hasTooltip = false
|
|
3447
|
+
} = props;
|
|
3448
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
3449
|
+
const [hasError, setHasError] = React.useState(false);
|
|
3450
|
+
const onItemChange = (newValue) => {
|
|
3451
|
+
setHasError(required && !newValue);
|
|
3452
|
+
updateItem(fieldName, newValue);
|
|
3453
|
+
};
|
|
3454
|
+
const label = hasLabel ? formatMessage({ id: index$1.getTranslation(`plugin.settings.${displayName}.label`) }) : "";
|
|
3455
|
+
const hint = hasHint ? formatMessage({ id: index$1.getTranslation(`plugin.settings.${displayName}.hint`) }) : "";
|
|
3456
|
+
const tooltip = hasTooltip ? formatMessage({ id: index$1.getTranslation(`plugin.settings.${displayName}.tooltip`) }) : "";
|
|
3457
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3458
|
+
designSystem.Field.Root,
|
|
3459
|
+
{
|
|
3460
|
+
name: `field_${displayName}`,
|
|
3461
|
+
required,
|
|
3462
|
+
error: hasError ? formatMessage({ id: index$1.getTranslation("plugin.settings.errors.required") }) : "",
|
|
3463
|
+
hint,
|
|
3464
|
+
children: [
|
|
3465
|
+
label && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: label }),
|
|
3466
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", children: [
|
|
3467
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { width: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3468
|
+
designSystem.Toggle,
|
|
3469
|
+
{
|
|
3470
|
+
checked: value,
|
|
3471
|
+
name: displayName,
|
|
3472
|
+
onLabel: formatMessage({ id: index$1.getTranslation("plugin.settings.buttons.on") }),
|
|
3473
|
+
offLabel: formatMessage({ id: index$1.getTranslation("plugin.settings.buttons.off") }),
|
|
3474
|
+
onChange: (e) => onItemChange(e.target.checked)
|
|
3475
|
+
}
|
|
3476
|
+
) }),
|
|
3477
|
+
tooltip && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginLeft: 2, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipIconButton, { label: tooltip, showBorder: true, variant: "ghost", children: /* @__PURE__ */ jsxRuntime.jsx(icons.Information, {}) }) })
|
|
3478
|
+
] }),
|
|
3479
|
+
hint && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {}),
|
|
3480
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
|
|
3481
|
+
]
|
|
3482
|
+
}
|
|
3483
|
+
);
|
|
3484
|
+
};
|
|
3485
|
+
const Settings = () => {
|
|
3486
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
3487
|
+
const isMounted = React.useRef(true);
|
|
3488
|
+
const { get, post } = admin.useFetchClient();
|
|
3489
|
+
React.useEffect(() => {
|
|
3490
|
+
const fetchData = async () => {
|
|
3491
|
+
const { data } = await get(`/drag-drop-content-types/settings`);
|
|
3492
|
+
setSettings(data.body);
|
|
3493
|
+
setIsLoading(false);
|
|
3494
|
+
};
|
|
3495
|
+
fetchData();
|
|
3496
|
+
return () => {
|
|
3497
|
+
isMounted.current = false;
|
|
3498
|
+
};
|
|
3499
|
+
}, []);
|
|
3500
|
+
const defaultSettingsBody = { title: "", subtitle: "", rank: "", triggerWebhooks: false };
|
|
3501
|
+
const [settings, setSettings] = React.useState(defaultSettingsBody);
|
|
3502
|
+
const [isSaving, setIsSaving] = React.useState(false);
|
|
3503
|
+
const [isLoading, setIsLoading] = React.useState(true);
|
|
3504
|
+
const { toggleNotification } = admin.useNotification();
|
|
3505
|
+
const handleSubmit = async () => {
|
|
3506
|
+
if (!settings)
|
|
3507
|
+
return;
|
|
3508
|
+
setIsSaving(true);
|
|
3509
|
+
const res = await post(`/drag-drop-content-types/settings`, {
|
|
3510
|
+
method: "POST",
|
|
3511
|
+
body: settings
|
|
3512
|
+
});
|
|
3513
|
+
setSettings(res.data.body);
|
|
3514
|
+
setIsSaving(false);
|
|
3515
|
+
toggleNotification({
|
|
3516
|
+
type: "success",
|
|
3517
|
+
message: formatMessage({
|
|
3518
|
+
id: "plugin.settings.updated",
|
|
3519
|
+
defaultMessage: "Settings successfully updated"
|
|
3520
|
+
})
|
|
3521
|
+
});
|
|
3522
|
+
};
|
|
3523
|
+
const onUpdateSettings = (fieldName, value) => {
|
|
3524
|
+
if (!settings)
|
|
3525
|
+
return;
|
|
3526
|
+
try {
|
|
3527
|
+
const updatedSettings = { ...settings };
|
|
3528
|
+
updatedSettings[fieldName] = value;
|
|
3529
|
+
setSettings(updatedSettings);
|
|
3530
|
+
} catch (e) {
|
|
3531
|
+
console.log(e);
|
|
3532
|
+
}
|
|
3533
|
+
};
|
|
3534
|
+
const checkFormErrors = () => {
|
|
3535
|
+
return !settings.rank;
|
|
3536
|
+
};
|
|
3537
|
+
const hasFormError = checkFormErrors();
|
|
3538
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3539
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3540
|
+
admin.Layouts.Header,
|
|
3541
|
+
{
|
|
3542
|
+
id: "title",
|
|
3543
|
+
title: formatMessage({ id: index$1.getTranslation("plugin.settings.title") }),
|
|
3544
|
+
subtitle: formatMessage({ id: index$1.getTranslation("plugin.settings.subtitle") }),
|
|
3545
|
+
primaryAction: isLoading ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {}) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
3546
|
+
designSystem.Button,
|
|
3547
|
+
{
|
|
3548
|
+
onClick: handleSubmit,
|
|
3549
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Check, {}),
|
|
3550
|
+
size: "L",
|
|
3551
|
+
disabled: isSaving || hasFormError,
|
|
3552
|
+
loading: isSaving,
|
|
3553
|
+
children: formatMessage({ id: index$1.getTranslation("plugin.settings.buttons.save") })
|
|
3554
|
+
}
|
|
3555
|
+
)
|
|
3556
|
+
}
|
|
3557
|
+
),
|
|
3558
|
+
isLoading ? /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Loading, {}) : /* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3559
|
+
designSystem.Box,
|
|
3560
|
+
{
|
|
3561
|
+
background: "neutral0",
|
|
3562
|
+
hasRadius: true,
|
|
3563
|
+
shadow: "filterShadow",
|
|
3564
|
+
paddingTop: 6,
|
|
3565
|
+
paddingBottom: 6,
|
|
3566
|
+
paddingLeft: 7,
|
|
3567
|
+
paddingRight: 7,
|
|
3568
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { size: 3, direction: "column", children: [
|
|
3569
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingBottom: 6, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", as: "h2", children: formatMessage({ id: index$1.getTranslation("plugin.settings.field-names") }) }) }),
|
|
3570
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { gap: 6, children: [
|
|
3571
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 0, style: { width: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3572
|
+
SettingsTextField,
|
|
3573
|
+
{
|
|
3574
|
+
hasTooltip: true,
|
|
3575
|
+
hasHint: true,
|
|
3576
|
+
hasLabel: true,
|
|
3577
|
+
hasPlaceholder: true,
|
|
3578
|
+
fieldName: "rank",
|
|
3579
|
+
displayName: "rank",
|
|
3580
|
+
required: true,
|
|
3581
|
+
updateItem: onUpdateSettings,
|
|
3582
|
+
value: settings.rank
|
|
3583
|
+
}
|
|
3584
|
+
) }) }),
|
|
3585
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 0, style: { width: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3586
|
+
SettingsTextField,
|
|
3587
|
+
{
|
|
3588
|
+
hasTooltip: true,
|
|
3589
|
+
hasHint: true,
|
|
3590
|
+
hasLabel: true,
|
|
3591
|
+
hasPlaceholder: true,
|
|
3592
|
+
fieldName: "title",
|
|
3593
|
+
displayName: "title",
|
|
3594
|
+
required: false,
|
|
3595
|
+
updateItem: onUpdateSettings,
|
|
3596
|
+
value: settings.title
|
|
3597
|
+
}
|
|
3598
|
+
) }) }),
|
|
3599
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 0, style: { width: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3600
|
+
SettingsTextField,
|
|
3601
|
+
{
|
|
3602
|
+
hasTooltip: true,
|
|
3603
|
+
hasHint: true,
|
|
3604
|
+
hasLabel: true,
|
|
3605
|
+
hasPlaceholder: true,
|
|
3606
|
+
fieldName: "subtitle",
|
|
3607
|
+
displayName: "subtitle",
|
|
3608
|
+
required: false,
|
|
3609
|
+
updateItem: onUpdateSettings,
|
|
3610
|
+
value: settings.subtitle
|
|
3611
|
+
}
|
|
3612
|
+
) }) }),
|
|
3613
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 0, style: { width: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3614
|
+
SettingsToggleField,
|
|
3615
|
+
{
|
|
3616
|
+
hasTooltip: true,
|
|
3617
|
+
hasHint: true,
|
|
3618
|
+
hasLabel: true,
|
|
3619
|
+
fieldName: "triggerWebhooks",
|
|
3620
|
+
displayName: "triggerWebhooks",
|
|
3621
|
+
required: false,
|
|
3622
|
+
updateItem: onUpdateSettings,
|
|
3623
|
+
value: settings.triggerWebhooks
|
|
3624
|
+
}
|
|
3625
|
+
) }) })
|
|
3626
|
+
] })
|
|
3627
|
+
] })
|
|
3628
|
+
}
|
|
3629
|
+
) })
|
|
3630
|
+
] });
|
|
3631
|
+
};
|
|
3632
|
+
exports.default = Settings;
|