@redocly/theme 0.63.0-next.3 → 0.63.0-next.5

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.
Files changed (54) hide show
  1. package/lib/components/Buttons/CopyButton.d.ts +1 -1
  2. package/lib/components/Buttons/CopyButton.js +1 -1
  3. package/lib/components/Buttons/DownloadButton.d.ts +6 -0
  4. package/lib/components/Buttons/DownloadButton.js +20 -0
  5. package/lib/components/Buttons/EmailButton.js +6 -1
  6. package/lib/components/Buttons/NewTabButton.js +6 -1
  7. package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistorySidebar.js +2 -2
  8. package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityVersionItem.js +6 -13
  9. package/lib/components/CodeBlock/CodeBlockControls.js +3 -3
  10. package/lib/components/Menu/MenuItem.js +1 -1
  11. package/lib/components/PageActions/PageActions.js +1 -1
  12. package/lib/components/Search/SearchDialog.js +1 -1
  13. package/lib/components/SidebarActions/SidebarActions.js +1 -1
  14. package/lib/components/SidebarActions/styled.d.ts +1 -1
  15. package/lib/components/Tooltip/AnchorTooltip.d.ts +7 -0
  16. package/lib/components/Tooltip/AnchorTooltip.js +233 -0
  17. package/lib/components/Tooltip/JsTooltip.d.ts +3 -0
  18. package/lib/components/Tooltip/JsTooltip.js +277 -0
  19. package/lib/components/Tooltip/Tooltip.d.ts +2 -13
  20. package/lib/components/Tooltip/Tooltip.js +14 -190
  21. package/lib/core/hooks/use-page-actions.js +9 -5
  22. package/lib/core/hooks/use-theme-hooks.js +1 -0
  23. package/lib/core/types/hooks.d.ts +4 -0
  24. package/lib/core/types/index.d.ts +1 -0
  25. package/lib/core/types/l10n.d.ts +1 -1
  26. package/lib/core/types/tooltip.d.ts +14 -0
  27. package/lib/core/types/tooltip.js +3 -0
  28. package/lib/core/utils/transform-revisions-to-version-history.js +13 -20
  29. package/lib/index.d.ts +1 -0
  30. package/lib/index.js +1 -0
  31. package/package.json +3 -3
  32. package/src/components/Buttons/CopyButton.tsx +2 -1
  33. package/src/components/Buttons/DownloadButton.tsx +41 -0
  34. package/src/components/Buttons/EmailButton.tsx +18 -8
  35. package/src/components/Buttons/NewTabButton.tsx +19 -8
  36. package/src/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistorySidebar.tsx +2 -2
  37. package/src/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityVersionItem.tsx +5 -21
  38. package/src/components/CodeBlock/CodeBlockControls.tsx +3 -0
  39. package/src/components/Menu/MenuItem.tsx +1 -0
  40. package/src/components/PageActions/PageActions.tsx +6 -1
  41. package/src/components/Search/SearchDialog.tsx +1 -1
  42. package/src/components/SidebarActions/SidebarActions.tsx +1 -0
  43. package/src/components/Tooltip/AnchorTooltip.tsx +259 -0
  44. package/src/components/Tooltip/JsTooltip.tsx +296 -0
  45. package/src/components/Tooltip/Tooltip.tsx +18 -257
  46. package/src/core/hooks/__mocks__/use-theme-hooks.ts +3 -0
  47. package/src/core/hooks/use-page-actions.ts +5 -0
  48. package/src/core/hooks/use-theme-hooks.ts +1 -0
  49. package/src/core/types/hooks.ts +2 -1
  50. package/src/core/types/index.ts +1 -0
  51. package/src/core/types/l10n.ts +5 -0
  52. package/src/core/types/tooltip.ts +15 -0
  53. package/src/core/utils/transform-revisions-to-version-history.ts +13 -21
  54. package/src/index.ts +1 -0
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { TooltipProps } from '../../components/Tooltip/Tooltip';
2
+ import type { TooltipProps } from '../../core/types';
3
3
  import type { ButtonProps } from '../../components/Button/Button';
