@redocly/theme 0.70.0-next.2 → 0.70.0-next.4

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 (155) hide show
  1. package/lib/components/Catalog/Catalog.js +1 -1
  2. package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistorySidebar.js +2 -2
  3. package/lib/components/Catalog/CatalogEntity/CatalogEntitySchema.js +1 -1
  4. package/lib/components/Catalog/CatalogMobileFiltersPanel/CatalogMobileFiltersPanel.js +1 -1
  5. package/lib/components/Catalog/CatalogMobileFiltersPanel/CatalogMobileFiltersPanelOverlay.js +2 -2
  6. package/lib/components/CodeBlock/CodeBlockControls.js +3 -5
  7. package/lib/components/Consent/Consent.d.ts +2 -0
  8. package/lib/components/Consent/Consent.js +17 -0
  9. package/lib/components/Consent/ConsentBanner.d.ts +2 -0
  10. package/lib/components/Consent/ConsentBanner.js +120 -0
  11. package/lib/components/Consent/ConsentDialog.d.ts +2 -0
  12. package/lib/components/Consent/ConsentDialog.js +128 -0
  13. package/lib/components/Consent/ConsentSettingsLink.d.ts +2 -0
  14. package/lib/components/Consent/ConsentSettingsLink.js +35 -0
  15. package/lib/components/Consent/variables.d.ts +1 -0
  16. package/lib/components/Consent/variables.js +31 -0
  17. package/lib/components/Dropdown/Dropdown.js +3 -1
  18. package/lib/components/Footer/Footer.js +4 -1
  19. package/lib/components/JsonViewer/Helpers.d.ts +10 -2
  20. package/lib/components/JsonViewer/Helpers.js +29 -33
  21. package/lib/components/JsonViewer/JsonViewer.js +15 -18
  22. package/lib/components/Markdown/Markdown.js +3 -2
  23. package/lib/components/Markdown/styles/base-table.js +14 -1
  24. package/lib/components/Markdown/variables.js +1 -0
  25. package/lib/components/Menu/Menu.js +4 -0
  26. package/lib/components/Menu/MenuSelect.d.ts +7 -0
  27. package/lib/components/Menu/MenuSelect.js +129 -0
  28. package/lib/components/Menu/variables.js +43 -4
  29. package/lib/components/Navbar/Navbar.js +44 -5
  30. package/lib/components/Navbar/variables.js +3 -0
  31. package/lib/components/NavigationTabs/NavigationTab.d.ts +7 -0
  32. package/lib/components/NavigationTabs/NavigationTab.js +93 -0
  33. package/lib/components/NavigationTabs/NavigationTabContent.d.ts +7 -0
  34. package/lib/components/NavigationTabs/NavigationTabContent.js +50 -0
  35. package/lib/components/NavigationTabs/NavigationTabMenu.d.ts +7 -0
  36. package/lib/components/NavigationTabs/NavigationTabMenu.js +18 -0
  37. package/lib/components/NavigationTabs/NavigationTabs.d.ts +7 -0
  38. package/lib/components/NavigationTabs/NavigationTabs.js +97 -0
  39. package/lib/components/NavigationTabs/variables.d.ts +1 -0
  40. package/lib/components/NavigationTabs/variables.js +37 -0
  41. package/lib/components/Product/utils.js +1 -1
  42. package/lib/components/Search/SearchAiMessage.js +1 -1
  43. package/lib/components/Search/SearchAiResponse.js +1 -0
  44. package/lib/components/Search/SearchTrigger.js +8 -2
  45. package/lib/components/Sidebar/Sidebar.js +2 -2
  46. package/lib/components/TableOfContent/TableOfContent.js +2 -2
  47. package/lib/core/constants/common.d.ts +1 -0
  48. package/lib/core/constants/common.js +1 -0
  49. package/lib/core/constants/consent.d.ts +2 -0
  50. package/lib/core/constants/consent.js +30 -0
  51. package/lib/core/constants/index.d.ts +1 -0
  52. package/lib/core/constants/index.js +1 -0
  53. package/lib/core/hooks/index.d.ts +3 -0
  54. package/lib/core/hooks/index.js +3 -0
  55. package/lib/core/hooks/menu/use-mobile-menu-items.js +75 -51
  56. package/lib/core/hooks/menu/use-mobile-menu-levels.js +12 -7
  57. package/lib/core/hooks/use-consent-dialog.d.ts +12 -0
  58. package/lib/core/hooks/use-consent-dialog.js +36 -0
  59. package/lib/core/hooks/use-consent-telemetry.d.ts +1 -0
  60. package/lib/core/hooks/use-consent-telemetry.js +42 -0
  61. package/lib/core/hooks/use-scroll-item-into-view.d.ts +2 -0
  62. package/lib/core/hooks/use-scroll-item-into-view.js +16 -0
  63. package/lib/core/hooks/use-theme-hooks.js +16 -0
  64. package/lib/core/styles/global.js +54 -42
  65. package/lib/core/types/consent.d.ts +54 -0
  66. package/lib/core/types/consent.js +3 -0
  67. package/lib/core/types/hooks.d.ts +7 -0
  68. package/lib/core/types/index.d.ts +2 -0
  69. package/lib/core/types/l10n.d.ts +1 -1
  70. package/lib/core/types/navigation-tabs.d.ts +49 -0
  71. package/lib/core/types/navigation-tabs.js +3 -0
  72. package/lib/core/utils/consent-settings-link-placement.d.ts +3 -0
  73. package/lib/core/utils/consent-settings-link-placement.js +15 -0
  74. package/lib/core/utils/index.d.ts +2 -0
  75. package/lib/core/utils/index.js +2 -0
  76. package/lib/core/utils/mcp.js +1 -1
  77. package/lib/core/utils/menu.d.ts +4 -0
  78. package/lib/core/utils/menu.js +48 -8
  79. package/lib/core/utils/navigation-tabs.d.ts +8 -0
  80. package/lib/core/utils/navigation-tabs.js +71 -0
  81. package/lib/core/utils/urls.js +3 -1
  82. package/lib/icons/ExpandCollapseIcon/ExpandCollapseIcon.d.ts +29 -0
  83. package/lib/icons/ExpandCollapseIcon/ExpandCollapseIcon.js +81 -0
  84. package/lib/index.d.ts +6 -0
  85. package/lib/index.js +8 -1
  86. package/lib/layouts/PageLayout.js +1 -1
  87. package/lib/layouts/RootLayout.js +2 -2
  88. package/lib/markdoc/components/CodeWalkthrough/CodeFilters.js +1 -1
  89. package/lib/markdoc/components/CodeWalkthrough/CodePanel.js +3 -3
  90. package/lib/markdoc/components/CodeWalkthrough/CodeWalkthrough.js +1 -1
  91. package/package.json +3 -3
  92. package/src/components/Catalog/Catalog.tsx +1 -1
  93. package/src/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistorySidebar.tsx +2 -2
  94. package/src/components/Catalog/CatalogEntity/CatalogEntitySchema.tsx +1 -1
  95. package/src/components/Catalog/CatalogMobileFiltersPanel/CatalogMobileFiltersPanel.tsx +1 -1
  96. package/src/components/Catalog/CatalogMobileFiltersPanel/CatalogMobileFiltersPanelOverlay.tsx +2 -2
  97. package/src/components/CodeBlock/CodeBlockControls.tsx +4 -7
  98. package/src/components/Consent/Consent.tsx +18 -0
  99. package/src/components/Consent/ConsentBanner.tsx +110 -0
  100. package/src/components/Consent/ConsentDialog.tsx +210 -0
  101. package/src/components/Consent/ConsentSettingsLink.tsx +44 -0
  102. package/src/components/Consent/variables.ts +28 -0
  103. package/src/components/Dropdown/Dropdown.tsx +4 -1
  104. package/src/components/Footer/Footer.tsx +2 -0
  105. package/src/components/JsonViewer/Helpers.tsx +46 -51
  106. package/src/components/JsonViewer/JsonViewer.tsx +23 -25
  107. package/src/components/Markdown/Markdown.tsx +3 -2
  108. package/src/components/Markdown/styles/base-table.ts +14 -1
  109. package/src/components/Markdown/variables.ts +1 -0
  110. package/src/components/Menu/Menu.tsx +5 -0
  111. package/src/components/Menu/MenuSelect.tsx +198 -0
  112. package/src/components/Menu/variables.ts +43 -4
  113. package/src/components/Navbar/Navbar.tsx +22 -5
  114. package/src/components/Navbar/variables.ts +3 -0
  115. package/src/components/NavigationTabs/NavigationTab.tsx +148 -0
  116. package/src/components/NavigationTabs/NavigationTabContent.tsx +66 -0
  117. package/src/components/NavigationTabs/NavigationTabMenu.tsx +40 -0
  118. package/src/components/NavigationTabs/NavigationTabs.tsx +83 -0
  119. package/src/components/NavigationTabs/variables.ts +34 -0
  120. package/src/components/Product/utils.ts +1 -1
  121. package/src/components/Search/SearchAiMessage.tsx +1 -1
  122. package/src/components/Search/SearchAiResponse.tsx +1 -0
  123. package/src/components/Search/SearchTrigger.tsx +11 -2
  124. package/src/components/Sidebar/Sidebar.tsx +2 -2
  125. package/src/components/TableOfContent/TableOfContent.tsx +2 -2
  126. package/src/core/constants/common.ts +1 -0
  127. package/src/core/constants/consent.ts +29 -0
  128. package/src/core/constants/index.ts +1 -0
  129. package/src/core/hooks/__mocks__/use-theme-hooks.ts +17 -0
  130. package/src/core/hooks/index.ts +3 -0
  131. package/src/core/hooks/menu/use-mobile-menu-items.ts +91 -56
  132. package/src/core/hooks/menu/use-mobile-menu-levels.ts +14 -6
  133. package/src/core/hooks/use-consent-dialog.ts +51 -0
  134. package/src/core/hooks/use-consent-telemetry.ts +56 -0
  135. package/src/core/hooks/use-scroll-item-into-view.ts +18 -0
  136. package/src/core/hooks/use-theme-hooks.ts +16 -0
  137. package/src/core/styles/global.ts +14 -2
  138. package/src/core/types/consent.ts +51 -0
  139. package/src/core/types/hooks.ts +7 -0
  140. package/src/core/types/index.ts +2 -0
  141. package/src/core/types/l10n.ts +25 -1
  142. package/src/core/types/navigation-tabs.ts +54 -0
  143. package/src/core/utils/consent-settings-link-placement.ts +18 -0
  144. package/src/core/utils/index.ts +2 -0
  145. package/src/core/utils/mcp.ts +1 -1
  146. package/src/core/utils/menu.ts +54 -9
  147. package/src/core/utils/navigation-tabs.ts +99 -0
  148. package/src/core/utils/urls.ts +3 -1
  149. package/src/icons/ExpandCollapseIcon/ExpandCollapseIcon.tsx +56 -0
  150. package/src/index.ts +7 -0
  151. package/src/layouts/PageLayout.tsx +1 -1
  152. package/src/layouts/RootLayout.tsx +2 -2
  153. package/src/markdoc/components/CodeWalkthrough/CodeFilters.tsx +1 -1
  154. package/src/markdoc/components/CodeWalkthrough/CodePanel.tsx +3 -3
  155. package/src/markdoc/components/CodeWalkthrough/CodeWalkthrough.tsx +1 -1
