react-tooltip 5.9.1-beta.0 → 5.10.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -109,16 +109,9 @@
109
109
  };
110
110
  var debounce_default = debounce;
111
111
 
112
- // src/components/TooltipContent/TooltipContent.tsx
113
- var import_jsx_runtime = __require("react/jsx-runtime");
114
- var TooltipContent = ({ content }) => {
115
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { dangerouslySetInnerHTML: { __html: content } });
116
- };
117
- var TooltipContent_default = TooltipContent;
118
-
119
112
  // src/components/TooltipProvider/TooltipProvider.tsx
120
113
  var import_react = __require("react");
121
- var import_jsx_runtime2 = __require("react/jsx-runtime");
114
+ var import_jsx_runtime = __require("react/jsx-runtime");
122
115
  var DEFAULT_TOOLTIP_ID = "DEFAULT_TOOLTIP_ID";
123
116
  var DEFAULT_CONTEXT_DATA = {
124
117
  anchorRefs: /* @__PURE__ */ new Set(),
@@ -186,7 +179,7 @@
186
179
  getTooltipData
187
180
  };
188
181
  }, [getTooltipData]);
189
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TooltipContext.Provider, { value: context, children });
182
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TooltipContext.Provider, { value: context, children });
190
183
  };
191
184
  function useTooltip(tooltipId = DEFAULT_TOOLTIP_ID) {
192
185
  return (0, import_react.useContext)(TooltipContext).getTooltipData(tooltipId);
@@ -196,7 +189,7 @@
196
189
  // src/components/TooltipProvider/TooltipWrapper.tsx
197
190
  var import_react2 = __require("react");
198
191
  var import_classnames = __toESM(require_classnames());
199
- var import_jsx_runtime3 = __require("react/jsx-runtime");
192
+ var import_jsx_runtime2 = __require("react/jsx-runtime");
200
193
  var TooltipWrapper = ({
201
194
  tooltipId,
202
195
  children,
@@ -220,7 +213,7 @@
220
213
  detach(anchorRef);
221
214
  };
222
215
  }, []);
223
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
216
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
224
217
  "span",
225
218
  {
226
219
  ref: anchorRef,
@@ -712,7 +705,7 @@
712
705
  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" };
713
706
 
714
707
  // src/components/Tooltip/Tooltip.tsx
715
- var import_jsx_runtime4 = __require("react/jsx-runtime");
708
+ var import_jsx_runtime3 = __require("react/jsx-runtime");
716
709
  var Tooltip = ({
717
710
  // props
718
711
  id,
@@ -727,7 +720,6 @@
727
720
  positionStrategy = "absolute",
728
721
  middlewares,
729
722
  wrapper: WrapperElement,
730
- children = null,
731
723
  delayShow = 0,
732
724
  delayHide = 0,
733
725
  float = false,
@@ -740,7 +732,6 @@
740
732
  afterHide,
741
733
  // props handled by controller
742
734
  content,
743
- html,
744
735
  isOpen,
745
736
  setIsOpen,
746
737
  activeAnchor,
@@ -1099,7 +1090,7 @@
1099
1090
  }
1100
1091
  setActualPlacement(computedStylesData.place);
1101
1092
  });
1102
- }, [show, activeAnchor, content, html, place, offset, positionStrategy, position]);
1093
+ }, [show, activeAnchor, content, place, offset, positionStrategy, position]);
1103
1094
  (0, import_react4.useEffect)(() => {
1104
1095
  var _a;
1105
1096
  const anchorById = document.querySelector(`[id='${anchorId}']`);
@@ -1133,27 +1124,29 @@
1133
1124
  setAnchorsBySelect([]);
1134
1125
  }
1135
1126
  }, [id, anchorSelect]);
