@redocly/theme 0.60.0 → 0.61.0-next.1

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 (45) hide show
  1. package/lib/components/Catalog/Catalog.js +12 -2
  2. package/lib/components/Catalog/CatalogEntities.js +18 -2
  3. package/lib/components/Catalog/CatalogEntity/CatalogEntity.js +10 -7
  4. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.d.ts +1 -1
  5. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.js +25 -2
  6. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTableContent.d.ts +2 -1
  7. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTableContent.js +2 -2
  8. package/lib/components/Catalog/CatalogEntity/CatalogEntitySchema.d.ts +4 -2
  9. package/lib/components/Catalog/CatalogEntity/CatalogEntitySchema.js +11 -3
  10. package/lib/components/Catalog/CatalogFilter/CatalogFilterCheckboxes.js +7 -1
  11. package/lib/components/Catalog/CatalogFilter/CatalogFilterContent.d.ts +2 -3
  12. package/lib/components/Catalog/CatalogFilter/CatalogFilterContent.js +4 -43
  13. package/lib/components/Catalog/CatalogSelector.d.ts +3 -4
  14. package/lib/components/Catalog/CatalogSelector.js +2 -3
  15. package/lib/components/Catalog/CatalogTableView/CatalogTableView.d.ts +2 -1
  16. package/lib/components/Catalog/CatalogTableView/CatalogTableView.js +2 -2
  17. package/lib/components/Catalog/CatalogTableView/CatalogTableViewRow.d.ts +2 -1
  18. package/lib/components/Catalog/CatalogTableView/CatalogTableViewRow.js +3 -5
  19. package/lib/components/Product/ProductPicker.js +1 -0
  20. package/lib/core/hooks/catalog/use-catalog-entity-details.d.ts +11 -0
  21. package/lib/core/hooks/catalog/{use-catalog-table-view-row.js → use-catalog-entity-details.js} +9 -9
  22. package/lib/core/hooks/index.d.ts +1 -1
  23. package/lib/core/hooks/index.js +1 -1
  24. package/lib/core/types/catalog.d.ts +23 -10
  25. package/lib/core/types/hooks.d.ts +5 -11
  26. package/lib/core/utils/urls.js +7 -3
  27. package/package.json +2 -2
  28. package/src/components/Catalog/Catalog.tsx +11 -9
  29. package/src/components/Catalog/CatalogEntities.tsx +24 -3
  30. package/src/components/Catalog/CatalogEntity/CatalogEntity.tsx +21 -9
  31. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.tsx +27 -0
  32. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTableContent.tsx +3 -0
  33. package/src/components/Catalog/CatalogEntity/CatalogEntitySchema.tsx +18 -3
  34. package/src/components/Catalog/CatalogFilter/CatalogFilterCheckboxes.tsx +7 -1
  35. package/src/components/Catalog/CatalogFilter/CatalogFilterContent.tsx +6 -17
  36. package/src/components/Catalog/CatalogSelector.tsx +4 -7
  37. package/src/components/Catalog/CatalogTableView/CatalogTableView.tsx +3 -0
  38. package/src/components/Catalog/CatalogTableView/CatalogTableViewRow.tsx +6 -5
  39. package/src/components/Product/ProductPicker.tsx +1 -0
  40. package/src/core/hooks/catalog/{use-catalog-table-view-row.ts → use-catalog-entity-details.ts} +11 -15
  41. package/src/core/hooks/index.ts +1 -1
  42. package/src/core/types/catalog.ts +32 -10
  43. package/src/core/types/hooks.ts +6 -24
  44. package/src/core/utils/urls.ts +10 -3
  45. package/lib/core/hooks/catalog/use-catalog-table-view-row.d.ts +0 -11
@@ -1,11 +1,26 @@
1
1
  import { InfiniteData, UseInfiniteQueryResult } from '@tanstack/react-query';
2
2
  import { ENTITY_RELATION_TYPES } from '@redocly/config';
3
3
 
