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.
@@ -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,27 +1130,29 @@ 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,
1148
1138
  role: "tooltip",
1149
- className: (0, import_classnames2.default)("react-tooltip", styles_module_default["tooltip"], styles_module_default[variant], className, {
1150
- [styles_module_default["show"]]: canShow,
1151
- [styles_module_default["fixed"]]: positionStrategy === "fixed",
1152
- [styles_module_default["clickable"]]: clickable,
1153
- "react-tooltip__place-top": actualPlacement === "top",
1154
- "react-tooltip__place-right": actualPlacement === "right",
1155
- "react-tooltip__place-bottom": actualPlacement === "bottom",
1156
- "react-tooltip__place-left": actualPlacement === "left"
1157
- }),
1139
+ className: (0, import_classnames2.default)(
1140
+ "react-tooltip",
1141
+ styles_module_default["tooltip"],
1142
+ styles_module_default[variant],
1143
+ className,
1144
+ `react-tooltip__place-${actualPlacement}`,
1145
+ {
1146
+ [styles_module_default["show"]]: canShow,
1147
+ [styles_module_default["fixed"]]: positionStrategy === "fixed",
1148
+ [styles_module_default["clickable"]]: clickable
1149
+ }
1150
+ ),
1158
1151
  style: { ...externalStyles, ...inlineStyles },
1159
1152
  ref: tooltipRef,
1160
1153
  children: [
1161
- html && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TooltipContent_default, { content: html }) || content || children,
1162
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1154
+ content,
1155
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1163
1156
  WrapperElement,
1164
1157
  {
1165
1158
  className: (0, import_classnames2.default)("react-tooltip-arrow", styles_module_default["arrow"], classNameArrow, {
@@ -1179,6 +1172,13 @@ var Tooltip = ({
1179
1172
  };
1180
1173
  var Tooltip_default = Tooltip;
1181
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
+
1182
1182
  // src/components/TooltipController/TooltipController.tsx
1183
1183
  var import_jsx_runtime5 = require("react/jsx-runtime");
1184
1184
  var TooltipController = ({
@@ -1187,6 +1187,7 @@ var TooltipController = ({
1187
1187
  anchorSelect,
1188
1188
  content,
1189
1189
  html,
1190
+ render,
1190
1191
  className,
1191
1192
  classNameArrow,
1192
1193
  variant = "dark",
@@ -1334,14 +1335,22 @@ var TooltipController = ({
1334
1335
  observer.disconnect();
1335
1336
  };
1336
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
+ }
1337
1347
  const props = {
1338
1348
  id,
1339
1349
  anchorId,
1340
1350
  anchorSelect,
1341
1351
  className,
1342
1352
  classNameArrow,
1343
- content: tooltipContent,
1344
- html: tooltipHtml,
1353
+ content: renderedContent,
1345
1354
  place: tooltipPlace,
1346
1355
  variant: tooltipVariant,
1347
1356
  offset: tooltipOffset,
@@ -1364,7 +1373,7 @@ var TooltipController = ({
1364
1373
  activeAnchor,
1365
1374
  setActiveAnchor: (anchor) => setActiveAnchor(anchor)
1366
1375
  };
1367
- 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 });
1368
1377
  };
1369
1378
  var TooltipController_default = TooltipController;
1370
1379
  /*! Bundled license information: