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.
@@ -115,16 +115,9 @@ var debounce = (func, wait, immediate) => {
115
115
  };
116
116
  var debounce_default = debounce;
117
117
 
118
- // src/components/TooltipContent/TooltipContent.tsx
119
- var import_jsx_runtime = require("react/jsx-runtime");
120
- var TooltipContent = ({ content }) => {
121
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { dangerouslySetInnerHTML: { __html: content } });
122
- };
123
- var TooltipContent_default = TooltipContent;
124
-
125
118
  // src/components/TooltipProvider/TooltipProvider.tsx
126
119
  var import_react = require("react");
127
- var import_jsx_runtime2 = require("react/jsx-runtime");
120
+ var import_jsx_runtime = require("react/jsx-runtime");
128
121
  var DEFAULT_TOOLTIP_ID = "DEFAULT_TOOLTIP_ID";
129
122
  var DEFAULT_CONTEXT_DATA = {
130
123
  anchorRefs: /* @__PURE__ */ new Set(),
@@ -192,7 +185,7 @@ var TooltipProvider = ({ children }) => {
192
185
  getTooltipData
193
186
  };
194
187
  }, [getTooltipData]);
195
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TooltipContext.Provider, { value: context, children });
188
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TooltipContext.Provider, { value: context, children });
196
189
  };
197
190
  function useTooltip(tooltipId = DEFAULT_TOOLTIP_ID) {
198
191
  return (0, import_react.useContext)(TooltipContext).getTooltipData(tooltipId);
@@ -202,7 +195,7 @@ var TooltipProvider_default = TooltipProvider;
202
195
  // src/components/TooltipProvider/TooltipWrapper.tsx
203
196
  var import_react2 = require("react");
204
197
  var import_classnames = __toESM(require_classnames());
205
- var import_jsx_runtime3 = require("react/jsx-runtime");
198
+ var import_jsx_runtime2 = require("react/jsx-runtime");
206
199
  var TooltipWrapper = ({
207
200
  tooltipId,
208
201
  children,
@@ -226,7 +219,7 @@ var TooltipWrapper = ({
226
219
  detach(anchorRef);
227
220
  };
228
221
  }, []);
229
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
222
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
230
223
  "span",
231
224
  {
232
225
  ref: anchorRef,
@@ -718,7 +711,7 @@ var computeTooltipPosition = async ({
718
711
  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" };
719
712
 
720
713
  // src/components/Tooltip/Tooltip.tsx
721
- var import_jsx_runtime4 = require("react/jsx-runtime");
714
+ var import_jsx_runtime3 = require("react/jsx-runtime");
722
715
  var Tooltip = ({
723
716
  // props
724
717
  id,
@@ -733,7 +726,6 @@ var Tooltip = ({
733
726
  positionStrategy = "absolute",
734
727
  middlewares,
735
728
  wrapper: WrapperElement,
736
- children = null,
737
729
  delayShow = 0,
738
730
  delayHide = 0,
739
731
  float = false,
@@ -746,7 +738,6 @@ var Tooltip = ({
746
738
  afterHide,
747
739
  // props handled by controller
748
740
  content,
749
- html,
750
741
  isOpen,
751
742
  setIsOpen,
752
743
  activeAnchor,
@@ -1105,7 +1096,7 @@ var Tooltip = ({
1105
1096
  }
1106
1097
  setActualPlacement(computedStylesData.place);
1107
1098
  });
1108
- }, [show, activeAnchor, content, html, place, offset, positionStrategy, position]);
1099
+ }, [show, activeAnchor, content, place, offset, positionStrategy, position]);
1109
1100
  (0, import_react4.useEffect)(() => {
1110
1101
  var _a;
1111
1102
  const anchorById = document.querySelector(`[id='${anchorId}']`);
@@ -1139,9 +1130,8 @@ var Tooltip = ({
1139
1130
  setAnchorsBySelect([]);
1140
1131
  }
1141
1132
  }, [id, anchorSelect]);
1142
- const hasContentOrChildren = Boolean(html || content || children);
1143
- const canShow = hasContentOrChildren && show && Object.keys(inlineStyles).length > 0;
1144
- return rendered ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
1133
+ const canShow = content && show && Object.keys(inlineStyles).length > 0;
1134
+ return rendered ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1145
1135
  WrapperElement,
1146
1136
  {
1147
1137
  id,
@@ -1161,8 +1151,8 @@ var Tooltip = ({
1161
1151
  style: { ...externalStyles, ...inlineStyles },
1162
1152
  ref: tooltipRef,
1163
1153
  children: [
1164
- html && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TooltipContent_default, { content: html }) || content || children,
1165
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1154
+ content,
1155
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1166
1156
  WrapperElement,
1167
1157
  {
1168
1158
  className: (0, import_classnames2.default)("react-tooltip-arrow", styles_module_default["arrow"], classNameArrow, {
@@ -1182,6 +1172,13 @@ var Tooltip = ({
1182
1172
  };
1183
1173
  var Tooltip_default = Tooltip;
1184
1174
 
1175
+ // src/components/TooltipContent/TooltipContent.tsx
1176
+ var import_jsx_runtime4 = require("react/jsx-runtime");
1177
+ var TooltipContent = ({ content }) => {
1178
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { dangerouslySetInnerHTML: { __html: content } });
1179
+ };
1180
+ var TooltipContent_default = TooltipContent;
1181
+
1185
1182
  // src/components/TooltipController/TooltipController.tsx
1186
1183
  var import_jsx_runtime5 = require("react/jsx-runtime");
1187
1184
  var TooltipController = ({
@@ -1190,6 +1187,7 @@ var TooltipController = ({
1190
1187
  anchorSelect,
1191
1188
  content,
1192
1189
  html,
1190
+ render,
1193
1191
  className,
1194
1192
  classNameArrow,
1195
1193
  variant = "dark",
@@ -1337,14 +1335,22 @@ var TooltipController = ({
1337
1335
  observer.disconnect();
1338
1336
  };
1339
1337
  }, [anchorRefs, providerActiveAnchor, activeAnchor, anchorId, anchorSelect]);
1338
+ let renderedContent = children;
1339
+ if (render) {
1340
+ renderedContent = render({ content: tooltipContent != null ? tooltipContent : null, activeAnchor });
1341
+ } else if (tooltipContent) {
1342
+ renderedContent = tooltipContent;
1343
+ }
1344
+ if (tooltipHtml) {
1345
+ renderedContent = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TooltipContent_default, { content: tooltipHtml });
1346
+ }
1340
1347
  const props = {
1341
1348
  id,
1342
1349
  anchorId,
1343
1350
  anchorSelect,
1344
1351
  className,
1345
1352
  classNameArrow,
1346
- content: tooltipContent,
1347
- html: tooltipHtml,
1353
+ content: renderedContent,
1348
1354
  place: tooltipPlace,
1349
1355
  variant: tooltipVariant,
1350
1356
  offset: tooltipOffset,
@@ -1367,7 +1373,7 @@ var TooltipController = ({
1367
1373
  activeAnchor,
1368
1374
  setActiveAnchor: (anchor) => setActiveAnchor(anchor)
1369
1375
  };
1370
- return children ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Tooltip_default, { ...props, children }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Tooltip_default, { ...props });
1376
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Tooltip_default, { ...props });
1371
1377
  };
1372
1378
  var TooltipController_default = TooltipController;
1373
1379
  /*! Bundled license information: