@redocly/theme 0.58.0-next.7 → 0.58.0-next.9

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.
@@ -11,6 +11,7 @@ const utils_1 = require("../../core/utils");
11
11
  const hooks_1 = require("../../core/hooks");
12
12
  const H2_1 = require("../../components/Typography/H2");
13
13
  const FilterContent_1 = require("../../components/Filter/FilterContent");
14
+ const FilterInput_1 = require("../../components/Filter/FilterInput");
14
15
  const FilterPopover_1 = require("../../components/Filter/FilterPopover");
15
16
  const CatalogClassicHighlight_1 = require("../../components/CatalogClassic/CatalogClassicHighlight");
16
17
  const CatalogClassicActions_1 = require("../../components/CatalogClassic/CatalogClassicActions");
@@ -25,7 +26,7 @@ function CatalogClassic(props) {
25
26
  (0, hooks_1.useModalScrollLock)(filterPopoverVisible);
26
27
  return (react_1.default.createElement(CatalogClassicHighlight_1.HighlightContext.Provider, { value: [filterTerm] },
27
28
  react_1.default.createElement(exports.CatalogPageWrapper, { "data-component-name": "CatalogClassic/CatalogClassic", withoutFilters: !filters.length },
28
- react_1.default.createElement(FiltersSidebar, { menu: react_1.default.createElement(FilterContent_1.FilterContent, { setFilterTerm: setFilterTerm, filters: filters, filterTerm: filterTerm, filterValuesCasing: catalogConfig.filterValuesCasing }) }),
29
+ Boolean(filters.length) && (react_1.default.createElement(FiltersSidebar, { menu: react_1.default.createElement(FilterContent_1.FilterContent, { setFilterTerm: setFilterTerm, filters: filters, filterTerm: filterTerm, filterValuesCasing: catalogConfig.filterValuesCasing }) })),
29
30
  filterPopoverVisible && (react_1.default.createElement(FilterPopover_1.FilterPopover, { onClose: () => setFilterPopoverVisible(false), setFilterTerm: setFilterTerm, filterTerm: filterTerm, filters: filters, filterValuesCasing: catalogConfig.filterValuesCasing })),
30
31
  react_1.default.createElement(CatalogClassicActions_1.CatalogClassicActions, { onOpenFilter: () => setFilterPopoverVisible(true), filters: filters, filterTerm: filterTerm }),
31
32
  react_1.default.createElement(exports.CatalogPageContent, null,
@@ -37,7 +38,9 @@ function CatalogClassic(props) {
37
38
  catalogConfig.description ? (react_1.default.createElement(exports.CatalogDescription, { "data-translation-key": catalogConfig.descriptionTranslationKey },
38
39
  ' ',
39
40
  translate(catalogConfig.descriptionTranslationKey, catalogConfig.description),
40
- ' ')) : null),
41
+ ' ')) : null,
42
+ !filters.length && (react_1.default.createElement(CatalogSearchWrapper, null,
43
+ react_1.default.createElement(FilterInput_1.FilterInput, { value: filterTerm, onChange: (updatedTerm) => setFilterTerm(updatedTerm) })))),
41
44
  react_1.default.createElement(CatalogClassicVirtualizedGroups_1.CatalogClassicVirtualizedGroups, { groups: groups, filters: filters, filterTerm: filterTerm })))));
42
45
  }
43
46
  exports.CatalogPageContent = styled_components_1.default.main `
@@ -110,4 +113,8 @@ const FiltersSidebar = (0, styled_components_1.default)(Sidebar_1.Sidebar) `
110
113
  }
111
114
  --menu-container-padding-top: 0;
112
115
  `;
116
+ const CatalogSearchWrapper = styled_components_1.default.div `
117
+ margin-top: var(--spacing-base);
118
+ max-width: 300px;
119
+ `;
113
120
  //# sourceMappingURL=CatalogClassic.js.map
@@ -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';
@@ -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[];
@@ -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.7",
3
+ "version": "0.58.0-next.9",
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.4"
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\")",
@@ -8,6 +8,7 @@ import { breakpoints } from '@redocly/theme/core/utils';
8
8
  import { useThemeHooks, useModalScrollLock } from '@redocly/theme/core/hooks';
9
9
  import { H2 } from '@redocly/theme/components/Typography/H2';
10
10
  import { FilterContent } from '@redocly/theme/components/Filter/FilterContent';
11
+ import { FilterInput } from '@redocly/theme/components/Filter/FilterInput';
11
12
  import { FilterPopover } from '@redocly/theme/components/Filter/FilterPopover';
12
13
  import { HighlightContext } from '@redocly/theme/components/CatalogClassic/CatalogClassicHighlight';
13
14
  import { CatalogClassicActions } from '@redocly/theme/components/CatalogClassic/CatalogClassicActions';
@@ -37,16 +38,18 @@ export default function CatalogClassic(props: CatalogClassicProps): JSX.Element
37
38
  data-component-name="CatalogClassic/CatalogClassic"
38
39
  withoutFilters={!filters.length}
39
40
  >
40
- <FiltersSidebar
41
- menu={
42
- <FilterContent
43
- setFilterTerm={setFilterTerm}
44
- filters={filters}
45
- filterTerm={filterTerm}
46
- filterValuesCasing={catalogConfig.filterValuesCasing}
47
- />
48
- }
49
- />
41
+ {Boolean(filters.length) && (
42
+ <FiltersSidebar
43
+ menu={
44
+ <FilterContent
45
+ setFilterTerm={setFilterTerm}
46
+ filters={filters}
47
+ filterTerm={filterTerm}
48
+ filterValuesCasing={catalogConfig.filterValuesCasing}
49
+ />
50
+ }
51
+ />
52
+ )}
50
53
  {filterPopoverVisible && (
51
54
  <FilterPopover
52
55
  onClose={() => setFilterPopoverVisible(false)}
@@ -75,6 +78,14 @@ export default function CatalogClassic(props: CatalogClassicProps): JSX.Element
75
78
  {translate(catalogConfig.descriptionTranslationKey, catalogConfig.description)}{' '}
76
79
  </CatalogDescription>
77
80
  ) : null}
81
+ {!filters.length && (
82
+ <CatalogSearchWrapper>
83
+ <FilterInput
84
+ value={filterTerm}
85
+ onChange={(updatedTerm) => setFilterTerm(updatedTerm)}
86
+ />
87
+ </CatalogSearchWrapper>
88
+ )}
78
89
  </CatalogPageDescriptionWrapper>
79
90
 
80
91
  <CatalogClassicVirtualizedGroups
@@ -163,3 +174,8 @@ const FiltersSidebar = styled(Sidebar)`
163
174
  }
164
175
  --menu-container-padding-top: 0;
165
176
  `;
177
+
178
+ const CatalogSearchWrapper = styled.div`
179
+ margin-top: var(--spacing-base);
180
+ max-width: 300px;
181
+ `;
@@ -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';
@@ -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
 
@@ -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,