react-tooltip 5.10.0-beta.1 → 5.10.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,
@@ -734,7 +727,6 @@ var Tooltip = ({
734
727
  positionStrategy = "absolute",
735
728
  middlewares,
736
729
  wrapper: WrapperElement,
737
- children = null,
738
730
  delayShow = 0,
739
731
  delayHide = 0,
740
732
  float = false,
@@ -747,7 +739,6 @@ var Tooltip = ({
747
739
  afterHide,
748
740
  // props handled by controller
749
741
  content,
750
- html,
751
742
  isOpen,
752
743
  setIsOpen,
753
744
  activeAnchor,
@@ -1108,7 +1099,7 @@ var Tooltip = ({
1108
1099
  }
1109
1100
  setActualPlacement(computedStylesData.place);
1110
1101
  });
1111
- }, [show, activeAnchor, content, html, place, offset, positionStrategy, position]);
1102
+ }, [show, activeAnchor, content, place, offset, positionStrategy, position]);
1112
1103
  (0, import_react4.useEffect)(() => {
1113
1104
  var _a;
1114
1105
  const anchorById = document.querySelector(`[id='${anchorId}']`);
@@ -1142,9 +1133,8 @@ var Tooltip = ({
1142
1133
  setAnchorsBySelect([]);
1143
1134
  }
1144
1135
  }, [id, anchorSelect]);
1145
- const hasContentOrChildren = Boolean(html || content || children);
1146
- const canShow = hasContentOrChildren && show && Object.keys(inlineStyles).length > 0;
1147
- return rendered ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
1136
+ const canShow = content && show && Object.keys(inlineStyles).length > 0;
1137
+ return rendered ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1148
1138
  WrapperElement,
1149
1139
  {
1150
1140
  id,
@@ -1164,8 +1154,8 @@ var Tooltip = ({
1164
1154
  style: { ...externalStyles, ...inlineStyles },
1165
1155
  ref: tooltipRef,
1166
1156
  children: [
1167
- html && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TooltipContent_default, { content: html }) || content || children,
1168
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1157
+ content,
1158
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1169
1159
  WrapperElement,
1170
1160
  {
1171
1161
  className: (0, import_classnames2.default)("react-tooltip-arrow", styles_module_default["arrow"], classNameArrow, {
@@ -1185,6 +1175,13 @@ var Tooltip = ({
1185
1175
  };
1186
1176
  var Tooltip_default = Tooltip;
1187
1177
 
1178
+ // src/components/TooltipContent/TooltipContent.tsx
1179
+ var import_jsx_runtime4 = require("react/jsx-runtime");
1180
+ var TooltipContent = ({ content }) => {
1181
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { dangerouslySetInnerHTML: { __html: content } });
1182
+ };
1183
+ var TooltipContent_default = TooltipContent;
1184
+
1188
1185
  // src/components/TooltipController/TooltipController.tsx
1189
1186
  var import_jsx_runtime5 = require("react/jsx-runtime");
1190
1187
  var TooltipController = ({
@@ -1193,6 +1190,7 @@ var TooltipController = ({
1193
1190
  anchorSelect,
1194
1191
  content,
1195
1192
  html,
1193
+ render,
1196
1194
  className,
1197
1195
  classNameArrow,
1198
1196
  variant = "dark",
@@ -1341,14 +1339,22 @@ var TooltipController = ({
1341
1339
  observer.disconnect();
1342
1340
  };
1343
1341
  }, [anchorRefs, providerActiveAnchor, activeAnchor, anchorId, anchorSelect]);
1342
+ let renderedContent = children;
1343
+ if (render) {
1344
+ renderedContent = render({ content: tooltipContent != null ? tooltipContent : null, activeAnchor });
1345
+ } else if (tooltipContent) {
1346
+ renderedContent = tooltipContent;
1347
+ }
1348
+ if (tooltipHtml) {
1349
+ renderedContent = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TooltipContent_default, { content: tooltipHtml });
1350
+ }
1344
1351
  const props = {
1345
1352
  id,
1346
1353
  anchorId,
1347
1354
  anchorSelect,
1348
1355
  className,
1349
1356
  classNameArrow,
1350
- content: tooltipContent,
1351
- html: tooltipHtml,
1357
+ content: renderedContent,
1352
1358
  place: tooltipPlace,
1353
1359
  variant: tooltipVariant,
1354
1360
  offset: tooltipOffset,
@@ -1372,7 +1378,7 @@ var TooltipController = ({
1372
1378
  activeAnchor,
1373
1379
  setActiveAnchor: (anchor) => setActiveAnchor(anchor)
1374
1380
  };
1375
- return children ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Tooltip_default, { ...props, children }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Tooltip_default, { ...props });
1381
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Tooltip_default, { ...props });
1376
1382
  };
1377
1383
  var TooltipController_default = TooltipController;
1378
1384
  /*! Bundled license information: