@redocly/theme 0.57.0 → 0.58.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 (67) hide show
  1. package/lib/components/Buttons/CopyButton.d.ts +1 -0
  2. package/lib/components/Buttons/CopyButton.js +3 -3
  3. package/lib/components/Catalog/Catalog.js +14 -2
  4. package/lib/components/Catalog/CatalogEntitiesEmptyState.d.ts +2 -1
  5. package/lib/components/Catalog/CatalogEntitiesEmptyState.js +32 -11
  6. package/lib/components/Catalog/CatalogEntity/CatalogEntity.d.ts +3 -7
  7. package/lib/components/Catalog/CatalogEntity/CatalogEntity.js +13 -7
  8. package/lib/components/Catalog/CatalogEntity/CatalogEntityMetadata.js +6 -6
  9. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityProperties.js +6 -10
  10. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/ContactProperty.js +5 -1
  11. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.d.ts +23 -0
  12. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.js +27 -0
  13. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations.d.ts +3 -2
  14. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations.js +2 -2
  15. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.js +11 -2
  16. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.d.ts +2 -1
  17. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.js +1 -1
  18. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTableContent.d.ts +2 -1
  19. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.js +2 -8
  20. package/lib/components/Catalog/CatalogEntity/CatalogEntitySchema.d.ts +5 -2
  21. package/lib/components/Catalog/CatalogEntity/CatalogEntitySchema.js +64 -30
  22. package/lib/components/Catalog/CatalogTableView/CatalogEntityRelationCell.d.ts +1 -1
  23. package/lib/components/Catalog/CatalogTableView/CatalogEntityRelationCell.js +2 -2
  24. package/lib/components/Catalog/variables.js +1 -1
  25. package/lib/components/Filter/FilterContent.d.ts +1 -1
  26. package/lib/components/Tooltip/Tooltip.js +6 -6
  27. package/lib/core/constants/catalog.d.ts +1 -0
  28. package/lib/core/constants/catalog.js +28 -1
  29. package/lib/core/hooks/catalog/useCatalogEntitySchema.d.ts +11 -0
  30. package/lib/core/hooks/catalog/useCatalogEntitySchema.js +39 -0
  31. package/lib/core/types/catalog.d.ts +7 -0
  32. package/lib/core/types/filter.d.ts +1 -1
  33. package/lib/core/utils/change-text-casing.d.ts +1 -1
  34. package/lib/core/utils/change-text-casing.js +3 -0
  35. package/lib/ext/configure.d.ts +1 -0
  36. package/lib/ext/configure.js +4 -1
  37. package/lib/ext/useConfigureReplay.d.ts +18 -0
  38. package/lib/ext/useConfigureReplay.js +64 -0
  39. package/package.json +4 -3
  40. package/src/components/Buttons/CopyButton.tsx +4 -1
  41. package/src/components/Catalog/Catalog.tsx +15 -2
  42. package/src/components/Catalog/CatalogEntitiesEmptyState.tsx +39 -16
  43. package/src/components/Catalog/CatalogEntity/CatalogEntity.tsx +42 -14
  44. package/src/components/Catalog/CatalogEntity/CatalogEntityMetadata.tsx +8 -6
  45. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityProperties.tsx +15 -14
  46. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/ContactProperty.tsx +6 -1
  47. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.tsx +125 -0
  48. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations.tsx +5 -1
  49. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.tsx +30 -3
  50. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.tsx +4 -3
  51. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTableContent.tsx +3 -1
  52. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.tsx +1 -13
  53. package/src/components/Catalog/CatalogEntity/CatalogEntitySchema.tsx +71 -23
  54. package/src/components/Catalog/CatalogTableView/CatalogEntityRelationCell.tsx +3 -3
  55. package/src/components/Catalog/variables.ts +1 -1
  56. package/src/components/Filter/FilterContent.tsx +3 -1
  57. package/src/components/Tooltip/Tooltip.tsx +6 -6
  58. package/src/core/constants/catalog.ts +28 -0
  59. package/src/core/hooks/catalog/useCatalogEntitySchema.ts +46 -0
  60. package/src/core/types/catalog.ts +9 -0
  61. package/src/core/types/filter.ts +3 -1
  62. package/src/core/utils/change-text-casing.ts +8 -1
  63. package/src/ext/configure.ts +5 -1
  64. package/src/ext/useConfigureReplay.ts +83 -0
  65. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/ApiDescriptionProperty.d.ts +0 -6
  66. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/ApiDescriptionProperty.js +0 -32
  67. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/ApiDescriptionProperty.tsx +0 -46
@@ -1,14 +1,26 @@
1
1
  "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
12
24
  };
13
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -17,39 +29,61 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
29
  exports.CatalogEntitySchema = CatalogEntitySchema;
18
30
  const react_1 = __importDefault(require("react"));
19
31
  const styled_components_1 = __importDefault(require("styled-components"));
32
+ const Sampler = __importStar(require("openapi-sampler"));
20
33
  const hooks_1 = require("../../../core/hooks");
34
+ const useCatalogEntitySchema_1 = require("../../../core/hooks/catalog/useCatalogEntitySchema");
21
35
  const JsonViewer_1 = require("../../../components/JsonViewer/JsonViewer");
22
- function CatalogEntitySchema({ entity }) {
36
+ const CopyButton_1 = require("../../../components/Buttons/CopyButton");
37
+ function CatalogEntitySchema({ entity, relatedEntity, RedocSchema, StoreProvider, }) {
23
38
  const { useTranslate } = (0, hooks_1.useThemeHooks)();
24
39
  const { translate } = useTranslate();
25
- const _a = entity.metadata || {}, { schema } = _a, metadataToShow = __rest(_a, ["schema"]);
26
- const metadata = Object.entries(metadataToShow);
27
- if (!metadata.length) {
28
- return null;
29
- }
30
- let parsedSchema;
31
- try {
32
- parsedSchema = JSON.parse(schema);
33
- }
34
- catch (error) {
35
- return null;
36
- }
40
+ const { definition, parsedSchema, rawSchema } = (0, useCatalogEntitySchema_1.useCatalogEntitySchema)({ entity, relatedEntity });
37
41
  return (react_1.default.createElement(MetadataWrapper, { "data-component-name": "Catalog/CatalogEntity/CatalogEntityMetadata" },
38
- react_1.default.createElement(Heading, null, translate('catalog.entity.metadata.title')),
39
- react_1.default.createElement(JsonViewer_1.JsonViewer, { data: parsedSchema, expandLevel: 3, title: "JSON" })));
42
+ react_1.default.createElement(HeaderWrapper, null,
43
+ react_1.default.createElement(Heading, null, translate('catalog.entity.schema.title')),
44
+ react_1.default.createElement(CopyButton_1.CopyButton, { data: rawSchema, buttonText: "Copy Schema", type: "compound", variant: "secondary", iconPosition: "right", size: "medium" })),
45
+ react_1.default.createElement(SplitViewWrapper, null,
46
+ react_1.default.createElement(SchemaContentWrapper, null,
47
+ react_1.default.createElement(StoreProvider, { definition: definition },
48
+ react_1.default.createElement(RedocSchema, { schema: parsedSchema }))),
49
+ react_1.default.createElement(SchemaSampleWrapper, null,
50
+ react_1.default.createElement(JsonViewer_1.JsonViewer, { data: Sampler.sample(Object.assign({}, parsedSchema)), expandLevel: 3, hideHeader: false })))));
40
51
  }
