@redocly/theme 0.69.0-next.8 → 0.69.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/lib/components/Accordion/Accordion.js +5 -1
  2. package/lib/components/Catalog/CatalogEntities.js +1 -0
  3. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.js +5 -3
  4. package/lib/components/Catalog/CatalogViewModeToggle.d.ts +1 -1
  5. package/lib/components/Catalog/CatalogViewModeToggle.js +2 -43
  6. package/lib/components/Filter/FilterInput.js +4 -2
  7. package/lib/components/JsonViewer/Helpers.js +12 -42
  8. package/lib/components/MCP/McpConnectionTabs.js +21 -11
  9. package/lib/components/Markdown/Markdown.js +1 -3
  10. package/lib/components/Markdown/styles/base-table.js +8 -0
  11. package/lib/components/Markdown/variables.js +1 -2
  12. package/lib/components/Panel/Panel.js +5 -1
  13. package/lib/components/Search/FilterFields/SearchFilterFieldSelect.js +22 -32
  14. package/lib/components/Search/SearchAiDialog.js +3 -0
  15. package/lib/components/Search/SearchItem.js +5 -3
  16. package/lib/components/Search/variables.js +1 -0
  17. package/lib/components/Select/Select.js +10 -5
  18. package/lib/components/Sidebar/Sidebar.js +2 -38
  19. package/lib/core/contexts/AccordionGroupContext.d.ts +1 -0
  20. package/lib/core/contexts/AccordionGroupContext.js +6 -0
  21. package/lib/core/contexts/PageActionsContext.d.ts +5 -0
  22. package/lib/core/contexts/PageActionsContext.js +10 -0
  23. package/lib/core/contexts/index.d.ts +2 -0
  24. package/lib/core/contexts/index.js +2 -0
  25. package/lib/core/hooks/code-walkthrough/use-code-walkthrough-controls.js +5 -17
  26. package/lib/core/hooks/code-walkthrough/use-code-walkthrough-steps.js +2 -0
  27. package/lib/core/hooks/menu/use-menu-item-expanded.js +1 -0
  28. package/lib/core/hooks/use-active-heading.js +4 -0
  29. package/lib/core/hooks/use-connect-mcp-button.js +7 -2
  30. package/lib/core/hooks/use-local-state.js +1 -0
  31. package/lib/core/hooks/use-mobile-menu.js +10 -2
  32. package/lib/core/hooks/use-product-picker.js +1 -1
  33. package/lib/core/hooks/use-tabs.js +4 -2
  34. package/lib/core/hooks/use-telemetry-fallback.d.ts +2 -0
  35. package/lib/core/hooks/use-telemetry-fallback.js +2 -0
  36. package/lib/core/styles/global.js +1 -0
  37. package/lib/core/utils/class-names.d.ts +1 -0
  38. package/lib/core/utils/class-names.js +7 -0
  39. package/lib/markdoc/components/Accordion/Accordion.js +6 -6
  40. package/lib/markdoc/components/Accordion/AccordionGroup.d.ts +2 -1
  41. package/lib/markdoc/components/Accordion/AccordionGroup.js +39 -3
  42. package/lib/markdoc/components/Heading/Heading.js +5 -2
  43. package/lib/markdoc/tags/accordion-group.js +3 -0
  44. package/package.json +2 -2
  45. package/src/components/Accordion/Accordion.tsx +7 -3
  46. package/src/components/Catalog/CatalogEntities.tsx +1 -0
  47. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.tsx +6 -4
  48. package/src/components/Catalog/CatalogViewModeToggle.tsx +2 -17
  49. package/src/components/Filter/FilterInput.tsx +5 -3
  50. package/src/components/JsonViewer/Helpers.tsx +13 -9
  51. package/src/components/MCP/McpConnectionTabs.tsx +32 -10
  52. package/src/components/Markdown/Markdown.tsx +1 -3
  53. package/src/components/Markdown/styles/base-table.ts +8 -0
  54. package/src/components/Markdown/variables.ts +1 -2
  55. package/src/components/Panel/Panel.tsx +7 -3
  56. package/src/components/Search/FilterFields/SearchFilterFieldSelect.tsx +32 -40
  57. package/src/components/Search/SearchAiDialog.tsx +3 -0
  58. package/src/components/Search/SearchItem.tsx +6 -1
  59. package/src/components/Search/variables.ts +1 -0
  60. package/src/components/Select/Select.tsx +12 -6
  61. package/src/components/Sidebar/Sidebar.tsx +2 -6
  62. package/src/core/contexts/AccordionGroupContext.tsx +3 -0
  63. package/src/core/contexts/PageActionsContext.tsx +7 -0
  64. package/src/core/contexts/index.ts +2 -0
  65. package/src/core/hooks/__mocks__/use-theme-hooks.ts +2 -0
  66. package/src/core/hooks/code-walkthrough/use-code-walkthrough-controls.ts +6 -20
  67. package/src/core/hooks/code-walkthrough/use-code-walkthrough-steps.ts +2 -0
  68. package/src/core/hooks/menu/use-menu-item-expanded.ts +1 -0
  69. package/src/core/hooks/use-active-heading.ts +4 -0
  70. package/src/core/hooks/use-connect-mcp-button.ts +8 -2
  71. package/src/core/hooks/use-local-state.ts +1 -0
  72. package/src/core/hooks/use-mobile-menu.ts +11 -3
  73. package/src/core/hooks/use-product-picker.ts +2 -2
  74. package/src/core/hooks/use-tabs.ts +4 -2
  75. package/src/core/hooks/use-telemetry-fallback.ts +2 -0
  76. package/src/core/styles/global.ts +1 -0
  77. package/src/core/utils/class-names.ts +8 -0
  78. package/src/markdoc/components/Accordion/Accordion.tsx +8 -2
  79. package/src/markdoc/components/Accordion/AccordionGroup.tsx +9 -2
  80. package/src/markdoc/components/Heading/Heading.tsx +7 -4
  81. package/src/markdoc/tags/accordion-group.ts +3 -0
