@redocly/theme 0.1.26 → 0.1.29

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 (135) hide show
  1. package/Button/Button.js +3 -3
  2. package/CodeBlock/CodeBlock.js +1 -1
  3. package/CopyButton/CopyButton.js +17 -1
  4. package/CopyButton/CopyButtonWrapper.js +1 -1
  5. package/Footer/Footer.js +2 -1
  6. package/Footer/FooterColumn.js +1 -1
  7. package/Footer/FooterColumns.d.ts +2 -2
  8. package/Footer/FooterColumns.js +1 -1
  9. package/JsonViewer/JsonViewer.d.ts +2 -0
  10. package/JsonViewer/JsonViewer.js +53 -22
  11. package/Markdown/Admonition.js +1 -1
  12. package/Markdown/CodeSample/CodeSample.js +17 -1
  13. package/Markdown/Heading.js +11 -2
  14. package/Markdown/MarkdownWrapper.js +2 -2
  15. package/Markdown/Mermaid.js +1 -1
  16. package/Markdown/Sup.d.ts +2 -0
  17. package/Markdown/Sup.js +19 -0
  18. package/Markdown/Tabs/Tabs.js +17 -1
  19. package/Markdown/index.d.ts +4 -3
  20. package/Markdown/index.js +4 -3
  21. package/Navbar/MobileNavbarDropdown.d.ts +8 -0
  22. package/Navbar/MobileNavbarDropdown.js +21 -0
  23. package/Navbar/MobileNavbarItem.d.ts +15 -0
  24. package/Navbar/MobileNavbarItem.js +102 -0
  25. package/Navbar/MobileNavbarMenu.d.ts +6 -0
  26. package/Navbar/MobileNavbarMenu.js +32 -0
  27. package/Navbar/MobileNavbarMenuButton.d.ts +4 -0
  28. package/Navbar/MobileNavbarMenuButton.js +19 -0
  29. package/Navbar/Navbar.js +26 -4
  30. package/Navbar/NavbarDropdown.js +1 -1
  31. package/Navbar/NavbarItem.d.ts +9 -3
  32. package/Navbar/NavbarItem.js +9 -9
  33. package/Navbar/NavbarMenu.js +3 -2
  34. package/PageNavigation/NextPageLink.js +4 -4
  35. package/PageNavigation/PreviousPageLink.js +4 -4
  36. package/Panel/PanelComponent.js +18 -2
  37. package/Profile/Profile.d.ts +8 -0
  38. package/Profile/Profile.js +60 -0
  39. package/Profile/index.d.ts +2 -0
  40. package/Profile/index.js +5 -0
  41. package/Search/Autocomplete.js +18 -2
  42. package/Search/utils.js +17 -1
  43. package/Sidebar/SidebarLayout.js +17 -1
  44. package/SourceCode/SourceCode.d.ts +10 -3
  45. package/SourceCode/SourceCode.js +10 -5
  46. package/TableOfContent/TableOfContent.js +4 -4
  47. package/Tooltip/Tooltip.d.ts +5 -4
  48. package/Tooltip/Tooltip.js +43 -21
  49. package/globalStyle.js +2 -2
  50. package/hooks/useActiveHeading.js +17 -1
  51. package/hooks/useActiveSectionId.d.ts +1 -1
  52. package/hooks/useActiveSectionId.js +17 -1
  53. package/hooks/useControl.js +17 -1
  54. package/hooks/useMobileMenu.js +17 -1
  55. package/hooks/useNavbarHeight.js +17 -1
  56. package/index.d.ts +1 -0
  57. package/index.js +1 -0
  58. package/package.json +1 -1
  59. package/src/Button/Button.tsx +5 -1
  60. package/src/CodeBlock/CodeBlock.ts +12 -0
  61. package/src/CopyButton/CopyButtonWrapper.tsx +1 -1
  62. package/src/Footer/Footer.tsx +4 -3
  63. package/src/Footer/FooterColumn.tsx +3 -1
  64. package/src/Footer/FooterColumns.tsx +3 -3
  65. package/src/JsonViewer/JsonViewer.tsx +55 -40
  66. package/src/Markdown/Admonition.tsx +1 -1
  67. package/src/Markdown/Heading.tsx +13 -2
  68. package/src/Markdown/MarkdownWrapper.tsx +58 -58
  69. package/src/Markdown/Mermaid.tsx +1 -1
  70. package/src/Markdown/Sup.tsx +8 -0
  71. package/src/Markdown/index.ts +4 -3
  72. package/src/Navbar/MobileNavbarDropdown.tsx +37 -0
  73. package/src/Navbar/MobileNavbarItem.tsx +116 -0
  74. package/src/Navbar/MobileNavbarMenu.tsx +106 -0
  75. package/src/Navbar/MobileNavbarMenuButton.tsx +13 -0
  76. package/src/Navbar/Navbar.tsx +11 -3
  77. package/src/Navbar/NavbarDropdown.tsx +1 -1
  78. package/src/Navbar/NavbarItem.tsx +9 -8
  79. package/src/Navbar/NavbarMenu.tsx +9 -4
  80. package/src/PageNavigation/NextPageLink.tsx +3 -3
  81. package/src/PageNavigation/PreviousPageLink.tsx +3 -3
  82. package/src/Profile/Profile.tsx +91 -0
  83. package/src/Profile/index.ts +2 -0
  84. package/src/SourceCode/SourceCode.tsx +32 -5
  85. package/src/TableOfContent/TableOfContent.tsx +3 -3
  86. package/src/Tooltip/Tooltip.tsx +87 -63
  87. package/src/globalStyle.ts +2 -0
  88. package/src/hooks/useActiveSectionId.ts +1 -1
  89. package/src/index.ts +1 -0
  90. package/src/types/portal/src/client/app/Sidebar/types.d.ts +2 -1
  91. package/src/types/portal/src/server/constants.d.ts +2 -0
  92. package/src/types/portal/src/server/dev-server/types.d.ts +22 -0
  93. package/src/types/portal/src/server/plugins/markdown/types.d.ts +15 -5
  94. package/src/types/portal/src/server/plugins/portal-config/get-frontmatter-keys-to-resolve.d.ts +2 -0
  95. package/src/types/portal/src/server/plugins/portal-config/types.d.ts +6 -2
  96. package/src/types/portal/src/server/plugins/reference-docs/utils.d.ts +26 -0
  97. package/src/types/portal/src/server/plugins/types.d.ts +29 -12
  98. package/src/types/portal/src/server/store.d.ts +16 -16
  99. package/src/types/portal/src/server/utils/fs.d.ts +2 -1
  100. package/src/types/portal/src/server/utils/index.d.ts +1 -0
  101. package/src/types/portal/src/server/utils/paths.d.ts +4 -0
  102. package/src/types/portal/src/server/utils/rbac.d.ts +15 -0
  103. package/src/types/portal/src/shared/constants.d.ts +7 -0
  104. package/src/types/portal/src/shared/models/config.d.ts +24 -12
  105. package/src/types/portal/src/shared/types.d.ts +17 -4
  106. package/src/types/portal/src/shared/urls.d.ts +1 -1
  107. package/src/types/portal/src/shared/utils.d.ts +2 -0
  108. package/src/ui/Burger.tsx +36 -0
  109. package/src/ui/Flex.tsx +1 -0
  110. package/src/utils/args-typecheck.ts +9 -0
  111. package/src/utils/class-names.ts +8 -0
  112. package/src/utils/color.ts +9 -0
  113. package/src/utils/highlight.ts +11 -0
  114. package/src/utils/index.ts +3 -0
  115. package/src/utils/jsonToHtml.ts +171 -59
  116. package/src/utils/theme-helpers.ts +3 -1
  117. package/ui/Burger.d.ts +8 -0
  118. package/ui/Burger.js +23 -0
  119. package/ui/Dropdown.js +17 -1
  120. package/ui/Flex.js +1 -1
  121. package/ui/UniversalLink.js +17 -1
  122. package/utils/args-typecheck.d.ts +2 -0
  123. package/utils/args-typecheck.js +13 -0
  124. package/utils/class-names.d.ts +1 -0
  125. package/utils/class-names.js +15 -0
  126. package/utils/color.d.ts +2 -0
  127. package/utils/color.js +12 -0
  128. package/utils/highlight.d.ts +1 -0
  129. package/utils/highlight.js +12 -1
  130. package/utils/index.d.ts +3 -0
  131. package/utils/index.js +3 -0
  132. package/utils/jsonToHtml.d.ts +4 -1
  133. package/utils/jsonToHtml.js +287 -83
  134. package/utils/media-css.js +40 -3
  135. package/utils/theme-helpers.js +59 -10
