lizaui 9.0.10 → 9.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/button/index.es.js +1 -1
  2. package/dist/calendar/index.cjs.js +11 -8
  3. package/dist/calendar/index.cjs.js.map +1 -1
  4. package/dist/calendar/index.es.js +12 -9
  5. package/dist/calendar/index.es.js.map +1 -1
  6. package/dist/checkbox/index.es.js +1 -1
  7. package/dist/chunks/{button-B0fpJrMg.js → button-CA3Y2GZ1.js} +2 -2
  8. package/dist/chunks/{button-B0fpJrMg.js.map → button-CA3Y2GZ1.js.map} +1 -1
  9. package/dist/chunks/{checkbox-C1Sssumg.js → checkbox-qzZKMLRN.js} +2 -2
  10. package/dist/chunks/{checkbox-C1Sssumg.js.map → checkbox-qzZKMLRN.js.map} +1 -1
  11. package/dist/chunks/{floating-ui.dom-DsMDyTcd.js → floating-ui.dom-N5ROFCJy.js} +1 -10
  12. package/dist/chunks/{floating-ui.dom-DsMDyTcd.js.map → floating-ui.dom-N5ROFCJy.js.map} +1 -1
  13. package/dist/chunks/{floating-ui.dom-Bd-QJw02.js → floating-ui.dom-NqZWWqNg.js} +4 -13
  14. package/dist/chunks/{floating-ui.dom-Bd-QJw02.js.map → floating-ui.dom-NqZWWqNg.js.map} +1 -1
  15. package/dist/chunks/index-CuySPbdY.js +559 -0
  16. package/dist/chunks/index-CuySPbdY.js.map +1 -0
  17. package/dist/chunks/index-DBDBh58Q.js +575 -0
  18. package/dist/chunks/index-DBDBh58Q.js.map +1 -0
  19. package/dist/chunks/index-DNSql2gU.js +662 -0
  20. package/dist/chunks/index-DNSql2gU.js.map +1 -0
  21. package/dist/chunks/{index-B4RTH1-D.js → index-DiC9dI6_.js} +4 -4
  22. package/dist/chunks/{index-B4RTH1-D.js.map → index-DiC9dI6_.js.map} +1 -1
  23. package/dist/chunks/index-DlZi5TkN.js +646 -0
  24. package/dist/chunks/index-DlZi5TkN.js.map +1 -0
  25. package/dist/chunks/{scroll-area-C0NhSIO2.js → scroll-area-BboZbU1u.js} +27 -27
  26. package/dist/chunks/{scroll-area-C0NhSIO2.js.map → scroll-area-BboZbU1u.js.map} +1 -1
  27. package/dist/chunks/{scroll-area-JgKF61tc.js → scroll-area-DKkgpH-S.js} +3 -3
  28. package/dist/chunks/{scroll-area-JgKF61tc.js.map → scroll-area-DKkgpH-S.js.map} +1 -1
  29. package/dist/chunks/{select-DGnc8VJi.js → select-MSYUKpRI.js} +83 -439
  30. package/dist/chunks/select-MSYUKpRI.js.map +1 -0
  31. package/dist/chunks/{select-Dpyj5dUk.js → select-s-z596Y4.js} +10 -366
  32. package/dist/chunks/select-s-z596Y4.js.map +1 -0
  33. package/dist/chunks/{textarea-D2_KC-J4.js → textarea-By2Vv44z.js} +36 -587
  34. package/dist/chunks/textarea-By2Vv44z.js.map +1 -0
  35. package/dist/chunks/{textarea-_HQpXiCX.js → textarea-ClJsk9Gp.js} +35 -586
  36. package/dist/chunks/textarea-ClJsk9Gp.js.map +1 -0
  37. package/dist/chunks/tooltip-BP--5Wj2.js +525 -0
  38. package/dist/chunks/tooltip-BP--5Wj2.js.map +1 -0
  39. package/dist/chunks/tooltip-KggPQa5m.js +541 -0
  40. package/dist/chunks/tooltip-KggPQa5m.js.map +1 -0
  41. package/dist/components/calendar/date-picker/date-picker.d.ts +1 -1
  42. package/dist/components/calendar/date-picker/date-picker.d.ts.map +1 -1
  43. package/dist/components/calendar/date-picker/interface/date-picker.interface.d.ts +3 -0
  44. package/dist/components/calendar/date-picker/interface/date-picker.interface.d.ts.map +1 -1
  45. package/dist/components/tooltip/tooltip-nice.d.ts +11 -0
  46. package/dist/components/tooltip/tooltip-nice.d.ts.map +1 -0
  47. package/dist/components/tooltip/tooltip.d.ts.map +1 -1
  48. package/dist/components/ui/tooltip.d.ts +8 -0
  49. package/dist/components/ui/tooltip.d.ts.map +1 -0
  50. package/dist/divider/index.es.js +1 -1
  51. package/dist/modal/index.es.js +1 -1
  52. package/dist/pagination/index.cjs.js +2 -2
  53. package/dist/pagination/index.es.js +3 -3
  54. package/dist/phone-input/index.cjs.js +2 -2
  55. package/dist/phone-input/index.es.js +3 -3
  56. package/dist/select-input/index.cjs.js +1 -1
  57. package/dist/select-input/index.es.js +2 -2
  58. package/dist/table/index.cjs.js +1 -1
  59. package/dist/table/index.es.js +2 -2
  60. package/dist/time-input/index.cjs.js +1 -1
  61. package/dist/time-input/index.es.js +2 -2
  62. package/dist/tooltip/index.cjs.js +1 -1
  63. package/dist/tooltip/index.es.js +1 -1
  64. package/dist/ui/index.cjs.js +292 -290
  65. package/dist/ui/index.cjs.js.map +1 -1
  66. package/dist/ui/index.es.js +182 -180
  67. package/dist/ui/index.es.js.map +1 -1
  68. package/package.json +10 -9
  69. package/dist/chunks/floating-ui.react-dom-CjlUwp8V.js +0 -294
  70. package/dist/chunks/floating-ui.react-dom-CjlUwp8V.js.map +0 -1
  71. package/dist/chunks/floating-ui.react-dom-D5BI9L2i.js +0 -310
  72. package/dist/chunks/floating-ui.react-dom-D5BI9L2i.js.map +0 -1
  73. package/dist/chunks/select-DGnc8VJi.js.map +0 -1
  74. package/dist/chunks/select-Dpyj5dUk.js.map +0 -1
  75. package/dist/chunks/textarea-D2_KC-J4.js.map +0 -1
  76. package/dist/chunks/textarea-_HQpXiCX.js.map +0 -1
  77. package/dist/chunks/tooltip-GGFk8ALK.js +0 -1402
  78. package/dist/chunks/tooltip-GGFk8ALK.js.map +0 -1
  79. package/dist/chunks/tooltip-JwIbppjO.js +0 -1387
  80. package/dist/chunks/tooltip-JwIbppjO.js.map +0 -1