4
4
  export type CopyButtonProps = {
5
5
  data: unknown;
@@ -57,7 +57,7 @@ function CopyButtonComponent({ data, type = 'icon', toasterPlacement = 'top', to
57
57
  onCopyClick === null || onCopyClick === void 0 ? void 0 : onCopyClick(e);
58
58
  };
59
59
  return (react_1.default.createElement(Tooltip_1.Tooltip, { className: `copy-button ${className ? className : ''}`, tip: translate('codeSnippet.copy.buttonText', toasterText || 'Copied!'), isOpen: tooltip.isOpened, placement: toasterPlacement, width: "fit-content" },
60
- react_1.default.createElement(Button_1.Button, { "data-component-name": "Buttons/CopyButton", onClick: (e) => copy(e, toasterDuration), "data-testid": dataTestId, icon: type === 'icon' || type === 'compound' ? react_1.default.createElement(CopyIcon_1.CopyIcon, null) : undefined, size: size, variant: variant, disabled: disabled, fullWidth: fullWidth, tone: tone, extraClass: extraClass, iconPosition: iconPosition }, (type === 'text' || type === 'compound') &&
60
+ react_1.default.createElement(Button_1.Button, { "data-component-name": "Buttons/CopyButton", onClick: (e) => copy(e, toasterDuration), "data-testid": dataTestId, icon: type === 'icon' || type === 'compound' ? react_1.default.createElement(CopyIcon_1.CopyIcon, null) : undefined, size: size, variant: variant, disabled: disabled, fullWidth: fullWidth, tone: tone, extraClass: extraClass, iconPosition: iconPosition, "aria-label": "Copy" }, (type === 'text' || type === 'compound') &&
61
61
  (buttonText || translate('codeSnippet.copy.toasterText', 'Copy')))));
62
62
  }
63
63
  exports.CopyButton = (0, react_1.memo)(CopyButtonComponent);
@@ -0,0 +1,6 @@
1
+ import type { JSX } from 'react';
2
+ export type DownloadButtonProps = {
3
+ data: string;
4
+ dataTestId?: string;
5
+ };
6
+ export declare function DownloadButton({ data, dataTestId, }: DownloadButtonProps): JSX.Element;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DownloadButton = DownloadButton;
7
+ const react_1 = __importDefault(require("react"));
8
+ const Button_1 = require("../../components/Button/Button");
9
+ const DownloadIcon_1 = require("../../icons/DownloadIcon/DownloadIcon");
10
+ const Tooltip_1 = require("../../components/Tooltip/Tooltip");
11
+ const hooks_1 = require("../../core/hooks");
12
+ function DownloadButton({ data, dataTestId = 'download-button', }) {
13
+ const { useTranslate } = (0, hooks_1.useThemeHooks)();
14
+ const { translate } = useTranslate();
15
+ return (react_1.default.createElement("div", { "data-component-name": "Buttons/DownloadButton" },
16
+ react_1.default.createElement(Tooltip_1.Tooltip, { tip: translate('button.download.tooltipText', 'Download description'), placement: "top", arrowPosition: "right" },
17
+ react_1.default.createElement("a", { href: data, target: "_blank", download: true, rel: "noreferrer" },
18
+ react_1.default.createElement(Button_1.Button, { variant: "text", size: "small", "aria-label": "Download", icon: react_1.default.createElement(DownloadIcon_1.DownloadIcon, null), "data-testid": dataTestId })))));
19
+ }
20
+ //# sourceMappingURL=DownloadButton.js.map
@@ -7,11 +7,16 @@ exports.EmailButton = EmailButton;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const Button_1 = require("../../components/Button/Button");
9
9
  const EmailIcon_1 = require("../../icons/EmailIcon/EmailIcon");
10
+ const Tooltip_1 = require("../../components/Tooltip/Tooltip");
11
+ const hooks_1 = require("../../core/hooks");
10
12
  function EmailButton({ data, dataTestId = 'email-button' }) {
13
+ const { useTranslate } = (0, hooks_1.useThemeHooks)();
14
+ const { translate } = useTranslate();
11
15
  const onClick = () => {
12
16
  window.location.href = `mailto:${data}`;
13
17
  };
14
18
  return (react_1.default.createElement("div", { "data-component-name": "Buttons/EmailButton" },
15
- react_1.default.createElement(Button_1.Button, { onClick: onClick, icon: react_1.default.createElement(EmailIcon_1.EmailIcon, null), size: "small", variant: "text", "data-testid": dataTestId, "aria-label": "Email" })));
19
+ react_1.default.createElement(Tooltip_1.Tooltip, { tip: translate('button.email.tooltipText', 'Send email'), placement: "top", arrowPosition: "right" },
20
+ react_1.default.createElement(Button_1.Button, { onClick: onClick, icon: react_1.default.createElement(EmailIcon_1.EmailIcon, null), size: "small", variant: "text", "data-testid": dataTestId, "aria-label": "Email" }))));
16
21
  }
