@redocly/theme 0.60.0-next.6 → 0.60.0-next.8

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 (46) hide show
  1. package/lib/components/Banner/Banner.d.ts +6 -0
  2. package/lib/components/Banner/Banner.js +172 -0
  3. package/lib/components/Banner/variables.d.ts +1 -0
  4. package/lib/components/Banner/variables.dark.d.ts +1 -0
  5. package/lib/components/Banner/variables.dark.js +12 -0
  6. package/lib/components/Banner/variables.js +45 -0
  7. package/lib/components/Buttons/AIAssistantButton.js +2 -1
  8. package/lib/components/LanguagePicker/LanguagePicker.js +1 -0
  9. package/lib/components/Navbar/Navbar.js +13 -5
  10. package/lib/components/Search/Search.js +6 -1
  11. package/lib/components/Search/SearchDialog.js +11 -5
  12. package/lib/core/contexts/SearchContext.d.ts +10 -0
  13. package/lib/core/contexts/SearchContext.js +56 -0
  14. package/lib/core/contexts/index.d.ts +1 -0
  15. package/lib/core/contexts/index.js +1 -0
  16. package/lib/core/hooks/search/use-search-dialog.js +4 -1
  17. package/lib/core/hooks/use-telemetry-fallback.d.ts +2 -0
  18. package/lib/core/hooks/use-telemetry-fallback.js +2 -0
  19. package/lib/core/hooks/use-theme-hooks.js +1 -0
  20. package/lib/core/openapi/index.d.ts +1 -0
  21. package/lib/core/openapi/index.js +4 -1
  22. package/lib/core/styles/dark.js +2 -0
  23. package/lib/core/styles/global.js +32 -30
  24. package/lib/core/types/hooks.d.ts +7 -3
  25. package/lib/index.d.ts +1 -0
  26. package/lib/index.js +2 -0
  27. package/package.json +7 -7
  28. package/src/components/Banner/Banner.tsx +179 -0
  29. package/src/components/Banner/variables.dark.ts +10 -0
  30. package/src/components/Banner/variables.ts +43 -0
  31. package/src/components/Buttons/AIAssistantButton.tsx +3 -2
  32. package/src/components/LanguagePicker/LanguagePicker.tsx +1 -0
  33. package/src/components/Navbar/Navbar.tsx +13 -5
  34. package/src/components/Search/Search.tsx +10 -1
  35. package/src/components/Search/SearchDialog.tsx +12 -5
  36. package/src/core/contexts/SearchContext.tsx +31 -0
  37. package/src/core/contexts/index.ts +1 -0
  38. package/src/core/hooks/__mocks__/use-theme-hooks.ts +4 -0
  39. package/src/core/hooks/search/use-search-dialog.ts +4 -1
  40. package/src/core/hooks/use-telemetry-fallback.ts +2 -0
  41. package/src/core/hooks/use-theme-hooks.ts +1 -0
  42. package/src/core/openapi/index.ts +1 -0
  43. package/src/core/styles/dark.ts +2 -0
  44. package/src/core/styles/global.ts +2 -0
  45. package/src/core/types/hooks.ts +6 -5
  46. package/src/index.ts +2 -0
@@ -4,6 +4,7 @@ import hotkeys from 'hotkeys-js';
4
4
 
5
5
  import { useThemeHooks } from '../use-theme-hooks';
6
6
  import { useThemeConfig } from '../use-theme-config';
7
+ import { useSearchSession } from '../../contexts';
7
8
 
8
9
  export function useSearchDialog() {
9
10
  const [isOpen, setIsOpen] = useState(false);
@@ -11,6 +12,7 @@ export function useSearchDialog() {
11
12
  const location = useLocation();
12
13
  const { useTelemetry } = useThemeHooks();
13
14
  const telemetry = useTelemetry();
15
+ const { refreshSearchSessionId } = useSearchSession();
14
16
  const keyShortcuts = themeSettings?.search?.shortcuts ?? ['⌘+K,CTRL+K'];
15
17
  const hotKeys = keyShortcuts?.join(',');
16
18
 
@@ -34,8 +36,9 @@ export function useSearchDialog() {
34
36
  }, []);
35
37
 
36
38
  const onClose = useCallback(() => {
39
+ refreshSearchSessionId();
37
40
  setIsOpen(false);
38
- }, []);
41
+ }, [refreshSearchSessionId]);
39
42
 
40
43
  // eslint-disable-next-line react-hooks/exhaustive-deps
41
44
  useEffect(onClose, [location]);