41
52
  const MetadataWrapper = styled_components_1.default.div `
42
53
  display: flex;
43
54
  flex-direction: column;
44
- gap: var(--spacing-xs);
45
55
  border-radius: var(--border-radius);
46
56
  background-color: var(--catalog-metadata-bg-color);
47
- transition: all 0.2s ease-in-out;
48
- margin: var(--spacing-lg) 0;
57
+ margin-top: var(--spacing-base);
58
+ margin-bottom: var(--spacing-xs);
59
+ `;
60
+ const SchemaContentWrapper = styled_components_1.default.div `
61
+ flex: 1;
62
+ & > div > div {
63
+ padding-left: 0;
64
+ padding-top: 0;
65
+ }
66
+ `;
67
+ const HeaderWrapper = styled_components_1.default.div `
68
+ display: flex;
69
+ align-items: center;
70
+ justify-content: space-between;
71
+ gap: var(--spacing-sm);
49
72
  `;
50
73
  const Heading = styled_components_1.default.h2 `
51
- margin-bottom: var(--spacing-base);
52
- margin-top: 0;
53
74
  font-size: var(--catalog-metadata-heading-size);
54
75
  `;
76
+ const SplitViewWrapper = styled_components_1.default.div `
77
+ display: flex;
78
+ justify-content: space-between;
79
+ align-items: flex-start;
80
+ gap: var(--spacing-base);
81
+ `;
82
+ const SchemaSampleWrapper = styled_components_1.default.div `
83
+ flex: 1;
84
+ position: sticky;
85
+ top: calc(var(--navbar-height) + var(--spacing-md));
86
+ align-self: flex-start;
87
+ padding-top: var(--spacing-sm);
88
+ `;
55
89
  //# sourceMappingURL=CatalogEntitySchema.js.map
@@ -1,3 +1,3 @@
1
1
  import type { BffCatalogRelatedEntity } from '../../../core/types';
2
2
  export type CatalogEntityRelationCellProps = Pick<BffCatalogRelatedEntity, 'relationType' | 'relationRole'>;
3
- export declare function CatalogEntityRelationCell({ relationType, relationRole, }: CatalogEntityRelationCellProps): "partOf" | "hasParts" | "creates" | "createdBy" | "owns" | "ownedBy" | "implements" | "implementedBy" | "dependsOn" | "dependencyOf" | "uses" | "usedBy" | "produces" | "consumes" | "linksTo" | "supersedes" | "supersededBy" | "compatibleWith" | "extends" | "extendedBy" | "relatesTo" | "hasMember" | "memberOf" | "triggers" | "triggeredBy";
3
+ export declare function CatalogEntityRelationCell({ relationType, relationRole, }: CatalogEntityRelationCellProps): string;
@@ -4,8 +4,8 @@ exports.CatalogEntityRelationCell = CatalogEntityRelationCell;
4
4
  const constants_1 = require("../../../core/constants");
5
5
  function CatalogEntityRelationCell({ relationType, relationRole, }) {
6
6
  if (relationRole === 'source') {
7
- return constants_1.reverseRelationMap[relationType];
7
+ return constants_1.relationTypeMap[constants_1.reverseRelationMap[relationType]];
8
8
  }
9
- return relationType;
9
+ return constants_1.relationTypeMap[relationType];
10
10
  }
11
11
  //# sourceMappingURL=CatalogEntityRelationCell.js.map
@@ -15,7 +15,7 @@ exports.catalog = (0, styled_components_1.css) `
15
15
  --catalog-filter-padding-vertical-mobile: 0;
16
16
  --catalog-filter-padding-horizontal-mobile: var(--spacing-base);
17
17
 
18
- --catalog-heading-margin: 0 0 var(--spacing-xl) 0;
18
+ --catalog-heading-margin: 0 0 var(--spacing-sm) 0;
19
19
  --catalog-sidebar-width: 285px;
20
20
 
21
21
  /**
@@ -5,7 +5,7 @@ export type FilterContentProps = {
5
5
  setFilterTerm: (value: string) => void;
6
6
  filters: ResolvedFilter[];
7
7
  filterTerm: string;
8
- filterValuesCasing?: NonNullable<RedoclyConfig['catalog']>[string]['filterValuesCasing'];
8
+ filterValuesCasing?: NonNullable<RedoclyConfig['catalog']>[string]['filterValuesCasing'] | ((str: string) => string);
9
9
  hideSearch?: boolean;
10
10
  showCounter?: boolean;
11
11
  };
@@ -151,17 +151,17 @@ const PLACEMENTS = {
151
151
  bottom: (0, styled_components_1.css) `
152
152
  ${({ withArrow, arrowPosition }) => withArrow && arrowPosition === 'left'
153
153
  ? (0, styled_components_1.css) `
154
- transform: translate(0, -100%);
155
- margin-top: -10px;
154
+ transform: translate(0, 10px);
155
+ margin-top: 0;
156
156
  `
157
157
  : arrowPosition === 'right'
158
158
  ? (0, styled_components_1.css) `
159
- transform: translate(-100%, -100%);
160
- margin-top: -10px;
159
+ transform: translate(-100%, 10px);
160
+ margin-top: 0;
161
161
  `
162
162
  : (0, styled_components_1.css) `
163
- transform: translate(-50%, -100%);
164
- margin-top: -10px;
163
+ transform: translate(-50%, 10px);
164
+ margin-top: 0;
165
165
  `}
166
166
 
167
167
  ${({ withArrow, arrowPosition }) => withArrow &&
@@ -2,6 +2,7 @@ import type { EntityRelationType } from '../types/catalog';
2
2
  export declare const CATALOG_TAG_MAX_LENGTH = 15;
3
3
  export declare const ENTITY_RELATION_TYPES: readonly ["partOf", "hasParts", "creates", "createdBy", "owns", "ownedBy", "implements", "implementedBy", "dependsOn", "dependencyOf", "uses", "usedBy", "produces", "consumes", "linksTo", "supersedes", "supersededBy", "compatibleWith", "extends", "extendedBy", "relatesTo", "hasMember", "memberOf", "triggers", "triggeredBy"];
4
4
  export declare const reverseRelationMap: Record<EntityRelationType, EntityRelationType>;
5
+ export declare const relationTypeMap: Record<EntityRelationType, string>;
5
6
  export declare enum GraphHandleType {
6
7
  Target = "target",
7
8
  Source = "source"
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GraphCustomEdgeType = exports.GraphCustomNodeType = exports.GraphHandleType = exports.reverseRelationMap = exports.ENTITY_RELATION_TYPES = exports.CATALOG_TAG_MAX_LENGTH = void 0;
3
+ exports.GraphCustomEdgeType = exports.GraphCustomNodeType = exports.GraphHandleType = exports.relationTypeMap = exports.reverseRelationMap = exports.ENTITY_RELATION_TYPES = exports.CATALOG_TAG_MAX_LENGTH = void 0;
4
4
  exports.CATALOG_TAG_MAX_LENGTH = 15;
5
5
  exports.ENTITY_RELATION_TYPES = [
6
6
  'partOf',
@@ -56,6 +56,33 @@ exports.reverseRelationMap = {
56
56
  triggers: 'triggeredBy',
57
57
  triggeredBy: 'triggers',
58
58
  };
59
+ exports.relationTypeMap = {
60
+ partOf: 'Part of',
61
+ hasParts: 'Has parts',
62
+ creates: 'Creates',
63
+ createdBy: 'Created by',
64
+ owns: 'Owns',
65
+ ownedBy: 'Owned by',
66
+ implements: 'Implements',
67
+ implementedBy: 'Implemented by',
68
+ dependsOn: 'Depends on',
69
+ dependencyOf: 'Dependency of',
70
+ uses: 'Uses',
71
+ usedBy: 'Used by',
72
+ produces: 'Produces',
73
+ consumes: 'Consumes',
74
+ linksTo: 'Links to',
75
+ supersedes: 'Supersedes',
76
+ supersededBy: 'Superseded by',
77
+ compatibleWith: 'Compatible with',
78
+ extends: 'Extends',
79
+ extendedBy: 'Extended by',
80
+ relatesTo: 'Relates to',
81
+ hasMember: 'Has member',
82
+ memberOf: 'Member of',
83
+ triggers: 'Triggers',
84
+ triggeredBy: 'Triggered by',
85
+ };
59
86
  var GraphHandleType;
60
87
  (function (GraphHandleType) {
61
88
  GraphHandleType["Target"] = "target";
@@ -0,0 +1,11 @@
1
+ import { BffCatalogEntity, BffCatalogRelatedEntity } from '../../types';
2
+ type CatalogEntitySchemaProps = {
3
+ entity: BffCatalogEntity;
4
+ relatedEntity: BffCatalogRelatedEntity | null;
5
+ };
6
+ export declare function useCatalogEntitySchema({ entity, relatedEntity }: CatalogEntitySchemaProps): {
7
+ definition: any;
8
+ parsedSchema: any;
9
+ rawSchema: any;
10
+ };
11
+ export {};
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCatalogEntitySchema = useCatalogEntitySchema;
4
+ function useCatalogEntitySchema({ entity, relatedEntity }) {
5
+ var _a, _b;
6
+ const { schema } = entity.metadata || {};
7
+ let parsedSchema;
8
+ try {
9
+ parsedSchema = JSON.parse(schema);
10
+ }
11
+ catch (error) {
12
+ parsedSchema = undefined;
13
+ }
14
+ let parsedApiDefinition;
15
+ try {
16
+ parsedApiDefinition = ((_a = relatedEntity === null || relatedEntity === void 0 ? void 0 : relatedEntity.metadata) === null || _a === void 0 ? void 0 : _a.schema)
17
+ ? JSON.parse(relatedEntity.metadata.schema)
18
+ : undefined;
19
+ }
20
+ catch (err) {
21
+ parsedApiDefinition = undefined;
22
+ }
23
+ const definition = !parsedApiDefinition || ((_b = relatedEntity === null || relatedEntity === void 0 ? void 0 : relatedEntity.metadata) === null || _b === void 0 ? void 0 : _b.specType) !== 'openapi'
24
+ ? {
25
+ openapi: '3.0.0',
26
+ info: { version: '1', description: 'test', title: 'test' },
27
+ paths: {},
28
+ components: {
29
+ schemas: {},
30
+ },
31
+ }
32
+ : parsedApiDefinition;
33
+ return {
34
+ definition,
35
+ parsedSchema,
36
+ rawSchema: schema,
37
+ };
38
+ }
39
+ //# sourceMappingURL=useCatalogEntitySchema.js.map
@@ -31,6 +31,11 @@ export type UseCatalogSearchResponse = {
31
31
  searchQuery: string;
32
32
  setSearchQuery: (query: string) => void;
33
33
  };
34
+ export type UseCatalogFilterResponse = {
35
+ filters: ResolvedFilter[];
36
+ filterQuery: string;
37
+ setFilterQuery: (filterQuery: string) => void;
38
+ };
34
39
  export type FilteredCatalog = {
35
40
  groups: {
36
41
  title: string;
@@ -135,6 +140,7 @@ export type BffCatalogEntity = {
135
140
  slack?: {
136
141
  channels?: Array<{
137
142
  name: string;
143
+ url?: string;
138
144
  }>;
139
145
  };
140
146
  };
@@ -166,3 +172,4 @@ export type Page = {
166
172
  total: number;
167
173
  };
168
174
  export type EntityRelationType = (typeof ENTITY_RELATION_TYPES)[number];
175
+ export type ListType = 'default' | 'team' | 'api-operation' | 'data-schema';
@@ -4,7 +4,7 @@ export type FilterProps = {
4
4
  filter: ResolvedFilter & {
5
5
  selectedOptions: any;
6
6
  };
7
- filterValuesCasing?: NonNullable<RedoclyConfig['catalog']>[string]['filterValuesCasing'];
7
+ filterValuesCasing?: NonNullable<RedoclyConfig['catalog']>[string]['filterValuesCasing'] | ((str: string) => string);
8
8
  showCounter?: boolean;
9
9
  };
10
10
  export type FilterTypes = NonNullable<FilterProps['filter']['type']>;
@@ -1,3 +1,3 @@
1
1
  type Casing = 'original' | 'lowercase' | 'uppercase' | 'sentence';
2
- export declare function changeTextCasing(str: string, casing?: Casing): string | undefined;
2
+ export declare function changeTextCasing(str: string, casing?: Casing | ((str: string) => string)): string | undefined;
3
3
  export {};
@@ -2,6 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.changeTextCasing = changeTextCasing;
4
4
  function changeTextCasing(str, casing = 'original') {
5
+ if (casing instanceof Function) {
6
+ return casing(str);
7
+ }
5
8
  if (casing === 'original' || !str)
6
9
  return str;
7
10
  if (casing === 'lowercase') {
@@ -18,6 +18,7 @@ export type ConfigureRequestValues = {
18
18
  cookie?: Record<string, string>;
19
19
  security?: SecurityDetails;
20
20
  envVariables?: Record<string, string>;
21
+ serverVariables?: Record<string, string>;
21
22
  };
22
23
  export type ConfigureServerRequestValues = {
23
24
  [serverUrl: string]: ConfigureRequestValues;
@@ -37,13 +37,16 @@ function configure(_context) {
37
37
  // envVariables: {
38
38
  // customLocation: 'prod'
39
39
  // },
40
+ // serverVariables: {
41
+ // version: 'v1',
42
+ // },
40
43
  // };
41
44
  // const { servers } = _context;
42
45
  // const serverRequestValues: ConfigureServerRequestValues = {};
43
46
  // for (const server of servers) {
44
47
  // if (server.url === 'https://dev.api.fake-museum-example.com') {
45
48
  // serverRequestValues[server.url] = exampleDevRequestValues;
46
- // } else if (server.url === 'https://api.fake-museum-example.com') {
49
+ // } else if (server.url === 'https://api.fake-museum-example.com/{version}') {
47
50
  // serverRequestValues[server.url] = exampleProdRequestValues;
48
51
  // } else {
49
52
  // serverRequestValues[server.url] = exampleDefaultRequestValues;
@@ -0,0 +1,18 @@
1
+ import type { ConfigureRequestValues, ConfigureServerRequestValues } from '../ext/configure';
2
+ import type { UserClaims, OpenAPIServer } from '../core/types';
3
+ type ContextProps = {
4
+ operation: {
5
+ name: string;
6
+ path: string;
7
+ operationId: string;
8
+ href: string;
9
+ method: string;
10
+ };
11
+ servers: OpenAPIServer[];
12
+ userClaims: UserClaims;
13
+ };
14
+ export declare function useConfigureReplay(context: ContextProps, isOpened: boolean): {
15
+ config: ConfigureRequestValues | ConfigureServerRequestValues | null | undefined;
16
+ refresh: () => Promise<void>;
17
+ };
18
+ export {};
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.useConfigureReplay = useConfigureReplay;
13
+ const react_1 = require("react");
14
+ function getReplayConfiguration(_context) {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ // Customize this function to fetch replay configuration from your API endpoint
17
+ // STEP 1: Uncomment the fetch code below and update the URL to your API endpoint
18
+ // try {
19
+ // const response = await fetch(`/api/replay-config/${_context.operation.operationId}`, {
20
+ // method: 'GET',
21
+ // headers: {
22
+ // 'Content-Type': 'application/json',
23
+ // },
24
+ // });
25
+ // if (!response.ok) {
26
+ // throw new Error(`HTTP error! status: ${response.status}`);
27
+ // }
28
+ // const { token } = await response.json();
29
+ //
30
+ // return {
31
+ // security: {
32
+ // token: {
33
+ // access_token: token,
34
+ // }
35
+ // }
36
+ // };
37
+ // } catch (error) {
38
+ // console.warn('Failed to fetch replay configuration:', error);
39
+ // throw error;
40
+ // }
41
+ // STEP 2: Remove this return null statement once you've implemented the fetch above
42
+ return null;
43
+ });
44
+ }
45
+ function useConfigureReplay(context, isOpened) {
46
+ const [config, setConfig] = (0, react_1.useState)();
47
+ const refresh = (0, react_1.useCallback)(() => __awaiter(this, void 0, void 0, function* () {
48
+ try {
49
+ const result = yield getReplayConfiguration(context);
50
+ setConfig(result);
51
+ }
52
+ catch (error) {
53
+ console.warn('Failed to configure replay for operation:', context.operation.operationId, error);
54
+ }
55
+ // eslint-disable-next-line react-hooks/exhaustive-deps
56
+ }), []);
57
+ (0, react_1.useEffect)(() => {
58
+ if (isOpened) {
59
+ refresh();
60
+ }
61
+ }, [isOpened, refresh]);
62
+ return { config, refresh };
63
+ }
64
+ //# sourceMappingURL=useConfigureReplay.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/theme",
3
- "version": "0.57.0",
3
+ "version": "0.58.0-next.1",
4
4
  "description": "Shared UI components lib",
5
5
  "keywords": [
6
6
  "theme",
@@ -84,10 +84,11 @@
84
84
  "lodash.debounce": "^4.0.8",
85
85
  "lodash.throttle": "4.1.1",
86
86
  "nprogress": "0.2.0",
87
+ "openapi-sampler": "1.6.1",
87
88
  "react-calendar": "5.1.0",
88
89
  "react-date-picker": "11.0.0",
89
- "@redocly/realm-asyncapi-sdk": "0.3.0",
90
- "@redocly/config": "0.29.0"
90
+ "@redocly/config": "0.29.1",
91
+ "@redocly/realm-asyncapi-sdk": "0.4.0-next.0"
91
92
  },
92
93
  "scripts": {
93
94
  "watch": "tsc -p tsconfig.build.json && (concurrently \"tsc -w -p tsconfig.build.json\" \"tsc-alias -w -p tsconfig.build.json\")",
@@ -28,6 +28,7 @@ export type CopyButtonProps = {
28
28
  fullWidth?: ButtonProps['fullWidth'];
29
29
  tone?: ButtonProps['tone'];
30
30
  extraClass?: ButtonProps['extraClass'];
31
+ iconPosition?: ButtonProps['iconPosition'];
31
32
  };
32
33
 
33
34
  function CopyButtonComponent({
@@ -46,6 +47,7 @@ function CopyButtonComponent({
46
47
  fullWidth,
47
48
  tone,
48
49
  extraClass,
50
+ iconPosition,
49
51
  }: CopyButtonProps): JSX.Element {
50
52
  const { useTranslate } = useThemeHooks();
51
53
  const tooltip = useControl();
@@ -85,9 +87,10 @@ function CopyButtonComponent({
85
87
  fullWidth={fullWidth}
86
88
  tone={tone}
87
89
  extraClass={extraClass}
90
+ iconPosition={iconPosition}
88
91
  >
89
92
  {(type === 'text' || type === 'compound') &&
90
- translate('codeSnippet.copy.toasterText', buttonText || 'Copy')}
93
+ (buttonText || translate('codeSnippet.copy.toasterText', 'Copy'))}
91
94
  </Button>
92
95
  </Tooltip>
93
96
  );
@@ -24,6 +24,20 @@ export type CatalogProps = {
24
24
  catalogSwitcherItems: CatalogSwitcherItem[];
25
25
  };
26
26
 
27
+ const customCatalogOptionsCasing = (str: string): string => {
28
+ if (!str) return str;
29
+
30
+ const words = str.split(/[\s-_]+/);
31
+ return words
32
+ .map((word, index) => {
33
+ if (index === 0 && word.toLowerCase() === 'api') {
34
+ return 'API';
35
+ }
36
+ return word[0].toUpperCase() + word.slice(1).toLowerCase();
37
+ })
38
+ .join(' ');
39
+ };
40
+
27
41
  export function Catalog(props: CatalogProps): JSX.Element {
28
42
  const { catalogConfig, entitiesTypes, initialEntitiesList, catalogSwitcherItems } = props;
29
43
 
@@ -71,7 +85,7 @@ export function Catalog(props: CatalogProps): JSX.Element {
71
85
  filterTerm={searchQuery}
72
86
  hideSearch={true}
73
87
  showCounter={false}
74
- filterValuesCasing="sentence"
88
+ filterValuesCasing={customCatalogOptionsCasing}
75
89
  />
76
90
  }
77
91
  footer={
@@ -209,7 +223,6 @@ const CatalogPageWrapper = styled.div`
209
223
  `;
210
224
 
211
225
  const CatalogPageDescription = styled.div`
212
- margin: var(--catalog-heading-margin);
213
226
  display: var(--catalog-page-description-display-mobile);
214
227
 
215
228
  @media screen and (min-width: ${breakpoints.medium}) {
@@ -1,35 +1,58 @@
1
1
  import React, { JSX } from 'react';
2
2
  import styled from 'styled-components';
3
3
 
4
+ import type { ListType } from '@redocly/theme/core/types';
5
+
4
6
  import { HexagonIcon } from '@redocly/theme/icons/HexagonIcon/HexagonIcon';
5
7
 
6
8
  interface CatalogEntitiesEmptyStateProps {
7
- listType?: 'default' | 'team';
9
+ listType?: ListType;
8
10
  }
9
11
 
12
+ const getEmptyStateContent = (
13
+ listType: ListType,
14
+ ): { header: string; paragraph1: string; paragraph2: string } => {
15
+ switch (listType) {
16
+ case 'team':
17
+ return {
18
+ header: 'No team members yet',
19
+ paragraph1: 'Your team members will appear here',
20
+ paragraph2: "once they've been added to the team.",
21
+ };
22
+ case 'api-operation':
23
+ return {
24
+ header: 'No operations yet',
25
+ paragraph1: 'Your operations will appear here',
26
+ paragraph2: "once they've been added to the API description.",
27
+ };
28
+ case 'data-schema':
29
+ return {
30
+ header: 'No schemas yet',
31
+ paragraph1: 'Your schemas will appear here',
32
+ paragraph2: "once they've been added to the API description.",
33
+ };
34
+ default:
35
+ return {
36
+ header: 'No entities found',
37
+ paragraph1: 'Try adjusting your search criteria or',
38
+ paragraph2: 'check back later for new additions.',
39
+ };
40
+ }
41
+ };
42
+
10
43
  export function CatalogEntitiesEmptyState({
11
44
  listType = 'default',
12
45
  }: CatalogEntitiesEmptyStateProps): JSX.Element {
13
- if (listType === 'team') {
14
- return (
15
- <EmptyStateWrapper data-component-name="Catalog/CatalogEntitiesEmptyState">
16
- <EmptyStateIconWrapper>
17
- <HexagonIcon size="21px" color="var(--color-warm-grey-7)" />
18
- </EmptyStateIconWrapper>
19
- <EmptyStateHeader>No team members yet</EmptyStateHeader>
20
- <EmptyStateText>Your team members will appear here</EmptyStateText>
21
- <EmptyStateText>once they&apos;ve been added to the team.</EmptyStateText>
22
- </EmptyStateWrapper>
23
- );
24
- }
46
+ const { header, paragraph1, paragraph2 } = getEmptyStateContent(listType);
47
+
25
48
  return (
26
49
  <EmptyStateWrapper data-component-name="Catalog/CatalogEntitiesEmptyState">
27
50
  <EmptyStateIconWrapper>
28
51
  <HexagonIcon size="21px" color="var(--color-warm-grey-7)" />
29
52
  </EmptyStateIconWrapper>
30
- <EmptyStateHeader>No entities found</EmptyStateHeader>
31
- <EmptyStateText>Try adjusting your search criteria or</EmptyStateText>
32
- <EmptyStateText>check back later for new additions.</EmptyStateText>
53
+ <EmptyStateHeader>{header}</EmptyStateHeader>
54
+ <EmptyStateText>{paragraph1}</EmptyStateText>
55
+ <EmptyStateText>{paragraph2}</EmptyStateText>
33
56
  </EmptyStateWrapper>
34
57
  );
35
58
  }