@@ -0,0 +1,22 @@
1
+ /// <reference types="node" />
2
+ import http from 'http';
3
+ import { MatchFunction } from 'path-to-regexp';
4
+ import { BuildIncremental } from 'esbuild';
5
+ export interface DevServerOptions {
6
+ clientEsbuild: BuildIncremental;
7
+ serverEsbuild: BuildIncremental;
8
+ port?: number;
9
+ }
10
+ export interface EnhancedIncomingMessage extends http.IncomingMessage {
11
+ pathname: string;
12
+ params: Record<string, string>;
13
+ body: string;
14
+ }
15
+ export interface Route {
16
+ matchPath: MatchFunction<EnhancedIncomingMessage['params']>;
17
+ handler(req: EnhancedIncomingMessage, res: http.ServerResponse): void;
18
+ }
19
+ export interface Server {
20
+ httpServer: http.Server;
21
+ addRoute(path: string, handler: Route['handler']): void;
22
+ }
@@ -1,4 +1,5 @@
1
1
  import { Config, Node, RenderableTreeNode } from '@markdoc/markdoc/dist/src/types';
2
+ import type { PageStaticData } from '../../../shared/types.js';
2
3
  import type { ContentProvider, ContentRecord } from '../../content/content-provider.js';
3
4
  import { PluginDefaultOptions } from '../types.js';