4
- import type { CatalogEntityConfig, LayoutVariant } from '@redocly/config';
4
+ import type { CatalogEntityConfig, EntitiesCatalogConfig, LayoutVariant } from '@redocly/config';
5
5
  import type { CatalogFilterConfig } from '@redocly/theme/config';
6
6
 
7
7
  export type SortOption = 'title' | '-title' | 'type' | '-type';
8
8
 
9
+ export type FilterResult = {
10
+ value: string;
11
+ count: number;
12
+ };
13
+
14
+ export type CatalogFiltersWithCounts = Record<string, FilterResult[]>;
15
+
16
+ export type UseCatalogProps = {
17
+ config?: CatalogEntityConfig;
18
+ entitiesCatalogConfig?: EntitiesCatalogConfig;
19
+ serverFilters?: CatalogFiltersWithCounts;
20
+ entitiesCounterInitial?: number;
21
+ initialViewMode?: CatalogViewMode;
22
+ };
23
+
9
24
  export type UseCatalogResponse = {
10
25
  filters: ResolvedFilter[];
11
26
  filterQuery: string;
@@ -25,6 +40,16 @@ export type UseCatalogResponse = {
25
40
  collapsedSidebar: boolean;
26
41
  };
27
42
 
43
+ export type UseCatalogFetchCatalogEntities = (
44
+ params: CatalogApiParams,
45
+ initialData?: BffCatalogEntityList,
46
+ ) => CatalogApiResults<BffCatalogEntity>;
47
+
48
+ export type UseCatalogFetchCatalogEntitiesRelations = (
49
+ params: CatalogApiParams & { entityKey: string },
50
+ initialData?: BffCatalogRelatedEntityList,
51
+ ) => CatalogApiResults<BffCatalogRelatedEntity>;
52
+
28
53
  export type UseCatalogSortResponse = {
29
54
  sortOption: SortOption | null;
30
55
  setSortOption: (option: SortOption | null) => void;
@@ -92,8 +117,8 @@ export type DefaultCatalogSlug =
92
117
  | 'api-descriptions'
93
118
  | 'all';
94
119
 
95
- export type CatalogApiResults<T, L> = {
96
- query: UseInfiniteQueryResult<InfiniteData<L, unknown>, Error>;
120
+ export type CatalogApiResults<T> = {
121
+ query: UseInfiniteQueryResult<InfiniteData<BffCatalogList<T>, unknown>, Error>;
97
122
  items: T[];
98
123
  total: number;
99
124
  };
@@ -186,17 +211,14 @@ export type BffCatalogEntity = {
186
211
  readonly updatedAt: string;
187
212
  };
188
213
 
189
- export type BffCatalogEntityList = {
214
+ export type BffCatalogList<T> = {
190
215
  object: 'list';
191
216
  page: Page;
192
- items: Array<BffCatalogEntity>;
217
+ items: Array<T>;
193
218
  };
194
219
 
195
- export type BffCatalogRelatedEntityList = {
196
- object: 'list';
197
- page: Page;
198
- items: Array<BffCatalogRelatedEntity>;
199
- };
220
+ export type BffCatalogEntityList = BffCatalogList<BffCatalogEntity>;
221
+ export type BffCatalogRelatedEntityList = BffCatalogList<BffCatalogRelatedEntity>;
200
222
 
201
223
  export type Page = {
202
224
  endCursor: string | null;
@@ -1,7 +1,6 @@
1
1
  import type { AsyncApiRealmUI } from '@redocly/realm-asyncapi-sdk';
2
2
  import type {
3
3
  BannerConfig,
4
- CatalogEntityConfig,
5
4
  PageData,
6
5
  PageProps,
7
6
  ResolvedNavItemWithLink,
@@ -13,12 +12,12 @@ import type { To, Location, NavigateFunction } from 'react-router-dom';
13
12
  import type { CatalogConfig, ProductUiConfig } from '@redocly/theme/config';
14
13
  import type {
15
14
  UseCatalogResponse,
16
- CatalogApiResults,
17
- CatalogApiParams,
18
15
  FilteredCatalog,
19
16
  UseCatalogSortResponse,
20
17
  UseCatalogSearchResponse,
21
- CatalogViewMode,
18
+ UseCatalogProps,
19
+ UseCatalogFetchCatalogEntities,
20
+ UseCatalogFetchCatalogEntitiesRelations,
22
21
  } from './catalog';
23
22
  import type { UserMenuData } from './user-menu';
24
23
  import type { ItemState } from './sidebar';
@@ -34,12 +33,6 @@ import type { TFunction } from './l10n';
34
33
  import type { BreadcrumbItem } from './breadcrumb';
35
34
  import type { DrilldownMenuItemDetails } from './sidebar';
36
35
 
37
- import {
38
- BffCatalogEntity,
39
- BffCatalogEntityList,
40
- BffCatalogRelatedEntity,
41
- BffCatalogRelatedEntityList,
42
- } from './catalog';
43
36
  import { AiSearchError } from '../constants/search';
44
37
 
45
38
  export type ThemeHooks = {
@@ -151,22 +144,11 @@ export type ThemeHooks = {
151
144
  nextPage?: ResolvedNavItemWithLink;
152
145
  }
153
146
  | undefined;
154
- useCatalog: (
155
- config?: CatalogEntityConfig,
156
- serverFilters?: Record<string, { value: string; count: number }[]>,
157
- entitiesCounterInitial?: number,
158
- initialViewMode?: CatalogViewMode,
159
- ) => UseCatalogResponse;
147
+ useCatalog: (props?: UseCatalogProps) => UseCatalogResponse;
160
148
  useCatalogSort: () => UseCatalogSortResponse;
161
149
  useCatalogSearch: () => UseCatalogSearchResponse;
162
- useFetchCatalogEntities: (
163
- params: CatalogApiParams,
164
- initialData?: BffCatalogEntityList,
165
- ) => CatalogApiResults<BffCatalogEntity, BffCatalogEntityList>;
166
- useFetchCatalogEntitiesRelations: (
167
- params: CatalogApiParams & { entityKey: string },
168
- initialData?: BffCatalogRelatedEntityList,
169
- ) => CatalogApiResults<BffCatalogRelatedEntity, BffCatalogRelatedEntityList>;
150
+ useFetchCatalogEntities: UseCatalogFetchCatalogEntities;
151
+ useFetchCatalogEntitiesRelations: UseCatalogFetchCatalogEntitiesRelations;
170
152
  useCatalogClassic: (config: CatalogConfig) => FilteredCatalog;
171
153
  useTelemetry: () => Omit<
172
154
  AsyncApiRealmUI.Telemetry,
@@ -19,9 +19,16 @@ export function withPathPrefix(url: string) {
19
19
 
20
20
  export function withoutPathPrefix(pathname: string) {
21
21
  const pathPrefix = getPathPrefix();
22
- return pathPrefix && pathname.startsWith(pathPrefix)
23
- ? pathname.slice(pathPrefix.length)
24
- : pathname;
22
+
23
+ if (!pathPrefix) {
24
+ return pathname;
25
+ }
26
+
27
+ if (pathPrefix === pathname) {
28
+ return '/';
29
+ }
30
+
31
+ return pathname.startsWith(pathPrefix) ? pathname.slice(pathPrefix.length) : pathname;
25
32
  }
26
33
 
27
34
  export function withoutHash(url: undefined | null): undefined;
@@ -1,11 +0,0 @@
1
- import type { CatalogEntityConfig, EntitiesCatalogConfig } from '@redocly/config';
2
- type CatalogTableViewRowProps = {
3
- entityKey: string;
4
- entityType: string;
5
- catalogConfig: CatalogEntityConfig;
6
- entitiesCatalogConfig?: EntitiesCatalogConfig;
7
- };
8
- export declare function useCatalogTableViewRow({ entityKey, entityType, catalogConfig, entitiesCatalogConfig, }: CatalogTableViewRowProps): {
9
- getEntityDetailsLink: () => string;
10
- };
11
- export {};