@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
@@ -151,7 +151,7 @@ const CatalogDescription = styled_components_1.default.p `
151
151
  const CatalogPageWrapper = styled_components_1.default.div `
152
152
  --sidebar-width: var(--catalog-sidebar-width);
153
153
 
154
- height: calc(100vh - var(--navbar-height) - var(--banner-height));
154
+ height: calc(100vh - var(--navbar-offset));
155
155
  display: flex;
156
156
  flex-direction: column;
157
157
  overflow: hidden;
@@ -142,10 +142,10 @@ function CatalogEntityHistorySidebar({ entityKey, revision, version, className,
142
142
  }
143
143
  const SidebarOverlay = styled_components_1.default.div `
144
144
  position: fixed;
145
- top: calc(var(--navbar-height) + var(--banner-height));
145
+ top: var(--navbar-offset);
146
146
  left: 0;
147
147
  width: var(--sidebar-width);
148
- height: calc(100vh - var(--navbar-height) - var(--banner-height));
148
+ height: calc(100vh - var(--navbar-offset));
149
149
  padding: var(--catalog-history-sidebar-padding);
150
150
  background-color: var(--catalog-history-sidebar-bg-color);
151
151
  border-right: 1px solid var(--catalog-history-sidebar-border-color);
@@ -98,7 +98,7 @@ const SplitViewWrapper = styled_components_1.default.div `
98
98
  const SchemaSampleWrapper = styled_components_1.default.div `
99
99
  flex: 1;
100
100
  position: sticky;
101
- top: calc(var(--navbar-height) + var(--banner-height) + var(--spacing-md));
101
+ top: calc(var(--navbar-offset) + var(--spacing-md));
102
102
  align-self: flex-start;
103
103
  padding-top: var(--spacing-sm);
104
104
  `;
@@ -14,7 +14,7 @@ function CatalogMobileFiltersPanel({ setMobileFiltersPanelOpen, filterContent, }
14
14
  }
15
15
  const CatalogMobileFiltersPanelWrapper = styled_components_1.default.div `
16
16
  width: 100%;
17
- max-height: calc(100vh - var(--navbar-height) - var(--banner-height));
17
+ max-height: calc(100vh - var(--navbar-offset));
18
18
  overflow-y: auto;
19
19
  background: var(--sidebar-bg-color);
20
20
  display: flex;
@@ -15,10 +15,10 @@ function CatalogMobileFiltersPanelOverlay({ setMobileFiltersPanelOpen, filterCon
15
15
  const CatalogMobileFiltersPanelOverlayWrapper = styled_components_1.default.div `
16
16
  display: none;
17
17
  position: fixed;
18
- top: calc(var(--navbar-height) + var(--banner-height));
18
+ top: var(--navbar-offset);
19
19
  left: 0;
20
20
  width: 100%;
21
- height: calc(100vh - var(--navbar-height) - var(--banner-height));
21
+ height: calc(100vh - var(--navbar-offset));
22
22
  z-index: 3;
23
23
  background: var(--bg-color);
24
24
  flex-direction: column;
@@ -11,8 +11,7 @@ const CopyButton_1 = require("../../components/Buttons/CopyButton");
11
11
  const Tooltip_1 = require("../../components/Tooltip/Tooltip");
12
12
  const hooks_1 = require("../../core/hooks");
13
13
  const DeselectIcon_1 = require("../../icons/DeselectIcon/DeselectIcon");
14
- const MaximizeIcon_1 = require("../../icons/MaximizeIcon/MaximizeIcon");
15
- const MinimizeIcon_1 = require("../../icons/MinimizeIcon/MinimizeIcon");
14
+ const ExpandCollapseIcon_1 = require("../../icons/ExpandCollapseIcon/ExpandCollapseIcon");
16
15
  const SelectIcon_1 = require("../../icons/SelectIcon/SelectIcon");
17
16
  const WarningSquareIcon_1 = require("../../icons/WarningSquareIcon/WarningSquareIcon");
18
17
  const Button_1 = require("../../components/Button/Button");
@@ -40,9 +39,8 @@ function CodeBlockControls({ children, className, title, controls, tabs, dropdow
40
39
  dropdown && react_1.default.createElement(CodeBlockDropdown_1.CodeBlockDropdown, Object.assign({}, dropdown)),
41
40
  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: ((_b = report.props) === null || _b === void 0 ? void 0 : _b.tooltip) ||
42
41
  translate('codeSnippet.report.tooltipText', 'Report a problem'), placement: "top", arrowPosition: "right" }, react_1.default.createElement(ControlButton, { 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", onClick: (_c = report.props) === null || _c === void 0 ? void 0 : _c.onClick }, controlsType !== 'icon' && (((_d = report.props) === null || _d === void 0 ? void 0 : _d.buttonText) || 'Report')))) : null,
43
- expand && !((_e = codeSnippet === null || codeSnippet === void 0 ? void 0 : codeSnippet.expand) === null || _e === void 0 ? void 0 : _e.hide) ? (react_1.default.createElement(Tooltip_1.Tooltip, { tip: ((_f = expand.props) === null || _f === void 0 ? void 0 : _f.tooltip) || translate('codeSnippet.expand.tooltipText', 'Expand all'), placement: "top", arrowPosition: "right" }, 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,
44
- collapse && !((_g = codeSnippet === null || codeSnippet === void 0 ? void 0 : codeSnippet.collapse) === null || _g === void 0 ? void 0 : _g.hide) ? (react_1.default.createElement(Tooltip_1.Tooltip, { tip: ((_h = collapse.props) === null || _h === void 0 ? void 0 : _h.tooltip) ||
45
- translate('codeSnippet.collapse.tooltipText', 'Collapse all'), placement: "top", arrowPosition: "right" }, 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' && ((collapse === null || collapse === void 0 ? void 0 : collapse.label) || 'Collapse all')))) : null,
42
+ expand && !((_e = codeSnippet === null || codeSnippet === void 0 ? void 0 : codeSnippet.expand) === null || _e === void 0 ? void 0 : _e.hide) ? (react_1.default.createElement(Tooltip_1.Tooltip, { tip: ((_f = expand.props) === null || _f === void 0 ? void 0 : _f.tooltip) || translate('codeSnippet.expand.tooltipText', 'Expand all'), placement: "top", arrowPosition: "right" }, react_1.default.createElement(ControlButton, { variant: "text", size: "small", "data-testid": "expand-all", icon: controlsType === 'icon' ? react_1.default.createElement(ExpandCollapseIcon_1.ExpandCollapseIcon, 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')))) : collapse && !((_g = codeSnippet === null || codeSnippet === void 0 ? void 0 : codeSnippet.collapse) === null || _g === void 0 ? void 0 : _g.hide) ? (react_1.default.createElement(Tooltip_1.Tooltip, { tip: ((_h = collapse.props) === null || _h === void 0 ? void 0 : _h.tooltip) ||
43
+ translate('codeSnippet.collapse.tooltipText', 'Collapse all'), placement: "top", arrowPosition: "right" }, react_1.default.createElement(ControlButton, { variant: "text", size: "small", "data-testid": "collapse-all", icon: controlsType === 'icon' ? react_1.default.createElement(ExpandCollapseIcon_1.ExpandCollapseIcon, { $collapse: true }) : undefined, onClick: collapse === null || collapse === void 0 ? void 0 : collapse.onClick, "aria-label": "Collapse all" }, controlsType !== 'icon' && ((collapse === null || collapse === void 0 ? void 0 : collapse.label) || 'Collapse all')))) : null,
46
44
  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, "aria-label": "Select all" }, controlsType !== 'icon' && (select === null || select === void 0 ? void 0 : select.label) ? select.label : 'Select all')) : null,
47
45
  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, "aria-label": "Clear all" }, controlsType !== 'icon' && (deselect === null || deselect === void 0 ? void 0 : deselect.label) ? deselect.label : 'Clear all')) : null,
48
46
  copy && !((_j = codeSnippet === null || codeSnippet === void 0 ? void 0 : codeSnippet.copy) === null || _j === void 0 ? void 0 : _j.hide) ? (react_1.default.createElement(Tooltip_1.Tooltip, { tip: translate('codeSnippet.copy.tooltipText', 'Copy to clipboard'), placement: "top", arrowPosition: "right" },
@@ -0,0 +1,2 @@
1
+ import type { JSX } from 'react';
2
+ export declare function Consent(): JSX.Element;
@@ -0,0 +1,17 @@
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.Consent = Consent;
7
+ const react_1 = __importDefault(require("react"));
8
+ const ConsentBanner_1 = require("../../components/Consent/ConsentBanner");
9
+ const ConsentDialog_1 = require("../../components/Consent/ConsentDialog");
10
+ const hooks_1 = require("../../core/hooks");
11
+ function Consent() {
12
+ (0, hooks_1.useConsentTelemetry)();
13
+ return (react_1.default.createElement(react_1.default.Fragment, null,
14
+ react_1.default.createElement(ConsentBanner_1.ConsentBanner, null),
15
+ react_1.default.createElement(ConsentDialog_1.ConsentDialog, null)));
16
+ }
17
+ //# sourceMappingURL=Consent.js.map
@@ -0,0 +1,2 @@
1
+ import type { JSX } from 'react';
2
+ export declare function ConsentBanner(): JSX.Element | null;
@@ -0,0 +1,120 @@
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.ConsentBanner = ConsentBanner;
40
+ const react_1 = __importDefault(require("react"));
41
+ const styled_components_1 = __importStar(require("styled-components"));
42
+ const Button_1 = require("../../components/Button/Button");
43
+ const Link_1 = require("../../components/Link/Link");
44
+ const hooks_1 = require("../../core/hooks");
45
+ function ConsentBanner() {
46
+ var _a;
47
+ const { useConsent, useTranslate } = (0, hooks_1.useThemeHooks)();
48
+ const consent = useConsent();
49
+ const { translate } = useTranslate();
50
+ if (!consent.enabled || consent.mode !== 'opt-in' || consent.decided || consent.isDialogOpen) {
51
+ return null;
52
+ }
53
+ const title = translate('consent.title', 'We value your privacy');
54
+ return (react_1.default.createElement(BannerWrapper, { "data-component-name": "Consent/ConsentBanner", role: "region", "aria-label": title },
55
+ react_1.default.createElement(Title, null, title),
56
+ react_1.default.createElement(Message, null,
57
+ translate('consent.message', 'By selecting "Accept all cookies", you agree to the use of cookies to improve site navigation, understand how our site is used, and support our marketing efforts. Select "Customize" to choose which types of cookies you allow.'),
58
+ ' ',
59
+ ((_a = consent.config) === null || _a === void 0 ? void 0 : _a.privacyPolicyUrl) ? (react_1.default.createElement(Link_1.Link, { to: consent.config.privacyPolicyUrl, external: true }, translate('consent.privacyPolicy', 'Privacy policy'))) : null),
60
+ react_1.default.createElement(Actions, null,
61
+ react_1.default.createElement(MainActions, null,
62
+ react_1.default.createElement(Button_1.Button, { variant: "outlined", onClick: consent.reject }, translate('consent.rejectAll', 'Reject all')),
63
+ react_1.default.createElement(Button_1.Button, { variant: "primary", onClick: consent.accept }, translate('consent.acceptAllCookies', 'Accept all cookies'))),
64
+ react_1.default.createElement(Button_1.Button, { variant: "text", onClick: consent.openDialog }, translate('consent.customize', 'Customize')))));
65
+ }
66
+ const slideUp = (0, styled_components_1.keyframes) `
67
+ from {
68
+ opacity: 0;
69
+ transform: translateY(16px);
70
+ }
71
+ to {
72
+ opacity: 1;
73
+ transform: translateY(0);
74
+ }
75
+ `;
76
+ const BannerWrapper = styled_components_1.default.div `
77
+ position: fixed;
78
+ left: var(--consent-banner-offset);
79
+ bottom: var(--consent-banner-offset);
80
+ z-index: var(--consent-banner-z-index);
81
+ display: flex;
82
+ flex-direction: column;
83
+ gap: var(--consent-banner-gap);
84
+ width: var(--consent-banner-width);
85
+ max-width: calc(100vw - 2 * var(--consent-banner-offset));
86
+ padding: var(--consent-banner-padding);
87
+ border: 1px solid var(--consent-banner-border-color);
88
+ border-radius: var(--consent-banner-border-radius);
89
+ background: var(--consent-banner-bg-color);
90
+ color: var(--consent-banner-text-color);
91
+ box-shadow: var(--consent-banner-box-shadow);
92
+ font-family: var(--font-family-base);
93
+
94
+ @media (prefers-reduced-motion: no-preference) {
95
+ animation: ${slideUp} 240ms ease-out;
96
+ }
97
+ `;
98
+ const Title = styled_components_1.default.h2 `
99
+ margin: 0;
100
+ font-size: var(--consent-banner-title-font-size);
101
+ font-weight: var(--font-weight-bold);
102
+ `;
103
+ const Message = styled_components_1.default.p `
104
+ margin: 0;
105
+ color: var(--text-color-secondary);
106
+ font-size: var(--consent-banner-font-size);
107
+ `;
108
+ const Actions = styled_components_1.default.div `
109
+ display: flex;
110
+ flex-wrap: wrap;
111
+ gap: var(--consent-banner-gap);
112
+ align-items: center;
113
+ justify-content: space-between;
114
+ `;
115
+ const MainActions = styled_components_1.default.div `
116
+ display: flex;
117
+ flex-wrap: wrap;
118
+ gap: var(--consent-banner-gap);
119
+ `;
120
+ //# sourceMappingURL=ConsentBanner.js.map
@@ -0,0 +1,2 @@
1
+ import type { JSX } from 'react';
2
+ export declare function ConsentDialog(): JSX.Element | null;
@@ -0,0 +1,128 @@
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.ConsentDialog = ConsentDialog;
7
+ const react_1 = __importDefault(require("react"));
8
+ const styled_components_1 = __importDefault(require("styled-components"));
9
+ const Button_1 = require("../../components/Button/Button");
10
+ const Link_1 = require("../../components/Link/Link");
11
+ const Portal_1 = require("../../components/Portal/Portal");
12
+ const Switch_1 = require("../../components/Switch/Switch");
13
+ const hooks_1 = require("../../core/hooks");
14
+ const CloseIcon_1 = require("../../icons/CloseIcon/CloseIcon");
15
+ const noop = () => { };
16
+ function ConsentDialog() {
17
+ const { useConsent } = (0, hooks_1.useThemeHooks)();
18
+ const consent = useConsent();
19
+ if (!consent.enabled || !consent.isDialogOpen) {
20
+ return null;
21
+ }
22
+ return react_1.default.createElement(ConsentDialogContent, { consent: consent });
23
+ }
24
+ function ConsentDialogContent({ consent }) {
25
+ var _a;
26
+ const { useTranslate } = (0, hooks_1.useThemeHooks)();
27
+ const { translate } = useTranslate();
28
+ const { draft, setCategory, dialogRef, close, save, categories } = (0, hooks_1.useConsentDialog)(consent);
29
+ return (react_1.default.createElement(Portal_1.Portal, null,
30
+ react_1.default.createElement(Overlay, { className: "scroll-lock", "data-component-name": "Consent/ConsentDialog", onMouseDown: (event) => {
31
+ if (event.target === event.currentTarget)
32
+ close();
33
+ } },
34
+ react_1.default.createElement(Dialog, { ref: dialogRef, role: "dialog", "aria-modal": "true", "aria-labelledby": "redocly-consent-dialog-title", tabIndex: -1 },
35
+ react_1.default.createElement(TitleRow, null,
36
+ react_1.default.createElement(Title, { id: "redocly-consent-dialog-title" }, translate('consent.dialog.title', 'Cookie preferences')),
37
+ react_1.default.createElement(Button_1.Button, { variant: "ghost", size: "small", icon: react_1.default.createElement(CloseIcon_1.CloseIcon, null), "aria-label": translate('consent.dialog.close', 'Close'), onClick: close })),
38
+ react_1.default.createElement(Description, null,
39
+ translate('consent.dialog.description', 'Choose which cookies this site may use. You can change your choice at any time.'),
40
+ ' ',
41
+ ((_a = consent.config) === null || _a === void 0 ? void 0 : _a.privacyPolicyUrl) ? (react_1.default.createElement(Link_1.Link, { to: consent.config.privacyPolicyUrl, external: true }, translate('consent.privacyPolicy', 'Privacy policy'))) : null),
42
+ categories.map((category) => {
43
+ const gpcLocked = category.id === 'marketing' && consent.gpc;
44
+ return (react_1.default.createElement(Row, { key: category.id },
45
+ react_1.default.createElement(RowText, null,
46
+ react_1.default.createElement(RowTitle, null, translate(category.titleTranslationKey, category.titleDefault)),
47
+ react_1.default.createElement(RowDescription, null, translate(category.descriptionTranslationKey, category.descriptionDefault)),
48
+ gpcLocked ? (react_1.default.createElement(GpcNotice, null, translate('consent.gpcNotice', 'Your browser asked us not to share your data, so this stays off.'))) : null),
49
+ category.locked ? (react_1.default.createElement(SwitchGroup, { role: "group", "aria-label": translate('consent.alwaysOn', 'Always on') },
50
+ react_1.default.createElement(Switch_1.Switch, { value: true, disabled: true, onChange: noop }))) : gpcLocked ? (react_1.default.createElement(SwitchGroup, { role: "group", "aria-label": translate('consent.alwaysOff', 'Always off') },
51
+ react_1.default.createElement(Switch_1.Switch, { value: false, disabled: true, onChange: noop }))) : (react_1.default.createElement(Switch_1.Switch, { value: draft[category.id], onChange: (value) => setCategory(category.id, value) }))));
52
+ }),
53
+ react_1.default.createElement(Actions, null,
54
+ react_1.default.createElement(Button_1.Button, { variant: "outlined", onClick: consent.reject }, translate('consent.rejectAll', 'Reject all')),
55
+ react_1.default.createElement(Spacer, null),
56
+ react_1.default.createElement(Button_1.Button, { variant: "outlined", onClick: consent.accept }, translate('consent.acceptAll', 'Accept all')),
57
+ react_1.default.createElement(Button_1.Button, { variant: "primary", onClick: save }, translate('consent.savePreferences', 'Save preferences')))))));
58
+ }
59
+ const Overlay = styled_components_1.default.div `
60
+ position: fixed;
61
+ inset: 0;
62
+ z-index: var(--z-index-overlay);
63
+ display: flex;
64
+ align-items: center;
65
+ justify-content: center;
66
+ background: var(--bg-color-modal-overlay);
67
+ font-family: var(--font-family-base);
68
+ `;
69
+ const Dialog = styled_components_1.default.div `
70
+ width: var(--consent-dialog-width);
71
+ max-width: var(--consent-dialog-max-width);
72
+ padding: var(--consent-dialog-padding);
73
+ border-radius: var(--consent-dialog-border-radius);
74
+ background: var(--consent-dialog-bg-color);
75
+ box-shadow: var(--consent-dialog-box-shadow);
76
+ `;
77
+ const TitleRow = styled_components_1.default.div `
78
+ display: flex;
79
+ gap: var(--spacing-xs);
80
+ align-items: flex-start;
81
+ justify-content: space-between;
82
+ `;
83
+ const Title = styled_components_1.default.h2 `
84
+ margin: 0 0 var(--spacing-xs);
85
+ font-size: var(--font-size-lg);
86
+ `;
87
+ const Description = styled_components_1.default.p `
88
+ margin: 0 0 var(--spacing-base);
89
+ color: var(--consent-dialog-description-color);
90
+ font-size: var(--font-size-sm);
91
+ `;
92
+ const Row = styled_components_1.default.div `
93
+ display: flex;
94
+ gap: var(--spacing-base);
95
+ align-items: flex-start;
96
+ padding: var(--spacing-sm) 0;
97
+ border-top: 1px solid var(--consent-dialog-row-border-color);
98
+ `;
99
+ const RowText = styled_components_1.default.div `
100
+ flex: 1;
101
+ `;
102
+ const RowTitle = styled_components_1.default.div `
103
+ font-size: var(--font-size-base);
104
+ font-weight: var(--font-weight-bold);
105
+ `;
106
+ const RowDescription = styled_components_1.default.div `
107
+ color: var(--consent-dialog-description-color);
108
+ font-size: var(--font-size-sm);
109
+ `;
110
+ const GpcNotice = styled_components_1.default.div `
111
+ color: var(--consent-dialog-description-color);
112
+ font-size: var(--font-size-sm);
113
+ `;
114
+ const SwitchGroup = styled_components_1.default.div `
115
+ flex: none;
116
+ `;
117
+ const Actions = styled_components_1.default.div `
118
+ display: flex;
119
+ flex-wrap: wrap;
120
+ gap: var(--spacing-xs);
121
+ margin-top: var(--spacing-base);
122
+ padding-top: var(--spacing-base);
123
+ border-top: 1px solid var(--consent-dialog-row-border-color);
124
+ `;
125
+ const Spacer = styled_components_1.default.span `
126
+ flex: 1;
127
+ `;
128
+ //# sourceMappingURL=ConsentDialog.js.map
@@ -0,0 +1,2 @@
1
+ import type { JSX } from 'react';
2
+ export declare function ConsentSettingsLink(): JSX.Element | null;
@@ -0,0 +1,35 @@
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.ConsentSettingsLink = ConsentSettingsLink;
7
+ const react_1 = __importDefault(require("react"));
8
+ const styled_components_1 = __importDefault(require("styled-components"));
9
+ const Button_1 = require("../../components/Button/Button");
10
+ const hooks_1 = require("../../core/hooks");
11
+ const utils_1 = require("../../core/utils");
12
+ function ConsentSettingsLink() {
13
+ const { useConsent, useTranslate } = (0, hooks_1.useThemeHooks)();
14
+ const { consent: consentConfig, footer } = (0, hooks_1.useThemeConfig)() || {};
15
+ const consent = useConsent();
16
+ const { translate } = useTranslate();
17
+ if (!consent.enabled || (0, utils_1.resolveSettingsLinkPlacement)(consentConfig, footer) !== 'footer') {
18
+ return null;
19
+ }
20
+ return (react_1.default.createElement(SettingsLinkButton, { variant: "link", size: "small", "data-component-name": "Consent/ConsentSettingsLink", onClick: consent.openDialog }, translate('consent.settingsLink', 'Cookie preferences')));
21
+ }
22
+ const SettingsLinkButton = (0, styled_components_1.default)(Button_1.Button) `
23
+ margin: var(--footer-link-padding-vertical) 0 var(--footer-link-padding-vertical) var(--spacing-sm);
24
+ padding: 0;
25
+ color: var(--footer-link-text-color);
26
+ font: inherit;
27
+ line-height: inherit;
28
+
29
+ &:hover,
30
+ &:focus-visible {
31
+ color: var(--footer-link-color-hover);
32
+ background: none;
33
+ }
34
+ `;
35
+ //# sourceMappingURL=ConsentSettingsLink.js.map
@@ -0,0 +1 @@
1
+ export declare const consent: import("styled-components").RuleSet<object>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.consent = void 0;
4
+ const styled_components_1 = require("styled-components");
5
+ exports.consent = (0, styled_components_1.css) `
6
+ /**
7
+ * @tokens Consent
8
+ */
9
+ --consent-banner-width: 380px;
10
+ --consent-banner-offset: var(--spacing-base); // @presenter Spacing
11
+ --consent-banner-bg-color: var(--bg-color); // @presenter Color
12
+ --consent-banner-text-color: var(--text-color-primary); // @presenter Color
13
+ --consent-banner-border-color: var(--border-color-primary); // @presenter Color
14
+ --consent-banner-border-radius: var(--border-radius-lg);
15
+ --consent-banner-box-shadow: var(--bg-raised-shadow);
16
+ --consent-banner-padding: var(--spacing-base); // @presenter Spacing
17
+ --consent-banner-gap: var(--spacing-sm); // @presenter Spacing
18
+ --consent-banner-title-font-size: var(--font-size-base);
19
+ --consent-banner-font-size: var(--font-size-sm);
20
+ --consent-banner-z-index: var(--z-index-overlay);
21
+
22
+ --consent-dialog-width: 560px;
23
+ --consent-dialog-max-width: calc(100vw - 2 * var(--spacing-base));
24
+ --consent-dialog-padding: var(--spacing-lg); // @presenter Spacing
25
+ --consent-dialog-border-radius: var(--border-radius-lg);
26
+ --consent-dialog-bg-color: var(--modal-bg-color); // @presenter Color
27
+ --consent-dialog-box-shadow: var(--modal-box-shadow);
28
+ --consent-dialog-row-border-color: var(--border-color-primary); // @presenter Color
29
+ --consent-dialog-description-color: var(--text-color-secondary); // @presenter Color
30
+ `;
31
+ //# sourceMappingURL=variables.js.map
@@ -42,6 +42,7 @@ const ChevronDownIcon_1 = require("../../icons/ChevronDownIcon/ChevronDownIcon")
42
42
  const ChevronUpIcon_1 = require("../../icons/ChevronUpIcon/ChevronUpIcon");
43
43
  const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? react_1.useLayoutEffect : react_1.useEffect;
44
44
  exports.Dropdown = (0, react_1.forwardRef)(({ children, className, active, trigger, triggerEvent = 'click', closeOnClick = true, withArrow, dataAttributes, placement, alignment, portalled = false, onClick, onClose, onOpen, }, ref) => {
45
+ var _a, _b;
45
46
  const dropdownRef = (0, react_1.useRef)(null);
46
47
  const menuRef = (0, react_1.useRef)(null);
47
48
  const [isOpen, setIsOpen] = (0, hooks_1.useControlledState)(false, active);
@@ -120,7 +121,8 @@ exports.Dropdown = (0, react_1.forwardRef)(({ children, className, active, trigg
120
121
  (0, hooks_1.useOutsideClick)(portalled ? [wrapperRef, menuRef] : wrapperRef, handleClose);
121
122
  const menuContent = typeof children === 'function' ? children({ close: handleClose, isOpen }) : children;
122
123
  const triggerChild = react_1.default.Children.only(trigger);
123
- const dropdownTrigger = (0, react_1.cloneElement)(triggerChild, Object.assign(Object.assign(Object.assign({ onClick: triggerEvent === 'click' ? handleToggle : undefined, 'aria-expanded': isOpen, icon: withArrow ? isOpen ? react_1.default.createElement(ChevronUpIcon_1.ChevronUpIcon, null) : react_1.default.createElement(ChevronDownIcon_1.ChevronDownIcon, null) : undefined }, (withArrow ? { iconPosition: 'right' } : {})), triggerChild.props), { onKeyDown: triggerEvent === 'click' ? handleKeyDown : undefined }));
124
+ const isLinkTrigger = Boolean(((_a = triggerChild.props) === null || _a === void 0 ? void 0 : _a.to) || ((_b = triggerChild.props) === null || _b === void 0 ? void 0 : _b.href));
125
+ const dropdownTrigger = (0, react_1.cloneElement)(triggerChild, Object.assign(Object.assign(Object.assign({ onClick: triggerEvent === 'click' ? handleToggle : undefined, 'aria-haspopup': 'menu', 'aria-expanded': isOpen, icon: withArrow ? isOpen ? react_1.default.createElement(ChevronUpIcon_1.ChevronUpIcon, null) : react_1.default.createElement(ChevronDownIcon_1.ChevronDownIcon, null) : undefined }, (withArrow ? { iconPosition: 'right' } : {})), triggerChild.props), { onKeyDown: triggerEvent === 'click' || !isLinkTrigger ? handleKeyDown : undefined }));
124
126
  const menu = (react_1.default.createElement(ChildrenWrapper, { ref: menuRef, $placement: placement, $alignment: alignment, $isOpen: isOpen, $portalled: portalled, style: portalled ? menuStyle : undefined, onClick: closeOnClick ? handleChildClick : undefined }, menuContent));
125
127
  const portalledMenu = isOpen && typeof document !== 'undefined' ? (0, react_dom_1.createPortal)(menu, document.body) : null;
126
128
  return (react_1.default.createElement(DropdownWrapper, Object.assign({ "data-component-name": "Dropdown/Dropdown", "data-testid": "dropdown" }, dataAttributes, { className: className, ref: wrapperRef, onPointerEnter: triggerEvent === 'hover' ? handleOpen : undefined, onPointerLeave: triggerEvent === 'hover' ? handleClose : undefined, onClick: onClick }),
@@ -11,6 +11,7 @@ const utils_1 = require("../../core/utils");
11
11
  const hooks_1 = require("../../core/hooks");
12
12
  const FooterCopyright_1 = require("../../components/Footer/FooterCopyright");
13
13
  const FooterColumn_1 = require("../../components/Footer/FooterColumn");
14
+ const ConsentSettingsLink_1 = require("../../components/Consent/ConsentSettingsLink");
14
15
  function Footer({ className }) {
15
16
  const { footer } = (0, hooks_1.useThemeConfig)() || {};
16
17
  const { items = [], copyrightText } = footer || {};
@@ -22,7 +23,9 @@ function Footer({ className }) {
22
23
  !!items.length && (react_1.default.createElement(FooterColumnsSection, null, withColumns
23
24
  ? items.map((column, index) => (react_1.default.createElement(FooterColumn_1.FooterColumn, { key: `${column.label}_${index}`, column: column })))
24
25
  : items.map((item, index) => (react_1.default.createElement(FooterItem_1.FooterItem, { key: index, item: item }))))),
25
- react_1.default.createElement(FooterCopyrightWrapper, null, copyrightText && react_1.default.createElement(FooterCopyright_1.FooterCopyright, { copyrightText: copyrightText }))));
26
+ react_1.default.createElement(FooterCopyrightWrapper, null,
27
+ copyrightText && react_1.default.createElement(FooterCopyright_1.FooterCopyright, { copyrightText: copyrightText }),
28
+ react_1.default.createElement(ConsentSettingsLink_1.ConsentSettingsLink, null))));
26
29
  }
27
30
  const FooterCopyrightWrapper = styled_components_1.default.div `
28
31
  display: flex;
@@ -1,9 +1,17 @@
1
1
  import React from 'react';
2
+ export type JsonFold = {
3
+ isExpanded: (path: string, level: number) => boolean;
4
+ setExpanded: (path: string, expanded: boolean) => void;
5
+ };
6
+ type Foldable = [path: string, level: number];
7
+ export declare function isFoldable(value: unknown): value is Record<string, unknown>;
8
+ export declare function collectFoldables(value: unknown, path?: string, level?: number): Foldable[];
2
9
  export declare function JsonValue(props: {
3
10
  value: any;
4
11
  level: number;
12
+ path: string;
5
13
  standalone?: boolean;
6
- defaultExpandLevel: number;
7
- expandAllSignal: boolean | undefined;
14
+ fold: JsonFold;
8
15
  maxStringLength?: number;
9
16
  }): React.ReactNode;
17
+ export {};
@@ -3,30 +3,36 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isFoldable = isFoldable;
7
+ exports.collectFoldables = collectFoldables;
6
8
  exports.JsonValue = JsonValue;
7
9
  const react_1 = __importDefault(require("react"));
8
10
  const styled_components_1 = __importDefault(require("styled-components"));
9
11
  const Button_1 = require("../../components/Button/Button");
10
12
  const ShowMoreToggleButton_1 = require("../../components/Button/ShowMoreToggleButton");
11
13
  const ChevronDownIcon_1 = require("../../icons/ChevronDownIcon/ChevronDownIcon");
14
+ function isFoldable(value) {
15
+ return (typeof value === 'object' &&
16
+ value !== null &&
17
+ Object.values(value).some((item) => item !== undefined));
18
+ }
19
+ function collectFoldables(value, path = '', level = 1) {
20
+ if (!isFoldable(value))
21
+ return [];
22
+ return Object.entries(value).flatMap(([key, child]) => {
23
+ const childPath = `${path}/${key}`;
24
+ return isFoldable(child)
25
+ ? [[childPath, level], ...collectFoldables(child, childPath, level + 1)]
26
+ : [];
27
+ });
28
+ }
12
29
  function JsonValue(props) {
13
- const { standalone, defaultExpandLevel, level, value, expandAllSignal, maxStringLength } = props;
30
+ const { standalone, fold, level, path, value, maxStringLength } = props;
14
31
  const indent = ' '.repeat(level * 2);
15
- const [isExpandedState, setExpanded] = react_1.default.useState(expandAllSignal !== null && expandAllSignal !== void 0 ? expandAllSignal : level < defaultExpandLevel);
16
- const isExpanded = expandAllSignal !== undefined && level > 0 ? expandAllSignal : isExpandedState;
17
- const [prevExpandAllSignal, setPrevExpandAllSignal] = react_1.default.useState(expandAllSignal);
18
- const [prevLevel, setPrevLevel] = react_1.default.useState(level);
19
- if (prevExpandAllSignal !== expandAllSignal || prevLevel !== level) {
20
- setPrevExpandAllSignal(expandAllSignal);
21
- setPrevLevel(level);
22
- if (expandAllSignal !== undefined && !(expandAllSignal === false && level === 0)) {
23
- setExpanded(expandAllSignal);
24
- }
25
- }
32
+ const isExpanded = fold.isExpanded(path, level);
26
33
  const keys = (value && Object.keys(value).filter((key) => value[key] !== undefined)) || []; // filter out undefined properties
27
34
  const valueType = typeof value;
28
- const isPrimitive = (valueType !== 'object' && value !== null) || keys.length === 0;
29
- if (isPrimitive) {
35
+ if (!isFoldable(value)) {
30
36
  const isOversizedString = typeof value === 'string' && maxStringLength !== undefined && value.length > maxStringLength;
31
37
  return (react_1.default.createElement(react_1.default.Fragment, null,
32
38
  standalone ? indent : null,
@@ -36,14 +42,14 @@ function JsonValue(props) {
36
42
  const closingPunctuation = Array.isArray(value) ? ']' : '}';
37
43
  const valueElement = Array.isArray(value)
38
44
  ? value.map((item, index) => (react_1.default.createElement(react_1.default.Fragment, { key: index },
39
- react_1.default.createElement(JsonValue, { value: item, level: level + 1, standalone: true, defaultExpandLevel: defaultExpandLevel, expandAllSignal: expandAllSignal, maxStringLength: maxStringLength }),
45
+ react_1.default.createElement(JsonValue, { value: item, level: level + 1, path: `${path}/${index}`, standalone: true, fold: fold, maxStringLength: maxStringLength }),
40
46
  index < value.length - 1 ? ',\n' : null)))
41
47
  : keys.map((key, index) => (react_1.default.createElement(react_1.default.Fragment, { key: key },
42
- react_1.default.createElement(JsonKeyValue, { name: key, value: value[key], level: level + 1, defaultExpandLevel: defaultExpandLevel, expandAllSignal: expandAllSignal, maxStringLength: maxStringLength }),
48
+ react_1.default.createElement(JsonKeyValue, { name: key, value: value[key], level: level + 1, path: `${path}/${key}`, fold: fold, maxStringLength: maxStringLength }),
43
49
  index < keys.length - 1 ? ',\n' : null)));
44
50
  const openingPunctuationElement = standalone ? (react_1.default.createElement(react_1.default.Fragment, null,
45
51
  indent,
46
- level > 0 ? (react_1.default.createElement(ExpandIcon, { onClick: () => setExpanded((v) => !v), isExpanded: isExpanded })) : null,
52
+ level > 0 ? (react_1.default.createElement(ExpandIcon, { onClick: () => fold.setExpanded(path, !isExpanded), isExpanded: isExpanded })) : null,
47
53
  openingPunctuation,
48
54
  isExpanded ? '\n' : null)) : null;
49
55
  const closingPunctuationElement = standalone ? (react_1.default.createElement(react_1.default.Fragment, null,
@@ -56,32 +62,22 @@ function JsonValue(props) {
56
62
  closingPunctuationElement));
57
63
  }
58
64
  function JsonKeyValue(props) {
59
- const { defaultExpandLevel, level, name, value, expandAllSignal, maxStringLength } = props;
65
+ const { fold, level, name, path, value, maxStringLength } = props;
60
66
  const indent = ' '.repeat(level * 2);
61
- const keys = (value && Object.keys(value).filter((key) => value[key] !== undefined)) || []; // filter out undefined properties
62
- const isCollapsible = typeof value === 'object' && value !== null && keys.length > 0;
63
- const [isExpandedState, setExpanded] = react_1.default.useState(expandAllSignal !== null && expandAllSignal !== void 0 ? expandAllSignal : level < defaultExpandLevel);
64
- const isExpanded = expandAllSignal !== undefined ? expandAllSignal : isExpandedState;
65
- const [prevExpandAllSignal, setPrevExpandAllSignal] = react_1.default.useState(expandAllSignal);
66
- if (prevExpandAllSignal !== expandAllSignal) {
67
- setPrevExpandAllSignal(expandAllSignal);
68
- if (expandAllSignal !== undefined) {
69
- setExpanded(expandAllSignal);
70
- }
71
- }
67
+ const isExpanded = fold.isExpanded(path, level);
72
68
  const openingPunctuation = Array.isArray(value) ? '[' : '{';
73
69
  const closingPunctuation = Array.isArray(value) ? ']' : '}';
74
- const valueElement = isCollapsible ? (react_1.default.createElement(react_1.default.Fragment, null,
70
+ const valueElement = isFoldable(value) ? (react_1.default.createElement(react_1.default.Fragment, null,
75
71
  openingPunctuation,
76
72
  isExpanded ? (react_1.default.createElement(react_1.default.Fragment, null,
77
73
  '\n',
78
- react_1.default.createElement(JsonValue, { value: value, level: level, defaultExpandLevel: defaultExpandLevel, expandAllSignal: expandAllSignal, maxStringLength: maxStringLength }),
74
+ react_1.default.createElement(JsonValue, { value: value, level: level, path: path, fold: fold, maxStringLength: maxStringLength }),
79
75
  '\n')) : (' … '),
80
76
  isExpanded ? indent : null,
81
- closingPunctuation)) : (react_1.default.createElement(JsonValue, { value: value, level: level, defaultExpandLevel: defaultExpandLevel, expandAllSignal: expandAllSignal, maxStringLength: maxStringLength }));
77
+ closingPunctuation)) : (react_1.default.createElement(JsonValue, { value: value, level: level, path: path, fold: fold, maxStringLength: maxStringLength }));
82
78
  return (react_1.default.createElement(react_1.default.Fragment, null,
83
79
  indent,
84
- isCollapsible ? (react_1.default.createElement(ExpandIcon, { onClick: () => setExpanded((v) => !v), isExpanded: isExpanded })) : null,
80
+ isFoldable(value) ? (react_1.default.createElement(ExpandIcon, { onClick: () => fold.setExpanded(path, !isExpanded), isExpanded: isExpanded })) : null,
85
81
  react_1.default.createElement("span", { className: "property token string" }, `"${name}"`),
86
82
  ": ",
87
83
  valueElement));