1136
- const hasContentOrChildren = Boolean(html || content || children);
1137
- const canShow = hasContentOrChildren && show && Object.keys(inlineStyles).length > 0;
1138
- return rendered ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
1127
+ const canShow = content && show && Object.keys(inlineStyles).length > 0;
1128
+ return rendered ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1139
1129
  WrapperElement,
1140
1130
  {
1141
1131
  id,
1142
1132
  role: "tooltip",
1143
- className: (0, import_classnames2.default)("react-tooltip", styles_module_default["tooltip"], styles_module_default[variant], className, {
1144
- [styles_module_default["show"]]: canShow,
1145
- [styles_module_default["fixed"]]: positionStrategy === "fixed",
1146
- [styles_module_default["clickable"]]: clickable,
1147
- "react-tooltip__place-top": actualPlacement === "top",
1148
- "react-tooltip__place-right": actualPlacement === "right",
1149
- "react-tooltip__place-bottom": actualPlacement === "bottom",
1150
- "react-tooltip__place-left": actualPlacement === "left"
1151
- }),
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
+ ),
1152
1145
  style: { ...externalStyles, ...inlineStyles },
1153
1146
  ref: tooltipRef,
1154
1147
  children: [
1155
- html && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TooltipContent_default, { content: html }) || content || children,
1156
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1148
+ content,
1149
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1157
1150
  WrapperElement,
1158
1151
  {
1159
1152
  className: (0, import_classnames2.default)("react-tooltip-arrow", styles_module_default["arrow"], classNameArrow, {
@@ -1173,6 +1166,13 @@
1173
1166
  };
1174
1167
  var Tooltip_default = Tooltip;
1175
1168
 
1169
+ // src/components/TooltipContent/TooltipContent.tsx
1170
+ var import_jsx_runtime4 = __require("react/jsx-runtime");
1171
+ var TooltipContent = ({ content }) => {
1172
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { dangerouslySetInnerHTML: { __html: content } });
1173
+ };
1174
+ var TooltipContent_default = TooltipContent;
1175
+
1176
1176
  // src/components/TooltipController/TooltipController.tsx
1177
1177
  var import_jsx_runtime5 = __require("react/jsx-runtime");
1178
1178
  var TooltipController = ({
@@ -1181,6 +1181,7 @@
1181
1181
  anchorSelect,
1182
1182
  content,
1183
1183
  html,
1184
+ render,
1184
1185
  className,
1185
1186
  classNameArrow,
1186
1187
  variant = "dark",
@@ -1328,14 +1329,22 @@
1328
1329
  observer.disconnect();
1329
1330
  };
1330
1331
  }, [anchorRefs, providerActiveAnchor, activeAnchor, anchorId, anchorSelect]);
1332
+ let renderedContent = children;
1333
+ if (render) {
1334
+ renderedContent = render({ content: tooltipContent != null ? tooltipContent : null, activeAnchor });
1335
+ } else if (tooltipContent) {
1336
+ renderedContent = tooltipContent;
1337
+ }
1338
+ if (tooltipHtml) {
1339
+ renderedContent = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TooltipContent_default, { content: tooltipHtml });
1340
+ }
1331
1341
  const props = {
1332
1342
  id,
1333
1343
  anchorId,
1334
1344
  anchorSelect,
1335
1345
  className,
1336
1346
  classNameArrow,
1337
- content: tooltipContent,
1338
- html: tooltipHtml,
1347
+ content: renderedContent,
1339
1348
  place: tooltipPlace,
1340
1349
  variant: tooltipVariant,
1341
1350
  offset: tooltipOffset,
@@ -1358,7 +1367,7 @@
1358
1367
  activeAnchor,
1359
1368
  setActiveAnchor: (anchor) => setActiveAnchor(anchor)
1360
1369
  };
1361
- return children ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Tooltip_default, { ...props, children }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Tooltip_default, { ...props });
1370
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Tooltip_default, { ...props });
1362
1371
  };
1363
1372
  var TooltipController_default = TooltipController;
1364
1373
  })();