@@ -0,0 +1,7 @@
1
+ import type { JSX } from 'react';
2
+ import type { NavigationTabsConfig } from '../../core/types';
3
+ export type NavigationTabsProps = {
4
+ config?: NavigationTabsConfig;
5
+ className?: string;
6
+ };
7
+ export declare function NavigationTabs({ config, className }: NavigationTabsProps): JSX.Element | null;
@@ -0,0 +1,97 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.NavigationTabs = NavigationTabs;
40
+ const react_1 = __importStar(require("react"));
41
+ const styled_components_1 = __importDefault(require("styled-components"));
42
+ const utils_1 = require("../../core/utils");
43
+ const hooks_1 = require("../../core/hooks");
44
+ const NavigationTab_1 = require("../../components/NavigationTabs/NavigationTab");
45
+ function NavigationTabs({ config, className }) {
46
+ var _a;
47
+ const { useTranslate } = (0, hooks_1.useThemeHooks)();
48
+ const { translate } = useTranslate();
49
+ const listRef = (0, react_1.useRef)(null);
50
+ const tabs = (_a = config === null || config === void 0 ? void 0 : config.items) !== null && _a !== void 0 ? _a : [];
51
+ const activeIndex = tabs.findIndex((tab) => tab.active);
52
+ (0, hooks_1.useScrollItemIntoView)(listRef, activeIndex);
53
+ if (!tabs.length) {
54
+ return null;
55
+ }
56
+ return (react_1.default.createElement(NavigationTabsWrapper, { "data-component-name": "NavigationTabs/NavigationTabs", className: className, "aria-label": translate('navigationTabs.label', 'Navigation tabs') },
57
+ react_1.default.createElement(NavigationTabsList, { ref: listRef }, tabs.map((tab, index) => (react_1.default.createElement(NavigationTab_1.NavigationTab, { key: `${tab.label}_${index}`, tab: tab }))))));
58
+ }
59
+ const NavigationTabsWrapper = styled_components_1.default.nav `
60
+ display: none;
61
+ box-sizing: border-box;
62
+ width: 100%;
63
+ height: var(--navigation-tabs-height);
64
+ max-width: var(--navbar-container-max-width);
65
+ padding: var(--navigation-tabs-padding);
66
+ background: var(--navigation-tabs-bg-color);
67
+ border-bottom: var(--navigation-tabs-bottom-border);
68
+ flex-shrink: 0;
69
+
70
+ @media screen and (min-width: ${utils_1.breakpoints.medium}) {
71
+ display: flex;
72
+ }
73
+
74
+ @media screen and (min-width: ${utils_1.breakpoints.max}) {
75
+ max-width: var(--container-max-width);
76
+ margin-left: auto;
77
+ margin-right: auto;
78
+ }
79
+ `;
80
+ const NavigationTabsList = styled_components_1.default.ul `
81
+ list-style: none;
82
+ margin: 0 0 calc(-1 * var(--navigation-tabs-border-width));
83
+ padding: 0;
84
+ display: flex;
85
+ flex-wrap: nowrap;
86
+ align-items: stretch;
87
+ gap: var(--navigation-tabs-gap);
88
+ min-width: 0;
89
+ overflow-x: auto;
90
+ scrollbar-width: none;
91
+ -ms-overflow-style: none;
92
+
93
+ &::-webkit-scrollbar {
94
+ display: none;
95
+ }
96
+ `;
97
+ //# sourceMappingURL=NavigationTabs.js.map
@@ -0,0 +1 @@
1
+ export declare const navigationTabs: import("styled-components").RuleSet<object>;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.navigationTabs = void 0;
4
+ const styled_components_1 = require("styled-components");
5
+ exports.navigationTabs = (0, styled_components_1.css) `
6
+ --navigation-tabs-height: 48px; // @presenter Spacing
7
+ --navigation-tabs-bg-color: transparent; // @presenter Color
8
+ --navigation-tabs-border-color: var(--border-color-secondary);
9
+ --navigation-tabs-border-width: 1px;
10
+ --navigation-tabs-bottom-border: var(--navigation-tabs-border-width) solid var(--navigation-tabs-border-color);
11
+ --navigation-tabs-padding-vertical: 0;
12
+ --navigation-tabs-padding-horizontal: var(--spacing-xl);
13
+ --navigation-tabs-padding: var(--navigation-tabs-padding-vertical) var(--navigation-tabs-padding-horizontal); // @presenter Spacing
14
+ --navigation-tabs-gap: var(--spacing-base); // @presenter Spacing
15
+
16
+ --navigation-tabs-item-padding-vertical: var(--spacing-xxs);
17
+ --navigation-tabs-item-padding-horizontal: 0;
18
+ --navigation-tabs-item-padding: var(--navigation-tabs-item-padding-vertical) var(--navigation-tabs-item-padding-horizontal);
19
+ --navigation-tabs-item-content-gap: var(--spacing-xs);
20
+ --navigation-tabs-item-font-size: var(--font-size-base);
21
+ --navigation-tabs-item-line-height: var(--line-height-base);
22
+ --navigation-tabs-item-font-weight: var(--font-weight-regular);
23
+ --navigation-tabs-item-font-weight-active: var(--font-weight-medium);
24
+ --navigation-tabs-item-text-color: var(--navbar-text-color); // @presenter Color
25
+ --navigation-tabs-item-text-color-hover: var(--text-color-primary); // @presenter Color
26
+ --navigation-tabs-item-text-color-active: var(--text-color-primary); // @presenter Color
27
+ --navigation-tabs-item-bottom-border: var(--navigation-tabs-border-width) solid transparent;
28
+ --navigation-tabs-item-bottom-border-hover: var(--navigation-tabs-border-width) solid var(--border-color-primary);
29
+ --navigation-tabs-item-bottom-border-active: var(--navigation-tabs-border-width) solid var(--border-color-inverse);
30
+ --navigation-tabs-item-border-color-focused: var(--button-border-color-focused);
31
+ --navigation-tabs-item-border-radius: var(--navbar-item-border-radius);
32
+ --navigation-tabs-item-icon-size: 1.25em; // @presenter Spacing
33
+ --navigation-tabs-item-external-icon-margin-left: 0;
34
+ --navigation-tabs-item-label-font-weight-active: var(--navigation-tabs-item-font-weight-active);
35
+ --navigation-tabs-item-transition: 150ms ease-in-out;
36
+ `;
37
+ //# sourceMappingURL=variables.js.map
@@ -5,6 +5,6 @@ function getProductClassName(productName) {
5
5
  return `product-${productName
6
6
  .toLowerCase()
7
7
  .replace(/[^a-z0-9]+/g, '-')
8
- .replace(/^-+|-+$/g, '')}`;
8
+ .replace(/^-+|(?<!-)-+$/g, '')}`;
9
9
  }
10
10
  //# sourceMappingURL=utils.js.map
@@ -251,7 +251,7 @@ const ResourceTagsWrapper = styled_components_1.default.div `
251
251
  flex-wrap: wrap;