@@ -54,6 +54,8 @@ export const useTelemetryFallback = () => ({
54
54
  sendSwitchServersClickedMessage: () => {},
55
55
  sendExamplesSwitcherClickedMessage: () => {},
56
56
  sendTryItOpenedMessage: () => {},
57
+ sendViewSecurityDetailsClickedMessage: () => {},
58
+ sendViewSecurityDetailsClosedMessage: () => {},
57
59
  sendAsyncapiDocsViewedMessage: () => {},
58
60
  sendAsyncapiDocsPerformanceMetricsMessage: () => {},
59
61
  sendAsyncapiDocsSwitchMessageClickedMessage: () => {},
@@ -17,6 +17,7 @@ const fallbacks = {
17
17
  **/
18
18
  useOtelTelemetry: () => ({ send: () => {} }),
19
19
  useBreadcrumbs: () => ({ breadcrumbs: [], siblings: undefined }),
20
+ useBanner: () => ({ banner: undefined, dismissBanner: () => {} }),
20
21
  useCodeHighlight: () => ({ highlight: (rawContent: string) => rawContent }),
21
22
  useUserMenu: () => ({}),
22
23
  usePageData: () => null,
@@ -37,3 +37,4 @@ export { useDialogHotKeys } from '../hooks/use-dialog-hotkeys';
37
37
  export { SecurityVariablesEnvSuffix } from '../constants/environments';
38
38
  export { isUndefined, isString, isNotNull, isObject } from '../utils/type-guards';
39
39
  export { ThemeDataContext, type ThemeDataTransferObject } from '../contexts/ThemeDataContext';
40
+ export { SearchSessionProvider, SearchSessionContext } from '../contexts/SearchContext';
@@ -14,6 +14,7 @@ import { cardsDarkMode } from '@redocly/theme/markdoc/components/Cards/variables
14
14
  import { catalogDarkMode } from '@redocly/theme/components/Catalog/variables.dark';
15
15
  import { pageActionsDarkMode } from '@redocly/theme/components/PageActions/variables.dark';
16
16
  import { tooltipDarkMode } from '@redocly/theme/components/Tooltip/variables.dark';
17
+ import { bannerDarkMode } from '@redocly/theme/components/Banner/variables.dark';
17
18
 
18
19
  const replayDarkMode = css`
19
20
  /**
@@ -328,6 +329,7 @@ export const darkMode = css`
328
329
  ${catalogDarkMode}
329
330
  ${pageActionsDarkMode}
330
331
  ${tooltipDarkMode}
332
+ ${bannerDarkMode}
331
333
 
332
334
  /**
333
335
  * @tokens Dark Theme Scrollbar Config
@@ -26,6 +26,7 @@ import { menu, mobileMenu } from '@redocly/theme/components/Menu/variables';
26
26
  import { code } from '@redocly/theme/components/CodeBlock/variables';
27
27
  import { productPicker } from '@redocly/theme/components/Product/variables';
28
28
  import { markdown } from '@redocly/theme/components/Markdown/variables';
29
+ import { banner } from '@redocly/theme/components/Banner/variables';
29
30
  import { markdownTabs } from '@redocly/theme/markdoc/components/Tabs/variables';
30
31
  import { mermaid } from '@redocly/theme/markdoc/components/Mermaid/variables';
31
32
  import { lastUpdated } from '@redocly/theme/components/LastUpdated/variables';
@@ -1239,6 +1240,7 @@ export const styles = css`
1239
1240
  ${apiReferenceDocs}
1240
1241
  ${apiReferencePanels}
1241
1242
  ${badges}
1243
+ ${banner}
1242
1244
  ${borders}
1243
1245
  ${breadcrumbs}
1244
1246
  ${button}
@@ -1,5 +1,6 @@
1
1
  import type { AsyncApiRealmUI } from '@redocly/realm-asyncapi-sdk';
2
2
  import type {
3
+ BannerConfig,
3
4
  CatalogEntityConfig,
4
5
  PageData,
5
6
  PageProps,
@@ -83,10 +84,13 @@ export type ThemeHooks = {
83
84
  breadcrumbs: BreadcrumbItem[];
84
85
  currentItemSiblings?: BreadcrumbItem[];
85
86
  };
87
+ useBanner: () => {
88
+ banner: BannerConfig | undefined;
89
+ dismissBanner: (content: string) => void;
90
+ };
86
91
  useSearch: (
87
92
  product?: string,
88
93
  autoSearchDisabled?: boolean,
89
- searchSessionId?: string,
90
94
  ) => {
91
95
  query: string;
92
96
  setQuery: React.Dispatch<React.SetStateAction<string>>;
@@ -108,10 +112,7 @@ export type ThemeHooks = {
108
112
  advancedSearch?: boolean;
109
113
  askAi?: boolean;
110
114
  };
111
- useAiSearch: (
112
- options?: { filter?: SearchFilterItem[] },
113
- searchSessionId?: string,
114
- ) => {
115
+ useAiSearch: (options?: { filter?: SearchFilterItem[] }) => {
115
116
  askQuestion: (question: string, history?: AiSearchConversationItem[]) => void;
116
117
  isGeneratingResponse: boolean;
117
118
  question: string;
package/src/index.ts CHANGED
@@ -52,6 +52,8 @@ export * from '@redocly/theme/components/Footer/Footer';
52
52
  export * from '@redocly/theme/components/Footer/FooterColumn';
53
53
  export * from '@redocly/theme/components/Footer/FooterCopyright';
54
54
  export * from '@redocly/theme/components/Footer/FooterItem';
55
+ /* Banner */
56
+ export * from '@redocly/theme/components/Banner/Banner';
55
57
  /* Typography */
56
58
  export * from '@redocly/theme/components/Typography/CompactTypography';
57
59
  export * from '@redocly/theme/components/Typography/Emphasis';