react-tooltip 5.10.1-beta.5 → 5.10.2-beta.1

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.
@@ -1,1389 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __commonJS = (cb, mod) => function __require() {
8
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
- // If the importer is in node compatibility mode or this is not an ESM
20
- // file that has been converted to a CommonJS file using a Babel-
21
- // compatible transform (i.e. "__esModule" has not been set), then set
22
- // "default" to the CommonJS "module.exports" for node compatibility.
23
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
- mod
25
- ));
26
-
27
- // node_modules/classnames/index.js
28
- var require_classnames = __commonJS({
29
- "node_modules/classnames/index.js"(exports, module) {
30
- (function() {
31
- "use strict";
32
- var hasOwn = {}.hasOwnProperty;
33
- var nativeCodeString = "[native code]";
34
- function classNames3() {
35
- var classes = [];
36
- for (var i3 = 0; i3 < arguments.length; i3++) {
37
- var arg = arguments[i3];
38
- if (!arg)
39
- continue;
40
- var argType = typeof arg;
41
- if (argType === "string" || argType === "number") {
42
- classes.push(arg);
43
- } else if (Array.isArray(arg)) {
44
- if (arg.length) {
45
- var inner = classNames3.apply(null, arg);
46
- if (inner) {
47
- classes.push(inner);
48
- }
49
- }
50
- } else if (argType === "object") {
51
- if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
52
- classes.push(arg.toString());
53
- continue;
54
- }
55
- for (var key in arg) {
56
- if (hasOwn.call(arg, key) && arg[key]) {
57
- classes.push(key);
58
- }
59
- }
60
- }
61
- }
62
- return classes.join(" ");
63
- }
64
- if (typeof module !== "undefined" && module.exports) {
65
- classNames3.default = classNames3;
66
- module.exports = classNames3;
67
- } else if (typeof define === "function" && typeof define.amd === "object" && define.amd) {
68
- define("classnames", [], function() {
69
- return classNames3;
70
- });
71
- } else {
72
- window.classNames = classNames3;
73
- }
74
- })();
75
- }
76
- });
77
-
78
- // src/components/TooltipController/TooltipController.tsx
79
- import { useEffect as useEffect4, useState as useState3 } from "react";
80
-
81
- // src/components/Tooltip/Tooltip.tsx
82
- var import_classnames2 = __toESM(require_classnames());
83
- import { useEffect as useEffect3, useState as useState2, useRef as useRef2 } from "react";
84
-
85
- // src/utils/debounce.ts
86
- var debounce = (func, wait, immediate) => {
87
- let timeout = null;
88
- return function debounced(...args) {
89
- const later = () => {
90
- timeout = null;
91
- if (!immediate) {
92
- func.apply(this, args);
93
- }
94
- };
95
- if (timeout) {
96
- clearTimeout(timeout);
97
- }
98
- timeout = setTimeout(later, wait);
99
- };
100
- };
101
- var debounce_default = debounce;
102
-
103
- // src/components/TooltipProvider/TooltipProvider.tsx
104
- import {
105
- createContext,
106
- useCallback,
107
- useContext,
108
- useMemo,
109
- useState
110
- } from "react";
111
- import { jsx } from "react/jsx-runtime";
112
- var DEFAULT_TOOLTIP_ID = "DEFAULT_TOOLTIP_ID";
113
- var DEFAULT_CONTEXT_DATA = {
114
- anchorRefs: /* @__PURE__ */ new Set(),
115
- activeAnchor: { current: null },
116
- attach: () => {
117
- },
118
- detach: () => {
119
- },
120
- setActiveAnchor: () => {
121
- }
122
- };
123
- var DEFAULT_CONTEXT_DATA_WRAPPER = {
124
- getTooltipData: () => DEFAULT_CONTEXT_DATA
125
- };
126
- var TooltipContext = createContext(DEFAULT_CONTEXT_DATA_WRAPPER);
127
- var TooltipProvider = ({ children }) => {
128
- const [anchorRefMap, setAnchorRefMap] = useState({
129
- [DEFAULT_TOOLTIP_ID]: /* @__PURE__ */ new Set()
130
- });
131
- const [activeAnchorMap, setActiveAnchorMap] = useState({
132
- [DEFAULT_TOOLTIP_ID]: { current: null }
133
- });
134
- const attach = (tooltipId, ...refs) => {
135
- setAnchorRefMap((oldMap) => {
136
- var _a;
137
- const tooltipRefs = (_a = oldMap[tooltipId]) != null ? _a : /* @__PURE__ */ new Set();
138
- refs.forEach((ref) => tooltipRefs.add(ref));
139
- return { ...oldMap, [tooltipId]: new Set(tooltipRefs) };
140
- });
141
- };
142
- const detach = (tooltipId, ...refs) => {
143
- setAnchorRefMap((oldMap) => {
144
- const tooltipRefs = oldMap[tooltipId];
145
- if (!tooltipRefs) {
146
- return oldMap;
147
- }
148
- refs.forEach((ref) => tooltipRefs.delete(ref));
149
- return { ...oldMap };
150
- });
151
- };
152
- const setActiveAnchor = (tooltipId, ref) => {
153
- setActiveAnchorMap((oldMap) => {
154
- var _a;
155
- if (((_a = oldMap[tooltipId]) == null ? void 0 : _a.current) === ref.current) {
156
- return oldMap;
157
- }
158
- return { ...oldMap, [tooltipId]: ref };
159
- });
160
- };
161
- const getTooltipData = useCallback(
162
- (tooltipId = DEFAULT_TOOLTIP_ID) => {
163
- var _a, _b;
164
- return {
165
- anchorRefs: (_a = anchorRefMap[tooltipId]) != null ? _a : /* @__PURE__ */ new Set(),
166
- activeAnchor: (_b = activeAnchorMap[tooltipId]) != null ? _b : { current: null },
167
- attach: (...refs) => attach(tooltipId, ...refs),
168
- detach: (...refs) => detach(tooltipId, ...refs),
169
- setActiveAnchor: (ref) => setActiveAnchor(tooltipId, ref)
170
- };
171
- },
172
- [anchorRefMap, activeAnchorMap, attach, detach]
173
- );
174
- const context = useMemo(() => {
175
- return {
176
- getTooltipData
177
- };
178
- }, [getTooltipData]);
179
- return /* @__PURE__ */ jsx(TooltipContext.Provider, { value: context, children });
180
- };
181
- function useTooltip(tooltipId = DEFAULT_TOOLTIP_ID) {
182
- return useContext(TooltipContext).getTooltipData(tooltipId);
183
- }
184
- var TooltipProvider_default = TooltipProvider;
185
-
186
- // src/components/TooltipProvider/TooltipWrapper.tsx
187
- var import_classnames = __toESM(require_classnames());
188
- import { useEffect, useRef } from "react";
189
- import { jsx as jsx2 } from "react/jsx-runtime";
190
- var TooltipWrapper = ({
191
- tooltipId,
192
- children,
193
- className,
194
- place,
195
- content,
196
- html,
197
- variant,
198
- offset,
199
- wrapper,
200
- events,
201
- positionStrategy,
202
- delayShow,
203
- delayHide
204
- }) => {
205
- const { attach, detach } = useTooltip(tooltipId);
206
- const anchorRef = useRef(null);
207
- useEffect(() => {
208
- attach(anchorRef);
209
- return () => {
210
- detach(anchorRef);
211
- };
212
- }, []);
213
- return /* @__PURE__ */ jsx2(
214
- "span",
215
- {
216
- ref: anchorRef,
217
- className: (0, import_classnames.default)("react-tooltip-wrapper", className),
218
- "data-tooltip-place": place,
219
- "data-tooltip-content": content,
220
- "data-tooltip-html": html,
221
- "data-tooltip-variant": variant,
222
- "data-tooltip-offset": offset,
223
- "data-tooltip-wrapper": wrapper,
224
- "data-tooltip-events": events,
225
- "data-tooltip-position-strategy": positionStrategy,
226
- "data-tooltip-delay-show": delayShow,
227
- "data-tooltip-delay-hide": delayHide,
228
- children
229
- }
230
- );
231
- };
232
- var TooltipWrapper_default = TooltipWrapper;
233
-
234
- // src/utils/use-isomorphic-layout-effect.ts
235
- import { useLayoutEffect, useEffect as useEffect2 } from "react";
236
- var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect2;
237
- var use_isomorphic_layout_effect_default = useIsomorphicLayoutEffect;
238
-
239
- // node_modules/@floating-ui/core/dist/floating-ui.core.browser.min.mjs
240
- function t(t2) {
241
- return t2.split("-")[1];
242
- }
243
- function e(t2) {
244
- return "y" === t2 ? "height" : "width";
245
- }
246
- function n(t2) {
247
- return t2.split("-")[0];
248
- }
249
- function o(t2) {
250
- return ["top", "bottom"].includes(n(t2)) ? "x" : "y";
251
- }
252
- function i(i3, r3, a3) {
253
- let { reference: l3, floating: s3 } = i3;
254
- const c3 = l3.x + l3.width / 2 - s3.width / 2, f3 = l3.y + l3.height / 2 - s3.height / 2, m3 = o(r3), u3 = e(m3), g3 = l3[u3] / 2 - s3[u3] / 2, d3 = "x" === m3;
255
- let p3;
256
- switch (n(r3)) {
257
- case "top":
258
- p3 = { x: c3, y: l3.y - s3.height };
259
- break;
260
- case "bottom":
261
- p3 = { x: c3, y: l3.y + l3.height };
262
- break;
263
- case "right":
264
- p3 = { x: l3.x + l3.width, y: f3 };
265
- break;
266
- case "left":
267
- p3 = { x: l3.x - s3.width, y: f3 };
268
- break;
269
- default:
270
- p3 = { x: l3.x, y: l3.y };
271
- }
272
- switch (t(r3)) {
273
- case "start":
274
- p3[m3] -= g3 * (a3 && d3 ? -1 : 1);
275
- break;
276
- case "end":
277
- p3[m3] += g3 * (a3 && d3 ? -1 : 1);
278
- }
279
- return p3;
280
- }
281
- var r = async (t2, e2, n3) => {
282
- const { placement: o3 = "bottom", strategy: r3 = "absolute", middleware: a3 = [], platform: l3 } = n3, s3 = a3.filter(Boolean), c3 = await (null == l3.isRTL ? void 0 : l3.isRTL(e2));
283
- let f3 = await l3.getElementRects({ reference: t2, floating: e2, strategy: r3 }), { x: m3, y: u3 } = i(f3, o3, c3), g3 = o3, d3 = {}, p3 = 0;
284
- for (let n4 = 0; n4 < s3.length; n4++) {
285
- const { name: a4, fn: h3 } = s3[n4], { x: y3, y: x3, data: w3, reset: v3 } = await h3({ x: m3, y: u3, initialPlacement: o3, placement: g3, strategy: r3, middlewareData: d3, rects: f3, platform: l3, elements: { reference: t2, floating: e2 } });
286
- m3 = null != y3 ? y3 : m3, u3 = null != x3 ? x3 : u3, d3 = { ...d3, [a4]: { ...d3[a4], ...w3 } }, v3 && p3 <= 50 && (p3++, "object" == typeof v3 && (v3.placement && (g3 = v3.placement), v3.rects && (f3 = true === v3.rects ? await l3.getElementRects({ reference: t2, floating: e2, strategy: r3 }) : v3.rects), { x: m3, y: u3 } = i(f3, g3, c3)), n4 = -1);
287
- }
288
- return { x: m3, y: u3, placement: g3, strategy: r3, middlewareData: d3 };
289
- };
290
- function a(t2) {
291
- return "number" != typeof t2 ? function(t3) {
292
- return { top: 0, right: 0, bottom: 0, left: 0, ...t3 };
293
- }(t2) : { top: t2, right: t2, bottom: t2, left: t2 };
294
- }
295
- function l(t2) {
296
- return { ...t2, top: t2.y, left: t2.x, right: t2.x + t2.width, bottom: t2.y + t2.height };
297
- }
298
- async function s(t2, e2) {
299
- var n3;
300
- void 0 === e2 && (e2 = {});
301
- const { x: o3, y: i3, platform: r3, rects: s3, elements: c3, strategy: f3 } = t2, { boundary: m3 = "clippingAncestors", rootBoundary: u3 = "viewport", elementContext: g3 = "floating", altBoundary: d3 = false, padding: p3 = 0 } = e2, h3 = a(p3), y3 = c3[d3 ? "floating" === g3 ? "reference" : "floating" : g3], x3 = l(await r3.getClippingRect({ element: null == (n3 = await (null == r3.isElement ? void 0 : r3.isElement(y3))) || n3 ? y3 : y3.contextElement || await (null == r3.getDocumentElement ? void 0 : r3.getDocumentElement(c3.floating)), boundary: m3, rootBoundary: u3, strategy: f3 })), w3 = "floating" === g3 ? { ...s3.floating, x: o3, y: i3 } : s3.reference, v3 = await (null == r3.getOffsetParent ? void 0 : r3.getOffsetParent(c3.floating)), b3 = await (null == r3.isElement ? void 0 : r3.isElement(v3)) && await (null == r3.getScale ? void 0 : r3.getScale(v3)) || { x: 1, y: 1 }, R2 = l(r3.convertOffsetParentRelativeRectToViewportRelativeRect ? await r3.convertOffsetParentRelativeRectToViewportRelativeRect({ rect: w3, offsetParent: v3, strategy: f3 }) : w3);
302
- return { top: (x3.top - R2.top + h3.top) / b3.y, bottom: (R2.bottom - x3.bottom + h3.bottom) / b3.y, left: (x3.left - R2.left + h3.left) / b3.x, right: (R2.right - x3.right + h3.right) / b3.x };
303
- }
304
- var c = Math.min;
305
- var f = Math.max;
306
- function m(t2, e2, n3) {
307
- return f(t2, c(e2, n3));
308
- }
309
- var u = (n3) => ({ name: "arrow", options: n3, async fn(i3) {
310
- const { element: r3, padding: l3 = 0 } = n3 || {}, { x: s3, y: c3, placement: f3, rects: u3, platform: g3, elements: d3 } = i3;
311
- if (null == r3)
312
- return {};
313
- const p3 = a(l3), h3 = { x: s3, y: c3 }, y3 = o(f3), x3 = e(y3), w3 = await g3.getDimensions(r3), v3 = "y" === y3, b3 = v3 ? "top" : "left", R2 = v3 ? "bottom" : "right", A2 = v3 ? "clientHeight" : "clientWidth", P2 = u3.reference[x3] + u3.reference[y3] - h3[y3] - u3.floating[x3], T3 = h3[y3] - u3.reference[y3], O3 = await (null == g3.getOffsetParent ? void 0 : g3.getOffsetParent(r3));
314
- let E3 = O3 ? O3[A2] : 0;
315
- E3 && await (null == g3.isElement ? void 0 : g3.isElement(O3)) || (E3 = d3.floating[A2] || u3.floating[x3]);
316
- const D3 = P2 / 2 - T3 / 2, L3 = p3[b3], k2 = E3 - w3[x3] - p3[R2], B = E3 / 2 - w3[x3] / 2 + D3, C2 = m(L3, B, k2), H2 = null != t(f3) && B != C2 && u3.reference[x3] / 2 - (B < L3 ? p3[b3] : p3[R2]) - w3[x3] / 2 < 0;
317
- return { [y3]: h3[y3] - (H2 ? B < L3 ? L3 - B : k2 - B : 0), data: { [y3]: C2, centerOffset: B - C2 } };
318
- } });
319
- var g = ["top", "right", "bottom", "left"];
320
- var d = g.reduce((t2, e2) => t2.concat(e2, e2 + "-start", e2 + "-end"), []);
321
- var p = { left: "right", right: "left", bottom: "top", top: "bottom" };
322
- function h(t2) {
323
- return t2.replace(/left|right|bottom|top/g, (t3) => p[t3]);
324
- }
325
- function y(n3, i3, r3) {
326
- void 0 === r3 && (r3 = false);
327
- const a3 = t(n3), l3 = o(n3), s3 = e(l3);
328
- let c3 = "x" === l3 ? a3 === (r3 ? "end" : "start") ? "right" : "left" : "start" === a3 ? "bottom" : "top";
329
- return i3.reference[s3] > i3.floating[s3] && (c3 = h(c3)), { main: c3, cross: h(c3) };
330
- }
331
- var x = { start: "end", end: "start" };
332
- function w(t2) {
333
- return t2.replace(/start|end/g, (t3) => x[t3]);
334
- }
335
- var b = function(e2) {
336
- return void 0 === e2 && (e2 = {}), { name: "flip", options: e2, async fn(o3) {
337
- var i3;
338
- const { placement: r3, middlewareData: a3, rects: l3, initialPlacement: c3, platform: f3, elements: m3 } = o3, { mainAxis: u3 = true, crossAxis: g3 = true, fallbackPlacements: d3, fallbackStrategy: p3 = "bestFit", fallbackAxisSideDirection: x3 = "none", flipAlignment: v3 = true, ...b3 } = e2, R2 = n(r3), A2 = n(c3) === c3, P2 = await (null == f3.isRTL ? void 0 : f3.isRTL(m3.floating)), T3 = d3 || (A2 || !v3 ? [h(c3)] : function(t2) {
339
- const e3 = h(t2);
340
- return [w(t2), e3, w(e3)];
341
- }(c3));
342
- d3 || "none" === x3 || T3.push(...function(e3, o4, i4, r4) {
343
- const a4 = t(e3);
344
- let l4 = function(t2, e4, n3) {
345
- const o5 = ["left", "right"], i5 = ["right", "left"], r5 = ["top", "bottom"], a5 = ["bottom", "top"];
346
- switch (t2) {
347
- case "top":
348
- case "bottom":
349
- return n3 ? e4 ? i5 : o5 : e4 ? o5 : i5;
350
- case "left":
351
- case "right":
352
- return e4 ? r5 : a5;
353
- default:
354
- return [];
355
- }
356
- }(n(e3), "start" === i4, r4);
357
- return a4 && (l4 = l4.map((t2) => t2 + "-" + a4), o4 && (l4 = l4.concat(l4.map(w)))), l4;
358
- }(c3, v3, x3, P2));
359
- const O3 = [c3, ...T3], E3 = await s(o3, b3), D3 = [];
360
- let L3 = (null == (i3 = a3.flip) ? void 0 : i3.overflows) || [];
361
- if (u3 && D3.push(E3[R2]), g3) {
362
- const { main: t2, cross: e3 } = y(r3, l3, P2);
363
- D3.push(E3[t2], E3[e3]);
364
- }
365
- if (L3 = [...L3, { placement: r3, overflows: D3 }], !D3.every((t2) => t2 <= 0)) {
366
- var k2, B;
367
- const t2 = ((null == (k2 = a3.flip) ? void 0 : k2.index) || 0) + 1, e3 = O3[t2];
368
- if (e3)
369
- return { data: { index: t2, overflows: L3 }, reset: { placement: e3 } };
370
- let n3 = null == (B = L3.filter((t3) => t3.overflows[0] <= 0).sort((t3, e4) => t3.overflows[1] - e4.overflows[1])[0]) ? void 0 : B.placement;
371
- if (!n3)
372
- switch (p3) {
373
- case "bestFit": {
374
- var C2;
375
- const t3 = null == (C2 = L3.map((t4) => [t4.placement, t4.overflows.filter((t5) => t5 > 0).reduce((t5, e4) => t5 + e4, 0)]).sort((t4, e4) => t4[1] - e4[1])[0]) ? void 0 : C2[0];
376
- t3 && (n3 = t3);
377
- break;
378
- }
379
- case "initialPlacement":
380
- n3 = c3;
381
- }
382
- if (r3 !== n3)
383
- return { reset: { placement: n3 } };
384
- }
385
- return {};
386
- } };
387
- };
388
- var O = function(e2) {
389
- return void 0 === e2 && (e2 = 0), { name: "offset", options: e2, async fn(i3) {
390
- const { x: r3, y: a3 } = i3, l3 = await async function(e3, i4) {
391
- const { placement: r4, platform: a4, elements: l4 } = e3, s3 = await (null == a4.isRTL ? void 0 : a4.isRTL(l4.floating)), c3 = n(r4), f3 = t(r4), m3 = "x" === o(r4), u3 = ["left", "top"].includes(c3) ? -1 : 1, g3 = s3 && m3 ? -1 : 1, d3 = "function" == typeof i4 ? i4(e3) : i4;
392
- let { mainAxis: p3, crossAxis: h3, alignmentAxis: y3 } = "number" == typeof d3 ? { mainAxis: d3, crossAxis: 0, alignmentAxis: null } : { mainAxis: 0, crossAxis: 0, alignmentAxis: null, ...d3 };
393
- return f3 && "number" == typeof y3 && (h3 = "end" === f3 ? -1 * y3 : y3), m3 ? { x: h3 * g3, y: p3 * u3 } : { x: p3 * u3, y: h3 * g3 };
394
- }(i3, e2);
395
- return { x: r3 + l3.x, y: a3 + l3.y, data: l3 };
396
- } };
397
- };
398
- function E(t2) {
399
- return "x" === t2 ? "y" : "x";
400
- }
401
- var D = function(t2) {
402
- return void 0 === t2 && (t2 = {}), { name: "shift", options: t2, async fn(e2) {
403
- const { x: i3, y: r3, placement: a3 } = e2, { mainAxis: l3 = true, crossAxis: c3 = false, limiter: f3 = { fn: (t3) => {
404
- let { x: e3, y: n3 } = t3;
405
- return { x: e3, y: n3 };
406
- } }, ...u3 } = t2, g3 = { x: i3, y: r3 }, d3 = await s(e2, u3), p3 = o(n(a3)), h3 = E(p3);
407
- let y3 = g3[p3], x3 = g3[h3];
408
- if (l3) {
409
- const t3 = "y" === p3 ? "bottom" : "right";
410
- y3 = m(y3 + d3["y" === p3 ? "top" : "left"], y3, y3 - d3[t3]);
411
- }
412
- if (c3) {
413
- const t3 = "y" === h3 ? "bottom" : "right";
414
- x3 = m(x3 + d3["y" === h3 ? "top" : "left"], x3, x3 - d3[t3]);
415
- }
416
- const w3 = f3.fn({ ...e2, [p3]: y3, [h3]: x3 });
417
- return { ...w3, data: { x: w3.x - i3, y: w3.y - r3 } };
418
- } };
419
- };
420
-
421
- // node_modules/@floating-ui/dom/dist/floating-ui.dom.browser.min.mjs
422
- function n2(t2) {
423
- var e2;
424
- return (null == (e2 = t2.ownerDocument) ? void 0 : e2.defaultView) || window;
425
- }
426
- function o2(t2) {
427
- return n2(t2).getComputedStyle(t2);
428
- }
429
- var i2 = Math.min;
430
- var r2 = Math.max;
431
- var l2 = Math.round;
432
- function c2(t2) {
433
- const e2 = o2(t2);
434
- let n3 = parseFloat(e2.width), i3 = parseFloat(e2.height);
435
- const r3 = t2.offsetWidth, c3 = t2.offsetHeight, s3 = l2(n3) !== r3 || l2(i3) !== c3;
436
- return s3 && (n3 = r3, i3 = c3), { width: n3, height: i3, fallback: s3 };
437
- }
438
- function s2(t2) {
439
- return h2(t2) ? (t2.nodeName || "").toLowerCase() : "";
440
- }
441
- var f2;
442
- function u2() {
443
- if (f2)
444
- return f2;
445
- const t2 = navigator.userAgentData;
446
- return t2 && Array.isArray(t2.brands) ? (f2 = t2.brands.map((t3) => t3.brand + "/" + t3.version).join(" "), f2) : navigator.userAgent;
447
- }
448
- function a2(t2) {
449
- return t2 instanceof n2(t2).HTMLElement;
450
- }
451
- function d2(t2) {
452
- return t2 instanceof n2(t2).Element;
453
- }
454
- function h2(t2) {
455
- return t2 instanceof n2(t2).Node;
456
- }
457
- function p2(t2) {
458
- if ("undefined" == typeof ShadowRoot)
459
- return false;
460
- return t2 instanceof n2(t2).ShadowRoot || t2 instanceof ShadowRoot;
461
- }
462
- function g2(t2) {
463
- const { overflow: e2, overflowX: n3, overflowY: i3, display: r3 } = o2(t2);
464
- return /auto|scroll|overlay|hidden|clip/.test(e2 + i3 + n3) && !["inline", "contents"].includes(r3);
465
- }
466
- function m2(t2) {
467
- return ["table", "td", "th"].includes(s2(t2));
468
- }
469
- function y2(t2) {
470
- const e2 = /firefox/i.test(u2()), n3 = o2(t2), i3 = n3.backdropFilter || n3.WebkitBackdropFilter;
471
- return "none" !== n3.transform || "none" !== n3.perspective || !!i3 && "none" !== i3 || e2 && "filter" === n3.willChange || e2 && !!n3.filter && "none" !== n3.filter || ["transform", "perspective"].some((t3) => n3.willChange.includes(t3)) || ["paint", "layout", "strict", "content"].some((t3) => {
472
- const e3 = n3.contain;
473
- return null != e3 && e3.includes(t3);
474
- });
475
- }
476
- function x2() {
477
- return /^((?!chrome|android).)*safari/i.test(u2());
478
- }
479
- function w2(t2) {
480
- return ["html", "body", "#document"].includes(s2(t2));
481
- }
482
- function v2(t2) {
483
- return d2(t2) ? t2 : t2.contextElement;
484
- }
485
- var b2 = { x: 1, y: 1 };
486
- function L2(t2) {
487
- const e2 = v2(t2);
488
- if (!a2(e2))
489
- return b2;
490
- const n3 = e2.getBoundingClientRect(), { width: o3, height: i3, fallback: r3 } = c2(e2);
491
- let s3 = (r3 ? l2(n3.width) : n3.width) / o3, f3 = (r3 ? l2(n3.height) : n3.height) / i3;
492
- return s3 && Number.isFinite(s3) || (s3 = 1), f3 && Number.isFinite(f3) || (f3 = 1), { x: s3, y: f3 };
493
- }
494
- function E2(e2, o3, i3, r3) {
495
- var l3, c3;
496
- void 0 === o3 && (o3 = false), void 0 === i3 && (i3 = false);
497
- const s3 = e2.getBoundingClientRect(), f3 = v2(e2);
498
- let u3 = b2;
499
- o3 && (r3 ? d2(r3) && (u3 = L2(r3)) : u3 = L2(e2));
500
- const a3 = f3 ? n2(f3) : window, h3 = x2() && i3;
501
- let p3 = (s3.left + (h3 && (null == (l3 = a3.visualViewport) ? void 0 : l3.offsetLeft) || 0)) / u3.x, g3 = (s3.top + (h3 && (null == (c3 = a3.visualViewport) ? void 0 : c3.offsetTop) || 0)) / u3.y, m3 = s3.width / u3.x, y3 = s3.height / u3.y;
502
- if (f3) {
503
- const t2 = n2(f3), e3 = r3 && d2(r3) ? n2(r3) : r3;
504
- let o4 = t2.frameElement;
505
- for (; o4 && r3 && e3 !== t2; ) {
506
- const t3 = L2(o4), e4 = o4.getBoundingClientRect(), i4 = getComputedStyle(o4);
507
- e4.x += (o4.clientLeft + parseFloat(i4.paddingLeft)) * t3.x, e4.y += (o4.clientTop + parseFloat(i4.paddingTop)) * t3.y, p3 *= t3.x, g3 *= t3.y, m3 *= t3.x, y3 *= t3.y, p3 += e4.x, g3 += e4.y, o4 = n2(o4).frameElement;
508
- }
509
- }
510
- return l({ width: m3, height: y3, x: p3, y: g3 });
511
- }
512
- function R(t2) {
513
- return ((h2(t2) ? t2.ownerDocument : t2.document) || window.document).documentElement;
514
- }
515
- function T2(t2) {
516
- return d2(t2) ? { scrollLeft: t2.scrollLeft, scrollTop: t2.scrollTop } : { scrollLeft: t2.pageXOffset, scrollTop: t2.pageYOffset };
517
- }
518
- function C(t2) {
519
- return E2(R(t2)).left + T2(t2).scrollLeft;
520
- }
521
- function F(t2) {
522
- if ("html" === s2(t2))
523
- return t2;
524
- const e2 = t2.assignedSlot || t2.parentNode || p2(t2) && t2.host || R(t2);
525
- return p2(e2) ? e2.host : e2;
526
- }
527
- function W(t2) {
528
- const e2 = F(t2);
529
- return w2(e2) ? e2.ownerDocument.body : a2(e2) && g2(e2) ? e2 : W(e2);
530
- }
531
- function D2(t2, e2) {
532
- var o3;
533
- void 0 === e2 && (e2 = []);
534
- const i3 = W(t2), r3 = i3 === (null == (o3 = t2.ownerDocument) ? void 0 : o3.body), l3 = n2(i3);
535
- return r3 ? e2.concat(l3, l3.visualViewport || [], g2(i3) ? i3 : []) : e2.concat(i3, D2(i3));
536
- }
537
- function S(e2, i3, l3) {
538
- let c3;
539
- if ("viewport" === i3)
540
- c3 = function(t2, e3) {
541
- const o3 = n2(t2), i4 = R(t2), r3 = o3.visualViewport;
542
- let l4 = i4.clientWidth, c4 = i4.clientHeight, s4 = 0, f4 = 0;
543
- if (r3) {
544
- l4 = r3.width, c4 = r3.height;
545
- const t3 = x2();
546
- (!t3 || t3 && "fixed" === e3) && (s4 = r3.offsetLeft, f4 = r3.offsetTop);
547
- }
548
- return { width: l4, height: c4, x: s4, y: f4 };
549
- }(e2, l3);
550
- else if ("document" === i3)
551
- c3 = function(t2) {
552
- const e3 = R(t2), n3 = T2(t2), i4 = t2.ownerDocument.body, l4 = r2(e3.scrollWidth, e3.clientWidth, i4.scrollWidth, i4.clientWidth), c4 = r2(e3.scrollHeight, e3.clientHeight, i4.scrollHeight, i4.clientHeight);
553
- let s4 = -n3.scrollLeft + C(t2);
554
- const f4 = -n3.scrollTop;
555
- return "rtl" === o2(i4).direction && (s4 += r2(e3.clientWidth, i4.clientWidth) - l4), { width: l4, height: c4, x: s4, y: f4 };
556
- }(R(e2));
557
- else if (d2(i3))
558
- c3 = function(t2, e3) {
559
- const n3 = E2(t2, true, "fixed" === e3), o3 = n3.top + t2.clientTop, i4 = n3.left + t2.clientLeft, r3 = a2(t2) ? L2(t2) : { x: 1, y: 1 };
560
- return { width: t2.clientWidth * r3.x, height: t2.clientHeight * r3.y, x: i4 * r3.x, y: o3 * r3.y };
561
- }(i3, l3);
562
- else {
563
- const t2 = { ...i3 };
564
- if (x2()) {
565
- var s3, f3;
566
- const o3 = n2(e2);
567
- t2.x -= (null == (s3 = o3.visualViewport) ? void 0 : s3.offsetLeft) || 0, t2.y -= (null == (f3 = o3.visualViewport) ? void 0 : f3.offsetTop) || 0;
568
- }
569
- c3 = t2;
570
- }
571
- return l(c3);
572
- }
573
- function A(t2, e2) {
574
- return a2(t2) && "fixed" !== o2(t2).position ? e2 ? e2(t2) : t2.offsetParent : null;
575
- }
576
- function H(t2, e2) {
577
- const i3 = n2(t2);
578
- if (!a2(t2))
579
- return i3;
580
- let r3 = A(t2, e2);
581
- for (; r3 && m2(r3) && "static" === o2(r3).position; )
582
- r3 = A(r3, e2);
583
- return r3 && ("html" === s2(r3) || "body" === s2(r3) && "static" === o2(r3).position && !y2(r3)) ? i3 : r3 || function(t3) {
584
- let e3 = F(t3);
585
- for (; a2(e3) && !w2(e3); ) {
586
- if (y2(e3))
587
- return e3;
588
- e3 = F(e3);
589
- }
590
- return null;
591
- }(t2) || i3;
592
- }
593
- function V(t2, e2, n3) {
594
- const o3 = a2(e2), i3 = R(e2), r3 = E2(t2, true, "fixed" === n3, e2);
595
- let l3 = { scrollLeft: 0, scrollTop: 0 };
596
- const c3 = { x: 0, y: 0 };
597
- if (o3 || !o3 && "fixed" !== n3)
598
- if (("body" !== s2(e2) || g2(i3)) && (l3 = T2(e2)), a2(e2)) {
599
- const t3 = E2(e2, true);
600
- c3.x = t3.x + e2.clientLeft, c3.y = t3.y + e2.clientTop;
601
- } else
602
- i3 && (c3.x = C(i3));
603
- return { x: r3.left + l3.scrollLeft - c3.x, y: r3.top + l3.scrollTop - c3.y, width: r3.width, height: r3.height };
604
- }
605
- var O2 = { getClippingRect: function(t2) {
606
- let { element: e2, boundary: n3, rootBoundary: l3, strategy: c3 } = t2;
607
- const f3 = "clippingAncestors" === n3 ? function(t3, e3) {
608
- const n4 = e3.get(t3);
609
- if (n4)
610
- return n4;
611
- let i3 = D2(t3).filter((t4) => d2(t4) && "body" !== s2(t4)), r3 = null;
612
- const l4 = "fixed" === o2(t3).position;
613
- let c4 = l4 ? F(t3) : t3;
614
- for (; d2(c4) && !w2(c4); ) {
615
- const t4 = o2(c4), e4 = y2(c4);
616
- "fixed" === t4.position ? r3 = null : (l4 ? e4 || r3 : e4 || "static" !== t4.position || !r3 || !["absolute", "fixed"].includes(r3.position)) ? r3 = t4 : i3 = i3.filter((t5) => t5 !== c4), c4 = F(c4);
617
- }
618
- return e3.set(t3, i3), i3;
619
- }(e2, this._c) : [].concat(n3), u3 = [...f3, l3], a3 = u3[0], h3 = u3.reduce((t3, n4) => {
620
- const o3 = S(e2, n4, c3);
621
- return t3.top = r2(o3.top, t3.top), t3.right = i2(o3.right, t3.right), t3.bottom = i2(o3.bottom, t3.bottom), t3.left = r2(o3.left, t3.left), t3;
622
- }, S(e2, a3, c3));
623
- return { width: h3.right - h3.left, height: h3.bottom - h3.top, x: h3.left, y: h3.top };
624
- }, convertOffsetParentRelativeRectToViewportRelativeRect: function(t2) {
625
- let { rect: e2, offsetParent: n3, strategy: o3 } = t2;
626
- const i3 = a2(n3), r3 = R(n3);
627
- if (n3 === r3)
628
- return e2;
629
- let l3 = { scrollLeft: 0, scrollTop: 0 }, c3 = { x: 1, y: 1 };
630
- const f3 = { x: 0, y: 0 };
631
- if ((i3 || !i3 && "fixed" !== o3) && (("body" !== s2(n3) || g2(r3)) && (l3 = T2(n3)), a2(n3))) {
632
- const t3 = E2(n3);
633
- c3 = L2(n3), f3.x = t3.x + n3.clientLeft, f3.y = t3.y + n3.clientTop;
634
- }
635
- return { width: e2.width * c3.x, height: e2.height * c3.y, x: e2.x * c3.x - l3.scrollLeft * c3.x + f3.x, y: e2.y * c3.y - l3.scrollTop * c3.y + f3.y };
636
- }, isElement: d2, getDimensions: function(t2) {
637
- return a2(t2) ? c2(t2) : t2.getBoundingClientRect();
638
- }, getOffsetParent: H, getDocumentElement: R, getScale: L2, async getElementRects(t2) {
639
- let { reference: e2, floating: n3, strategy: o3 } = t2;
640
- const i3 = this.getOffsetParent || H, r3 = this.getDimensions;
641
- return { reference: V(e2, await i3(n3), o3), floating: { x: 0, y: 0, ...await r3(n3) } };
642
- }, getClientRects: (t2) => Array.from(t2.getClientRects()), isRTL: (t2) => "rtl" === o2(t2).direction };
643
- var z = (t2, n3, o3) => {
644
- const i3 = /* @__PURE__ */ new Map(), r3 = { platform: O2, ...o3 }, l3 = { ...r3.platform, _c: i3 };
645
- return r(t2, n3, { ...r3, platform: l3 });
646
- };
647
-
648
- // src/utils/compute-positions.ts
649
- var computeTooltipPosition = async ({
650
- elementReference = null,
651
- tooltipReference = null,
652
- tooltipArrowReference = null,
653
- place = "top",
654
- offset: offsetValue = 10,
655
- strategy = "absolute",
656
- middlewares = [O(Number(offsetValue)), b(), D({ padding: 5 })]
657
- }) => {
658
- if (!elementReference) {
659
- return { tooltipStyles: {}, tooltipArrowStyles: {}, place };
660
- }
661
- if (tooltipReference === null) {
662
- return { tooltipStyles: {}, tooltipArrowStyles: {}, place };
663
- }
664
- const middleware = middlewares;
665
- if (tooltipArrowReference) {
666
- middleware.push(u({ element: tooltipArrowReference, padding: 5 }));
667
- return z(elementReference, tooltipReference, {
668
- placement: place,
669
- strategy,
670
- middleware
671
- }).then(({ x: x3, y: y3, placement, middlewareData }) => {
672
- var _a, _b;
673
- const styles = { left: `${x3}px`, top: `${y3}px` };
674
- const { x: arrowX, y: arrowY } = (_a = middlewareData.arrow) != null ? _a : { x: 0, y: 0 };
675
- const staticSide = (_b = {
676
- top: "bottom",
677
- right: "left",
678
- bottom: "top",
679
- left: "right"
680
- }[placement.split("-")[0]]) != null ? _b : "bottom";
681
- const arrowStyle = {
682
- left: arrowX != null ? `${arrowX}px` : "",
683
- top: arrowY != null ? `${arrowY}px` : "",
684
- right: "",
685
- bottom: "",
686
- [staticSide]: "-4px"
687
- };
688
- return { tooltipStyles: styles, tooltipArrowStyles: arrowStyle, place: placement };
689
- });
690
- }
691
- return z(elementReference, tooltipReference, {
692
- placement: "bottom",
693
- strategy,
694
- middleware
695
- }).then(({ x: x3, y: y3, placement }) => {
696
- const styles = { left: `${x3}px`, top: `${y3}px` };
697
- return { tooltipStyles: styles, tooltipArrowStyles: {}, place: placement };
698
- });
699
- };
700
-
701
- // esbuild-css-modules-plugin-namespace:./src/components/Tooltip/styles.module.css?esbuild-css-modules-plugin-building
702
- var styles_module_default = { "arrow": "react-tooltip__arrow_KtSkBq", "clickable": "react-tooltip__clickable_KtSkBq", "dark": "react-tooltip__dark_KtSkBq", "error": "react-tooltip__error_KtSkBq", "fixed": "react-tooltip__fixed_KtSkBq", "info": "react-tooltip__info_KtSkBq", "light": "react-tooltip__light_KtSkBq", "noArrow": "react-tooltip__no-arrow_KtSkBq", "show": "react-tooltip__show_KtSkBq", "success": "react-tooltip__success_KtSkBq", "tooltip": "react-tooltip__tooltip_KtSkBq", "warning": "react-tooltip__warning_KtSkBq" };
703
-
704
- // src/components/Tooltip/Tooltip.tsx
705
- import { jsx as jsx3, jsxs } from "react/jsx-runtime";
706
- var Tooltip = ({
707
- // props
708
- id,
709
- className,
710
- classNameArrow,
711
- variant = "dark",
712
- anchorId,
713
- anchorSelect,
714
- place = "top",
715
- offset = 10,
716
- events = ["hover"],
717
- openOnClick = false,
718
- positionStrategy = "absolute",
719
- middlewares,
720
- wrapper: WrapperElement,
721
- delayShow = 0,
722
- delayHide = 0,
723
- float = false,
724
- noArrow = false,
725
- clickable = false,
726
- closeOnEsc = false,
727
- style: externalStyles,
728
- position,
729
- afterShow,
730
- afterHide,
731
- // props handled by controller
732
- content,
733
- isOpen,
734
- setIsOpen,
735
- activeAnchor,
736
- setActiveAnchor
737
- }) => {
738
- const tooltipRef = useRef2(null);
739
- const tooltipArrowRef = useRef2(null);
740
- const tooltipShowDelayTimerRef = useRef2(null);
741
- const tooltipHideDelayTimerRef = useRef2(null);
742
- const [actualPlacement, setActualPlacement] = useState2(place);
743
- const [inlineStyles, setInlineStyles] = useState2({});
744
- const [inlineArrowStyles, setInlineArrowStyles] = useState2({});
745
- const [show, setShow] = useState2(false);
746
- const [rendered, setRendered] = useState2(false);
747
- const wasShowing = useRef2(false);
748
- const lastFloatPosition = useRef2(null);
749
- const { anchorRefs, setActiveAnchor: setProviderActiveAnchor } = useTooltip(id);
750
- const hoveringTooltip = useRef2(false);
751
- const [anchorsBySelect, setAnchorsBySelect] = useState2([]);
752
- const mounted = useRef2(false);
753
- const shouldOpenOnClick = openOnClick || events.includes("click");
754
- use_isomorphic_layout_effect_default(() => {
755
- mounted.current = true;
756
- return () => {
757
- mounted.current = false;
758
- };
759
- }, []);
760
- useEffect3(() => {
761
- if (!show) {
762
- const timeout = setTimeout(() => {
763
- setRendered(false);
764
- }, 150);
765
- return () => {
766
- clearTimeout(timeout);
767
- };
768
- }
769
- return () => null;
770
- }, [show]);
771
- const handleShow = (value) => {
772
- if (!mounted.current) {
773
- return;
774
- }
775
- if (value) {
776
- setRendered(true);
777
- }
778
- setTimeout(() => {
779
- if (!mounted.current) {
780
- return;
781
- }
782
- setIsOpen == null ? void 0 : setIsOpen(value);
783
- if (isOpen === void 0) {
784
- setShow(value);
785
- }
786
- }, 10);
787
- };
788
- useEffect3(() => {
789
- if (isOpen === void 0) {
790
- return () => null;
791
- }
792
- if (isOpen) {
793
- setRendered(true);
794
- }
795
- const timeout = setTimeout(() => {
796
- setShow(isOpen);
797
- }, 10);
798
- return () => {
799
- clearTimeout(timeout);
800
- };
801
- }, [isOpen]);
802
- useEffect3(() => {
803
- if (show === wasShowing.current) {
804
- return;
805
- }
806
- wasShowing.current = show;
807
- if (show) {
808
- afterShow == null ? void 0 : afterShow();
809
- } else {
810
- afterHide == null ? void 0 : afterHide();
811
- }
812
- }, [show]);
813
- const handleShowTooltipDelayed = () => {
814
- if (tooltipShowDelayTimerRef.current) {
815
- clearTimeout(tooltipShowDelayTimerRef.current);
816
- }
817
- tooltipShowDelayTimerRef.current = setTimeout(() => {
818
- handleShow(true);
819
- }, delayShow);
820
- };
821
- const handleHideTooltipDelayed = (delay = delayHide) => {
822
- if (tooltipHideDelayTimerRef.current) {
823
- clearTimeout(tooltipHideDelayTimerRef.current);
824
- }
825
- tooltipHideDelayTimerRef.current = setTimeout(() => {
826
- if (hoveringTooltip.current) {
827
- return;
828
- }
829
- handleShow(false);
830
- }, delay);
831
- };
832
- const handleShowTooltip = (event) => {
833
- var _a;
834
- if (!event) {
835
- return;
836
- }
837
- if (delayShow) {
838
- handleShowTooltipDelayed();
839
- } else {
840
- handleShow(true);
841
- }
842
- const target = (_a = event.currentTarget) != null ? _a : event.target;
843
- setActiveAnchor(target);
844
- setProviderActiveAnchor({ current: target });
845
- if (tooltipHideDelayTimerRef.current) {
846
- clearTimeout(tooltipHideDelayTimerRef.current);
847
- }
848
- };
849
- const handleHideTooltip = () => {
850
- if (clickable) {
851
- handleHideTooltipDelayed(delayHide || 100);
852
- } else if (delayHide) {
853
- handleHideTooltipDelayed();
854
- } else {
855
- handleShow(false);
856
- }
857
- if (tooltipShowDelayTimerRef.current) {
858
- clearTimeout(tooltipShowDelayTimerRef.current);
859
- }
860
- };
861
- const handleTooltipPosition = ({ x: x3, y: y3 }) => {
862
- const virtualElement = {
863
- getBoundingClientRect() {
864
- return {
865
- x: x3,
866
- y: y3,
867
- width: 0,
868
- height: 0,
869
- top: y3,
870
- left: x3,
871
- right: x3,
872
- bottom: y3
873
- };
874
- }
875
- };
876
- computeTooltipPosition({
877
- place,
878
- offset,
879
- elementReference: virtualElement,
880
- tooltipReference: tooltipRef.current,
881
- tooltipArrowReference: tooltipArrowRef.current,
882
- strategy: positionStrategy,
883
- middlewares
884
- }).then((computedStylesData) => {
885
- if (Object.keys(computedStylesData.tooltipStyles).length) {
886
- setInlineStyles(computedStylesData.tooltipStyles);
887
- }
888
- if (Object.keys(computedStylesData.tooltipArrowStyles).length) {
889
- setInlineArrowStyles(computedStylesData.tooltipArrowStyles);
890
- }
891
- setActualPlacement(computedStylesData.place);
892
- });
893
- };
894
- const handleMouseMove = (event) => {
895
- if (!event) {
896
- return;
897
- }
898
- const mouseEvent = event;
899
- const mousePosition = {
900
- x: mouseEvent.clientX,
901
- y: mouseEvent.clientY
902
- };
903
- handleTooltipPosition(mousePosition);
904
- lastFloatPosition.current = mousePosition;
905
- };
906
- const handleClickTooltipAnchor = (event) => {
907
- handleShowTooltip(event);
908
- if (delayHide) {
909
- handleHideTooltipDelayed();
910
- }
911
- };
912
- const handleClickOutsideAnchors = (event) => {
913
- var _a;
914
- const anchorById = document.querySelector(`[id='${anchorId}']`);
915
- const anchors = [anchorById, ...anchorsBySelect];
916
- if (anchors.some((anchor) => anchor == null ? void 0 : anchor.contains(event.target))) {
917
- return;
918
- }
919
- if ((_a = tooltipRef.current) == null ? void 0 : _a.contains(event.target)) {
920
- return;
921
- }
922
- handleShow(false);
923
- };
924
- const handleEsc = (event) => {
925
- if (event.key !== "Escape") {
926
- return;
927
- }
928
- handleShow(false);
929
- };
930
- const debouncedHandleShowTooltip = debounce_default(handleShowTooltip, 50);
931
- const debouncedHandleHideTooltip = debounce_default(handleHideTooltip, 50);
932
- useEffect3(() => {
933
- var _a, _b;
934
- const elementRefs = new Set(anchorRefs);
935
- anchorsBySelect.forEach((anchor) => {
936
- elementRefs.add({ current: anchor });
937
- });
938
- const anchorById = document.querySelector(`[id='${anchorId}']`);
939
- if (anchorById) {
940
- elementRefs.add({ current: anchorById });
941
- }
942
- if (closeOnEsc) {
943
- window.addEventListener("keydown", handleEsc);
944
- }
945
- const enabledEvents = [];
946
- if (shouldOpenOnClick) {
947
- window.addEventListener("click", handleClickOutsideAnchors);
948
- enabledEvents.push({ event: "click", listener: handleClickTooltipAnchor });
949
- } else {
950
- enabledEvents.push(
951
- { event: "mouseenter", listener: debouncedHandleShowTooltip },
952
- { event: "mouseleave", listener: debouncedHandleHideTooltip },
953
- { event: "focus", listener: debouncedHandleShowTooltip },
954
- { event: "blur", listener: debouncedHandleHideTooltip }
955
- );
956
- if (float) {
957
- enabledEvents.push({
958
- event: "mousemove",
959
- listener: handleMouseMove
960
- });
961
- }
962
- }
963
- const handleMouseEnterTooltip = () => {
964
- hoveringTooltip.current = true;
965
- };
966
- const handleMouseLeaveTooltip = () => {
967
- hoveringTooltip.current = false;
968
- handleHideTooltip();
969
- };
970
- if (clickable && !shouldOpenOnClick) {
971
- (_a = tooltipRef.current) == null ? void 0 : _a.addEventListener("mouseenter", handleMouseEnterTooltip);
972
- (_b = tooltipRef.current) == null ? void 0 : _b.addEventListener("mouseleave", handleMouseLeaveTooltip);
973
- }
974
- enabledEvents.forEach(({ event, listener }) => {
975
- elementRefs.forEach((ref) => {
976
- var _a2;
977
- (_a2 = ref.current) == null ? void 0 : _a2.addEventListener(event, listener);
978
- });
979
- });
980
- return () => {
981
- var _a2, _b2;
982
- if (shouldOpenOnClick) {
983
- window.removeEventListener("click", handleClickOutsideAnchors);
984
- }
985
- if (closeOnEsc) {
986
- window.removeEventListener("keydown", handleEsc);
987
- }
988
- if (clickable && !shouldOpenOnClick) {
989
- (_a2 = tooltipRef.current) == null ? void 0 : _a2.removeEventListener("mouseenter", handleMouseEnterTooltip);
990
- (_b2 = tooltipRef.current) == null ? void 0 : _b2.removeEventListener("mouseleave", handleMouseLeaveTooltip);
991
- }
992
- enabledEvents.forEach(({ event, listener }) => {
993
- elementRefs.forEach((ref) => {
994
- var _a3;
995
- (_a3 = ref.current) == null ? void 0 : _a3.removeEventListener(event, listener);
996
- });
997
- });
998
- };
999
- }, [rendered, anchorRefs, anchorsBySelect, closeOnEsc, events]);
1000
- useEffect3(() => {
1001
- let selector = anchorSelect != null ? anchorSelect : "";
1002
- if (!selector && id) {
1003
- selector = `[data-tooltip-id='${id}']`;
1004
- }
1005
- const documentObserverCallback = (mutationList) => {
1006
- const newAnchors = [];
1007
- mutationList.forEach((mutation) => {
1008
- if (mutation.type === "attributes" && mutation.attributeName === "data-tooltip-id") {
1009
- const newId = mutation.target.getAttribute("data-tooltip-id");
1010
- if (newId === id) {
1011
- newAnchors.push(mutation.target);
1012
- }
1013
- }
1014
- if (mutation.type !== "childList") {
1015
- return;
1016
- }
1017
- if (activeAnchor) {
1018
- ;
1019
- [...mutation.removedNodes].some((node) => {
1020
- if (node.contains(activeAnchor)) {
1021
- setRendered(false);
1022
- handleShow(false);
1023
- setActiveAnchor(null);
1024
- return true;
1025
- }
1026
- return false;
1027
- });
1028
- }
1029
- if (!selector) {
1030
- return;
1031
- }
1032
- try {
1033
- const elements = [...mutation.addedNodes].filter((node) => node.nodeType === 1);
1034
- newAnchors.push(
1035
- ...elements.filter(
1036
- (element) => element.matches(selector)
1037
- )
1038
- );
1039
- newAnchors.push(
1040
- ...elements.flatMap(
1041
- (element) => [...element.querySelectorAll(selector)]
1042
- )
1043
- );
1044
- } catch (e2) {
1045
- }
1046
- });
1047
- if (newAnchors.length) {
1048
- setAnchorsBySelect((anchors) => [...anchors, ...newAnchors]);
1049
- }
1050
- };
1051
- const documentObserver = new MutationObserver(documentObserverCallback);
1052
- documentObserver.observe(document.body, {
1053
- childList: true,
1054
- subtree: true,
1055
- attributes: true,
1056
- attributeFilter: ["data-tooltip-id"]
1057
- });
1058
- return () => {
1059
- documentObserver.disconnect();
1060
- };
1061
- }, [id, anchorSelect, activeAnchor]);
1062
- useEffect3(() => {
1063
- if (position) {
1064
- handleTooltipPosition(position);
1065
- return;
1066
- }
1067
- if (float) {
1068
- if (lastFloatPosition.current) {
1069
- handleTooltipPosition(lastFloatPosition.current);
1070
- }
1071
- return;
1072
- }
1073
- computeTooltipPosition({
1074
- place,
1075
- offset,
1076
- elementReference: activeAnchor,
1077
- tooltipReference: tooltipRef.current,
1078
- tooltipArrowReference: tooltipArrowRef.current,
1079
- strategy: positionStrategy,
1080
- middlewares
1081
- }).then((computedStylesData) => {
1082
- if (!mounted.current) {
1083
- return;
1084
- }
1085
- if (Object.keys(computedStylesData.tooltipStyles).length) {
1086
- setInlineStyles(computedStylesData.tooltipStyles);
1087
- }
1088
- if (Object.keys(computedStylesData.tooltipArrowStyles).length) {
1089
- setInlineArrowStyles(computedStylesData.tooltipArrowStyles);
1090
- }
1091
- setActualPlacement(computedStylesData.place);
1092
- });
1093
- }, [show, activeAnchor, content, place, offset, positionStrategy, position]);
1094
- useEffect3(() => {
1095
- var _a;
1096
- const anchorById = document.querySelector(`[id='${anchorId}']`);
1097
- const anchors = [...anchorsBySelect, anchorById];
1098
- if (!activeAnchor || !anchors.includes(activeAnchor)) {
1099
- setActiveAnchor((_a = anchorsBySelect[0]) != null ? _a : anchorById);
1100
- }
1101
- }, [anchorId, anchorsBySelect, activeAnchor]);
1102
- useEffect3(() => {
1103
- return () => {
1104
- if (tooltipShowDelayTimerRef.current) {
1105
- clearTimeout(tooltipShowDelayTimerRef.current);
1106
- }
1107
- if (tooltipHideDelayTimerRef.current) {
1108
- clearTimeout(tooltipHideDelayTimerRef.current);
1109
- }
1110
- };
1111
- }, []);
1112
- useEffect3(() => {
1113
- let selector = anchorSelect;
1114
- if (!selector && id) {
1115
- selector = `[data-tooltip-id='${id}']`;
1116
- }
1117
- if (!selector) {
1118
- return;
1119
- }
1120
- try {
1121
- const anchors = Array.from(document.querySelectorAll(selector));
1122
- setAnchorsBySelect(anchors);
1123
- } catch (e2) {
1124
- setAnchorsBySelect([]);
1125
- }
1126
- }, [id, anchorSelect]);
1127
- const canShow = content && show && Object.keys(inlineStyles).length > 0;
1128
- return rendered ? /* @__PURE__ */ jsxs(
1129
- WrapperElement,
1130
- {
1131
- id,
1132
- role: "tooltip",
1133
- className: (0, import_classnames2.default)(
1134
- "react-tooltip",
1135
- styles_module_default["tooltip"],
1136
- styles_module_default[variant],
1137
- className,
1138
- `react-tooltip__place-${actualPlacement}`,
1139
- {
1140
- [styles_module_default["show"]]: canShow,
1141
- [styles_module_default["fixed"]]: positionStrategy === "fixed",
1142
- [styles_module_default["clickable"]]: clickable
1143
- }
1144
- ),
1145
- style: { ...externalStyles, ...inlineStyles },
1146
- ref: tooltipRef,
1147
- children: [
1148
- content,
1149
- /* @__PURE__ */ jsx3(
1150
- WrapperElement,
1151
- {
1152
- className: (0, import_classnames2.default)("react-tooltip-arrow", styles_module_default["arrow"], classNameArrow, {
1153
- /**
1154
- * changed from dash `no-arrow` to camelcase because of:
1155
- * https://github.com/indooorsman/esbuild-css-modules-plugin/issues/42
1156
- */
1157
- [styles_module_default["noArrow"]]: noArrow
1158
- }),
1159
- style: inlineArrowStyles,
1160
- ref: tooltipArrowRef
1161
- }
1162
- )
1163
- ]
1164
- }
1165
- ) : null;
1166
- };
1167
- var Tooltip_default = Tooltip;
1168
-
1169
- // src/components/TooltipContent/TooltipContent.tsx
1170
- import { jsx as jsx4 } from "react/jsx-runtime";
1171
- var TooltipContent = ({ content }) => {
1172
- return /* @__PURE__ */ jsx4("span", { dangerouslySetInnerHTML: { __html: content } });
1173
- };
1174
- var TooltipContent_default = TooltipContent;
1175
-
1176
- // src/components/TooltipController/TooltipController.tsx
1177
- import { jsx as jsx5 } from "react/jsx-runtime";
1178
- var TooltipController = ({
1179
- id,
1180
- anchorId,
1181
- anchorSelect,
1182
- content,
1183
- html,
1184
- render,
1185
- className,
1186
- classNameArrow,
1187
- variant = "dark",
1188
- place = "top",
1189
- offset = 10,
1190
- wrapper = "div",
1191
- children = null,
1192
- events = ["hover"],
1193
- openOnClick = false,
1194
- positionStrategy = "absolute",
1195
- middlewares,
1196
- delayShow = 0,
1197
- delayHide = 0,
1198
- float = false,
1199
- noArrow = false,
1200
- clickable = false,
1201
- closeOnEsc = false,
1202
- style,
1203
- position,
1204
- isOpen,
1205
- setIsOpen,
1206
- afterShow,
1207
- afterHide
1208
- }) => {
1209
- const [tooltipContent, setTooltipContent] = useState3(content);
1210
- const [tooltipHtml, setTooltipHtml] = useState3(html);
1211
- const [tooltipPlace, setTooltipPlace] = useState3(place);
1212
- const [tooltipVariant, setTooltipVariant] = useState3(variant);
1213
- const [tooltipOffset, setTooltipOffset] = useState3(offset);
1214
- const [tooltipDelayShow, setTooltipDelayShow] = useState3(delayShow);
1215
- const [tooltipDelayHide, setTooltipDelayHide] = useState3(delayHide);
1216
- const [tooltipFloat, setTooltipFloat] = useState3(float);
1217
- const [tooltipWrapper, setTooltipWrapper] = useState3(wrapper);
1218
- const [tooltipEvents, setTooltipEvents] = useState3(events);
1219
- const [tooltipPositionStrategy, setTooltipPositionStrategy] = useState3(positionStrategy);
1220
- const [activeAnchor, setActiveAnchor] = useState3(null);
1221
- const { anchorRefs, activeAnchor: providerActiveAnchor } = useTooltip(id);
1222
- const getDataAttributesFromAnchorElement = (elementReference) => {
1223
- const dataAttributes = elementReference == null ? void 0 : elementReference.getAttributeNames().reduce((acc, name) => {
1224
- var _a;
1225
- if (name.startsWith("data-tooltip-")) {
1226
- const parsedAttribute = name.replace(/^data-tooltip-/, "");
1227
- acc[parsedAttribute] = (_a = elementReference == null ? void 0 : elementReference.getAttribute(name)) != null ? _a : null;
1228
- }
1229
- return acc;
1230
- }, {});
1231
- return dataAttributes;
1232
- };
1233
- const applyAllDataAttributesFromAnchorElement = (dataAttributes) => {
1234
- const handleDataAttributes = {
1235
- place: (value) => {
1236
- setTooltipPlace(value != null ? value : place);
1237
- },
1238
- content: (value) => {
1239
- setTooltipContent(value != null ? value : content);
1240
- },
1241
- html: (value) => {
1242
- setTooltipHtml(value != null ? value : html);
1243
- },
1244
- variant: (value) => {
1245
- setTooltipVariant(value != null ? value : variant);
1246
- },
1247
- offset: (value) => {
1248
- setTooltipOffset(value === null ? offset : Number(value));
1249
- },
1250
- wrapper: (value) => {
1251
- setTooltipWrapper(value != null ? value : wrapper);
1252
- },
1253
- events: (value) => {
1254
- const parsed = value == null ? void 0 : value.split(" ");
1255
- setTooltipEvents(parsed != null ? parsed : events);
1256
- },
1257
- "position-strategy": (value) => {
1258
- setTooltipPositionStrategy(value != null ? value : positionStrategy);
1259
- },
1260
- "delay-show": (value) => {
1261
- setTooltipDelayShow(value === null ? delayShow : Number(value));
1262
- },
1263
- "delay-hide": (value) => {
1264
- setTooltipDelayHide(value === null ? delayHide : Number(value));
1265
- },
1266
- float: (value) => {
1267
- setTooltipFloat(value === null ? float : value === "true");
1268
- }
1269
- };
1270
- Object.values(handleDataAttributes).forEach((handler) => handler(null));
1271
- Object.entries(dataAttributes).forEach(([key, value]) => {
1272
- var _a;
1273
- (_a = handleDataAttributes[key]) == null ? void 0 : _a.call(handleDataAttributes, value);
1274
- });
1275
- };
1276
- useEffect4(() => {
1277
- setTooltipContent(content);
1278
- }, [content]);
1279
- useEffect4(() => {
1280
- setTooltipHtml(html);
1281
- }, [html]);
1282
- useEffect4(() => {
1283
- setTooltipPlace(place);
1284
- }, [place]);
1285
- useEffect4(() => {
1286
- var _a;
1287
- const elementRefs = new Set(anchorRefs);
1288
- let selector = anchorSelect;
1289
- if (!selector && id) {
1290
- selector = `[data-tooltip-id='${id}']`;
1291
- }
1292
- if (selector) {
1293
- try {
1294
- const anchorsBySelect = document.querySelectorAll(selector);
1295
- anchorsBySelect.forEach((anchor) => {
1296
- elementRefs.add({ current: anchor });
1297
- });
1298
- } catch (e2) {
1299
- if (true) {
1300
- console.warn(`[react-tooltip] "${anchorSelect}" is not a valid CSS selector`);
1301
- }
1302
- }
1303
- }
1304
- const anchorById = document.querySelector(`[id='${anchorId}']`);
1305
- if (anchorById) {
1306
- elementRefs.add({ current: anchorById });
1307
- }
1308
- if (!elementRefs.size) {
1309
- return () => null;
1310
- }
1311
- const anchorElement = (_a = activeAnchor != null ? activeAnchor : anchorById) != null ? _a : providerActiveAnchor.current;
1312
- const observerCallback = (mutationList) => {
1313
- mutationList.forEach((mutation) => {
1314
- var _a2;
1315
- if (!anchorElement || mutation.type !== "attributes" || !((_a2 = mutation.attributeName) == null ? void 0 : _a2.startsWith("data-tooltip-"))) {
1316
- return;
1317
- }
1318
- const dataAttributes = getDataAttributesFromAnchorElement(anchorElement);
1319
- applyAllDataAttributesFromAnchorElement(dataAttributes);
1320
- });
1321
- };
1322
- const observer = new MutationObserver(observerCallback);
1323
- const observerConfig = { attributes: true, childList: false, subtree: false };
1324
- if (anchorElement) {
1325
- const dataAttributes = getDataAttributesFromAnchorElement(anchorElement);
1326
- applyAllDataAttributesFromAnchorElement(dataAttributes);
1327
- observer.observe(anchorElement, observerConfig);
1328
- }
1329
- return () => {
1330
- observer.disconnect();
1331
- };
1332
- }, [anchorRefs, providerActiveAnchor, activeAnchor, anchorId, anchorSelect]);
1333
- let renderedContent = children;
1334
- if (render) {
1335
- renderedContent = render({ content: tooltipContent != null ? tooltipContent : null, activeAnchor });
1336
- } else if (tooltipContent) {
1337
- renderedContent = tooltipContent;
1338
- }
1339
- if (tooltipHtml) {
1340
- renderedContent = /* @__PURE__ */ jsx5(TooltipContent_default, { content: tooltipHtml });
1341
- }
1342
- const props = {
1343
- id,
1344
- anchorId,
1345
- anchorSelect,
1346
- className,
1347
- classNameArrow,
1348
- content: renderedContent,
1349
- place: tooltipPlace,
1350
- variant: tooltipVariant,
1351
- offset: tooltipOffset,
1352
- wrapper: tooltipWrapper,
1353
- events: tooltipEvents,
1354
- openOnClick,
1355
- positionStrategy: tooltipPositionStrategy,
1356
- middlewares,
1357
- delayShow: tooltipDelayShow,
1358
- delayHide: tooltipDelayHide,
1359
- float: tooltipFloat,
1360
- noArrow,
1361
- clickable,
1362
- closeOnEsc,
1363
- style,
1364
- position,
1365
- isOpen,
1366
- setIsOpen,
1367
- afterShow,
1368
- afterHide,
1369
- activeAnchor,
1370
- setActiveAnchor: (anchor) => setActiveAnchor(anchor)
1371
- };
1372
- return /* @__PURE__ */ jsx5(Tooltip_default, { ...props });
1373
- };
1374
- var TooltipController_default = TooltipController;
1375
- export {
1376
- TooltipController_default as Tooltip,
1377
- TooltipProvider_default as TooltipProvider,
1378
- TooltipWrapper_default as TooltipWrapper
1379
- };
1380
- /*! Bundled license information:
1381
-
1382
- classnames/index.js:
1383
- (*!
1384
- Copyright (c) 2018 Jed Watson.
1385
- Licensed under the MIT License (MIT), see
1386
- http://jedwatson.github.io/classnames
1387
- *)
1388
- */
1389
- //# sourceMappingURL=react-tooltip.esm.js.map