react-tooltip 5.9.1 → 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,9 +1124,8 @@
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,
@@ -1155,8 +1145,8 @@
1155
1145
  style: { ...externalStyles, ...inlineStyles },
1156
1146
  ref: tooltipRef,
1157
1147
  children: [
1158
- html && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TooltipContent_default, { content: html }) || content || children,
1159
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1148
+ content,
1149
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1160
1150
  WrapperElement,
1161
1151
  {
1162
1152
  className: (0, import_classnames2.default)("react-tooltip-arrow", styles_module_default["arrow"], classNameArrow, {
@@ -1176,6 +1166,13 @@
1176
1166
  };
1177
1167
  var Tooltip_default = Tooltip;
1178
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
+
1179
1176
  // src/components/TooltipController/TooltipController.tsx
1180
1177
  var import_jsx_runtime5 = __require("react/jsx-runtime");
1181
1178
  var TooltipController = ({
@@ -1184,6 +1181,7 @@
1184
1181
  anchorSelect,
1185
1182
  content,
1186
1183
  html,
1184
+ render,
1187
1185
  className,
1188
1186
  classNameArrow,
1189
1187
  variant = "dark",
@@ -1331,14 +1329,22 @@
1331
1329
  observer.disconnect();
1332
1330
  };
1333
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
+ }
1334
1341
  const props = {
1335
1342
  id,
1336
1343
  anchorId,
1337
1344
  anchorSelect,
1338
1345
  className,
1339
1346
  classNameArrow,
1340
- content: tooltipContent,
1341
- html: tooltipHtml,
1347
+ content: renderedContent,
1342
1348
  place: tooltipPlace,
1343
1349
  variant: tooltipVariant,
1344
1350
  offset: tooltipOffset,
@@ -1361,7 +1367,7 @@
1361
1367
  activeAnchor,
1362
1368
  setActiveAnchor: (anchor) => setActiveAnchor(anchor)
1363
1369
  };
1364
- 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 });
1365
1371
  };
1366
1372
  var TooltipController_default = TooltipController;
1367
1373
  })();