@@ -599,6 +599,7 @@ const links = css`
599
599
  `;
600
600
 
601
601
 
602
+ // oxlint-disable-next-line theme/css-variable-pattern -- `--schema-labels--text-color` is a documented public variable
602
603
  const apiReferenceDocs = css`
603
604
  /* === ref docs and graphql docs specific === */
604
605
 
@@ -1,5 +1,13 @@
1
1
  const SPACE_DELIMITER = ' ';
2
2
 
3
+ // EasyList/AdGuard ship generic cosmetic rules that hide these exact class tokens on every
4
+ // site; the trailing underscore keeps the class usable without matching the filter lists.
5
+ const ADBLOCK_HIDDEN_CLASS_NAMES = new Set(['product-ad', 'product-ads', 'product-inlist-ad']);
6
+
7
+ export function getSafeClassName(className: string): string {
8
+ return ADBLOCK_HIDDEN_CLASS_NAMES.has(className) ? `${className}_` : className;
9
+ }
10
+
3
11
  export function concatClassNames(...args: Array<string | undefined>): string {
4
12
  return args
5
13
  .map((className) => (className ? className.trim() : className))
@@ -1,10 +1,11 @@
1
- import React from 'react';
1
+ import React, { useContext } from 'react';
2
2
  import styled, { keyframes } from 'styled-components';
3
3
 
4
4
  import type { JSX, PropsWithChildren } from 'react';
5
5
 
6
6
  import { ChevronRightIcon } from '@redocly/theme/icons/ChevronRightIcon/ChevronRightIcon';
7
7
  import { ACCORDION_COMPONENT_NAME } from '@redocly/theme/core/constants';
8
+ import { AccordionGroupContext } from '@redocly/theme/core/contexts';
8
9
 
9
10
  export type AccordionProps = {
10
11
  title: string;
@@ -22,10 +23,13 @@ export function Accordion({
22
23
  'data-source': dataSource,
23
24
  'data-hash': dataHash,
24
25
  }: PropsWithChildren<AccordionProps>): JSX.Element {
26
+ const groupName = useContext(AccordionGroupContext);
27
+
25
28
  return (
26
29
  <AccordionWrapper
27
30
  className={className}
28
31
  open={expanded}
32
+ name={groupName ?? undefined}
29
33
  data-component-name={ACCORDION_COMPONENT_NAME}
30
34
  data-source={dataSource}
31
35
  data-hash={dataHash}
@@ -37,7 +41,9 @@ export function Accordion({
37
41
  />
38
42
  {title}
39
43
  </AccordionSummary>
40
- <AccordionBody>{children}</AccordionBody>
44
+ <AccordionBody>
45
+ <AccordionGroupContext.Provider value={null}>{children}</AccordionGroupContext.Provider>
46
+ </AccordionBody>
41
47
  </AccordionWrapper>
42
48
  );
43
49
  }
@@ -1,24 +1,31 @@
1
- import React from 'react';
1
+ import React, { useId } from 'react';
2
2
  import styled from 'styled-components';
3
3
 
4
4
  import type { JSX, PropsWithChildren } from 'react';
5
5
 
6
6
  import { ACCORDION_GROUP_COMPONENT_NAME, ACCORDION_SELECTOR } from '@redocly/theme/core/constants';
7
+ import { AccordionGroupContext } from '@redocly/theme/core/contexts';
7
8
 
8
9
  export type AccordionGroupProps = {
10
+ singleExpanded?: boolean;
9
11
  className?: string;
10
12
  };
11
13
 
12
14
  export function AccordionGroup({
15
+ singleExpanded = false,
13
16
  className,
14
17
  children,
15
18
  }: PropsWithChildren<AccordionGroupProps>): JSX.Element {
19
+ const groupName = useId();
20
+
16
21
  return (
17
22
  <AccordionGroupWrapper
18
23
  className={className}
19
24
  data-component-name={ACCORDION_GROUP_COMPONENT_NAME}
20
25
  >
21
- {children}
26
+ <AccordionGroupContext.Provider value={singleExpanded ? groupName : null}>
27
+ {children}
28
+ </AccordionGroupContext.Provider>
22
29
  </AccordionGroupWrapper>
23
30
  );
24
31
  }
@@ -1,4 +1,4 @@
1
- import React, { createElement, isValidElement } from 'react';
1
+ import React, { createElement, isValidElement, useContext } from 'react';
2
2
  import styled from 'styled-components';
3
3
  import { useLocation } from 'react-router';
4
4
 
@@ -9,6 +9,7 @@ import { concatClassNames } from '@redocly/theme/core/utils';
9
9
  import { LinkIcon } from '@redocly/theme/icons/LinkIcon/LinkIcon';
10
10
  import { PageActions } from '@redocly/theme/components/PageActions/PageActions';
11
11
  import { useThemeHooks } from '@redocly/theme/core/hooks';
12
+ import { PageActionsContext } from '@redocly/theme/core/contexts';
12
13
  import {
13
14
  ANCHOR_CLASS,
14
15
  HEADING_ANCHOR_CLASS,
@@ -65,8 +66,10 @@ export function Heading({
65
66
  const { usePageProps } = useThemeHooks();
66
67
  const pageProps = usePageProps();
67
68
 
68
- const isMarkdownPage =
69
- pageProps?.metadata?.type === 'markdown' || pageProps?.metadata?.type === 'asciidoc';
69
+ // The page-type fallback is only for backward compatibility; templates set the scope.
70
+ const withPageActions =
71
+ useContext(PageActionsContext) ??
72
+ (pageProps?.metadata?.type === 'markdown' || pageProps?.metadata?.type === 'asciidoc');
70
73
  const headingTextId = `${id}-heading-text`;
71
74
 
72
75
  const linkEl = (
@@ -101,7 +104,7 @@ export function Heading({
101
104
  <HeadingContentWrapper>
102
105
  {linkEl}
103
106
  {headingText}
104
- {isMarkdownPage && __idx === 0 ? <PageActions pageSlug={pathname} /> : null}
107
+ {withPageActions && __idx === 0 ? <PageActions pageSlug={pathname} /> : null}
105
108
  </HeadingContentWrapper>
106
109
  </div>
107
110
  );
@@ -3,6 +3,9 @@ import type { MarkdocSchemaWrapper } from '@redocly/theme/markdoc/tags/types';
3
3
  export const accordionGroup: MarkdocSchemaWrapper = {
4
4
  schema: {
5
5
  render: 'AccordionGroup',
6
+ attributes: {
7
+ singleExpanded: { type: Boolean, default: false },
8
+ },
6
9
  },
7
10
  tagName: 'accordion-group',
8
11
  };