@redocly/theme 0.58.0-next.6 → 0.58.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.
@@ -1,5 +1,5 @@
1
1
  export type { UserClaims } from '../types/user-claims';
2
- export type { SearchDocument, SearchItemData, OperationParameter } from '../types/search';
2
+ export type { OperationParameter, ParameterHighlight } from '../types/search';
3
3
  export type { TFunction, TOptions } from '../types/l10n';
4
4
  export type { SelectOption, SelectProps } from '../types/select';
5
5
  export { IS_BROWSER } from '../utils/dom';
@@ -16,3 +16,4 @@ export * from './open-api-server';
16
16
  export * from './marker';
17
17
  export * from './code-walkthrough';
18
18
  export * from './page-actions';
19
+ export * from './open-api-info';
@@ -32,4 +32,5 @@ __exportStar(require("./open-api-server"), exports);
32
32
  __exportStar(require("./marker"), exports);
33
33
  __exportStar(require("./code-walkthrough"), exports);
34
34
  __exportStar(require("./page-actions"), exports);
35
+ __exportStar(require("./open-api-info"), exports);
35
36
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,34 @@
1
+ export type OpenAPIInfo = {
2
+ title: string;
3
+ version: string;
4
+ description?: string;
5
+ summary?: string;
6
+ termsOfService?: string;
7
+ contact?: {
8
+ name?: string;
9
+ url?: string;
10
+ email?: string;
11
+ };
12
+ license?: {
13
+ name: string;
14
+ url?: string;
15
+ identifier?: string;
16
+ };
17
+ externalDocs?: {
18
+ description?: string;
19
+ url: string;
20
+ };
21
+ 'x-logo'?: {
22
+ url?: string;
23
+ backgroundColor?: string;
24
+ altText?: string;
25
+ href?: string;
26
+ };
27
+ 'x-metadata'?: {
28
+ apiId?: string;
29
+ [key: string]: unknown;
30
+ };
31
+ 'x-seo'?: {
32
+ title?: string;
33
+ };
34
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=open-api-info.js.map
@@ -13,7 +13,7 @@ export type OperationParameter = {
13
13
  example: string | undefined;
14
14
  enum: string[] | undefined;
15
15
  };
16
- export type SearchDocument = {
16
+ export type SearchHit = {
17
17
  id: string;
18
18
  url: string;
19
19
  title: string | string[];
@@ -24,7 +24,6 @@ export type SearchDocument = {
24
24
  deprecated?: boolean;
25
25
  security?: string[];
26
26
  parameters?: OperationParameter[];
27
- metadata?: Record<string, any>;
28
27
  version?: string;
29
28
  versionFolderId?: string;
30
29
  isDefaultVersion?: boolean;
@@ -48,7 +47,7 @@ export type ParameterHighlight = {
48
47
  path: string[];
49
48
  };
50
49
  export type SearchItemData = {
51
- document: SearchDocument;
50
+ document: SearchHit;
52
51
  highlight: Record<string, string> & {
53
52
  parameters?: ParameterHighlight[];
54
53
  path?: string[];
@@ -1,5 +1,5 @@
1
1
  import type { ConfigureRequestValues, ConfigureServerRequestValues } from '../ext/configure';
2
- import type { UserClaims, OpenAPIServer } from '../core/types';
2
+ import type { UserClaims, OpenAPIServer, OpenAPIInfo } from '../core/types';
3
3
  type ContextProps = {
4
4
  operation: {
5
5
  name: string;
@@ -8,6 +8,7 @@ type ContextProps = {
8
8
  href: string;
9
9
  method: string;
10
10
  };
11
+ info: OpenAPIInfo;
11
12
  servers: OpenAPIServer[];
12
13
  userClaims: UserClaims;
13
14
  };
@@ -16,7 +16,8 @@ type TabsProps = {
16
16
  className?: string;
17
17
  size: TabsSize;
18
18
  forceReady?: boolean;
19
+ initialTab?: string;
19
20
  };
20
- export declare function Tabs({ children, className, size, forceReady }: TabsProps): JSX.Element;
21
+ export declare function Tabs({ children, className, size, forceReady, initialTab: propInitialTab, }: TabsProps): JSX.Element;
21
22
  export declare const TabContent: import("styled-components").StyledComponent<"div", any, {}, never>;
22
23
  export {};
@@ -34,7 +34,7 @@ var TabsSize;
34
34
  TabsSize["SMALL"] = "small";
35
35
  TabsSize["MEDIUM"] = "medium";
36
36
  })(TabsSize || (exports.TabsSize = TabsSize = {}));
37
- function Tabs({ children, className, size, forceReady = false }) {
37
+ function Tabs({ children, className, size, forceReady = false, initialTab: propInitialTab, }) {
38
38
  var _a, _b;
39
39
  const [childrenArray, setChildrenArray] = (0, react_1.useState)(react_1.default.Children.toArray(children));
40
40
  (0, react_1.useEffect)(() => {
@@ -42,7 +42,8 @@ function Tabs({ children, className, size, forceReady = false }) {
42
42
  }, [children]);
43
43
  const tabsContainerRef = (0, react_1.useRef)(null);
44
44
  const [isAnimating, setIsAnimating] = (0, react_1.useState)(false);
45
- const initialTab = (_b = (_a = childrenArray[0]) === null || _a === void 0 ? void 0 : _a.props.label) !== null && _b !== void 0 ? _b : '';
45
+ const defaultInitialTab = (_b = (_a = childrenArray[0]) === null || _a === void 0 ? void 0 : _a.props.label) !== null && _b !== void 0 ? _b : '';
46
+ const initialTab = propInitialTab !== null && propInitialTab !== void 0 ? propInitialTab : defaultInitialTab;
46
47
  const { activeTab, setTabRef, onTabClick, handleKeyboard, getTabId, visibleTabs, overflowTabs, ready, allTabsHidden, } = (0, hooks_1.useTabs)({
47
48
  initialTab,
48
49
  totalTabs: childrenArray.length,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/theme",
3
- "version": "0.58.0-next.6",
3
+ "version": "0.58.0-next.8",
4
4
  "description": "Shared UI components lib",
5
5
  "keywords": [
6
6
  "theme",
@@ -87,8 +87,8 @@
87
87
  "openapi-sampler": "1.6.1",
88
88
  "react-calendar": "5.1.0",
89
89
  "react-date-picker": "11.0.0",
90
- "@redocly/config": "0.34.0",
91
- "@redocly/realm-asyncapi-sdk": "0.4.0-next.2"
90
+ "@redocly/config": "0.35.0",
91
+ "@redocly/realm-asyncapi-sdk": "0.4.0-next.3"
92
92
  },
93
93
  "scripts": {
94
94
  "watch": "tsc -p tsconfig.build.json && (concurrently \"tsc -w -p tsconfig.build.json\" \"tsc-alias -w -p tsconfig.build.json\")",
@@ -5,7 +5,7 @@
5
5
  // the overall bundle size by avoiding importing the entire theme package
6
6
  // when only specific functionality is needed.
7
7
  export type { UserClaims } from '../types/user-claims';
8
- export type { SearchDocument, SearchItemData, OperationParameter } from '../types/search';
8
+ export type { OperationParameter, ParameterHighlight } from '../types/search';
9
9
  export type { TFunction, TOptions } from '../types/l10n';
10
10
  export type { SelectOption, SelectProps } from '../types/select';
11
11
  export { IS_BROWSER } from '../utils/dom';
@@ -16,3 +16,4 @@ export * from './open-api-server';
16
16
  export * from './marker';
17
17
  export * from './code-walkthrough';
18
18
  export * from './page-actions';
19
+ export * from './open-api-info';
@@ -0,0 +1,34 @@
1
+ export type OpenAPIInfo = {
2
+ title: string;
3
+ version: string;
4
+ description?: string;
5
+ summary?: string;
6
+ termsOfService?: string;
7
+ contact?: {
8
+ name?: string;
9
+ url?: string;
10
+ email?: string;
11
+ };
12
+ license?: {
13
+ name: string;
14
+ url?: string;
15
+ identifier?: string;
16
+ };
17
+ externalDocs?: {
18
+ description?: string;
19
+ url: string;
20
+ };
21
+ 'x-logo'?: {
22
+ url?: string;
23
+ backgroundColor?: string;
24
+ altText?: string;
25
+ href?: string;
26
+ };
27
+ 'x-metadata'?: {
28
+ apiId?: string;
29
+ [key: string]: unknown;
30
+ };
31
+ 'x-seo'?: {
32
+ title?: string;
33
+ };
34
+ };
@@ -15,7 +15,8 @@ export type OperationParameter = {
15
15
  enum: string[] | undefined;
16
16
  };
17
17
 
18
- export type SearchDocument = {
18
+ // TODO: review SearchHit type as it might contain properties that are not in the search results
19
+ export type SearchHit = {
19
20
  id: string;
20
21
  url: string;
21
22
  title: string | string[];
@@ -26,7 +27,6 @@ export type SearchDocument = {
26
27
  deprecated?: boolean;
27
28
  security?: string[];
28
29
  parameters?: OperationParameter[];
29
- metadata?: Record<string, any>;
30
30
  version?: string;
31
31
  versionFolderId?: string;
32
32
  isDefaultVersion?: boolean;
@@ -47,7 +47,7 @@ export type ParameterHighlight = {
47
47
  };
48
48
 
49
49
  export type SearchItemData = {
50
- document: SearchDocument;
50
+ document: SearchHit;
51
51
  highlight: Record<string, string> & { parameters?: ParameterHighlight[]; path?: string[] };
52
52
  };
53
53
 
@@ -4,7 +4,7 @@ import type {
4
4
  ConfigureRequestValues,
5
5
  ConfigureServerRequestValues,
6
6
  } from '@redocly/theme/ext/configure';
7
- import type { UserClaims, OpenAPIServer } from '@redocly/theme/core/types';
7
+ import type { UserClaims, OpenAPIServer, OpenAPIInfo } from '@redocly/theme/core/types';
8
8
 
9
9
  type ContextProps = {
10
10
  operation: {
@@ -14,6 +14,7 @@ type ContextProps = {
14
14
  href: string;
15
15
  method: string;
16
16
  };
17
+ info: OpenAPIInfo;
17
18
  servers: OpenAPIServer[];
18
19
  userClaims: UserClaims;
19
20
  };
@@ -24,9 +24,16 @@ type TabsProps = {
24
24
  className?: string;
25
25
  size: TabsSize;
26
26
  forceReady?: boolean;
27
+ initialTab?: string;
27
28
  };
28
29
 
29
- export function Tabs({ children, className, size, forceReady = false }: TabsProps): JSX.Element {
30
+ export function Tabs({
31
+ children,
32
+ className,
33
+ size,
34
+ forceReady = false,
35
+ initialTab: propInitialTab,
36
+ }: TabsProps): JSX.Element {
30
37
  const [childrenArray, setChildrenArray] = useState<React.ReactElement<TabItemProps>[]>(
31
38
  React.Children.toArray(children) as React.ReactElement<TabItemProps>[],
32
39
  );
@@ -36,7 +43,8 @@ export function Tabs({ children, className, size, forceReady = false }: TabsProp
36
43
  }, [children]);
37
44
  const tabsContainerRef = useRef<HTMLUListElement>(null);
38
45
  const [isAnimating, setIsAnimating] = useState<boolean>(false);
39
- const initialTab = childrenArray[0]?.props.label ?? '';
46
+ const defaultInitialTab = childrenArray[0]?.props.label ?? '';
47
+ const initialTab = propInitialTab ?? defaultInitialTab;
40
48
  const {
41
49
  activeTab,
42
50
  setTabRef,