@brickkit/cli 0.10.0 → 0.12.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 +1 -1
- package/dashboard-dist/CollapsiblePanel-CbUysOp5.js +2 -0
- package/dashboard-dist/CompositeRoot-D4sRkYq3.js +1 -0
- package/dashboard-dist/Geist-Variable.woff2 +0 -0
- package/dashboard-dist/GeistMono-Variable.woff2 +0 -0
- package/dashboard-dist/PopoverPopup-CiI2avT_.js +1 -0
- package/dashboard-dist/api-reference-B-bZRtNV.js +265 -0
- package/dashboard-dist/app.css +2 -2
- package/dashboard-dist/app.js +13 -13
- package/dashboard-dist/ccount-CcG1m-Yh.js +1 -0
- package/dashboard-dist/client-BJJtVSVr.js +1 -0
- package/dashboard-dist/core-Z7NJFk0K.js +1 -0
- package/dashboard-dist/docs-Dpfc0wJb.js +4 -0
- package/dashboard-dist/docs.css +1 -1
- package/dashboard-dist/kit.js +1 -0
- package/dashboard-dist/popover-BzejBolB.js +1 -0
- package/dashboard-dist/react-dom-client.js +3 -0
- package/dashboard-dist/react-dom.js +3 -0
- package/dashboard-dist/react-jsx-runtime.js +1 -1
- package/dashboard-dist/react.js +3 -3
- package/dashboard-dist/theme.css +123 -0
- package/dist/app-entry2.js +2 -3
- package/dist/bin.d.ts +0 -2
- package/dist/bin.js +606 -49
- package/dist/bin.js.map +1 -1
- package/dist/client-contract-file2.js +2 -3
- package/dist/client-contract2.js +18 -10
- package/dist/client-contract2.js.map +1 -1
- package/dist/compiler.d.ts +1 -2
- package/dist/compiler.js +1 -1
- package/dist/compiler2.js +3 -4
- package/dist/config.js +250 -0
- package/dist/config.js.map +1 -0
- package/dist/dashboard-extension.d.ts +25 -0
- package/dist/dashboard.d.ts +2997 -0
- package/dist/dev-reporter.d.ts +0 -2
- package/dist/dev-reporter.js +1 -2
- package/dist/dev-telemetry-store.js +1411 -966
- package/dist/dev-telemetry-store.js.map +1 -1
- package/dist/dev-telemetry.js +3 -4
- package/dist/dev-telemetry.js.map +1 -1
- package/dist/dev-worker.js +3 -4
- package/dist/emit.d.ts +0 -2
- package/dist/index.d.ts +96 -17
- package/dist/index.js +4 -5
- package/dist/lint/eslint.d.ts +2 -0
- package/dist/lint/eslint.js +1 -0
- package/dist/lint/oxlint.d.ts +17 -0
- package/dist/lint/oxlint.js +18 -0
- package/dist/lint/oxlint.js.map +1 -0
- package/dist/plugin.d.ts +70 -0
- package/dist/plugin.js +64 -0
- package/dist/plugin.js.map +1 -0
- package/dist/presets.js +1066 -0
- package/dist/presets.js.map +1 -0
- package/dist/runner.js +114 -32
- package/dist/runner.js.map +1 -1
- package/dist/vite.d.ts +6 -5
- package/dist/vite.js +13 -9
- package/dist/vite.js.map +1 -1
- package/dist/workflows.d.ts +0 -2
- package/dist/workflows2.js +3 -4
- package/inspector-dist/client/assets/api.rpc-BvRk9kiK.js +0 -0
- package/inspector-dist/client/assets/api.stream._streamId-BvRk9kiK.js +0 -0
- package/inspector-dist/client/assets/app-CCzpuUz_.css +2 -0
- package/inspector-dist/client/assets/dist-BK8w6xOr.js +3930 -0
- package/inspector-dist/client/assets/dist-CG2aVufI.js +197 -0
- package/inspector-dist/client/assets/entry.client-D9jbgmTR.js +9391 -0
- package/inspector-dist/client/assets/highlighted-body-B3W2YXNL-DYVdwGy2.js +34 -0
- package/inspector-dist/client/assets/home-CyjkvtII.js +2883 -0
- package/inspector-dist/client/assets/jsx-runtime-CPEah4WQ.js +7084 -0
- package/inspector-dist/client/assets/manifest-ba30b52d.js +1 -0
- package/inspector-dist/client/assets/mermaid-3ZIDBTTL-Dy6IVqPy.js +1 -0
- package/inspector-dist/client/assets/root-8BMab1lL.css +2 -0
- package/inspector-dist/client/assets/root-DX9wtogx.js +332 -0
- package/inspector-dist/client/assets/run-detail-C69EJGql.js +1549 -0
- package/inspector-dist/client/assets/tabs-B6B88IjT.js +75692 -0
- package/inspector-dist/client/assets/tabs-L5XKzOpP.css +1 -0
- package/inspector-dist/client/assets/world-config-context-C3BqXPIv.js +30 -0
- package/inspector-dist/client/assets/zstd-browser-decoder-ByUgcY9H.js +41 -0
- package/inspector-dist/server/assets/app-WoDoT62X.js +100155 -0
- package/inspector-dist/server/assets/chunk-RLXIAIE6-CbvDIAEa.js +42977 -0
- package/inspector-dist/server/assets/dist-BRxZSWUN.js +1140 -0
- package/inspector-dist/server/assets/dist-CQnQcIJg.js +199 -0
- package/inspector-dist/server/assets/dist-DqRd9pyS.js +1644 -0
- package/inspector-dist/server/assets/dist-qR-969AD.js +10327 -0
- package/inspector-dist/server/assets/encryption-_PuklZNX.js +888 -0
- package/inspector-dist/server/assets/event-metadata-BVakQJ_y.js +147 -0
- package/inspector-dist/server/assets/functions-CImcpqNl.js +1172 -0
- package/inspector-dist/server/assets/global-singleton-CPirHxFh.js +82 -0
- package/inspector-dist/server/assets/highlighted-body-B3W2YXNL-fPMB_t7F.js +36 -0
- package/inspector-dist/server/assets/mermaid-3ZIDBTTL-bADXySE3.js +3 -0
- package/inspector-dist/server/assets/parse-D9Vvgzt9.js +471 -0
- package/inspector-dist/server/assets/rolldown-runtime-CLg409Sh.js +44 -0
- package/inspector-dist/server/assets/serialization-format-DDtsVTU1.js +478 -0
- package/inspector-dist/server/assets/token-BW4GdQZh.js +62 -0
- package/inspector-dist/server/assets/token-D6FXdkJT.js +57 -0
- package/inspector-dist/server/assets/token-util-BoNmi-wE.js +457 -0
- package/inspector-dist/server/assets/wrapper-wiqsGXcE.js +3626 -0
- package/inspector-dist/server/assets/ws-transport-DV7oG4mL.js +29478 -0
- package/inspector-dist/server/assets/zstd-browser-decoder-Cswf0KO6.js +40 -0
- package/inspector-dist/server/index.js +2 -57
- package/package.json +57 -32
- package/vite-client.d.ts +1 -1
- package/dashboard-dist/CollapsiblePanel-a54TwMKb.js +0 -2
- package/dashboard-dist/PopoverPopup-BLzjTqsi.js +0 -1
- package/dashboard-dist/api-reference-r893F8zi.js +0 -260
- package/dashboard-dist/core-BWAwhSFf.js +0 -1
- package/dashboard-dist/docs-CkMy3Y5i.js +0 -4
- package/dashboard-dist/preload-helper-CjQDFR0M.js +0 -1
- package/dist/bin.d.ts.map +0 -1
- package/dist/build.js +0 -119
- package/dist/build.js.map +0 -1
- package/dist/dev-reporter.d.ts.map +0 -1
- package/dist/emit.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/vite.d.ts.map +0 -1
- package/dist/workflows.d.ts.map +0 -1
- package/inspector-dist/client/assets/api.rpc-l0sNRNKZ.js +0 -1
- package/inspector-dist/client/assets/api.stream._streamId-l0sNRNKZ.js +0 -1
- package/inspector-dist/client/assets/app-CY7CQBRo.css +0 -1
- package/inspector-dist/client/assets/entry.client-BJ6G3n5t.js +0 -11697
- package/inspector-dist/client/assets/highlighted-body-B3W2YXNL-C-3wZnxf.js +0 -19
- package/inspector-dist/client/assets/home-CSKAS4P2.js +0 -4979
- package/inspector-dist/client/assets/index-DECCyMR0.js +0 -4482
- package/inspector-dist/client/assets/index-Dot7CgrA.js +0 -9837
- package/inspector-dist/client/assets/index-HqNj_XIX.js +0 -200
- package/inspector-dist/client/assets/manifest-4baa7c6f.js +0 -1
- package/inspector-dist/client/assets/mermaid-3ZIDBTTL-DC0K8uTy.js +0 -58626
- package/inspector-dist/client/assets/mermaid-3ZIDBTTL-F88p7PFX.css +0 -1
- package/inspector-dist/client/assets/root-Bmn5n3jF.js +0 -305
- package/inspector-dist/client/assets/root-CfCr265_.css +0 -1
- package/inspector-dist/client/assets/run-detail-CWoGxu_0.css +0 -1
- package/inspector-dist/client/assets/run-detail-Cc7tSGNq.js +0 -6237
- package/inspector-dist/client/assets/world-config-context-BAD1QCrR.js +0 -26
- package/inspector-dist/client/assets/zstd-browser-decoder-BQoRpP7L.js +0 -28
- package/inspector-dist/server/assets/app-C-ZVJtic.js +0 -174880
- package/inspector-dist/server/assets/highlighted-body-B3W2YXNL-C8sq8F_D.js +0 -71
- package/inspector-dist/server/assets/index-BfLBLRRi.js +0 -204
- package/inspector-dist/server/assets/index-BzrGWk7J.js +0 -1164
- package/inspector-dist/server/assets/index-CWJr34WJ.js +0 -1296
- package/inspector-dist/server/assets/index-CYlmUaKx.js +0 -191
- package/inspector-dist/server/assets/mermaid-3ZIDBTTL-Dv5rjfMN.js +0 -58
- package/inspector-dist/server/assets/token-DnLp3wBO.js +0 -95
- package/inspector-dist/server/assets/token-util-Bpfp-B0w.js +0 -33
- package/inspector-dist/server/assets/wrapper-D5LIcZ_u.js +0 -67
- package/inspector-dist/server/assets/zstd-browser-decoder-BM8GpVB8.js +0 -77
|
@@ -0,0 +1,3930 @@
|
|
|
1
|
+
import { F as require_react, P as require_react_dom, R as __toESM, t as require_jsx_runtime } from "./jsx-runtime-CPEah4WQ.js";
|
|
2
|
+
// ../../node_modules/.bun/@radix-ui+primitive@1.1.3/node_modules/@radix-ui/primitive/dist/index.mjs
|
|
3
|
+
var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
|
|
4
|
+
typeof window !== "undefined" && window.document && window.document.createElement;
|
|
5
|
+
function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
|
|
6
|
+
return function handleEvent(event) {
|
|
7
|
+
originalEventHandler?.(event);
|
|
8
|
+
if (checkForDefaultPrevented === false || !event.defaultPrevented) return ourEventHandler?.(event);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
// ../../node_modules/.bun/@radix-ui+react-compose-refs@1.1.2+340ca8aed1dead99/node_modules/@radix-ui/react-compose-refs/dist/index.mjs
|
|
12
|
+
function setRef(ref, value) {
|
|
13
|
+
if (typeof ref === "function") return ref(value);
|
|
14
|
+
else if (ref !== null && ref !== void 0) ref.current = value;
|
|
15
|
+
}
|
|
16
|
+
function composeRefs(...refs) {
|
|
17
|
+
return (node) => {
|
|
18
|
+
let hasCleanup = false;
|
|
19
|
+
const cleanups = refs.map((ref) => {
|
|
20
|
+
const cleanup = setRef(ref, node);
|
|
21
|
+
if (!hasCleanup && typeof cleanup == "function") hasCleanup = true;
|
|
22
|
+
return cleanup;
|
|
23
|
+
});
|
|
24
|
+
if (hasCleanup) return () => {
|
|
25
|
+
for (let i = 0; i < cleanups.length; i++) {
|
|
26
|
+
const cleanup = cleanups[i];
|
|
27
|
+
if (typeof cleanup == "function") cleanup();
|
|
28
|
+
else setRef(refs[i], null);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function useComposedRefs(...refs) {
|
|
34
|
+
return import_react.useCallback(composeRefs(...refs), refs);
|
|
35
|
+
}
|
|
36
|
+
// ../../node_modules/.bun/@radix-ui+react-context@1.1.2+340ca8aed1dead99/node_modules/@radix-ui/react-context/dist/index.mjs
|
|
37
|
+
var import_jsx_runtime = require_jsx_runtime();
|
|
38
|
+
function createContextScope(scopeName, createContextScopeDeps = []) {
|
|
39
|
+
let defaultContexts = [];
|
|
40
|
+
function createContext3(rootComponentName, defaultContext) {
|
|
41
|
+
const BaseContext = import_react.createContext(defaultContext);
|
|
42
|
+
const index = defaultContexts.length;
|
|
43
|
+
defaultContexts = [...defaultContexts, defaultContext];
|
|
44
|
+
const Provider = (props) => {
|
|
45
|
+
const { scope, children, ...context } = props;
|
|
46
|
+
const Context = scope?.[scopeName]?.[index] || BaseContext;
|
|
47
|
+
const value = import_react.useMemo(() => context, Object.values(context));
|
|
48
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Context.Provider, {
|
|
49
|
+
value,
|
|
50
|
+
children
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
Provider.displayName = rootComponentName + "Provider";
|
|
54
|
+
function useContext2(consumerName, scope) {
|
|
55
|
+
const Context = scope?.[scopeName]?.[index] || BaseContext;
|
|
56
|
+
const context = import_react.useContext(Context);
|
|
57
|
+
if (context) return context;
|
|
58
|
+
if (defaultContext !== void 0) return defaultContext;
|
|
59
|
+
throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
|
|
60
|
+
}
|
|
61
|
+
return [Provider, useContext2];
|
|
62
|
+
}
|
|
63
|
+
const createScope = () => {
|
|
64
|
+
const scopeContexts = defaultContexts.map((defaultContext) => {
|
|
65
|
+
return import_react.createContext(defaultContext);
|
|
66
|
+
});
|
|
67
|
+
return function useScope(scope) {
|
|
68
|
+
const contexts = scope?.[scopeName] || scopeContexts;
|
|
69
|
+
return import_react.useMemo(() => ({ [`__scope${scopeName}`]: {
|
|
70
|
+
...scope,
|
|
71
|
+
[scopeName]: contexts
|
|
72
|
+
} }), [scope, contexts]);
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
createScope.scopeName = scopeName;
|
|
76
|
+
return [createContext3, composeContextScopes(createScope, ...createContextScopeDeps)];
|
|
77
|
+
}
|
|
78
|
+
function composeContextScopes(...scopes) {
|
|
79
|
+
const baseScope = scopes[0];
|
|
80
|
+
if (scopes.length === 1) return baseScope;
|
|
81
|
+
const createScope = () => {
|
|
82
|
+
const scopeHooks = scopes.map((createScope2) => ({
|
|
83
|
+
useScope: createScope2(),
|
|
84
|
+
scopeName: createScope2.scopeName
|
|
85
|
+
}));
|
|
86
|
+
return function useComposedScopes(overrideScopes) {
|
|
87
|
+
const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
|
|
88
|
+
const currentScope = useScope(overrideScopes)[`__scope${scopeName}`];
|
|
89
|
+
return {
|
|
90
|
+
...nextScopes2,
|
|
91
|
+
...currentScope
|
|
92
|
+
};
|
|
93
|
+
}, {});
|
|
94
|
+
return import_react.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
createScope.scopeName = baseScope.scopeName;
|
|
98
|
+
return createScope;
|
|
99
|
+
}
|
|
100
|
+
// ../../node_modules/.bun/@radix-ui+react-slot@1.2.3+340ca8aed1dead99/node_modules/@radix-ui/react-slot/dist/index.mjs
|
|
101
|
+
var import_react_dom = /* @__PURE__ */ __toESM(require_react_dom(), 1);
|
|
102
|
+
// @__NO_SIDE_EFFECTS__
|
|
103
|
+
function createSlot(ownerName) {
|
|
104
|
+
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
105
|
+
const Slot2 = import_react.forwardRef((props, forwardedRef) => {
|
|
106
|
+
const { children, ...slotProps } = props;
|
|
107
|
+
const childrenArray = import_react.Children.toArray(children);
|
|
108
|
+
const slottable = childrenArray.find(isSlottable);
|
|
109
|
+
if (slottable) {
|
|
110
|
+
const newElement = slottable.props.children;
|
|
111
|
+
const newChildren = childrenArray.map((child) => {
|
|
112
|
+
if (child === slottable) {
|
|
113
|
+
if (import_react.Children.count(newElement) > 1) return import_react.Children.only(null);
|
|
114
|
+
return import_react.isValidElement(newElement) ? newElement.props.children : null;
|
|
115
|
+
} else return child;
|
|
116
|
+
});
|
|
117
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SlotClone, {
|
|
118
|
+
...slotProps,
|
|
119
|
+
ref: forwardedRef,
|
|
120
|
+
children: import_react.isValidElement(newElement) ? import_react.cloneElement(newElement, void 0, newChildren) : null
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SlotClone, {
|
|
124
|
+
...slotProps,
|
|
125
|
+
ref: forwardedRef,
|
|
126
|
+
children
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
130
|
+
return Slot2;
|
|
131
|
+
}
|
|
132
|
+
// @__NO_SIDE_EFFECTS__
|
|
133
|
+
function createSlotClone(ownerName) {
|
|
134
|
+
const SlotClone = import_react.forwardRef((props, forwardedRef) => {
|
|
135
|
+
const { children, ...slotProps } = props;
|
|
136
|
+
if (import_react.isValidElement(children)) {
|
|
137
|
+
const childrenRef = getElementRef$1(children);
|
|
138
|
+
const props2 = mergeProps(slotProps, children.props);
|
|
139
|
+
if (children.type !== import_react.Fragment) props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
140
|
+
return import_react.cloneElement(children, props2);
|
|
141
|
+
}
|
|
142
|
+
return import_react.Children.count(children) > 1 ? import_react.Children.only(null) : null;
|
|
143
|
+
});
|
|
144
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
145
|
+
return SlotClone;
|
|
146
|
+
}
|
|
147
|
+
var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
|
|
148
|
+
// @__NO_SIDE_EFFECTS__
|
|
149
|
+
function createSlottable(ownerName) {
|
|
150
|
+
const Slottable2 = ({ children }) => {
|
|
151
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
|
|
152
|
+
};
|
|
153
|
+
Slottable2.displayName = `${ownerName}.Slottable`;
|
|
154
|
+
Slottable2.__radixId = SLOTTABLE_IDENTIFIER;
|
|
155
|
+
return Slottable2;
|
|
156
|
+
}
|
|
157
|
+
function isSlottable(child) {
|
|
158
|
+
return import_react.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
159
|
+
}
|
|
160
|
+
function mergeProps(slotProps, childProps) {
|
|
161
|
+
const overrideProps = { ...childProps };
|
|
162
|
+
for (const propName in childProps) {
|
|
163
|
+
const slotPropValue = slotProps[propName];
|
|
164
|
+
const childPropValue = childProps[propName];
|
|
165
|
+
if (/^on[A-Z]/.test(propName)) {
|
|
166
|
+
if (slotPropValue && childPropValue) overrideProps[propName] = (...args) => {
|
|
167
|
+
const result = childPropValue(...args);
|
|
168
|
+
slotPropValue(...args);
|
|
169
|
+
return result;
|
|
170
|
+
};
|
|
171
|
+
else if (slotPropValue) overrideProps[propName] = slotPropValue;
|
|
172
|
+
} else if (propName === "style") overrideProps[propName] = {
|
|
173
|
+
...slotPropValue,
|
|
174
|
+
...childPropValue
|
|
175
|
+
};
|
|
176
|
+
else if (propName === "className") overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
...slotProps,
|
|
180
|
+
...overrideProps
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function getElementRef$1(element) {
|
|
184
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
|
|
185
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
186
|
+
if (mayWarn) return element.ref;
|
|
187
|
+
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
|
|
188
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
189
|
+
if (mayWarn) return element.props.ref;
|
|
190
|
+
return element.props.ref || element.ref;
|
|
191
|
+
}
|
|
192
|
+
// ../../node_modules/.bun/@radix-ui+react-primitive@2.1.3+a68cb332b68cb125/node_modules/@radix-ui/react-primitive/dist/index.mjs
|
|
193
|
+
var Primitive = [
|
|
194
|
+
"a",
|
|
195
|
+
"button",
|
|
196
|
+
"div",
|
|
197
|
+
"form",
|
|
198
|
+
"h2",
|
|
199
|
+
"h3",
|
|
200
|
+
"img",
|
|
201
|
+
"input",
|
|
202
|
+
"label",
|
|
203
|
+
"li",
|
|
204
|
+
"nav",
|
|
205
|
+
"ol",
|
|
206
|
+
"p",
|
|
207
|
+
"select",
|
|
208
|
+
"span",
|
|
209
|
+
"svg",
|
|
210
|
+
"ul"
|
|
211
|
+
].reduce((primitive, node) => {
|
|
212
|
+
const Slot = /* @__PURE__ */ createSlot(`Primitive.${node}`);
|
|
213
|
+
const Node = import_react.forwardRef((props, forwardedRef) => {
|
|
214
|
+
const { asChild, ...primitiveProps } = props;
|
|
215
|
+
const Comp = asChild ? Slot : node;
|
|
216
|
+
if (typeof window !== "undefined") window[Symbol.for("radix-ui")] = true;
|
|
217
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Comp, {
|
|
218
|
+
...primitiveProps,
|
|
219
|
+
ref: forwardedRef
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
Node.displayName = `Primitive.${node}`;
|
|
223
|
+
return {
|
|
224
|
+
...primitive,
|
|
225
|
+
[node]: Node
|
|
226
|
+
};
|
|
227
|
+
}, {});
|
|
228
|
+
function dispatchDiscreteCustomEvent(target, event) {
|
|
229
|
+
if (target) import_react_dom.flushSync(() => target.dispatchEvent(event));
|
|
230
|
+
}
|
|
231
|
+
// ../../node_modules/.bun/@radix-ui+react-use-callback-ref@1.1.1+340ca8aed1dead99/node_modules/@radix-ui/react-use-callback-ref/dist/index.mjs
|
|
232
|
+
function useCallbackRef(callback) {
|
|
233
|
+
const callbackRef = import_react.useRef(callback);
|
|
234
|
+
import_react.useEffect(() => {
|
|
235
|
+
callbackRef.current = callback;
|
|
236
|
+
});
|
|
237
|
+
return import_react.useMemo(() => (...args) => callbackRef.current?.(...args), []);
|
|
238
|
+
}
|
|
239
|
+
// ../../node_modules/.bun/@radix-ui+react-use-escape-keydown@1.1.1+340ca8aed1dead99/node_modules/@radix-ui/react-use-escape-keydown/dist/index.mjs
|
|
240
|
+
function useEscapeKeydown(onEscapeKeyDownProp, ownerDocument = globalThis?.document) {
|
|
241
|
+
const onEscapeKeyDown = useCallbackRef(onEscapeKeyDownProp);
|
|
242
|
+
import_react.useEffect(() => {
|
|
243
|
+
const handleKeyDown = (event) => {
|
|
244
|
+
if (event.key === "Escape") onEscapeKeyDown(event);
|
|
245
|
+
};
|
|
246
|
+
ownerDocument.addEventListener("keydown", handleKeyDown, { capture: true });
|
|
247
|
+
return () => ownerDocument.removeEventListener("keydown", handleKeyDown, { capture: true });
|
|
248
|
+
}, [onEscapeKeyDown, ownerDocument]);
|
|
249
|
+
}
|
|
250
|
+
// ../../node_modules/.bun/@radix-ui+react-dismissable-layer@1.1.11+a68cb332b68cb125/node_modules/@radix-ui/react-dismissable-layer/dist/index.mjs
|
|
251
|
+
var DISMISSABLE_LAYER_NAME = "DismissableLayer";
|
|
252
|
+
var CONTEXT_UPDATE = "dismissableLayer.update";
|
|
253
|
+
var POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside";
|
|
254
|
+
var FOCUS_OUTSIDE = "dismissableLayer.focusOutside";
|
|
255
|
+
var originalBodyPointerEvents;
|
|
256
|
+
var DismissableLayerContext = import_react.createContext({
|
|
257
|
+
layers: /* @__PURE__ */ new Set(),
|
|
258
|
+
layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
|
|
259
|
+
branches: /* @__PURE__ */ new Set()
|
|
260
|
+
});
|
|
261
|
+
var DismissableLayer = import_react.forwardRef((props, forwardedRef) => {
|
|
262
|
+
const { disableOutsidePointerEvents = false, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, onDismiss, ...layerProps } = props;
|
|
263
|
+
const context = import_react.useContext(DismissableLayerContext);
|
|
264
|
+
const [node, setNode] = import_react.useState(null);
|
|
265
|
+
const ownerDocument = node?.ownerDocument ?? globalThis?.document;
|
|
266
|
+
const [, force] = import_react.useState({});
|
|
267
|
+
const composedRefs = useComposedRefs(forwardedRef, (node2) => setNode(node2));
|
|
268
|
+
const layers = Array.from(context.layers);
|
|
269
|
+
const [highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1);
|
|
270
|
+
const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);
|
|
271
|
+
const index = node ? layers.indexOf(node) : -1;
|
|
272
|
+
const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
|
|
273
|
+
const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;
|
|
274
|
+
const pointerDownOutside = usePointerDownOutside((event) => {
|
|
275
|
+
const target = event.target;
|
|
276
|
+
const isPointerDownOnBranch = [...context.branches].some((branch) => branch.contains(target));
|
|
277
|
+
if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
|
|
278
|
+
onPointerDownOutside?.(event);
|
|
279
|
+
onInteractOutside?.(event);
|
|
280
|
+
if (!event.defaultPrevented) onDismiss?.();
|
|
281
|
+
}, ownerDocument);
|
|
282
|
+
const focusOutside = useFocusOutside((event) => {
|
|
283
|
+
const target = event.target;
|
|
284
|
+
if ([...context.branches].some((branch) => branch.contains(target))) return;
|
|
285
|
+
onFocusOutside?.(event);
|
|
286
|
+
onInteractOutside?.(event);
|
|
287
|
+
if (!event.defaultPrevented) onDismiss?.();
|
|
288
|
+
}, ownerDocument);
|
|
289
|
+
useEscapeKeydown((event) => {
|
|
290
|
+
if (!(index === context.layers.size - 1)) return;
|
|
291
|
+
onEscapeKeyDown?.(event);
|
|
292
|
+
if (!event.defaultPrevented && onDismiss) {
|
|
293
|
+
event.preventDefault();
|
|
294
|
+
onDismiss();
|
|
295
|
+
}
|
|
296
|
+
}, ownerDocument);
|
|
297
|
+
import_react.useEffect(() => {
|
|
298
|
+
if (!node) return;
|
|
299
|
+
if (disableOutsidePointerEvents) {
|
|
300
|
+
if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
|
|
301
|
+
originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
|
|
302
|
+
ownerDocument.body.style.pointerEvents = "none";
|
|
303
|
+
}
|
|
304
|
+
context.layersWithOutsidePointerEventsDisabled.add(node);
|
|
305
|
+
}
|
|
306
|
+
context.layers.add(node);
|
|
307
|
+
dispatchUpdate();
|
|
308
|
+
return () => {
|
|
309
|
+
if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;
|
|
310
|
+
};
|
|
311
|
+
}, [
|
|
312
|
+
node,
|
|
313
|
+
ownerDocument,
|
|
314
|
+
disableOutsidePointerEvents,
|
|
315
|
+
context
|
|
316
|
+
]);
|
|
317
|
+
import_react.useEffect(() => {
|
|
318
|
+
return () => {
|
|
319
|
+
if (!node) return;
|
|
320
|
+
context.layers.delete(node);
|
|
321
|
+
context.layersWithOutsidePointerEventsDisabled.delete(node);
|
|
322
|
+
dispatchUpdate();
|
|
323
|
+
};
|
|
324
|
+
}, [node, context]);
|
|
325
|
+
import_react.useEffect(() => {
|
|
326
|
+
const handleUpdate = () => force({});
|
|
327
|
+
document.addEventListener(CONTEXT_UPDATE, handleUpdate);
|
|
328
|
+
return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);
|
|
329
|
+
}, []);
|
|
330
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Primitive.div, {
|
|
331
|
+
...layerProps,
|
|
332
|
+
ref: composedRefs,
|
|
333
|
+
style: {
|
|
334
|
+
pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
|
|
335
|
+
...props.style
|
|
336
|
+
},
|
|
337
|
+
onFocusCapture: composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture),
|
|
338
|
+
onBlurCapture: composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture),
|
|
339
|
+
onPointerDownCapture: composeEventHandlers(props.onPointerDownCapture, pointerDownOutside.onPointerDownCapture)
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
DismissableLayer.displayName = DISMISSABLE_LAYER_NAME;
|
|
343
|
+
var BRANCH_NAME = "DismissableLayerBranch";
|
|
344
|
+
var DismissableLayerBranch = import_react.forwardRef((props, forwardedRef) => {
|
|
345
|
+
const context = import_react.useContext(DismissableLayerContext);
|
|
346
|
+
const ref = import_react.useRef(null);
|
|
347
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
348
|
+
import_react.useEffect(() => {
|
|
349
|
+
const node = ref.current;
|
|
350
|
+
if (node) {
|
|
351
|
+
context.branches.add(node);
|
|
352
|
+
return () => {
|
|
353
|
+
context.branches.delete(node);
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
}, [context.branches]);
|
|
357
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Primitive.div, {
|
|
358
|
+
...props,
|
|
359
|
+
ref: composedRefs
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
DismissableLayerBranch.displayName = BRANCH_NAME;
|
|
363
|
+
function usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis?.document) {
|
|
364
|
+
const handlePointerDownOutside = useCallbackRef(onPointerDownOutside);
|
|
365
|
+
const isPointerInsideReactTreeRef = import_react.useRef(false);
|
|
366
|
+
const handleClickRef = import_react.useRef(() => {});
|
|
367
|
+
import_react.useEffect(() => {
|
|
368
|
+
const handlePointerDown = (event) => {
|
|
369
|
+
if (event.target && !isPointerInsideReactTreeRef.current) {
|
|
370
|
+
let handleAndDispatchPointerDownOutsideEvent2 = function() {
|
|
371
|
+
handleAndDispatchCustomEvent(POINTER_DOWN_OUTSIDE, handlePointerDownOutside, eventDetail, { discrete: true });
|
|
372
|
+
};
|
|
373
|
+
const eventDetail = { originalEvent: event };
|
|
374
|
+
if (event.pointerType === "touch") {
|
|
375
|
+
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
376
|
+
handleClickRef.current = handleAndDispatchPointerDownOutsideEvent2;
|
|
377
|
+
ownerDocument.addEventListener("click", handleClickRef.current, { once: true });
|
|
378
|
+
} else handleAndDispatchPointerDownOutsideEvent2();
|
|
379
|
+
} else ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
380
|
+
isPointerInsideReactTreeRef.current = false;
|
|
381
|
+
};
|
|
382
|
+
const timerId = window.setTimeout(() => {
|
|
383
|
+
ownerDocument.addEventListener("pointerdown", handlePointerDown);
|
|
384
|
+
}, 0);
|
|
385
|
+
return () => {
|
|
386
|
+
window.clearTimeout(timerId);
|
|
387
|
+
ownerDocument.removeEventListener("pointerdown", handlePointerDown);
|
|
388
|
+
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
389
|
+
};
|
|
390
|
+
}, [ownerDocument, handlePointerDownOutside]);
|
|
391
|
+
return { onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true };
|
|
392
|
+
}
|
|
393
|
+
function useFocusOutside(onFocusOutside, ownerDocument = globalThis?.document) {
|
|
394
|
+
const handleFocusOutside = useCallbackRef(onFocusOutside);
|
|
395
|
+
const isFocusInsideReactTreeRef = import_react.useRef(false);
|
|
396
|
+
import_react.useEffect(() => {
|
|
397
|
+
const handleFocus = (event) => {
|
|
398
|
+
if (event.target && !isFocusInsideReactTreeRef.current) handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, { originalEvent: event }, { discrete: false });
|
|
399
|
+
};
|
|
400
|
+
ownerDocument.addEventListener("focusin", handleFocus);
|
|
401
|
+
return () => ownerDocument.removeEventListener("focusin", handleFocus);
|
|
402
|
+
}, [ownerDocument, handleFocusOutside]);
|
|
403
|
+
return {
|
|
404
|
+
onFocusCapture: () => isFocusInsideReactTreeRef.current = true,
|
|
405
|
+
onBlurCapture: () => isFocusInsideReactTreeRef.current = false
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
function dispatchUpdate() {
|
|
409
|
+
const event = new CustomEvent(CONTEXT_UPDATE);
|
|
410
|
+
document.dispatchEvent(event);
|
|
411
|
+
}
|
|
412
|
+
function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
|
|
413
|
+
const target = detail.originalEvent.target;
|
|
414
|
+
const event = new CustomEvent(name, {
|
|
415
|
+
bubbles: false,
|
|
416
|
+
cancelable: true,
|
|
417
|
+
detail
|
|
418
|
+
});
|
|
419
|
+
if (handler) target.addEventListener(name, handler, { once: true });
|
|
420
|
+
if (discrete) dispatchDiscreteCustomEvent(target, event);
|
|
421
|
+
else target.dispatchEvent(event);
|
|
422
|
+
}
|
|
423
|
+
// ../../node_modules/.bun/@radix-ui+react-use-layout-effect@1.1.1+340ca8aed1dead99/node_modules/@radix-ui/react-use-layout-effect/dist/index.mjs
|
|
424
|
+
var useLayoutEffect2 = globalThis?.document ? import_react.useLayoutEffect : () => {};
|
|
425
|
+
// ../../node_modules/.bun/@radix-ui+react-id@1.1.1+340ca8aed1dead99/node_modules/@radix-ui/react-id/dist/index.mjs
|
|
426
|
+
var useReactId = import_react[" useId ".trim().toString()] || (() => void 0);
|
|
427
|
+
var count = 0;
|
|
428
|
+
function useId(deterministicId) {
|
|
429
|
+
const [id, setId] = import_react.useState(useReactId());
|
|
430
|
+
useLayoutEffect2(() => {
|
|
431
|
+
if (!deterministicId) setId((reactId) => reactId ?? String(count++));
|
|
432
|
+
}, [deterministicId]);
|
|
433
|
+
return deterministicId || (id ? `radix-${id}` : "");
|
|
434
|
+
}
|
|
435
|
+
// ../../node_modules/.bun/@floating-ui+utils@0.2.12/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
|
|
436
|
+
/**
|
|
437
|
+
* Custom positioning reference element.
|
|
438
|
+
* @see https://floating-ui.com/docs/virtual-elements
|
|
439
|
+
*/
|
|
440
|
+
var sides = [
|
|
441
|
+
"top",
|
|
442
|
+
"right",
|
|
443
|
+
"bottom",
|
|
444
|
+
"left"
|
|
445
|
+
];
|
|
446
|
+
var min = Math.min;
|
|
447
|
+
var max = Math.max;
|
|
448
|
+
var round = Math.round;
|
|
449
|
+
var floor = Math.floor;
|
|
450
|
+
var createCoords = (v) => ({
|
|
451
|
+
x: v,
|
|
452
|
+
y: v
|
|
453
|
+
});
|
|
454
|
+
var oppositeSideMap = {
|
|
455
|
+
left: "right",
|
|
456
|
+
right: "left",
|
|
457
|
+
bottom: "top",
|
|
458
|
+
top: "bottom"
|
|
459
|
+
};
|
|
460
|
+
function clamp(start, value, end) {
|
|
461
|
+
return max(start, min(value, end));
|
|
462
|
+
}
|
|
463
|
+
function evaluate(value, param) {
|
|
464
|
+
return typeof value === "function" ? value(param) : value;
|
|
465
|
+
}
|
|
466
|
+
function getSide(placement) {
|
|
467
|
+
return placement.split("-")[0];
|
|
468
|
+
}
|
|
469
|
+
function getAlignment(placement) {
|
|
470
|
+
return placement.split("-")[1];
|
|
471
|
+
}
|
|
472
|
+
function getOppositeAxis(axis) {
|
|
473
|
+
return axis === "x" ? "y" : "x";
|
|
474
|
+
}
|
|
475
|
+
function getAxisLength(axis) {
|
|
476
|
+
return axis === "y" ? "height" : "width";
|
|
477
|
+
}
|
|
478
|
+
function getSideAxis(placement) {
|
|
479
|
+
const firstChar = placement[0];
|
|
480
|
+
return firstChar === "t" || firstChar === "b" ? "y" : "x";
|
|
481
|
+
}
|
|
482
|
+
function getAlignmentAxis(placement) {
|
|
483
|
+
return getOppositeAxis(getSideAxis(placement));
|
|
484
|
+
}
|
|
485
|
+
function getAlignmentSides(placement, rects, rtl) {
|
|
486
|
+
if (rtl === void 0) rtl = false;
|
|
487
|
+
const alignment = getAlignment(placement);
|
|
488
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
489
|
+
const length = getAxisLength(alignmentAxis);
|
|
490
|
+
let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
|
|
491
|
+
if (rects.reference[length] > rects.floating[length]) mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
492
|
+
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
|
493
|
+
}
|
|
494
|
+
function getExpandedPlacements(placement) {
|
|
495
|
+
const oppositePlacement = getOppositePlacement(placement);
|
|
496
|
+
return [
|
|
497
|
+
getOppositeAlignmentPlacement(placement),
|
|
498
|
+
oppositePlacement,
|
|
499
|
+
getOppositeAlignmentPlacement(oppositePlacement)
|
|
500
|
+
];
|
|
501
|
+
}
|
|
502
|
+
function getOppositeAlignmentPlacement(placement) {
|
|
503
|
+
return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
|
|
504
|
+
}
|
|
505
|
+
var lrPlacement = ["left", "right"];
|
|
506
|
+
var rlPlacement = ["right", "left"];
|
|
507
|
+
var tbPlacement = ["top", "bottom"];
|
|
508
|
+
var btPlacement = ["bottom", "top"];
|
|
509
|
+
function getSideList(side, isStart, rtl) {
|
|
510
|
+
switch (side) {
|
|
511
|
+
case "top":
|
|
512
|
+
case "bottom":
|
|
513
|
+
if (rtl) return isStart ? rlPlacement : lrPlacement;
|
|
514
|
+
return isStart ? lrPlacement : rlPlacement;
|
|
515
|
+
case "left":
|
|
516
|
+
case "right": return isStart ? tbPlacement : btPlacement;
|
|
517
|
+
default: return [];
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
521
|
+
const alignment = getAlignment(placement);
|
|
522
|
+
let list = getSideList(getSide(placement), direction === "start", rtl);
|
|
523
|
+
if (alignment) {
|
|
524
|
+
list = list.map((side) => side + "-" + alignment);
|
|
525
|
+
if (flipAlignment) list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
526
|
+
}
|
|
527
|
+
return list;
|
|
528
|
+
}
|
|
529
|
+
function getOppositePlacement(placement) {
|
|
530
|
+
const side = getSide(placement);
|
|
531
|
+
return oppositeSideMap[side] + placement.slice(side.length);
|
|
532
|
+
}
|
|
533
|
+
function expandPaddingObject(padding) {
|
|
534
|
+
var _padding$top, _padding$right, _padding$bottom, _padding$left;
|
|
535
|
+
return {
|
|
536
|
+
top: (_padding$top = padding.top) != null ? _padding$top : 0,
|
|
537
|
+
right: (_padding$right = padding.right) != null ? _padding$right : 0,
|
|
538
|
+
bottom: (_padding$bottom = padding.bottom) != null ? _padding$bottom : 0,
|
|
539
|
+
left: (_padding$left = padding.left) != null ? _padding$left : 0
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
function getPaddingObject(padding) {
|
|
543
|
+
return typeof padding !== "number" ? expandPaddingObject(padding) : {
|
|
544
|
+
top: padding,
|
|
545
|
+
right: padding,
|
|
546
|
+
bottom: padding,
|
|
547
|
+
left: padding
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
function rectToClientRect(rect) {
|
|
551
|
+
const { x, y, width, height } = rect;
|
|
552
|
+
return {
|
|
553
|
+
width,
|
|
554
|
+
height,
|
|
555
|
+
top: y,
|
|
556
|
+
left: x,
|
|
557
|
+
right: x + width,
|
|
558
|
+
bottom: y + height,
|
|
559
|
+
x,
|
|
560
|
+
y
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
// ../../node_modules/.bun/@floating-ui+core@1.8.0/node_modules/@floating-ui/core/dist/floating-ui.core.mjs
|
|
564
|
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
565
|
+
let { reference, floating } = _ref;
|
|
566
|
+
const sideAxis = getSideAxis(placement);
|
|
567
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
568
|
+
const alignLength = getAxisLength(alignmentAxis);
|
|
569
|
+
const side = getSide(placement);
|
|
570
|
+
const isVertical = sideAxis === "y";
|
|
571
|
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
572
|
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
573
|
+
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
|
574
|
+
let coords;
|
|
575
|
+
switch (side) {
|
|
576
|
+
case "top":
|
|
577
|
+
coords = {
|
|
578
|
+
x: commonX,
|
|
579
|
+
y: reference.y - floating.height
|
|
580
|
+
};
|
|
581
|
+
break;
|
|
582
|
+
case "bottom":
|
|
583
|
+
coords = {
|
|
584
|
+
x: commonX,
|
|
585
|
+
y: reference.y + reference.height
|
|
586
|
+
};
|
|
587
|
+
break;
|
|
588
|
+
case "right":
|
|
589
|
+
coords = {
|
|
590
|
+
x: reference.x + reference.width,
|
|
591
|
+
y: commonY
|
|
592
|
+
};
|
|
593
|
+
break;
|
|
594
|
+
case "left":
|
|
595
|
+
coords = {
|
|
596
|
+
x: reference.x - floating.width,
|
|
597
|
+
y: commonY
|
|
598
|
+
};
|
|
599
|
+
break;
|
|
600
|
+
default: coords = {
|
|
601
|
+
x: reference.x,
|
|
602
|
+
y: reference.y
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
const alignment = getAlignment(placement);
|
|
606
|
+
if (alignment) coords[alignmentAxis] += commonAlign * (alignment === "end" ? 1 : -1) * (rtl && isVertical ? -1 : 1);
|
|
607
|
+
return coords;
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* Resolves with an object of overflow side offsets that determine how much the
|
|
611
|
+
* element is overflowing a given clipping boundary on each side.
|
|
612
|
+
* - positive = overflowing the boundary by that number of pixels
|
|
613
|
+
* - negative = how many pixels left before it will overflow
|
|
614
|
+
* - 0 = lies flush with the boundary
|
|
615
|
+
* @see https://floating-ui.com/docs/detectOverflow
|
|
616
|
+
*/
|
|
617
|
+
async function detectOverflow(state, options) {
|
|
618
|
+
var _await$platform$isEle;
|
|
619
|
+
if (options === void 0) options = {};
|
|
620
|
+
const { x, y, platform, rects, elements, strategy } = state;
|
|
621
|
+
const { boundary = "clippingAncestors", rootBoundary = "viewport", elementContext = "floating", altBoundary = false, padding = 0 } = evaluate(options, state);
|
|
622
|
+
const paddingObject = getPaddingObject(padding);
|
|
623
|
+
const element = elements[altBoundary ? elementContext === "floating" ? "reference" : "floating" : elementContext];
|
|
624
|
+
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
|
625
|
+
element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating)),
|
|
626
|
+
boundary,
|
|
627
|
+
rootBoundary,
|
|
628
|
+
strategy
|
|
629
|
+
}));
|
|
630
|
+
const rect = elementContext === "floating" ? {
|
|
631
|
+
x,
|
|
632
|
+
y,
|
|
633
|
+
width: rects.floating.width,
|
|
634
|
+
height: rects.floating.height
|
|
635
|
+
} : rects.reference;
|
|
636
|
+
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
|
637
|
+
const offsetScale = await (platform.isElement == null ? void 0 : platform.isElement(offsetParent)) && await (platform.getScale == null ? void 0 : platform.getScale(offsetParent)) || {
|
|
638
|
+
x: 1,
|
|
639
|
+
y: 1
|
|
640
|
+
};
|
|
641
|
+
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
642
|
+
elements,
|
|
643
|
+
rect,
|
|
644
|
+
offsetParent,
|
|
645
|
+
strategy
|
|
646
|
+
}) : rect);
|
|
647
|
+
return {
|
|
648
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
649
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
650
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
651
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
652
|
+
};
|
|
653
|
+
}
|
|
654
|
+
var MAX_RESET_COUNT = 50;
|
|
655
|
+
/**
|
|
656
|
+
* Computes the `x` and `y` coordinates that will place the floating element
|
|
657
|
+
* next to a given reference element.
|
|
658
|
+
*
|
|
659
|
+
* This export does not have any `platform` interface logic. You will need to
|
|
660
|
+
* write one for the platform you are using Floating UI with.
|
|
661
|
+
*/
|
|
662
|
+
var computePosition$1 = async (reference, floating, config) => {
|
|
663
|
+
const { placement = "bottom", strategy = "absolute", middleware = [], platform } = config;
|
|
664
|
+
const platformWithDetectOverflow = platform.detectOverflow ? platform : {
|
|
665
|
+
...platform,
|
|
666
|
+
detectOverflow
|
|
667
|
+
};
|
|
668
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
|
669
|
+
let rects = await platform.getElementRects({
|
|
670
|
+
reference,
|
|
671
|
+
floating,
|
|
672
|
+
strategy
|
|
673
|
+
});
|
|
674
|
+
let { x, y } = computeCoordsFromPlacement(rects, placement, rtl);
|
|
675
|
+
let statefulPlacement = placement;
|
|
676
|
+
let resetCount = 0;
|
|
677
|
+
const middlewareData = {};
|
|
678
|
+
for (let i = 0; i < middleware.length; i++) {
|
|
679
|
+
const currentMiddleware = middleware[i];
|
|
680
|
+
if (!currentMiddleware) continue;
|
|
681
|
+
const { name, fn } = currentMiddleware;
|
|
682
|
+
const { x: nextX, y: nextY, data, reset } = await fn({
|
|
683
|
+
x,
|
|
684
|
+
y,
|
|
685
|
+
initialPlacement: placement,
|
|
686
|
+
placement: statefulPlacement,
|
|
687
|
+
strategy,
|
|
688
|
+
middlewareData,
|
|
689
|
+
rects,
|
|
690
|
+
platform: platformWithDetectOverflow,
|
|
691
|
+
elements: {
|
|
692
|
+
reference,
|
|
693
|
+
floating
|
|
694
|
+
}
|
|
695
|
+
});
|
|
696
|
+
x = nextX != null ? nextX : x;
|
|
697
|
+
y = nextY != null ? nextY : y;
|
|
698
|
+
middlewareData[name] = {
|
|
699
|
+
...middlewareData[name],
|
|
700
|
+
...data
|
|
701
|
+
};
|
|
702
|
+
if (reset && resetCount < MAX_RESET_COUNT) {
|
|
703
|
+
resetCount++;
|
|
704
|
+
if (typeof reset === "object") {
|
|
705
|
+
if (reset.placement) statefulPlacement = reset.placement;
|
|
706
|
+
if (reset.rects) rects = reset.rects === true ? await platform.getElementRects({
|
|
707
|
+
reference,
|
|
708
|
+
floating,
|
|
709
|
+
strategy
|
|
710
|
+
}) : reset.rects;
|
|
711
|
+
({x, y} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
712
|
+
}
|
|
713
|
+
i = -1;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
return {
|
|
717
|
+
x,
|
|
718
|
+
y,
|
|
719
|
+
placement: statefulPlacement,
|
|
720
|
+
strategy,
|
|
721
|
+
middlewareData
|
|
722
|
+
};
|
|
723
|
+
};
|
|
724
|
+
/**
|
|
725
|
+
* Provides data to position an inner element of the floating element so that it
|
|
726
|
+
* appears centered to the reference element.
|
|
727
|
+
* @see https://floating-ui.com/docs/arrow
|
|
728
|
+
*/
|
|
729
|
+
var arrow$3 = (options) => ({
|
|
730
|
+
name: "arrow",
|
|
731
|
+
options,
|
|
732
|
+
async fn(state) {
|
|
733
|
+
const { x, y, placement, rects, platform, elements, middlewareData } = state;
|
|
734
|
+
const { element, padding = 0 } = evaluate(options, state) || {};
|
|
735
|
+
if (element == null) return {};
|
|
736
|
+
const paddingObject = getPaddingObject(padding);
|
|
737
|
+
const coords = {
|
|
738
|
+
x,
|
|
739
|
+
y
|
|
740
|
+
};
|
|
741
|
+
const axis = getAlignmentAxis(placement);
|
|
742
|
+
const length = getAxisLength(axis);
|
|
743
|
+
const arrowDimensions = await platform.getDimensions(element);
|
|
744
|
+
const isYAxis = axis === "y";
|
|
745
|
+
const minProp = isYAxis ? "top" : "left";
|
|
746
|
+
const maxProp = isYAxis ? "bottom" : "right";
|
|
747
|
+
const clientProp = isYAxis ? "clientHeight" : "clientWidth";
|
|
748
|
+
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
749
|
+
const startDiff = coords[axis] - rects.reference[axis];
|
|
750
|
+
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
|
|
751
|
+
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
|
752
|
+
if (!clientSize || !await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent))) clientSize = elements.floating[clientProp] || rects.floating[length];
|
|
753
|
+
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
754
|
+
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
|
755
|
+
const minPadding = min(paddingObject[minProp], largestPossiblePadding);
|
|
756
|
+
const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
|
|
757
|
+
const max = clientSize - arrowDimensions[length] - maxPadding;
|
|
758
|
+
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
759
|
+
const offset = clamp(minPadding, center, max);
|
|
760
|
+
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < minPadding ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
|
761
|
+
const alignmentOffset = shouldAddOffset ? center < minPadding ? center - minPadding : center - max : 0;
|
|
762
|
+
return {
|
|
763
|
+
[axis]: coords[axis] + alignmentOffset,
|
|
764
|
+
data: {
|
|
765
|
+
[axis]: offset,
|
|
766
|
+
centerOffset: center - offset - alignmentOffset,
|
|
767
|
+
...shouldAddOffset && { alignmentOffset }
|
|
768
|
+
},
|
|
769
|
+
reset: shouldAddOffset
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
});
|
|
773
|
+
/**
|
|
774
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
775
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
776
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
777
|
+
* @see https://floating-ui.com/docs/flip
|
|
778
|
+
*/
|
|
779
|
+
var flip$1 = function(options) {
|
|
780
|
+
if (options === void 0) options = {};
|
|
781
|
+
return {
|
|
782
|
+
name: "flip",
|
|
783
|
+
options,
|
|
784
|
+
async fn(state) {
|
|
785
|
+
var _middlewareData$arrow, _middlewareData$flip;
|
|
786
|
+
const { placement, middlewareData, rects, initialPlacement, platform, elements } = state;
|
|
787
|
+
const { mainAxis: checkMainAxis = true, crossAxis: checkCrossAxis = true, fallbackPlacements: specifiedFallbackPlacements, fallbackStrategy = "bestFit", fallbackAxisSideDirection = "none", flipAlignment = true, ...detectOverflowOptions } = evaluate(options, state);
|
|
788
|
+
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) return {};
|
|
789
|
+
const side = getSide(placement);
|
|
790
|
+
const initialSideAxis = getSideAxis(initialPlacement);
|
|
791
|
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
792
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
793
|
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
794
|
+
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
|
|
795
|
+
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
796
|
+
const placements = [initialPlacement, ...fallbackPlacements];
|
|
797
|
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
|
798
|
+
const overflows = [];
|
|
799
|
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
800
|
+
if (checkMainAxis) overflows.push(overflow[side]);
|
|
801
|
+
if (checkCrossAxis) {
|
|
802
|
+
const sides = getAlignmentSides(placement, rects, rtl);
|
|
803
|
+
overflows.push(overflow[sides[0]], overflow[sides[1]]);
|
|
804
|
+
}
|
|
805
|
+
overflowsData = [...overflowsData, {
|
|
806
|
+
placement,
|
|
807
|
+
overflows
|
|
808
|
+
}];
|
|
809
|
+
if (!overflows.every((side) => side <= 0)) {
|
|
810
|
+
var _middlewareData$flip2, _overflowsData$filter;
|
|
811
|
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
812
|
+
const nextPlacement = placements[nextIndex];
|
|
813
|
+
if (nextPlacement) {
|
|
814
|
+
if (!(checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false) || overflowsData.every((d) => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) return {
|
|
815
|
+
data: {
|
|
816
|
+
index: nextIndex,
|
|
817
|
+
overflows: overflowsData
|
|
818
|
+
},
|
|
819
|
+
reset: { placement: nextPlacement }
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
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;
|
|
823
|
+
if (!resetPlacement) switch (fallbackStrategy) {
|
|
824
|
+
case "bestFit": {
|
|
825
|
+
var _overflowsData$filter2;
|
|
826
|
+
const placement = (_overflowsData$filter2 = overflowsData.filter((d) => {
|
|
827
|
+
if (hasFallbackAxisSideDirection) {
|
|
828
|
+
const currentSideAxis = getSideAxis(d.placement);
|
|
829
|
+
return currentSideAxis === initialSideAxis || currentSideAxis === "y";
|
|
830
|
+
}
|
|
831
|
+
return true;
|
|
832
|
+
}).map((d) => [d.placement, d.overflows.filter((overflow) => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
|
|
833
|
+
if (placement) resetPlacement = placement;
|
|
834
|
+
break;
|
|
835
|
+
}
|
|
836
|
+
case "initialPlacement": resetPlacement = initialPlacement;
|
|
837
|
+
}
|
|
838
|
+
if (placement !== resetPlacement) return { reset: { placement: resetPlacement } };
|
|
839
|
+
}
|
|
840
|
+
return {};
|
|
841
|
+
}
|
|
842
|
+
};
|
|
843
|
+
};
|
|
844
|
+
function getSideOffsets(overflow, rect) {
|
|
845
|
+
return {
|
|
846
|
+
top: overflow.top - rect.height,
|
|
847
|
+
right: overflow.right - rect.width,
|
|
848
|
+
bottom: overflow.bottom - rect.height,
|
|
849
|
+
left: overflow.left - rect.width
|
|
850
|
+
};
|
|
851
|
+
}
|
|
852
|
+
function isAnySideFullyClipped(overflow) {
|
|
853
|
+
return sides.some((side) => overflow[side] >= 0);
|
|
854
|
+
}
|
|
855
|
+
/**
|
|
856
|
+
* Provides data to hide the floating element in applicable situations, such as
|
|
857
|
+
* when it is not in the same clipping context as the reference element.
|
|
858
|
+
* @see https://floating-ui.com/docs/hide
|
|
859
|
+
*/
|
|
860
|
+
var hide$1 = function(options) {
|
|
861
|
+
if (options === void 0) options = {};
|
|
862
|
+
return {
|
|
863
|
+
name: "hide",
|
|
864
|
+
options,
|
|
865
|
+
async fn(state) {
|
|
866
|
+
const { rects, platform } = state;
|
|
867
|
+
const { strategy = "referenceHidden", ...detectOverflowOptions } = evaluate(options, state);
|
|
868
|
+
switch (strategy) {
|
|
869
|
+
case "referenceHidden": {
|
|
870
|
+
const offsets = getSideOffsets(await platform.detectOverflow(state, {
|
|
871
|
+
...detectOverflowOptions,
|
|
872
|
+
elementContext: "reference"
|
|
873
|
+
}), rects.reference);
|
|
874
|
+
return { data: {
|
|
875
|
+
referenceHiddenOffsets: offsets,
|
|
876
|
+
referenceHidden: isAnySideFullyClipped(offsets)
|
|
877
|
+
} };
|
|
878
|
+
}
|
|
879
|
+
case "escaped": {
|
|
880
|
+
const offsets = getSideOffsets(await platform.detectOverflow(state, {
|
|
881
|
+
...detectOverflowOptions,
|
|
882
|
+
altBoundary: true
|
|
883
|
+
}), rects.floating);
|
|
884
|
+
return { data: {
|
|
885
|
+
escapedOffsets: offsets,
|
|
886
|
+
escaped: isAnySideFullyClipped(offsets)
|
|
887
|
+
} };
|
|
888
|
+
}
|
|
889
|
+
default: return {};
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
};
|
|
893
|
+
};
|
|
894
|
+
var originSides = /*#__PURE__*/ new Set(["left", "top"]);
|
|
895
|
+
async function convertValueToCoords(state, options) {
|
|
896
|
+
const { placement, platform, elements } = state;
|
|
897
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
898
|
+
const side = getSide(placement);
|
|
899
|
+
const alignment = getAlignment(placement);
|
|
900
|
+
const isVertical = getSideAxis(placement) === "y";
|
|
901
|
+
const mainAxisMulti = originSides.has(side) ? -1 : 1;
|
|
902
|
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
903
|
+
const rawValue = evaluate(options, state);
|
|
904
|
+
let { mainAxis, crossAxis, alignmentAxis } = typeof rawValue === "number" ? {
|
|
905
|
+
mainAxis: rawValue,
|
|
906
|
+
crossAxis: 0,
|
|
907
|
+
alignmentAxis: null
|
|
908
|
+
} : {
|
|
909
|
+
mainAxis: rawValue.mainAxis || 0,
|
|
910
|
+
crossAxis: rawValue.crossAxis || 0,
|
|
911
|
+
alignmentAxis: rawValue.alignmentAxis
|
|
912
|
+
};
|
|
913
|
+
if (alignment && typeof alignmentAxis === "number") crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
|
|
914
|
+
return isVertical ? {
|
|
915
|
+
x: crossAxis * crossAxisMulti,
|
|
916
|
+
y: mainAxis * mainAxisMulti
|
|
917
|
+
} : {
|
|
918
|
+
x: mainAxis * mainAxisMulti,
|
|
919
|
+
y: crossAxis * crossAxisMulti
|
|
920
|
+
};
|
|
921
|
+
}
|
|
922
|
+
/**
|
|
923
|
+
* Modifies the placement by translating the floating element along the
|
|
924
|
+
* specified axes.
|
|
925
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
|
926
|
+
* object may be passed.
|
|
927
|
+
* @see https://floating-ui.com/docs/offset
|
|
928
|
+
*/
|
|
929
|
+
var offset$1 = function(options) {
|
|
930
|
+
if (options === void 0) options = 0;
|
|
931
|
+
return {
|
|
932
|
+
name: "offset",
|
|
933
|
+
options,
|
|
934
|
+
async fn(state) {
|
|
935
|
+
var _middlewareData$offse, _middlewareData$arrow;
|
|
936
|
+
const { x, y, placement, middlewareData } = state;
|
|
937
|
+
const diffCoords = await convertValueToCoords(state, options);
|
|
938
|
+
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) return {};
|
|
939
|
+
return {
|
|
940
|
+
x: x + diffCoords.x,
|
|
941
|
+
y: y + diffCoords.y,
|
|
942
|
+
data: {
|
|
943
|
+
...diffCoords,
|
|
944
|
+
placement
|
|
945
|
+
}
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
};
|
|
949
|
+
};
|
|
950
|
+
/**
|
|
951
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
|
952
|
+
* keep it in view when it will overflow the clipping boundary.
|
|
953
|
+
* @see https://floating-ui.com/docs/shift
|
|
954
|
+
*/
|
|
955
|
+
var shift$1 = function(options) {
|
|
956
|
+
if (options === void 0) options = {};
|
|
957
|
+
return {
|
|
958
|
+
name: "shift",
|
|
959
|
+
options,
|
|
960
|
+
async fn(state) {
|
|
961
|
+
const { x, y, placement, platform } = state;
|
|
962
|
+
const { mainAxis: checkMainAxis = true, crossAxis: checkCrossAxis = false, limiter = { fn: (_ref) => {
|
|
963
|
+
let { x, y } = _ref;
|
|
964
|
+
return {
|
|
965
|
+
x,
|
|
966
|
+
y
|
|
967
|
+
};
|
|
968
|
+
} }, ...detectOverflowOptions } = evaluate(options, state);
|
|
969
|
+
const coords = {
|
|
970
|
+
x,
|
|
971
|
+
y
|
|
972
|
+
};
|
|
973
|
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
|
974
|
+
const crossAxis = getSideAxis(placement);
|
|
975
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
976
|
+
let mainAxisCoord = coords[mainAxis];
|
|
977
|
+
let crossAxisCoord = coords[crossAxis];
|
|
978
|
+
const clampCoord = (axis, coord) => clamp(coord + overflow[axis === "y" ? "top" : "left"], coord, coord - overflow[axis === "y" ? "bottom" : "right"]);
|
|
979
|
+
if (checkMainAxis) mainAxisCoord = clampCoord(mainAxis, mainAxisCoord);
|
|
980
|
+
if (checkCrossAxis) crossAxisCoord = clampCoord(crossAxis, crossAxisCoord);
|
|
981
|
+
const limitedCoords = limiter.fn({
|
|
982
|
+
...state,
|
|
983
|
+
[mainAxis]: mainAxisCoord,
|
|
984
|
+
[crossAxis]: crossAxisCoord
|
|
985
|
+
});
|
|
986
|
+
return {
|
|
987
|
+
...limitedCoords,
|
|
988
|
+
data: {
|
|
989
|
+
x: limitedCoords.x - x,
|
|
990
|
+
y: limitedCoords.y - y,
|
|
991
|
+
enabled: {
|
|
992
|
+
[mainAxis]: checkMainAxis,
|
|
993
|
+
[crossAxis]: checkCrossAxis
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
};
|
|
997
|
+
}
|
|
998
|
+
};
|
|
999
|
+
};
|
|
1000
|
+
/**
|
|
1001
|
+
* Built-in `limiter` that will stop `shift()` at a certain point.
|
|
1002
|
+
*/
|
|
1003
|
+
var limitShift$1 = function(options) {
|
|
1004
|
+
if (options === void 0) options = {};
|
|
1005
|
+
return {
|
|
1006
|
+
options,
|
|
1007
|
+
fn(state) {
|
|
1008
|
+
var _rawOffset$mainAxis, _rawOffset$crossAxis;
|
|
1009
|
+
const { x, y, placement, rects, middlewareData } = state;
|
|
1010
|
+
const { offset = 0, mainAxis: checkMainAxis = true, crossAxis: checkCrossAxis = true } = evaluate(options, state);
|
|
1011
|
+
const coords = {
|
|
1012
|
+
x,
|
|
1013
|
+
y
|
|
1014
|
+
};
|
|
1015
|
+
const crossAxis = getSideAxis(placement);
|
|
1016
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
1017
|
+
let mainAxisCoord = coords[mainAxis];
|
|
1018
|
+
let crossAxisCoord = coords[crossAxis];
|
|
1019
|
+
const rawOffset = evaluate(offset, state);
|
|
1020
|
+
const computedOffset = typeof rawOffset === "number" ? {
|
|
1021
|
+
mainAxis: rawOffset,
|
|
1022
|
+
crossAxis: 0
|
|
1023
|
+
} : {
|
|
1024
|
+
mainAxis: (_rawOffset$mainAxis = rawOffset.mainAxis) != null ? _rawOffset$mainAxis : 0,
|
|
1025
|
+
crossAxis: (_rawOffset$crossAxis = rawOffset.crossAxis) != null ? _rawOffset$crossAxis : 0
|
|
1026
|
+
};
|
|
1027
|
+
if (checkMainAxis) {
|
|
1028
|
+
const len = mainAxis === "y" ? "height" : "width";
|
|
1029
|
+
const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
|
|
1030
|
+
const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
|
|
1031
|
+
if (mainAxisCoord < limitMin) mainAxisCoord = limitMin;
|
|
1032
|
+
else if (mainAxisCoord > limitMax) mainAxisCoord = limitMax;
|
|
1033
|
+
}
|
|
1034
|
+
if (checkCrossAxis) {
|
|
1035
|
+
var _middlewareData$offse, _middlewareData$offse2;
|
|
1036
|
+
const len = mainAxis === "y" ? "width" : "height";
|
|
1037
|
+
const isOriginSide = originSides.has(getSide(placement));
|
|
1038
|
+
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);
|
|
1039
|
+
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);
|
|
1040
|
+
if (crossAxisCoord < limitMin) crossAxisCoord = limitMin;
|
|
1041
|
+
else if (crossAxisCoord > limitMax) crossAxisCoord = limitMax;
|
|
1042
|
+
}
|
|
1043
|
+
return {
|
|
1044
|
+
[mainAxis]: mainAxisCoord,
|
|
1045
|
+
[crossAxis]: crossAxisCoord
|
|
1046
|
+
};
|
|
1047
|
+
}
|
|
1048
|
+
};
|
|
1049
|
+
};
|
|
1050
|
+
/**
|
|
1051
|
+
* Provides data that allows you to change the size of the floating element —
|
|
1052
|
+
* for instance, prevent it from overflowing the clipping boundary or match the
|
|
1053
|
+
* width of the reference element.
|
|
1054
|
+
* @see https://floating-ui.com/docs/size
|
|
1055
|
+
*/
|
|
1056
|
+
var size$1 = function(options) {
|
|
1057
|
+
if (options === void 0) options = {};
|
|
1058
|
+
return {
|
|
1059
|
+
name: "size",
|
|
1060
|
+
options,
|
|
1061
|
+
async fn(state) {
|
|
1062
|
+
const { placement, rects, platform, elements } = state;
|
|
1063
|
+
const { apply = () => {}, ...detectOverflowOptions } = evaluate(options, state);
|
|
1064
|
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
|
1065
|
+
const side = getSide(placement);
|
|
1066
|
+
const alignment = getAlignment(placement);
|
|
1067
|
+
const isYAxis = getSideAxis(placement) === "y";
|
|
1068
|
+
const { width, height } = rects.floating;
|
|
1069
|
+
let heightSide;
|
|
1070
|
+
let widthSide;
|
|
1071
|
+
if (side === "top" || side === "bottom") {
|
|
1072
|
+
heightSide = side;
|
|
1073
|
+
widthSide = alignment === (await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
|
|
1074
|
+
} else {
|
|
1075
|
+
widthSide = side;
|
|
1076
|
+
heightSide = alignment === "end" ? "top" : "bottom";
|
|
1077
|
+
}
|
|
1078
|
+
const maximumClippingHeight = height - overflow.top - overflow.bottom;
|
|
1079
|
+
const maximumClippingWidth = width - overflow.left - overflow.right;
|
|
1080
|
+
const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
|
|
1081
|
+
const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
|
|
1082
|
+
const shiftData = state.middlewareData.shift;
|
|
1083
|
+
const noShift = !shiftData;
|
|
1084
|
+
let availableHeight = overflowAvailableHeight;
|
|
1085
|
+
let availableWidth = overflowAvailableWidth;
|
|
1086
|
+
if (shiftData != null && shiftData.enabled.x) availableWidth = maximumClippingWidth;
|
|
1087
|
+
if (shiftData != null && shiftData.enabled.y) availableHeight = maximumClippingHeight;
|
|
1088
|
+
if (noShift && !alignment) {
|
|
1089
|
+
if (isYAxis) availableWidth = width - 2 * max(overflow.left, overflow.right);
|
|
1090
|
+
else availableHeight = height - 2 * max(overflow.top, overflow.bottom);
|
|
1091
|
+
}
|
|
1092
|
+
await apply({
|
|
1093
|
+
...state,
|
|
1094
|
+
availableWidth,
|
|
1095
|
+
availableHeight
|
|
1096
|
+
});
|
|
1097
|
+
const nextDimensions = await platform.getDimensions(elements.floating);
|
|
1098
|
+
if (width !== nextDimensions.width || height !== nextDimensions.height) return { reset: { rects: true } };
|
|
1099
|
+
return {};
|
|
1100
|
+
}
|
|
1101
|
+
};
|
|
1102
|
+
};
|
|
1103
|
+
// ../../node_modules/.bun/@floating-ui+utils@0.2.12/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
|
|
1104
|
+
function hasWindow() {
|
|
1105
|
+
return typeof window !== "undefined";
|
|
1106
|
+
}
|
|
1107
|
+
function getNodeName(node) {
|
|
1108
|
+
if (isNode(node)) return (node.nodeName || "").toLowerCase();
|
|
1109
|
+
return "#document";
|
|
1110
|
+
}
|
|
1111
|
+
function getWindow(node) {
|
|
1112
|
+
var _node$ownerDocument;
|
|
1113
|
+
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
1114
|
+
}
|
|
1115
|
+
function getDocumentElement(node) {
|
|
1116
|
+
var _ref;
|
|
1117
|
+
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
1118
|
+
}
|
|
1119
|
+
function isNode(value) {
|
|
1120
|
+
if (!hasWindow()) return false;
|
|
1121
|
+
return value instanceof Node || value instanceof getWindow(value).Node;
|
|
1122
|
+
}
|
|
1123
|
+
function isElement(value) {
|
|
1124
|
+
if (!hasWindow()) return false;
|
|
1125
|
+
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
1126
|
+
}
|
|
1127
|
+
function isHTMLElement(value) {
|
|
1128
|
+
if (!hasWindow()) return false;
|
|
1129
|
+
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
1130
|
+
}
|
|
1131
|
+
function isShadowRoot(value) {
|
|
1132
|
+
if (!hasWindow() || typeof ShadowRoot === "undefined") return false;
|
|
1133
|
+
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
1134
|
+
}
|
|
1135
|
+
function isOverflowElement(element) {
|
|
1136
|
+
const { overflow, overflowX, overflowY, display } = getComputedStyle$1(element);
|
|
1137
|
+
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
|
|
1138
|
+
}
|
|
1139
|
+
function isTableElement(element) {
|
|
1140
|
+
return /^(table|td|th)$/.test(getNodeName(element));
|
|
1141
|
+
}
|
|
1142
|
+
function isTopLayer(element) {
|
|
1143
|
+
try {
|
|
1144
|
+
if (element.matches(":popover-open")) return true;
|
|
1145
|
+
} catch (_e) {}
|
|
1146
|
+
try {
|
|
1147
|
+
return element.matches(":modal");
|
|
1148
|
+
} catch (_e) {
|
|
1149
|
+
return false;
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
|
|
1153
|
+
var containRe = /paint|layout|strict|content/;
|
|
1154
|
+
var isNotNone = (value) => !!value && value !== "none";
|
|
1155
|
+
var isWebKitValue;
|
|
1156
|
+
function isContainingBlock(elementOrCss) {
|
|
1157
|
+
const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
|
|
1158
|
+
return isNotNone(css.transform) || isNotNone(css.translate) || isNotNone(css.scale) || isNotNone(css.rotate) || isNotNone(css.perspective) || !isWebKit() && (isNotNone(css.backdropFilter) || isNotNone(css.filter)) || willChangeRe.test(css.willChange || "") || containRe.test(css.contain || "");
|
|
1159
|
+
}
|
|
1160
|
+
function getContainingBlock(element) {
|
|
1161
|
+
let currentNode = getParentNode(element);
|
|
1162
|
+
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1163
|
+
if (isContainingBlock(currentNode)) return currentNode;
|
|
1164
|
+
else if (isTopLayer(currentNode)) return null;
|
|
1165
|
+
currentNode = getParentNode(currentNode);
|
|
1166
|
+
}
|
|
1167
|
+
return null;
|
|
1168
|
+
}
|
|
1169
|
+
function isWebKit() {
|
|
1170
|
+
if (isWebKitValue == null) isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
|
|
1171
|
+
return isWebKitValue;
|
|
1172
|
+
}
|
|
1173
|
+
function isLastTraversableNode(node) {
|
|
1174
|
+
return /^(html|body|#document)$/.test(getNodeName(node));
|
|
1175
|
+
}
|
|
1176
|
+
function getComputedStyle$1(element) {
|
|
1177
|
+
return getWindow(element).getComputedStyle(element);
|
|
1178
|
+
}
|
|
1179
|
+
function getNodeScroll(element) {
|
|
1180
|
+
if (isElement(element)) return {
|
|
1181
|
+
scrollLeft: element.scrollLeft,
|
|
1182
|
+
scrollTop: element.scrollTop
|
|
1183
|
+
};
|
|
1184
|
+
return {
|
|
1185
|
+
scrollLeft: element.scrollX,
|
|
1186
|
+
scrollTop: element.scrollY
|
|
1187
|
+
};
|
|
1188
|
+
}
|
|
1189
|
+
function getParentNode(node) {
|
|
1190
|
+
if (getNodeName(node) === "html") return node;
|
|
1191
|
+
const result = node.assignedSlot || node.parentNode || isShadowRoot(node) && node.host || getDocumentElement(node);
|
|
1192
|
+
return isShadowRoot(result) ? result.host : result;
|
|
1193
|
+
}
|
|
1194
|
+
function getNearestOverflowAncestor(node) {
|
|
1195
|
+
const parentNode = getParentNode(node);
|
|
1196
|
+
if (isLastTraversableNode(parentNode)) return (node.ownerDocument || node).body;
|
|
1197
|
+
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) return parentNode;
|
|
1198
|
+
return getNearestOverflowAncestor(parentNode);
|
|
1199
|
+
}
|
|
1200
|
+
function getOverflowAncestors(node, list, traverseIframes) {
|
|
1201
|
+
var _node$ownerDocument2;
|
|
1202
|
+
if (list === void 0) list = [];
|
|
1203
|
+
if (traverseIframes === void 0) traverseIframes = true;
|
|
1204
|
+
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
1205
|
+
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
|
1206
|
+
const win = getWindow(scrollableAncestor);
|
|
1207
|
+
if (isBody) {
|
|
1208
|
+
const frameElement = getFrameElement(win);
|
|
1209
|
+
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
|
1210
|
+
} else return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
|
1211
|
+
}
|
|
1212
|
+
function getFrameElement(win) {
|
|
1213
|
+
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
|
1214
|
+
}
|
|
1215
|
+
// ../../node_modules/.bun/@floating-ui+dom@1.8.0/node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
|
|
1216
|
+
function getCssDimensions(element) {
|
|
1217
|
+
const css = getComputedStyle$1(element);
|
|
1218
|
+
let width = parseFloat(css.width) || 0;
|
|
1219
|
+
let height = parseFloat(css.height) || 0;
|
|
1220
|
+
const hasOffset = isHTMLElement(element);
|
|
1221
|
+
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
1222
|
+
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
1223
|
+
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
1224
|
+
if (shouldFallback) {
|
|
1225
|
+
width = offsetWidth;
|
|
1226
|
+
height = offsetHeight;
|
|
1227
|
+
}
|
|
1228
|
+
return {
|
|
1229
|
+
width,
|
|
1230
|
+
height,
|
|
1231
|
+
$: shouldFallback
|
|
1232
|
+
};
|
|
1233
|
+
}
|
|
1234
|
+
function unwrapElement(element) {
|
|
1235
|
+
return !isElement(element) ? element.contextElement : element;
|
|
1236
|
+
}
|
|
1237
|
+
function getScale(element) {
|
|
1238
|
+
const domElement = unwrapElement(element);
|
|
1239
|
+
if (!isHTMLElement(domElement)) return createCoords(1);
|
|
1240
|
+
const rect = domElement.getBoundingClientRect();
|
|
1241
|
+
const { width, height, $ } = getCssDimensions(domElement);
|
|
1242
|
+
let x = ($ ? round(rect.width) : rect.width) / width;
|
|
1243
|
+
let y = ($ ? round(rect.height) : rect.height) / height;
|
|
1244
|
+
if (!x || !Number.isFinite(x)) x = 1;
|
|
1245
|
+
if (!y || !Number.isFinite(y)) y = 1;
|
|
1246
|
+
return {
|
|
1247
|
+
x,
|
|
1248
|
+
y
|
|
1249
|
+
};
|
|
1250
|
+
}
|
|
1251
|
+
var noOffsets = /*#__PURE__*/ createCoords(0);
|
|
1252
|
+
function getVisualOffsets(element) {
|
|
1253
|
+
const win = getWindow(element);
|
|
1254
|
+
if (!isWebKit() || !win.visualViewport) return noOffsets;
|
|
1255
|
+
return {
|
|
1256
|
+
x: win.visualViewport.offsetLeft,
|
|
1257
|
+
y: win.visualViewport.offsetTop
|
|
1258
|
+
};
|
|
1259
|
+
}
|
|
1260
|
+
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
1261
|
+
if (isFixed === void 0) isFixed = false;
|
|
1262
|
+
return !!floatingOffsetParent && isFixed && floatingOffsetParent === getWindow(element);
|
|
1263
|
+
}
|
|
1264
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
1265
|
+
if (includeScale === void 0) includeScale = false;
|
|
1266
|
+
if (isFixedStrategy === void 0) isFixedStrategy = false;
|
|
1267
|
+
const clientRect = element.getBoundingClientRect();
|
|
1268
|
+
const domElement = unwrapElement(element);
|
|
1269
|
+
let scale = createCoords(1);
|
|
1270
|
+
if (includeScale) {
|
|
1271
|
+
if (offsetParent) {
|
|
1272
|
+
if (isElement(offsetParent)) scale = getScale(offsetParent);
|
|
1273
|
+
} else scale = getScale(element);
|
|
1274
|
+
}
|
|
1275
|
+
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
|
1276
|
+
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
|
1277
|
+
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
|
1278
|
+
let width = clientRect.width / scale.x;
|
|
1279
|
+
let height = clientRect.height / scale.y;
|
|
1280
|
+
if (domElement && offsetParent) {
|
|
1281
|
+
const win = getWindow(domElement);
|
|
1282
|
+
const offsetWin = isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
1283
|
+
let currentWin = win;
|
|
1284
|
+
let currentIFrame = getFrameElement(currentWin);
|
|
1285
|
+
while (currentIFrame && offsetWin !== currentWin) {
|
|
1286
|
+
const iframeScale = getScale(currentIFrame);
|
|
1287
|
+
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
1288
|
+
const css = getComputedStyle$1(currentIFrame);
|
|
1289
|
+
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
1290
|
+
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
1291
|
+
x *= iframeScale.x;
|
|
1292
|
+
y *= iframeScale.y;
|
|
1293
|
+
width *= iframeScale.x;
|
|
1294
|
+
height *= iframeScale.y;
|
|
1295
|
+
x += left;
|
|
1296
|
+
y += top;
|
|
1297
|
+
currentWin = getWindow(currentIFrame);
|
|
1298
|
+
currentIFrame = getFrameElement(currentWin);
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
return rectToClientRect({
|
|
1302
|
+
width,
|
|
1303
|
+
height,
|
|
1304
|
+
x,
|
|
1305
|
+
y
|
|
1306
|
+
});
|
|
1307
|
+
}
|
|
1308
|
+
function getWindowScrollBarX(element, rect) {
|
|
1309
|
+
const leftScroll = getNodeScroll(element).scrollLeft;
|
|
1310
|
+
if (!rect) return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
|
|
1311
|
+
return rect.left + leftScroll;
|
|
1312
|
+
}
|
|
1313
|
+
function getHTMLOffset(documentElement, scroll) {
|
|
1314
|
+
const htmlRect = documentElement.getBoundingClientRect();
|
|
1315
|
+
return {
|
|
1316
|
+
x: htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect),
|
|
1317
|
+
y: htmlRect.top + scroll.scrollTop
|
|
1318
|
+
};
|
|
1319
|
+
}
|
|
1320
|
+
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
1321
|
+
let { elements, rect, offsetParent, strategy } = _ref;
|
|
1322
|
+
const isFixed = strategy === "fixed";
|
|
1323
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
1324
|
+
const topLayer = elements ? isTopLayer(elements.floating) : false;
|
|
1325
|
+
if (offsetParent === documentElement || topLayer && isFixed) return rect;
|
|
1326
|
+
let scroll = {
|
|
1327
|
+
scrollLeft: 0,
|
|
1328
|
+
scrollTop: 0
|
|
1329
|
+
};
|
|
1330
|
+
let scale = createCoords(1);
|
|
1331
|
+
const offsets = createCoords(0);
|
|
1332
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1333
|
+
if (isOffsetParentAnElement || !isFixed) {
|
|
1334
|
+
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) scroll = getNodeScroll(offsetParent);
|
|
1335
|
+
if (isOffsetParentAnElement) {
|
|
1336
|
+
const offsetRect = getBoundingClientRect(offsetParent);
|
|
1337
|
+
scale = getScale(offsetParent);
|
|
1338
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1339
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
1343
|
+
return {
|
|
1344
|
+
width: rect.width * scale.x,
|
|
1345
|
+
height: rect.height * scale.y,
|
|
1346
|
+
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
|
|
1347
|
+
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
|
|
1348
|
+
};
|
|
1349
|
+
}
|
|
1350
|
+
function getClientRects(element) {
|
|
1351
|
+
return element.getClientRects ? Array.from(element.getClientRects()) : [];
|
|
1352
|
+
}
|
|
1353
|
+
function getDocumentRect(html) {
|
|
1354
|
+
const scroll = getNodeScroll(html);
|
|
1355
|
+
const body = html.ownerDocument.body;
|
|
1356
|
+
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
|
1357
|
+
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
|
1358
|
+
let x = -scroll.scrollLeft + getWindowScrollBarX(html);
|
|
1359
|
+
const y = -scroll.scrollTop;
|
|
1360
|
+
if (getComputedStyle$1(body).direction === "rtl") x += max(html.clientWidth, body.clientWidth) - width;
|
|
1361
|
+
return {
|
|
1362
|
+
width,
|
|
1363
|
+
height,
|
|
1364
|
+
x,
|
|
1365
|
+
y
|
|
1366
|
+
};
|
|
1367
|
+
}
|
|
1368
|
+
var SCROLLBAR_MAX = 25;
|
|
1369
|
+
function getViewportRect(element, strategy, rootBoundary) {
|
|
1370
|
+
if (rootBoundary === void 0) rootBoundary = "viewport";
|
|
1371
|
+
const isLayoutViewport = rootBoundary === "layoutViewport";
|
|
1372
|
+
const win = getWindow(element);
|
|
1373
|
+
const html = getDocumentElement(element);
|
|
1374
|
+
const visualViewport = win.visualViewport;
|
|
1375
|
+
let width = html.clientWidth;
|
|
1376
|
+
let height = html.clientHeight;
|
|
1377
|
+
let x = 0;
|
|
1378
|
+
let y = 0;
|
|
1379
|
+
if (visualViewport) {
|
|
1380
|
+
const layoutRelativeClientCoords = !isWebKit() || strategy === "fixed";
|
|
1381
|
+
if (isLayoutViewport) {
|
|
1382
|
+
if (!layoutRelativeClientCoords) {
|
|
1383
|
+
x = -visualViewport.offsetLeft;
|
|
1384
|
+
y = -visualViewport.offsetTop;
|
|
1385
|
+
}
|
|
1386
|
+
} else {
|
|
1387
|
+
width = visualViewport.width;
|
|
1388
|
+
height = visualViewport.height;
|
|
1389
|
+
if (layoutRelativeClientCoords) {
|
|
1390
|
+
x = visualViewport.offsetLeft;
|
|
1391
|
+
y = visualViewport.offsetTop;
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
if (getWindowScrollBarX(html) <= 0) {
|
|
1396
|
+
const doc = html.ownerDocument;
|
|
1397
|
+
const body = doc.body;
|
|
1398
|
+
const bodyStyles = getComputedStyle(body);
|
|
1399
|
+
const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
|
|
1400
|
+
const reservedWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
|
|
1401
|
+
const gutter = getComputedStyle(html).scrollbarGutter === "stable both-edges" ? reservedWidth / 2 : reservedWidth;
|
|
1402
|
+
if (gutter <= SCROLLBAR_MAX) width -= gutter;
|
|
1403
|
+
}
|
|
1404
|
+
return {
|
|
1405
|
+
width,
|
|
1406
|
+
height,
|
|
1407
|
+
x,
|
|
1408
|
+
y
|
|
1409
|
+
};
|
|
1410
|
+
}
|
|
1411
|
+
function getInnerBoundingClientRect(element, strategy) {
|
|
1412
|
+
const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
|
|
1413
|
+
const top = clientRect.top + element.clientTop;
|
|
1414
|
+
const left = clientRect.left + element.clientLeft;
|
|
1415
|
+
const scale = getScale(element);
|
|
1416
|
+
return {
|
|
1417
|
+
width: element.clientWidth * scale.x,
|
|
1418
|
+
height: element.clientHeight * scale.y,
|
|
1419
|
+
x: left * scale.x,
|
|
1420
|
+
y: top * scale.y
|
|
1421
|
+
};
|
|
1422
|
+
}
|
|
1423
|
+
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
|
1424
|
+
let rect;
|
|
1425
|
+
if (clippingAncestor === "viewport" || clippingAncestor === "layoutViewport") rect = getViewportRect(element, strategy, clippingAncestor);
|
|
1426
|
+
else if (clippingAncestor === "document") rect = getDocumentRect(getDocumentElement(element));
|
|
1427
|
+
else if (isElement(clippingAncestor)) rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
1428
|
+
else {
|
|
1429
|
+
const visualOffsets = getVisualOffsets(element);
|
|
1430
|
+
rect = {
|
|
1431
|
+
x: clippingAncestor.x - visualOffsets.x,
|
|
1432
|
+
y: clippingAncestor.y - visualOffsets.y,
|
|
1433
|
+
width: clippingAncestor.width,
|
|
1434
|
+
height: clippingAncestor.height
|
|
1435
|
+
};
|
|
1436
|
+
}
|
|
1437
|
+
return rectToClientRect(rect);
|
|
1438
|
+
}
|
|
1439
|
+
function getClippingElementAncestors(element, cache) {
|
|
1440
|
+
const cachedResult = cache.get(element);
|
|
1441
|
+
if (cachedResult) return cachedResult;
|
|
1442
|
+
let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
|
|
1443
|
+
let lastKeptComputedStyle = null;
|
|
1444
|
+
const elementIsFixed = getComputedStyle$1(element).position === "fixed";
|
|
1445
|
+
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
1446
|
+
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1447
|
+
const computedStyle = getComputedStyle$1(currentNode);
|
|
1448
|
+
const currentNodeIsContaining = isContainingBlock(currentNode);
|
|
1449
|
+
const lastPosition = lastKeptComputedStyle ? lastKeptComputedStyle.position : elementIsFixed ? "fixed" : "";
|
|
1450
|
+
if (!currentNodeIsContaining && (lastPosition === "fixed" || lastPosition === "absolute" && computedStyle.position === "static")) result = result.filter((ancestor) => ancestor !== currentNode);
|
|
1451
|
+
else lastKeptComputedStyle = computedStyle;
|
|
1452
|
+
currentNode = getParentNode(currentNode);
|
|
1453
|
+
}
|
|
1454
|
+
cache.set(element, result);
|
|
1455
|
+
return result;
|
|
1456
|
+
}
|
|
1457
|
+
function getClippingRect(_ref) {
|
|
1458
|
+
let { element, boundary, rootBoundary, strategy } = _ref;
|
|
1459
|
+
const clippingAncestors = [...boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary), rootBoundary];
|
|
1460
|
+
const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
|
|
1461
|
+
let top = firstRect.top;
|
|
1462
|
+
let right = firstRect.right;
|
|
1463
|
+
let bottom = firstRect.bottom;
|
|
1464
|
+
let left = firstRect.left;
|
|
1465
|
+
for (let i = 1; i < clippingAncestors.length; i++) {
|
|
1466
|
+
const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i], strategy);
|
|
1467
|
+
top = max(rect.top, top);
|
|
1468
|
+
right = min(rect.right, right);
|
|
1469
|
+
bottom = min(rect.bottom, bottom);
|
|
1470
|
+
left = max(rect.left, left);
|
|
1471
|
+
}
|
|
1472
|
+
return {
|
|
1473
|
+
width: right - left,
|
|
1474
|
+
height: bottom - top,
|
|
1475
|
+
x: left,
|
|
1476
|
+
y: top
|
|
1477
|
+
};
|
|
1478
|
+
}
|
|
1479
|
+
function getDimensions(element) {
|
|
1480
|
+
const { width, height } = getCssDimensions(element);
|
|
1481
|
+
return {
|
|
1482
|
+
width,
|
|
1483
|
+
height
|
|
1484
|
+
};
|
|
1485
|
+
}
|
|
1486
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
1487
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1488
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
1489
|
+
const isFixed = strategy === "fixed";
|
|
1490
|
+
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
|
1491
|
+
let scroll = {
|
|
1492
|
+
scrollLeft: 0,
|
|
1493
|
+
scrollTop: 0
|
|
1494
|
+
};
|
|
1495
|
+
const offsets = createCoords(0);
|
|
1496
|
+
if (isOffsetParentAnElement || !isFixed) {
|
|
1497
|
+
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) scroll = getNodeScroll(offsetParent);
|
|
1498
|
+
if (isOffsetParentAnElement) {
|
|
1499
|
+
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
1500
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1501
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
if (!isOffsetParentAnElement && documentElement) offsets.x = getWindowScrollBarX(documentElement);
|
|
1505
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
1506
|
+
return {
|
|
1507
|
+
x: rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x,
|
|
1508
|
+
y: rect.top + scroll.scrollTop - offsets.y - htmlOffset.y,
|
|
1509
|
+
width: rect.width,
|
|
1510
|
+
height: rect.height
|
|
1511
|
+
};
|
|
1512
|
+
}
|
|
1513
|
+
function isStaticPositioned(element) {
|
|
1514
|
+
return getComputedStyle$1(element).position === "static";
|
|
1515
|
+
}
|
|
1516
|
+
function getTrueOffsetParent(element, polyfill) {
|
|
1517
|
+
if (!isHTMLElement(element) || getComputedStyle$1(element).position === "fixed") return null;
|
|
1518
|
+
if (polyfill) return polyfill(element);
|
|
1519
|
+
let rawOffsetParent = element.offsetParent;
|
|
1520
|
+
if (getDocumentElement(element) === rawOffsetParent) rawOffsetParent = rawOffsetParent.ownerDocument.body;
|
|
1521
|
+
return rawOffsetParent;
|
|
1522
|
+
}
|
|
1523
|
+
function getOffsetParent(element, polyfill) {
|
|
1524
|
+
const win = getWindow(element);
|
|
1525
|
+
if (isTopLayer(element)) return win;
|
|
1526
|
+
if (!isHTMLElement(element)) {
|
|
1527
|
+
let svgOffsetParent = getParentNode(element);
|
|
1528
|
+
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
|
|
1529
|
+
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) return svgOffsetParent;
|
|
1530
|
+
svgOffsetParent = getParentNode(svgOffsetParent);
|
|
1531
|
+
}
|
|
1532
|
+
return win;
|
|
1533
|
+
}
|
|
1534
|
+
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
1535
|
+
while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
1536
|
+
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) return win;
|
|
1537
|
+
return offsetParent || getContainingBlock(element) || win;
|
|
1538
|
+
}
|
|
1539
|
+
var getElementRects = async function(data) {
|
|
1540
|
+
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
1541
|
+
const getDimensionsFn = this.getDimensions;
|
|
1542
|
+
const floatingDimensions = await getDimensionsFn(data.floating);
|
|
1543
|
+
return {
|
|
1544
|
+
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
|
1545
|
+
floating: {
|
|
1546
|
+
x: 0,
|
|
1547
|
+
y: 0,
|
|
1548
|
+
width: floatingDimensions.width,
|
|
1549
|
+
height: floatingDimensions.height
|
|
1550
|
+
}
|
|
1551
|
+
};
|
|
1552
|
+
};
|
|
1553
|
+
function isRTL(element) {
|
|
1554
|
+
return getComputedStyle$1(element).direction === "rtl";
|
|
1555
|
+
}
|
|
1556
|
+
var platform = {
|
|
1557
|
+
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
1558
|
+
getDocumentElement,
|
|
1559
|
+
getClippingRect,
|
|
1560
|
+
getOffsetParent,
|
|
1561
|
+
getElementRects,
|
|
1562
|
+
getClientRects,
|
|
1563
|
+
getDimensions,
|
|
1564
|
+
getScale,
|
|
1565
|
+
isElement,
|
|
1566
|
+
isRTL
|
|
1567
|
+
};
|
|
1568
|
+
function rectsAreEqual(a, b) {
|
|
1569
|
+
return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
|
|
1570
|
+
}
|
|
1571
|
+
function observeMove(element, onMove, ancestorResize) {
|
|
1572
|
+
let io = null;
|
|
1573
|
+
let timeoutId;
|
|
1574
|
+
const root = getDocumentElement(element);
|
|
1575
|
+
function cleanup() {
|
|
1576
|
+
var _io;
|
|
1577
|
+
clearTimeout(timeoutId);
|
|
1578
|
+
(_io = io) == null || _io.disconnect();
|
|
1579
|
+
io = null;
|
|
1580
|
+
}
|
|
1581
|
+
function refresh(skip, threshold) {
|
|
1582
|
+
if (skip === void 0) skip = false;
|
|
1583
|
+
if (threshold === void 0) threshold = 1;
|
|
1584
|
+
cleanup();
|
|
1585
|
+
const elementRectForRootMargin = element.getBoundingClientRect();
|
|
1586
|
+
const { left, top, width, height } = elementRectForRootMargin;
|
|
1587
|
+
if (!skip) onMove();
|
|
1588
|
+
if (!width || !height) return;
|
|
1589
|
+
const insetTop = floor(top);
|
|
1590
|
+
const insetRight = floor(root.clientWidth - (left + width));
|
|
1591
|
+
const insetBottom = floor(root.clientHeight - (top + height));
|
|
1592
|
+
const insetLeft = floor(left);
|
|
1593
|
+
const options = {
|
|
1594
|
+
rootMargin: -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px",
|
|
1595
|
+
threshold: max(0, min(1, threshold)) || 1
|
|
1596
|
+
};
|
|
1597
|
+
let isFirstUpdate = true;
|
|
1598
|
+
function handleObserve(entries) {
|
|
1599
|
+
const ratio = entries[0].intersectionRatio;
|
|
1600
|
+
if (!rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) return refresh();
|
|
1601
|
+
if (ratio !== threshold) {
|
|
1602
|
+
if (!isFirstUpdate) return refresh();
|
|
1603
|
+
if (!ratio) timeoutId = setTimeout(() => {
|
|
1604
|
+
refresh(false, 1e-7);
|
|
1605
|
+
}, 1e3);
|
|
1606
|
+
else refresh(false, ratio);
|
|
1607
|
+
}
|
|
1608
|
+
isFirstUpdate = false;
|
|
1609
|
+
}
|
|
1610
|
+
try {
|
|
1611
|
+
io = new IntersectionObserver(handleObserve, {
|
|
1612
|
+
...options,
|
|
1613
|
+
root: root.ownerDocument
|
|
1614
|
+
});
|
|
1615
|
+
} catch (_e) {
|
|
1616
|
+
io = new IntersectionObserver(handleObserve, options);
|
|
1617
|
+
}
|
|
1618
|
+
io.observe(element);
|
|
1619
|
+
}
|
|
1620
|
+
const win = getWindow(element);
|
|
1621
|
+
const handleResize = () => refresh(ancestorResize);
|
|
1622
|
+
win.addEventListener("resize", handleResize);
|
|
1623
|
+
refresh(true);
|
|
1624
|
+
return () => {
|
|
1625
|
+
win.removeEventListener("resize", handleResize);
|
|
1626
|
+
cleanup();
|
|
1627
|
+
};
|
|
1628
|
+
}
|
|
1629
|
+
/**
|
|
1630
|
+
* Automatically updates the position of the floating element when necessary.
|
|
1631
|
+
* Should only be called when the floating element is mounted on the DOM or
|
|
1632
|
+
* visible on the screen.
|
|
1633
|
+
* @returns cleanup function that should be invoked when the floating element is
|
|
1634
|
+
* removed from the DOM or hidden from the screen.
|
|
1635
|
+
* @see https://floating-ui.com/docs/autoUpdate
|
|
1636
|
+
*/
|
|
1637
|
+
function autoUpdate(reference, floating, update, options) {
|
|
1638
|
+
if (options === void 0) options = {};
|
|
1639
|
+
const { ancestorScroll = true, ancestorResize = true, elementResize = typeof ResizeObserver === "function", layoutShift = typeof IntersectionObserver === "function", animationFrame = false } = options;
|
|
1640
|
+
const referenceEl = unwrapElement(reference);
|
|
1641
|
+
const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
|
|
1642
|
+
ancestors.forEach((ancestor) => {
|
|
1643
|
+
ancestorScroll && ancestor.addEventListener("scroll", update);
|
|
1644
|
+
ancestorResize && ancestor.addEventListener("resize", update);
|
|
1645
|
+
});
|
|
1646
|
+
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update, ancestorResize) : null;
|
|
1647
|
+
let reobserveFrame = -1;
|
|
1648
|
+
let resizeObserver = null;
|
|
1649
|
+
if (elementResize) {
|
|
1650
|
+
resizeObserver = new ResizeObserver((_ref) => {
|
|
1651
|
+
let [firstEntry] = _ref;
|
|
1652
|
+
if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
|
|
1653
|
+
resizeObserver.unobserve(floating);
|
|
1654
|
+
cancelAnimationFrame(reobserveFrame);
|
|
1655
|
+
reobserveFrame = requestAnimationFrame(() => {
|
|
1656
|
+
var _resizeObserver;
|
|
1657
|
+
(_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
|
|
1658
|
+
});
|
|
1659
|
+
}
|
|
1660
|
+
update();
|
|
1661
|
+
});
|
|
1662
|
+
if (referenceEl && !animationFrame) resizeObserver.observe(referenceEl);
|
|
1663
|
+
if (floating) resizeObserver.observe(floating);
|
|
1664
|
+
}
|
|
1665
|
+
let frameId;
|
|
1666
|
+
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
|
1667
|
+
if (animationFrame) frameLoop();
|
|
1668
|
+
function frameLoop() {
|
|
1669
|
+
const nextRefRect = getBoundingClientRect(reference);
|
|
1670
|
+
if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) update();
|
|
1671
|
+
prevRefRect = nextRefRect;
|
|
1672
|
+
frameId = requestAnimationFrame(frameLoop);
|
|
1673
|
+
}
|
|
1674
|
+
update();
|
|
1675
|
+
return () => {
|
|
1676
|
+
var _resizeObserver2;
|
|
1677
|
+
ancestors.forEach((ancestor) => {
|
|
1678
|
+
ancestorScroll && ancestor.removeEventListener("scroll", update);
|
|
1679
|
+
ancestorResize && ancestor.removeEventListener("resize", update);
|
|
1680
|
+
});
|
|
1681
|
+
cleanupIo?.();
|
|
1682
|
+
(_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
|
|
1683
|
+
resizeObserver = null;
|
|
1684
|
+
if (animationFrame) cancelAnimationFrame(frameId);
|
|
1685
|
+
};
|
|
1686
|
+
}
|
|
1687
|
+
/**
|
|
1688
|
+
* Modifies the placement by translating the floating element along the
|
|
1689
|
+
* specified axes.
|
|
1690
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
|
1691
|
+
* object may be passed.
|
|
1692
|
+
* @see https://floating-ui.com/docs/offset
|
|
1693
|
+
*/
|
|
1694
|
+
var offset$2 = offset$1;
|
|
1695
|
+
/**
|
|
1696
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
|
1697
|
+
* keep it in view when it will overflow the clipping boundary.
|
|
1698
|
+
* @see https://floating-ui.com/docs/shift
|
|
1699
|
+
*/
|
|
1700
|
+
var shift$2 = shift$1;
|
|
1701
|
+
/**
|
|
1702
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
1703
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
1704
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
1705
|
+
* @see https://floating-ui.com/docs/flip
|
|
1706
|
+
*/
|
|
1707
|
+
var flip$2 = flip$1;
|
|
1708
|
+
/**
|
|
1709
|
+
* Provides data that allows you to change the size of the floating element —
|
|
1710
|
+
* for instance, prevent it from overflowing the clipping boundary or match the
|
|
1711
|
+
* width of the reference element.
|
|
1712
|
+
* @see https://floating-ui.com/docs/size
|
|
1713
|
+
*/
|
|
1714
|
+
var size$2 = size$1;
|
|
1715
|
+
/**
|
|
1716
|
+
* Provides data to hide the floating element in applicable situations, such as
|
|
1717
|
+
* when it is not in the same clipping context as the reference element.
|
|
1718
|
+
* @see https://floating-ui.com/docs/hide
|
|
1719
|
+
*/
|
|
1720
|
+
var hide$2 = hide$1;
|
|
1721
|
+
/**
|
|
1722
|
+
* Provides data to position an inner element of the floating element so that it
|
|
1723
|
+
* appears centered to the reference element.
|
|
1724
|
+
* @see https://floating-ui.com/docs/arrow
|
|
1725
|
+
*/
|
|
1726
|
+
var arrow$2 = arrow$3;
|
|
1727
|
+
/**
|
|
1728
|
+
* Built-in `limiter` that will stop `shift()` at a certain point.
|
|
1729
|
+
*/
|
|
1730
|
+
var limitShift$2 = limitShift$1;
|
|
1731
|
+
/**
|
|
1732
|
+
* Computes the `x` and `y` coordinates that will place the floating element
|
|
1733
|
+
* next to a given reference element.
|
|
1734
|
+
*/
|
|
1735
|
+
var computePosition = (reference, floating, options) => {
|
|
1736
|
+
const cache = /* @__PURE__ */ new Map();
|
|
1737
|
+
const mergedOptions = options != null ? options : {};
|
|
1738
|
+
const platformWithCache = {
|
|
1739
|
+
...platform,
|
|
1740
|
+
...mergedOptions.platform,
|
|
1741
|
+
_c: cache
|
|
1742
|
+
};
|
|
1743
|
+
return computePosition$1(reference, floating, {
|
|
1744
|
+
...mergedOptions,
|
|
1745
|
+
platform: platformWithCache
|
|
1746
|
+
});
|
|
1747
|
+
};
|
|
1748
|
+
// ../../node_modules/.bun/@floating-ui+react-dom@2.1.9+dfc90389513bb65c/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
|
|
1749
|
+
var index = typeof document !== "undefined" ? import_react.useLayoutEffect : function noop() {};
|
|
1750
|
+
function deepEqual(a, b) {
|
|
1751
|
+
if (a === b) return true;
|
|
1752
|
+
if (typeof a !== typeof b) return false;
|
|
1753
|
+
if (typeof a === "function" && a.toString() === b.toString()) return true;
|
|
1754
|
+
let length;
|
|
1755
|
+
let i;
|
|
1756
|
+
let keys;
|
|
1757
|
+
if (a && b && typeof a === "object") {
|
|
1758
|
+
if (Array.isArray(a)) {
|
|
1759
|
+
length = a.length;
|
|
1760
|
+
if (length !== b.length) return false;
|
|
1761
|
+
for (i = length; i-- !== 0;) if (!deepEqual(a[i], b[i])) return false;
|
|
1762
|
+
return true;
|
|
1763
|
+
}
|
|
1764
|
+
keys = Object.keys(a);
|
|
1765
|
+
length = keys.length;
|
|
1766
|
+
if (length !== Object.keys(b).length) return false;
|
|
1767
|
+
for (i = length; i-- !== 0;) if (!{}.hasOwnProperty.call(b, keys[i])) return false;
|
|
1768
|
+
for (i = length; i-- !== 0;) {
|
|
1769
|
+
const key = keys[i];
|
|
1770
|
+
if (key === "_owner" && a.$$typeof) continue;
|
|
1771
|
+
if (!deepEqual(a[key], b[key])) return false;
|
|
1772
|
+
}
|
|
1773
|
+
return true;
|
|
1774
|
+
}
|
|
1775
|
+
return a !== a && b !== b;
|
|
1776
|
+
}
|
|
1777
|
+
function getDPR(element) {
|
|
1778
|
+
if (typeof window === "undefined") return 1;
|
|
1779
|
+
return (element.ownerDocument.defaultView || window).devicePixelRatio || 1;
|
|
1780
|
+
}
|
|
1781
|
+
function roundByDPR(element, value) {
|
|
1782
|
+
const dpr = getDPR(element);
|
|
1783
|
+
return Math.round(value * dpr) / dpr;
|
|
1784
|
+
}
|
|
1785
|
+
function useLatestRef(value) {
|
|
1786
|
+
const ref = import_react.useRef(value);
|
|
1787
|
+
index(() => {
|
|
1788
|
+
ref.current = value;
|
|
1789
|
+
});
|
|
1790
|
+
return ref;
|
|
1791
|
+
}
|
|
1792
|
+
/**
|
|
1793
|
+
* Provides data to position a floating element.
|
|
1794
|
+
* @see https://floating-ui.com/docs/useFloating
|
|
1795
|
+
*/
|
|
1796
|
+
function useFloating(options) {
|
|
1797
|
+
if (options === void 0) options = {};
|
|
1798
|
+
const { placement = "bottom", strategy = "absolute", middleware = [], platform, elements: { reference: externalReference, floating: externalFloating } = {}, transform = true, whileElementsMounted, open } = options;
|
|
1799
|
+
const [data, setData] = import_react.useState({
|
|
1800
|
+
x: 0,
|
|
1801
|
+
y: 0,
|
|
1802
|
+
strategy,
|
|
1803
|
+
placement,
|
|
1804
|
+
middlewareData: {},
|
|
1805
|
+
isPositioned: false
|
|
1806
|
+
});
|
|
1807
|
+
const [latestMiddleware, setLatestMiddleware] = import_react.useState(middleware);
|
|
1808
|
+
if (!deepEqual(latestMiddleware, middleware)) setLatestMiddleware(middleware);
|
|
1809
|
+
const [_reference, _setReference] = import_react.useState(null);
|
|
1810
|
+
const [_floating, _setFloating] = import_react.useState(null);
|
|
1811
|
+
const setReference = import_react.useCallback((node) => {
|
|
1812
|
+
if (node !== referenceRef.current) {
|
|
1813
|
+
referenceRef.current = node;
|
|
1814
|
+
_setReference(node);
|
|
1815
|
+
}
|
|
1816
|
+
}, []);
|
|
1817
|
+
const setFloating = import_react.useCallback((node) => {
|
|
1818
|
+
if (node !== floatingRef.current) {
|
|
1819
|
+
floatingRef.current = node;
|
|
1820
|
+
_setFloating(node);
|
|
1821
|
+
}
|
|
1822
|
+
}, []);
|
|
1823
|
+
const referenceEl = externalReference || _reference;
|
|
1824
|
+
const floatingEl = externalFloating || _floating;
|
|
1825
|
+
const referenceRef = import_react.useRef(null);
|
|
1826
|
+
const floatingRef = import_react.useRef(null);
|
|
1827
|
+
const dataRef = import_react.useRef(data);
|
|
1828
|
+
const hasWhileElementsMounted = whileElementsMounted != null;
|
|
1829
|
+
const whileElementsMountedRef = useLatestRef(whileElementsMounted);
|
|
1830
|
+
const platformRef = useLatestRef(platform);
|
|
1831
|
+
const openRef = useLatestRef(open);
|
|
1832
|
+
const update = import_react.useCallback(() => {
|
|
1833
|
+
if (!referenceRef.current || !floatingRef.current) return;
|
|
1834
|
+
const config = {
|
|
1835
|
+
placement,
|
|
1836
|
+
strategy,
|
|
1837
|
+
middleware: latestMiddleware
|
|
1838
|
+
};
|
|
1839
|
+
if (platformRef.current) config.platform = platformRef.current;
|
|
1840
|
+
computePosition(referenceRef.current, floatingRef.current, config).then((data) => {
|
|
1841
|
+
const fullData = {
|
|
1842
|
+
...data,
|
|
1843
|
+
isPositioned: openRef.current !== false
|
|
1844
|
+
};
|
|
1845
|
+
if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
|
|
1846
|
+
dataRef.current = fullData;
|
|
1847
|
+
import_react_dom.flushSync(() => {
|
|
1848
|
+
setData(fullData);
|
|
1849
|
+
});
|
|
1850
|
+
}
|
|
1851
|
+
});
|
|
1852
|
+
}, [
|
|
1853
|
+
latestMiddleware,
|
|
1854
|
+
placement,
|
|
1855
|
+
strategy,
|
|
1856
|
+
platformRef,
|
|
1857
|
+
openRef
|
|
1858
|
+
]);
|
|
1859
|
+
index(() => {
|
|
1860
|
+
if (open === false && dataRef.current.isPositioned) {
|
|
1861
|
+
dataRef.current.isPositioned = false;
|
|
1862
|
+
setData((data) => ({
|
|
1863
|
+
...data,
|
|
1864
|
+
isPositioned: false
|
|
1865
|
+
}));
|
|
1866
|
+
}
|
|
1867
|
+
}, [open]);
|
|
1868
|
+
const isMountedRef = import_react.useRef(false);
|
|
1869
|
+
index(() => {
|
|
1870
|
+
isMountedRef.current = true;
|
|
1871
|
+
return () => {
|
|
1872
|
+
isMountedRef.current = false;
|
|
1873
|
+
};
|
|
1874
|
+
}, []);
|
|
1875
|
+
index(() => {
|
|
1876
|
+
if (referenceEl) referenceRef.current = referenceEl;
|
|
1877
|
+
if (floatingEl) floatingRef.current = floatingEl;
|
|
1878
|
+
if (referenceEl && floatingEl) {
|
|
1879
|
+
if (whileElementsMountedRef.current) return whileElementsMountedRef.current(referenceEl, floatingEl, update);
|
|
1880
|
+
update();
|
|
1881
|
+
}
|
|
1882
|
+
}, [
|
|
1883
|
+
referenceEl,
|
|
1884
|
+
floatingEl,
|
|
1885
|
+
update,
|
|
1886
|
+
whileElementsMountedRef,
|
|
1887
|
+
hasWhileElementsMounted
|
|
1888
|
+
]);
|
|
1889
|
+
const refs = import_react.useMemo(() => ({
|
|
1890
|
+
reference: referenceRef,
|
|
1891
|
+
floating: floatingRef,
|
|
1892
|
+
setReference,
|
|
1893
|
+
setFloating
|
|
1894
|
+
}), [setReference, setFloating]);
|
|
1895
|
+
const elements = import_react.useMemo(() => ({
|
|
1896
|
+
reference: referenceEl,
|
|
1897
|
+
floating: floatingEl
|
|
1898
|
+
}), [referenceEl, floatingEl]);
|
|
1899
|
+
const floatingStyles = import_react.useMemo(() => {
|
|
1900
|
+
const initialStyles = {
|
|
1901
|
+
position: strategy,
|
|
1902
|
+
left: 0,
|
|
1903
|
+
top: 0
|
|
1904
|
+
};
|
|
1905
|
+
if (!elements.floating) return initialStyles;
|
|
1906
|
+
const x = roundByDPR(elements.floating, data.x);
|
|
1907
|
+
const y = roundByDPR(elements.floating, data.y);
|
|
1908
|
+
if (transform) return {
|
|
1909
|
+
...initialStyles,
|
|
1910
|
+
transform: "translate(" + x + "px, " + y + "px)",
|
|
1911
|
+
...getDPR(elements.floating) >= 1.5 && { willChange: "transform" }
|
|
1912
|
+
};
|
|
1913
|
+
return {
|
|
1914
|
+
position: strategy,
|
|
1915
|
+
left: x,
|
|
1916
|
+
top: y
|
|
1917
|
+
};
|
|
1918
|
+
}, [
|
|
1919
|
+
strategy,
|
|
1920
|
+
transform,
|
|
1921
|
+
elements.floating,
|
|
1922
|
+
data.x,
|
|
1923
|
+
data.y
|
|
1924
|
+
]);
|
|
1925
|
+
return import_react.useMemo(() => ({
|
|
1926
|
+
...data,
|
|
1927
|
+
update,
|
|
1928
|
+
refs,
|
|
1929
|
+
elements,
|
|
1930
|
+
floatingStyles
|
|
1931
|
+
}), [
|
|
1932
|
+
data,
|
|
1933
|
+
update,
|
|
1934
|
+
refs,
|
|
1935
|
+
elements,
|
|
1936
|
+
floatingStyles
|
|
1937
|
+
]);
|
|
1938
|
+
}
|
|
1939
|
+
/**
|
|
1940
|
+
* Provides data to position an inner element of the floating element so that it
|
|
1941
|
+
* appears centered to the reference element.
|
|
1942
|
+
* This wraps the core `arrow` middleware to allow React refs as the element.
|
|
1943
|
+
* @see https://floating-ui.com/docs/arrow
|
|
1944
|
+
*/
|
|
1945
|
+
var arrow$1 = (options) => {
|
|
1946
|
+
function isRef(value) {
|
|
1947
|
+
return {}.hasOwnProperty.call(value, "current");
|
|
1948
|
+
}
|
|
1949
|
+
return {
|
|
1950
|
+
name: "arrow",
|
|
1951
|
+
options,
|
|
1952
|
+
fn(state) {
|
|
1953
|
+
const { element, padding } = typeof options === "function" ? options(state) : options;
|
|
1954
|
+
if (element && isRef(element)) {
|
|
1955
|
+
if (element.current != null) return arrow$2({
|
|
1956
|
+
element: element.current,
|
|
1957
|
+
padding
|
|
1958
|
+
}).fn(state);
|
|
1959
|
+
return {};
|
|
1960
|
+
}
|
|
1961
|
+
if (element) return arrow$2({
|
|
1962
|
+
element,
|
|
1963
|
+
padding
|
|
1964
|
+
}).fn(state);
|
|
1965
|
+
return {};
|
|
1966
|
+
}
|
|
1967
|
+
};
|
|
1968
|
+
};
|
|
1969
|
+
/**
|
|
1970
|
+
* Modifies the placement by translating the floating element along the
|
|
1971
|
+
* specified axes.
|
|
1972
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
|
1973
|
+
* object may be passed.
|
|
1974
|
+
* @see https://floating-ui.com/docs/offset
|
|
1975
|
+
*/
|
|
1976
|
+
var offset = (options, deps) => {
|
|
1977
|
+
const result = offset$2(options);
|
|
1978
|
+
return {
|
|
1979
|
+
name: result.name,
|
|
1980
|
+
fn: result.fn,
|
|
1981
|
+
options: [options, deps]
|
|
1982
|
+
};
|
|
1983
|
+
};
|
|
1984
|
+
/**
|
|
1985
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
|
1986
|
+
* keep it in view when it will overflow the clipping boundary.
|
|
1987
|
+
* @see https://floating-ui.com/docs/shift
|
|
1988
|
+
*/
|
|
1989
|
+
var shift = (options, deps) => {
|
|
1990
|
+
const result = shift$2(options);
|
|
1991
|
+
return {
|
|
1992
|
+
name: result.name,
|
|
1993
|
+
fn: result.fn,
|
|
1994
|
+
options: [options, deps]
|
|
1995
|
+
};
|
|
1996
|
+
};
|
|
1997
|
+
/**
|
|
1998
|
+
* Built-in `limiter` that will stop `shift()` at a certain point.
|
|
1999
|
+
*/
|
|
2000
|
+
var limitShift = (options, deps) => {
|
|
2001
|
+
return {
|
|
2002
|
+
fn: limitShift$2(options).fn,
|
|
2003
|
+
options: [options, deps]
|
|
2004
|
+
};
|
|
2005
|
+
};
|
|
2006
|
+
/**
|
|
2007
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
2008
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
2009
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
2010
|
+
* @see https://floating-ui.com/docs/flip
|
|
2011
|
+
*/
|
|
2012
|
+
var flip = (options, deps) => {
|
|
2013
|
+
const result = flip$2(options);
|
|
2014
|
+
return {
|
|
2015
|
+
name: result.name,
|
|
2016
|
+
fn: result.fn,
|
|
2017
|
+
options: [options, deps]
|
|
2018
|
+
};
|
|
2019
|
+
};
|
|
2020
|
+
/**
|
|
2021
|
+
* Provides data that allows you to change the size of the floating element —
|
|
2022
|
+
* for instance, prevent it from overflowing the clipping boundary or match the
|
|
2023
|
+
* width of the reference element.
|
|
2024
|
+
* @see https://floating-ui.com/docs/size
|
|
2025
|
+
*/
|
|
2026
|
+
var size = (options, deps) => {
|
|
2027
|
+
const result = size$2(options);
|
|
2028
|
+
return {
|
|
2029
|
+
name: result.name,
|
|
2030
|
+
fn: result.fn,
|
|
2031
|
+
options: [options, deps]
|
|
2032
|
+
};
|
|
2033
|
+
};
|
|
2034
|
+
/**
|
|
2035
|
+
* Provides data to hide the floating element in applicable situations, such as
|
|
2036
|
+
* when it is not in the same clipping context as the reference element.
|
|
2037
|
+
* @see https://floating-ui.com/docs/hide
|
|
2038
|
+
*/
|
|
2039
|
+
var hide = (options, deps) => {
|
|
2040
|
+
const result = hide$2(options);
|
|
2041
|
+
return {
|
|
2042
|
+
name: result.name,
|
|
2043
|
+
fn: result.fn,
|
|
2044
|
+
options: [options, deps]
|
|
2045
|
+
};
|
|
2046
|
+
};
|
|
2047
|
+
/**
|
|
2048
|
+
* Provides data to position an inner element of the floating element so that it
|
|
2049
|
+
* appears centered to the reference element.
|
|
2050
|
+
* This wraps the core `arrow` middleware to allow React refs as the element.
|
|
2051
|
+
* @see https://floating-ui.com/docs/arrow
|
|
2052
|
+
*/
|
|
2053
|
+
var arrow = (options, deps) => {
|
|
2054
|
+
const result = arrow$1(options);
|
|
2055
|
+
return {
|
|
2056
|
+
name: result.name,
|
|
2057
|
+
fn: result.fn,
|
|
2058
|
+
options: [options, deps]
|
|
2059
|
+
};
|
|
2060
|
+
};
|
|
2061
|
+
// ../../node_modules/.bun/@radix-ui+react-arrow@1.1.7+a68cb332b68cb125/node_modules/@radix-ui/react-arrow/dist/index.mjs
|
|
2062
|
+
var NAME$1 = "Arrow";
|
|
2063
|
+
var Arrow$1 = import_react.forwardRef((props, forwardedRef) => {
|
|
2064
|
+
const { children, width = 10, height = 5, ...arrowProps } = props;
|
|
2065
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Primitive.svg, {
|
|
2066
|
+
...arrowProps,
|
|
2067
|
+
ref: forwardedRef,
|
|
2068
|
+
width,
|
|
2069
|
+
height,
|
|
2070
|
+
viewBox: "0 0 30 10",
|
|
2071
|
+
preserveAspectRatio: "none",
|
|
2072
|
+
children: props.asChild ? children : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("polygon", { points: "0,0 30,0 15,10" })
|
|
2073
|
+
});
|
|
2074
|
+
});
|
|
2075
|
+
Arrow$1.displayName = NAME$1;
|
|
2076
|
+
var Root$1 = Arrow$1;
|
|
2077
|
+
// ../../node_modules/.bun/@radix-ui+react-use-size@1.1.1+340ca8aed1dead99/node_modules/@radix-ui/react-use-size/dist/index.mjs
|
|
2078
|
+
function useSize(element) {
|
|
2079
|
+
const [size, setSize] = import_react.useState(void 0);
|
|
2080
|
+
useLayoutEffect2(() => {
|
|
2081
|
+
if (element) {
|
|
2082
|
+
setSize({
|
|
2083
|
+
width: element.offsetWidth,
|
|
2084
|
+
height: element.offsetHeight
|
|
2085
|
+
});
|
|
2086
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
2087
|
+
if (!Array.isArray(entries)) return;
|
|
2088
|
+
if (!entries.length) return;
|
|
2089
|
+
const entry = entries[0];
|
|
2090
|
+
let width;
|
|
2091
|
+
let height;
|
|
2092
|
+
if ("borderBoxSize" in entry) {
|
|
2093
|
+
const borderSizeEntry = entry["borderBoxSize"];
|
|
2094
|
+
const borderSize = Array.isArray(borderSizeEntry) ? borderSizeEntry[0] : borderSizeEntry;
|
|
2095
|
+
width = borderSize["inlineSize"];
|
|
2096
|
+
height = borderSize["blockSize"];
|
|
2097
|
+
} else {
|
|
2098
|
+
width = element.offsetWidth;
|
|
2099
|
+
height = element.offsetHeight;
|
|
2100
|
+
}
|
|
2101
|
+
setSize({
|
|
2102
|
+
width,
|
|
2103
|
+
height
|
|
2104
|
+
});
|
|
2105
|
+
});
|
|
2106
|
+
resizeObserver.observe(element, { box: "border-box" });
|
|
2107
|
+
return () => resizeObserver.unobserve(element);
|
|
2108
|
+
} else setSize(void 0);
|
|
2109
|
+
}, [element]);
|
|
2110
|
+
return size;
|
|
2111
|
+
}
|
|
2112
|
+
// ../../node_modules/.bun/@radix-ui+react-popper@1.2.8+a68cb332b68cb125/node_modules/@radix-ui/react-popper/dist/index.mjs
|
|
2113
|
+
var POPPER_NAME = "Popper";
|
|
2114
|
+
var [createPopperContext, createPopperScope] = createContextScope(POPPER_NAME);
|
|
2115
|
+
var [PopperProvider, usePopperContext] = createPopperContext(POPPER_NAME);
|
|
2116
|
+
var Popper = (props) => {
|
|
2117
|
+
const { __scopePopper, children } = props;
|
|
2118
|
+
const [anchor, setAnchor] = import_react.useState(null);
|
|
2119
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperProvider, {
|
|
2120
|
+
scope: __scopePopper,
|
|
2121
|
+
anchor,
|
|
2122
|
+
onAnchorChange: setAnchor,
|
|
2123
|
+
children
|
|
2124
|
+
});
|
|
2125
|
+
};
|
|
2126
|
+
Popper.displayName = POPPER_NAME;
|
|
2127
|
+
var ANCHOR_NAME = "PopperAnchor";
|
|
2128
|
+
var PopperAnchor = import_react.forwardRef((props, forwardedRef) => {
|
|
2129
|
+
const { __scopePopper, virtualRef, ...anchorProps } = props;
|
|
2130
|
+
const context = usePopperContext(ANCHOR_NAME, __scopePopper);
|
|
2131
|
+
const ref = import_react.useRef(null);
|
|
2132
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
2133
|
+
const anchorRef = import_react.useRef(null);
|
|
2134
|
+
import_react.useEffect(() => {
|
|
2135
|
+
const previousAnchor = anchorRef.current;
|
|
2136
|
+
anchorRef.current = virtualRef?.current || ref.current;
|
|
2137
|
+
if (previousAnchor !== anchorRef.current) context.onAnchorChange(anchorRef.current);
|
|
2138
|
+
});
|
|
2139
|
+
return virtualRef ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Primitive.div, {
|
|
2140
|
+
...anchorProps,
|
|
2141
|
+
ref: composedRefs
|
|
2142
|
+
});
|
|
2143
|
+
});
|
|
2144
|
+
PopperAnchor.displayName = ANCHOR_NAME;
|
|
2145
|
+
var CONTENT_NAME$1 = "PopperContent";
|
|
2146
|
+
var [PopperContentProvider, useContentContext] = createPopperContext(CONTENT_NAME$1);
|
|
2147
|
+
var PopperContent = import_react.forwardRef((props, forwardedRef) => {
|
|
2148
|
+
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;
|
|
2149
|
+
const context = usePopperContext(CONTENT_NAME$1, __scopePopper);
|
|
2150
|
+
const [content, setContent] = import_react.useState(null);
|
|
2151
|
+
const composedRefs = useComposedRefs(forwardedRef, (node) => setContent(node));
|
|
2152
|
+
const [arrow$4, setArrow] = import_react.useState(null);
|
|
2153
|
+
const arrowSize = useSize(arrow$4);
|
|
2154
|
+
const arrowWidth = arrowSize?.width ?? 0;
|
|
2155
|
+
const arrowHeight = arrowSize?.height ?? 0;
|
|
2156
|
+
const desiredPlacement = side + (align !== "center" ? "-" + align : "");
|
|
2157
|
+
const collisionPadding = typeof collisionPaddingProp === "number" ? collisionPaddingProp : {
|
|
2158
|
+
top: 0,
|
|
2159
|
+
right: 0,
|
|
2160
|
+
bottom: 0,
|
|
2161
|
+
left: 0,
|
|
2162
|
+
...collisionPaddingProp
|
|
2163
|
+
};
|
|
2164
|
+
const boundary = Array.isArray(collisionBoundary) ? collisionBoundary : [collisionBoundary];
|
|
2165
|
+
const hasExplicitBoundaries = boundary.length > 0;
|
|
2166
|
+
const detectOverflowOptions = {
|
|
2167
|
+
padding: collisionPadding,
|
|
2168
|
+
boundary: boundary.filter(isNotNull),
|
|
2169
|
+
altBoundary: hasExplicitBoundaries
|
|
2170
|
+
};
|
|
2171
|
+
const { refs, floatingStyles, placement, isPositioned, middlewareData } = useFloating({
|
|
2172
|
+
strategy: "fixed",
|
|
2173
|
+
placement: desiredPlacement,
|
|
2174
|
+
whileElementsMounted: (...args) => {
|
|
2175
|
+
return autoUpdate(...args, { animationFrame: updatePositionStrategy === "always" });
|
|
2176
|
+
},
|
|
2177
|
+
elements: { reference: context.anchor },
|
|
2178
|
+
middleware: [
|
|
2179
|
+
offset({
|
|
2180
|
+
mainAxis: sideOffset + arrowHeight,
|
|
2181
|
+
alignmentAxis: alignOffset
|
|
2182
|
+
}),
|
|
2183
|
+
avoidCollisions && shift({
|
|
2184
|
+
mainAxis: true,
|
|
2185
|
+
crossAxis: false,
|
|
2186
|
+
limiter: sticky === "partial" ? limitShift() : void 0,
|
|
2187
|
+
...detectOverflowOptions
|
|
2188
|
+
}),
|
|
2189
|
+
avoidCollisions && flip({ ...detectOverflowOptions }),
|
|
2190
|
+
size({
|
|
2191
|
+
...detectOverflowOptions,
|
|
2192
|
+
apply: ({ elements, rects, availableWidth, availableHeight }) => {
|
|
2193
|
+
const { width: anchorWidth, height: anchorHeight } = rects.reference;
|
|
2194
|
+
const contentStyle = elements.floating.style;
|
|
2195
|
+
contentStyle.setProperty("--radix-popper-available-width", `${availableWidth}px`);
|
|
2196
|
+
contentStyle.setProperty("--radix-popper-available-height", `${availableHeight}px`);
|
|
2197
|
+
contentStyle.setProperty("--radix-popper-anchor-width", `${anchorWidth}px`);
|
|
2198
|
+
contentStyle.setProperty("--radix-popper-anchor-height", `${anchorHeight}px`);
|
|
2199
|
+
}
|
|
2200
|
+
}),
|
|
2201
|
+
arrow$4 && arrow({
|
|
2202
|
+
element: arrow$4,
|
|
2203
|
+
padding: arrowPadding
|
|
2204
|
+
}),
|
|
2205
|
+
transformOrigin({
|
|
2206
|
+
arrowWidth,
|
|
2207
|
+
arrowHeight
|
|
2208
|
+
}),
|
|
2209
|
+
hideWhenDetached && hide({
|
|
2210
|
+
strategy: "referenceHidden",
|
|
2211
|
+
...detectOverflowOptions
|
|
2212
|
+
})
|
|
2213
|
+
]
|
|
2214
|
+
});
|
|
2215
|
+
const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
|
|
2216
|
+
const handlePlaced = useCallbackRef(onPlaced);
|
|
2217
|
+
useLayoutEffect2(() => {
|
|
2218
|
+
if (isPositioned) handlePlaced?.();
|
|
2219
|
+
}, [isPositioned, handlePlaced]);
|
|
2220
|
+
const arrowX = middlewareData.arrow?.x;
|
|
2221
|
+
const arrowY = middlewareData.arrow?.y;
|
|
2222
|
+
const cannotCenterArrow = middlewareData.arrow?.centerOffset !== 0;
|
|
2223
|
+
const [contentZIndex, setContentZIndex] = import_react.useState();
|
|
2224
|
+
useLayoutEffect2(() => {
|
|
2225
|
+
if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
|
|
2226
|
+
}, [content]);
|
|
2227
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
2228
|
+
ref: refs.setFloating,
|
|
2229
|
+
"data-radix-popper-content-wrapper": "",
|
|
2230
|
+
style: {
|
|
2231
|
+
...floatingStyles,
|
|
2232
|
+
transform: isPositioned ? floatingStyles.transform : "translate(0, -200%)",
|
|
2233
|
+
minWidth: "max-content",
|
|
2234
|
+
zIndex: contentZIndex,
|
|
2235
|
+
["--radix-popper-transform-origin"]: [middlewareData.transformOrigin?.x, middlewareData.transformOrigin?.y].join(" "),
|
|
2236
|
+
...middlewareData.hide?.referenceHidden && {
|
|
2237
|
+
visibility: "hidden",
|
|
2238
|
+
pointerEvents: "none"
|
|
2239
|
+
}
|
|
2240
|
+
},
|
|
2241
|
+
dir: props.dir,
|
|
2242
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperContentProvider, {
|
|
2243
|
+
scope: __scopePopper,
|
|
2244
|
+
placedSide,
|
|
2245
|
+
onArrowChange: setArrow,
|
|
2246
|
+
arrowX,
|
|
2247
|
+
arrowY,
|
|
2248
|
+
shouldHideArrow: cannotCenterArrow,
|
|
2249
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Primitive.div, {
|
|
2250
|
+
"data-side": placedSide,
|
|
2251
|
+
"data-align": placedAlign,
|
|
2252
|
+
...contentProps,
|
|
2253
|
+
ref: composedRefs,
|
|
2254
|
+
style: {
|
|
2255
|
+
...contentProps.style,
|
|
2256
|
+
animation: !isPositioned ? "none" : void 0
|
|
2257
|
+
}
|
|
2258
|
+
})
|
|
2259
|
+
})
|
|
2260
|
+
});
|
|
2261
|
+
});
|
|
2262
|
+
PopperContent.displayName = CONTENT_NAME$1;
|
|
2263
|
+
var ARROW_NAME$1 = "PopperArrow";
|
|
2264
|
+
var OPPOSITE_SIDE = {
|
|
2265
|
+
top: "bottom",
|
|
2266
|
+
right: "left",
|
|
2267
|
+
bottom: "top",
|
|
2268
|
+
left: "right"
|
|
2269
|
+
};
|
|
2270
|
+
var PopperArrow = import_react.forwardRef(function PopperArrow2(props, forwardedRef) {
|
|
2271
|
+
const { __scopePopper, ...arrowProps } = props;
|
|
2272
|
+
const contentContext = useContentContext(ARROW_NAME$1, __scopePopper);
|
|
2273
|
+
const baseSide = OPPOSITE_SIDE[contentContext.placedSide];
|
|
2274
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
2275
|
+
ref: contentContext.onArrowChange,
|
|
2276
|
+
style: {
|
|
2277
|
+
position: "absolute",
|
|
2278
|
+
left: contentContext.arrowX,
|
|
2279
|
+
top: contentContext.arrowY,
|
|
2280
|
+
[baseSide]: 0,
|
|
2281
|
+
transformOrigin: {
|
|
2282
|
+
top: "",
|
|
2283
|
+
right: "0 0",
|
|
2284
|
+
bottom: "center 0",
|
|
2285
|
+
left: "100% 0"
|
|
2286
|
+
}[contentContext.placedSide],
|
|
2287
|
+
transform: {
|
|
2288
|
+
top: "translateY(100%)",
|
|
2289
|
+
right: "translateY(50%) rotate(90deg) translateX(-50%)",
|
|
2290
|
+
bottom: `rotate(180deg)`,
|
|
2291
|
+
left: "translateY(50%) rotate(-90deg) translateX(50%)"
|
|
2292
|
+
}[contentContext.placedSide],
|
|
2293
|
+
visibility: contentContext.shouldHideArrow ? "hidden" : void 0
|
|
2294
|
+
},
|
|
2295
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Root$1, {
|
|
2296
|
+
...arrowProps,
|
|
2297
|
+
ref: forwardedRef,
|
|
2298
|
+
style: {
|
|
2299
|
+
...arrowProps.style,
|
|
2300
|
+
display: "block"
|
|
2301
|
+
}
|
|
2302
|
+
})
|
|
2303
|
+
});
|
|
2304
|
+
});
|
|
2305
|
+
PopperArrow.displayName = ARROW_NAME$1;
|
|
2306
|
+
function isNotNull(value) {
|
|
2307
|
+
return value !== null;
|
|
2308
|
+
}
|
|
2309
|
+
var transformOrigin = (options) => ({
|
|
2310
|
+
name: "transformOrigin",
|
|
2311
|
+
options,
|
|
2312
|
+
fn(data) {
|
|
2313
|
+
const { placement, rects, middlewareData } = data;
|
|
2314
|
+
const isArrowHidden = middlewareData.arrow?.centerOffset !== 0;
|
|
2315
|
+
const arrowWidth = isArrowHidden ? 0 : options.arrowWidth;
|
|
2316
|
+
const arrowHeight = isArrowHidden ? 0 : options.arrowHeight;
|
|
2317
|
+
const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
|
|
2318
|
+
const noArrowAlign = {
|
|
2319
|
+
start: "0%",
|
|
2320
|
+
center: "50%",
|
|
2321
|
+
end: "100%"
|
|
2322
|
+
}[placedAlign];
|
|
2323
|
+
const arrowXCenter = (middlewareData.arrow?.x ?? 0) + arrowWidth / 2;
|
|
2324
|
+
const arrowYCenter = (middlewareData.arrow?.y ?? 0) + arrowHeight / 2;
|
|
2325
|
+
let x = "";
|
|
2326
|
+
let y = "";
|
|
2327
|
+
if (placedSide === "bottom") {
|
|
2328
|
+
x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
|
|
2329
|
+
y = `${-arrowHeight}px`;
|
|
2330
|
+
} else if (placedSide === "top") {
|
|
2331
|
+
x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
|
|
2332
|
+
y = `${rects.floating.height + arrowHeight}px`;
|
|
2333
|
+
} else if (placedSide === "right") {
|
|
2334
|
+
x = `${-arrowHeight}px`;
|
|
2335
|
+
y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
|
|
2336
|
+
} else if (placedSide === "left") {
|
|
2337
|
+
x = `${rects.floating.width + arrowHeight}px`;
|
|
2338
|
+
y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
|
|
2339
|
+
}
|
|
2340
|
+
return { data: {
|
|
2341
|
+
x,
|
|
2342
|
+
y
|
|
2343
|
+
} };
|
|
2344
|
+
}
|
|
2345
|
+
});
|
|
2346
|
+
function getSideAndAlignFromPlacement(placement) {
|
|
2347
|
+
const [side, align = "center"] = placement.split("-");
|
|
2348
|
+
return [side, align];
|
|
2349
|
+
}
|
|
2350
|
+
var Root2 = Popper;
|
|
2351
|
+
var Anchor = PopperAnchor;
|
|
2352
|
+
var Content = PopperContent;
|
|
2353
|
+
var Arrow = PopperArrow;
|
|
2354
|
+
// ../../node_modules/.bun/@radix-ui+react-portal@1.1.9+a68cb332b68cb125/node_modules/@radix-ui/react-portal/dist/index.mjs
|
|
2355
|
+
var PORTAL_NAME$1 = "Portal";
|
|
2356
|
+
var Portal$1 = import_react.forwardRef((props, forwardedRef) => {
|
|
2357
|
+
const { container: containerProp, ...portalProps } = props;
|
|
2358
|
+
const [mounted, setMounted] = import_react.useState(false);
|
|
2359
|
+
useLayoutEffect2(() => setMounted(true), []);
|
|
2360
|
+
const container = containerProp || mounted && globalThis?.document?.body;
|
|
2361
|
+
return container ? import_react_dom.createPortal(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Primitive.div, {
|
|
2362
|
+
...portalProps,
|
|
2363
|
+
ref: forwardedRef
|
|
2364
|
+
}), container) : null;
|
|
2365
|
+
});
|
|
2366
|
+
Portal$1.displayName = PORTAL_NAME$1;
|
|
2367
|
+
// ../../node_modules/.bun/@radix-ui+react-presence@1.1.5+a68cb332b68cb125/node_modules/@radix-ui/react-presence/dist/index.mjs
|
|
2368
|
+
function useStateMachine(initialState, machine) {
|
|
2369
|
+
return import_react.useReducer((state, event) => {
|
|
2370
|
+
return machine[state][event] ?? state;
|
|
2371
|
+
}, initialState);
|
|
2372
|
+
}
|
|
2373
|
+
var Presence = (props) => {
|
|
2374
|
+
const { present, children } = props;
|
|
2375
|
+
const presence = usePresence(present);
|
|
2376
|
+
const child = typeof children === "function" ? children({ present: presence.isPresent }) : import_react.Children.only(children);
|
|
2377
|
+
const ref = useComposedRefs(presence.ref, getElementRef(child));
|
|
2378
|
+
return typeof children === "function" || presence.isPresent ? import_react.cloneElement(child, { ref }) : null;
|
|
2379
|
+
};
|
|
2380
|
+
Presence.displayName = "Presence";
|
|
2381
|
+
function usePresence(present) {
|
|
2382
|
+
const [node, setNode] = import_react.useState();
|
|
2383
|
+
const stylesRef = import_react.useRef(null);
|
|
2384
|
+
const prevPresentRef = import_react.useRef(present);
|
|
2385
|
+
const prevAnimationNameRef = import_react.useRef("none");
|
|
2386
|
+
const [state, send] = useStateMachine(present ? "mounted" : "unmounted", {
|
|
2387
|
+
mounted: {
|
|
2388
|
+
UNMOUNT: "unmounted",
|
|
2389
|
+
ANIMATION_OUT: "unmountSuspended"
|
|
2390
|
+
},
|
|
2391
|
+
unmountSuspended: {
|
|
2392
|
+
MOUNT: "mounted",
|
|
2393
|
+
ANIMATION_END: "unmounted"
|
|
2394
|
+
},
|
|
2395
|
+
unmounted: { MOUNT: "mounted" }
|
|
2396
|
+
});
|
|
2397
|
+
import_react.useEffect(() => {
|
|
2398
|
+
const currentAnimationName = getAnimationName(stylesRef.current);
|
|
2399
|
+
prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none";
|
|
2400
|
+
}, [state]);
|
|
2401
|
+
useLayoutEffect2(() => {
|
|
2402
|
+
const styles = stylesRef.current;
|
|
2403
|
+
const wasPresent = prevPresentRef.current;
|
|
2404
|
+
if (wasPresent !== present) {
|
|
2405
|
+
const prevAnimationName = prevAnimationNameRef.current;
|
|
2406
|
+
const currentAnimationName = getAnimationName(styles);
|
|
2407
|
+
if (present) send("MOUNT");
|
|
2408
|
+
else if (currentAnimationName === "none" || styles?.display === "none") send("UNMOUNT");
|
|
2409
|
+
else if (wasPresent && prevAnimationName !== currentAnimationName) send("ANIMATION_OUT");
|
|
2410
|
+
else send("UNMOUNT");
|
|
2411
|
+
prevPresentRef.current = present;
|
|
2412
|
+
}
|
|
2413
|
+
}, [present, send]);
|
|
2414
|
+
useLayoutEffect2(() => {
|
|
2415
|
+
if (node) {
|
|
2416
|
+
let timeoutId;
|
|
2417
|
+
const ownerWindow = node.ownerDocument.defaultView ?? window;
|
|
2418
|
+
const handleAnimationEnd = (event) => {
|
|
2419
|
+
const isCurrentAnimation = getAnimationName(stylesRef.current).includes(CSS.escape(event.animationName));
|
|
2420
|
+
if (event.target === node && isCurrentAnimation) {
|
|
2421
|
+
send("ANIMATION_END");
|
|
2422
|
+
if (!prevPresentRef.current) {
|
|
2423
|
+
const currentFillMode = node.style.animationFillMode;
|
|
2424
|
+
node.style.animationFillMode = "forwards";
|
|
2425
|
+
timeoutId = ownerWindow.setTimeout(() => {
|
|
2426
|
+
if (node.style.animationFillMode === "forwards") node.style.animationFillMode = currentFillMode;
|
|
2427
|
+
});
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2430
|
+
};
|
|
2431
|
+
const handleAnimationStart = (event) => {
|
|
2432
|
+
if (event.target === node) prevAnimationNameRef.current = getAnimationName(stylesRef.current);
|
|
2433
|
+
};
|
|
2434
|
+
node.addEventListener("animationstart", handleAnimationStart);
|
|
2435
|
+
node.addEventListener("animationcancel", handleAnimationEnd);
|
|
2436
|
+
node.addEventListener("animationend", handleAnimationEnd);
|
|
2437
|
+
return () => {
|
|
2438
|
+
ownerWindow.clearTimeout(timeoutId);
|
|
2439
|
+
node.removeEventListener("animationstart", handleAnimationStart);
|
|
2440
|
+
node.removeEventListener("animationcancel", handleAnimationEnd);
|
|
2441
|
+
node.removeEventListener("animationend", handleAnimationEnd);
|
|
2442
|
+
};
|
|
2443
|
+
} else send("ANIMATION_END");
|
|
2444
|
+
}, [node, send]);
|
|
2445
|
+
return {
|
|
2446
|
+
isPresent: ["mounted", "unmountSuspended"].includes(state),
|
|
2447
|
+
ref: import_react.useCallback((node2) => {
|
|
2448
|
+
stylesRef.current = node2 ? getComputedStyle(node2) : null;
|
|
2449
|
+
setNode(node2);
|
|
2450
|
+
}, [])
|
|
2451
|
+
};
|
|
2452
|
+
}
|
|
2453
|
+
function getAnimationName(styles) {
|
|
2454
|
+
return styles?.animationName || "none";
|
|
2455
|
+
}
|
|
2456
|
+
function getElementRef(element) {
|
|
2457
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
|
|
2458
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
2459
|
+
if (mayWarn) return element.ref;
|
|
2460
|
+
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
|
|
2461
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
2462
|
+
if (mayWarn) return element.props.ref;
|
|
2463
|
+
return element.props.ref || element.ref;
|
|
2464
|
+
}
|
|
2465
|
+
// ../../node_modules/.bun/@radix-ui+react-use-controllable-state@1.2.2+340ca8aed1dead99/node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs
|
|
2466
|
+
var useInsertionEffect = import_react[" useInsertionEffect ".trim().toString()] || useLayoutEffect2;
|
|
2467
|
+
function useControllableState({ prop, defaultProp, onChange = () => {}, caller }) {
|
|
2468
|
+
const [uncontrolledProp, setUncontrolledProp, onChangeRef] = useUncontrolledState({
|
|
2469
|
+
defaultProp,
|
|
2470
|
+
onChange
|
|
2471
|
+
});
|
|
2472
|
+
const isControlled = prop !== void 0;
|
|
2473
|
+
const value = isControlled ? prop : uncontrolledProp;
|
|
2474
|
+
{
|
|
2475
|
+
const isControlledRef = import_react.useRef(prop !== void 0);
|
|
2476
|
+
import_react.useEffect(() => {
|
|
2477
|
+
const wasControlled = isControlledRef.current;
|
|
2478
|
+
if (wasControlled !== isControlled) console.warn(`${caller} is changing from ${wasControlled ? "controlled" : "uncontrolled"} to ${isControlled ? "controlled" : "uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`);
|
|
2479
|
+
isControlledRef.current = isControlled;
|
|
2480
|
+
}, [isControlled, caller]);
|
|
2481
|
+
}
|
|
2482
|
+
return [value, import_react.useCallback((nextValue) => {
|
|
2483
|
+
if (isControlled) {
|
|
2484
|
+
const value2 = isFunction(nextValue) ? nextValue(prop) : nextValue;
|
|
2485
|
+
if (value2 !== prop) onChangeRef.current?.(value2);
|
|
2486
|
+
} else setUncontrolledProp(nextValue);
|
|
2487
|
+
}, [
|
|
2488
|
+
isControlled,
|
|
2489
|
+
prop,
|
|
2490
|
+
setUncontrolledProp,
|
|
2491
|
+
onChangeRef
|
|
2492
|
+
])];
|
|
2493
|
+
}
|
|
2494
|
+
function useUncontrolledState({ defaultProp, onChange }) {
|
|
2495
|
+
const [value, setValue] = import_react.useState(defaultProp);
|
|
2496
|
+
const prevValueRef = import_react.useRef(value);
|
|
2497
|
+
const onChangeRef = import_react.useRef(onChange);
|
|
2498
|
+
useInsertionEffect(() => {
|
|
2499
|
+
onChangeRef.current = onChange;
|
|
2500
|
+
}, [onChange]);
|
|
2501
|
+
import_react.useEffect(() => {
|
|
2502
|
+
if (prevValueRef.current !== value) {
|
|
2503
|
+
onChangeRef.current?.(value);
|
|
2504
|
+
prevValueRef.current = value;
|
|
2505
|
+
}
|
|
2506
|
+
}, [value, prevValueRef]);
|
|
2507
|
+
return [
|
|
2508
|
+
value,
|
|
2509
|
+
setValue,
|
|
2510
|
+
onChangeRef
|
|
2511
|
+
];
|
|
2512
|
+
}
|
|
2513
|
+
function isFunction(value) {
|
|
2514
|
+
return typeof value === "function";
|
|
2515
|
+
}
|
|
2516
|
+
// ../../node_modules/.bun/@radix-ui+react-visually-hidden@1.2.3+a68cb332b68cb125/node_modules/@radix-ui/react-visually-hidden/dist/index.mjs
|
|
2517
|
+
var VISUALLY_HIDDEN_STYLES = Object.freeze({
|
|
2518
|
+
position: "absolute",
|
|
2519
|
+
border: 0,
|
|
2520
|
+
width: 1,
|
|
2521
|
+
height: 1,
|
|
2522
|
+
padding: 0,
|
|
2523
|
+
margin: -1,
|
|
2524
|
+
overflow: "hidden",
|
|
2525
|
+
clip: "rect(0, 0, 0, 0)",
|
|
2526
|
+
whiteSpace: "nowrap",
|
|
2527
|
+
wordWrap: "normal"
|
|
2528
|
+
});
|
|
2529
|
+
var NAME = "VisuallyHidden";
|
|
2530
|
+
var VisuallyHidden = import_react.forwardRef((props, forwardedRef) => {
|
|
2531
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Primitive.span, {
|
|
2532
|
+
...props,
|
|
2533
|
+
ref: forwardedRef,
|
|
2534
|
+
style: {
|
|
2535
|
+
...VISUALLY_HIDDEN_STYLES,
|
|
2536
|
+
...props.style
|
|
2537
|
+
}
|
|
2538
|
+
});
|
|
2539
|
+
});
|
|
2540
|
+
VisuallyHidden.displayName = NAME;
|
|
2541
|
+
var Root = VisuallyHidden;
|
|
2542
|
+
// ../../node_modules/.bun/@radix-ui+react-tooltip@1.2.8+a68cb332b68cb125/node_modules/@radix-ui/react-tooltip/dist/index.mjs
|
|
2543
|
+
var [createTooltipContext, createTooltipScope] = createContextScope("Tooltip", [createPopperScope]);
|
|
2544
|
+
var usePopperScope = createPopperScope();
|
|
2545
|
+
var PROVIDER_NAME = "TooltipProvider";
|
|
2546
|
+
var DEFAULT_DELAY_DURATION = 700;
|
|
2547
|
+
var TOOLTIP_OPEN = "tooltip.open";
|
|
2548
|
+
var [TooltipProviderContextProvider, useTooltipProviderContext] = createTooltipContext(PROVIDER_NAME);
|
|
2549
|
+
var TooltipProvider = (props) => {
|
|
2550
|
+
const { __scopeTooltip, delayDuration = DEFAULT_DELAY_DURATION, skipDelayDuration = 300, disableHoverableContent = false, children } = props;
|
|
2551
|
+
const isOpenDelayedRef = import_react.useRef(true);
|
|
2552
|
+
const isPointerInTransitRef = import_react.useRef(false);
|
|
2553
|
+
const skipDelayTimerRef = import_react.useRef(0);
|
|
2554
|
+
import_react.useEffect(() => {
|
|
2555
|
+
const skipDelayTimer = skipDelayTimerRef.current;
|
|
2556
|
+
return () => window.clearTimeout(skipDelayTimer);
|
|
2557
|
+
}, []);
|
|
2558
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TooltipProviderContextProvider, {
|
|
2559
|
+
scope: __scopeTooltip,
|
|
2560
|
+
isOpenDelayedRef,
|
|
2561
|
+
delayDuration,
|
|
2562
|
+
onOpen: import_react.useCallback(() => {
|
|
2563
|
+
window.clearTimeout(skipDelayTimerRef.current);
|
|
2564
|
+
isOpenDelayedRef.current = false;
|
|
2565
|
+
}, []),
|
|
2566
|
+
onClose: import_react.useCallback(() => {
|
|
2567
|
+
window.clearTimeout(skipDelayTimerRef.current);
|
|
2568
|
+
skipDelayTimerRef.current = window.setTimeout(() => isOpenDelayedRef.current = true, skipDelayDuration);
|
|
2569
|
+
}, [skipDelayDuration]),
|
|
2570
|
+
isPointerInTransitRef,
|
|
2571
|
+
onPointerInTransitChange: import_react.useCallback((inTransit) => {
|
|
2572
|
+
isPointerInTransitRef.current = inTransit;
|
|
2573
|
+
}, []),
|
|
2574
|
+
disableHoverableContent,
|
|
2575
|
+
children
|
|
2576
|
+
});
|
|
2577
|
+
};
|
|
2578
|
+
TooltipProvider.displayName = PROVIDER_NAME;
|
|
2579
|
+
var TOOLTIP_NAME = "Tooltip";
|
|
2580
|
+
var [TooltipContextProvider, useTooltipContext] = createTooltipContext(TOOLTIP_NAME);
|
|
2581
|
+
var Tooltip = (props) => {
|
|
2582
|
+
const { __scopeTooltip, children, open: openProp, defaultOpen, onOpenChange, disableHoverableContent: disableHoverableContentProp, delayDuration: delayDurationProp } = props;
|
|
2583
|
+
const providerContext = useTooltipProviderContext(TOOLTIP_NAME, props.__scopeTooltip);
|
|
2584
|
+
const popperScope = usePopperScope(__scopeTooltip);
|
|
2585
|
+
const [trigger, setTrigger] = import_react.useState(null);
|
|
2586
|
+
const contentId = useId();
|
|
2587
|
+
const openTimerRef = import_react.useRef(0);
|
|
2588
|
+
const disableHoverableContent = disableHoverableContentProp ?? providerContext.disableHoverableContent;
|
|
2589
|
+
const delayDuration = delayDurationProp ?? providerContext.delayDuration;
|
|
2590
|
+
const wasOpenDelayedRef = import_react.useRef(false);
|
|
2591
|
+
const [open, setOpen] = useControllableState({
|
|
2592
|
+
prop: openProp,
|
|
2593
|
+
defaultProp: defaultOpen ?? false,
|
|
2594
|
+
onChange: (open2) => {
|
|
2595
|
+
if (open2) {
|
|
2596
|
+
providerContext.onOpen();
|
|
2597
|
+
document.dispatchEvent(new CustomEvent(TOOLTIP_OPEN));
|
|
2598
|
+
} else providerContext.onClose();
|
|
2599
|
+
onOpenChange?.(open2);
|
|
2600
|
+
},
|
|
2601
|
+
caller: TOOLTIP_NAME
|
|
2602
|
+
});
|
|
2603
|
+
const stateAttribute = import_react.useMemo(() => {
|
|
2604
|
+
return open ? wasOpenDelayedRef.current ? "delayed-open" : "instant-open" : "closed";
|
|
2605
|
+
}, [open]);
|
|
2606
|
+
const handleOpen = import_react.useCallback(() => {
|
|
2607
|
+
window.clearTimeout(openTimerRef.current);
|
|
2608
|
+
openTimerRef.current = 0;
|
|
2609
|
+
wasOpenDelayedRef.current = false;
|
|
2610
|
+
setOpen(true);
|
|
2611
|
+
}, [setOpen]);
|
|
2612
|
+
const handleClose = import_react.useCallback(() => {
|
|
2613
|
+
window.clearTimeout(openTimerRef.current);
|
|
2614
|
+
openTimerRef.current = 0;
|
|
2615
|
+
setOpen(false);
|
|
2616
|
+
}, [setOpen]);
|
|
2617
|
+
const handleDelayedOpen = import_react.useCallback(() => {
|
|
2618
|
+
window.clearTimeout(openTimerRef.current);
|
|
2619
|
+
openTimerRef.current = window.setTimeout(() => {
|
|
2620
|
+
wasOpenDelayedRef.current = true;
|
|
2621
|
+
setOpen(true);
|
|
2622
|
+
openTimerRef.current = 0;
|
|
2623
|
+
}, delayDuration);
|
|
2624
|
+
}, [delayDuration, setOpen]);
|
|
2625
|
+
import_react.useEffect(() => {
|
|
2626
|
+
return () => {
|
|
2627
|
+
if (openTimerRef.current) {
|
|
2628
|
+
window.clearTimeout(openTimerRef.current);
|
|
2629
|
+
openTimerRef.current = 0;
|
|
2630
|
+
}
|
|
2631
|
+
};
|
|
2632
|
+
}, []);
|
|
2633
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Root2, {
|
|
2634
|
+
...popperScope,
|
|
2635
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TooltipContextProvider, {
|
|
2636
|
+
scope: __scopeTooltip,
|
|
2637
|
+
contentId,
|
|
2638
|
+
open,
|
|
2639
|
+
stateAttribute,
|
|
2640
|
+
trigger,
|
|
2641
|
+
onTriggerChange: setTrigger,
|
|
2642
|
+
onTriggerEnter: import_react.useCallback(() => {
|
|
2643
|
+
if (providerContext.isOpenDelayedRef.current) handleDelayedOpen();
|
|
2644
|
+
else handleOpen();
|
|
2645
|
+
}, [
|
|
2646
|
+
providerContext.isOpenDelayedRef,
|
|
2647
|
+
handleDelayedOpen,
|
|
2648
|
+
handleOpen
|
|
2649
|
+
]),
|
|
2650
|
+
onTriggerLeave: import_react.useCallback(() => {
|
|
2651
|
+
if (disableHoverableContent) handleClose();
|
|
2652
|
+
else {
|
|
2653
|
+
window.clearTimeout(openTimerRef.current);
|
|
2654
|
+
openTimerRef.current = 0;
|
|
2655
|
+
}
|
|
2656
|
+
}, [handleClose, disableHoverableContent]),
|
|
2657
|
+
onOpen: handleOpen,
|
|
2658
|
+
onClose: handleClose,
|
|
2659
|
+
disableHoverableContent,
|
|
2660
|
+
children
|
|
2661
|
+
})
|
|
2662
|
+
});
|
|
2663
|
+
};
|
|
2664
|
+
Tooltip.displayName = TOOLTIP_NAME;
|
|
2665
|
+
var TRIGGER_NAME = "TooltipTrigger";
|
|
2666
|
+
var TooltipTrigger = import_react.forwardRef((props, forwardedRef) => {
|
|
2667
|
+
const { __scopeTooltip, ...triggerProps } = props;
|
|
2668
|
+
const context = useTooltipContext(TRIGGER_NAME, __scopeTooltip);
|
|
2669
|
+
const providerContext = useTooltipProviderContext(TRIGGER_NAME, __scopeTooltip);
|
|
2670
|
+
const popperScope = usePopperScope(__scopeTooltip);
|
|
2671
|
+
const composedRefs = useComposedRefs(forwardedRef, import_react.useRef(null), context.onTriggerChange);
|
|
2672
|
+
const isPointerDownRef = import_react.useRef(false);
|
|
2673
|
+
const hasPointerMoveOpenedRef = import_react.useRef(false);
|
|
2674
|
+
const handlePointerUp = import_react.useCallback(() => isPointerDownRef.current = false, []);
|
|
2675
|
+
import_react.useEffect(() => {
|
|
2676
|
+
return () => document.removeEventListener("pointerup", handlePointerUp);
|
|
2677
|
+
}, [handlePointerUp]);
|
|
2678
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Anchor, {
|
|
2679
|
+
asChild: true,
|
|
2680
|
+
...popperScope,
|
|
2681
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Primitive.button, {
|
|
2682
|
+
"aria-describedby": context.open ? context.contentId : void 0,
|
|
2683
|
+
"data-state": context.stateAttribute,
|
|
2684
|
+
...triggerProps,
|
|
2685
|
+
ref: composedRefs,
|
|
2686
|
+
onPointerMove: composeEventHandlers(props.onPointerMove, (event) => {
|
|
2687
|
+
if (event.pointerType === "touch") return;
|
|
2688
|
+
if (!hasPointerMoveOpenedRef.current && !providerContext.isPointerInTransitRef.current) {
|
|
2689
|
+
context.onTriggerEnter();
|
|
2690
|
+
hasPointerMoveOpenedRef.current = true;
|
|
2691
|
+
}
|
|
2692
|
+
}),
|
|
2693
|
+
onPointerLeave: composeEventHandlers(props.onPointerLeave, () => {
|
|
2694
|
+
context.onTriggerLeave();
|
|
2695
|
+
hasPointerMoveOpenedRef.current = false;
|
|
2696
|
+
}),
|
|
2697
|
+
onPointerDown: composeEventHandlers(props.onPointerDown, () => {
|
|
2698
|
+
if (context.open) context.onClose();
|
|
2699
|
+
isPointerDownRef.current = true;
|
|
2700
|
+
document.addEventListener("pointerup", handlePointerUp, { once: true });
|
|
2701
|
+
}),
|
|
2702
|
+
onFocus: composeEventHandlers(props.onFocus, () => {
|
|
2703
|
+
if (!isPointerDownRef.current) context.onOpen();
|
|
2704
|
+
}),
|
|
2705
|
+
onBlur: composeEventHandlers(props.onBlur, context.onClose),
|
|
2706
|
+
onClick: composeEventHandlers(props.onClick, context.onClose)
|
|
2707
|
+
})
|
|
2708
|
+
});
|
|
2709
|
+
});
|
|
2710
|
+
TooltipTrigger.displayName = TRIGGER_NAME;
|
|
2711
|
+
var PORTAL_NAME = "TooltipPortal";
|
|
2712
|
+
var [PortalProvider, usePortalContext] = createTooltipContext(PORTAL_NAME, { forceMount: void 0 });
|
|
2713
|
+
var TooltipPortal = (props) => {
|
|
2714
|
+
const { __scopeTooltip, forceMount, children, container } = props;
|
|
2715
|
+
const context = useTooltipContext(PORTAL_NAME, __scopeTooltip);
|
|
2716
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PortalProvider, {
|
|
2717
|
+
scope: __scopeTooltip,
|
|
2718
|
+
forceMount,
|
|
2719
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Presence, {
|
|
2720
|
+
present: forceMount || context.open,
|
|
2721
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Portal$1, {
|
|
2722
|
+
asChild: true,
|
|
2723
|
+
container,
|
|
2724
|
+
children
|
|
2725
|
+
})
|
|
2726
|
+
})
|
|
2727
|
+
});
|
|
2728
|
+
};
|
|
2729
|
+
TooltipPortal.displayName = PORTAL_NAME;
|
|
2730
|
+
var CONTENT_NAME = "TooltipContent";
|
|
2731
|
+
var TooltipContent = import_react.forwardRef((props, forwardedRef) => {
|
|
2732
|
+
const portalContext = usePortalContext(CONTENT_NAME, props.__scopeTooltip);
|
|
2733
|
+
const { forceMount = portalContext.forceMount, side = "top", ...contentProps } = props;
|
|
2734
|
+
const context = useTooltipContext(CONTENT_NAME, props.__scopeTooltip);
|
|
2735
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Presence, {
|
|
2736
|
+
present: forceMount || context.open,
|
|
2737
|
+
children: context.disableHoverableContent ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TooltipContentImpl, {
|
|
2738
|
+
side,
|
|
2739
|
+
...contentProps,
|
|
2740
|
+
ref: forwardedRef
|
|
2741
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TooltipContentHoverable, {
|
|
2742
|
+
side,
|
|
2743
|
+
...contentProps,
|
|
2744
|
+
ref: forwardedRef
|
|
2745
|
+
})
|
|
2746
|
+
});
|
|
2747
|
+
});
|
|
2748
|
+
var TooltipContentHoverable = import_react.forwardRef((props, forwardedRef) => {
|
|
2749
|
+
const context = useTooltipContext(CONTENT_NAME, props.__scopeTooltip);
|
|
2750
|
+
const providerContext = useTooltipProviderContext(CONTENT_NAME, props.__scopeTooltip);
|
|
2751
|
+
const ref = import_react.useRef(null);
|
|
2752
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
2753
|
+
const [pointerGraceArea, setPointerGraceArea] = import_react.useState(null);
|
|
2754
|
+
const { trigger, onClose } = context;
|
|
2755
|
+
const content = ref.current;
|
|
2756
|
+
const { onPointerInTransitChange } = providerContext;
|
|
2757
|
+
const handleRemoveGraceArea = import_react.useCallback(() => {
|
|
2758
|
+
setPointerGraceArea(null);
|
|
2759
|
+
onPointerInTransitChange(false);
|
|
2760
|
+
}, [onPointerInTransitChange]);
|
|
2761
|
+
const handleCreateGraceArea = import_react.useCallback((event, hoverTarget) => {
|
|
2762
|
+
const currentTarget = event.currentTarget;
|
|
2763
|
+
const exitPoint = {
|
|
2764
|
+
x: event.clientX,
|
|
2765
|
+
y: event.clientY
|
|
2766
|
+
};
|
|
2767
|
+
const paddedExitPoints = getPaddedExitPoints(exitPoint, getExitSideFromRect(exitPoint, currentTarget.getBoundingClientRect()));
|
|
2768
|
+
const hoverTargetPoints = getPointsFromRect(hoverTarget.getBoundingClientRect());
|
|
2769
|
+
const graceArea = getHull([...paddedExitPoints, ...hoverTargetPoints]);
|
|
2770
|
+
setPointerGraceArea(graceArea);
|
|
2771
|
+
onPointerInTransitChange(true);
|
|
2772
|
+
}, [onPointerInTransitChange]);
|
|
2773
|
+
import_react.useEffect(() => {
|
|
2774
|
+
return () => handleRemoveGraceArea();
|
|
2775
|
+
}, [handleRemoveGraceArea]);
|
|
2776
|
+
import_react.useEffect(() => {
|
|
2777
|
+
if (trigger && content) {
|
|
2778
|
+
const handleTriggerLeave = (event) => handleCreateGraceArea(event, content);
|
|
2779
|
+
const handleContentLeave = (event) => handleCreateGraceArea(event, trigger);
|
|
2780
|
+
trigger.addEventListener("pointerleave", handleTriggerLeave);
|
|
2781
|
+
content.addEventListener("pointerleave", handleContentLeave);
|
|
2782
|
+
return () => {
|
|
2783
|
+
trigger.removeEventListener("pointerleave", handleTriggerLeave);
|
|
2784
|
+
content.removeEventListener("pointerleave", handleContentLeave);
|
|
2785
|
+
};
|
|
2786
|
+
}
|
|
2787
|
+
}, [
|
|
2788
|
+
trigger,
|
|
2789
|
+
content,
|
|
2790
|
+
handleCreateGraceArea,
|
|
2791
|
+
handleRemoveGraceArea
|
|
2792
|
+
]);
|
|
2793
|
+
import_react.useEffect(() => {
|
|
2794
|
+
if (pointerGraceArea) {
|
|
2795
|
+
const handleTrackPointerGrace = (event) => {
|
|
2796
|
+
const target = event.target;
|
|
2797
|
+
const pointerPosition = {
|
|
2798
|
+
x: event.clientX,
|
|
2799
|
+
y: event.clientY
|
|
2800
|
+
};
|
|
2801
|
+
const hasEnteredTarget = trigger?.contains(target) || content?.contains(target);
|
|
2802
|
+
const isPointerOutsideGraceArea = !isPointInPolygon(pointerPosition, pointerGraceArea);
|
|
2803
|
+
if (hasEnteredTarget) handleRemoveGraceArea();
|
|
2804
|
+
else if (isPointerOutsideGraceArea) {
|
|
2805
|
+
handleRemoveGraceArea();
|
|
2806
|
+
onClose();
|
|
2807
|
+
}
|
|
2808
|
+
};
|
|
2809
|
+
document.addEventListener("pointermove", handleTrackPointerGrace);
|
|
2810
|
+
return () => document.removeEventListener("pointermove", handleTrackPointerGrace);
|
|
2811
|
+
}
|
|
2812
|
+
}, [
|
|
2813
|
+
trigger,
|
|
2814
|
+
content,
|
|
2815
|
+
pointerGraceArea,
|
|
2816
|
+
onClose,
|
|
2817
|
+
handleRemoveGraceArea
|
|
2818
|
+
]);
|
|
2819
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TooltipContentImpl, {
|
|
2820
|
+
...props,
|
|
2821
|
+
ref: composedRefs
|
|
2822
|
+
});
|
|
2823
|
+
});
|
|
2824
|
+
var [VisuallyHiddenContentContextProvider, useVisuallyHiddenContentContext] = createTooltipContext(TOOLTIP_NAME, { isInside: false });
|
|
2825
|
+
var Slottable = /* @__PURE__ */ createSlottable("TooltipContent");
|
|
2826
|
+
var TooltipContentImpl = import_react.forwardRef((props, forwardedRef) => {
|
|
2827
|
+
const { __scopeTooltip, children, "aria-label": ariaLabel, onEscapeKeyDown, onPointerDownOutside, ...contentProps } = props;
|
|
2828
|
+
const context = useTooltipContext(CONTENT_NAME, __scopeTooltip);
|
|
2829
|
+
const popperScope = usePopperScope(__scopeTooltip);
|
|
2830
|
+
const { onClose } = context;
|
|
2831
|
+
import_react.useEffect(() => {
|
|
2832
|
+
document.addEventListener(TOOLTIP_OPEN, onClose);
|
|
2833
|
+
return () => document.removeEventListener(TOOLTIP_OPEN, onClose);
|
|
2834
|
+
}, [onClose]);
|
|
2835
|
+
import_react.useEffect(() => {
|
|
2836
|
+
if (context.trigger) {
|
|
2837
|
+
const handleScroll = (event) => {
|
|
2838
|
+
if (event.target?.contains(context.trigger)) onClose();
|
|
2839
|
+
};
|
|
2840
|
+
window.addEventListener("scroll", handleScroll, { capture: true });
|
|
2841
|
+
return () => window.removeEventListener("scroll", handleScroll, { capture: true });
|
|
2842
|
+
}
|
|
2843
|
+
}, [context.trigger, onClose]);
|
|
2844
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DismissableLayer, {
|
|
2845
|
+
asChild: true,
|
|
2846
|
+
disableOutsidePointerEvents: false,
|
|
2847
|
+
onEscapeKeyDown,
|
|
2848
|
+
onPointerDownOutside,
|
|
2849
|
+
onFocusOutside: (event) => event.preventDefault(),
|
|
2850
|
+
onDismiss: onClose,
|
|
2851
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Content, {
|
|
2852
|
+
"data-state": context.stateAttribute,
|
|
2853
|
+
...popperScope,
|
|
2854
|
+
...contentProps,
|
|
2855
|
+
ref: forwardedRef,
|
|
2856
|
+
style: {
|
|
2857
|
+
...contentProps.style,
|
|
2858
|
+
"--radix-tooltip-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
2859
|
+
"--radix-tooltip-content-available-width": "var(--radix-popper-available-width)",
|
|
2860
|
+
"--radix-tooltip-content-available-height": "var(--radix-popper-available-height)",
|
|
2861
|
+
"--radix-tooltip-trigger-width": "var(--radix-popper-anchor-width)",
|
|
2862
|
+
"--radix-tooltip-trigger-height": "var(--radix-popper-anchor-height)"
|
|
2863
|
+
},
|
|
2864
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Slottable, { children }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(VisuallyHiddenContentContextProvider, {
|
|
2865
|
+
scope: __scopeTooltip,
|
|
2866
|
+
isInside: true,
|
|
2867
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Root, {
|
|
2868
|
+
id: context.contentId,
|
|
2869
|
+
role: "tooltip",
|
|
2870
|
+
children: ariaLabel || children
|
|
2871
|
+
})
|
|
2872
|
+
})]
|
|
2873
|
+
})
|
|
2874
|
+
});
|
|
2875
|
+
});
|
|
2876
|
+
TooltipContent.displayName = CONTENT_NAME;
|
|
2877
|
+
var ARROW_NAME = "TooltipArrow";
|
|
2878
|
+
var TooltipArrow = import_react.forwardRef((props, forwardedRef) => {
|
|
2879
|
+
const { __scopeTooltip, ...arrowProps } = props;
|
|
2880
|
+
const popperScope = usePopperScope(__scopeTooltip);
|
|
2881
|
+
return useVisuallyHiddenContentContext(ARROW_NAME, __scopeTooltip).isInside ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Arrow, {
|
|
2882
|
+
...popperScope,
|
|
2883
|
+
...arrowProps,
|
|
2884
|
+
ref: forwardedRef
|
|
2885
|
+
});
|
|
2886
|
+
});
|
|
2887
|
+
TooltipArrow.displayName = ARROW_NAME;
|
|
2888
|
+
function getExitSideFromRect(point, rect) {
|
|
2889
|
+
const top = Math.abs(rect.top - point.y);
|
|
2890
|
+
const bottom = Math.abs(rect.bottom - point.y);
|
|
2891
|
+
const right = Math.abs(rect.right - point.x);
|
|
2892
|
+
const left = Math.abs(rect.left - point.x);
|
|
2893
|
+
switch (Math.min(top, bottom, right, left)) {
|
|
2894
|
+
case left: return "left";
|
|
2895
|
+
case right: return "right";
|
|
2896
|
+
case top: return "top";
|
|
2897
|
+
case bottom: return "bottom";
|
|
2898
|
+
default: throw new Error("unreachable");
|
|
2899
|
+
}
|
|
2900
|
+
}
|
|
2901
|
+
function getPaddedExitPoints(exitPoint, exitSide, padding = 5) {
|
|
2902
|
+
const paddedExitPoints = [];
|
|
2903
|
+
switch (exitSide) {
|
|
2904
|
+
case "top":
|
|
2905
|
+
paddedExitPoints.push({
|
|
2906
|
+
x: exitPoint.x - padding,
|
|
2907
|
+
y: exitPoint.y + padding
|
|
2908
|
+
}, {
|
|
2909
|
+
x: exitPoint.x + padding,
|
|
2910
|
+
y: exitPoint.y + padding
|
|
2911
|
+
});
|
|
2912
|
+
break;
|
|
2913
|
+
case "bottom":
|
|
2914
|
+
paddedExitPoints.push({
|
|
2915
|
+
x: exitPoint.x - padding,
|
|
2916
|
+
y: exitPoint.y - padding
|
|
2917
|
+
}, {
|
|
2918
|
+
x: exitPoint.x + padding,
|
|
2919
|
+
y: exitPoint.y - padding
|
|
2920
|
+
});
|
|
2921
|
+
break;
|
|
2922
|
+
case "left":
|
|
2923
|
+
paddedExitPoints.push({
|
|
2924
|
+
x: exitPoint.x + padding,
|
|
2925
|
+
y: exitPoint.y - padding
|
|
2926
|
+
}, {
|
|
2927
|
+
x: exitPoint.x + padding,
|
|
2928
|
+
y: exitPoint.y + padding
|
|
2929
|
+
});
|
|
2930
|
+
break;
|
|
2931
|
+
case "right": paddedExitPoints.push({
|
|
2932
|
+
x: exitPoint.x - padding,
|
|
2933
|
+
y: exitPoint.y - padding
|
|
2934
|
+
}, {
|
|
2935
|
+
x: exitPoint.x - padding,
|
|
2936
|
+
y: exitPoint.y + padding
|
|
2937
|
+
});
|
|
2938
|
+
}
|
|
2939
|
+
return paddedExitPoints;
|
|
2940
|
+
}
|
|
2941
|
+
function getPointsFromRect(rect) {
|
|
2942
|
+
const { top, right, bottom, left } = rect;
|
|
2943
|
+
return [
|
|
2944
|
+
{
|
|
2945
|
+
x: left,
|
|
2946
|
+
y: top
|
|
2947
|
+
},
|
|
2948
|
+
{
|
|
2949
|
+
x: right,
|
|
2950
|
+
y: top
|
|
2951
|
+
},
|
|
2952
|
+
{
|
|
2953
|
+
x: right,
|
|
2954
|
+
y: bottom
|
|
2955
|
+
},
|
|
2956
|
+
{
|
|
2957
|
+
x: left,
|
|
2958
|
+
y: bottom
|
|
2959
|
+
}
|
|
2960
|
+
];
|
|
2961
|
+
}
|
|
2962
|
+
function isPointInPolygon(point, polygon) {
|
|
2963
|
+
const { x, y } = point;
|
|
2964
|
+
let inside = false;
|
|
2965
|
+
for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
|
|
2966
|
+
const ii = polygon[i];
|
|
2967
|
+
const jj = polygon[j];
|
|
2968
|
+
const xi = ii.x;
|
|
2969
|
+
const yi = ii.y;
|
|
2970
|
+
const xj = jj.x;
|
|
2971
|
+
const yj = jj.y;
|
|
2972
|
+
if (yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi) inside = !inside;
|
|
2973
|
+
}
|
|
2974
|
+
return inside;
|
|
2975
|
+
}
|
|
2976
|
+
function getHull(points) {
|
|
2977
|
+
const newPoints = points.slice();
|
|
2978
|
+
newPoints.sort((a, b) => {
|
|
2979
|
+
if (a.x < b.x) return -1;
|
|
2980
|
+
else if (a.x > b.x) return 1;
|
|
2981
|
+
else if (a.y < b.y) return -1;
|
|
2982
|
+
else if (a.y > b.y) return 1;
|
|
2983
|
+
else return 0;
|
|
2984
|
+
});
|
|
2985
|
+
return getHullPresorted(newPoints);
|
|
2986
|
+
}
|
|
2987
|
+
function getHullPresorted(points) {
|
|
2988
|
+
if (points.length <= 1) return points.slice();
|
|
2989
|
+
const upperHull = [];
|
|
2990
|
+
for (let i = 0; i < points.length; i++) {
|
|
2991
|
+
const p = points[i];
|
|
2992
|
+
while (upperHull.length >= 2) {
|
|
2993
|
+
const q = upperHull[upperHull.length - 1];
|
|
2994
|
+
const r = upperHull[upperHull.length - 2];
|
|
2995
|
+
if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x)) upperHull.pop();
|
|
2996
|
+
else break;
|
|
2997
|
+
}
|
|
2998
|
+
upperHull.push(p);
|
|
2999
|
+
}
|
|
3000
|
+
upperHull.pop();
|
|
3001
|
+
const lowerHull = [];
|
|
3002
|
+
for (let i = points.length - 1; i >= 0; i--) {
|
|
3003
|
+
const p = points[i];
|
|
3004
|
+
while (lowerHull.length >= 2) {
|
|
3005
|
+
const q = lowerHull[lowerHull.length - 1];
|
|
3006
|
+
const r = lowerHull[lowerHull.length - 2];
|
|
3007
|
+
if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x)) lowerHull.pop();
|
|
3008
|
+
else break;
|
|
3009
|
+
}
|
|
3010
|
+
lowerHull.push(p);
|
|
3011
|
+
}
|
|
3012
|
+
lowerHull.pop();
|
|
3013
|
+
if (upperHull.length === 1 && lowerHull.length === 1 && upperHull[0].x === lowerHull[0].x && upperHull[0].y === lowerHull[0].y) return upperHull;
|
|
3014
|
+
else return upperHull.concat(lowerHull);
|
|
3015
|
+
}
|
|
3016
|
+
var Provider = TooltipProvider;
|
|
3017
|
+
var Root3 = Tooltip;
|
|
3018
|
+
var Trigger = TooltipTrigger;
|
|
3019
|
+
var Portal = TooltipPortal;
|
|
3020
|
+
var Content2 = TooltipContent;
|
|
3021
|
+
var Arrow2 = TooltipArrow;
|
|
3022
|
+
// ../../node_modules/.bun/sonner@2.0.7+dfc90389513bb65c/node_modules/sonner/dist/index.mjs
|
|
3023
|
+
function __insertCSS(code) {
|
|
3024
|
+
if (!code || typeof document == "undefined") return;
|
|
3025
|
+
let head = document.head || document.getElementsByTagName("head")[0];
|
|
3026
|
+
let style = document.createElement("style");
|
|
3027
|
+
style.type = "text/css";
|
|
3028
|
+
head.appendChild(style);
|
|
3029
|
+
style.styleSheet ? style.styleSheet.cssText = code : style.appendChild(document.createTextNode(code));
|
|
3030
|
+
}
|
|
3031
|
+
var getAsset = (type) => {
|
|
3032
|
+
switch (type) {
|
|
3033
|
+
case "success": return SuccessIcon;
|
|
3034
|
+
case "info": return InfoIcon;
|
|
3035
|
+
case "warning": return WarningIcon;
|
|
3036
|
+
case "error": return ErrorIcon;
|
|
3037
|
+
default: return null;
|
|
3038
|
+
}
|
|
3039
|
+
};
|
|
3040
|
+
var bars = Array(12).fill(0);
|
|
3041
|
+
var Loader = ({ visible, className }) => {
|
|
3042
|
+
return /*#__PURE__*/ import_react.createElement("div", {
|
|
3043
|
+
className: ["sonner-loading-wrapper", className].filter(Boolean).join(" "),
|
|
3044
|
+
"data-visible": visible
|
|
3045
|
+
}, /*#__PURE__*/ import_react.createElement("div", { className: "sonner-spinner" }, bars.map((_, i) => /*#__PURE__*/ import_react.createElement("div", {
|
|
3046
|
+
className: "sonner-loading-bar",
|
|
3047
|
+
key: `spinner-bar-${i}`
|
|
3048
|
+
}))));
|
|
3049
|
+
};
|
|
3050
|
+
var SuccessIcon = /*#__PURE__*/ import_react.createElement("svg", {
|
|
3051
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3052
|
+
viewBox: "0 0 20 20",
|
|
3053
|
+
fill: "currentColor",
|
|
3054
|
+
height: "20",
|
|
3055
|
+
width: "20"
|
|
3056
|
+
}, /*#__PURE__*/ import_react.createElement("path", {
|
|
3057
|
+
fillRule: "evenodd",
|
|
3058
|
+
d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",
|
|
3059
|
+
clipRule: "evenodd"
|
|
3060
|
+
}));
|
|
3061
|
+
var WarningIcon = /*#__PURE__*/ import_react.createElement("svg", {
|
|
3062
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3063
|
+
viewBox: "0 0 24 24",
|
|
3064
|
+
fill: "currentColor",
|
|
3065
|
+
height: "20",
|
|
3066
|
+
width: "20"
|
|
3067
|
+
}, /*#__PURE__*/ import_react.createElement("path", {
|
|
3068
|
+
fillRule: "evenodd",
|
|
3069
|
+
d: "M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",
|
|
3070
|
+
clipRule: "evenodd"
|
|
3071
|
+
}));
|
|
3072
|
+
var InfoIcon = /*#__PURE__*/ import_react.createElement("svg", {
|
|
3073
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3074
|
+
viewBox: "0 0 20 20",
|
|
3075
|
+
fill: "currentColor",
|
|
3076
|
+
height: "20",
|
|
3077
|
+
width: "20"
|
|
3078
|
+
}, /*#__PURE__*/ import_react.createElement("path", {
|
|
3079
|
+
fillRule: "evenodd",
|
|
3080
|
+
d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",
|
|
3081
|
+
clipRule: "evenodd"
|
|
3082
|
+
}));
|
|
3083
|
+
var ErrorIcon = /*#__PURE__*/ import_react.createElement("svg", {
|
|
3084
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3085
|
+
viewBox: "0 0 20 20",
|
|
3086
|
+
fill: "currentColor",
|
|
3087
|
+
height: "20",
|
|
3088
|
+
width: "20"
|
|
3089
|
+
}, /*#__PURE__*/ import_react.createElement("path", {
|
|
3090
|
+
fillRule: "evenodd",
|
|
3091
|
+
d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",
|
|
3092
|
+
clipRule: "evenodd"
|
|
3093
|
+
}));
|
|
3094
|
+
var CloseIcon = /*#__PURE__*/ import_react.createElement("svg", {
|
|
3095
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3096
|
+
width: "12",
|
|
3097
|
+
height: "12",
|
|
3098
|
+
viewBox: "0 0 24 24",
|
|
3099
|
+
fill: "none",
|
|
3100
|
+
stroke: "currentColor",
|
|
3101
|
+
strokeWidth: "1.5",
|
|
3102
|
+
strokeLinecap: "round",
|
|
3103
|
+
strokeLinejoin: "round"
|
|
3104
|
+
}, /*#__PURE__*/ import_react.createElement("line", {
|
|
3105
|
+
x1: "18",
|
|
3106
|
+
y1: "6",
|
|
3107
|
+
x2: "6",
|
|
3108
|
+
y2: "18"
|
|
3109
|
+
}), /*#__PURE__*/ import_react.createElement("line", {
|
|
3110
|
+
x1: "6",
|
|
3111
|
+
y1: "6",
|
|
3112
|
+
x2: "18",
|
|
3113
|
+
y2: "18"
|
|
3114
|
+
}));
|
|
3115
|
+
var useIsDocumentHidden = () => {
|
|
3116
|
+
const [isDocumentHidden, setIsDocumentHidden] = import_react.useState(document.hidden);
|
|
3117
|
+
import_react.useEffect(() => {
|
|
3118
|
+
const callback = () => {
|
|
3119
|
+
setIsDocumentHidden(document.hidden);
|
|
3120
|
+
};
|
|
3121
|
+
document.addEventListener("visibilitychange", callback);
|
|
3122
|
+
return () => window.removeEventListener("visibilitychange", callback);
|
|
3123
|
+
}, []);
|
|
3124
|
+
return isDocumentHidden;
|
|
3125
|
+
};
|
|
3126
|
+
var toastsCounter = 1;
|
|
3127
|
+
var Observer = class {
|
|
3128
|
+
constructor() {
|
|
3129
|
+
this.subscribe = (subscriber) => {
|
|
3130
|
+
this.subscribers.push(subscriber);
|
|
3131
|
+
return () => {
|
|
3132
|
+
const index = this.subscribers.indexOf(subscriber);
|
|
3133
|
+
this.subscribers.splice(index, 1);
|
|
3134
|
+
};
|
|
3135
|
+
};
|
|
3136
|
+
this.publish = (data) => {
|
|
3137
|
+
this.subscribers.forEach((subscriber) => subscriber(data));
|
|
3138
|
+
};
|
|
3139
|
+
this.addToast = (data) => {
|
|
3140
|
+
this.publish(data);
|
|
3141
|
+
this.toasts = [...this.toasts, data];
|
|
3142
|
+
};
|
|
3143
|
+
this.create = (data) => {
|
|
3144
|
+
var _data_id;
|
|
3145
|
+
const { message, ...rest } = data;
|
|
3146
|
+
const id = typeof (data == null ? void 0 : data.id) === "number" || ((_data_id = data.id) == null ? void 0 : _data_id.length) > 0 ? data.id : toastsCounter++;
|
|
3147
|
+
const alreadyExists = this.toasts.find((toast) => {
|
|
3148
|
+
return toast.id === id;
|
|
3149
|
+
});
|
|
3150
|
+
const dismissible = data.dismissible === void 0 ? true : data.dismissible;
|
|
3151
|
+
if (this.dismissedToasts.has(id)) this.dismissedToasts.delete(id);
|
|
3152
|
+
if (alreadyExists) this.toasts = this.toasts.map((toast) => {
|
|
3153
|
+
if (toast.id === id) {
|
|
3154
|
+
this.publish({
|
|
3155
|
+
...toast,
|
|
3156
|
+
...data,
|
|
3157
|
+
id,
|
|
3158
|
+
title: message
|
|
3159
|
+
});
|
|
3160
|
+
return {
|
|
3161
|
+
...toast,
|
|
3162
|
+
...data,
|
|
3163
|
+
id,
|
|
3164
|
+
dismissible,
|
|
3165
|
+
title: message
|
|
3166
|
+
};
|
|
3167
|
+
}
|
|
3168
|
+
return toast;
|
|
3169
|
+
});
|
|
3170
|
+
else this.addToast({
|
|
3171
|
+
title: message,
|
|
3172
|
+
...rest,
|
|
3173
|
+
dismissible,
|
|
3174
|
+
id
|
|
3175
|
+
});
|
|
3176
|
+
return id;
|
|
3177
|
+
};
|
|
3178
|
+
this.dismiss = (id) => {
|
|
3179
|
+
if (id) {
|
|
3180
|
+
this.dismissedToasts.add(id);
|
|
3181
|
+
requestAnimationFrame(() => this.subscribers.forEach((subscriber) => subscriber({
|
|
3182
|
+
id,
|
|
3183
|
+
dismiss: true
|
|
3184
|
+
})));
|
|
3185
|
+
} else this.toasts.forEach((toast) => {
|
|
3186
|
+
this.subscribers.forEach((subscriber) => subscriber({
|
|
3187
|
+
id: toast.id,
|
|
3188
|
+
dismiss: true
|
|
3189
|
+
}));
|
|
3190
|
+
});
|
|
3191
|
+
return id;
|
|
3192
|
+
};
|
|
3193
|
+
this.message = (message, data) => {
|
|
3194
|
+
return this.create({
|
|
3195
|
+
...data,
|
|
3196
|
+
message
|
|
3197
|
+
});
|
|
3198
|
+
};
|
|
3199
|
+
this.error = (message, data) => {
|
|
3200
|
+
return this.create({
|
|
3201
|
+
...data,
|
|
3202
|
+
message,
|
|
3203
|
+
type: "error"
|
|
3204
|
+
});
|
|
3205
|
+
};
|
|
3206
|
+
this.success = (message, data) => {
|
|
3207
|
+
return this.create({
|
|
3208
|
+
...data,
|
|
3209
|
+
type: "success",
|
|
3210
|
+
message
|
|
3211
|
+
});
|
|
3212
|
+
};
|
|
3213
|
+
this.info = (message, data) => {
|
|
3214
|
+
return this.create({
|
|
3215
|
+
...data,
|
|
3216
|
+
type: "info",
|
|
3217
|
+
message
|
|
3218
|
+
});
|
|
3219
|
+
};
|
|
3220
|
+
this.warning = (message, data) => {
|
|
3221
|
+
return this.create({
|
|
3222
|
+
...data,
|
|
3223
|
+
type: "warning",
|
|
3224
|
+
message
|
|
3225
|
+
});
|
|
3226
|
+
};
|
|
3227
|
+
this.loading = (message, data) => {
|
|
3228
|
+
return this.create({
|
|
3229
|
+
...data,
|
|
3230
|
+
type: "loading",
|
|
3231
|
+
message
|
|
3232
|
+
});
|
|
3233
|
+
};
|
|
3234
|
+
this.promise = (promise, data) => {
|
|
3235
|
+
if (!data) return;
|
|
3236
|
+
let id = void 0;
|
|
3237
|
+
if (data.loading !== void 0) id = this.create({
|
|
3238
|
+
...data,
|
|
3239
|
+
promise,
|
|
3240
|
+
type: "loading",
|
|
3241
|
+
message: data.loading,
|
|
3242
|
+
description: typeof data.description !== "function" ? data.description : void 0
|
|
3243
|
+
});
|
|
3244
|
+
const p = Promise.resolve(promise instanceof Function ? promise() : promise);
|
|
3245
|
+
let shouldDismiss = id !== void 0;
|
|
3246
|
+
let result;
|
|
3247
|
+
const originalPromise = p.then(async (response) => {
|
|
3248
|
+
result = ["resolve", response];
|
|
3249
|
+
if (import_react.isValidElement(response)) {
|
|
3250
|
+
shouldDismiss = false;
|
|
3251
|
+
this.create({
|
|
3252
|
+
id,
|
|
3253
|
+
type: "default",
|
|
3254
|
+
message: response
|
|
3255
|
+
});
|
|
3256
|
+
} else if (isHttpResponse(response) && !response.ok) {
|
|
3257
|
+
shouldDismiss = false;
|
|
3258
|
+
const promiseData = typeof data.error === "function" ? await data.error(`HTTP error! status: ${response.status}`) : data.error;
|
|
3259
|
+
const description = typeof data.description === "function" ? await data.description(`HTTP error! status: ${response.status}`) : data.description;
|
|
3260
|
+
const toastSettings = typeof promiseData === "object" && !import_react.isValidElement(promiseData) ? promiseData : { message: promiseData };
|
|
3261
|
+
this.create({
|
|
3262
|
+
id,
|
|
3263
|
+
type: "error",
|
|
3264
|
+
description,
|
|
3265
|
+
...toastSettings
|
|
3266
|
+
});
|
|
3267
|
+
} else if (response instanceof Error) {
|
|
3268
|
+
shouldDismiss = false;
|
|
3269
|
+
const promiseData = typeof data.error === "function" ? await data.error(response) : data.error;
|
|
3270
|
+
const description = typeof data.description === "function" ? await data.description(response) : data.description;
|
|
3271
|
+
const toastSettings = typeof promiseData === "object" && !import_react.isValidElement(promiseData) ? promiseData : { message: promiseData };
|
|
3272
|
+
this.create({
|
|
3273
|
+
id,
|
|
3274
|
+
type: "error",
|
|
3275
|
+
description,
|
|
3276
|
+
...toastSettings
|
|
3277
|
+
});
|
|
3278
|
+
} else if (data.success !== void 0) {
|
|
3279
|
+
shouldDismiss = false;
|
|
3280
|
+
const promiseData = typeof data.success === "function" ? await data.success(response) : data.success;
|
|
3281
|
+
const description = typeof data.description === "function" ? await data.description(response) : data.description;
|
|
3282
|
+
const toastSettings = typeof promiseData === "object" && !import_react.isValidElement(promiseData) ? promiseData : { message: promiseData };
|
|
3283
|
+
this.create({
|
|
3284
|
+
id,
|
|
3285
|
+
type: "success",
|
|
3286
|
+
description,
|
|
3287
|
+
...toastSettings
|
|
3288
|
+
});
|
|
3289
|
+
}
|
|
3290
|
+
}).catch(async (error) => {
|
|
3291
|
+
result = ["reject", error];
|
|
3292
|
+
if (data.error !== void 0) {
|
|
3293
|
+
shouldDismiss = false;
|
|
3294
|
+
const promiseData = typeof data.error === "function" ? await data.error(error) : data.error;
|
|
3295
|
+
const description = typeof data.description === "function" ? await data.description(error) : data.description;
|
|
3296
|
+
const toastSettings = typeof promiseData === "object" && !import_react.isValidElement(promiseData) ? promiseData : { message: promiseData };
|
|
3297
|
+
this.create({
|
|
3298
|
+
id,
|
|
3299
|
+
type: "error",
|
|
3300
|
+
description,
|
|
3301
|
+
...toastSettings
|
|
3302
|
+
});
|
|
3303
|
+
}
|
|
3304
|
+
}).finally(() => {
|
|
3305
|
+
if (shouldDismiss) {
|
|
3306
|
+
this.dismiss(id);
|
|
3307
|
+
id = void 0;
|
|
3308
|
+
}
|
|
3309
|
+
data.finally == null || data.finally.call(data);
|
|
3310
|
+
});
|
|
3311
|
+
const unwrap = () => new Promise((resolve, reject) => originalPromise.then(() => result[0] === "reject" ? reject(result[1]) : resolve(result[1])).catch(reject));
|
|
3312
|
+
if (typeof id !== "string" && typeof id !== "number") return { unwrap };
|
|
3313
|
+
else return Object.assign(id, { unwrap });
|
|
3314
|
+
};
|
|
3315
|
+
this.custom = (jsx, data) => {
|
|
3316
|
+
const id = (data == null ? void 0 : data.id) || toastsCounter++;
|
|
3317
|
+
this.create({
|
|
3318
|
+
jsx: jsx(id),
|
|
3319
|
+
id,
|
|
3320
|
+
...data
|
|
3321
|
+
});
|
|
3322
|
+
return id;
|
|
3323
|
+
};
|
|
3324
|
+
this.getActiveToasts = () => {
|
|
3325
|
+
return this.toasts.filter((toast) => !this.dismissedToasts.has(toast.id));
|
|
3326
|
+
};
|
|
3327
|
+
this.subscribers = [];
|
|
3328
|
+
this.toasts = [];
|
|
3329
|
+
this.dismissedToasts = /* @__PURE__ */ new Set();
|
|
3330
|
+
}
|
|
3331
|
+
};
|
|
3332
|
+
var ToastState = new Observer();
|
|
3333
|
+
var toastFunction = (message, data) => {
|
|
3334
|
+
const id = (data == null ? void 0 : data.id) || toastsCounter++;
|
|
3335
|
+
ToastState.addToast({
|
|
3336
|
+
title: message,
|
|
3337
|
+
...data,
|
|
3338
|
+
id
|
|
3339
|
+
});
|
|
3340
|
+
return id;
|
|
3341
|
+
};
|
|
3342
|
+
var isHttpResponse = (data) => {
|
|
3343
|
+
return data && typeof data === "object" && "ok" in data && typeof data.ok === "boolean" && "status" in data && typeof data.status === "number";
|
|
3344
|
+
};
|
|
3345
|
+
var basicToast = toastFunction;
|
|
3346
|
+
var getHistory = () => ToastState.toasts;
|
|
3347
|
+
var getToasts = () => ToastState.getActiveToasts();
|
|
3348
|
+
var toast = Object.assign(basicToast, {
|
|
3349
|
+
success: ToastState.success,
|
|
3350
|
+
info: ToastState.info,
|
|
3351
|
+
warning: ToastState.warning,
|
|
3352
|
+
error: ToastState.error,
|
|
3353
|
+
custom: ToastState.custom,
|
|
3354
|
+
message: ToastState.message,
|
|
3355
|
+
promise: ToastState.promise,
|
|
3356
|
+
dismiss: ToastState.dismiss,
|
|
3357
|
+
loading: ToastState.loading
|
|
3358
|
+
}, {
|
|
3359
|
+
getHistory,
|
|
3360
|
+
getToasts
|
|
3361
|
+
});
|
|
3362
|
+
__insertCSS("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");
|
|
3363
|
+
function isAction(action) {
|
|
3364
|
+
return action.label !== void 0;
|
|
3365
|
+
}
|
|
3366
|
+
var VISIBLE_TOASTS_AMOUNT = 3;
|
|
3367
|
+
var VIEWPORT_OFFSET = "24px";
|
|
3368
|
+
var MOBILE_VIEWPORT_OFFSET = "16px";
|
|
3369
|
+
var TOAST_LIFETIME = 4e3;
|
|
3370
|
+
var TOAST_WIDTH = 356;
|
|
3371
|
+
var GAP = 14;
|
|
3372
|
+
var SWIPE_THRESHOLD = 45;
|
|
3373
|
+
var TIME_BEFORE_UNMOUNT = 200;
|
|
3374
|
+
function cn(...classes) {
|
|
3375
|
+
return classes.filter(Boolean).join(" ");
|
|
3376
|
+
}
|
|
3377
|
+
function getDefaultSwipeDirections(position) {
|
|
3378
|
+
const [y, x] = position.split("-");
|
|
3379
|
+
const directions = [];
|
|
3380
|
+
if (y) directions.push(y);
|
|
3381
|
+
if (x) directions.push(x);
|
|
3382
|
+
return directions;
|
|
3383
|
+
}
|
|
3384
|
+
var Toast = (props) => {
|
|
3385
|
+
var _toast_classNames, _toast_classNames1, _toast_classNames2, _toast_classNames3, _toast_classNames4, _toast_classNames5, _toast_classNames6, _toast_classNames7, _toast_classNames8;
|
|
3386
|
+
const { invert: ToasterInvert, toast, unstyled, interacting, setHeights, visibleToasts, heights, index, toasts, expanded, removeToast, defaultRichColors, closeButton: closeButtonFromToaster, style, cancelButtonStyle, actionButtonStyle, className = "", descriptionClassName = "", duration: durationFromToaster, position, gap, expandByDefault, classNames, icons, closeButtonAriaLabel = "Close toast" } = props;
|
|
3387
|
+
const [swipeDirection, setSwipeDirection] = import_react.useState(null);
|
|
3388
|
+
const [swipeOutDirection, setSwipeOutDirection] = import_react.useState(null);
|
|
3389
|
+
const [mounted, setMounted] = import_react.useState(false);
|
|
3390
|
+
const [removed, setRemoved] = import_react.useState(false);
|
|
3391
|
+
const [swiping, setSwiping] = import_react.useState(false);
|
|
3392
|
+
const [swipeOut, setSwipeOut] = import_react.useState(false);
|
|
3393
|
+
const [isSwiped, setIsSwiped] = import_react.useState(false);
|
|
3394
|
+
const [offsetBeforeRemove, setOffsetBeforeRemove] = import_react.useState(0);
|
|
3395
|
+
const [initialHeight, setInitialHeight] = import_react.useState(0);
|
|
3396
|
+
const remainingTime = import_react.useRef(toast.duration || durationFromToaster || TOAST_LIFETIME);
|
|
3397
|
+
const dragStartTime = import_react.useRef(null);
|
|
3398
|
+
const toastRef = import_react.useRef(null);
|
|
3399
|
+
const isFront = index === 0;
|
|
3400
|
+
const isVisible = index + 1 <= visibleToasts;
|
|
3401
|
+
const toastType = toast.type;
|
|
3402
|
+
const dismissible = toast.dismissible !== false;
|
|
3403
|
+
const toastClassname = toast.className || "";
|
|
3404
|
+
const toastDescriptionClassname = toast.descriptionClassName || "";
|
|
3405
|
+
const heightIndex = import_react.useMemo(() => heights.findIndex((height) => height.toastId === toast.id) || 0, [heights, toast.id]);
|
|
3406
|
+
const closeButton = import_react.useMemo(() => {
|
|
3407
|
+
var _toast_closeButton;
|
|
3408
|
+
return (_toast_closeButton = toast.closeButton) != null ? _toast_closeButton : closeButtonFromToaster;
|
|
3409
|
+
}, [toast.closeButton, closeButtonFromToaster]);
|
|
3410
|
+
const duration = import_react.useMemo(() => toast.duration || durationFromToaster || TOAST_LIFETIME, [toast.duration, durationFromToaster]);
|
|
3411
|
+
const closeTimerStartTimeRef = import_react.useRef(0);
|
|
3412
|
+
const offset = import_react.useRef(0);
|
|
3413
|
+
const lastCloseTimerStartTimeRef = import_react.useRef(0);
|
|
3414
|
+
const pointerStartRef = import_react.useRef(null);
|
|
3415
|
+
const [y, x] = position.split("-");
|
|
3416
|
+
const toastsHeightBefore = import_react.useMemo(() => {
|
|
3417
|
+
return heights.reduce((prev, curr, reducerIndex) => {
|
|
3418
|
+
if (reducerIndex >= heightIndex) return prev;
|
|
3419
|
+
return prev + curr.height;
|
|
3420
|
+
}, 0);
|
|
3421
|
+
}, [heights, heightIndex]);
|
|
3422
|
+
const isDocumentHidden = useIsDocumentHidden();
|
|
3423
|
+
const invert = toast.invert || ToasterInvert;
|
|
3424
|
+
const disabled = toastType === "loading";
|
|
3425
|
+
offset.current = import_react.useMemo(() => heightIndex * gap + toastsHeightBefore, [heightIndex, toastsHeightBefore]);
|
|
3426
|
+
import_react.useEffect(() => {
|
|
3427
|
+
remainingTime.current = duration;
|
|
3428
|
+
}, [duration]);
|
|
3429
|
+
import_react.useEffect(() => {
|
|
3430
|
+
setMounted(true);
|
|
3431
|
+
}, []);
|
|
3432
|
+
import_react.useEffect(() => {
|
|
3433
|
+
const toastNode = toastRef.current;
|
|
3434
|
+
if (toastNode) {
|
|
3435
|
+
const height = toastNode.getBoundingClientRect().height;
|
|
3436
|
+
setInitialHeight(height);
|
|
3437
|
+
setHeights((h) => [{
|
|
3438
|
+
toastId: toast.id,
|
|
3439
|
+
height,
|
|
3440
|
+
position: toast.position
|
|
3441
|
+
}, ...h]);
|
|
3442
|
+
return () => setHeights((h) => h.filter((height) => height.toastId !== toast.id));
|
|
3443
|
+
}
|
|
3444
|
+
}, [setHeights, toast.id]);
|
|
3445
|
+
import_react.useLayoutEffect(() => {
|
|
3446
|
+
if (!mounted) return;
|
|
3447
|
+
const toastNode = toastRef.current;
|
|
3448
|
+
const originalHeight = toastNode.style.height;
|
|
3449
|
+
toastNode.style.height = "auto";
|
|
3450
|
+
const newHeight = toastNode.getBoundingClientRect().height;
|
|
3451
|
+
toastNode.style.height = originalHeight;
|
|
3452
|
+
setInitialHeight(newHeight);
|
|
3453
|
+
setHeights((heights) => {
|
|
3454
|
+
if (!heights.find((height) => height.toastId === toast.id)) return [{
|
|
3455
|
+
toastId: toast.id,
|
|
3456
|
+
height: newHeight,
|
|
3457
|
+
position: toast.position
|
|
3458
|
+
}, ...heights];
|
|
3459
|
+
else return heights.map((height) => height.toastId === toast.id ? {
|
|
3460
|
+
...height,
|
|
3461
|
+
height: newHeight
|
|
3462
|
+
} : height);
|
|
3463
|
+
});
|
|
3464
|
+
}, [
|
|
3465
|
+
mounted,
|
|
3466
|
+
toast.title,
|
|
3467
|
+
toast.description,
|
|
3468
|
+
setHeights,
|
|
3469
|
+
toast.id,
|
|
3470
|
+
toast.jsx,
|
|
3471
|
+
toast.action,
|
|
3472
|
+
toast.cancel
|
|
3473
|
+
]);
|
|
3474
|
+
const deleteToast = import_react.useCallback(() => {
|
|
3475
|
+
setRemoved(true);
|
|
3476
|
+
setOffsetBeforeRemove(offset.current);
|
|
3477
|
+
setHeights((h) => h.filter((height) => height.toastId !== toast.id));
|
|
3478
|
+
setTimeout(() => {
|
|
3479
|
+
removeToast(toast);
|
|
3480
|
+
}, TIME_BEFORE_UNMOUNT);
|
|
3481
|
+
}, [
|
|
3482
|
+
toast,
|
|
3483
|
+
removeToast,
|
|
3484
|
+
setHeights,
|
|
3485
|
+
offset
|
|
3486
|
+
]);
|
|
3487
|
+
import_react.useEffect(() => {
|
|
3488
|
+
if (toast.promise && toastType === "loading" || toast.duration === Infinity || toast.type === "loading") return;
|
|
3489
|
+
let timeoutId;
|
|
3490
|
+
const pauseTimer = () => {
|
|
3491
|
+
if (lastCloseTimerStartTimeRef.current < closeTimerStartTimeRef.current) {
|
|
3492
|
+
const elapsedTime = (/* @__PURE__ */ new Date()).getTime() - closeTimerStartTimeRef.current;
|
|
3493
|
+
remainingTime.current = remainingTime.current - elapsedTime;
|
|
3494
|
+
}
|
|
3495
|
+
lastCloseTimerStartTimeRef.current = (/* @__PURE__ */ new Date()).getTime();
|
|
3496
|
+
};
|
|
3497
|
+
const startTimer = () => {
|
|
3498
|
+
if (remainingTime.current === Infinity) return;
|
|
3499
|
+
closeTimerStartTimeRef.current = (/* @__PURE__ */ new Date()).getTime();
|
|
3500
|
+
timeoutId = setTimeout(() => {
|
|
3501
|
+
toast.onAutoClose == null || toast.onAutoClose.call(toast, toast);
|
|
3502
|
+
deleteToast();
|
|
3503
|
+
}, remainingTime.current);
|
|
3504
|
+
};
|
|
3505
|
+
if (expanded || interacting || isDocumentHidden) pauseTimer();
|
|
3506
|
+
else startTimer();
|
|
3507
|
+
return () => clearTimeout(timeoutId);
|
|
3508
|
+
}, [
|
|
3509
|
+
expanded,
|
|
3510
|
+
interacting,
|
|
3511
|
+
toast,
|
|
3512
|
+
toastType,
|
|
3513
|
+
isDocumentHidden,
|
|
3514
|
+
deleteToast
|
|
3515
|
+
]);
|
|
3516
|
+
import_react.useEffect(() => {
|
|
3517
|
+
if (toast.delete) {
|
|
3518
|
+
deleteToast();
|
|
3519
|
+
toast.onDismiss == null || toast.onDismiss.call(toast, toast);
|
|
3520
|
+
}
|
|
3521
|
+
}, [deleteToast, toast.delete]);
|
|
3522
|
+
function getLoadingIcon() {
|
|
3523
|
+
var _toast_classNames;
|
|
3524
|
+
if (icons == null ? void 0 : icons.loading) {
|
|
3525
|
+
var _toast_classNames1;
|
|
3526
|
+
return /*#__PURE__*/ import_react.createElement("div", {
|
|
3527
|
+
className: cn(classNames == null ? void 0 : classNames.loader, toast == null ? void 0 : (_toast_classNames1 = toast.classNames) == null ? void 0 : _toast_classNames1.loader, "sonner-loader"),
|
|
3528
|
+
"data-visible": toastType === "loading"
|
|
3529
|
+
}, icons.loading);
|
|
3530
|
+
}
|
|
3531
|
+
return /*#__PURE__*/ import_react.createElement(Loader, {
|
|
3532
|
+
className: cn(classNames == null ? void 0 : classNames.loader, toast == null ? void 0 : (_toast_classNames = toast.classNames) == null ? void 0 : _toast_classNames.loader),
|
|
3533
|
+
visible: toastType === "loading"
|
|
3534
|
+
});
|
|
3535
|
+
}
|
|
3536
|
+
const icon = toast.icon || (icons == null ? void 0 : icons[toastType]) || getAsset(toastType);
|
|
3537
|
+
var _toast_richColors, _icons_close;
|
|
3538
|
+
return /*#__PURE__*/ import_react.createElement("li", {
|
|
3539
|
+
tabIndex: 0,
|
|
3540
|
+
ref: toastRef,
|
|
3541
|
+
className: cn(className, toastClassname, classNames == null ? void 0 : classNames.toast, toast == null ? void 0 : (_toast_classNames = toast.classNames) == null ? void 0 : _toast_classNames.toast, classNames == null ? void 0 : classNames.default, classNames == null ? void 0 : classNames[toastType], toast == null ? void 0 : (_toast_classNames1 = toast.classNames) == null ? void 0 : _toast_classNames1[toastType]),
|
|
3542
|
+
"data-sonner-toast": "",
|
|
3543
|
+
"data-rich-colors": (_toast_richColors = toast.richColors) != null ? _toast_richColors : defaultRichColors,
|
|
3544
|
+
"data-styled": !Boolean(toast.jsx || toast.unstyled || unstyled),
|
|
3545
|
+
"data-mounted": mounted,
|
|
3546
|
+
"data-promise": Boolean(toast.promise),
|
|
3547
|
+
"data-swiped": isSwiped,
|
|
3548
|
+
"data-removed": removed,
|
|
3549
|
+
"data-visible": isVisible,
|
|
3550
|
+
"data-y-position": y,
|
|
3551
|
+
"data-x-position": x,
|
|
3552
|
+
"data-index": index,
|
|
3553
|
+
"data-front": isFront,
|
|
3554
|
+
"data-swiping": swiping,
|
|
3555
|
+
"data-dismissible": dismissible,
|
|
3556
|
+
"data-type": toastType,
|
|
3557
|
+
"data-invert": invert,
|
|
3558
|
+
"data-swipe-out": swipeOut,
|
|
3559
|
+
"data-swipe-direction": swipeOutDirection,
|
|
3560
|
+
"data-expanded": Boolean(expanded || expandByDefault && mounted),
|
|
3561
|
+
"data-testid": toast.testId,
|
|
3562
|
+
style: {
|
|
3563
|
+
"--index": index,
|
|
3564
|
+
"--toasts-before": index,
|
|
3565
|
+
"--z-index": toasts.length - index,
|
|
3566
|
+
"--offset": `${removed ? offsetBeforeRemove : offset.current}px`,
|
|
3567
|
+
"--initial-height": expandByDefault ? "auto" : `${initialHeight}px`,
|
|
3568
|
+
...style,
|
|
3569
|
+
...toast.style
|
|
3570
|
+
},
|
|
3571
|
+
onDragEnd: () => {
|
|
3572
|
+
setSwiping(false);
|
|
3573
|
+
setSwipeDirection(null);
|
|
3574
|
+
pointerStartRef.current = null;
|
|
3575
|
+
},
|
|
3576
|
+
onPointerDown: (event) => {
|
|
3577
|
+
if (event.button === 2) return;
|
|
3578
|
+
if (disabled || !dismissible) return;
|
|
3579
|
+
dragStartTime.current = /* @__PURE__ */ new Date();
|
|
3580
|
+
setOffsetBeforeRemove(offset.current);
|
|
3581
|
+
event.target.setPointerCapture(event.pointerId);
|
|
3582
|
+
if (event.target.tagName === "BUTTON") return;
|
|
3583
|
+
setSwiping(true);
|
|
3584
|
+
pointerStartRef.current = {
|
|
3585
|
+
x: event.clientX,
|
|
3586
|
+
y: event.clientY
|
|
3587
|
+
};
|
|
3588
|
+
},
|
|
3589
|
+
onPointerUp: () => {
|
|
3590
|
+
var _toastRef_current, _toastRef_current1, _dragStartTime_current;
|
|
3591
|
+
if (swipeOut || !dismissible) return;
|
|
3592
|
+
pointerStartRef.current = null;
|
|
3593
|
+
const swipeAmountX = Number(((_toastRef_current = toastRef.current) == null ? void 0 : _toastRef_current.style.getPropertyValue("--swipe-amount-x").replace("px", "")) || 0);
|
|
3594
|
+
const swipeAmountY = Number(((_toastRef_current1 = toastRef.current) == null ? void 0 : _toastRef_current1.style.getPropertyValue("--swipe-amount-y").replace("px", "")) || 0);
|
|
3595
|
+
const timeTaken = (/* @__PURE__ */ new Date()).getTime() - ((_dragStartTime_current = dragStartTime.current) == null ? void 0 : _dragStartTime_current.getTime());
|
|
3596
|
+
const swipeAmount = swipeDirection === "x" ? swipeAmountX : swipeAmountY;
|
|
3597
|
+
const velocity = Math.abs(swipeAmount) / timeTaken;
|
|
3598
|
+
if (Math.abs(swipeAmount) >= SWIPE_THRESHOLD || velocity > .11) {
|
|
3599
|
+
setOffsetBeforeRemove(offset.current);
|
|
3600
|
+
toast.onDismiss == null || toast.onDismiss.call(toast, toast);
|
|
3601
|
+
if (swipeDirection === "x") setSwipeOutDirection(swipeAmountX > 0 ? "right" : "left");
|
|
3602
|
+
else setSwipeOutDirection(swipeAmountY > 0 ? "down" : "up");
|
|
3603
|
+
deleteToast();
|
|
3604
|
+
setSwipeOut(true);
|
|
3605
|
+
return;
|
|
3606
|
+
} else {
|
|
3607
|
+
var _toastRef_current2, _toastRef_current3;
|
|
3608
|
+
(_toastRef_current2 = toastRef.current) == null || _toastRef_current2.style.setProperty("--swipe-amount-x", `0px`);
|
|
3609
|
+
(_toastRef_current3 = toastRef.current) == null || _toastRef_current3.style.setProperty("--swipe-amount-y", `0px`);
|
|
3610
|
+
}
|
|
3611
|
+
setIsSwiped(false);
|
|
3612
|
+
setSwiping(false);
|
|
3613
|
+
setSwipeDirection(null);
|
|
3614
|
+
},
|
|
3615
|
+
onPointerMove: (event) => {
|
|
3616
|
+
var _window_getSelection, _toastRef_current, _toastRef_current1;
|
|
3617
|
+
if (!pointerStartRef.current || !dismissible) return;
|
|
3618
|
+
if (((_window_getSelection = window.getSelection()) == null ? void 0 : _window_getSelection.toString().length) > 0) return;
|
|
3619
|
+
const yDelta = event.clientY - pointerStartRef.current.y;
|
|
3620
|
+
const xDelta = event.clientX - pointerStartRef.current.x;
|
|
3621
|
+
var _props_swipeDirections;
|
|
3622
|
+
const swipeDirections = (_props_swipeDirections = props.swipeDirections) != null ? _props_swipeDirections : getDefaultSwipeDirections(position);
|
|
3623
|
+
if (!swipeDirection && (Math.abs(xDelta) > 1 || Math.abs(yDelta) > 1)) setSwipeDirection(Math.abs(xDelta) > Math.abs(yDelta) ? "x" : "y");
|
|
3624
|
+
let swipeAmount = {
|
|
3625
|
+
x: 0,
|
|
3626
|
+
y: 0
|
|
3627
|
+
};
|
|
3628
|
+
const getDampening = (delta) => {
|
|
3629
|
+
return 1 / (1.5 + Math.abs(delta) / 20);
|
|
3630
|
+
};
|
|
3631
|
+
if (swipeDirection === "y") {
|
|
3632
|
+
if (swipeDirections.includes("top") || swipeDirections.includes("bottom")) {
|
|
3633
|
+
if (swipeDirections.includes("top") && yDelta < 0 || swipeDirections.includes("bottom") && yDelta > 0) swipeAmount.y = yDelta;
|
|
3634
|
+
else {
|
|
3635
|
+
const dampenedDelta = yDelta * getDampening(yDelta);
|
|
3636
|
+
swipeAmount.y = Math.abs(dampenedDelta) < Math.abs(yDelta) ? dampenedDelta : yDelta;
|
|
3637
|
+
}
|
|
3638
|
+
}
|
|
3639
|
+
} else if (swipeDirection === "x") {
|
|
3640
|
+
if (swipeDirections.includes("left") || swipeDirections.includes("right")) {
|
|
3641
|
+
if (swipeDirections.includes("left") && xDelta < 0 || swipeDirections.includes("right") && xDelta > 0) swipeAmount.x = xDelta;
|
|
3642
|
+
else {
|
|
3643
|
+
const dampenedDelta = xDelta * getDampening(xDelta);
|
|
3644
|
+
swipeAmount.x = Math.abs(dampenedDelta) < Math.abs(xDelta) ? dampenedDelta : xDelta;
|
|
3645
|
+
}
|
|
3646
|
+
}
|
|
3647
|
+
}
|
|
3648
|
+
if (Math.abs(swipeAmount.x) > 0 || Math.abs(swipeAmount.y) > 0) setIsSwiped(true);
|
|
3649
|
+
(_toastRef_current = toastRef.current) == null || _toastRef_current.style.setProperty("--swipe-amount-x", `${swipeAmount.x}px`);
|
|
3650
|
+
(_toastRef_current1 = toastRef.current) == null || _toastRef_current1.style.setProperty("--swipe-amount-y", `${swipeAmount.y}px`);
|
|
3651
|
+
}
|
|
3652
|
+
}, closeButton && !toast.jsx && toastType !== "loading" ? /*#__PURE__*/ import_react.createElement("button", {
|
|
3653
|
+
"aria-label": closeButtonAriaLabel,
|
|
3654
|
+
"data-disabled": disabled,
|
|
3655
|
+
"data-close-button": true,
|
|
3656
|
+
onClick: disabled || !dismissible ? () => {} : () => {
|
|
3657
|
+
deleteToast();
|
|
3658
|
+
toast.onDismiss == null || toast.onDismiss.call(toast, toast);
|
|
3659
|
+
},
|
|
3660
|
+
className: cn(classNames == null ? void 0 : classNames.closeButton, toast == null ? void 0 : (_toast_classNames2 = toast.classNames) == null ? void 0 : _toast_classNames2.closeButton)
|
|
3661
|
+
}, (_icons_close = icons == null ? void 0 : icons.close) != null ? _icons_close : CloseIcon) : null, (toastType || toast.icon || toast.promise) && toast.icon !== null && ((icons == null ? void 0 : icons[toastType]) !== null || toast.icon) ? /*#__PURE__*/ import_react.createElement("div", {
|
|
3662
|
+
"data-icon": "",
|
|
3663
|
+
className: cn(classNames == null ? void 0 : classNames.icon, toast == null ? void 0 : (_toast_classNames3 = toast.classNames) == null ? void 0 : _toast_classNames3.icon)
|
|
3664
|
+
}, toast.promise || toast.type === "loading" && !toast.icon ? toast.icon || getLoadingIcon() : null, toast.type !== "loading" ? icon : null) : null, /*#__PURE__*/ import_react.createElement("div", {
|
|
3665
|
+
"data-content": "",
|
|
3666
|
+
className: cn(classNames == null ? void 0 : classNames.content, toast == null ? void 0 : (_toast_classNames4 = toast.classNames) == null ? void 0 : _toast_classNames4.content)
|
|
3667
|
+
}, /*#__PURE__*/ import_react.createElement("div", {
|
|
3668
|
+
"data-title": "",
|
|
3669
|
+
className: cn(classNames == null ? void 0 : classNames.title, toast == null ? void 0 : (_toast_classNames5 = toast.classNames) == null ? void 0 : _toast_classNames5.title)
|
|
3670
|
+
}, toast.jsx ? toast.jsx : typeof toast.title === "function" ? toast.title() : toast.title), toast.description ? /*#__PURE__*/ import_react.createElement("div", {
|
|
3671
|
+
"data-description": "",
|
|
3672
|
+
className: cn(descriptionClassName, toastDescriptionClassname, classNames == null ? void 0 : classNames.description, toast == null ? void 0 : (_toast_classNames6 = toast.classNames) == null ? void 0 : _toast_classNames6.description)
|
|
3673
|
+
}, typeof toast.description === "function" ? toast.description() : toast.description) : null), /*#__PURE__*/ import_react.isValidElement(toast.cancel) ? toast.cancel : toast.cancel && isAction(toast.cancel) ? /*#__PURE__*/ import_react.createElement("button", {
|
|
3674
|
+
"data-button": true,
|
|
3675
|
+
"data-cancel": true,
|
|
3676
|
+
style: toast.cancelButtonStyle || cancelButtonStyle,
|
|
3677
|
+
onClick: (event) => {
|
|
3678
|
+
if (!isAction(toast.cancel)) return;
|
|
3679
|
+
if (!dismissible) return;
|
|
3680
|
+
toast.cancel.onClick == null || toast.cancel.onClick.call(toast.cancel, event);
|
|
3681
|
+
deleteToast();
|
|
3682
|
+
},
|
|
3683
|
+
className: cn(classNames == null ? void 0 : classNames.cancelButton, toast == null ? void 0 : (_toast_classNames7 = toast.classNames) == null ? void 0 : _toast_classNames7.cancelButton)
|
|
3684
|
+
}, toast.cancel.label) : null, /*#__PURE__*/ import_react.isValidElement(toast.action) ? toast.action : toast.action && isAction(toast.action) ? /*#__PURE__*/ import_react.createElement("button", {
|
|
3685
|
+
"data-button": true,
|
|
3686
|
+
"data-action": true,
|
|
3687
|
+
style: toast.actionButtonStyle || actionButtonStyle,
|
|
3688
|
+
onClick: (event) => {
|
|
3689
|
+
if (!isAction(toast.action)) return;
|
|
3690
|
+
toast.action.onClick == null || toast.action.onClick.call(toast.action, event);
|
|
3691
|
+
if (event.defaultPrevented) return;
|
|
3692
|
+
deleteToast();
|
|
3693
|
+
},
|
|
3694
|
+
className: cn(classNames == null ? void 0 : classNames.actionButton, toast == null ? void 0 : (_toast_classNames8 = toast.classNames) == null ? void 0 : _toast_classNames8.actionButton)
|
|
3695
|
+
}, toast.action.label) : null);
|
|
3696
|
+
};
|
|
3697
|
+
function getDocumentDirection() {
|
|
3698
|
+
if (typeof window === "undefined") return "ltr";
|
|
3699
|
+
if (typeof document === "undefined") return "ltr";
|
|
3700
|
+
const dirAttribute = document.documentElement.getAttribute("dir");
|
|
3701
|
+
if (dirAttribute === "auto" || !dirAttribute) return window.getComputedStyle(document.documentElement).direction;
|
|
3702
|
+
return dirAttribute;
|
|
3703
|
+
}
|
|
3704
|
+
function assignOffset(defaultOffset, mobileOffset) {
|
|
3705
|
+
const styles = {};
|
|
3706
|
+
[defaultOffset, mobileOffset].forEach((offset, index) => {
|
|
3707
|
+
const isMobile = index === 1;
|
|
3708
|
+
const prefix = isMobile ? "--mobile-offset" : "--offset";
|
|
3709
|
+
const defaultValue = isMobile ? MOBILE_VIEWPORT_OFFSET : VIEWPORT_OFFSET;
|
|
3710
|
+
function assignAll(offset) {
|
|
3711
|
+
[
|
|
3712
|
+
"top",
|
|
3713
|
+
"right",
|
|
3714
|
+
"bottom",
|
|
3715
|
+
"left"
|
|
3716
|
+
].forEach((key) => {
|
|
3717
|
+
styles[`${prefix}-${key}`] = typeof offset === "number" ? `${offset}px` : offset;
|
|
3718
|
+
});
|
|
3719
|
+
}
|
|
3720
|
+
if (typeof offset === "number" || typeof offset === "string") assignAll(offset);
|
|
3721
|
+
else if (typeof offset === "object") [
|
|
3722
|
+
"top",
|
|
3723
|
+
"right",
|
|
3724
|
+
"bottom",
|
|
3725
|
+
"left"
|
|
3726
|
+
].forEach((key) => {
|
|
3727
|
+
if (offset[key] === void 0) styles[`${prefix}-${key}`] = defaultValue;
|
|
3728
|
+
else styles[`${prefix}-${key}`] = typeof offset[key] === "number" ? `${offset[key]}px` : offset[key];
|
|
3729
|
+
});
|
|
3730
|
+
else assignAll(defaultValue);
|
|
3731
|
+
});
|
|
3732
|
+
return styles;
|
|
3733
|
+
}
|
|
3734
|
+
var Toaster = /*#__PURE__*/ import_react.forwardRef(function Toaster(props, ref) {
|
|
3735
|
+
const { id, invert, position = "bottom-right", hotkey = ["altKey", "KeyT"], expand, closeButton, className, offset, mobileOffset, theme = "light", richColors, duration, style, visibleToasts = VISIBLE_TOASTS_AMOUNT, toastOptions, dir = getDocumentDirection(), gap = GAP, icons, containerAriaLabel = "Notifications" } = props;
|
|
3736
|
+
const [toasts, setToasts] = import_react.useState([]);
|
|
3737
|
+
const filteredToasts = import_react.useMemo(() => {
|
|
3738
|
+
if (id) return toasts.filter((toast) => toast.toasterId === id);
|
|
3739
|
+
return toasts.filter((toast) => !toast.toasterId);
|
|
3740
|
+
}, [toasts, id]);
|
|
3741
|
+
const possiblePositions = import_react.useMemo(() => {
|
|
3742
|
+
return Array.from(new Set([position].concat(filteredToasts.filter((toast) => toast.position).map((toast) => toast.position))));
|
|
3743
|
+
}, [filteredToasts, position]);
|
|
3744
|
+
const [heights, setHeights] = import_react.useState([]);
|
|
3745
|
+
const [expanded, setExpanded] = import_react.useState(false);
|
|
3746
|
+
const [interacting, setInteracting] = import_react.useState(false);
|
|
3747
|
+
const [actualTheme, setActualTheme] = import_react.useState(theme !== "system" ? theme : typeof window !== "undefined" ? window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : "light");
|
|
3748
|
+
const listRef = import_react.useRef(null);
|
|
3749
|
+
const hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, "");
|
|
3750
|
+
const lastFocusedElementRef = import_react.useRef(null);
|
|
3751
|
+
const isFocusWithinRef = import_react.useRef(false);
|
|
3752
|
+
const removeToast = import_react.useCallback((toastToRemove) => {
|
|
3753
|
+
setToasts((toasts) => {
|
|
3754
|
+
var _toasts_find;
|
|
3755
|
+
if (!((_toasts_find = toasts.find((toast) => toast.id === toastToRemove.id)) == null ? void 0 : _toasts_find.delete)) ToastState.dismiss(toastToRemove.id);
|
|
3756
|
+
return toasts.filter(({ id }) => id !== toastToRemove.id);
|
|
3757
|
+
});
|
|
3758
|
+
}, []);
|
|
3759
|
+
import_react.useEffect(() => {
|
|
3760
|
+
return ToastState.subscribe((toast) => {
|
|
3761
|
+
if (toast.dismiss) {
|
|
3762
|
+
requestAnimationFrame(() => {
|
|
3763
|
+
setToasts((toasts) => toasts.map((t) => t.id === toast.id ? {
|
|
3764
|
+
...t,
|
|
3765
|
+
delete: true
|
|
3766
|
+
} : t));
|
|
3767
|
+
});
|
|
3768
|
+
return;
|
|
3769
|
+
}
|
|
3770
|
+
setTimeout(() => {
|
|
3771
|
+
import_react_dom.flushSync(() => {
|
|
3772
|
+
setToasts((toasts) => {
|
|
3773
|
+
const indexOfExistingToast = toasts.findIndex((t) => t.id === toast.id);
|
|
3774
|
+
if (indexOfExistingToast !== -1) return [
|
|
3775
|
+
...toasts.slice(0, indexOfExistingToast),
|
|
3776
|
+
{
|
|
3777
|
+
...toasts[indexOfExistingToast],
|
|
3778
|
+
...toast
|
|
3779
|
+
},
|
|
3780
|
+
...toasts.slice(indexOfExistingToast + 1)
|
|
3781
|
+
];
|
|
3782
|
+
return [toast, ...toasts];
|
|
3783
|
+
});
|
|
3784
|
+
});
|
|
3785
|
+
});
|
|
3786
|
+
});
|
|
3787
|
+
}, [toasts]);
|
|
3788
|
+
import_react.useEffect(() => {
|
|
3789
|
+
if (theme !== "system") {
|
|
3790
|
+
setActualTheme(theme);
|
|
3791
|
+
return;
|
|
3792
|
+
}
|
|
3793
|
+
if (theme === "system") {
|
|
3794
|
+
if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) setActualTheme("dark");
|
|
3795
|
+
else setActualTheme("light");
|
|
3796
|
+
}
|
|
3797
|
+
if (typeof window === "undefined") return;
|
|
3798
|
+
const darkMediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
3799
|
+
try {
|
|
3800
|
+
darkMediaQuery.addEventListener("change", ({ matches }) => {
|
|
3801
|
+
if (matches) setActualTheme("dark");
|
|
3802
|
+
else setActualTheme("light");
|
|
3803
|
+
});
|
|
3804
|
+
} catch (error) {
|
|
3805
|
+
darkMediaQuery.addListener(({ matches }) => {
|
|
3806
|
+
try {
|
|
3807
|
+
if (matches) setActualTheme("dark");
|
|
3808
|
+
else setActualTheme("light");
|
|
3809
|
+
} catch (e) {
|
|
3810
|
+
console.error(e);
|
|
3811
|
+
}
|
|
3812
|
+
});
|
|
3813
|
+
}
|
|
3814
|
+
}, [theme]);
|
|
3815
|
+
import_react.useEffect(() => {
|
|
3816
|
+
if (toasts.length <= 1) setExpanded(false);
|
|
3817
|
+
}, [toasts]);
|
|
3818
|
+
import_react.useEffect(() => {
|
|
3819
|
+
const handleKeyDown = (event) => {
|
|
3820
|
+
var _listRef_current;
|
|
3821
|
+
if (hotkey.every((key) => event[key] || event.code === key)) {
|
|
3822
|
+
var _listRef_current1;
|
|
3823
|
+
setExpanded(true);
|
|
3824
|
+
(_listRef_current1 = listRef.current) == null || _listRef_current1.focus();
|
|
3825
|
+
}
|
|
3826
|
+
if (event.code === "Escape" && (document.activeElement === listRef.current || ((_listRef_current = listRef.current) == null ? void 0 : _listRef_current.contains(document.activeElement)))) setExpanded(false);
|
|
3827
|
+
};
|
|
3828
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
3829
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
3830
|
+
}, [hotkey]);
|
|
3831
|
+
import_react.useEffect(() => {
|
|
3832
|
+
if (listRef.current) return () => {
|
|
3833
|
+
if (lastFocusedElementRef.current) {
|
|
3834
|
+
lastFocusedElementRef.current.focus({ preventScroll: true });
|
|
3835
|
+
lastFocusedElementRef.current = null;
|
|
3836
|
+
isFocusWithinRef.current = false;
|
|
3837
|
+
}
|
|
3838
|
+
};
|
|
3839
|
+
}, [listRef.current]);
|
|
3840
|
+
return /*#__PURE__*/ import_react.createElement("section", {
|
|
3841
|
+
ref,
|
|
3842
|
+
"aria-label": `${containerAriaLabel} ${hotkeyLabel}`,
|
|
3843
|
+
tabIndex: -1,
|
|
3844
|
+
"aria-live": "polite",
|
|
3845
|
+
"aria-relevant": "additions text",
|
|
3846
|
+
"aria-atomic": "false",
|
|
3847
|
+
suppressHydrationWarning: true
|
|
3848
|
+
}, possiblePositions.map((position, index) => {
|
|
3849
|
+
var _heights_;
|
|
3850
|
+
const [y, x] = position.split("-");
|
|
3851
|
+
if (!filteredToasts.length) return null;
|
|
3852
|
+
return /*#__PURE__*/ import_react.createElement("ol", {
|
|
3853
|
+
key: position,
|
|
3854
|
+
dir: dir === "auto" ? getDocumentDirection() : dir,
|
|
3855
|
+
tabIndex: -1,
|
|
3856
|
+
ref: listRef,
|
|
3857
|
+
className,
|
|
3858
|
+
"data-sonner-toaster": true,
|
|
3859
|
+
"data-sonner-theme": actualTheme,
|
|
3860
|
+
"data-y-position": y,
|
|
3861
|
+
"data-x-position": x,
|
|
3862
|
+
style: {
|
|
3863
|
+
"--front-toast-height": `${((_heights_ = heights[0]) == null ? void 0 : _heights_.height) || 0}px`,
|
|
3864
|
+
"--width": `${TOAST_WIDTH}px`,
|
|
3865
|
+
"--gap": `${gap}px`,
|
|
3866
|
+
...style,
|
|
3867
|
+
...assignOffset(offset, mobileOffset)
|
|
3868
|
+
},
|
|
3869
|
+
onBlur: (event) => {
|
|
3870
|
+
if (isFocusWithinRef.current && !event.currentTarget.contains(event.relatedTarget)) {
|
|
3871
|
+
isFocusWithinRef.current = false;
|
|
3872
|
+
if (lastFocusedElementRef.current) {
|
|
3873
|
+
lastFocusedElementRef.current.focus({ preventScroll: true });
|
|
3874
|
+
lastFocusedElementRef.current = null;
|
|
3875
|
+
}
|
|
3876
|
+
}
|
|
3877
|
+
},
|
|
3878
|
+
onFocus: (event) => {
|
|
3879
|
+
if (event.target instanceof HTMLElement && event.target.dataset.dismissible === "false") return;
|
|
3880
|
+
if (!isFocusWithinRef.current) {
|
|
3881
|
+
isFocusWithinRef.current = true;
|
|
3882
|
+
lastFocusedElementRef.current = event.relatedTarget;
|
|
3883
|
+
}
|
|
3884
|
+
},
|
|
3885
|
+
onMouseEnter: () => setExpanded(true),
|
|
3886
|
+
onMouseMove: () => setExpanded(true),
|
|
3887
|
+
onMouseLeave: () => {
|
|
3888
|
+
if (!interacting) setExpanded(false);
|
|
3889
|
+
},
|
|
3890
|
+
onDragEnd: () => setExpanded(false),
|
|
3891
|
+
onPointerDown: (event) => {
|
|
3892
|
+
if (event.target instanceof HTMLElement && event.target.dataset.dismissible === "false") return;
|
|
3893
|
+
setInteracting(true);
|
|
3894
|
+
},
|
|
3895
|
+
onPointerUp: () => setInteracting(false)
|
|
3896
|
+
}, filteredToasts.filter((toast) => !toast.position && index === 0 || toast.position === position).map((toast, index) => {
|
|
3897
|
+
var _toastOptions_duration, _toastOptions_closeButton;
|
|
3898
|
+
return /*#__PURE__*/ import_react.createElement(Toast, {
|
|
3899
|
+
key: toast.id,
|
|
3900
|
+
icons,
|
|
3901
|
+
index,
|
|
3902
|
+
toast,
|
|
3903
|
+
defaultRichColors: richColors,
|
|
3904
|
+
duration: (_toastOptions_duration = toastOptions == null ? void 0 : toastOptions.duration) != null ? _toastOptions_duration : duration,
|
|
3905
|
+
className: toastOptions == null ? void 0 : toastOptions.className,
|
|
3906
|
+
descriptionClassName: toastOptions == null ? void 0 : toastOptions.descriptionClassName,
|
|
3907
|
+
invert,
|
|
3908
|
+
visibleToasts,
|
|
3909
|
+
closeButton: (_toastOptions_closeButton = toastOptions == null ? void 0 : toastOptions.closeButton) != null ? _toastOptions_closeButton : closeButton,
|
|
3910
|
+
interacting,
|
|
3911
|
+
position,
|
|
3912
|
+
style: toastOptions == null ? void 0 : toastOptions.style,
|
|
3913
|
+
unstyled: toastOptions == null ? void 0 : toastOptions.unstyled,
|
|
3914
|
+
classNames: toastOptions == null ? void 0 : toastOptions.classNames,
|
|
3915
|
+
cancelButtonStyle: toastOptions == null ? void 0 : toastOptions.cancelButtonStyle,
|
|
3916
|
+
actionButtonStyle: toastOptions == null ? void 0 : toastOptions.actionButtonStyle,
|
|
3917
|
+
closeButtonAriaLabel: toastOptions == null ? void 0 : toastOptions.closeButtonAriaLabel,
|
|
3918
|
+
removeToast,
|
|
3919
|
+
toasts: filteredToasts.filter((t) => t.position == toast.position),
|
|
3920
|
+
heights: heights.filter((h) => h.position == toast.position),
|
|
3921
|
+
setHeights,
|
|
3922
|
+
expandByDefault: expand,
|
|
3923
|
+
gap,
|
|
3924
|
+
expanded,
|
|
3925
|
+
swipeDirections: props.swipeDirections
|
|
3926
|
+
});
|
|
3927
|
+
}));
|
|
3928
|
+
}));
|
|
3929
|
+
});
|
|
3930
|
+
export { useFloating as _, Portal as a, TooltipProvider as c, flip as d, hide as f, size as g, shift as h, Content2 as i, Trigger as l, offset as m, toast as n, Provider as o, limitShift as p, Arrow2 as r, Root3 as s, Toaster as t, arrow as u, autoUpdate as v };
|