@thecb/components 11.8.0-beta.5 → 11.8.0-beta.7

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.
package/dist/index.cjs.js CHANGED
@@ -51175,39 +51175,32 @@ var TurnstileWidget = /*#__PURE__*/React.forwardRef(function (_ref4, ref) {
51175
51175
  }, error)));
51176
51176
  });
51177
51177
 
51178
- var hoverColor$6 = "#116285";
51179
- var activeColor$b = "#0E506D";
51180
- var tooltipTriggerColor = "#15749D";
51178
+ var TOOLTIP_THEME_SOURCE = "Popover";
51181
51179
  var fallbackValues$12 = {
51182
- hoverColor: hoverColor$6,
51183
- activeColor: activeColor$b,
51184
- tooltipTriggerColor: tooltipTriggerColor
51180
+ hoverColor: SAPPHIRE_BLUE,
51181
+ activeColor: PEACOCK_BLUE,
51182
+ popoverTriggerColor: MATISSE_BLUE,
51183
+ borderColor: "rgba(255, 255, 255, 0.85)"
51185
51184
  };
51186
-
51187
51185
  var Tooltip = function Tooltip(_ref) {
51188
- var themeValues = _ref.themeValues,
51189
- _ref$triggerText = _ref.triggerText,
51190
- triggerText = _ref$triggerText === void 0 ? "" : _ref$triggerText,
51191
- _ref$content = _ref.content,
51192
- content = _ref$content === void 0 ? "" : _ref$content,
51186
+ var tooltipID = _ref.tooltipID,
51193
51187
  _ref$hasIconTrigger = _ref.hasIconTrigger,
51194
51188
  hasIconTrigger = _ref$hasIconTrigger === void 0 ? false : _ref$hasIconTrigger,
51195
51189
  _ref$IconTrigger = _ref.IconTrigger,
51196
51190
  IconTrigger = _ref$IconTrigger === void 0 ? WarningIconXS : _ref$IconTrigger,
51197
51191
  _ref$iconHelpText = _ref.iconHelpText,
51198
- iconHelpText = _ref$iconHelpText === void 0 ? "" : _ref$iconHelpText,
51199
- _ref$tooltipID = _ref.tooltipID,
51200
- tooltipID = _ref$tooltipID === void 0 ? "tooltip-content" : _ref$tooltipID,
51201
- _ref$extraStyles = _ref.extraStyles,
51202
- extraStyles = _ref$extraStyles === void 0 ? "" : _ref$extraStyles,
51203
- _ref$textExtraStyles = _ref.textExtraStyles,
51204
- textExtraStyles = _ref$textExtraStyles === void 0 ? "" : _ref$textExtraStyles,
51205
- _ref$minWidth = _ref.minWidth,
51206
- minWidth = _ref$minWidth === void 0 ? "250px" : _ref$minWidth,
51207
- _ref$maxWidth = _ref.maxWidth,
51208
- maxWidth = _ref$maxWidth === void 0 ? "300px" : _ref$maxWidth,
51209
- _ref$height = _ref.height,
51210
- height = _ref$height === void 0 ? "auto" : _ref$height,
51192
+ iconHelpText = _ref$iconHelpText === void 0 ? "Open the tooltip" : _ref$iconHelpText,
51193
+ _ref$triggerText = _ref.triggerText,
51194
+ triggerText = _ref$triggerText === void 0 ? "Open the tooltip" : _ref$triggerText,
51195
+ _ref$tooltipContent = _ref.tooltipContent,
51196
+ tooltipContent = _ref$tooltipContent === void 0 ? "The contents of the tooltip go here." : _ref$tooltipContent,
51197
+ _ref$contentPosition = _ref.contentPosition,
51198
+ contentPosition = _ref$contentPosition === void 0 ? {
51199
+ top: "-110px",
51200
+ right: "auto",
51201
+ bottom: "auto",
51202
+ left: "-225px"
51203
+ } : _ref$contentPosition,
51211
51204
  _ref$arrowDirection = _ref.arrowDirection,
51212
51205
  arrowDirection = _ref$arrowDirection === void 0 ? "down" : _ref$arrowDirection,
51213
51206
  _ref$arrowPosition = _ref.arrowPosition,
@@ -51217,104 +51210,117 @@ var Tooltip = function Tooltip(_ref) {
51217
51210
  arrowBottom: "-8px",
51218
51211
  arrowLeft: "auto"
51219
51212
  } : _ref$arrowPosition,
51220
- _ref$position = _ref.position,
51221
- position = _ref$position === void 0 ? {
51222
- top: "-110px",
51223
- right: "auto",
51224
- bottom: "auto",
51225
- left: "-225px"
51226
- } : _ref$position,
51227
- _ref$iconColor = _ref.iconColor,
51228
- iconColor = _ref$iconColor === void 0 ? SELECTIVE_YELLOW : _ref$iconColor,
51229
- buttonExtraStyles = _ref.buttonExtraStyles,
51230
- _ref$backgroundColor = _ref.backgroundColor,
51231
- backgroundColor = _ref$backgroundColor === void 0 ? "white" : _ref$backgroundColor,
51232
- _ref$borderColor = _ref.borderColor,
51233
- borderColor = _ref$borderColor === void 0 ? "rgba(255, 255, 255, 0.85)" : _ref$borderColor,
51234
- tooltipContentExtraStyles = _ref.tooltipContentExtraStyles;
51235
- var hoverColor = themeValues.hoverColor,
51236
- activeColor = themeValues.activeColor,
51237
- tooltipTriggerColor = themeValues.tooltipTriggerColor;
51238
- var _ref2 = position !== null && position !== void 0 ? position : {},
51239
- top = _ref2.top,
51240
- right = _ref2.right,
51241
- bottom = _ref2.bottom,
51242
- left = _ref2.left;
51243
- var _ref3 = arrowPosition !== null && arrowPosition !== void 0 ? arrowPosition : {},
51244
- arrowTop = _ref3.arrowTop,
51245
- arrowRight = _ref3.arrowRight,
51246
- arrowBottom = _ref3.arrowBottom,
51247
- arrowLeft = _ref3.arrowLeft;
51213
+ _ref$minWidth = _ref.minWidth,
51214
+ minWidth = _ref$minWidth === void 0 ? "250px" : _ref$minWidth,
51215
+ _ref$maxWidth = _ref.maxWidth,
51216
+ maxWidth = _ref$maxWidth === void 0 ? "300px" : _ref$maxWidth,
51217
+ _ref$height = _ref.height,
51218
+ height = _ref$height === void 0 ? "auto" : _ref$height,
51219
+ _ref$containerExtraSt = _ref.containerExtraStyles,
51220
+ containerExtraStyles = _ref$containerExtraSt === void 0 ? "" : _ref$containerExtraSt,
51221
+ _ref$triggerExtraStyl = _ref.triggerExtraStyles,
51222
+ triggerExtraStyles = _ref$triggerExtraStyl === void 0 ? "" : _ref$triggerExtraStyl,
51223
+ _ref$triggerButtonVar = _ref.triggerButtonVariant,
51224
+ triggerButtonVariant = _ref$triggerButtonVar === void 0 ? "smallGhost" : _ref$triggerButtonVar;
51225
+ var closeTimeoutRef = React.useRef(null);
51248
51226
  var _useState = React.useState(false),
51249
51227
  _useState2 = _slicedToArray(_useState, 2),
51250
51228
  tooltipOpen = _useState2[0],
51251
51229
  setTooltipOpen = _useState2[1];
51252
- var handleToggleTooltip = function handleToggleTooltip(tooltipState) {
51253
- if (tooltipOpen !== tooltipState) {
51254
- setTooltipOpen(tooltipState);
51230
+ var themeContext = React.useContext(styled.ThemeContext);
51231
+ var themeValues = createThemeValues(themeContext, fallbackValues$12, TOOLTIP_THEME_SOURCE);
51232
+ var borderColor = themeValues.borderColor,
51233
+ popoverTriggerColor = themeValues.popoverTriggerColor,
51234
+ hoverColor = themeValues.hoverColor,
51235
+ activeColor = themeValues.activeColor;
51236
+ var top = contentPosition.top,
51237
+ right = contentPosition.right,
51238
+ bottom = contentPosition.bottom,
51239
+ left = contentPosition.left;
51240
+ var arrowTop = arrowPosition.arrowTop,
51241
+ arrowRight = arrowPosition.arrowRight,
51242
+ arrowBottom = arrowPosition.arrowBottom,
51243
+ arrowLeft = arrowPosition.arrowLeft;
51244
+ var handleToggleTooltip = function handleToggleTooltip(desiredTooltipState) {
51245
+ if (tooltipOpen !== desiredTooltipState) {
51246
+ setTooltipOpen(desiredTooltipState);
51255
51247
  }
51256
51248
  };
51257
51249
  var handleKeyboardEvent = function handleKeyboardEvent(e) {
51258
- if (e.key === ESCAPE) {
51250
+ if (e.key === "Escape") {
51259
51251
  handleToggleTooltip(false);
51260
51252
  }
51261
51253
  };
51254
+ var handleMouseEnter = function handleMouseEnter() {
51255
+ if (closeTimeoutRef.current) {
51256
+ clearTimeout(closeTimeoutRef.current);
51257
+ closeTimeoutRef.current = null;
51258
+ }
51259
+ handleToggleTooltip(true);
51260
+ };
51261
+ var handleMouseLeave = function handleMouseLeave() {
51262
+ closeTimeoutRef.current = setTimeout(function () {
51263
+ handleToggleTooltip(false);
51264
+ }, 300);
51265
+ };
51266
+ React.useEffect(function () {
51267
+ return function () {
51268
+ if (closeTimeoutRef.current) {
51269
+ clearTimeout(closeTimeoutRef.current);
51270
+ }
51271
+ };
51272
+ }, []);
51262
51273
  return /*#__PURE__*/React__default.createElement(Box, {
51274
+ ref: closeTimeoutRef,
51263
51275
  padding: "0",
51264
- extraStyles: "position: relative; ".concat(extraStyles)
51265
- }, /*#__PURE__*/React__default.createElement(ButtonWithAction, {
51276
+ extraStyles: "position: relative; ".concat(containerExtraStyles),
51266
51277
  action: function action() {
51267
51278
  return noop$1;
51268
51279
  },
51280
+ onMouseEnter: handleMouseEnter,
51281
+ onMouseLeave: handleMouseLeave,
51282
+ onKeyDown: handleKeyboardEvent,
51283
+ "data-qa": "tooltip-container"
51284
+ }, /*#__PURE__*/React__default.createElement(ButtonWithAction, {
51285
+ "aria-describedby": tooltipID,
51286
+ variant: triggerButtonVariant,
51269
51287
  onFocus: function onFocus() {
51270
51288
  return handleToggleTooltip(true);
51271
51289
  },
51272
51290
  onBlur: function onBlur() {
51273
51291
  return handleToggleTooltip(false);
51274
51292
  },
51275
- onKeyDown: handleKeyboardEvent,
51276
51293
  onTouchStart: function onTouchStart() {
51277
51294
  return handleToggleTooltip(true);
51278
51295
  },
51279
- onTouchEnd: function onTouchEnd() {
51280
- return handleToggleTooltip(false);
51281
- },
51282
- onMouseEnter: function onMouseEnter() {
51283
- return handleToggleTooltip(true);
51284
- },
51285
- onMouseLeave: function onMouseLeave() {
51286
- return handleToggleTooltip(false);
51287
- },
51288
- contentOverride: true,
51289
- variant: "smallGhost",
51290
- tabIndex: "0",
51291
- "aria-describedby": tooltipID,
51292
- extraStyles: buttonExtraStyles
51293
- }, hasIconTrigger && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Box, {
51296
+ "data-qa": "tooltip-trigger",
51297
+ contentOverride: true
51298
+ }, hasIconTrigger === true && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Box, {
51294
51299
  "aria-label": "Open tooltip"
51295
51300
  }, /*#__PURE__*/React__default.createElement(IconTrigger, {
51296
- color: iconColor
51301
+ color: themeValues.links
51297
51302
  })), /*#__PURE__*/React__default.createElement(Box, {
51298
51303
  padding: "0",
51299
51304
  srOnly: true
51300
- }, /*#__PURE__*/React__default.createElement(Text$1, null, iconHelpText))), !hasIconTrigger && /*#__PURE__*/React__default.createElement(Text$1, {
51301
- extraStyles: "color: ".concat(tooltipTriggerColor, "; &:hover {\n ").concat(hoverColor, "; &:active ").concat(activeColor, "; ").concat(textExtraStyles)
51305
+ }, /*#__PURE__*/React__default.createElement(Text$1, null, iconHelpText))), hasIconTrigger === false && /*#__PURE__*/React__default.createElement(Text$1, {
51306
+ color: popoverTriggerColor,
51307
+ extraStyles: "\n &:visited {\n color: ".concat(popoverTriggerColor, ";\n }\n &:hover {\n color: ").concat(hoverColor, "; \n }\n &:active {\n color: ").concat(activeColor, "; \n }\n ").concat(triggerExtraStyles, ";\n ")
51302
51308
  }, triggerText)), /*#__PURE__*/React__default.createElement(Box, {
51303
- background: backgroundColor,
51304
- borderRadius: "4px",
51305
- boxShadow: "0px 2px 14px 0px rgb(246, 246, 249), 0px 3px 8px 0px rgb(202, 206, 216)",
51306
- id: tooltipID,
51307
51309
  role: "tooltip",
51308
- minWidth: minWidth,
51309
- maxWidth: maxWidth,
51310
+ id: tooltipID,
51310
51311
  "aria-hidden": !tooltipOpen,
51311
- extraStyles: "\n display: ".concat(tooltipOpen ? "block" : "none", "; \n position: absolute; \n top: ").concat(top, "; \n right: ").concat(right, "; \n bottom: ").concat(bottom, "; \n left: ").concat(left, ";\n height: ").concat(height, ";\n ").concat(tooltipContentExtraStyles, ";\n ")
51312
- }, /*#__PURE__*/React__default.createElement(Paragraph$1, null, content), /*#__PURE__*/React__default.createElement(Box, {
51312
+ "data-qa": "tooltip-contents",
51313
+ extraStyles: "\n position: absolute;\n display: ".concat(tooltipOpen ? "block" : "none", "; \n top: ").concat(top, "; \n right: ").concat(right, "; \n bottom: ").concat(bottom, "; \n left: ").concat(left, ";\n height: ").concat(height, ";\n "),
51314
+ boxShadow: "0px 2px 14px 0px rgb(246, 246, 249), 0px 3px 8px 0px rgb(202, 206, 216)",
51315
+ border: "1px solid transparent",
51316
+ borderRadius: "4px",
51317
+ minWidth: minWidth,
51318
+ maxWidth: maxWidth
51319
+ }, /*#__PURE__*/React__default.createElement(Paragraph$1, null, tooltipContent), /*#__PURE__*/React__default.createElement(Box, {
51313
51320
  padding: "0",
51314
51321
  extraStyles: "\n position: absolute;\n content: \"\";\n width: 0;\n height: 0;\n ".concat(arrowBorder(borderColor, arrowDirection, "8px"), ";\n filter: drop-shadow(2px 8px 14px black);\n bottom: ").concat(arrowBottom, ";\n right: ").concat(arrowRight, ";\n top: ").concat(arrowTop, ";\n left: ").concat(arrowLeft, ";\n ")
51315
51322
  })));
51316
51323
  };
51317
- var Tooltip$1 = themeComponent(Tooltip, "Tooltip", fallbackValues$12);
51318
51324
 
51319
51325
  var pageBackground = "#FBFCFD";
51320
51326
  var fallbackValues$13 = {
@@ -51871,7 +51877,7 @@ exports.TimeoutImage = TimeoutImage;
51871
51877
  exports.Title = Title$1;
51872
51878
  exports.ToastNotification = ToastNotification;
51873
51879
  exports.ToggleSwitch = ToggleSwitch$1;
51874
- exports.Tooltip = Tooltip$1;
51880
+ exports.Tooltip = Tooltip;
51875
51881
  exports.TrashIcon = TrashIcon$1;
51876
51882
  exports.TrashIconV2 = TrashIconV2$1;
51877
51883
  exports.TurnstileWidget = TurnstileWidget;