17
22
  //# sourceMappingURL=EmailButton.js.map
@@ -7,11 +7,16 @@ exports.NewTabButton = NewTabButton;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const Button_1 = require("../../components/Button/Button");
9
9
  const ArrowUpRightIcon_1 = require("../../icons/ArrowUpRightIcon/ArrowUpRightIcon");
10
+ const Tooltip_1 = require("../../components/Tooltip/Tooltip");
11
+ const hooks_1 = require("../../core/hooks");
10
12
  function NewTabButton({ data, dataTestId = 'new-tab-button', }) {
13
+ const { useTranslate } = (0, hooks_1.useThemeHooks)();
14
+ const { translate } = useTranslate();
11
15
  const onClick = () => {
12
16
  window.open(data, '_blank');
13
17
  };
14
18
  return (react_1.default.createElement("div", { "data-component-name": "Buttons/NewTabButton" },
15
- react_1.default.createElement(Button_1.Button, { onClick: onClick, icon: react_1.default.createElement(ArrowUpRightIcon_1.ArrowUpRightIcon, null), "data-testid": dataTestId, "aria-label": "Open in new tab", size: "small", variant: "text" })));
19
+ react_1.default.createElement(Tooltip_1.Tooltip, { tip: translate('button.externalLink.tooltipText', 'Open in new tab'), placement: "top", arrowPosition: "right" },
20
+ react_1.default.createElement(Button_1.Button, { onClick: onClick, icon: react_1.default.createElement(ArrowUpRightIcon_1.ArrowUpRightIcon, null), "data-testid": dataTestId, "aria-label": "Open in new tab", size: "small", variant: "text" }))));
16
21
  }
17
22
  //# sourceMappingURL=NewTabButton.js.map
