react-tooltip 5.10.0-beta.1 → 5.10.1-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,
@@ -728,7 +721,6 @@
728
721
  positionStrategy = "absolute",
729
722
  middlewares,
730
723
  wrapper: WrapperElement,
731
- children = null,
732
724
  delayShow = 0,
733
725
  delayHide = 0,
734
726
  float = false,
@@ -741,7 +733,6 @@
741
733
  afterHide,
742
734
  // props handled by controller
743
735
  content,
744
- html,
745
736
  isOpen,
746
737
  setIsOpen,
747
738
  activeAnchor,
@@ -1102,7 +1093,7 @@
1102
1093
  }
1103
1094
  setActualPlacement(computedStylesData.place);
1104
1095
  });
1105
- }, [show, activeAnchor, content, html, place, offset, positionStrategy, position]);
1096
+ }, [show, activeAnchor, content, place, offset, positionStrategy, position]);
1106
1097
  (0, import_react4.useEffect)(() => {
1107
1098
  var _a;
1108
1099
  const anchorById = document.querySelector(`[id='${anchorId}']`);
@@ -1136,9 +1127,8 @@
1136
1127
  setAnchorsBySelect([]);
1137
1128
  }
1138
1129
  }, [id, anchorSelect]);
1139
- const hasContentOrChildren = Boolean(html || content || children);
1140
- const canShow = hasContentOrChildren && show && Object.keys(inlineStyles).length > 0;
1141
- return rendered ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
1130
+ const canShow = content && show && Object.keys(inlineStyles).length > 0;
1131
+ return rendered ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1142
1132
  WrapperElement,
1143
1133
  {
1144
1134
  id,
@@ -1158,8 +1148,8 @@
1158
1148
  style: { ...externalStyles, ...inlineStyles },
1159
1149
  ref: tooltipRef,
1160
1150
  children: [
1161
- html && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TooltipContent_default, { content: html }) || content || children,
1162
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1151
+ content,
1152
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1163
1153
  WrapperElement,
1164
1154
  {
1165
1155
  className: (0, import_classnames2.default)("react-tooltip-arrow", styles_module_default["arrow"], classNameArrow, {
@@ -1179,6 +1169,13 @@
1179
1169
  };
1180
1170
  var Tooltip_default = Tooltip;
1181
1171
 
1172
+ // src/components/TooltipContent/TooltipContent.tsx
1173
+ var import_jsx_runtime4 = __require("react/jsx-runtime");
1174
+ var TooltipContent = ({ content }) => {
1175
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { dangerouslySetInnerHTML: { __html: content } });
1176
+ };
1177
+ var TooltipContent_default = TooltipContent;
1178
+
1182
1179
  // src/components/TooltipController/TooltipController.tsx
1183
1180
  var import_jsx_runtime5 = __require("react/jsx-runtime");
1184
1181
  var TooltipController = ({
@@ -1187,6 +1184,7 @@
1187
1184
  anchorSelect,
1188
1185
  content,
1189
1186
  html,
1187
+ render,
1190
1188
  className,
1191
1189
  classNameArrow,
1192
1190
  variant = "dark",
@@ -1335,14 +1333,22 @@
1335
1333
  observer.disconnect();
1336
1334
  };
1337
1335
  }, [anchorRefs, providerActiveAnchor, activeAnchor, anchorId, anchorSelect]);
1336
+ let renderedContent = children;
1337
+ if (render) {
1338
+ renderedContent = render({ content: tooltipContent != null ? tooltipContent : null, activeAnchor });
1339
+ } else if (tooltipContent) {
1340
+ renderedContent = tooltipContent;
1341
+ }
1342
+ if (tooltipHtml) {
1343
+ renderedContent = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TooltipContent_default, { content: tooltipHtml });
1344
+ }
1338
1345
  const props = {
1339
1346
  id,
1340
1347
  anchorId,
1341
1348
  anchorSelect,
1342
1349
  className,
1343
1350
  classNameArrow,
1344
- content: tooltipContent,
1345
- html: tooltipHtml,
1351
+ content: renderedContent,
1346
1352
  place: tooltipPlace,
1347
1353
  variant: tooltipVariant,
1348
1354
  offset: tooltipOffset,
@@ -1366,7 +1372,7 @@
1366
1372
  activeAnchor,
1367
1373
  setActiveAnchor: (anchor) => setActiveAnchor(anchor)
1368
1374
  };
1369
- return children ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Tooltip_default, { ...props, children }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Tooltip_default, { ...props });
1375
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Tooltip_default, { ...props });
1370
1376
  };
1371
1377
  var TooltipController_default = TooltipController;
1372
1378
  })();