252
252
  gap: var(--search-ai-resource-tags-gap);
253
253
  `;
254
- const ResourceTag = (0, styled_components_1.default)(Tag_1.Tag) `
254
+ const ResourceTag = (0, styled_components_1.default)(Tag_1.Tag).attrs({ textTransform: 'none' }) `
255
255
  .tag-default {
256
256
  --tag-color: var(--search-ai-resource-tag-text-color);
257
257
  max-width: 100%;
@@ -141,6 +141,7 @@ const ResourceTags = styled_components_1.default.div `
141
141
  `;
142
142
  const ResourceTag = (0, styled_components_1.default)(Tag_1.Tag).attrs({
143
143
  className: 'tag-resource',
144
+ textTransform: 'none',
144
145
  }) `
145
146
  .tag-default {
146
147
  --tag-color: --search-ai-resource-tag-text-color;
@@ -61,13 +61,16 @@ function SearchTrigger({ onClick, className }) {
61
61
  }
62
62
  }
63
63
  mainShortcutKey = mainShortcutKey === null || mainShortcutKey === void 0 ? void 0 : mainShortcutKey.toUpperCase();
64
- const isMac = (0, utils_1.getUserAgent)().includes('Mac');
64
+ // A page can be cached and served to every platform, so the server renders a hidden
65
+ // placeholder and the browser picks the label after hydration.
66
+ const [isMac, setIsMac] = React.useState(undefined);
67
+ React.useEffect(() => setIsMac((0, utils_1.getUserAgent)().includes('Mac')), []);
65
68
  return (React.createElement(SearchTriggerWrapper, { onClick: onClick, className: className, "data-component-name": "Search/SearchTrigger" },
66
69
  React.createElement(SearchTriggerButton, { "data-testid": "search-trigger-button", variant: "text", size: "medium", icon: React.createElement(SearchIcon_1.SearchIcon, null), "aria-label": "Search trigger button" }),
67
70
  React.createElement(SearchTriggerInput, { "data-testid": "search-trigger-input", "data-translation-key": "search.navbar.label" },
68
71
  React.createElement(SearchIcon_1.SearchIcon, null),
69
72
  translate('search.navbar.label', 'Search'),
70
- mainShortcutKey === constants_1.DEFAULT_KEYBOARD_SHORTCUTS ? (React.createElement("span", null, isMac ? '⌘K' : 'Ctrl+K')) : (React.createElement("span", null, mainShortcutKey)))));
73
+ mainShortcutKey === constants_1.DEFAULT_KEYBOARD_SHORTCUTS ? (React.createElement(SearchTriggerShortcut, { $isPending: isMac === undefined }, isMac ? '⌘K' : 'Ctrl+K')) : (React.createElement("span", null, mainShortcutKey)))));
71
74
  }