@@ -111,10 +111,10 @@ function CatalogEntityHistorySidebar({ entityKey, revision, version, className,
111
111
  }
112
112
  const SidebarOverlay = styled_components_1.default.div `
113
113
  position: fixed;
114
- top: var(--navbar-height);
114
+ top: calc(var(--navbar-height) + var(--banner-height, 0));
115
115
  left: 0;
116
116
  width: var(--sidebar-width);
117
- height: calc(100vh - var(--navbar-height));
117
+ height: calc(100vh - var(--navbar-height) - var(--banner-height, 0));
118
118
  background-color: var(--catalog-history-sidebar-bg-color);
119
119
  border-right: 1px solid var(--catalog-history-sidebar-border-color);
120
120
  display: flex;
@@ -70,12 +70,10 @@ function CatalogEntityVersionItem({ group, basePath, isExpanded, onToggle, }) {
70
70
  }, [isExpanded]);
71
71
  const isNotSpecifiedVersion = group.version === constants_1.VERSION_NOT_SPECIFIED;
72
72
  const singleRevisionLink = (0, utils_1.buildRevisionUrl)(basePath, group.singleRevisionDate, group.version);
73
- const isClickable = hasRevisions || Boolean(singleRevisionLink);
74
- const isSingleRevisionActive = Boolean(singleRevisionLink && group.isCurrent);
75
73
  const versionTitle = isNotSpecifiedVersion
76
74
  ? `${translate('catalog.history.version.label', 'Version')}: ${translate('catalog.history.version.notSpecified', 'not specified')}`
77
75
  : `${translate('catalog.history.version.label', 'Version')}: ${group.version}`;
78
- const versionButton = (react_1.default.createElement(VersionButton, { type: "button", onClick: () => hasRevisions && onToggle(group.version), "$isClickable": isClickable, "$isCurrent": group.isCurrent, "$isActive": isSingleRevisionActive },
76
+ const versionButton = (react_1.default.createElement(VersionButton, { type: "button", onClick: () => hasRevisions && onToggle(group.version), "$isCurrent": group.isCurrent },
79
77
  react_1.default.createElement(VersionIcon, { "$isCurrent": group.isCurrent }, group.isCurrent ? (react_1.default.createElement(CheckmarkOutlineIcon_1.CheckmarkOutlineIcon, { size: "16px", color: "--catalog-history-sidebar-version-icon-color-current" })) : (react_1.default.createElement(NavaidMilitaryIcon_1.NavaidMilitaryIcon, { size: "16px", color: "--catalog-history-sidebar-version-icon-color" }))),
80
78
  react_1.default.createElement(VersionInfo, null,
81
79
  react_1.default.createElement(VersionTitleRow, null,
@@ -105,21 +103,16 @@ const VersionButton = styled_components_1.default.button `
105
103
  align-items: center;
106
104
  width: calc(100% - var(--catalog-history-sidebar-version-icon-margin-right));
107
105
  padding: var(--catalog-history-sidebar-version-header-padding);
108
- cursor: ${({ $isClickable }) => ($isClickable ? 'pointer' : 'default')};
106
+ cursor: pointer;
109
107
  border-radius: var(--catalog-history-sidebar-version-header-border-radius);
110
108
  transition: 0.2s ease;
111
109
  text-decoration: none;
112
110
  color: inherit;
113
- background-color: ${({ $isActive }) => $isActive ? 'var(--catalog-history-sidebar-revision-item-bg-color-active)' : 'transparent'};
111
+ background-color: 'transparent';
114
112
 
115
- ${({ $isClickable, $isActive }) => $isClickable &&
116
- `
117
- &:hover {
118
- background-color: ${$isActive
119
- ? 'var(--catalog-history-sidebar-revision-item-bg-color-active)'
120
- : 'var(--catalog-history-sidebar-version-header-bg-color-hover)'};
121
- }
122
- `}
113
+ &:hover {
114
+ background-color: var(--catalog-history-sidebar-version-header-bg-color-hover);
115
+ }
123
116
 
124
117
  ${({ $isCurrent }) => !$isCurrent &&
125
118
  `
@@ -39,11 +39,11 @@ function CodeBlockControls({ children, className, title, controls, tabs, dropdow
39
39
  react_1.default.createElement(ControlsWrapper, null,
40
40
  dropdown && react_1.default.createElement(CodeBlockDropdown_1.CodeBlockDropdown, Object.assign({}, dropdown)),
41
41
  report && !report.hidden && !((_a = report === null || report === void 0 ? void 0 : report.props) === null || _a === void 0 ? void 0 : _a.hide) ? (react_1.default.createElement(Tooltip_1.Tooltip, { tip: translate('codeSnippet.report.tooltipText', 'Report a problem'), placement: "top", arrowPosition: "right" },
42
- react_1.default.createElement(ControlButton, Object.assign({ variant: "text", size: "small", "data-testid": "report-button", icon: controlsType === 'icon' ? react_1.default.createElement(WarningSquareIcon_1.WarningSquareIcon, { size: "18px" }) : undefined }, report.props), controlsType != 'icon' && (((_b = report.props) === null || _b === void 0 ? void 0 : _b.buttonText) || 'Report')))) : null,
42
+ react_1.default.createElement(ControlButton, Object.assign({ variant: "text", size: "small", "data-testid": "report-button", icon: controlsType === 'icon' ? react_1.default.createElement(WarningSquareIcon_1.WarningSquareIcon, { size: "18px" }) : undefined, "aria-label": "Report a problem" }, report.props), controlsType != 'icon' && (((_b = report.props) === null || _b === void 0 ? void 0 : _b.buttonText) || 'Report')))) : null,
43
43
  expand && !((_c = codeSnippet === null || codeSnippet === void 0 ? void 0 : codeSnippet.expand) === null || _c === void 0 ? void 0 : _c.hide) ? (react_1.default.createElement(Tooltip_1.Tooltip, { tip: translate('codeSnippet.expand.tooltipText', 'Expand all'), placement: "top", arrowPosition: "right" },
44
- react_1.default.createElement(ControlButton, { variant: "text", size: "small", "data-testid": "expand-all", icon: controlsType === 'icon' ? react_1.default.createElement(MaximizeIcon_1.MaximizeIcon, null) : undefined, onClick: expand === null || expand === void 0 ? void 0 : expand.onClick }, controlsType !== 'icon' && ((expand === null || expand === void 0 ? void 0 : expand.label) || 'Expand all')))) : null,
44
+ react_1.default.createElement(ControlButton, { variant: "text", size: "small", "data-testid": "expand-all", icon: controlsType === 'icon' ? react_1.default.createElement(MaximizeIcon_1.MaximizeIcon, null) : undefined, "aria-label": "Expand all", onClick: expand === null || expand === void 0 ? void 0 : expand.onClick }, controlsType !== 'icon' && ((expand === null || expand === void 0 ? void 0 : expand.label) || 'Expand all')))) : null,
45
45
  collapse && !((_d = codeSnippet === null || codeSnippet === void 0 ? void 0 : codeSnippet.collapse) === null || _d === void 0 ? void 0 : _d.hide) ? (react_1.default.createElement(Tooltip_1.Tooltip, { tip: translate('codeSnippet.collapse.tooltipText', 'Collapse all'), placement: "top", arrowPosition: "right" },
46
- react_1.default.createElement(ControlButton, { variant: "text", size: "small", "data-testid": "collapse-all", icon: controlsType === 'icon' ? react_1.default.createElement(MinimizeIcon_1.MinimizeIcon, null) : undefined, onClick: collapse === null || collapse === void 0 ? void 0 : collapse.onClick }, controlsType !== 'icon' && ((expand === null || expand === void 0 ? void 0 : expand.label) || 'Collapse all')))) : null,
46
+ react_1.default.createElement(ControlButton, { variant: "text", size: "small", "data-testid": "collapse-all", icon: controlsType === 'icon' ? react_1.default.createElement(MinimizeIcon_1.MinimizeIcon, null) : undefined, onClick: collapse === null || collapse === void 0 ? void 0 : collapse.onClick, "aria-label": "Collapse all" }, controlsType !== 'icon' && ((expand === null || expand === void 0 ? void 0 : expand.label) || 'Collapse all')))) : null,
47
47
  select ? (react_1.default.createElement(ControlButton, { variant: "text", size: "small", "data-testid": "select-all", icon: controlsType === 'icon' ? react_1.default.createElement(SelectIcon_1.SelectIcon, null) : undefined, onClick: select === null || select === void 0 ? void 0 : select.onClick }, controlsType !== 'icon' && (select === null || select === void 0 ? void 0 : select.label) ? select.label : 'Select all')) : null,
48
48
  deselect ? (react_1.default.createElement(ControlButton, { variant: "text", size: "small", "data-testid": "clear-all", icon: controlsType === 'icon' ? react_1.default.createElement(DeselectIcon_1.DeselectIcon, null) : undefined, onClick: deselect === null || deselect === void 0 ? void 0 : deselect.onClick }, controlsType !== 'icon' && (deselect === null || deselect === void 0 ? void 0 : deselect.label) ? deselect.label : 'Clear all')) : null,
49
49
  copy && !((_e = codeSnippet === null || codeSnippet === void 0 ? void 0 : codeSnippet.copy) === null || _e === void 0 ? void 0 : _e.hide) ? (react_1.default.createElement(Tooltip_1.Tooltip, { tip: translate('codeSnippet.copy.tooltipText', 'Copy to clipboard'), placement: "top", arrowPosition: "right" },
@@ -100,7 +100,7 @@ function MenuItem(props) {
100
100
  item.sublabel ? (react_1.default.createElement(MenuItemSubLabel, null, translate(item.subLabelTranslationKey, item.sublabel))) : null),
101
101
  isDrilldown ? react_1.default.createElement(ArrowRightIcon_1.ArrowRightIcon, { size: "12px" }) : null,
102
102
  hasHttpTag ? (react_1.default.createElement(HttpTag_1.HttpTag, { color: httpColor || '' }, item.httpVerb === 'hook' ? 'event' : item.httpVerb)) : null));
103
- return (react_1.default.createElement(MenuItemWrapper, { "data-component-name": "Menu/MenuItem", className: generateClassName({ type, item, className }) },
103
+ return (react_1.default.createElement(MenuItemWrapper, { "data-component-name": "Menu/MenuItem", className: generateClassName({ type, item, className }), role: "listitem" },
104
104
  item.link ? (react_1.default.createElement(MenuItemLink, { to: item.link, external: item.external, target: item.target, languageInsensitive: item.languageInsensitive, onKeyDown: handleExpandOnEnter }, label)) : (label),
105
105
  isNested ? (react_1.default.createElement(MenuItemNestedWrapper, { depth: depth, ref: nestedMenuRef, style: style }, isExpanded || !canUnmount ? props.children : null)) : null,
106
106
  item.separatorLine ? (react_1.default.createElement(MenuItemSeparatorLine, { depth: depth, linePosition: item.linePosition })) : null));
@@ -88,7 +88,7 @@ function PageActions(props) {
88
88
  return (react_1.default.createElement(PageActionsWrapper, { "data-component-name": "PageActions/PageActions" },
89
89
  react_1.default.createElement(ButtonGroup_1.ButtonGroup, { variant: "outlined", size: "medium" },
90
90
  react_1.default.createElement(Button_1.Button, { icon: renderIcon(buttonAction, actionState), to: 'link' in buttonAction ? buttonAction.link : undefined, external: true, onClick: () => handleActionClick(buttonAction) }, buttonAction.buttonText),
91
- actions.length > 1 ? (react_1.default.createElement(StyledDropdown, { withArrow: true, trigger: react_1.default.createElement(Button_1.Button, null), placement: "bottom", alignment: "end" },
91
+ actions.length > 1 ? (react_1.default.createElement(StyledDropdown, { withArrow: true, trigger: react_1.default.createElement(Button_1.Button, { "aria-label": "More actions" }), placement: "bottom", alignment: "end" },
92
92
  react_1.default.createElement(StyledDropdownMenu, null, menuItems))) : null)));
93
93
  }
94
94
  function renderIcon(buttonAction, actionState) {
@@ -73,7 +73,7 @@ function SearchDialog({ onClose, className, initialMode = 'search', }) {
73
73
  const { query, setQuery, filter, setFilter, items, isSearchLoading, facets, setLoadMore, advancedSearch, askAi, groupField, } = useSearch(product === null || product === void 0 ? void 0 : product.name, autoSearchDisabled);
74
74
  const { isFilterOpen, onFilterToggle, onFilterChange, onFilterReset, onFacetReset, onQuickFilterReset, } = (0, hooks_1.useSearchFilter)(filter, setFilter);
75
75
  const { addSearchHistoryItem } = (0, hooks_1.useRecentSearches)();
76
- const aiSearch = useAiSearch({ filter });
76
+ const aiSearch = useAiSearch({ filter: filter, product: product === null || product === void 0 ? void 0 : product.name });
77
77
  (0, hooks_1.useModalScrollLock)(true);
78
78
  const searchInputRef = (0, react_1.useRef)(null);
79
79
  const modalRef = (0, react_1.useRef)(null);
@@ -30,7 +30,7 @@ const SidebarActions = ({ layout, hideCollapseSidebarButton = false, collapsedSi
30
30
  else {
31
31
  telemetry.sendSidebarItemCollapsedMessage();
32
32
  }
33
- }, size: "small", variant: "outlined", icon: collapsedSidebar ? react_1.default.createElement(SidePanelOpenIcon_1.SidePanelOpenIcon, null) : react_1.default.createElement(SidePanelCloseIcon_1.SidePanelCloseIcon, null) }))),
33
+ }, size: "small", variant: "outlined", "aria-label": collapsedSidebar ? 'Show sidebar' : 'Hide sidebar', icon: collapsedSidebar ? react_1.default.createElement(SidePanelOpenIcon_1.SidePanelOpenIcon, null) : react_1.default.createElement(SidePanelCloseIcon_1.SidePanelCloseIcon, null) }))),
34
34
  isApiDocs && (react_1.default.createElement(styled_1.ControlsWrapChangeLayoutButtons, { isCollapsed: collapsedSidebar },
35
35
  react_1.default.createElement(ChangeViewButton_1.ChangeViewButton, { collapsedSidebar: collapsedSidebar, layout: layout, onClick: () => {
36
36
  onChangeViewClick();
@@ -1,7 +1,7 @@
1
1
  declare const StyledChangeViewButton: import("styled-components").StyledComponent<"span", any, {
2
2
  collapsedSidebar?: boolean;
3
3
  }, never>;
4
- declare const StyledChangeViewButtonWrap: import("styled-components").StyledComponent<import("react").NamedExoticComponent<import("react").PropsWithChildren<import("../../components/Tooltip/Tooltip").TooltipProps>>, any, {
4
+ declare const StyledChangeViewButtonWrap: import("styled-components").StyledComponent<import("react").NamedExoticComponent<import("../..").TooltipProps>, any, {
5
5
  active?: boolean;
6
6
  }, never>;
7
7
  declare const ControlsWrap: import("styled-components").StyledComponent<"span", any, {
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import type { TooltipProps } from '../../core/types';
3
+ type Props = Exclude<TooltipProps, 'arrowPosition'> & {
4
+ arrowPosition?: 'left' | 'right' | 'center';
5
+ };
6
+ export declare const Tooltip: React.NamedExoticComponent<React.PropsWithChildren<Props>>;
7
+ export {};
@@ -0,0 +1,233 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.Tooltip = void 0;
37
+ const react_1 = __importStar(require("react"));
38
+ const styled_components_1 = __importStar(require("styled-components"));
39
+ const hooks_1 = require("../../core/hooks");
40
+ const Portal_1 = require("../../components/Portal/Portal");
41
+ function TooltipComponent({ children, isOpen, tip, withArrow = true, placement = 'top', className = 'default', width, dataTestId, disabled = false, arrowPosition = 'center', onClick, }) {
42
+ const tooltipWrapperRef = (0, react_1.useRef)(null);
43
+ const tooltipBodyRef = (0, react_1.useRef)(null);
44
+ const { isOpened, handleOpen, handleClose } = (0, hooks_1.useControl)(isOpen);
45
+ const anchorName = `--tooltip${(0, react_1.useId)().replace(/:/g, '')}`;
46
+ (0, hooks_1.useOutsideClick)(isOpened ? [tooltipWrapperRef, tooltipBodyRef] : tooltipWrapperRef, handleClose);
47
+ const isControlled = isOpen !== undefined;
48
+ (0, react_1.useEffect)(() => {
49
+ if (!isControlled)
50
+ return;
51
+ if (isOpen && !disabled) {
52
+ handleOpen();
53
+ }
54
+ else {
55
+ handleClose();
56
+ }
57
+ }, [isOpen, disabled, isControlled, handleOpen, handleClose]);
58
+ const controllers = !isControlled && !disabled
59
+ ? {
60
+ onMouseEnter: handleOpen,
61
+ onMouseLeave: handleClose,
62
+ onClick: (e) => {
63
+ onClick === null || onClick === void 0 ? void 0 : onClick(e);
64
+ handleClose();
65
+ },
66
+ onFocus: handleOpen,
67
+ onBlur: handleClose,
68
+ }
69
+ : {};
70
+ return (react_1.default.createElement(TooltipWrapper, Object.assign({ ref: tooltipWrapperRef }, controllers, { className: `tooltip-${className}`, "data-component-name": "Tooltip/Tooltip", anchorName: anchorName }),
71
+ children,
72
+ isOpened && !disabled && (react_1.default.createElement(Portal_1.Portal, null,
73
+ react_1.default.createElement(TooltipBody, { ref: tooltipBodyRef, "data-testid": dataTestId || (typeof tip === 'string' ? tip : ''), placement: placement, width: width, withArrow: withArrow, arrowPosition: arrowPosition, anchorName: anchorName }, tip)))));
74
+ }
75
+ exports.Tooltip = (0, react_1.memo)(TooltipComponent);
76
+ const PLACEMENTS = {
77
+ top: (0, styled_components_1.css) `
78
+ bottom: anchor(top);
79
+ ${({ withArrow, arrowPosition }) => withArrow && arrowPosition === 'left'
80
+ ? (0, styled_components_1.css) `
81
+ transform: translate(-32px, -6px);
82
+ left: anchor(center);
83
+ `
84
+ : arrowPosition === 'right'
85
+ ? (0, styled_components_1.css) `
86
+ transform: translate(32px, -6px);
87
+ right: anchor(center);
88
+ `
89
+ : (0, styled_components_1.css) `
90
+ transform: translate(-50%, -6px);
91
+ left: anchor(center);
92
+ `}
93
+
94
+ ${({ withArrow, arrowPosition }) => withArrow &&
95
+ (0, styled_components_1.css) `
96
+ &::after {
97
+ border-left: 14px solid transparent;
98
+ border-right: 14px solid transparent;
99
+ border-top-width: 8px;
100
+ border-top-style: solid;
101
+ border-radius: 2px;
102
+ bottom: 0;
103
+ ${arrowPosition === 'left' && 'left: 16px; transform: translateY(100%);'}
104
+ ${arrowPosition === 'center' && 'left: 50%; transform: translate(-50%, 100%);'}
105
+ ${arrowPosition === 'right' && 'right: 16px; transform: translateY(100%);'}
106
+ }
107
+ `}
108
+ `,
109
+ bottom: (0, styled_components_1.css) `
110
+ top: anchor(bottom);
111
+ ${({ withArrow, arrowPosition }) => withArrow && arrowPosition === 'left'
112
+ ? (0, styled_components_1.css) `
113
+ transform: translate(-32px, 6px);
114
+ left: anchor(center);
115
+ `
116
+ : arrowPosition === 'right'
117
+ ? (0, styled_components_1.css) `
118
+ transform: translate(32px, 6px);
119
+ right: anchor(center);
120
+ `
121
+ : (0, styled_components_1.css) `
122
+ transform: translate(-50%, 6px);
123
+ left: anchor(center);
124
+ `}
125
+
126
+ ${({ withArrow, arrowPosition }) => withArrow &&
127
+ (0, styled_components_1.css) `
128
+ &::after {
129
+ border-left: 14px solid transparent;
130
+ border-right: 14px solid transparent;
131
+ border-bottom-width: 8px;
132
+ border-bottom-style: solid;
133
+ border-radius: 0 0 2px 2px;
134
+ top: 0;
135
+ ${arrowPosition === 'left' && 'left: 16px; transform: translateY(-100%);'}
136
+ ${arrowPosition === 'center' && 'left: 50%; transform: translate(-50%, -100%);'}
137
+ ${arrowPosition === 'right' && 'right: 16px; transform: translateY(-100%);'}
138
+ }
139
+ `}
140
+ `,
141
+ left: (0, styled_components_1.css) `
142
+ transform: translate(-100%, -50%);
143
+ margin-left: -7px;
144
+ top: anchor(center);
145
+ left: anchor(left);
146
+
147
+ ${({ withArrow }) => withArrow &&
148
+ (0, styled_components_1.css) `
149
+ &::after {
150
+ border-top: 14px solid transparent;
151
+ border-bottom: 14px solid transparent;
152
+ border-left-width: 8px;
153
+ border-left-style: solid;
154
+ border-radius: 2px 0 0 2px;
155
+ right: -9px;
156
+ top: 50%;
157
+ transform: translateY(-50%);
158
+ }
159
+ `}
160
+ `,
161
+ right: (0, styled_components_1.css) `
162
+ transform: translate(0, -50%);
163
+ margin-left: 7px;
164
+ top: anchor(center);
165
+ left: anchor(right);
166
+
167
+ ${({ withArrow }) => withArrow &&
168
+ (0, styled_components_1.css) `
169
+ &::after {
170
+ border-top: 14px solid transparent;
171
+ border-bottom: 14px solid transparent;
172
+ border-right-width: 8px;
173
+ border-right-style: solid;
174
+ border-radius: 0 2px 2px 0;
175
+ left: -9px;
176
+ top: 50%;
177
+ transform: translateY(-50%);
178
+ }
179
+ `}
180
+ `,
181
+ };
182
+ const TooltipWrapper = styled_components_1.default.div.attrs(({ anchorName }) => ({
183
+ style: {
184
+ anchorName: anchorName,
185
+ },
186
+ })) `
187
+ display: flex;
188
+ `;
189
+ const TooltipBody = styled_components_1.default.span.attrs(({ anchorName }) => ({
190
+ style: {
191
+ positionAnchor: anchorName,
192
+ },
193
+ })) `
194
+ position: fixed;
195
+ min-width: 64px;
196
+ padding: var(--tooltip-padding);
197
+ max-width: var(--tooltip-max-width);
198
+ white-space: normal;
199
+ word-break: normal;
200
+ overflow-wrap: break-word;
201
+ text-align: left;
202
+
203
+ border-radius: var(--border-radius-md);
204
+ transition: opacity 0.3s ease-out;
205
+
206
+ font-size: var(--font-size-base);
207
+ line-height: var(--line-height-base);
208
+
209
+ z-index: var(--z-index-overlay);
210
+
211
+ &::after {
212
+ position: absolute;
213
+
214
+ content: ' ';
215
+ display: inline-block;
216
+ width: 0;
217
+ height: 0;
218
+ border-color: var(--tooltip-arrow-color, var(--tooltip-bg-color));
219
+ }
220
+
221
+ background: var(--tooltip-bg-color);
222
+ color: var(--tooltip-text-color);
223
+ border: var(--tooltip-border-width, 0) var(--tooltip-border-style, solid)
224
+ var(--tooltip-border-color, transparent);
225
+ box-shadow: var(--bg-raised-shadow);
226
+
227
+ width: ${({ width }) => width || 'max-content'};
228
+
229
+ ${({ placement }) => (0, styled_components_1.css) `
230
+ ${PLACEMENTS[placement]};
231
+ `}
232
+ `;
233
+ //# sourceMappingURL=AnchorTooltip.js.map
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import type { TooltipProps } from '../../core/types';
3
+ export declare const Tooltip: React.NamedExoticComponent<React.PropsWithChildren<TooltipProps>>;