4
5
  import type { RouteDetails } from '../types.js';
@@ -7,16 +8,21 @@ export interface MdHeading {
7
8
  value: string;
8
9
  depth: number;
9
10
  }
10
- export declare type MarkdownOptions = {
11
+ export declare type RoutesInfoActions = {
11
12
  getRouteByFsPath: (relativePath: string) => RouteDetails | undefined;
12
13
  getRouteBySlug?: (slug: string) => RouteDetails | undefined;
13
- contentProvider: ContentProvider;
14
14
  };
15
- export interface MdPartialsContext {
15
+ export interface MdOptions {
16
16
  partials: Record<string, Node>;
17
+ variables?: Record<string, any>;
17
18
  }
18
- export declare type MdRenderContext = ContentRecord & PluginDefaultOptions & MdPartialsContext;
19
- export declare type MdCompilationContext = MdRenderContext & MarkdownOptions;
19
+ export declare type MdRenderContext = ContentRecord & PluginDefaultOptions & MdOptions;
20
+ export declare type MdCompilationContext = MdRenderContext & RoutesInfoActions & {
21
+ contentProvider: ContentProvider;
22
+ };
23
+ export declare type MdProcessContext = PluginDefaultOptions & RoutesInfoActions & {
24
+ contentProvider: ContentProvider;
25
+ } & MdOptions;
20
26
  export interface MdCompilationResult {
21
27
  result: RenderableTreeNode;
22
28
  headings: MdHeading[];
@@ -24,3 +30,7 @@ export interface MdCompilationResult {
24
30
  export interface ExtendedMarkdocConfig extends Config {
25
31
  currentProcessedPage?: string;
26
32
  }
33
+ export interface MdPageStaticData extends PageStaticData {
34
+ ast: string;
35
+ frontmatter: Record<string, unknown>;
36
+ }
@@ -0,0 +1,2 @@
1
+ import { PortalConfig } from '../../../shared/models/config.js';
2
+ export declare function getFrontmatterKeysToResolve(config?: PortalConfig): string[];
@@ -1,5 +1,5 @@
1
1
  import { ResolvedConfigLinks } from '../../../shared/types.js';
2
- import { PortalConfig, RawTheme } from '../../../shared/models/config.js';
2
+ import { AuthConfig, PortalConfig, RawTheme } from '../../../shared/models/config.js';
3
3
  import { Redirect } from '../types';
4
4
  export interface GlobalData {
5
5
  nav?: ResolvedConfigLinks;
@@ -13,8 +13,12 @@ export interface GlobalConfig {
13
13
  stylesheets?: string;
14
14
  redirects: Record<string, Redirect>;
15
15
  fileName: string;
16
+ rbac: RbacConfig;
16
17
  [k: string]: unknown;
17
18
  }
18
- export declare type RbacConfig = Record<string, string[]>;
19
+ export declare type RbacConfig = {
20
+ roles: Record<string, string[]>;
21
+ auth?: AuthConfig;
22
+ };
19
23
  export declare type CustomEntryPropertyType = Record<string, string | boolean>;
20
24
  export declare type ScriptOrStylesheetConfig = string | CustomEntryPropertyType;
@@ -0,0 +1,26 @@
1
+ import type { Pagination as PaginationType, IMenuItem, OpenAPIDefinition as IOpenAPIDefinition, MenuItemType } from '@redocly/reference-docs';
2
+ import { RedocProRawOptions } from '@redocly/reference-docs';
3
+ import type { ResolvedNavItem } from '../../../shared/types.js';
4
+ import type { ParsedContentRecord } from '../../content/content-provider.js';
5
+ export interface IMenuItemExtended extends IMenuItem {
6
+ httpVerb?: string;
7
+ }
8
+ export declare function loadDefinition(content: ParsedContentRecord): Promise<IOpenAPIDefinition | undefined>;
9
+ export declare function convertRedocToSidebar(data: {
10
+ redocItems: IMenuItemExtended[];
11
+ sidebarItems: ResolvedNavItem[];
12
+ parentId?: string;
13
+ routeSlug: string;
14
+ pagination: PaginationType;
15
+ }): void;
16
+ export declare const shouldAddPage: ({ pagination, type, }: {
17
+ pagination: PaginationType;
18
+ type: MenuItemType;
19
+ }) => boolean;
20
+ export declare const removeMarkdownLinks: (text: string) => string;
21
+ export declare function getConfigByPath(apis: {
22
+ [x: string]: {
23
+ root: string;
24
+ 'features.openapi': RedocProRawOptions;
25
+ };
26
+ } | undefined, path: string): RedocProRawOptions;
@@ -1,24 +1,39 @@
1
- import type { PageProps, ResolvedNavItem } from '../../shared/types.js';
2
- import type { Template } from '../store';
1
+ import type { PageProps, PageStaticData, ResolvedNavItem, Version } from '../../shared/types.js';
3
2
  import type { ContentProvider } from '../content/content-provider.js';
4
3
  import { SearchData, SearchDocument } from '../../shared/models';
5
- import type { GlobalData, GlobalConfig, RbacConfig } from './portal-config/types.js';
6
- export declare type DataLoaderContext = {
4
+ import { PERMISSION_PROP_NAME } from '@shared/constants.js';
5
+ import { Store } from '../store.js';
6
+ import type { GlobalData, GlobalConfig } from './portal-config/types.js';
7
+ import { MdOptions } from './markdown/types.js';
8
+ export declare type GetStaticDataContext = {
7
9
  getRouteByFsPath: (relativePath: string) => RouteDetails | undefined;
8
10
  getRouteBySlug: (relativePath: string) => RouteDetails | undefined;
11
+ getGlobalConfig<T = unknown>(key: string): T | undefined;
12
+ getAllRoutes: () => RouteDetails[];
13
+ contentDir: string;
14
+ outdir: string;
15
+ };
16
+ export declare type RbacContext = {
17
+ roles: string[];
18
+ permissions: string[];
9
19
  };
10
- export declare type DataLoader<T = any> = (contentProvider: ContentProvider, context: DataLoaderContext) => Promise<T>;
11
- export interface RouteDetails {
20
+ export declare type GetStaticDataFn<TData extends PageStaticData = PageStaticData, TProps extends PageProps = PageProps> = (route: RouteDetails<TData, TProps>, contentProvider: ContentProvider, context: GetStaticDataContext) => Promise<TData>;
21
+ export declare type GetServerPropsContext = {
22
+ getGlobalConfig<T = unknown>(key: string): T | undefined;
23
+ getRbacPermissionsByRole: Store['getRbacPermissionsByRole'];
24
+ };
25
+ export declare type GetServerPropsFn<TData extends PageStaticData = PageStaticData, TProps extends PageProps = PageProps> = (route: RouteDetails<TData, TProps>, data: TData, mdOptions: MdOptions) => Promise<TProps>;
26
+ export interface RouteDetails<TData extends PageStaticData = PageStaticData, TProps extends PageProps = PageProps> {
12
27
  slug: string;
13
28
  fsPath: string;
14
29
  templateId: string;
15
- dataLoaders: {
16
- props: DataLoader<PageProps>;
17
- [k: string]: DataLoader;
18
- };
30
+ [PERMISSION_PROP_NAME]?: string;
31
+ versions?: Version[];
19
32
  getNavText?: () => Promise<string>;
20
33
  getSidebar?(): ResolvedNavItem[];
21
34
  getSearchDocuments?(): Promise<SearchDocument[]>;
35
+ getStaticData?: GetStaticDataFn<TData, TProps>;
36
+ serverPropsGetterIds?: string[];
22
37
  }
23
38
  export interface Redirect {
24
39
  to: string;
@@ -32,9 +47,10 @@ export interface PathVersionInfo {
32
47
  export interface ProcessContentActions {
33
48
  createSharedData(id: string, data: unknown): string;
34
49
  addRouteSharedData(slug: string, dataKey: string, dataId: string): void;
50
+ setGlobalConfig: (data: Partial<GlobalConfig>) => void;
35
51
  addRoute: (route: RouteDetails) => void;
36
- createTemplate: (template: Template) => Template;
37
- setRbacConfig: (rbacConfig: RbacConfig) => void;
52
+ createTemplate: (id: string, importPath: string) => string;
53
+ registerServerPropsGetter: (id: string, importPath: string) => string;
38
54
  }
39
55
  export interface AfterRoutesCreatedActions {
40
56
  createSharedData(id: string, data: unknown): string;
@@ -47,6 +63,7 @@ export interface AfterRoutesCreatedActions {
47
63
  setSearchData: (data: SearchData) => void;
48
64
  addRedirect: (from: string, to: Redirect) => void;
49
65
  contentDir: string;
66
+ outdir: string;
50
67
  }
51
68
  export interface PluginInstance {
52
69
  watch?: RegExp;
@@ -1,13 +1,9 @@
1
1
  import { Plugin } from 'esbuild';
2
2
  import { JSONIndex, SearchDocument, SearchData } from '../shared/models';
3
+ import type { PageStaticData } from '../shared/types.js';
3
4
  import type { RouteDetails, Redirect } from './plugins/types.js';
4
- import type { GlobalData, GlobalConfig, RbacConfig } from './plugins/portal-config/types';
5
- export declare class Template {
6
- pathOrThemePath: string;
7
- id: string;
8
- hash: string;
9
- constructor(pathOrThemePath: string, id: string);
10
- }
5
+ import type { GlobalData, GlobalConfig } from './plugins/portal-config/types';
6
+ import type { ContentProvider } from './content/content-provider';
11
7
  export declare class Store {
12
8
  contentDir: string;
13
9
  outdir: string;
@@ -18,10 +14,11 @@ export declare class Store {
18
14
  searchDocuments: SearchDocument[];
19
15
  searchIndex: JSONIndex;
20
16
  sharedData: Map<string, unknown>;
21
- templates: Map<string, Template>;
17
+ routesStaticDataCache: Map<string, PageStaticData>;
18
+ templates: Map<string, string>;
19
+ serverPropsGetters: Map<string, string>;
22
20
  esbuildPlugins: Plugin[];
23
21
  listeners: Map<string, Set<Function>>;
24
- rbacConfig: RbacConfig;
25
22
  globalData: GlobalData;
26
23
  cliOptions: Record<string, string>;
27
24
  globalConfig: GlobalConfig;
@@ -34,19 +31,22 @@ export declare class Store {
34
31
  on(type: 'global-data-updated', cb: (pathname: string, data: Record<string, unknown>) => void): void;
35
32
  runListeners<T extends Array<unknown>>(type: 'template-updated' | 'global-data-updated' | 'shared-data-updated' | 'search-data-updated' | 'routes-updated' | 'build-updated', ...args: T): void;
36
33
  addEsbuildPlugin(plugin: Plugin): void;
37
- setGlobalData(data: GlobalData): void;
34
+ setGlobalData: (data: GlobalData) => void;
38
35
  setSearchData(data: SearchData): void;
39
36
  setCliOptions(data: Record<string, string>): void;
40
37
  setGlobalConfig(data: Partial<GlobalConfig>): void;
41
- setRbacConfig(rbacConfig: RbacConfig): void;
38
+ getRbacPermissionsByRole(role: string): string[] | undefined;
39
+ getGlobalConfig<T = unknown>(key: string): T;
42
40
  addRedirect(from: string, to: Redirect): void;
43
41
  createSharedData: (id: string, data: unknown) => string;
44
42
  addRouteSharedData: (routeSlug: string, dataKey: string, dataId: string) => void;
45
43
  addRoute: (route: RouteDetails) => void;
46
- getRouteByFsPath: (relativePath: string) => RouteDetails | undefined;
47
- getRouteBySlug: (slug: string) => RouteDetails | undefined;
48
- getAllRoutes: () => RouteDetails[];
49
- getTemplate: (id: string) => Template | undefined;
50
- createTemplate: (template: Template) => Template;
44
+ getRouteByFsPath: (relativePath: string) => RouteDetails<PageStaticData, import("../shared/types.js").PageProps> | undefined;
45
+ getRouteBySlug: (slug: string) => RouteDetails<PageStaticData, import("../shared/types.js").PageProps> | undefined;
46
+ getAllRoutes: () => RouteDetails<PageStaticData, import("../shared/types.js").PageProps>[];
47
+ getTemplate: (id: string) => string | undefined;
48
+ createTemplate: (id: string, importPath: string) => string;
49
+ registerServerPropsGetter: (id: string, importPath: string) => string;
50
+ resolveRouteStaticData(route: RouteDetails, contentProvider: ContentProvider): Promise<{}>;
51
51
  clear: () => void;
52
52
  }
@@ -1,4 +1,5 @@
1
1
  export declare function readFileAsStringSync(filePath: string): string | null | undefined;
2
2
  export declare function readFileNames(dir: string): string[];
3
- export declare function copyStaticFile(absolutePath: string, outdir: string): string;
3
+ export declare function copyStaticFile(absolutePath: string, outdir: string): string | undefined;
4
+ export declare function copyFolderRecursiveSync(source: string, target: string): void;
4
5
  export declare function ensureDir(path: string): string;
@@ -3,3 +3,4 @@ export * from './crypto.js';
3
3
  export * from './fs.js';
4
4
  export * from './reporter/reporter.js';
5
5
  export * from './paths.js';
6
+ export * from './rbac.js';
@@ -1,4 +1,6 @@
1
+ import { OpenAPIDefinition } from '@redocly/reference-docs';
1
2
  import type { ContentProvider } from '../content/content-provider.js';
3
+ import { Route } from '../dev-server/types';
2
4
  export declare function getDataFromRelativePath(relativePath: string): {
3
5
  pathVersion: string | null;
4
6
  basePath: string;
@@ -11,3 +13,5 @@ export declare function excludeVersion<T extends string[] | string>(arg: T): {
11
13
  version?: string;
12
14
  data: T;
13
15
  };
16
+ export declare function getParamsFromPath(path: string, route: Route): Record<string, string>;
17
+ export declare function getDefinitionFiles(contentProvider: ContentProvider): Promise<Map<string, OpenAPIDefinition>>;
@@ -0,0 +1,15 @@
1
+ import { Store } from '../store';
2
+ import { PERMISSION_PROP_NAME } from '../../shared/constants.js';
3
+ export declare function canAccessResource<T extends {
4
+ [PERMISSION_PROP_NAME]?: string;
5
+ }>(resource: T, permissions: Set<string>): boolean;
6
+ export declare function getPermissionsForRoles(store: Pick<Store, 'getRbacPermissionsByRole'>, roles: string[]): Set<string>;
7
+ export declare function getUserRolesFromCookies(cookies?: string): string[];
8
+ /**
9
+ * Maps the input deep and removes objects that have a 'permission' prop
10
+ * but do not match the input permissions list
11
+ * @param input can be object, array, string or any other value
12
+ * @param permissions
13
+ * @returns
14
+ */
15
+ export declare function filterDataByAccessDeep(input: any, permissions: Set<string>): any;
@@ -1,10 +1,17 @@
1
1
  export declare const RUNTIME_RESOURCES_DIR = "runtime";
2
2
  export declare const REDOC_OVERVIEW_ITEM_ID = "overview";
3
3
  export declare const PORTAL_CUSTOM_THEMES_FOLDER = "@theme";
4
+ export declare const DEFAULT_THEME_NAME = "@redocly/theme";
4
5
  export declare const CUSTOM_MARKDOC_OPTIONS_PATH = "markdoc";
5
6
  export declare const CUSTOM_MARKDOC_TAGS_PATH = "tags";
6
7
  export declare const USER_THEME_ALIAS = "@theme";
8
+ export declare const PUBLIC_ASSETS_FOLDER = "/assets";
7
9
  export declare const PUBLIC_STATIC_FOLDER = "/static";
10
+ export declare const THEME_ASSETS_FOLDER = "theme-assets";
11
+ export declare const PERMISSION_PROP_NAME = "redocly::permission";
12
+ export declare const OIDC_CALLBACK_ROUTE_PATH = "/_auth/oidc";
13
+ export declare const DEFAULT_OIDC_SCOPES = "openid";
8
14
  export declare enum FsErrors {
9
15
  NotExist = "ENOENT"
10
16
  }
17
+ export declare const INTERNALLY_IGNORED_FILES: string[];
@@ -1,9 +1,28 @@
1
- import { RawNavItem, LogoConfig, ResolvedNavItem } from '../types';
1
+ import { RawNavItem, LogoConfig } from '../types';
2
+ declare type RawNavConfig = RawNavItem[] | Record<string, RawNavItem[] | {
3
+ items: RawNavItem[];
4
+ } | string>;
5
+ export declare type AuthProviderConfig = {
6
+ type: string;
7
+ configurationUrl: string;
8
+ clientId: string;
9
+ clientSecret: string;
10
+ rolesClaimName: string;
11
+ scopes?: Array<string>;
12
+ };
13
+ export declare type AuthIdpsConfig = {
14
+ main: AuthProviderConfig;
15
+ };
16
+ export declare type AuthConfig = {
17
+ idps: AuthIdpsConfig;
18
+ };
2
19
  export interface PortalConfig extends Record<string, any> {
3
- nav?: RawNavItem[];
20
+ nav?: RawNavConfig;
4
21
  logo?: LogoConfig;
5
22
  themes?: RawTheme[];
6
- footer?: FooterConfig;
23
+ footer?: RawNavConfig;
24
+ auth?: AuthConfig;
25
+ frontmatterKeysToResolve?: string[];
7
26
  }
8
27
  export interface RawTheme {
9
28
  name: string;
@@ -11,18 +30,11 @@ export interface RawTheme {
11
30
  }
12
31
  export interface ResolvedTheme extends RawTheme {
13
32
  stylesFile?: string;
33
+ path: string;
14
34
  markdoc: {
15
35
  nodesFiles: string[];
16
36
  tagsFiles: string[];
17
37
  componentsFile?: string;
18
38
  };
19
39
  }
20
- export interface FooterConfig {
21
- copyrightText?: string;
22
- columns?: FooterColumn[];
23
- }
24
- export interface FooterColumn {
25
- group: string;
26
- label?: string;
27
- items: ResolvedNavItem[];
28
- }
40
+ export {};
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { PERMISSION_PROP_NAME } from './constants';
2
3
  export declare type ResolvedNavLinkItem = {
3
4
  type: 'link';
4
5
  link: string;
@@ -12,6 +13,7 @@ export declare type ResolvedNavLinkItem = {
12
13
  separatorLine?: boolean;
13
14
  routeSlug?: string;
14
15
  active?: boolean;
16
+ [PERMISSION_PROP_NAME]?: string;
15
17
  };
16
18
  export declare type ResolvedNavGroupItem = {
17
19
  type: 'group';
@@ -25,6 +27,7 @@ export declare type ResolvedNavGroupItem = {
25
27
  separatorLine?: boolean;
26
28
  routeSlug?: string;
27
29
  active?: boolean;
30
+ [PERMISSION_PROP_NAME]?: string;
28
31
  };
29
32
  export declare type ResolvedNavItem = ResolvedNavLinkItem | ResolvedNavGroupItem | {
30
33
  type: 'separator';
@@ -35,6 +38,7 @@ export declare type ResolvedNavItem = ResolvedNavLinkItem | ResolvedNavGroupItem
35
38
  separatorLine?: boolean;
36
39
  link?: undefined;
37
40
  items?: ResolvedNavItem[];
41
+ [PERMISSION_PROP_NAME]?: string;
38
42
  } | {
39
43
  type: 'error';
40
44
  version?: string;
@@ -43,23 +47,30 @@ export declare type ResolvedNavItem = ResolvedNavLinkItem | ResolvedNavGroupItem
43
47
  label: string;
44
48
  link?: undefined;
45
49
  items?: ResolvedNavItem[];
50
+ [PERMISSION_PROP_NAME]?: string;
46
51
  };
47
52
  export declare type ResolvedNavItemWithLink = (ResolvedNavLinkItem | ResolvedNavGroupItem) & {
48
53
  link: string;
49
54
  };
50
55
  export declare type ResolvedSidebar = ResolvedNavItem[];
51
56
  export interface PageProps {
52
- seo: {
57
+ seo?: {
53
58
  title: string;
54
59
  };
55
- versions?: Version[];
56
- frontmatter?: Omit<PageProps, 'frontmatter'>;
60
+ frontmatter?: Omit<PageProps, 'frontmatter'> & {
61
+ settings?: any;
62
+ };
63
+ [k: string]: any;
64
+ }
65
+ export interface PageStaticData {
66
+ props?: PageProps;
57
67
  [k: string]: unknown;
58
68
  }
59
69
  export interface PageData {
60
70
  templateId: string;
61
71
  sharedDataIds: Record<string, string>;
62
72
  props: PageProps;
73
+ versions?: Version[];
63
74
  }
64
75
  export interface CachedPageData extends PageData {
65
76
  Template: React.ComponentType<{
@@ -117,6 +128,8 @@ export declare type VersionedFolderConfig = {
117
128
  versions: VersionConfigItem[];
118
129
  hasVersionsConfig?: boolean;
119
130
  };
120
- export declare type NavGroup = ResolvedNavItem[] | undefined | string;
131
+ export declare type NavGroup = ResolvedNavItem[] | undefined | string | boolean | number;
121
132
  export declare type NavGroupRecord = Record<string, NavGroup>;
122
133
  export declare type ResolvedConfigLinks = NavGroup | NavGroupRecord;
134
+ export declare type RawNavConfigItem = RawNavItem | RawNavItem[] | string | undefined | boolean | number;
135
+ export declare type RawNavConfig = RawNavConfigItem | Record<string, RawNavConfigItem>;
@@ -1,10 +1,10 @@
1
1
  export declare function getPageDataUrl(normalizedRoute: string): string;
2
2
  export declare function getClientPageDataUrl(normalizedRoute: string): string;
3
- export declare function getSidebarUrl(id: string): string;
4
3
  export declare function getSharedDataUrl(id: string): string;
5
4
  export declare const GLOBAL_DATA_URL = "/app-data.json";
6
5
  export declare const SEARCH_DATA_URL = "/search-data.json";
7
6
  export declare const SEARCH_INDEX_URL = "/search-index.json";
7
+ export declare const EJECT_COMPONENT_URL = "/eject-component";
8
8
  export declare function combineUrls(baseURL: string, ...relativeURLs: string[]): string;
9
9
  export declare function withPathPrefix(url: string): string;
10
10
  export declare function withoutHash(url: string): string;
@@ -14,3 +14,5 @@ export declare function getGlobMatcher(glob: Glob, options?: {}): (file: string)
14
14
  export declare function isTag(value?: any): value is Tag;
15
15
  export declare function isNode(value?: any): value is Node;
16
16
  export declare const getCssPropertyValue: (name: string) => string;
17
+ export declare function normalizeRoute(route: string): string;
18
+ export declare function isPrimitive(arg: any): arg is string | boolean | number;
@@ -0,0 +1,36 @@
1
+ import React, { MouseEventHandler } from 'react';
2
+ import styled from 'styled-components';
3
+
4
+ export interface BurgerProps {
5
+ onClick: MouseEventHandler;
6
+ className?: string;
7
+ }
8
+
9
+ function BurgerComponent({ onClick, className }: BurgerProps): JSX.Element {
10
+ return (
11
+ <Button onClick={onClick} className={className} data-component-name="ui/Burger">
12
+ <Line></Line>
13
+ <Line></Line>
14
+ <Line></Line>
15
+ </Button>
16
+ );
17
+ }
18
+
19
+ const Button = styled.button`
20
+ all: unset;
21
+ max-width: 30px;
22
+ width: 100%;
23
+ min-width: 10px;
24
+ display: block;
25
+ cursor: pointer;
26
+ `;
27
+
28
+ const Line = styled.div`
29
+ margin: 4px 0;
30
+ width: 100%;
31
+ height: 2px;
32
+ background: #fff;
33
+ border-radius: 1px;
34
+ `;
35
+
36
+ export const Burger = styled(BurgerComponent)``;
package/src/ui/Flex.tsx CHANGED
@@ -8,6 +8,7 @@ export interface FlexProps extends FlexboxProps, WidthProps {}
8
8
 
9
9
  export const Flex = styled(Box).attrs({ 'data-component-name': 'ui/Flex' })<FlexProps>`
10
10
  display: flex;
11
+ flex-wrap: wrap;
11
12
  ${flexbox}
12
13
  ${width}
13
14
  `;
@@ -0,0 +1,9 @@
1
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
2
+ export function isEmptyArray(items: any): boolean {
3
+ return Array.isArray(items) && !items?.length;
4
+ }
5
+
6
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
7
+ export function isPrimitive(arg: any): boolean {
8
+ return ['string', 'boolean', 'number'].includes(typeof arg);
9
+ }
@@ -0,0 +1,8 @@
1
+ const SPACE_DELIMITER = ' ';
2
+
3
+ export function concatClassNames(...args: Array<string | undefined>): string {
4
+ return args
5
+ .map((className) => (className ? className.trim() : className))
6
+ .filter(Boolean)
7
+ .join(SPACE_DELIMITER);
8
+ }
@@ -0,0 +1,9 @@
1
+ export const getRandomNumber = (limit: number): number => Math.floor(Math.random() * limit);
2
+
3
+ export function getRandomColor(): string {
4
+ const h = getRandomNumber(360);
5
+ const s = getRandomNumber(100);
6
+ const l = getRandomNumber(100);
7
+
8
+ return `hsl(${h}deg, ${s}%, ${l}%)`;
9
+ }
@@ -22,6 +22,7 @@ import 'prismjs/components/prism-swift.js';
22
22
  import 'prismjs/components/prism-graphql.js';
23
23
 
24
24
  const DEFAULT_LANG = 'clike';
25
+ const NEW_LINE_EXP = /\n(?!$)/g;
25
26
 
26
27
  Prism.languages.insertBefore(
27
28
  'javascript',
@@ -79,3 +80,13 @@ export function highlight(source: string | number | boolean, lang: string = DEFA
79
80
  }
80
81
  return Prism.highlight(source.toString(), grammar, lang);
81
82
  }
83
+
84
+ export function addLineNumbers(highlightedCode: string, start = 1): string {
85
+ const codeLines = highlightedCode.split(NEW_LINE_EXP);
86
+
87
+ return codeLines
88
+ .map((line, i) => {
89
+ return `<span class="code-line" data-line-number=${start + i}>${line}</span>`;
90
+ })
91
+ .join('\n');
92
+ }
@@ -4,3 +4,6 @@ export * from './highlight';
4
4
  export * from './jsonToHtml';
5
5
  export * from './media-css';
6
6
  export * from './theme-helpers';
7
+ export * from './class-names';
8
+ export * from './args-typecheck';
9
+ export * from './color';