72
75
  const SearchTriggerWrapper = styled_components_1.default.div `
73
76
  color: var(--search-trigger-color);
@@ -85,6 +88,9 @@ const SearchTriggerButton = (0, styled_components_1.default)(Button_1.Button) `
85
88
  display: none;
86
89
  }
87
90
  `;
91
+ const SearchTriggerShortcut = styled_components_1.default.span `
92
+ visibility: ${({ $isPending }) => ($isPending ? 'hidden' : 'visible')};
93
+ `;
88
94
  const SearchTriggerInput = styled_components_1.default.div `
89
95
  display: none;
90
96
  align-items: center;
@@ -38,8 +38,8 @@ const SidebarContent = styled_components_1.default.aside `
38
38
  flex-direction: column;
39
39
  width: 100%;
40
40
  -webkit-font-smoothing: antialiased;
41
- top: calc(var(--navbar-height) + var(--banner-height));
42
- height: calc(100vh - var(--navbar-height) - var(--banner-height));
41
+ top: var(--navbar-offset);
42
+ height: calc(100vh - var(--navbar-offset));
43
43
  overflow-x: hidden;
44
44
  ${({ $opened }) => `
45
45
  display: ${$opened ? 'flex' : 'none'}
@@ -91,8 +91,8 @@ const TableOfContentHeader = styled_components_1.default.div `
91
91
  `;
