react-tooltip 5.10.1 → 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.
- package/dist/react-tooltip.cjs +840 -0
- package/dist/react-tooltip.cjs.map +1 -0
- package/dist/react-tooltip.css +32 -23
- package/dist/react-tooltip.min.cjs +2 -0
- package/dist/react-tooltip.min.cjs.map +1 -0
- package/dist/react-tooltip.min.css +1 -0
- package/dist/react-tooltip.min.mjs +2 -0
- package/dist/react-tooltip.min.mjs.map +1 -0
- package/dist/react-tooltip.mjs +830 -0
- package/dist/react-tooltip.mjs.map +1 -0
- package/dist/react-tooltip.umd.js +841 -0
- package/dist/react-tooltip.umd.js.map +1 -0
- package/dist/react-tooltip.umd.min.js +2 -0
- package/dist/react-tooltip.umd.min.js.map +1 -0
- package/package.json +14 -2
- package/tsconfig.json +3 -2
- package/dist/react-tooltip.cjs.js +0 -923
- package/dist/react-tooltip.cjs.js.map +0 -7
- package/dist/react-tooltip.cjs.min.js +0 -2
- package/dist/react-tooltip.cjs.min.js.map +0 -7
- package/dist/react-tooltip.css.map +0 -7
- package/dist/react-tooltip.esm.js +0 -896
- package/dist/react-tooltip.esm.js.map +0 -7
- package/dist/react-tooltip.esm.min.js +0 -2
- package/dist/react-tooltip.esm.min.js.map +0 -7
- package/dist/react-tooltip.iife.js +0 -918
- package/dist/react-tooltip.iife.js.map +0 -7
- package/dist/react-tooltip.iife.min.js +0 -2
- package/dist/react-tooltip.iife.min.js.map +0 -7
- package/dist/react-tooltip.min.js +0 -2
- package/dist/react-tooltip.min.js.map +0 -7
|
@@ -1,923 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/index.tsx
|
|
31
|
-
var src_exports = {};
|
|
32
|
-
__export(src_exports, {
|
|
33
|
-
Tooltip: () => TooltipController_default,
|
|
34
|
-
TooltipProvider: () => TooltipProvider_default,
|
|
35
|
-
TooltipWrapper: () => TooltipWrapper_default
|
|
36
|
-
});
|
|
37
|
-
module.exports = __toCommonJS(src_exports);
|
|
38
|
-
|
|
39
|
-
// src/components/TooltipController/TooltipController.tsx
|
|
40
|
-
var import_react5 = require("react");
|
|
41
|
-
|
|
42
|
-
// src/components/Tooltip/Tooltip.tsx
|
|
43
|
-
var import_react4 = require("react");
|
|
44
|
-
var import_classnames2 = __toESM(require("classnames"));
|
|
45
|
-
|
|
46
|
-
// src/utils/debounce.ts
|
|
47
|
-
var debounce = (func, wait, immediate) => {
|
|
48
|
-
let timeout = null;
|
|
49
|
-
return function debounced(...args) {
|
|
50
|
-
const later = () => {
|
|
51
|
-
timeout = null;
|
|
52
|
-
if (!immediate) {
|
|
53
|
-
func.apply(this, args);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
if (timeout) {
|
|
57
|
-
clearTimeout(timeout);
|
|
58
|
-
}
|
|
59
|
-
timeout = setTimeout(later, wait);
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
var debounce_default = debounce;
|
|
63
|
-
|
|
64
|
-
// src/components/TooltipProvider/TooltipProvider.tsx
|
|
65
|
-
var import_react = require("react");
|
|
66
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
67
|
-
var DEFAULT_TOOLTIP_ID = "DEFAULT_TOOLTIP_ID";
|
|
68
|
-
var DEFAULT_CONTEXT_DATA = {
|
|
69
|
-
anchorRefs: /* @__PURE__ */ new Set(),
|
|
70
|
-
activeAnchor: { current: null },
|
|
71
|
-
attach: () => {
|
|
72
|
-
},
|
|
73
|
-
detach: () => {
|
|
74
|
-
},
|
|
75
|
-
setActiveAnchor: () => {
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
var DEFAULT_CONTEXT_DATA_WRAPPER = {
|
|
79
|
-
getTooltipData: () => DEFAULT_CONTEXT_DATA
|
|
80
|
-
};
|
|
81
|
-
var TooltipContext = (0, import_react.createContext)(DEFAULT_CONTEXT_DATA_WRAPPER);
|
|
82
|
-
var TooltipProvider = ({ children }) => {
|
|
83
|
-
const [anchorRefMap, setAnchorRefMap] = (0, import_react.useState)({
|
|
84
|
-
[DEFAULT_TOOLTIP_ID]: /* @__PURE__ */ new Set()
|
|
85
|
-
});
|
|
86
|
-
const [activeAnchorMap, setActiveAnchorMap] = (0, import_react.useState)({
|
|
87
|
-
[DEFAULT_TOOLTIP_ID]: { current: null }
|
|
88
|
-
});
|
|
89
|
-
const attach = (tooltipId, ...refs) => {
|
|
90
|
-
setAnchorRefMap((oldMap) => {
|
|
91
|
-
var _a;
|
|
92
|
-
const tooltipRefs = (_a = oldMap[tooltipId]) != null ? _a : /* @__PURE__ */ new Set();
|
|
93
|
-
refs.forEach((ref) => tooltipRefs.add(ref));
|
|
94
|
-
return { ...oldMap, [tooltipId]: new Set(tooltipRefs) };
|
|
95
|
-
});
|
|
96
|
-
};
|
|
97
|
-
const detach = (tooltipId, ...refs) => {
|
|
98
|
-
setAnchorRefMap((oldMap) => {
|
|
99
|
-
const tooltipRefs = oldMap[tooltipId];
|
|
100
|
-
if (!tooltipRefs) {
|
|
101
|
-
return oldMap;
|
|
102
|
-
}
|
|
103
|
-
refs.forEach((ref) => tooltipRefs.delete(ref));
|
|
104
|
-
return { ...oldMap };
|
|
105
|
-
});
|
|
106
|
-
};
|
|
107
|
-
const setActiveAnchor = (tooltipId, ref) => {
|
|
108
|
-
setActiveAnchorMap((oldMap) => {
|
|
109
|
-
var _a;
|
|
110
|
-
if (((_a = oldMap[tooltipId]) == null ? void 0 : _a.current) === ref.current) {
|
|
111
|
-
return oldMap;
|
|
112
|
-
}
|
|
113
|
-
return { ...oldMap, [tooltipId]: ref };
|
|
114
|
-
});
|
|
115
|
-
};
|
|
116
|
-
const getTooltipData = (0, import_react.useCallback)(
|
|
117
|
-
(tooltipId = DEFAULT_TOOLTIP_ID) => {
|
|
118
|
-
var _a, _b;
|
|
119
|
-
return {
|
|
120
|
-
anchorRefs: (_a = anchorRefMap[tooltipId]) != null ? _a : /* @__PURE__ */ new Set(),
|
|
121
|
-
activeAnchor: (_b = activeAnchorMap[tooltipId]) != null ? _b : { current: null },
|
|
122
|
-
attach: (...refs) => attach(tooltipId, ...refs),
|
|
123
|
-
detach: (...refs) => detach(tooltipId, ...refs),
|
|
124
|
-
setActiveAnchor: (ref) => setActiveAnchor(tooltipId, ref)
|
|
125
|
-
};
|
|
126
|
-
},
|
|
127
|
-
[anchorRefMap, activeAnchorMap, attach, detach]
|
|
128
|
-
);
|
|
129
|
-
const context = (0, import_react.useMemo)(() => {
|
|
130
|
-
return {
|
|
131
|
-
getTooltipData
|
|
132
|
-
};
|
|
133
|
-
}, [getTooltipData]);
|
|
134
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TooltipContext.Provider, { value: context, children });
|
|
135
|
-
};
|
|
136
|
-
function useTooltip(tooltipId = DEFAULT_TOOLTIP_ID) {
|
|
137
|
-
return (0, import_react.useContext)(TooltipContext).getTooltipData(tooltipId);
|
|
138
|
-
}
|
|
139
|
-
var TooltipProvider_default = TooltipProvider;
|
|
140
|
-
|
|
141
|
-
// src/components/TooltipProvider/TooltipWrapper.tsx
|
|
142
|
-
var import_react2 = require("react");
|
|
143
|
-
var import_classnames = __toESM(require("classnames"));
|
|
144
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
145
|
-
var TooltipWrapper = ({
|
|
146
|
-
tooltipId,
|
|
147
|
-
children,
|
|
148
|
-
className,
|
|
149
|
-
place,
|
|
150
|
-
content,
|
|
151
|
-
html,
|
|
152
|
-
variant,
|
|
153
|
-
offset: offset2,
|
|
154
|
-
wrapper,
|
|
155
|
-
events,
|
|
156
|
-
positionStrategy,
|
|
157
|
-
delayShow,
|
|
158
|
-
delayHide
|
|
159
|
-
}) => {
|
|
160
|
-
const { attach, detach } = useTooltip(tooltipId);
|
|
161
|
-
const anchorRef = (0, import_react2.useRef)(null);
|
|
162
|
-
(0, import_react2.useEffect)(() => {
|
|
163
|
-
attach(anchorRef);
|
|
164
|
-
return () => {
|
|
165
|
-
detach(anchorRef);
|
|
166
|
-
};
|
|
167
|
-
}, []);
|
|
168
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
169
|
-
"span",
|
|
170
|
-
{
|
|
171
|
-
ref: anchorRef,
|
|
172
|
-
className: (0, import_classnames.default)("react-tooltip-wrapper", className),
|
|
173
|
-
"data-tooltip-place": place,
|
|
174
|
-
"data-tooltip-content": content,
|
|
175
|
-
"data-tooltip-html": html,
|
|
176
|
-
"data-tooltip-variant": variant,
|
|
177
|
-
"data-tooltip-offset": offset2,
|
|
178
|
-
"data-tooltip-wrapper": wrapper,
|
|
179
|
-
"data-tooltip-events": events,
|
|
180
|
-
"data-tooltip-position-strategy": positionStrategy,
|
|
181
|
-
"data-tooltip-delay-show": delayShow,
|
|
182
|
-
"data-tooltip-delay-hide": delayHide,
|
|
183
|
-
children
|
|
184
|
-
}
|
|
185
|
-
);
|
|
186
|
-
};
|
|
187
|
-
var TooltipWrapper_default = TooltipWrapper;
|
|
188
|
-
|
|
189
|
-
// src/utils/use-isomorphic-layout-effect.ts
|
|
190
|
-
var import_react3 = require("react");
|
|
191
|
-
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? import_react3.useLayoutEffect : import_react3.useEffect;
|
|
192
|
-
var use_isomorphic_layout_effect_default = useIsomorphicLayoutEffect;
|
|
193
|
-
|
|
194
|
-
// src/utils/compute-positions.ts
|
|
195
|
-
var import_dom = require("@floating-ui/dom");
|
|
196
|
-
var computeTooltipPosition = async ({
|
|
197
|
-
elementReference = null,
|
|
198
|
-
tooltipReference = null,
|
|
199
|
-
tooltipArrowReference = null,
|
|
200
|
-
place = "top",
|
|
201
|
-
offset: offsetValue = 10,
|
|
202
|
-
strategy = "absolute",
|
|
203
|
-
middlewares = [(0, import_dom.offset)(Number(offsetValue)), (0, import_dom.flip)(), (0, import_dom.shift)({ padding: 5 })]
|
|
204
|
-
}) => {
|
|
205
|
-
if (!elementReference) {
|
|
206
|
-
return { tooltipStyles: {}, tooltipArrowStyles: {}, place };
|
|
207
|
-
}
|
|
208
|
-
if (tooltipReference === null) {
|
|
209
|
-
return { tooltipStyles: {}, tooltipArrowStyles: {}, place };
|
|
210
|
-
}
|
|
211
|
-
const middleware = middlewares;
|
|
212
|
-
if (tooltipArrowReference) {
|
|
213
|
-
middleware.push((0, import_dom.arrow)({ element: tooltipArrowReference, padding: 5 }));
|
|
214
|
-
return (0, import_dom.computePosition)(elementReference, tooltipReference, {
|
|
215
|
-
placement: place,
|
|
216
|
-
strategy,
|
|
217
|
-
middleware
|
|
218
|
-
}).then(({ x, y, placement, middlewareData }) => {
|
|
219
|
-
var _a, _b;
|
|
220
|
-
const styles = { left: `${x}px`, top: `${y}px` };
|
|
221
|
-
const { x: arrowX, y: arrowY } = (_a = middlewareData.arrow) != null ? _a : { x: 0, y: 0 };
|
|
222
|
-
const staticSide = (_b = {
|
|
223
|
-
top: "bottom",
|
|
224
|
-
right: "left",
|
|
225
|
-
bottom: "top",
|
|
226
|
-
left: "right"
|
|
227
|
-
}[placement.split("-")[0]]) != null ? _b : "bottom";
|
|
228
|
-
const arrowStyle = {
|
|
229
|
-
left: arrowX != null ? `${arrowX}px` : "",
|
|
230
|
-
top: arrowY != null ? `${arrowY}px` : "",
|
|
231
|
-
right: "",
|
|
232
|
-
bottom: "",
|
|
233
|
-
[staticSide]: "-4px"
|
|
234
|
-
};
|
|
235
|
-
return { tooltipStyles: styles, tooltipArrowStyles: arrowStyle, place: placement };
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
return (0, import_dom.computePosition)(elementReference, tooltipReference, {
|
|
239
|
-
placement: "bottom",
|
|
240
|
-
strategy,
|
|
241
|
-
middleware
|
|
242
|
-
}).then(({ x, y, placement }) => {
|
|
243
|
-
const styles = { left: `${x}px`, top: `${y}px` };
|
|
244
|
-
return { tooltipStyles: styles, tooltipArrowStyles: {}, place: placement };
|
|
245
|
-
});
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
// esbuild-css-modules-plugin-namespace:./src/components/Tooltip/styles.module.css?esbuild-css-modules-plugin-building
|
|
249
|
-
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" };
|
|
250
|
-
|
|
251
|
-
// src/components/Tooltip/Tooltip.tsx
|
|
252
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
253
|
-
var Tooltip = ({
|
|
254
|
-
// props
|
|
255
|
-
id,
|
|
256
|
-
className,
|
|
257
|
-
classNameArrow,
|
|
258
|
-
variant = "dark",
|
|
259
|
-
anchorId,
|
|
260
|
-
anchorSelect,
|
|
261
|
-
place = "top",
|
|
262
|
-
offset: offset2 = 10,
|
|
263
|
-
events = ["hover"],
|
|
264
|
-
openOnClick = false,
|
|
265
|
-
positionStrategy = "absolute",
|
|
266
|
-
middlewares,
|
|
267
|
-
wrapper: WrapperElement,
|
|
268
|
-
delayShow = 0,
|
|
269
|
-
delayHide = 0,
|
|
270
|
-
float = false,
|
|
271
|
-
noArrow = false,
|
|
272
|
-
clickable = false,
|
|
273
|
-
closeOnEsc = false,
|
|
274
|
-
style: externalStyles,
|
|
275
|
-
position,
|
|
276
|
-
afterShow,
|
|
277
|
-
afterHide,
|
|
278
|
-
// props handled by controller
|
|
279
|
-
content,
|
|
280
|
-
isOpen,
|
|
281
|
-
setIsOpen,
|
|
282
|
-
activeAnchor,
|
|
283
|
-
setActiveAnchor
|
|
284
|
-
}) => {
|
|
285
|
-
const tooltipRef = (0, import_react4.useRef)(null);
|
|
286
|
-
const tooltipArrowRef = (0, import_react4.useRef)(null);
|
|
287
|
-
const tooltipShowDelayTimerRef = (0, import_react4.useRef)(null);
|
|
288
|
-
const tooltipHideDelayTimerRef = (0, import_react4.useRef)(null);
|
|
289
|
-
const [actualPlacement, setActualPlacement] = (0, import_react4.useState)(place);
|
|
290
|
-
const [inlineStyles, setInlineStyles] = (0, import_react4.useState)({});
|
|
291
|
-
const [inlineArrowStyles, setInlineArrowStyles] = (0, import_react4.useState)({});
|
|
292
|
-
const [show, setShow] = (0, import_react4.useState)(false);
|
|
293
|
-
const [rendered, setRendered] = (0, import_react4.useState)(false);
|
|
294
|
-
const wasShowing = (0, import_react4.useRef)(false);
|
|
295
|
-
const lastFloatPosition = (0, import_react4.useRef)(null);
|
|
296
|
-
const { anchorRefs, setActiveAnchor: setProviderActiveAnchor } = useTooltip(id);
|
|
297
|
-
const hoveringTooltip = (0, import_react4.useRef)(false);
|
|
298
|
-
const [anchorsBySelect, setAnchorsBySelect] = (0, import_react4.useState)([]);
|
|
299
|
-
const mounted = (0, import_react4.useRef)(false);
|
|
300
|
-
const shouldOpenOnClick = openOnClick || events.includes("click");
|
|
301
|
-
use_isomorphic_layout_effect_default(() => {
|
|
302
|
-
mounted.current = true;
|
|
303
|
-
return () => {
|
|
304
|
-
mounted.current = false;
|
|
305
|
-
};
|
|
306
|
-
}, []);
|
|
307
|
-
(0, import_react4.useEffect)(() => {
|
|
308
|
-
if (!show) {
|
|
309
|
-
const timeout = setTimeout(() => {
|
|
310
|
-
setRendered(false);
|
|
311
|
-
}, 150);
|
|
312
|
-
return () => {
|
|
313
|
-
clearTimeout(timeout);
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
return () => null;
|
|
317
|
-
}, [show]);
|
|
318
|
-
const handleShow = (value) => {
|
|
319
|
-
if (!mounted.current) {
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
if (value) {
|
|
323
|
-
setRendered(true);
|
|
324
|
-
}
|
|
325
|
-
setTimeout(() => {
|
|
326
|
-
if (!mounted.current) {
|
|
327
|
-
return;
|
|
328
|
-
}
|
|
329
|
-
setIsOpen == null ? void 0 : setIsOpen(value);
|
|
330
|
-
if (isOpen === void 0) {
|
|
331
|
-
setShow(value);
|
|
332
|
-
}
|
|
333
|
-
}, 10);
|
|
334
|
-
};
|
|
335
|
-
(0, import_react4.useEffect)(() => {
|
|
336
|
-
if (isOpen === void 0) {
|
|
337
|
-
return () => null;
|
|
338
|
-
}
|
|
339
|
-
if (isOpen) {
|
|
340
|
-
setRendered(true);
|
|
341
|
-
}
|
|
342
|
-
const timeout = setTimeout(() => {
|
|
343
|
-
setShow(isOpen);
|
|
344
|
-
}, 10);
|
|
345
|
-
return () => {
|
|
346
|
-
clearTimeout(timeout);
|
|
347
|
-
};
|
|
348
|
-
}, [isOpen]);
|
|
349
|
-
(0, import_react4.useEffect)(() => {
|
|
350
|
-
if (show === wasShowing.current) {
|
|
351
|
-
return;
|
|
352
|
-
}
|
|
353
|
-
wasShowing.current = show;
|
|
354
|
-
if (show) {
|
|
355
|
-
afterShow == null ? void 0 : afterShow();
|
|
356
|
-
} else {
|
|
357
|
-
afterHide == null ? void 0 : afterHide();
|
|
358
|
-
}
|
|
359
|
-
}, [show]);
|
|
360
|
-
const handleShowTooltipDelayed = () => {
|
|
361
|
-
if (tooltipShowDelayTimerRef.current) {
|
|
362
|
-
clearTimeout(tooltipShowDelayTimerRef.current);
|
|
363
|
-
}
|
|
364
|
-
tooltipShowDelayTimerRef.current = setTimeout(() => {
|
|
365
|
-
handleShow(true);
|
|
366
|
-
}, delayShow);
|
|
367
|
-
};
|
|
368
|
-
const handleHideTooltipDelayed = (delay = delayHide) => {
|
|
369
|
-
if (tooltipHideDelayTimerRef.current) {
|
|
370
|
-
clearTimeout(tooltipHideDelayTimerRef.current);
|
|
371
|
-
}
|
|
372
|
-
tooltipHideDelayTimerRef.current = setTimeout(() => {
|
|
373
|
-
if (hoveringTooltip.current) {
|
|
374
|
-
return;
|
|
375
|
-
}
|
|
376
|
-
handleShow(false);
|
|
377
|
-
}, delay);
|
|
378
|
-
};
|
|
379
|
-
const handleShowTooltip = (event) => {
|
|
380
|
-
var _a;
|
|
381
|
-
if (!event) {
|
|
382
|
-
return;
|
|
383
|
-
}
|
|
384
|
-
if (delayShow) {
|
|
385
|
-
handleShowTooltipDelayed();
|
|
386
|
-
} else {
|
|
387
|
-
handleShow(true);
|
|
388
|
-
}
|
|
389
|
-
const target = (_a = event.currentTarget) != null ? _a : event.target;
|
|
390
|
-
setActiveAnchor(target);
|
|
391
|
-
setProviderActiveAnchor({ current: target });
|
|
392
|
-
if (tooltipHideDelayTimerRef.current) {
|
|
393
|
-
clearTimeout(tooltipHideDelayTimerRef.current);
|
|
394
|
-
}
|
|
395
|
-
};
|
|
396
|
-
const handleHideTooltip = () => {
|
|
397
|
-
if (clickable) {
|
|
398
|
-
handleHideTooltipDelayed(delayHide || 100);
|
|
399
|
-
} else if (delayHide) {
|
|
400
|
-
handleHideTooltipDelayed();
|
|
401
|
-
} else {
|
|
402
|
-
handleShow(false);
|
|
403
|
-
}
|
|
404
|
-
if (tooltipShowDelayTimerRef.current) {
|
|
405
|
-
clearTimeout(tooltipShowDelayTimerRef.current);
|
|
406
|
-
}
|
|
407
|
-
};
|
|
408
|
-
const handleTooltipPosition = ({ x, y }) => {
|
|
409
|
-
const virtualElement = {
|
|
410
|
-
getBoundingClientRect() {
|
|
411
|
-
return {
|
|
412
|
-
x,
|
|
413
|
-
y,
|
|
414
|
-
width: 0,
|
|
415
|
-
height: 0,
|
|
416
|
-
top: y,
|
|
417
|
-
left: x,
|
|
418
|
-
right: x,
|
|
419
|
-
bottom: y
|
|
420
|
-
};
|
|
421
|
-
}
|
|
422
|
-
};
|
|
423
|
-
computeTooltipPosition({
|
|
424
|
-
place,
|
|
425
|
-
offset: offset2,
|
|
426
|
-
elementReference: virtualElement,
|
|
427
|
-
tooltipReference: tooltipRef.current,
|
|
428
|
-
tooltipArrowReference: tooltipArrowRef.current,
|
|
429
|
-
strategy: positionStrategy,
|
|
430
|
-
middlewares
|
|
431
|
-
}).then((computedStylesData) => {
|
|
432
|
-
if (Object.keys(computedStylesData.tooltipStyles).length) {
|
|
433
|
-
setInlineStyles(computedStylesData.tooltipStyles);
|
|
434
|
-
}
|
|
435
|
-
if (Object.keys(computedStylesData.tooltipArrowStyles).length) {
|
|
436
|
-
setInlineArrowStyles(computedStylesData.tooltipArrowStyles);
|
|
437
|
-
}
|
|
438
|
-
setActualPlacement(computedStylesData.place);
|
|
439
|
-
});
|
|
440
|
-
};
|
|
441
|
-
const handleMouseMove = (event) => {
|
|
442
|
-
if (!event) {
|
|
443
|
-
return;
|
|
444
|
-
}
|
|
445
|
-
const mouseEvent = event;
|
|
446
|
-
const mousePosition = {
|
|
447
|
-
x: mouseEvent.clientX,
|
|
448
|
-
y: mouseEvent.clientY
|
|
449
|
-
};
|
|
450
|
-
handleTooltipPosition(mousePosition);
|
|
451
|
-
lastFloatPosition.current = mousePosition;
|
|
452
|
-
};
|
|
453
|
-
const handleClickTooltipAnchor = (event) => {
|
|
454
|
-
handleShowTooltip(event);
|
|
455
|
-
if (delayHide) {
|
|
456
|
-
handleHideTooltipDelayed();
|
|
457
|
-
}
|
|
458
|
-
};
|
|
459
|
-
const handleClickOutsideAnchors = (event) => {
|
|
460
|
-
var _a;
|
|
461
|
-
const anchorById = document.querySelector(`[id='${anchorId}']`);
|
|
462
|
-
const anchors = [anchorById, ...anchorsBySelect];
|
|
463
|
-
if (anchors.some((anchor) => anchor == null ? void 0 : anchor.contains(event.target))) {
|
|
464
|
-
return;
|
|
465
|
-
}
|
|
466
|
-
if ((_a = tooltipRef.current) == null ? void 0 : _a.contains(event.target)) {
|
|
467
|
-
return;
|
|
468
|
-
}
|
|
469
|
-
handleShow(false);
|
|
470
|
-
};
|
|
471
|
-
const handleEsc = (event) => {
|
|
472
|
-
if (event.key !== "Escape") {
|
|
473
|
-
return;
|
|
474
|
-
}
|
|
475
|
-
handleShow(false);
|
|
476
|
-
};
|
|
477
|
-
const debouncedHandleShowTooltip = debounce_default(handleShowTooltip, 50);
|
|
478
|
-
const debouncedHandleHideTooltip = debounce_default(handleHideTooltip, 50);
|
|
479
|
-
(0, import_react4.useEffect)(() => {
|
|
480
|
-
var _a, _b;
|
|
481
|
-
const elementRefs = new Set(anchorRefs);
|
|
482
|
-
anchorsBySelect.forEach((anchor) => {
|
|
483
|
-
elementRefs.add({ current: anchor });
|
|
484
|
-
});
|
|
485
|
-
const anchorById = document.querySelector(`[id='${anchorId}']`);
|
|
486
|
-
if (anchorById) {
|
|
487
|
-
elementRefs.add({ current: anchorById });
|
|
488
|
-
}
|
|
489
|
-
if (closeOnEsc) {
|
|
490
|
-
window.addEventListener("keydown", handleEsc);
|
|
491
|
-
}
|
|
492
|
-
const enabledEvents = [];
|
|
493
|
-
if (shouldOpenOnClick) {
|
|
494
|
-
window.addEventListener("click", handleClickOutsideAnchors);
|
|
495
|
-
enabledEvents.push({ event: "click", listener: handleClickTooltipAnchor });
|
|
496
|
-
} else {
|
|
497
|
-
enabledEvents.push(
|
|
498
|
-
{ event: "mouseenter", listener: debouncedHandleShowTooltip },
|
|
499
|
-
{ event: "mouseleave", listener: debouncedHandleHideTooltip },
|
|
500
|
-
{ event: "focus", listener: debouncedHandleShowTooltip },
|
|
501
|
-
{ event: "blur", listener: debouncedHandleHideTooltip }
|
|
502
|
-
);
|
|
503
|
-
if (float) {
|
|
504
|
-
enabledEvents.push({
|
|
505
|
-
event: "mousemove",
|
|
506
|
-
listener: handleMouseMove
|
|
507
|
-
});
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
const handleMouseEnterTooltip = () => {
|
|
511
|
-
hoveringTooltip.current = true;
|
|
512
|
-
};
|
|
513
|
-
const handleMouseLeaveTooltip = () => {
|
|
514
|
-
hoveringTooltip.current = false;
|
|
515
|
-
handleHideTooltip();
|
|
516
|
-
};
|
|
517
|
-
if (clickable && !shouldOpenOnClick) {
|
|
518
|
-
(_a = tooltipRef.current) == null ? void 0 : _a.addEventListener("mouseenter", handleMouseEnterTooltip);
|
|
519
|
-
(_b = tooltipRef.current) == null ? void 0 : _b.addEventListener("mouseleave", handleMouseLeaveTooltip);
|
|
520
|
-
}
|
|
521
|
-
enabledEvents.forEach(({ event, listener }) => {
|
|
522
|
-
elementRefs.forEach((ref) => {
|
|
523
|
-
var _a2;
|
|
524
|
-
(_a2 = ref.current) == null ? void 0 : _a2.addEventListener(event, listener);
|
|
525
|
-
});
|
|
526
|
-
});
|
|
527
|
-
return () => {
|
|
528
|
-
var _a2, _b2;
|
|
529
|
-
if (shouldOpenOnClick) {
|
|
530
|
-
window.removeEventListener("click", handleClickOutsideAnchors);
|
|
531
|
-
}
|
|
532
|
-
if (closeOnEsc) {
|
|
533
|
-
window.removeEventListener("keydown", handleEsc);
|
|
534
|
-
}
|
|
535
|
-
if (clickable && !shouldOpenOnClick) {
|
|
536
|
-
(_a2 = tooltipRef.current) == null ? void 0 : _a2.removeEventListener("mouseenter", handleMouseEnterTooltip);
|
|
537
|
-
(_b2 = tooltipRef.current) == null ? void 0 : _b2.removeEventListener("mouseleave", handleMouseLeaveTooltip);
|
|
538
|
-
}
|
|
539
|
-
enabledEvents.forEach(({ event, listener }) => {
|
|
540
|
-
elementRefs.forEach((ref) => {
|
|
541
|
-
var _a3;
|
|
542
|
-
(_a3 = ref.current) == null ? void 0 : _a3.removeEventListener(event, listener);
|
|
543
|
-
});
|
|
544
|
-
});
|
|
545
|
-
};
|
|
546
|
-
}, [rendered, anchorRefs, anchorsBySelect, closeOnEsc, events]);
|
|
547
|
-
(0, import_react4.useEffect)(() => {
|
|
548
|
-
let selector = anchorSelect != null ? anchorSelect : "";
|
|
549
|
-
if (!selector && id) {
|
|
550
|
-
selector = `[data-tooltip-id='${id}']`;
|
|
551
|
-
}
|
|
552
|
-
const documentObserverCallback = (mutationList) => {
|
|
553
|
-
const newAnchors = [];
|
|
554
|
-
mutationList.forEach((mutation) => {
|
|
555
|
-
if (mutation.type === "attributes" && mutation.attributeName === "data-tooltip-id") {
|
|
556
|
-
const newId = mutation.target.getAttribute("data-tooltip-id");
|
|
557
|
-
if (newId === id) {
|
|
558
|
-
newAnchors.push(mutation.target);
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
if (mutation.type !== "childList") {
|
|
562
|
-
return;
|
|
563
|
-
}
|
|
564
|
-
if (activeAnchor) {
|
|
565
|
-
;
|
|
566
|
-
[...mutation.removedNodes].some((node) => {
|
|
567
|
-
var _a;
|
|
568
|
-
if ((_a = node == null ? void 0 : node.contains) == null ? void 0 : _a.call(node, activeAnchor)) {
|
|
569
|
-
setRendered(false);
|
|
570
|
-
handleShow(false);
|
|
571
|
-
setActiveAnchor(null);
|
|
572
|
-
return true;
|
|
573
|
-
}
|
|
574
|
-
return false;
|
|
575
|
-
});
|
|
576
|
-
}
|
|
577
|
-
if (!selector) {
|
|
578
|
-
return;
|
|
579
|
-
}
|
|
580
|
-
try {
|
|
581
|
-
const elements = [...mutation.addedNodes].filter((node) => node.nodeType === 1);
|
|
582
|
-
newAnchors.push(
|
|
583
|
-
...elements.filter(
|
|
584
|
-
(element) => element.matches(selector)
|
|
585
|
-
)
|
|
586
|
-
);
|
|
587
|
-
newAnchors.push(
|
|
588
|
-
...elements.flatMap(
|
|
589
|
-
(element) => [...element.querySelectorAll(selector)]
|
|
590
|
-
)
|
|
591
|
-
);
|
|
592
|
-
} catch (e) {
|
|
593
|
-
}
|
|
594
|
-
});
|
|
595
|
-
if (newAnchors.length) {
|
|
596
|
-
setAnchorsBySelect((anchors) => [...anchors, ...newAnchors]);
|
|
597
|
-
}
|
|
598
|
-
};
|
|
599
|
-
const documentObserver = new MutationObserver(documentObserverCallback);
|
|
600
|
-
documentObserver.observe(document.body, {
|
|
601
|
-
childList: true,
|
|
602
|
-
subtree: true,
|
|
603
|
-
attributes: true,
|
|
604
|
-
attributeFilter: ["data-tooltip-id"]
|
|
605
|
-
});
|
|
606
|
-
return () => {
|
|
607
|
-
documentObserver.disconnect();
|
|
608
|
-
};
|
|
609
|
-
}, [id, anchorSelect, activeAnchor]);
|
|
610
|
-
(0, import_react4.useEffect)(() => {
|
|
611
|
-
if (position) {
|
|
612
|
-
handleTooltipPosition(position);
|
|
613
|
-
return;
|
|
614
|
-
}
|
|
615
|
-
if (float) {
|
|
616
|
-
if (lastFloatPosition.current) {
|
|
617
|
-
handleTooltipPosition(lastFloatPosition.current);
|
|
618
|
-
}
|
|
619
|
-
return;
|
|
620
|
-
}
|
|
621
|
-
computeTooltipPosition({
|
|
622
|
-
place,
|
|
623
|
-
offset: offset2,
|
|
624
|
-
elementReference: activeAnchor,
|
|
625
|
-
tooltipReference: tooltipRef.current,
|
|
626
|
-
tooltipArrowReference: tooltipArrowRef.current,
|
|
627
|
-
strategy: positionStrategy,
|
|
628
|
-
middlewares
|
|
629
|
-
}).then((computedStylesData) => {
|
|
630
|
-
if (!mounted.current) {
|
|
631
|
-
return;
|
|
632
|
-
}
|
|
633
|
-
if (Object.keys(computedStylesData.tooltipStyles).length) {
|
|
634
|
-
setInlineStyles(computedStylesData.tooltipStyles);
|
|
635
|
-
}
|
|
636
|
-
if (Object.keys(computedStylesData.tooltipArrowStyles).length) {
|
|
637
|
-
setInlineArrowStyles(computedStylesData.tooltipArrowStyles);
|
|
638
|
-
}
|
|
639
|
-
setActualPlacement(computedStylesData.place);
|
|
640
|
-
});
|
|
641
|
-
}, [show, activeAnchor, content, place, offset2, positionStrategy, position]);
|
|
642
|
-
(0, import_react4.useEffect)(() => {
|
|
643
|
-
var _a;
|
|
644
|
-
const anchorById = document.querySelector(`[id='${anchorId}']`);
|
|
645
|
-
const anchors = [...anchorsBySelect, anchorById];
|
|
646
|
-
if (!activeAnchor || !anchors.includes(activeAnchor)) {
|
|
647
|
-
setActiveAnchor((_a = anchorsBySelect[0]) != null ? _a : anchorById);
|
|
648
|
-
}
|
|
649
|
-
}, [anchorId, anchorsBySelect, activeAnchor]);
|
|
650
|
-
(0, import_react4.useEffect)(() => {
|
|
651
|
-
return () => {
|
|
652
|
-
if (tooltipShowDelayTimerRef.current) {
|
|
653
|
-
clearTimeout(tooltipShowDelayTimerRef.current);
|
|
654
|
-
}
|
|
655
|
-
if (tooltipHideDelayTimerRef.current) {
|
|
656
|
-
clearTimeout(tooltipHideDelayTimerRef.current);
|
|
657
|
-
}
|
|
658
|
-
};
|
|
659
|
-
}, []);
|
|
660
|
-
(0, import_react4.useEffect)(() => {
|
|
661
|
-
let selector = anchorSelect;
|
|
662
|
-
if (!selector && id) {
|
|
663
|
-
selector = `[data-tooltip-id='${id}']`;
|
|
664
|
-
}
|
|
665
|
-
if (!selector) {
|
|
666
|
-
return;
|
|
667
|
-
}
|
|
668
|
-
try {
|
|
669
|
-
const anchors = Array.from(document.querySelectorAll(selector));
|
|
670
|
-
setAnchorsBySelect(anchors);
|
|
671
|
-
} catch (e) {
|
|
672
|
-
setAnchorsBySelect([]);
|
|
673
|
-
}
|
|
674
|
-
}, [id, anchorSelect]);
|
|
675
|
-
const canShow = content && show && Object.keys(inlineStyles).length > 0;
|
|
676
|
-
return rendered ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
677
|
-
WrapperElement,
|
|
678
|
-
{
|
|
679
|
-
id,
|
|
680
|
-
role: "tooltip",
|
|
681
|
-
className: (0, import_classnames2.default)(
|
|
682
|
-
"react-tooltip",
|
|
683
|
-
styles_module_default["tooltip"],
|
|
684
|
-
styles_module_default[variant],
|
|
685
|
-
className,
|
|
686
|
-
`react-tooltip__place-${actualPlacement}`,
|
|
687
|
-
{
|
|
688
|
-
[styles_module_default["show"]]: canShow,
|
|
689
|
-
[styles_module_default["fixed"]]: positionStrategy === "fixed",
|
|
690
|
-
[styles_module_default["clickable"]]: clickable
|
|
691
|
-
}
|
|
692
|
-
),
|
|
693
|
-
style: { ...externalStyles, ...inlineStyles },
|
|
694
|
-
ref: tooltipRef,
|
|
695
|
-
children: [
|
|
696
|
-
content,
|
|
697
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
698
|
-
WrapperElement,
|
|
699
|
-
{
|
|
700
|
-
className: (0, import_classnames2.default)("react-tooltip-arrow", styles_module_default["arrow"], classNameArrow, {
|
|
701
|
-
/**
|
|
702
|
-
* changed from dash `no-arrow` to camelcase because of:
|
|
703
|
-
* https://github.com/indooorsman/esbuild-css-modules-plugin/issues/42
|
|
704
|
-
*/
|
|
705
|
-
[styles_module_default["noArrow"]]: noArrow
|
|
706
|
-
}),
|
|
707
|
-
style: inlineArrowStyles,
|
|
708
|
-
ref: tooltipArrowRef
|
|
709
|
-
}
|
|
710
|
-
)
|
|
711
|
-
]
|
|
712
|
-
}
|
|
713
|
-
) : null;
|
|
714
|
-
};
|
|
715
|
-
var Tooltip_default = Tooltip;
|
|
716
|
-
|
|
717
|
-
// src/components/TooltipContent/TooltipContent.tsx
|
|
718
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
719
|
-
var TooltipContent = ({ content }) => {
|
|
720
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { dangerouslySetInnerHTML: { __html: content } });
|
|
721
|
-
};
|
|
722
|
-
var TooltipContent_default = TooltipContent;
|
|
723
|
-
|
|
724
|
-
// src/components/TooltipController/TooltipController.tsx
|
|
725
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
726
|
-
var TooltipController = ({
|
|
727
|
-
id,
|
|
728
|
-
anchorId,
|
|
729
|
-
anchorSelect,
|
|
730
|
-
content,
|
|
731
|
-
html,
|
|
732
|
-
render,
|
|
733
|
-
className,
|
|
734
|
-
classNameArrow,
|
|
735
|
-
variant = "dark",
|
|
736
|
-
place = "top",
|
|
737
|
-
offset: offset2 = 10,
|
|
738
|
-
wrapper = "div",
|
|
739
|
-
children = null,
|
|
740
|
-
events = ["hover"],
|
|
741
|
-
openOnClick = false,
|
|
742
|
-
positionStrategy = "absolute",
|
|
743
|
-
middlewares,
|
|
744
|
-
delayShow = 0,
|
|
745
|
-
delayHide = 0,
|
|
746
|
-
float = false,
|
|
747
|
-
noArrow = false,
|
|
748
|
-
clickable = false,
|
|
749
|
-
closeOnEsc = false,
|
|
750
|
-
style,
|
|
751
|
-
position,
|
|
752
|
-
isOpen,
|
|
753
|
-
setIsOpen,
|
|
754
|
-
afterShow,
|
|
755
|
-
afterHide
|
|
756
|
-
}) => {
|
|
757
|
-
const [tooltipContent, setTooltipContent] = (0, import_react5.useState)(content);
|
|
758
|
-
const [tooltipHtml, setTooltipHtml] = (0, import_react5.useState)(html);
|
|
759
|
-
const [tooltipPlace, setTooltipPlace] = (0, import_react5.useState)(place);
|
|
760
|
-
const [tooltipVariant, setTooltipVariant] = (0, import_react5.useState)(variant);
|
|
761
|
-
const [tooltipOffset, setTooltipOffset] = (0, import_react5.useState)(offset2);
|
|
762
|
-
const [tooltipDelayShow, setTooltipDelayShow] = (0, import_react5.useState)(delayShow);
|
|
763
|
-
const [tooltipDelayHide, setTooltipDelayHide] = (0, import_react5.useState)(delayHide);
|
|
764
|
-
const [tooltipFloat, setTooltipFloat] = (0, import_react5.useState)(float);
|
|
765
|
-
const [tooltipWrapper, setTooltipWrapper] = (0, import_react5.useState)(wrapper);
|
|
766
|
-
const [tooltipEvents, setTooltipEvents] = (0, import_react5.useState)(events);
|
|
767
|
-
const [tooltipPositionStrategy, setTooltipPositionStrategy] = (0, import_react5.useState)(positionStrategy);
|
|
768
|
-
const [activeAnchor, setActiveAnchor] = (0, import_react5.useState)(null);
|
|
769
|
-
const { anchorRefs, activeAnchor: providerActiveAnchor } = useTooltip(id);
|
|
770
|
-
const getDataAttributesFromAnchorElement = (elementReference) => {
|
|
771
|
-
const dataAttributes = elementReference == null ? void 0 : elementReference.getAttributeNames().reduce((acc, name) => {
|
|
772
|
-
var _a;
|
|
773
|
-
if (name.startsWith("data-tooltip-")) {
|
|
774
|
-
const parsedAttribute = name.replace(/^data-tooltip-/, "");
|
|
775
|
-
acc[parsedAttribute] = (_a = elementReference == null ? void 0 : elementReference.getAttribute(name)) != null ? _a : null;
|
|
776
|
-
}
|
|
777
|
-
return acc;
|
|
778
|
-
}, {});
|
|
779
|
-
return dataAttributes;
|
|
780
|
-
};
|
|
781
|
-
const applyAllDataAttributesFromAnchorElement = (dataAttributes) => {
|
|
782
|
-
const handleDataAttributes = {
|
|
783
|
-
place: (value) => {
|
|
784
|
-
setTooltipPlace(value != null ? value : place);
|
|
785
|
-
},
|
|
786
|
-
content: (value) => {
|
|
787
|
-
setTooltipContent(value != null ? value : content);
|
|
788
|
-
},
|
|
789
|
-
html: (value) => {
|
|
790
|
-
setTooltipHtml(value != null ? value : html);
|
|
791
|
-
},
|
|
792
|
-
variant: (value) => {
|
|
793
|
-
setTooltipVariant(value != null ? value : variant);
|
|
794
|
-
},
|
|
795
|
-
offset: (value) => {
|
|
796
|
-
setTooltipOffset(value === null ? offset2 : Number(value));
|
|
797
|
-
},
|
|
798
|
-
wrapper: (value) => {
|
|
799
|
-
setTooltipWrapper(value != null ? value : wrapper);
|
|
800
|
-
},
|
|
801
|
-
events: (value) => {
|
|
802
|
-
const parsed = value == null ? void 0 : value.split(" ");
|
|
803
|
-
setTooltipEvents(parsed != null ? parsed : events);
|
|
804
|
-
},
|
|
805
|
-
"position-strategy": (value) => {
|
|
806
|
-
setTooltipPositionStrategy(value != null ? value : positionStrategy);
|
|
807
|
-
},
|
|
808
|
-
"delay-show": (value) => {
|
|
809
|
-
setTooltipDelayShow(value === null ? delayShow : Number(value));
|
|
810
|
-
},
|
|
811
|
-
"delay-hide": (value) => {
|
|
812
|
-
setTooltipDelayHide(value === null ? delayHide : Number(value));
|
|
813
|
-
},
|
|
814
|
-
float: (value) => {
|
|
815
|
-
setTooltipFloat(value === null ? float : value === "true");
|
|
816
|
-
}
|
|
817
|
-
};
|
|
818
|
-
Object.values(handleDataAttributes).forEach((handler) => handler(null));
|
|
819
|
-
Object.entries(dataAttributes).forEach(([key, value]) => {
|
|
820
|
-
var _a;
|
|
821
|
-
(_a = handleDataAttributes[key]) == null ? void 0 : _a.call(handleDataAttributes, value);
|
|
822
|
-
});
|
|
823
|
-
};
|
|
824
|
-
(0, import_react5.useEffect)(() => {
|
|
825
|
-
setTooltipContent(content);
|
|
826
|
-
}, [content]);
|
|
827
|
-
(0, import_react5.useEffect)(() => {
|
|
828
|
-
setTooltipHtml(html);
|
|
829
|
-
}, [html]);
|
|
830
|
-
(0, import_react5.useEffect)(() => {
|
|
831
|
-
setTooltipPlace(place);
|
|
832
|
-
}, [place]);
|
|
833
|
-
(0, import_react5.useEffect)(() => {
|
|
834
|
-
var _a;
|
|
835
|
-
const elementRefs = new Set(anchorRefs);
|
|
836
|
-
let selector = anchorSelect;
|
|
837
|
-
if (!selector && id) {
|
|
838
|
-
selector = `[data-tooltip-id='${id}']`;
|
|
839
|
-
}
|
|
840
|
-
if (selector) {
|
|
841
|
-
try {
|
|
842
|
-
const anchorsBySelect = document.querySelectorAll(selector);
|
|
843
|
-
anchorsBySelect.forEach((anchor) => {
|
|
844
|
-
elementRefs.add({ current: anchor });
|
|
845
|
-
});
|
|
846
|
-
} catch (e) {
|
|
847
|
-
if (true) {
|
|
848
|
-
console.warn(`[react-tooltip] "${anchorSelect}" is not a valid CSS selector`);
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
const anchorById = document.querySelector(`[id='${anchorId}']`);
|
|
853
|
-
if (anchorById) {
|
|
854
|
-
elementRefs.add({ current: anchorById });
|
|
855
|
-
}
|
|
856
|
-
if (!elementRefs.size) {
|
|
857
|
-
return () => null;
|
|
858
|
-
}
|
|
859
|
-
const anchorElement = (_a = activeAnchor != null ? activeAnchor : anchorById) != null ? _a : providerActiveAnchor.current;
|
|
860
|
-
const observerCallback = (mutationList) => {
|
|
861
|
-
mutationList.forEach((mutation) => {
|
|
862
|
-
var _a2;
|
|
863
|
-
if (!anchorElement || mutation.type !== "attributes" || !((_a2 = mutation.attributeName) == null ? void 0 : _a2.startsWith("data-tooltip-"))) {
|
|
864
|
-
return;
|
|
865
|
-
}
|
|
866
|
-
const dataAttributes = getDataAttributesFromAnchorElement(anchorElement);
|
|
867
|
-
applyAllDataAttributesFromAnchorElement(dataAttributes);
|
|
868
|
-
});
|
|
869
|
-
};
|
|
870
|
-
const observer = new MutationObserver(observerCallback);
|
|
871
|
-
const observerConfig = { attributes: true, childList: false, subtree: false };
|
|
872
|
-
if (anchorElement) {
|
|
873
|
-
const dataAttributes = getDataAttributesFromAnchorElement(anchorElement);
|
|
874
|
-
applyAllDataAttributesFromAnchorElement(dataAttributes);
|
|
875
|
-
observer.observe(anchorElement, observerConfig);
|
|
876
|
-
}
|
|
877
|
-
return () => {
|
|
878
|
-
observer.disconnect();
|
|
879
|
-
};
|
|
880
|
-
}, [anchorRefs, providerActiveAnchor, activeAnchor, anchorId, anchorSelect]);
|
|
881
|
-
let renderedContent = children;
|
|
882
|
-
if (render) {
|
|
883
|
-
renderedContent = render({ content: tooltipContent != null ? tooltipContent : null, activeAnchor });
|
|
884
|
-
} else if (tooltipContent) {
|
|
885
|
-
renderedContent = tooltipContent;
|
|
886
|
-
}
|
|
887
|
-
if (tooltipHtml) {
|
|
888
|
-
renderedContent = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TooltipContent_default, { content: tooltipHtml });
|
|
889
|
-
}
|
|
890
|
-
const props = {
|
|
891
|
-
id,
|
|
892
|
-
anchorId,
|
|
893
|
-
anchorSelect,
|
|
894
|
-
className,
|
|
895
|
-
classNameArrow,
|
|
896
|
-
content: renderedContent,
|
|
897
|
-
place: tooltipPlace,
|
|
898
|
-
variant: tooltipVariant,
|
|
899
|
-
offset: tooltipOffset,
|
|
900
|
-
wrapper: tooltipWrapper,
|
|
901
|
-
events: tooltipEvents,
|
|
902
|
-
openOnClick,
|
|
903
|
-
positionStrategy: tooltipPositionStrategy,
|
|
904
|
-
middlewares,
|
|
905
|
-
delayShow: tooltipDelayShow,
|
|
906
|
-
delayHide: tooltipDelayHide,
|
|
907
|
-
float: tooltipFloat,
|
|
908
|
-
noArrow,
|
|
909
|
-
clickable,
|
|
910
|
-
closeOnEsc,
|
|
911
|
-
style,
|
|
912
|
-
position,
|
|
913
|
-
isOpen,
|
|
914
|
-
setIsOpen,
|
|
915
|
-
afterShow,
|
|
916
|
-
afterHide,
|
|
917
|
-
activeAnchor,
|
|
918
|
-
setActiveAnchor: (anchor) => setActiveAnchor(anchor)
|
|
919
|
-
};
|
|
920
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Tooltip_default, { ...props });
|
|
921
|
-
};
|
|
922
|
-
var TooltipController_default = TooltipController;
|
|
923
|
-
//# sourceMappingURL=react-tooltip.cjs.js.map
|