@@ -1,1402 +0,0 @@
1
- "use strict";
2
- const jsxRuntime = require("react/jsx-runtime");
3
- const React = require("react");
4
- const floatingUi_dom = require("./floating-ui.dom-DsMDyTcd.js");
5
- require("react-dom");
6
- const floatingUi_reactDom = require("./floating-ui.react-dom-D5BI9L2i.js");
7
- const tailwindMerge = require("tailwind-merge");
8
- const clsx = require("clsx");
9
- function _interopNamespaceDefault(e) {
10
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
11
- if (e) {
12
- for (const k in e) {
13
- if (k !== "default") {
14
- const d = Object.getOwnPropertyDescriptor(e, k);
15
- Object.defineProperty(n, k, d.get ? d : {
16
- enumerable: true,
17
- get: () => e[k]
18
- });
19
- }
20
- }
21
- }
22
- n.default = e;
23
- return Object.freeze(n);
24
- }
25
- const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
26
- function getPlatform() {
27
- const uaData = navigator.userAgentData;
28
- if (uaData != null && uaData.platform) {
29
- return uaData.platform;
30
- }
31
- return navigator.platform;
32
- }
33
- function getUserAgent() {
34
- const uaData = navigator.userAgentData;
35
- if (uaData && Array.isArray(uaData.brands)) {
36
- return uaData.brands.map((_ref) => {
37
- let {
38
- brand,
39
- version
40
- } = _ref;
41
- return brand + "/" + version;
42
- }).join(" ");
43
- }
44
- return navigator.userAgent;
45
- }
46
- function isSafari() {
47
- return /apple/i.test(navigator.vendor);
48
- }
49
- function isMac() {
50
- return getPlatform().toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
51
- }
52
- function isJSDOM() {
53
- return getUserAgent().includes("jsdom/");
54
- }
55
- const FOCUSABLE_ATTRIBUTE$1 = "data-floating-ui-focusable";
56
- const TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
57
- function activeElement(doc) {
58
- let activeElement2 = doc.activeElement;
59
- while (((_activeElement = activeElement2) == null || (_activeElement = _activeElement.shadowRoot) == null ? void 0 : _activeElement.activeElement) != null) {
60
- var _activeElement;
61
- activeElement2 = activeElement2.shadowRoot.activeElement;
62
- }
63
- return activeElement2;
64
- }
65
- function contains(parent, child) {
66
- if (!parent || !child) {
67
- return false;
68
- }
69
- const rootNode = child.getRootNode == null ? void 0 : child.getRootNode();
70
- if (parent.contains(child)) {
71
- return true;
72
- }
73
- if (rootNode && floatingUi_dom.isShadowRoot(rootNode)) {
74
- let next = child;
75
- while (next) {
76
- if (parent === next) {
77
- return true;
78
- }
79
- next = next.parentNode || next.host;
80
- }
81
- }
82
- return false;
83
- }
84
- function getTarget(event) {
85
- if ("composedPath" in event) {
86
- return event.composedPath()[0];
87
- }
88
- return event.target;
89
- }
90
- function isEventTargetWithin(event, node) {
91
- if (node == null) {
92
- return false;
93
- }
94
- if ("composedPath" in event) {
95
- return event.composedPath().includes(node);
96
- }
97
- const e = event;
98
- return e.target != null && node.contains(e.target);
99
- }
100
- function isRootElement(element) {
101
- return element.matches("html,body");
102
- }
103
- function getDocument(node) {
104
- return (node == null ? void 0 : node.ownerDocument) || document;
105
- }
106
- function isTypeableElement(element) {
107
- return floatingUi_dom.isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
108
- }
109
- function matchesFocusVisible(element) {
110
- if (!element || isJSDOM()) return true;
111
- try {
112
- return element.matches(":focus-visible");
113
- } catch (_e) {
114
- return true;
115
- }
116
- }
117
- function getFloatingFocusElement(floatingElement) {
118
- if (!floatingElement) {
119
- return null;
120
- }
121
- return floatingElement.hasAttribute(FOCUSABLE_ATTRIBUTE$1) ? floatingElement : floatingElement.querySelector("[" + FOCUSABLE_ATTRIBUTE$1 + "]") || floatingElement;
122
- }
123
- function getNodeChildren(nodes, id, onlyOpenChildren) {
124
- if (onlyOpenChildren === void 0) {
125
- onlyOpenChildren = true;
126
- }
127
- const directChildren = nodes.filter((node) => {
128
- var _node$context;
129
- return node.parentId === id && (!onlyOpenChildren || ((_node$context = node.context) == null ? void 0 : _node$context.open));
130
- });
131
- return directChildren.flatMap((child) => [child, ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
132
- }
133
- function isReactEvent(event) {
134
- return "nativeEvent" in event;
135
- }
136
- function isMouseLikePointerType(pointerType, strict) {
137
- const values = ["mouse", "pen"];
138
- {
139
- values.push("", void 0);
140
- }
141
- return values.includes(pointerType);
142
- }
143
- var isClient = typeof document !== "undefined";
144
- var noop = function noop2() {
145
- };
146
- var index = isClient ? React.useLayoutEffect : noop;
147
- const SafeReact$1 = {
148
- ...React__namespace
149
- };
150
- function useLatestRef(value) {
151
- const ref = React__namespace.useRef(value);
152
- index(() => {
153
- ref.current = value;
154
- });
155
- return ref;
156
- }
157
- const useInsertionEffect = SafeReact$1.useInsertionEffect;
158
- const useSafeInsertionEffect = useInsertionEffect || ((fn) => fn());
159
- function useEffectEvent(callback) {
160
- const ref = React__namespace.useRef(() => {
161
- if (process.env.NODE_ENV !== "production") {
162
- throw new Error("Cannot call an event handler while rendering.");
163
- }
164
- });
165
- useSafeInsertionEffect(() => {
166
- ref.current = callback;
167
- });
168
- return React__namespace.useCallback(function() {
169
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
170
- args[_key] = arguments[_key];
171
- }
172
- return ref.current == null ? void 0 : ref.current(...args);
173
- }, []);
174
- }
175
- const FOCUSABLE_ATTRIBUTE = "data-floating-ui-focusable";
176
- const ACTIVE_KEY = "active";
177
- const SELECTED_KEY = "selected";
178
- const SafeReact = {
179
- ...React__namespace
180
- };
181
- let serverHandoffComplete = false;
182
- let count = 0;
183
- const genId = () => (
184
- // Ensure the id is unique with multiple independent versions of Floating UI
185
- // on <React 18
186
- "floating-ui-" + Math.random().toString(36).slice(2, 6) + count++
187
- );
188
- function useFloatingId() {
189
- const [id, setId] = React__namespace.useState(() => serverHandoffComplete ? genId() : void 0);
190
- index(() => {
191
- if (id == null) {
192
- setId(genId());
193
- }
194
- }, []);
195
- React__namespace.useEffect(() => {
196
- serverHandoffComplete = true;
197
- }, []);
198
- return id;
199
- }
200
- const useReactId = SafeReact.useId;
201
- const useId = useReactId || useFloatingId;
202
- let devMessageSet;
203
- if (process.env.NODE_ENV !== "production") {
204
- devMessageSet = /* @__PURE__ */ new Set();
205
- }
206
- function warn() {
207
- var _devMessageSet;
208
- for (var _len = arguments.length, messages = new Array(_len), _key = 0; _key < _len; _key++) {
209
- messages[_key] = arguments[_key];
210
- }
211
- const message = "Floating UI: " + messages.join(" ");
212
- if (!((_devMessageSet = devMessageSet) != null && _devMessageSet.has(message))) {
213
- var _devMessageSet2;
214
- (_devMessageSet2 = devMessageSet) == null || _devMessageSet2.add(message);
215
- }
216
- }
217
- function error() {
218
- var _devMessageSet3;
219
- for (var _len2 = arguments.length, messages = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
220
- messages[_key2] = arguments[_key2];
221
- }
222
- const message = "Floating UI: " + messages.join(" ");
223
- if (!((_devMessageSet3 = devMessageSet) != null && _devMessageSet3.has(message))) {
224
- var _devMessageSet4;
225
- (_devMessageSet4 = devMessageSet) == null || _devMessageSet4.add(message);
226
- }
227
- }
228
- const FloatingArrow = /* @__PURE__ */ React__namespace.forwardRef(function FloatingArrow2(props, ref) {
229
- const {
230
- context: {
231
- placement,
232
- elements: {
233
- floating
234
- },
235
- middlewareData: {
236
- arrow,
237
- shift
238
- }
239
- },
240
- width = 14,
241
- height = 7,
242
- tipRadius = 0,
243
- strokeWidth = 0,
244
- staticOffset,
245
- stroke,
246
- d,
247
- style: {
248
- transform,
249
- ...restStyle
250
- } = {},
251
- ...rest
252
- } = props;
253
- if (process.env.NODE_ENV !== "production") {
254
- if (!ref) {
255
- warn("The `ref` prop is required for `FloatingArrow`.");
256
- }
257
- }
258
- const clipPathId = useId();
259
- const [isRTL, setIsRTL] = React__namespace.useState(false);
260
- index(() => {
261
- if (!floating) return;
262
- const isRTL2 = floatingUi_dom.getComputedStyle(floating).direction === "rtl";
263
- if (isRTL2) {
264
- setIsRTL(true);
265
- }
266
- }, [floating]);
267
- if (!floating) {
268
- return null;
269
- }
270
- const [side, alignment] = placement.split("-");
271
- const isVerticalSide = side === "top" || side === "bottom";
272
- let computedStaticOffset = staticOffset;
273
- if (isVerticalSide && shift != null && shift.x || !isVerticalSide && shift != null && shift.y) {
274
- computedStaticOffset = null;
275
- }
276
- const computedStrokeWidth = strokeWidth * 2;
277
- const halfStrokeWidth = computedStrokeWidth / 2;
278
- const svgX = width / 2 * (tipRadius / -8 + 1);
279
- const svgY = height / 2 * tipRadius / 4;
280
- const isCustomShape = !!d;
281
- const yOffsetProp = computedStaticOffset && alignment === "end" ? "bottom" : "top";
282
- let xOffsetProp = computedStaticOffset && alignment === "end" ? "right" : "left";
283
- if (computedStaticOffset && isRTL) {
284
- xOffsetProp = alignment === "end" ? "left" : "right";
285
- }
286
- const arrowX = (arrow == null ? void 0 : arrow.x) != null ? computedStaticOffset || arrow.x : "";
287
- const arrowY = (arrow == null ? void 0 : arrow.y) != null ? computedStaticOffset || arrow.y : "";
288
- const dValue = d || "M0,0" + (" H" + width) + (" L" + (width - svgX) + "," + (height - svgY)) + (" Q" + width / 2 + "," + height + " " + svgX + "," + (height - svgY)) + " Z";
289
- const rotation = {
290
- top: isCustomShape ? "rotate(180deg)" : "",
291
- left: isCustomShape ? "rotate(90deg)" : "rotate(-90deg)",
292
- bottom: isCustomShape ? "" : "rotate(180deg)",
293
- right: isCustomShape ? "rotate(-90deg)" : "rotate(90deg)"
294
- }[side];
295
- return /* @__PURE__ */ jsxRuntime.jsxs("svg", {
296
- ...rest,
297
- "aria-hidden": true,
298
- ref,
299
- width: isCustomShape ? width : width + computedStrokeWidth,
300
- height: width,
301
- viewBox: "0 0 " + width + " " + (height > width ? height : width),
302
- style: {
303
- position: "absolute",
304
- pointerEvents: "none",
305
- [xOffsetProp]: arrowX,
306
- [yOffsetProp]: arrowY,
307
- [side]: isVerticalSide || isCustomShape ? "100%" : "calc(100% - " + computedStrokeWidth / 2 + "px)",
308
- transform: [rotation, transform].filter((t) => !!t).join(" "),
309
- ...restStyle
310
- },
311
- children: [computedStrokeWidth > 0 && /* @__PURE__ */ jsxRuntime.jsx("path", {
312
- clipPath: "url(#" + clipPathId + ")",
313
- fill: "none",
314
- stroke,
315
- strokeWidth: computedStrokeWidth + (d ? 0 : 1),
316
- d: dValue
317
- }), /* @__PURE__ */ jsxRuntime.jsx("path", {
318
- stroke: computedStrokeWidth && !d ? rest.fill : "none",
319
- d: dValue
320
- }), /* @__PURE__ */ jsxRuntime.jsx("clipPath", {
321
- id: clipPathId,
322
- children: /* @__PURE__ */ jsxRuntime.jsx("rect", {
323
- x: -halfStrokeWidth,
324
- y: halfStrokeWidth * (isCustomShape ? -1 : 1),
325
- width: width + computedStrokeWidth,
326
- height: width
327
- })
328
- })]
329
- });
330
- });
331
- function createEventEmitter() {
332
- const map = /* @__PURE__ */ new Map();
333
- return {
334
- emit(event, data) {
335
- var _map$get;
336
- (_map$get = map.get(event)) == null || _map$get.forEach((listener) => listener(data));
337
- },
338
- on(event, listener) {
339
- if (!map.has(event)) {
340
- map.set(event, /* @__PURE__ */ new Set());
341
- }
342
- map.get(event).add(listener);
343
- },
344
- off(event, listener) {
345
- var _map$get2;
346
- (_map$get2 = map.get(event)) == null || _map$get2.delete(listener);
347
- }
348
- };
349
- }
350
- const FloatingNodeContext = /* @__PURE__ */ React__namespace.createContext(null);
351
- const FloatingTreeContext = /* @__PURE__ */ React__namespace.createContext(null);
352
- const useFloatingParentNodeId = () => {
353
- var _React$useContext;
354
- return ((_React$useContext = React__namespace.useContext(FloatingNodeContext)) == null ? void 0 : _React$useContext.id) || null;
355
- };
356
- const useFloatingTree = () => React__namespace.useContext(FloatingTreeContext);
357
- function createAttribute(name) {
358
- return "data-floating-ui-" + name;
359
- }
360
- function clearTimeoutIfSet(timeoutRef) {
361
- if (timeoutRef.current !== -1) {
362
- clearTimeout(timeoutRef.current);
363
- timeoutRef.current = -1;
364
- }
365
- }
366
- const safePolygonIdentifier = /* @__PURE__ */ createAttribute("safe-polygon");
367
- function getDelay(value, prop, pointerType) {
368
- if (pointerType && !isMouseLikePointerType(pointerType)) {
369
- return 0;
370
- }
371
- if (typeof value === "number") {
372
- return value;
373
- }
374
- if (typeof value === "function") {
375
- const result = value();
376
- if (typeof result === "number") {
377
- return result;
378
- }
379
- return result == null ? void 0 : result[prop];
380
- }
381
- return value == null ? void 0 : value[prop];
382
- }
383
- function getRestMs(value) {
384
- if (typeof value === "function") {
385
- return value();
386
- }
387
- return value;
388
- }
389
- function useHover(context, props) {
390
- if (props === void 0) {
391
- props = {};
392
- }
393
- const {
394
- open,
395
- onOpenChange,
396
- dataRef,
397
- events,
398
- elements
399
- } = context;
400
- const {
401
- enabled = true,
402
- delay = 0,
403
- handleClose = null,
404
- mouseOnly = false,
405
- restMs = 0,
406
- move = true
407
- } = props;
408
- const tree = useFloatingTree();
409
- const parentId = useFloatingParentNodeId();
410
- const handleCloseRef = useLatestRef(handleClose);
411
- const delayRef = useLatestRef(delay);
412
- const openRef = useLatestRef(open);
413
- const restMsRef = useLatestRef(restMs);
414
- const pointerTypeRef = React__namespace.useRef();
415
- const timeoutRef = React__namespace.useRef(-1);
416
- const handlerRef = React__namespace.useRef();
417
- const restTimeoutRef = React__namespace.useRef(-1);
418
- const blockMouseMoveRef = React__namespace.useRef(true);
419
- const performedPointerEventsMutationRef = React__namespace.useRef(false);
420
- const unbindMouseMoveRef = React__namespace.useRef(() => {
421
- });
422
- const restTimeoutPendingRef = React__namespace.useRef(false);
423
- const isHoverOpen = useEffectEvent(() => {
424
- var _dataRef$current$open;
425
- const type = (_dataRef$current$open = dataRef.current.openEvent) == null ? void 0 : _dataRef$current$open.type;
426
- return (type == null ? void 0 : type.includes("mouse")) && type !== "mousedown";
427
- });
428
- React__namespace.useEffect(() => {
429
- if (!enabled) return;
430
- function onOpenChange2(_ref) {
431
- let {
432
- open: open2
433
- } = _ref;
434
- if (!open2) {
435
- clearTimeoutIfSet(timeoutRef);
436
- clearTimeoutIfSet(restTimeoutRef);
437
- blockMouseMoveRef.current = true;
438
- restTimeoutPendingRef.current = false;
439
- }
440
- }
441
- events.on("openchange", onOpenChange2);
442
- return () => {
443
- events.off("openchange", onOpenChange2);
444
- };
445
- }, [enabled, events]);
446
- React__namespace.useEffect(() => {
447
- if (!enabled) return;
448
- if (!handleCloseRef.current) return;
449
- if (!open) return;
450
- function onLeave(event) {
451
- if (isHoverOpen()) {
452
- onOpenChange(false, event, "hover");
453
- }
454
- }
455
- const html = getDocument(elements.floating).documentElement;
456
- html.addEventListener("mouseleave", onLeave);
457
- return () => {
458
- html.removeEventListener("mouseleave", onLeave);
459
- };
460
- }, [elements.floating, open, onOpenChange, enabled, handleCloseRef, isHoverOpen]);
461
- const closeWithDelay = React__namespace.useCallback(function(event, runElseBranch, reason) {
462
- if (runElseBranch === void 0) {
463
- runElseBranch = true;
464
- }
465
- if (reason === void 0) {
466
- reason = "hover";
467
- }
468
- const closeDelay = getDelay(delayRef.current, "close", pointerTypeRef.current);
469
- if (closeDelay && !handlerRef.current) {
470
- clearTimeoutIfSet(timeoutRef);
471
- timeoutRef.current = window.setTimeout(() => onOpenChange(false, event, reason), closeDelay);
472
- } else if (runElseBranch) {
473
- clearTimeoutIfSet(timeoutRef);
474
- onOpenChange(false, event, reason);
475
- }
476
- }, [delayRef, onOpenChange]);
477
- const cleanupMouseMoveHandler = useEffectEvent(() => {
478
- unbindMouseMoveRef.current();
479
- handlerRef.current = void 0;
480
- });
481
- const clearPointerEvents = useEffectEvent(() => {
482
- if (performedPointerEventsMutationRef.current) {
483
- const body = getDocument(elements.floating).body;
484
- body.style.pointerEvents = "";
485
- body.removeAttribute(safePolygonIdentifier);
486
- performedPointerEventsMutationRef.current = false;
487
- }
488
- });
489
- const isClickLikeOpenEvent = useEffectEvent(() => {
490
- return dataRef.current.openEvent ? ["click", "mousedown"].includes(dataRef.current.openEvent.type) : false;
491
- });
492
- React__namespace.useEffect(() => {
493
- if (!enabled) return;
494
- function onReferenceMouseEnter(event) {
495
- clearTimeoutIfSet(timeoutRef);
496
- blockMouseMoveRef.current = false;
497
- if (mouseOnly && !isMouseLikePointerType(pointerTypeRef.current) || getRestMs(restMsRef.current) > 0 && !getDelay(delayRef.current, "open")) {
498
- return;
499
- }
500
- const openDelay = getDelay(delayRef.current, "open", pointerTypeRef.current);
501
- if (openDelay) {
502
- timeoutRef.current = window.setTimeout(() => {
503
- if (!openRef.current) {
504
- onOpenChange(true, event, "hover");
505
- }
506
- }, openDelay);
507
- } else if (!open) {
508
- onOpenChange(true, event, "hover");
509
- }
510
- }
511
- function onReferenceMouseLeave(event) {
512
- if (isClickLikeOpenEvent()) {
513
- clearPointerEvents();
514
- return;
515
- }
516
- unbindMouseMoveRef.current();
517
- const doc = getDocument(elements.floating);
518
- clearTimeoutIfSet(restTimeoutRef);
519
- restTimeoutPendingRef.current = false;
520
- if (handleCloseRef.current && dataRef.current.floatingContext) {
521
- if (!open) {
522
- clearTimeoutIfSet(timeoutRef);
523
- }
524
- handlerRef.current = handleCloseRef.current({
525
- ...dataRef.current.floatingContext,
526
- tree,
527
- x: event.clientX,
528
- y: event.clientY,
529
- onClose() {
530
- clearPointerEvents();
531
- cleanupMouseMoveHandler();
532
- if (!isClickLikeOpenEvent()) {
533
- closeWithDelay(event, true, "safe-polygon");
534
- }
535
- }
536
- });
537
- const handler = handlerRef.current;
538
- doc.addEventListener("mousemove", handler);
539
- unbindMouseMoveRef.current = () => {
540
- doc.removeEventListener("mousemove", handler);
541
- };
542
- return;
543
- }
544
- const shouldClose = pointerTypeRef.current === "touch" ? !contains(elements.floating, event.relatedTarget) : true;
545
- if (shouldClose) {
546
- closeWithDelay(event);
547
- }
548
- }
549
- function onScrollMouseLeave(event) {
550
- if (isClickLikeOpenEvent()) return;
551
- if (!dataRef.current.floatingContext) return;
552
- handleCloseRef.current == null || handleCloseRef.current({
553
- ...dataRef.current.floatingContext,
554
- tree,
555
- x: event.clientX,
556
- y: event.clientY,
557
- onClose() {
558
- clearPointerEvents();
559
- cleanupMouseMoveHandler();
560
- if (!isClickLikeOpenEvent()) {
561
- closeWithDelay(event);
562
- }
563
- }
564
- })(event);
565
- }
566
- function onFloatingMouseEnter() {
567
- clearTimeoutIfSet(timeoutRef);
568
- }
569
- function onFloatingMouseLeave(event) {
570
- if (!isClickLikeOpenEvent()) {
571
- closeWithDelay(event, false);
572
- }
573
- }
574
- if (floatingUi_dom.isElement(elements.domReference)) {
575
- const reference2 = elements.domReference;
576
- const floating = elements.floating;
577
- if (open) {
578
- reference2.addEventListener("mouseleave", onScrollMouseLeave);
579
- }
580
- if (move) {
581
- reference2.addEventListener("mousemove", onReferenceMouseEnter, {
582
- once: true
583
- });
584
- }
585
- reference2.addEventListener("mouseenter", onReferenceMouseEnter);
586
- reference2.addEventListener("mouseleave", onReferenceMouseLeave);
587
- if (floating) {
588
- floating.addEventListener("mouseleave", onScrollMouseLeave);
589
- floating.addEventListener("mouseenter", onFloatingMouseEnter);
590
- floating.addEventListener("mouseleave", onFloatingMouseLeave);
591
- }
592
- return () => {
593
- if (open) {
594
- reference2.removeEventListener("mouseleave", onScrollMouseLeave);
595
- }
596
- if (move) {
597
- reference2.removeEventListener("mousemove", onReferenceMouseEnter);
598
- }
599
- reference2.removeEventListener("mouseenter", onReferenceMouseEnter);
600
- reference2.removeEventListener("mouseleave", onReferenceMouseLeave);
601
- if (floating) {
602
- floating.removeEventListener("mouseleave", onScrollMouseLeave);
603
- floating.removeEventListener("mouseenter", onFloatingMouseEnter);
604
- floating.removeEventListener("mouseleave", onFloatingMouseLeave);
605
- }
606
- };
607
- }
608
- }, [elements, enabled, context, mouseOnly, move, closeWithDelay, cleanupMouseMoveHandler, clearPointerEvents, onOpenChange, open, openRef, tree, delayRef, handleCloseRef, dataRef, isClickLikeOpenEvent, restMsRef]);
609
- index(() => {
610
- var _handleCloseRef$curre;
611
- if (!enabled) return;
612
- if (open && (_handleCloseRef$curre = handleCloseRef.current) != null && (_handleCloseRef$curre = _handleCloseRef$curre.__options) != null && _handleCloseRef$curre.blockPointerEvents && isHoverOpen()) {
613
- performedPointerEventsMutationRef.current = true;
614
- const floatingEl = elements.floating;
615
- if (floatingUi_dom.isElement(elements.domReference) && floatingEl) {
616
- var _tree$nodesRef$curren;
617
- const body = getDocument(elements.floating).body;
618
- body.setAttribute(safePolygonIdentifier, "");
619
- const ref = elements.domReference;
620
- const parentFloating = tree == null || (_tree$nodesRef$curren = tree.nodesRef.current.find((node) => node.id === parentId)) == null || (_tree$nodesRef$curren = _tree$nodesRef$curren.context) == null ? void 0 : _tree$nodesRef$curren.elements.floating;
621
- if (parentFloating) {
622
- parentFloating.style.pointerEvents = "";
623
- }
624
- body.style.pointerEvents = "none";
625
- ref.style.pointerEvents = "auto";
626
- floatingEl.style.pointerEvents = "auto";
627
- return () => {
628
- body.style.pointerEvents = "";
629
- ref.style.pointerEvents = "";
630
- floatingEl.style.pointerEvents = "";
631
- };
632
- }
633
- }
634
- }, [enabled, open, parentId, elements, tree, handleCloseRef, isHoverOpen]);
635
- index(() => {
636
- if (!open) {
637
- pointerTypeRef.current = void 0;
638
- restTimeoutPendingRef.current = false;
639
- cleanupMouseMoveHandler();
640
- clearPointerEvents();
641
- }
642
- }, [open, cleanupMouseMoveHandler, clearPointerEvents]);
643
- React__namespace.useEffect(() => {
644
- return () => {
645
- cleanupMouseMoveHandler();
646
- clearTimeoutIfSet(timeoutRef);
647
- clearTimeoutIfSet(restTimeoutRef);
648
- clearPointerEvents();
649
- };
650
- }, [enabled, elements.domReference, cleanupMouseMoveHandler, clearPointerEvents]);
651
- const reference = React__namespace.useMemo(() => {
652
- function setPointerRef(event) {
653
- pointerTypeRef.current = event.pointerType;
654
- }
655
- return {
656
- onPointerDown: setPointerRef,
657
- onPointerEnter: setPointerRef,
658
- onMouseMove(event) {
659
- const {
660
- nativeEvent
661
- } = event;
662
- function handleMouseMove() {
663
- if (!blockMouseMoveRef.current && !openRef.current) {
664
- onOpenChange(true, nativeEvent, "hover");
665
- }
666
- }
667
- if (mouseOnly && !isMouseLikePointerType(pointerTypeRef.current)) {
668
- return;
669
- }
670
- if (open || getRestMs(restMsRef.current) === 0) {
671
- return;
672
- }
673
- if (restTimeoutPendingRef.current && event.movementX ** 2 + event.movementY ** 2 < 2) {
674
- return;
675
- }
676
- clearTimeoutIfSet(restTimeoutRef);
677
- if (pointerTypeRef.current === "touch") {
678
- handleMouseMove();
679
- } else {
680
- restTimeoutPendingRef.current = true;
681
- restTimeoutRef.current = window.setTimeout(handleMouseMove, getRestMs(restMsRef.current));
682
- }
683
- }
684
- };
685
- }, [mouseOnly, onOpenChange, open, openRef, restMsRef]);
686
- return React__namespace.useMemo(() => enabled ? {
687
- reference
688
- } : {}, [enabled, reference]);
689
- }
690
- const bubbleHandlerKeys = {
691
- pointerdown: "onPointerDown",
692
- mousedown: "onMouseDown",
693
- click: "onClick"
694
- };
695
- const captureHandlerKeys = {
696
- pointerdown: "onPointerDownCapture",
697
- mousedown: "onMouseDownCapture",
698
- click: "onClickCapture"
699
- };
700
- const normalizeProp = (normalizable) => {
701
- var _normalizable$escapeK, _normalizable$outside;
702
- return {
703
- escapeKey: typeof normalizable === "boolean" ? normalizable : (_normalizable$escapeK = normalizable == null ? void 0 : normalizable.escapeKey) != null ? _normalizable$escapeK : false,
704
- outsidePress: typeof normalizable === "boolean" ? normalizable : (_normalizable$outside = normalizable == null ? void 0 : normalizable.outsidePress) != null ? _normalizable$outside : true
705
- };
706
- };
707
- function useDismiss(context, props) {
708
- if (props === void 0) {
709
- props = {};
710
- }
711
- const {
712
- open,
713
- onOpenChange,
714
- elements,
715
- dataRef
716
- } = context;
717
- const {
718
- enabled = true,
719
- escapeKey = true,
720
- outsidePress: unstable_outsidePress = true,
721
- outsidePressEvent = "pointerdown",
722
- referencePress = false,
723
- referencePressEvent = "pointerdown",
724
- ancestorScroll = false,
725
- bubbles,
726
- capture
727
- } = props;
728
- const tree = useFloatingTree();
729
- const outsidePressFn = useEffectEvent(typeof unstable_outsidePress === "function" ? unstable_outsidePress : () => false);
730
- const outsidePress = typeof unstable_outsidePress === "function" ? outsidePressFn : unstable_outsidePress;
731
- const endedOrStartedInsideRef = React__namespace.useRef(false);
732
- const {
733
- escapeKey: escapeKeyBubbles,
734
- outsidePress: outsidePressBubbles
735
- } = normalizeProp(bubbles);
736
- const {
737
- escapeKey: escapeKeyCapture,
738
- outsidePress: outsidePressCapture
739
- } = normalizeProp(capture);
740
- const isComposingRef = React__namespace.useRef(false);
741
- const closeOnEscapeKeyDown = useEffectEvent((event) => {
742
- var _dataRef$current$floa;
743
- if (!open || !enabled || !escapeKey || event.key !== "Escape") {
744
- return;
745
- }
746
- if (isComposingRef.current) {
747
- return;
748
- }
749
- const nodeId = (_dataRef$current$floa = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa.nodeId;
750
- const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
751
- if (!escapeKeyBubbles) {
752
- event.stopPropagation();
753
- if (children.length > 0) {
754
- let shouldDismiss = true;
755
- children.forEach((child) => {
756
- var _child$context;
757
- if ((_child$context = child.context) != null && _child$context.open && !child.context.dataRef.current.__escapeKeyBubbles) {
758
- shouldDismiss = false;
759
- return;
760
- }
761
- });
762
- if (!shouldDismiss) {
763
- return;
764
- }
765
- }
766
- }
767
- onOpenChange(false, isReactEvent(event) ? event.nativeEvent : event, "escape-key");
768
- });
769
- const closeOnEscapeKeyDownCapture = useEffectEvent((event) => {
770
- var _getTarget2;
771
- const callback = () => {
772
- var _getTarget;
773
- closeOnEscapeKeyDown(event);
774
- (_getTarget = getTarget(event)) == null || _getTarget.removeEventListener("keydown", callback);
775
- };
776
- (_getTarget2 = getTarget(event)) == null || _getTarget2.addEventListener("keydown", callback);
777
- });
778
- const closeOnPressOutside = useEffectEvent((event) => {
779
- var _dataRef$current$floa2;
780
- const insideReactTree = dataRef.current.insideReactTree;
781
- dataRef.current.insideReactTree = false;
782
- const endedOrStartedInside = endedOrStartedInsideRef.current;
783
- endedOrStartedInsideRef.current = false;
784
- if (outsidePressEvent === "click" && endedOrStartedInside) {
785
- return;
786
- }
787
- if (insideReactTree) {
788
- return;
789
- }
790
- if (typeof outsidePress === "function" && !outsidePress(event)) {
791
- return;
792
- }
793
- const target = getTarget(event);
794
- const inertSelector = "[" + createAttribute("inert") + "]";
795
- const markers = getDocument(elements.floating).querySelectorAll(inertSelector);
796
- let targetRootAncestor = floatingUi_dom.isElement(target) ? target : null;
797
- while (targetRootAncestor && !floatingUi_dom.isLastTraversableNode(targetRootAncestor)) {
798
- const nextParent = floatingUi_dom.getParentNode(targetRootAncestor);
799
- if (floatingUi_dom.isLastTraversableNode(nextParent) || !floatingUi_dom.isElement(nextParent)) {
800
- break;
801
- }
802
- targetRootAncestor = nextParent;
803
- }
804
- if (markers.length && floatingUi_dom.isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
805
- !contains(target, elements.floating) && // If the target root element contains none of the markers, then the
806
- // element was injected after the floating element rendered.
807
- Array.from(markers).every((marker) => !contains(targetRootAncestor, marker))) {
808
- return;
809
- }
810
- if (floatingUi_dom.isHTMLElement(target) && floating) {
811
- const lastTraversableNode = floatingUi_dom.isLastTraversableNode(target);
812
- const style = floatingUi_dom.getComputedStyle(target);
813
- const scrollRe = /auto|scroll/;
814
- const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
815
- const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
816
- const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
817
- const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
818
- const isRTL = style.direction === "rtl";
819
- const pressedVerticalScrollbar = canScrollY && (isRTL ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
820
- const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
821
- if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
822
- return;
823
- }
824
- }
825
- const nodeId = (_dataRef$current$floa2 = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa2.nodeId;
826
- const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => {
827
- var _node$context;
828
- return isEventTargetWithin(event, (_node$context = node.context) == null ? void 0 : _node$context.elements.floating);
829
- });
830
- if (isEventTargetWithin(event, elements.floating) || isEventTargetWithin(event, elements.domReference) || targetIsInsideChildren) {
831
- return;
832
- }
833
- const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
834
- if (children.length > 0) {
835
- let shouldDismiss = true;
836
- children.forEach((child) => {
837
- var _child$context2;
838
- if ((_child$context2 = child.context) != null && _child$context2.open && !child.context.dataRef.current.__outsidePressBubbles) {
839
- shouldDismiss = false;
840
- return;
841
- }
842
- });
843
- if (!shouldDismiss) {
844
- return;
845
- }
846
- }
847
- onOpenChange(false, event, "outside-press");
848
- });
849
- const closeOnPressOutsideCapture = useEffectEvent((event) => {
850
- var _getTarget4;
851
- const callback = () => {
852
- var _getTarget3;
853
- closeOnPressOutside(event);
854
- (_getTarget3 = getTarget(event)) == null || _getTarget3.removeEventListener(outsidePressEvent, callback);
855
- };
856
- (_getTarget4 = getTarget(event)) == null || _getTarget4.addEventListener(outsidePressEvent, callback);
857
- });
858
- React__namespace.useEffect(() => {
859
- if (!open || !enabled) {
860
- return;
861
- }
862
- dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
863
- dataRef.current.__outsidePressBubbles = outsidePressBubbles;
864
- let compositionTimeout = -1;
865
- function onScroll(event) {
866
- onOpenChange(false, event, "ancestor-scroll");
867
- }
868
- function handleCompositionStart() {
869
- window.clearTimeout(compositionTimeout);
870
- isComposingRef.current = true;
871
- }
872
- function handleCompositionEnd() {
873
- compositionTimeout = window.setTimeout(
874
- () => {
875
- isComposingRef.current = false;
876
- },
877
- // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
878
- // Only apply to WebKit for the test to remain 0ms.
879
- floatingUi_dom.isWebKit() ? 5 : 0
880
- );
881
- }
882
- const doc = getDocument(elements.floating);
883
- if (escapeKey) {
884
- doc.addEventListener("keydown", escapeKeyCapture ? closeOnEscapeKeyDownCapture : closeOnEscapeKeyDown, escapeKeyCapture);
885
- doc.addEventListener("compositionstart", handleCompositionStart);
886
- doc.addEventListener("compositionend", handleCompositionEnd);
887
- }
888
- outsidePress && doc.addEventListener(outsidePressEvent, outsidePressCapture ? closeOnPressOutsideCapture : closeOnPressOutside, outsidePressCapture);
889
- let ancestors = [];
890
- if (ancestorScroll) {
891
- if (floatingUi_dom.isElement(elements.domReference)) {
892
- ancestors = floatingUi_dom.getOverflowAncestors(elements.domReference);
893
- }
894
- if (floatingUi_dom.isElement(elements.floating)) {
895
- ancestors = ancestors.concat(floatingUi_dom.getOverflowAncestors(elements.floating));
896
- }
897
- if (!floatingUi_dom.isElement(elements.reference) && elements.reference && elements.reference.contextElement) {
898
- ancestors = ancestors.concat(floatingUi_dom.getOverflowAncestors(elements.reference.contextElement));
899
- }
900
- }
901
- ancestors = ancestors.filter((ancestor) => {
902
- var _doc$defaultView;
903
- return ancestor !== ((_doc$defaultView = doc.defaultView) == null ? void 0 : _doc$defaultView.visualViewport);
904
- });
905
- ancestors.forEach((ancestor) => {
906
- ancestor.addEventListener("scroll", onScroll, {
907
- passive: true
908
- });
909
- });
910
- return () => {
911
- if (escapeKey) {
912
- doc.removeEventListener("keydown", escapeKeyCapture ? closeOnEscapeKeyDownCapture : closeOnEscapeKeyDown, escapeKeyCapture);
913
- doc.removeEventListener("compositionstart", handleCompositionStart);
914
- doc.removeEventListener("compositionend", handleCompositionEnd);
915
- }
916
- outsidePress && doc.removeEventListener(outsidePressEvent, outsidePressCapture ? closeOnPressOutsideCapture : closeOnPressOutside, outsidePressCapture);
917
- ancestors.forEach((ancestor) => {
918
- ancestor.removeEventListener("scroll", onScroll);
919
- });
920
- window.clearTimeout(compositionTimeout);
921
- };
922
- }, [dataRef, elements, escapeKey, outsidePress, outsidePressEvent, open, onOpenChange, ancestorScroll, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, escapeKeyCapture, closeOnEscapeKeyDownCapture, closeOnPressOutside, outsidePressCapture, closeOnPressOutsideCapture]);
923
- React__namespace.useEffect(() => {
924
- dataRef.current.insideReactTree = false;
925
- }, [dataRef, outsidePress, outsidePressEvent]);
926
- const reference = React__namespace.useMemo(() => ({
927
- onKeyDown: closeOnEscapeKeyDown,
928
- ...referencePress && {
929
- [bubbleHandlerKeys[referencePressEvent]]: (event) => {
930
- onOpenChange(false, event.nativeEvent, "reference-press");
931
- },
932
- ...referencePressEvent !== "click" && {
933
- onClick(event) {
934
- onOpenChange(false, event.nativeEvent, "reference-press");
935
- }
936
- }
937
- }
938
- }), [closeOnEscapeKeyDown, onOpenChange, referencePress, referencePressEvent]);
939
- const floating = React__namespace.useMemo(() => ({
940
- onKeyDown: closeOnEscapeKeyDown,
941
- onMouseDown() {
942
- endedOrStartedInsideRef.current = true;
943
- },
944
- onMouseUp() {
945
- endedOrStartedInsideRef.current = true;
946
- },
947
- [captureHandlerKeys[outsidePressEvent]]: () => {
948
- dataRef.current.insideReactTree = true;
949
- }
950
- }), [closeOnEscapeKeyDown, outsidePressEvent, dataRef]);
951
- return React__namespace.useMemo(() => enabled ? {
952
- reference,
953
- floating
954
- } : {}, [enabled, reference, floating]);
955
- }
956
- function useFloatingRootContext(options) {
957
- const {
958
- open = false,
959
- onOpenChange: onOpenChangeProp,
960
- elements: elementsProp
961
- } = options;
962
- const floatingId = useId();
963
- const dataRef = React__namespace.useRef({});
964
- const [events] = React__namespace.useState(() => createEventEmitter());
965
- const nested = useFloatingParentNodeId() != null;
966
- if (process.env.NODE_ENV !== "production") {
967
- const optionDomReference = elementsProp.reference;
968
- if (optionDomReference && !floatingUi_dom.isElement(optionDomReference)) {
969
- error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `refs.setPositionReference()`", "instead.");
970
- }
971
- }
972
- const [positionReference, setPositionReference] = React__namespace.useState(elementsProp.reference);
973
- const onOpenChange = useEffectEvent((open2, event, reason) => {
974
- dataRef.current.openEvent = open2 ? event : void 0;
975
- events.emit("openchange", {
976
- open: open2,
977
- event,
978
- reason,
979
- nested
980
- });
981
- onOpenChangeProp == null || onOpenChangeProp(open2, event, reason);
982
- });
983
- const refs = React__namespace.useMemo(() => ({
984
- setPositionReference
985
- }), []);
986
- const elements = React__namespace.useMemo(() => ({
987
- reference: positionReference || elementsProp.reference || null,
988
- floating: elementsProp.floating || null,
989
- domReference: elementsProp.reference
990
- }), [positionReference, elementsProp.reference, elementsProp.floating]);
991
- return React__namespace.useMemo(() => ({
992
- dataRef,
993
- open,
994
- onOpenChange,
995
- elements,
996
- events,
997
- floatingId,
998
- refs
999
- }), [open, onOpenChange, elements, events, floatingId, refs]);
1000
- }
1001
- function useFloating(options) {
1002
- if (options === void 0) {
1003
- options = {};
1004
- }
1005
- const {
1006
- nodeId
1007
- } = options;
1008
- const internalRootContext = useFloatingRootContext({
1009
- ...options,
1010
- elements: {
1011
- reference: null,
1012
- floating: null,
1013
- ...options.elements
1014
- }
1015
- });
1016
- const rootContext = options.rootContext || internalRootContext;
1017
- const computedElements = rootContext.elements;
1018
- const [_domReference, setDomReference] = React__namespace.useState(null);
1019
- const [positionReference, _setPositionReference] = React__namespace.useState(null);
1020
- const optionDomReference = computedElements == null ? void 0 : computedElements.domReference;
1021
- const domReference = optionDomReference || _domReference;
1022
- const domReferenceRef = React__namespace.useRef(null);
1023
- const tree = useFloatingTree();
1024
- index(() => {
1025
- if (domReference) {
1026
- domReferenceRef.current = domReference;
1027
- }
1028
- }, [domReference]);
1029
- const position = floatingUi_reactDom.useFloating({
1030
- ...options,
1031
- elements: {
1032
- ...computedElements,
1033
- ...positionReference && {
1034
- reference: positionReference
1035
- }
1036
- }
1037
- });
1038
- const setPositionReference = React__namespace.useCallback((node) => {
1039
- const computedPositionReference = floatingUi_dom.isElement(node) ? {
1040
- getBoundingClientRect: () => node.getBoundingClientRect(),
1041
- getClientRects: () => node.getClientRects(),
1042
- contextElement: node
1043
- } : node;
1044
- _setPositionReference(computedPositionReference);
1045
- position.refs.setReference(computedPositionReference);
1046
- }, [position.refs]);
1047
- const setReference = React__namespace.useCallback((node) => {
1048
- if (floatingUi_dom.isElement(node) || node === null) {
1049
- domReferenceRef.current = node;
1050
- setDomReference(node);
1051
- }
1052
- if (floatingUi_dom.isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
1053
- // `null` to support `positionReference` + an unstable `reference`
1054
- // callback ref.
1055
- node !== null && !floatingUi_dom.isElement(node)) {
1056
- position.refs.setReference(node);
1057
- }
1058
- }, [position.refs]);
1059
- const refs = React__namespace.useMemo(() => ({
1060
- ...position.refs,
1061
- setReference,
1062
- setPositionReference,
1063
- domReference: domReferenceRef
1064
- }), [position.refs, setReference, setPositionReference]);
1065
- const elements = React__namespace.useMemo(() => ({
1066
- ...position.elements,
1067
- domReference
1068
- }), [position.elements, domReference]);
1069
- const context = React__namespace.useMemo(() => ({
1070
- ...position,
1071
- ...rootContext,
1072
- refs,
1073
- elements,
1074
- nodeId
1075
- }), [position, refs, elements, nodeId, rootContext]);
1076
- index(() => {
1077
- rootContext.dataRef.current.floatingContext = context;
1078
- const node = tree == null ? void 0 : tree.nodesRef.current.find((node2) => node2.id === nodeId);
1079
- if (node) {
1080
- node.context = context;
1081
- }
1082
- });
1083
- return React__namespace.useMemo(() => ({
1084
- ...position,
1085
- context,
1086
- refs,
1087
- elements
1088
- }), [position, refs, elements, context]);
1089
- }
1090
- function isMacSafari() {
1091
- return isMac() && isSafari();
1092
- }
1093
- function useFocus(context, props) {
1094
- if (props === void 0) {
1095
- props = {};
1096
- }
1097
- const {
1098
- open,
1099
- onOpenChange,
1100
- events,
1101
- dataRef,
1102
- elements
1103
- } = context;
1104
- const {
1105
- enabled = true,
1106
- visibleOnly = true
1107
- } = props;
1108
- const blockFocusRef = React__namespace.useRef(false);
1109
- const timeoutRef = React__namespace.useRef(-1);
1110
- const keyboardModalityRef = React__namespace.useRef(true);
1111
- React__namespace.useEffect(() => {
1112
- if (!enabled) return;
1113
- const win = floatingUi_dom.getWindow(elements.domReference);
1114
- function onBlur() {
1115
- if (!open && floatingUi_dom.isHTMLElement(elements.domReference) && elements.domReference === activeElement(getDocument(elements.domReference))) {
1116
- blockFocusRef.current = true;
1117
- }
1118
- }
1119
- function onKeyDown() {
1120
- keyboardModalityRef.current = true;
1121
- }
1122
- function onPointerDown() {
1123
- keyboardModalityRef.current = false;
1124
- }
1125
- win.addEventListener("blur", onBlur);
1126
- if (isMacSafari()) {
1127
- win.addEventListener("keydown", onKeyDown, true);
1128
- win.addEventListener("pointerdown", onPointerDown, true);
1129
- }
1130
- return () => {
1131
- win.removeEventListener("blur", onBlur);
1132
- if (isMacSafari()) {
1133
- win.removeEventListener("keydown", onKeyDown, true);
1134
- win.removeEventListener("pointerdown", onPointerDown, true);
1135
- }
1136
- };
1137
- }, [elements.domReference, open, enabled]);
1138
- React__namespace.useEffect(() => {
1139
- if (!enabled) return;
1140
- function onOpenChange2(_ref) {
1141
- let {
1142
- reason
1143
- } = _ref;
1144
- if (reason === "reference-press" || reason === "escape-key") {
1145
- blockFocusRef.current = true;
1146
- }
1147
- }
1148
- events.on("openchange", onOpenChange2);
1149
- return () => {
1150
- events.off("openchange", onOpenChange2);
1151
- };
1152
- }, [events, enabled]);
1153
- React__namespace.useEffect(() => {
1154
- return () => {
1155
- clearTimeoutIfSet(timeoutRef);
1156
- };
1157
- }, []);
1158
- const reference = React__namespace.useMemo(() => ({
1159
- onMouseLeave() {
1160
- blockFocusRef.current = false;
1161
- },
1162
- onFocus(event) {
1163
- if (blockFocusRef.current) return;
1164
- const target = getTarget(event.nativeEvent);
1165
- if (visibleOnly && floatingUi_dom.isElement(target)) {
1166
- if (isMacSafari() && !event.relatedTarget) {
1167
- if (!keyboardModalityRef.current && !isTypeableElement(target)) {
1168
- return;
1169
- }
1170
- } else if (!matchesFocusVisible(target)) {
1171
- return;
1172
- }
1173
- }
1174
- onOpenChange(true, event.nativeEvent, "focus");
1175
- },
1176
- onBlur(event) {
1177
- blockFocusRef.current = false;
1178
- const relatedTarget = event.relatedTarget;
1179
- const nativeEvent = event.nativeEvent;
1180
- const movedToFocusGuard = floatingUi_dom.isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
1181
- timeoutRef.current = window.setTimeout(() => {
1182
- var _dataRef$current$floa;
1183
- const activeEl = activeElement(elements.domReference ? elements.domReference.ownerDocument : document);
1184
- if (!relatedTarget && activeEl === elements.domReference) return;
1185
- if (contains((_dataRef$current$floa = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa.refs.floating.current, activeEl) || contains(elements.domReference, activeEl) || movedToFocusGuard) {
1186
- return;
1187
- }
1188
- onOpenChange(false, nativeEvent, "focus");
1189
- });
1190
- }
1191
- }), [dataRef, elements.domReference, onOpenChange, visibleOnly]);
1192
- return React__namespace.useMemo(() => enabled ? {
1193
- reference
1194
- } : {}, [enabled, reference]);
1195
- }
1196
- function mergeProps(userProps, propsList, elementKey) {
1197
- const map = /* @__PURE__ */ new Map();
1198
- const isItem = elementKey === "item";
1199
- let domUserProps = userProps;
1200
- if (isItem && userProps) {
1201
- const {
1202
- [ACTIVE_KEY]: _,
1203
- [SELECTED_KEY]: __,
1204
- ...validProps
1205
- } = userProps;
1206
- domUserProps = validProps;
1207
- }
1208
- return {
1209
- ...elementKey === "floating" && {
1210
- tabIndex: -1,
1211
- [FOCUSABLE_ATTRIBUTE]: ""
1212
- },
1213
- ...domUserProps,
1214
- ...propsList.map((value) => {
1215
- const propsOrGetProps = value ? value[elementKey] : null;
1216
- if (typeof propsOrGetProps === "function") {
1217
- return userProps ? propsOrGetProps(userProps) : null;
1218
- }
1219
- return propsOrGetProps;
1220
- }).concat(userProps).reduce((acc, props) => {
1221
- if (!props) {
1222
- return acc;
1223
- }
1224
- Object.entries(props).forEach((_ref) => {
1225
- let [key, value] = _ref;
1226
- if (isItem && [ACTIVE_KEY, SELECTED_KEY].includes(key)) {
1227
- return;
1228
- }
1229
- if (key.indexOf("on") === 0) {
1230
- if (!map.has(key)) {
1231
- map.set(key, []);
1232
- }
1233
- if (typeof value === "function") {
1234
- var _map$get;
1235
- (_map$get = map.get(key)) == null || _map$get.push(value);
1236
- acc[key] = function() {
1237
- var _map$get2;
1238
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1239
- args[_key] = arguments[_key];
1240
- }
1241
- return (_map$get2 = map.get(key)) == null ? void 0 : _map$get2.map((fn) => fn(...args)).find((val) => val !== void 0);
1242
- };
1243
- }
1244
- } else {
1245
- acc[key] = value;
1246
- }
1247
- });
1248
- return acc;
1249
- }, {})
1250
- };
1251
- }
1252
- function useInteractions(propsList) {
1253
- if (propsList === void 0) {
1254
- propsList = [];
1255
- }
1256
- const referenceDeps = propsList.map((key) => key == null ? void 0 : key.reference);
1257
- const floatingDeps = propsList.map((key) => key == null ? void 0 : key.floating);
1258
- const itemDeps = propsList.map((key) => key == null ? void 0 : key.item);
1259
- const getReferenceProps = React__namespace.useCallback(
1260
- (userProps) => mergeProps(userProps, propsList, "reference"),
1261
- // eslint-disable-next-line react-hooks/exhaustive-deps
1262
- referenceDeps
1263
- );
1264
- const getFloatingProps = React__namespace.useCallback(
1265
- (userProps) => mergeProps(userProps, propsList, "floating"),
1266
- // eslint-disable-next-line react-hooks/exhaustive-deps
1267
- floatingDeps
1268
- );
1269
- const getItemProps = React__namespace.useCallback(
1270
- (userProps) => mergeProps(userProps, propsList, "item"),
1271
- // eslint-disable-next-line react-hooks/exhaustive-deps
1272
- itemDeps
1273
- );
1274
- return React__namespace.useMemo(() => ({
1275
- getReferenceProps,
1276
- getFloatingProps,
1277
- getItemProps
1278
- }), [getReferenceProps, getFloatingProps, getItemProps]);
1279
- }
1280
- const componentRoleToAriaRoleMap = /* @__PURE__ */ new Map([["select", "listbox"], ["combobox", "listbox"], ["label", false]]);
1281
- function useRole(context, props) {
1282
- var _elements$domReferenc, _componentRoleToAriaR;
1283
- if (props === void 0) {
1284
- props = {};
1285
- }
1286
- const {
1287
- open,
1288
- elements,
1289
- floatingId: defaultFloatingId
1290
- } = context;
1291
- const {
1292
- enabled = true,
1293
- role = "dialog"
1294
- } = props;
1295
- const defaultReferenceId = useId();
1296
- const referenceId = ((_elements$domReferenc = elements.domReference) == null ? void 0 : _elements$domReferenc.id) || defaultReferenceId;
1297
- const floatingId = React__namespace.useMemo(() => {
1298
- var _getFloatingFocusElem;
1299
- return ((_getFloatingFocusElem = getFloatingFocusElement(elements.floating)) == null ? void 0 : _getFloatingFocusElem.id) || defaultFloatingId;
1300
- }, [elements.floating, defaultFloatingId]);
1301
- const ariaRole = (_componentRoleToAriaR = componentRoleToAriaRoleMap.get(role)) != null ? _componentRoleToAriaR : role;
1302
- const parentId = useFloatingParentNodeId();
1303
- const isNested = parentId != null;
1304
- const reference = React__namespace.useMemo(() => {
1305
- if (ariaRole === "tooltip" || role === "label") {
1306
- return {
1307
- ["aria-" + (role === "label" ? "labelledby" : "describedby")]: open ? floatingId : void 0
1308
- };
1309
- }
1310
- return {
1311
- "aria-expanded": open ? "true" : "false",
1312
- "aria-haspopup": ariaRole === "alertdialog" ? "dialog" : ariaRole,
1313
- "aria-controls": open ? floatingId : void 0,
1314
- ...ariaRole === "listbox" && {
1315
- role: "combobox"
1316
- },
1317
- ...ariaRole === "menu" && {
1318
- id: referenceId
1319
- },
1320
- ...ariaRole === "menu" && isNested && {
1321
- role: "menuitem"
1322
- },
1323
- ...role === "select" && {
1324
- "aria-autocomplete": "none"
1325
- },
1326
- ...role === "combobox" && {
1327
- "aria-autocomplete": "list"
1328
- }
1329
- };
1330
- }, [ariaRole, floatingId, isNested, open, referenceId, role]);
1331
- const floating = React__namespace.useMemo(() => {
1332
- const floatingProps = {
1333
- id: floatingId,
1334
- ...ariaRole && {
1335
- role: ariaRole
1336
- }
1337
- };
1338
- if (ariaRole === "tooltip" || role === "label") {
1339
- return floatingProps;
1340
- }
1341
- return {
1342
- ...floatingProps,
1343
- ...ariaRole === "menu" && {
1344
- "aria-labelledby": referenceId
1345
- }
1346
- };
1347
- }, [ariaRole, floatingId, referenceId, role]);
1348
- const item = React__namespace.useCallback((_ref) => {
1349
- let {
1350
- active,
1351
- selected
1352
- } = _ref;
1353
- const commonProps = {
1354
- role: "option",
1355
- ...active && {
1356
- id: floatingId + "-fui-option"
1357
- }
1358
- };
1359
- switch (role) {
1360
- case "select":
1361
- case "combobox":
1362
- return {
1363
- ...commonProps,
1364
- "aria-selected": selected
1365
- };
1366
- }
1367
- return {};
1368
- }, [floatingId, role]);
1369
- return React__namespace.useMemo(() => enabled ? {
1370
- reference,
1371
- floating,
1372
- item
1373
- } : {}, [enabled, reference, floating, item]);
1374
- }
1375
- const Tooltip = ({ children, content, className, placement = "top", showArrow = true }) => {
1376
- const [isOpen, setIsOpen] = React.useState(false);
1377
- const arrowRef = React.useRef(null);
1378
- const { refs, floatingStyles, context } = useFloating({
1379
- open: isOpen,
1380
- onOpenChange: setIsOpen,
1381
- placement,
1382
- middleware: [floatingUi_reactDom.offset(8), floatingUi_reactDom.flip(), floatingUi_reactDom.shift(), floatingUi_reactDom.arrow({ element: arrowRef })],
1383
- whileElementsMounted: floatingUi_dom.autoUpdate
1384
- });
1385
- const hover = useHover(context);
1386
- const focus = useFocus(context);
1387
- const dismiss = useDismiss(context);
1388
- const role = useRole(context);
1389
- const { getReferenceProps, getFloatingProps } = useInteractions([hover, focus, dismiss, role]);
1390
- const mergedClass = tailwindMerge.twMerge(
1391
- clsx("bg-content1 font-normal text-sm rounded-md filter-(--filter-drop-shadow-small) flex justify-center items-center z-10 px-2.5 py-1 outline-none box-border subpixel-antialiased normal-case", className)
1392
- );
1393
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1394
- /* @__PURE__ */ jsxRuntime.jsx("div", { ref: refs.setReference, ...getReferenceProps(), children }),
1395
- isOpen && /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: refs.setFloating, style: floatingStyles, ...getFloatingProps(), className: mergedClass, children: [
1396
- content,
1397
- showArrow && /* @__PURE__ */ jsxRuntime.jsx(FloatingArrow, { ref: arrowRef, context, className: "text-content1", fill: "currentColor" })
1398
- ] })
1399
- ] });
1400
- };
1401
- exports.Tooltip = Tooltip;
1402
- //# sourceMappingURL=tooltip-GGFk8ALK.js.map