92
92
  const TableOfContentItems = styled_components_1.default.div `
93
93
  position: sticky;
94
- top: calc(var(--navbar-height) + var(--toc-offset-top));
95
- max-height: calc(100vh - var(--navbar-height) - var(--toc-offset-top));
94
+ top: calc(var(--navbar-stack-height) + var(--toc-offset-top));
95
+ max-height: calc(100vh - var(--navbar-stack-height) - var(--toc-offset-top));
96
96
  overflow-y: auto;
97
97
  width: var(--toc-width);
98
98
  border-left: solid 1px var(--toc-border-color);
@@ -15,6 +15,7 @@ export declare enum FEEDBACK_TYPES {
15
15
  }
16
16
  export declare const DEFAULT_FEEDBACK_TYPE = FEEDBACK_TYPES.SENTIMENT;
17
17
  export declare enum MenuItemType {
18
+ Select = "select",
18
19
  Separator = "separator",
19
20
  DrillDown = "drilldown",
20
21
  Group = "group",
@@ -21,6 +21,7 @@ var FEEDBACK_TYPES;
21
21
  exports.DEFAULT_FEEDBACK_TYPE = FEEDBACK_TYPES.SENTIMENT;
22
22
  var MenuItemType;
23
23
  (function (MenuItemType) {
24
+ MenuItemType["Select"] = "select";
24
25
  MenuItemType["Separator"] = "separator";
25
26
  MenuItemType["DrillDown"] = "drilldown";
26
27
  MenuItemType["Group"] = "group";
@@ -0,0 +1,2 @@
1
+ import type { ConsentCategory } from '../types/consent';
2
+ export declare const CONSENT_CATEGORIES: readonly ConsentCategory[];
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CONSENT_CATEGORIES = void 0;
4
+ exports.CONSENT_CATEGORIES = [
5
+ {
6
+ id: 'necessary',
7
+ locked: true,
8
+ titleTranslationKey: 'consent.category.necessary.title',
9
+ descriptionTranslationKey: 'consent.category.necessary.description',
10
+ titleDefault: 'Necessary',
11
+ descriptionDefault: 'Needed for the site to work: your consent choice, your color mode, and anonymous usage data.',
12
+ },
13
+ {
14
+ id: 'analytics',
15
+ locked: false,
16
+ titleTranslationKey: 'consent.category.analytics.title',
17
+ descriptionTranslationKey: 'consent.category.analytics.description',
18
+ titleDefault: 'Analytics',
19
+ descriptionDefault: 'Helps us understand which pages are useful.',
20
+ },
21
+ {
22
+ id: 'marketing',
23
+ locked: false,
24
+ titleTranslationKey: 'consent.category.marketing.title',
25
+ descriptionTranslationKey: 'consent.category.marketing.description',
26
+ titleDefault: 'Marketing',
27
+ descriptionDefault: 'Lets us measure which campaigns bring visitors to this site.',
28
+ },
29
+ ];
30
+ //# sourceMappingURL=consent.js.map
@@ -10,3 +10,4 @@ export * from './mcp';
10
10
  export * from './feedback';
11
11
  export * from './heading';
12
12
  export * from './markdown';
13
+ export * from './consent';
@@ -26,4 +26,5 @@ __exportStar(require("./mcp"), exports);
26
26
  __exportStar(require("./feedback"), exports);
27
27
  __exportStar(require("./heading"), exports);
28
28
  __exportStar(require("./markdown"), exports);
29
+ __exportStar(require("./consent"), exports);
29
30
  //# sourceMappingURL=index.js.map
@@ -22,6 +22,8 @@ export * from './menu/use-collapse';
22
22
  export * from './feedback/use-report-dialog';
23
23
  export * from './use-tabs';
24
24
  export * from './use-focus-trap';
25
+ export * from './use-consent-dialog';
26
+ export * from './use-consent-telemetry';
25
27
  export * from './use-language-picker';
26
28
  export * from './use-product-picker';
27
29
  export * from './search/use-search-dialog';
@@ -56,3 +58,4 @@ export * from './use-toast-logic';
56
58
  export * from './use-banner-telemetry';
57
59
  export * from './use-tooltip-fallback-placement';
58
60
  export * from './use-anchor-positioning';
61
+ export * from './use-scroll-item-into-view';
@@ -38,6 +38,8 @@ __exportStar(require("./menu/use-collapse"), exports);
38
38
  __exportStar(require("./feedback/use-report-dialog"), exports);
39
39
  __exportStar(require("./use-tabs"), exports);
40
40
  __exportStar(require("./use-focus-trap"), exports);
41
+ __exportStar(require("./use-consent-dialog"), exports);
42
+ __exportStar(require("./use-consent-telemetry"), exports);
41
43
  __exportStar(require("./use-language-picker"), exports);
42
44
  __exportStar(require("./use-product-picker"), exports);
43
45
  __exportStar(require("./search/use-search-dialog"), exports);
@@ -72,4 +74,5 @@ __exportStar(require("./use-toast-logic"), exports);
72
74
  __exportStar(require("./use-banner-telemetry"), exports);
73
75
  __exportStar(require("./use-tooltip-fallback-placement"), exports);
74
76
  __exportStar(require("./use-anchor-positioning"), exports);
77
+ __exportStar(require("./use-scroll-item-into-view"), exports);
75
78
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useMobileMenuItems = void 0;
4
+ const react_1 = require("react");
4
5
  const react_router_1 = require("react-router");
5
6
  const use_theme_hooks_1 = require("../use-theme-hooks");
6
7
  const use_theme_config_1 = require("../use-theme-config");
@@ -10,73 +11,96 @@ const MENU_SEPARATOR = {
10
11
  type: 'separator',
11
12
  separatorLine: true,
12
13
  };
14
+ const NO_VERSIONS = [];
15
+ const NO_NAV_ITEMS = [];
13
16
  const useMobileMenuItems = (menuType) => {
14
- var _a, _b, _c;
15
- const { useTranslate, useL10nConfig, useCurrentProduct, usePageVersions, useSidebarItems } = (0, use_theme_hooks_1.useThemeHooks)();
16
- const { versions = [] } = usePageVersions() || {};
17
+ var _a, _b, _c, _d;
18
+ var _e, _f, _g;
19
+ const { useTranslate, useL10nConfig, useCurrentProduct, usePageVersions, useSidebarItems, useNavigationTabs, } = (0, use_theme_hooks_1.useThemeHooks)();
20
+ const versions = (_e = (_a = usePageVersions()) === null || _a === void 0 ? void 0 : _a.versions) !== null && _e !== void 0 ? _e : NO_VERSIONS;
17
21
  const { defaultLocale, currentLocale, locales } = useL10nConfig();
18
22
  const { translate } = useTranslate();
19
23
  const activeVersion = versions.find((version) => version.active);
20
24
  const { currentItems: sidebarItems, pushDrilldownState, popDrilldownState, backLink, } = useSidebarItems(activeVersion);
25
+ const navigationTabs = useNavigationTabs();
21
26
  const location = (0, react_router_1.useLocation)();
22
27
  const currentProduct = useCurrentProduct();
23
- const hasProductNavbarOverride = (_a = currentProduct === null || currentProduct === void 0 ? void 0 : currentProduct.configOverride) === null || _a === void 0 ? void 0 : _a.navbar;
28
+ const hasProductNavbarOverride = (_b = currentProduct === null || currentProduct === void 0 ? void 0 : currentProduct.configOverride) === null || _b === void 0 ? void 0 : _b.navbar;
24
29
  const productThemeConfig = (0, use_theme_config_1.useThemeConfig)();
25
30
  const baseThemeConfig = (0, use_theme_config_1.useThemeConfig)(false);
26
- const baseNavItems = (((_b = baseThemeConfig.navbar) === null || _b === void 0 ? void 0 : _b.items) || []);
27
- const productNavItems = (hasProductNavbarOverride ? ((_c = productThemeConfig.navbar) === null || _c === void 0 ? void 0 : _c.items) || [] : []);
28
- const menuItems = [];
29
- if (menuType === common_1.MobileMenuType.PAGE) {
30
- if (activeVersion) {
31
- // eslint-disable-next-line no-warning-comments
32
- // TODO: consider to refactor
33
- const versionsSection = (0, menu_1.buildVersionSection)(translate, versions, activeVersion);
34
- menuItems.push(...versionsSection);
31
+ const baseNavItems = ((_f = (_c = baseThemeConfig.navbar) === null || _c === void 0 ? void 0 : _c.items) !== null && _f !== void 0 ? _f : NO_NAV_ITEMS);
32
+ const productNavItems = (hasProductNavbarOverride ? ((_g = (_d = productThemeConfig.navbar) === null || _d === void 0 ? void 0 : _d.items) !== null && _g !== void 0 ? _g : NO_NAV_ITEMS) : NO_NAV_ITEMS);
33
+ const products = baseThemeConfig.products;
34
+ const items = (0, react_1.useMemo)(() => {
35
+ const menuItems = [];
36
+ const navigationTabsSelect = menuType === common_1.MobileMenuType.PAGE ? (0, menu_1.buildNavigationTabsSelect)({ navigationTabs }) : undefined;
37
+ if (menuType === common_1.MobileMenuType.PAGE) {
38
+ if (activeVersion) {
39
+ menuItems.push(...(0, menu_1.buildVersionSection)(translate, versions, activeVersion));
40
+ }
41
+ if (menuItems.length && sidebarItems.length) {
42
+ menuItems.push(MENU_SEPARATOR);
43
+ }
44
+ menuItems.push(...sidebarItems);
35
45
  }
36
- if (menuItems.length && sidebarItems.length) {
37
- menuItems.push(MENU_SEPARATOR);
38
- }
39
- menuItems.push(...sidebarItems);
40
- }
41
- else if (menuType === common_1.MobileMenuType.PRODUCT) {
42
- menuItems.push(...productNavItems);
43
- if (menuItems.length && baseNavItems.length) {
44
- menuItems.push(MENU_SEPARATOR);
45
- }
46
- if (baseNavItems.length) {
47
- menuItems.push(...baseNavItems);
46
+ else if (menuType === common_1.MobileMenuType.PRODUCT) {
47
+ menuItems.push(...productNavItems);
48
+ if (menuItems.length && baseNavItems.length) {
49
+ menuItems.push(MENU_SEPARATOR);
50
+ }
51
+ if (baseNavItems.length) {
52
+ menuItems.push(...baseNavItems);
53
+ }
48
54
  }
49
- }
50
- else if (menuType === common_1.MobileMenuType.MAIN_MENU) {
51
- const productMenuItems = Object.values(baseThemeConfig.products || {}).map((product) => ({
52
- label: product.name,
53
- link: product.link,
54
- icon: product.icon,
55
- type: 'link',
56
- }));
57
- if (productMenuItems.length) {
58
- menuItems.push({
59
- type: 'separator',
60
- label: translate('mobileMenu.products', 'Products'),
61
- });
62
- menuItems.push(...productMenuItems);
55
+ else if (menuType === common_1.MobileMenuType.MAIN_MENU) {
56
+ const productMenuItems = Object.values(products || {}).map((product) => ({
57
+ label: product.name,
58
+ link: product.link,
59
+ icon: product.icon,
60
+ type: 'link',
61
+ }));
62
+ if (productMenuItems.length) {
63
+ menuItems.push({
64
+ type: 'separator',
65
+ label: translate('mobileMenu.products', 'Products'),
66
+ });
67
+ menuItems.push(...productMenuItems);
68
+ }
69
+ if (menuItems.length && baseNavItems.length) {
70
+ menuItems.push(MENU_SEPARATOR);
71
+ }
72
+ if (baseNavItems.length) {
73
+ menuItems.push(...baseNavItems);
74
+ }
63
75
  }
64
- if (menuItems.length && baseNavItems.length) {
76
+ const languagesMenu = (0, menu_1.buildLanguagesGroup)(locales, defaultLocale, currentLocale);
77
+ if (menuItems.length && languagesMenu) {
65
78
  menuItems.push(MENU_SEPARATOR);
66
79
  }
67
- if (baseNavItems.length) {
68
- menuItems.push(...baseNavItems);
80
+ if (languagesMenu) {
81
+ menuItems.push(languagesMenu);
69
82
  }
70
- }
71
- const languagesMenu = (0, menu_1.buildLanguagesGroup)(locales, defaultLocale, currentLocale);
72
- if (menuItems.length && languagesMenu) {
73
- menuItems.push(MENU_SEPARATOR);
74
- }
75
- if (languagesMenu) {
76
- menuItems.push(languagesMenu);
77
- }
83
+ return [
84
+ ...(navigationTabsSelect ? [navigationTabsSelect] : []),
85
+ ...(0, menu_1.mapNavbarItems)(menuItems, defaultLocale, currentLocale, locales, location),
86
+ ];
87
+ }, [
88
+ menuType,
89
+ navigationTabs,
90
+ activeVersion,
91
+ versions,
92
+ sidebarItems,
93
+ productNavItems,
94
+ baseNavItems,
95
+ products,
96
+ translate,
97
+ locales,
98
+ defaultLocale,
99
+ currentLocale,
100
+ location,
101
+ ]);
78
102
  return {
79
- items: (0, menu_1.mapNavbarItems)(menuItems, defaultLocale, currentLocale, locales, location),
103
+ items,
80
104
  popDrilldownState,
81
105
  pushDrilldownState,
82
106
  backLink,
@@ -7,31 +7,36 @@ const use_theme_hooks_1 = require("../use-theme-hooks");
7
7
  const use_theme_config_1 = require("../use-theme-config");
8
8
  const common_1 = require("../../constants/common");
9
9
  const useMobileMenuLevels = () => {
10
- var _a, _b;
11
- const { useTranslate, useCurrentProduct, usePageVersions, useSidebarItems } = (0, use_theme_hooks_1.useThemeHooks)();
10
+ var _a, _b, _c;
11
+ const { useTranslate, useCurrentProduct, usePageVersions, useSidebarItems, useNavigationTabs } = (0, use_theme_hooks_1.useThemeHooks)();
12
12
  const { versions = [] } = usePageVersions() || {};
13
13
  const activeVersion = versions.find((version) => version === null || version === void 0 ? void 0 : version.active);
14
14
  const { currentItems: sidebarItems } = useSidebarItems(activeVersion);
15
+ const navigationTabs = useNavigationTabs();
15
16
  const { translate } = useTranslate();
16
17
  const currentProduct = useCurrentProduct();
17
18
  const productThemeConfig = (0, use_theme_config_1.useThemeConfig)();
19
+ const baseThemeConfig = (0, use_theme_config_1.useThemeConfig)(false);
18
20
  const location = (0, react_router_1.useLocation)();
19
21
  const hasProductNavbarOverride = (_a = currentProduct === null || currentProduct === void 0 ? void 0 : currentProduct.configOverride) === null || _a === void 0 ? void 0 : _a.navbar;
20
22
  const productNavItems = (hasProductNavbarOverride ? ((_b = productThemeConfig.navbar) === null || _b === void 0 ? void 0 : _b.items) || [] : []);
23
+ const hasMainMenuItems = Object.values(baseThemeConfig.products || {}).length > 0 ||
24
+ (((_c = baseThemeConfig.navbar) === null || _c === void 0 ? void 0 : _c.items) || []).length > 0;
21
25
  const menuLevels = (0, react_1.useMemo)(() => {
22
- const menuLevels = [
23
- {
26
+ const menuLevels = [];
27
+ if (hasMainMenuItems) {
28
+ menuLevels.push({
24
29
  label: translate('mobileMenu.mainMenu', 'Main menu'),
25
30
  type: common_1.MobileMenuType.MAIN_MENU,
26
- },
27
- ];
31
+ });
32
+ }
28
33
  if (currentProduct && productNavItems.length) {
29
34
  menuLevels.push({
30
35
  label: currentProduct.name,
31
36
  type: common_1.MobileMenuType.PRODUCT,
32
37
  });
33
38
  }
34
- if (sidebarItems.length || activeVersion) {
39
+ if (sidebarItems.length || activeVersion || (navigationTabs === null || navigationTabs === void 0 ? void 0 : navigationTabs.tabs.length)) {
35
40
  menuLevels.push({
36
41
  label: translate('mobileMenu.previous', 'Previous'),
37
42
  type: common_1.MobileMenuType.PAGE,
@@ -0,0 +1,12 @@
1
+ import type { RefObject } from 'react';
2
+ import type { ConsentCategory, ConsentCategoryId, UseConsentResult } from '../types/consent';
3
+ export type ConsentDraft = Record<Exclude<ConsentCategoryId, 'necessary'>, boolean>;
4
+ export type UseConsentDialogResult = {
5
+ draft: ConsentDraft;
6
+ setCategory: (id: keyof ConsentDraft, value: boolean) => void;
7
+ dialogRef: RefObject<HTMLDivElement | null>;
8
+ close: () => void;
9
+ save: () => void;
10
+ categories: readonly ConsentCategory[];
11
+ };
12
+ export declare function useConsentDialog(consent: UseConsentResult): UseConsentDialogResult;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useConsentDialog = useConsentDialog;
4
+ const react_1 = require("react");
5
+ const consent_1 = require("../constants/consent");
6
+ const use_focus_trap_1 = require("./use-focus-trap");
7
+ function useConsentDialog(consent) {
8
+ const [draft, setDraft] = (0, react_1.useState)(() => { var _a, _b; var _c, _d; return ({
9
+ analytics: (_c = (_a = consent.state) === null || _a === void 0 ? void 0 : _a.analytics) !== null && _c !== void 0 ? _c : consent.mode === 'opt-out',
10
+ marketing: ((_d = (_b = consent.state) === null || _b === void 0 ? void 0 : _b.marketing) !== null && _d !== void 0 ? _d : consent.mode === 'opt-out') && !consent.gpc,
11
+ }); });
12
+ const dialogRef = (0, react_1.useRef)(null);
13
+ const close = consent.closeDialog;
14
+ const closeRef = (0, react_1.useRef)(close);
15
+ closeRef.current = close;
16
+ (0, react_1.useEffect)(() => {
17
+ const previous = document.activeElement;
18
+ const onKeyDown = (event) => {
19
+ if (event.key === 'Escape')
20
+ closeRef.current();
21
+ };
22
+ document.addEventListener('keydown', onKeyDown);
23
+ return () => {
24
+ var _a;
25
+ document.removeEventListener('keydown', onKeyDown);
26
+ (_a = previous === null || previous === void 0 ? void 0 : previous.focus) === null || _a === void 0 ? void 0 : _a.call(previous);
27
+ };
28
+ }, []);
29
+ (0, use_focus_trap_1.useFocusTrap)(dialogRef);
30
+ const setCategory = (id, value) => {
31
+ setDraft((current) => (Object.assign(Object.assign({}, current), { [id]: value })));
32
+ };
33
+ const save = () => consent.save(draft);
34
+ return { draft, setCategory, dialogRef, close, save, categories: consent_1.CONSENT_CATEGORIES };
35
+ }
36
+ //# sourceMappingURL=use-consent-dialog.js.map
@@ -0,0 +1 @@
1
+ export declare function useConsentTelemetry(): void;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useConsentTelemetry = useConsentTelemetry;
4
+ const react_1 = require("react");
5
+ const use_theme_hooks_1 = require("./use-theme-hooks");
6
+ const get_base_data_attributes_1 = require("../utils/telemetry/get-base-data-attributes");
7
+ function isRealmOwned(runtime) {
8
+ return runtime.region.source !== 'provider';
9
+ }
10
+ function getConsentRuntime() {
11
+ var _a;
12
+ if (typeof window === 'undefined')
13
+ return undefined;
14
+ return (_a = window.redocly) === null || _a === void 0 ? void 0 : _a.consent;
15
+ }
16
+ // Sends one consent.changed event per visitor choice in the modes Realm owns.
17
+ function useConsentTelemetry() {
18
+ const { useTelemetry } = (0, use_theme_hooks_1.useThemeHooks)();
19
+ const telemetry = useTelemetry();
20
+ const telemetryRef = (0, react_1.useRef)(telemetry);
21
+ telemetryRef.current = telemetry;
22
+ (0, react_1.useEffect)(() => {
23
+ const found = getConsentRuntime();
24
+ const runtime = found && isRealmOwned(found) ? found : null;
25
+ if (!runtime)
26
+ return;
27
+ return runtime.on('change', (state) => {
28
+ const choice = state.analytics && state.marketing
29
+ ? 'accept'
30
+ : !state.analytics && !state.marketing
31
+ ? 'reject'
32
+ : 'partial';
33
+ const { origin, pathname, search, hash } = window.location;
34
+ const uri = `${origin}${pathname}${search}${hash}`;
35
+ telemetryRef.current.sendConsentChangedMessage([
36
+ Object.assign(Object.assign({}, (0, get_base_data_attributes_1.getBaseDataAttributes)('consent', 'consent')), { choice, mode: runtime.mode, configuredMode: runtime.configuredMode, regionSource: runtime.region.source, gpc: runtime.gpc }),
37
+ (0, get_base_data_attributes_1.getBaseDataAttributes)(uri, 'page', uri),
38
+ ]);
39
+ });
40
+ }, []);
41
+ }
42
+ //# sourceMappingURL=use-consent-telemetry.js.map
@@ -0,0 +1,2 @@
1
+ import type { RefObject } from 'react';
2
+ export declare function useScrollItemIntoView(listRef: RefObject<HTMLElement | null>, activeIndex: number): void;