@redocly/theme 0.61.0-next.2 → 0.61.0

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 (71) hide show
  1. package/lib/components/Catalog/CatalogEntity/CatalogEntity.js +5 -0
  2. package/lib/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsGraph.js +9 -0
  3. package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistoryButton.d.ts +6 -0
  4. package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistoryButton.js +144 -0
  5. package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistorySidebar.d.ts +8 -0
  6. package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistorySidebar.js +161 -0
  7. package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityRevisionItem.d.ts +8 -0
  8. package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityRevisionItem.js +67 -0
  9. package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityVersionItem.d.ts +9 -0
  10. package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityVersionItem.js +212 -0
  11. package/lib/components/Catalog/CatalogEntity/CatalogEntityMetadata.js +2 -25
  12. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.js +12 -1
  13. package/lib/components/Catalog/CatalogEntity/ShowMoreButton.d.ts +8 -0
  14. package/lib/components/Catalog/CatalogEntity/ShowMoreButton.js +35 -0
  15. package/lib/components/Catalog/CatalogTableView/CatalogTableViewRow.d.ts +2 -0
  16. package/lib/components/Catalog/CatalogTableView/CatalogTableViewRow.js +4 -1
  17. package/lib/components/Catalog/variables.js +112 -0
  18. package/lib/components/Menu/variables.js +1 -0
  19. package/lib/components/Tooltip/Tooltip.js +2 -0
  20. package/lib/core/constants/catalog.d.ts +1 -0
  21. package/lib/core/constants/catalog.js +2 -1
  22. package/lib/core/hooks/catalog/use-catalog-entity-details.d.ts +3 -1
  23. package/lib/core/hooks/catalog/use-catalog-entity-details.js +12 -5
  24. package/lib/core/hooks/use-color-switcher.js +7 -8
  25. package/lib/core/hooks/use-page-actions.js +37 -6
  26. package/lib/core/hooks/use-telemetry-fallback.d.ts +2 -0
  27. package/lib/core/hooks/use-telemetry-fallback.js +2 -0
  28. package/lib/core/types/catalog.d.ts +33 -4
  29. package/lib/core/types/hooks.d.ts +14 -3
  30. package/lib/core/types/l10n.d.ts +1 -1
  31. package/lib/core/utils/build-revision-url.d.ts +1 -0
  32. package/lib/core/utils/build-revision-url.js +15 -0
  33. package/lib/core/utils/date.d.ts +14 -0
  34. package/lib/core/utils/date.js +39 -0
  35. package/lib/core/utils/index.d.ts +2 -0
  36. package/lib/core/utils/index.js +2 -0
  37. package/lib/core/utils/transform-revisions-to-version-history.d.ts +8 -0
  38. package/lib/core/utils/transform-revisions-to-version-history.js +110 -0
  39. package/lib/icons/NavaidMilitaryIcon/NavaidMilitaryIcon.d.ts +9 -0
  40. package/lib/icons/NavaidMilitaryIcon/NavaidMilitaryIcon.js +26 -0
  41. package/lib/index.d.ts +2 -0
  42. package/lib/index.js +2 -0
  43. package/package.json +6 -6
  44. package/src/components/Catalog/CatalogEntity/CatalogEntity.tsx +7 -1
  45. package/src/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsGraph.tsx +12 -0
  46. package/src/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistoryButton.tsx +147 -0
  47. package/src/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistorySidebar.tsx +180 -0
  48. package/src/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityRevisionItem.tsx +93 -0
  49. package/src/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityVersionItem.tsx +284 -0
  50. package/src/components/Catalog/CatalogEntity/CatalogEntityMetadata.tsx +3 -25
  51. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.tsx +15 -2
  52. package/src/components/Catalog/CatalogEntity/ShowMoreButton.tsx +47 -0
  53. package/src/components/Catalog/CatalogTableView/CatalogTableViewRow.tsx +6 -1
  54. package/src/components/Catalog/variables.ts +112 -0
  55. package/src/components/Menu/variables.ts +1 -0
  56. package/src/components/Tooltip/Tooltip.tsx +2 -0
  57. package/src/core/constants/catalog.ts +2 -0
  58. package/src/core/hooks/__mocks__/use-theme-hooks.ts +1 -0
  59. package/src/core/hooks/catalog/use-catalog-entity-details.ts +22 -6
  60. package/src/core/hooks/use-color-switcher.ts +13 -10
  61. package/src/core/hooks/use-page-actions.ts +63 -6
  62. package/src/core/hooks/use-telemetry-fallback.ts +2 -0
  63. package/src/core/types/catalog.ts +38 -10
  64. package/src/core/types/hooks.ts +23 -4
  65. package/src/core/types/l10n.ts +10 -0
  66. package/src/core/utils/build-revision-url.ts +16 -0
  67. package/src/core/utils/date.ts +33 -0
  68. package/src/core/utils/index.ts +2 -0
  69. package/src/core/utils/transform-revisions-to-version-history.ts +163 -0
  70. package/src/icons/NavaidMilitaryIcon/NavaidMilitaryIcon.tsx +43 -0
  71. package/src/index.ts +2 -0
@@ -18,6 +18,7 @@ const hooks_1 = require("../../../core/hooks");
18
18
  const CatalogEntitySchema_1 = require("../../../components/Catalog/CatalogEntity/CatalogEntitySchema");
19
19
  const CatalogEntityMethodAndPath_1 = require("../../../components/Catalog/CatalogEntity/CatalogEntityMethodAndPath");
20
20
  const CatalogEntityRelationsGraph_lazy_1 = require("../../../components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsGraph.lazy");
21
+ const theme_1 = require("../../../index.js");
21
22
  const renderFirstColumnEntitySection = (entity) => {
22
23
  switch (entity.type) {
23
24
  case 'api-operation':
@@ -37,10 +38,14 @@ function CatalogEntity({ RedocSchema, StoreProvider, GraphqlTypeRenderer, }) {
37
38
  const { useTranslate, useCatalog, usePageProps } = (0, hooks_1.useThemeHooks)();
38
39
  const { translate } = useTranslate();
39
40
  const { entity, relations, catalogConfig, entitiesCatalogConfig, relatedEntity } = usePageProps();
41
+ const [searchParams] = (0, react_router_dom_1.useSearchParams)();
42
+ const revision = searchParams.get('revision') || undefined;
43
+ const version = searchParams.get('version') || undefined;
40
44
  const linkToMainCatalog = `catalogs/${catalogConfig.slug}`;
41
45
  const linkToMainCatalogLabel = translate(catalogConfig.titleTranslationKey);
42
46
  const { searchQuery, setSearchQuery } = useCatalog();
43
47
  return (react_1.default.createElement(CatalogPageWrapper, { "data-component-name": "Catalog/CatalogEntity/CatalogEntity" },
48
+ react_1.default.createElement(theme_1.CatalogEntityHistorySidebar, { entityKey: entity.key, revision: revision, version: version }),
44
49
  react_1.default.createElement(CatalogPageContent, null,
45
50
  react_1.default.createElement(Breadcrumbs_1.Breadcrumbs, { additionalBreadcrumbs: [
46
51
  { label: linkToMainCatalogLabel, link: linkToMainCatalog },
@@ -61,8 +61,17 @@ function CatalogEntityRelationsGraph({ entity, }) {
61
61
  var _a;
62
62
  const { useFetchCatalogEntitiesRelations } = (0, hooks_1.useThemeHooks)();
63
63
  const { activeColorMode } = (0, hooks_1.useColorSwitcher)();
64
+ const combinedFilter = (0, react_1.useMemo)(() => {
65
+ if (entity.version && entity.revision) {
66
+ const versionFilter = `version:"${entity.version}"`;
67
+ const revisionFilter = `revision:"${entity.revision}"`;
68
+ return `${versionFilter} AND ${revisionFilter}`;
69
+ }
70
+ return undefined;
71
+ }, [entity.version, entity.revision]);
64
72
  const { items: allRelations } = useFetchCatalogEntitiesRelations({
65
73
  entityKey: entity.key,
74
+ filter: combinedFilter,
66
75
  });
67
76
  const { nodes, edges, onNodesChange, onEdgesChange, onConnect } = (0, hooks_2.useGraph)({
68
77
  entity,
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export type CatalogHistoryButtonProps = {
3
+ version: string | null;
4
+ className?: string;
5
+ };
6
+ export declare function CatalogEntityHistoryButton({ version, className, }: CatalogHistoryButtonProps): React.ReactElement;
@@ -0,0 +1,144 @@
1
+ "use strict";
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 () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.CatalogEntityHistoryButton = CatalogEntityHistoryButton;
40
+ const react_1 = __importStar(require("react"));
41
+ const styled_components_1 = __importDefault(require("styled-components"));
42
+ const RecentlyViewedIcon_1 = require("../../../../icons/RecentlyViewedIcon/RecentlyViewedIcon");
43
+ const CheckmarkOutlineIcon_1 = require("../../../../icons/CheckmarkOutlineIcon/CheckmarkOutlineIcon");
44
+ const hooks_1 = require("../../../../core/hooks");
45
+ const constants_1 = require("../../../../core/constants");
46
+ function CatalogEntityHistoryButton({ version, className, }) {
47
+ const [label, setLabel] = (0, react_1.useState)(version === constants_1.VERSION_NOT_SPECIFIED ? null : version);
48
+ const { useTranslate } = (0, hooks_1.useThemeHooks)();
49
+ const { translate } = useTranslate();
50
+ const handleClose = (0, react_1.useCallback)((e) => {
51
+ setLabel(e.detail.version === constants_1.VERSION_NOT_SPECIFIED
52
+ ? e.detail.revision || 'r.1'
53
+ : `${e.detail.version || version}, ${e.detail.revision || 'r.1'}`);
54
+ }, [version]);
55
+ (0, react_1.useEffect)(() => {
56
+ window.addEventListener('portal:sidebar:close-version-history', (e) => handleClose(e));
57
+ return () => {
58
+ window.removeEventListener('portal:sidebar:close-version-history', (e) => handleClose(e));
59
+ };
60
+ }, [handleClose]);
61
+ const handleClick = () => {
62
+ window.dispatchEvent(new CustomEvent('portal:sidebar:open-version-history'));
63
+ };
64
+ return (react_1.default.createElement(CatalogHistoryButtonWrapper, { className: className, "data-component-name": "Catalog/CatalogHistoryButton" },
65
+ react_1.default.createElement(Separator, null),
66
+ react_1.default.createElement(HistoryItem, { onClick: handleClick },
67
+ react_1.default.createElement(HistoryIcon, null),
68
+ react_1.default.createElement(HistoryContent, null,
69
+ react_1.default.createElement(HistoryText, null, translate('catalog.history.button.label', 'Version history')),
70
+ label && (react_1.default.createElement(VersionPill, null,
71
+ react_1.default.createElement(CheckmarkIcon, null),
72
+ react_1.default.createElement("span", null, label)))))));
73
+ }
74
+ const CatalogHistoryButtonWrapper = styled_components_1.default.div `
75
+ width: 100%;
76
+ `;
77
+ const Separator = styled_components_1.default.div `
78
+ width: 100%;
79
+ height: 1px;
80
+ background-color: var(--catalog-history-separator-border-color);
81
+ margin-bottom: var(--catalog-history-separator-margin-bottom);
82
+ flex-shrink: 0;
83
+ `;
84
+ const HistoryItem = styled_components_1.default.button `
85
+ all: unset;
86
+ display: flex;
87
+ align-items: center;
88
+ justify-content: space-between;
89
+ gap: var(--catalog-history-item-gap);
90
+ padding: var(--catalog-history-item-padding);
91
+ margin-bottom: var(--catalog-history-item-margin-bottom);
92
+ width: 100%;
93
+ border-radius: var(--catalog-history-item-border-radius);
94
+ cursor: pointer;
95
+ transition: background-color 0.2s ease;
96
+
97
+ &:hover {
98
+ background-color: var(--catalog-history-item-bg-color-hover);
99
+ }
100
+ `;
101
+ const HistoryContent = styled_components_1.default.div `
102
+ display: flex;
103
+ align-items: center;
104
+ justify-content: space-between;
105
+ flex: 1;
106
+ gap: var(--catalog-history-item-gap);
107
+ `;
108
+ const HistoryText = styled_components_1.default.span `
109
+ font-family: var(--catalog-history-text-font-family);
110
+ font-size: var(--catalog-history-text-font-size);
111
+ font-weight: var(--catalog-history-text-font-weight);
112
+ line-height: var(--catalog-history-text-line-height);
113
+ color: var(--catalog-history-text-color);
114
+ flex: 1;
115
+ `;
116
+ const HistoryIcon = (0, styled_components_1.default)(RecentlyViewedIcon_1.RecentlyViewedIcon) `
117
+ width: var(--catalog-history-icon-size);
118
+ height: var(--catalog-history-icon-size);
119
+ flex-shrink: 0;
120
+ `;
121
+ const VersionPill = styled_components_1.default.div `
122
+ display: flex;
123
+ align-items: center;
124
+ gap: var(--catalog-history-pill-gap);
125
+ padding: var(--catalog-history-pill-padding-vertical)
126
+ var(--catalog-history-pill-padding-horizontal);
127
+ border: 1px solid var(--catalog-history-pill-border-color);
128
+ border-radius: var(--catalog-history-pill-border-radius);
129
+ background-color: transparent;
130
+ flex-shrink: 0;
131
+
132
+ span {
133
+ font-family: var(--catalog-history-pill-font-family);
134
+ font-size: var(--catalog-history-pill-font-size);
135
+ line-height: var(--catalog-history-pill-line-height);
136
+ color: var(--catalog-history-pill-text-color);
137
+ }
138
+ `;
139
+ const CheckmarkIcon = (0, styled_components_1.default)(CheckmarkOutlineIcon_1.CheckmarkOutlineIcon) `
140
+ width: var(--catalog-history-pill-icon-size);
141
+ height: var(--catalog-history-pill-icon-size);
142
+ color: var(--catalog-history-pill-icon-color);
143
+ `;
144
+ //# sourceMappingURL=CatalogEntityHistoryButton.js.map
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ export type CatalogHistorySidebarProps = {
3
+ entityKey: string;
4
+ revision?: string;
5
+ version?: string | null;
6
+ className?: string;
7
+ };
8
+ export declare function CatalogEntityHistorySidebar({ entityKey, revision, version, className, }: CatalogHistorySidebarProps): React.ReactElement | null;
@@ -0,0 +1,161 @@
1
+ "use strict";
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 () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.CatalogEntityHistorySidebar = CatalogEntityHistorySidebar;
40
+ const react_1 = __importStar(require("react"));
41
+ const styled_components_1 = __importDefault(require("styled-components"));
42
+ const react_router_dom_1 = require("react-router-dom");
43
+ const CloseIcon_1 = require("../../../../icons/CloseIcon/CloseIcon");
44
+ const hooks_1 = require("../../../../core/hooks");
45
+ const MenuContainer_1 = require("../../../../components/Menu/MenuContainer");
46
+ const utils_1 = require("../../../../core/utils");
47
+ const CatalogEntityVersionItem_1 = require("./CatalogEntityVersionItem");
48
+ function CatalogEntityHistorySidebar({ entityKey, revision, version, className, }) {
49
+ const [isOpen, setIsOpen] = (0, react_1.useState)(false);
50
+ const location = (0, react_router_dom_1.useLocation)();
51
+ const basePath = location.pathname;
52
+ const { useTranslate, useFetchCatalogEntityRevisions, useL10nConfig } = (0, hooks_1.useThemeHooks)();
53
+ const { translate } = useTranslate();
54
+ const { currentLocale } = useL10nConfig();
55
+ const { items: revisions } = useFetchCatalogEntityRevisions({ entityKey });
56
+ const versionHistoryItems = (0, react_1.useMemo)(() => (0, utils_1.transformRevisionsToVersionHistory)({
57
+ revisions,
58
+ currentRevisionDate: revision,
59
+ currentVersion: version,
60
+ locale: currentLocale,
61
+ }), [revisions, revision, version, currentLocale]);
62
+ const activeRevisionLabel = (0, react_1.useMemo)(() => {
63
+ var _a;
64
+ const itemWithActiveRevision = versionHistoryItems.find((item) => { var _a; return (_a = item.revisions) === null || _a === void 0 ? void 0 : _a.some((revision) => revision.isActive); });
65
+ const activeRevision = (_a = itemWithActiveRevision === null || itemWithActiveRevision === void 0 ? void 0 : itemWithActiveRevision.revisions) === null || _a === void 0 ? void 0 : _a.find((revision) => revision.isActive);
66
+ return activeRevision === null || activeRevision === void 0 ? void 0 : activeRevision.name;
67
+ }, [versionHistoryItems]);
68
+ const [expandedVersions, setExpandedVersions] = (0, react_1.useState)(new Set());
69
+ (0, react_1.useEffect)(() => {
70
+ setExpandedVersions(new Set(versionHistoryItems.filter((item) => item.isExpanded).map((item) => item.version)));
71
+ }, [versionHistoryItems]);
72
+ const handleOpenSidebar = (0, react_1.useCallback)(() => {
73
+ setIsOpen(true);
74
+ }, []);
75
+ (0, react_1.useEffect)(() => {
76
+ window.addEventListener('portal:sidebar:open-version-history', handleOpenSidebar);
77
+ return () => {
78
+ window.removeEventListener('portal:sidebar:open-version-history', handleOpenSidebar);
79
+ };
80
+ }, [handleOpenSidebar]);
81
+ const handleClose = () => {
82
+ window.dispatchEvent(new CustomEvent('portal:sidebar:close-version-history', {
83
+ detail: { version, revision: activeRevisionLabel },
84
+ }));
85
+ setIsOpen(false);
86
+ };
87
+ const toggleVersion = (version) => {
88
+ setExpandedVersions((prev) => {
89
+ const newSet = new Set(prev);
90
+ if (newSet.has(version)) {
91
+ newSet.delete(version);
92
+ }
93
+ else {
94
+ newSet.add(version);
95
+ }
96
+ return newSet;
97
+ });
98
+ };
99
+ if (!isOpen) {
100
+ return null;
101
+ }
102
+ return (react_1.default.createElement(SidebarOverlay, { className: className, "data-component-name": "Catalog/CatalogHistorySidebar" },
103
+ react_1.default.createElement(SidebarHeader, null,
104
+ react_1.default.createElement(HeaderTitle, null, translate('catalog.history.sidebar.title', 'Version history')),
105
+ react_1.default.createElement(CloseButton, { onClick: handleClose, "aria-label": translate('catalog.history.sidebar.close', 'Close version history') },
106
+ react_1.default.createElement(CloseIcon_1.CloseIcon, { size: "20px", color: "--catalog-history-sidebar-close-icon-color" }))),
107
+ react_1.default.createElement(MenuContainer_1.MenuContainer, { growContent: true },
108
+ react_1.default.createElement(VersionList, null, versionHistoryItems.map((group) => (react_1.default.createElement(CatalogEntityVersionItem_1.CatalogEntityVersionItem, { key: group.version, group: group, basePath: basePath, isExpanded: expandedVersions.has(group.version), onToggle: toggleVersion })))))));
109
+ }
110
+ const SidebarOverlay = styled_components_1.default.div `
111
+ position: fixed;
112
+ top: var(--navbar-height);
113
+ left: 0;
114
+ width: var(--sidebar-width);
115
+ height: calc(100vh - var(--navbar-height));
116
+ background-color: var(--catalog-history-sidebar-bg-color);
117
+ border-right: 1px solid var(--catalog-history-sidebar-border-color);
118
+ display: flex;
119
+ flex-direction: column;
120
+ z-index: calc(var(--z-index-raised) - 1);
121
+ overflow: hidden;
122
+ `;
123
+ const SidebarHeader = styled_components_1.default.div `
124
+ display: flex;
125
+ align-items: center;
126
+ justify-content: space-between;
127
+ padding: var(--catalog-history-sidebar-header-padding);
128
+ border-bottom: 1px solid var(--catalog-history-sidebar-border-color);
129
+ flex-shrink: 0;
130
+ `;
131
+ const HeaderTitle = styled_components_1.default.h2 `
132
+ margin: 0;
133
+ font-family: var(--catalog-history-sidebar-header-font-family);
134
+ font-size: var(--catalog-history-sidebar-header-font-size);
135
+ font-weight: var(--catalog-history-sidebar-header-font-weight);
136
+ line-height: var(--catalog-history-sidebar-header-line-height);
137
+ letter-spacing: var(--catalog-history-sidebar-header-letter-spacing);
138
+ color: var(--catalog-history-sidebar-header-color);
139
+ `;
140
+ const CloseButton = styled_components_1.default.button `
141
+ all: unset;
142
+ display: flex;
143
+ align-items: center;
144
+ justify-content: center;
145
+ width: var(--catalog-history-sidebar-close-button-size);
146
+ height: var(--catalog-history-sidebar-close-button-size);
147
+ cursor: pointer;
148
+ border-radius: var(--catalog-history-sidebar-close-button-border-radius);
149
+ transition: background-color 0.2s ease;
150
+
151
+ &:hover {
152
+ background-color: var(--catalog-history-sidebar-close-button-bg-color-hover);
153
+ }
154
+ `;
155
+ const VersionList = styled_components_1.default.ul `
156
+ list-style: none;
157
+ margin: 0;
158
+ padding: var(--catalog-history-sidebar-content-padding);
159
+ margin-top: var(--catalog-history-sidebar-content-margin-top);
160
+ `;
161
+ //# sourceMappingURL=CatalogEntityHistorySidebar.js.map
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import type { CatalogEntityRevision } from '../../../../core/types';
3
+ export type CatalogEntityRevisionItemProps = {
4
+ revisionItem: CatalogEntityRevision;
5
+ basePath: string;
6
+ version?: string | null;
7
+ };
8
+ export declare function CatalogEntityRevisionItem({ revisionItem, basePath, version, }: CatalogEntityRevisionItemProps): React.ReactElement;
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CatalogEntityRevisionItem = CatalogEntityRevisionItem;
7
+ const react_1 = __importDefault(require("react"));
8
+ const styled_components_1 = __importDefault(require("styled-components"));
9
+ const Link_1 = require("../../../../components/Link/Link");
10
+ const Tag_1 = require("../../../../components/Tag/Tag");
11
+ const utils_1 = require("../../../../core/utils");
12
+ const hooks_1 = require("../../../../core/hooks");
13
+ function CatalogEntityRevisionItem({ revisionItem, basePath, version, }) {
14
+ var _a, _b;
15
+ const { useTranslate } = (0, hooks_1.useThemeHooks)();
16
+ const { translate } = useTranslate();
17
+ const revisionFilter = (_a = (0, utils_1.buildRevisionUrl)(basePath, revisionItem.revisionDate, version)) !== null && _a !== void 0 ? _a : basePath;
18
+ const isActive = (_b = revisionItem.isActive) !== null && _b !== void 0 ? _b : false;
19
+ return (react_1.default.createElement(RevisionItemWrapper, { to: revisionFilter, "$isActive": isActive },
20
+ react_1.default.createElement(RevisionNameRow, null,
21
+ react_1.default.createElement(RevisionName, null, revisionItem.name),
22
+ revisionItem.isCurrent && (react_1.default.createElement(Tag_1.Tag, { color: "grey", borderless: true, textTransform: "none", style: {
23
+ fontSize: 'var(--font-size-xs)',
24
+ borderRadius: 'var(--catalog-history-sidebar-revision-tag-border-radius)',
25
+ } }, translate('catalog.history.revision.current', 'current')))),
26
+ react_1.default.createElement(RevisionDate, null, revisionItem.date)));
27
+ }
28
+ const RevisionItemWrapper = (0, styled_components_1.default)(Link_1.Link) `
29
+ display: flex;
30
+ justify-content: space-between;
31
+ align-items: center;
32
+ padding: var(--catalog-history-sidebar-revision-item-padding);
33
+ margin-left: calc(-1 * var(--catalog-history-sidebar-revisions-padding-left));
34
+ padding-left: var(--catalog-history-sidebar-revisions-padding-left);
35
+ border-radius: var(--catalog-history-sidebar-revision-item-border-radius);
36
+ transition: 0.2s ease;
37
+ text-decoration: none;
38
+ color: inherit;
39
+ cursor: pointer;
40
+ background-color: ${({ $isActive }) => $isActive ? 'var(--catalog-history-sidebar-revision-item-bg-color-active)' : 'transparent'};
41
+
42
+ &:hover {
43
+ background-color: ${({ $isActive }) => $isActive
44
+ ? 'var(--catalog-history-sidebar-revision-item-bg-color-active)'
45
+ : 'var(--catalog-history-sidebar-revision-item-bg-color-hover)'};
46
+ }
47
+ `;
48
+ const RevisionNameRow = styled_components_1.default.div `
49
+ display: flex;
50
+ align-items: center;
51
+ gap: var(--spacing-xs, 8px);
52
+ `;
53
+ const RevisionName = styled_components_1.default.span `
54
+ font-family: var(--catalog-history-sidebar-revision-name-font-family);
55
+ font-size: var(--catalog-history-sidebar-revision-name-font-size);
56
+ font-weight: var(--catalog-history-sidebar-revision-name-font-weight);
57
+ line-height: var(--catalog-history-sidebar-revision-name-line-height);
58
+ color: var(--catalog-history-sidebar-revision-name-color);
59
+ `;
60
+ const RevisionDate = styled_components_1.default.span `
61
+ font-family: var(--catalog-history-sidebar-revision-date-font-family);
62
+ font-size: var(--catalog-history-sidebar-revision-date-font-size);
63
+ font-weight: var(--catalog-history-sidebar-revision-date-font-weight);
64
+ line-height: var(--catalog-history-sidebar-revision-date-line-height);
65
+ color: var(--catalog-history-sidebar-revision-date-color);
66
+ `;
67
+ //# sourceMappingURL=CatalogEntityRevisionItem.js.map
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import type { CatalogEntityVersionHistoryGroup } from '../../../../core/types';
3
+ export type CatalogEntityVersionItemProps = {
4
+ group: CatalogEntityVersionHistoryGroup;
5
+ basePath: string;
6
+ isExpanded: boolean;
7
+ onToggle: (version: string) => void;
8
+ };
9
+ export declare function CatalogEntityVersionItem({ group, basePath, isExpanded, onToggle, }: CatalogEntityVersionItemProps): React.ReactElement;
@@ -0,0 +1,212 @@
1
+ "use strict";
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 () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.CatalogEntityVersionItem = CatalogEntityVersionItem;
40
+ const react_1 = __importStar(require("react"));
41
+ const styled_components_1 = __importDefault(require("styled-components"));
42
+ const ChevronDownIcon_1 = require("../../../../icons/ChevronDownIcon/ChevronDownIcon");
43
+ const ChevronRightIcon_1 = require("../../../../icons/ChevronRightIcon/ChevronRightIcon");
44
+ const CheckmarkOutlineIcon_1 = require("../../../../icons/CheckmarkOutlineIcon/CheckmarkOutlineIcon");
45
+ const NavaidMilitaryIcon_1 = require("../../../../icons/NavaidMilitaryIcon/NavaidMilitaryIcon");
46
+ const Link_1 = require("../../../../components/Link/Link");
47
+ const Tag_1 = require("../../../../components/Tag/Tag");
48
+ const hooks_1 = require("../../../../core/hooks");
49
+ const ShowMoreButton_1 = require("../../../../components/Catalog/CatalogEntity/ShowMoreButton");
50
+ const CatalogEntityRevisionItem_1 = require("../../../../components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityRevisionItem");
51
+ const utils_1 = require("../../../../core/utils");
52
+ const constants_1 = require("../../../../core/constants");
53
+ const MAX_INITIAL_REVISIONS = 5;
54
+ const MAX_REVISIONS = 20;
55
+ function CatalogEntityVersionItem({ group, basePath, isExpanded, onToggle, }) {
56
+ const { useTranslate } = (0, hooks_1.useThemeHooks)();
57
+ const { translate } = useTranslate();
58
+ const [showAllRevisions, setShowAllRevisions] = (0, react_1.useState)(false);
59
+ const revisions = group.revisions || [];
60
+ const hasRevisions = revisions.length > 0;
61
+ const hasMoreThanMax = revisions.length > MAX_INITIAL_REVISIONS;
62
+ const hasMoreThanLimit = revisions.length > MAX_REVISIONS;
63
+ const displayedRevisions = showAllRevisions
64
+ ? revisions.slice(0, MAX_REVISIONS)
65
+ : revisions.slice(0, MAX_INITIAL_REVISIONS);
66
+ (0, react_1.useEffect)(() => {
67
+ if (!isExpanded) {
68
+ setShowAllRevisions(false);
69
+ }
70
+ }, [isExpanded]);
71
+ const isNotSpecifiedVersion = group.version === constants_1.VERSION_NOT_SPECIFIED;
72
+ const singleRevisionLink = (0, utils_1.buildRevisionUrl)(basePath, group.singleRevisionDate, group.version);
73
+ const isClickable = hasRevisions || Boolean(singleRevisionLink);
74
+ const isSingleRevisionActive = Boolean(singleRevisionLink && group.isCurrent);
75
+ const versionTitle = isNotSpecifiedVersion
76
+ ? `${translate('catalog.history.version.label', 'Version')}: ${translate('catalog.history.version.notSpecified', 'not specified')}`
77
+ : `${translate('catalog.history.version.label', 'Version')}: ${group.version}`;
78
+ const versionButton = (react_1.default.createElement(VersionButton, { type: "button", onClick: () => hasRevisions && onToggle(group.version), "$isClickable": isClickable, "$isCurrent": group.isCurrent, "$isActive": isSingleRevisionActive },
79
+ react_1.default.createElement(VersionIcon, { "$isCurrent": group.isCurrent }, group.isCurrent ? (react_1.default.createElement(CheckmarkOutlineIcon_1.CheckmarkOutlineIcon, { size: "16px", color: "--catalog-history-sidebar-version-icon-color-current" })) : (react_1.default.createElement(NavaidMilitaryIcon_1.NavaidMilitaryIcon, { size: "16px", color: "--catalog-history-sidebar-version-icon-color" }))),
80
+ react_1.default.createElement(VersionInfo, null,
81
+ react_1.default.createElement(VersionTitleRow, null,
82
+ react_1.default.createElement(VersionTitle, null, versionTitle),
83
+ group.isDefaultVersion && (react_1.default.createElement(Tag_1.Tag, { color: "grey", borderless: true, textTransform: "none", style: {
84
+ fontSize: 'var(--font-size-xs)',
85
+ borderRadius: 'var(--catalog-history-sidebar-version-tag-border-radius)',
86
+ flexShrink: 0,
87
+ } }, translate('catalog.history.version.default', 'default')))),
88
+ !isNotSpecifiedVersion && react_1.default.createElement(VersionDate, null, group.date)),
89
+ hasRevisions && (react_1.default.createElement(ChevronIcon, null, isExpanded ? (react_1.default.createElement(ChevronDownIcon_1.ChevronDownIcon, { size: "16px", color: "--catalog-history-sidebar-chevron-icon-color" })) : (react_1.default.createElement(ChevronRightIcon_1.ChevronRightIcon, { size: "16px", color: "--catalog-history-sidebar-chevron-icon-color" }))))));
90
+ return (react_1.default.createElement("li", null,
91
+ singleRevisionLink ? react_1.default.createElement(Link_1.Link, { to: singleRevisionLink }, versionButton) : versionButton,
92
+ hasRevisions && isExpanded && (react_1.default.createElement(RevisionsList, null,
93
+ displayedRevisions.map((revisionItem) => (react_1.default.createElement(CatalogEntityRevisionItem_1.CatalogEntityRevisionItem, { key: revisionItem.name, revisionItem: revisionItem, basePath: basePath, version: group.version }))),
94
+ hasMoreThanLimit && showAllRevisions && (react_1.default.createElement(RevisionsLimitMessage, null, translate('catalog.history.revisions.limitMessage', 'Older revisions are not stored.'))),
95
+ hasMoreThanMax && (react_1.default.createElement(ShowMoreButton_1.ShowMoreButton, { onClick: () => setShowAllRevisions(!showAllRevisions), isExpanded: showAllRevisions }, showAllRevisions
96
+ ? translate('catalog.history.revisions.showLess', 'Show less')
97
+ : translate('catalog.history.revisions.showMore', {
98
+ defaultValue: 'Show more',
99
+ count: Math.min(revisions.length - MAX_INITIAL_REVISIONS, MAX_REVISIONS - MAX_INITIAL_REVISIONS),
100
+ })))))));
101
+ }
102
+ const VersionButton = styled_components_1.default.button `
103
+ all: unset;
104
+ display: flex;
105
+ align-items: center;
106
+ width: calc(100% - var(--catalog-history-sidebar-version-icon-margin-right));
107
+ padding: var(--catalog-history-sidebar-version-header-padding);
108
+ cursor: ${({ $isClickable }) => ($isClickable ? 'pointer' : 'default')};
109
+ border-radius: var(--catalog-history-sidebar-version-header-border-radius);
110
+ transition: 0.2s ease;
111
+ text-decoration: none;
112
+ color: inherit;
113
+ background-color: ${({ $isActive }) => $isActive ? 'var(--catalog-history-sidebar-revision-item-bg-color-active)' : 'transparent'};
114
+
115
+ ${({ $isClickable, $isActive }) => $isClickable &&
116
+ `
117
+ &:hover {
118
+ background-color: ${$isActive
119
+ ? 'var(--catalog-history-sidebar-revision-item-bg-color-active)'
120
+ : 'var(--catalog-history-sidebar-version-header-bg-color-hover)'};
121
+ }
122
+ `}
123
+
124
+ ${({ $isCurrent }) => !$isCurrent &&
125
+ `
126
+ &:hover ${VersionIcon} {
127
+ background-color: var(--color-static-white);
128
+ }
129
+ `}
130
+ `;
131
+ const VersionIcon = styled_components_1.default.div `
132
+ display: flex;
133
+ align-items: center;
134
+ justify-content: center;
135
+ width: var(--catalog-history-sidebar-version-icon-size);
136
+ height: var(--catalog-history-sidebar-version-icon-size);
137
+ flex-shrink: 0;
138
+ border-radius: 50%;
139
+ background-color: ${({ $isCurrent }) => $isCurrent ? 'var(--color-primary-base)' : 'var(--catalog-avatar-bg-color)'};
140
+ transition: background-color 0.2s ease;
141
+ margin-right: var(--catalog-history-sidebar-version-icon-margin-right);
142
+
143
+ svg path {
144
+ transition: fill 0.2s ease;
145
+ }
146
+ `;
147
+ const VersionInfo = styled_components_1.default.div `
148
+ display: flex;
149
+ flex-direction: column;
150
+ align-items: flex-start;
151
+ gap: var(--catalog-history-sidebar-version-info-gap);
152
+ `;
153
+ const VersionTitleRow = styled_components_1.default.div `
154
+ display: flex;
155
+ align-items: center;
156
+ gap: var(--spacing-xs, 8px);
157
+ `;
158
+ const VersionTitle = styled_components_1.default.span `
159
+ font-family: var(--catalog-history-sidebar-version-title-font-family);
160
+ font-size: var(--catalog-history-sidebar-version-title-font-size);
161
+ font-weight: var(--catalog-history-sidebar-version-title-font-weight);
162
+ line-height: var(--catalog-history-sidebar-version-title-line-height);
163
+ color: var(--catalog-history-sidebar-version-title-color);
164
+ flex-shrink: 1;
165
+ min-width: 0;
166
+ `;
167
+ const VersionDate = styled_components_1.default.span `
168
+ font-family: var(--catalog-history-sidebar-version-date-font-family);
169
+ font-size: var(--catalog-history-sidebar-version-date-font-size);
170
+ font-weight: var(--catalog-history-sidebar-version-date-font-weight);
171
+ line-height: var(--catalog-history-sidebar-version-date-line-height);
172
+ color: var(--catalog-history-sidebar-version-date-color);
173
+ `;
174
+ const ChevronIcon = styled_components_1.default.div `
175
+ display: flex;
176
+ align-items: center;
177
+ justify-content: center;
178
+ flex-shrink: 0;
179
+ margin-left: auto;
180
+ `;
181
+ const RevisionsList = styled_components_1.default.ul `
182
+ list-style: none;
183
+ margin: 0;
184
+ padding: 0;
185
+ padding-left: var(--catalog-history-sidebar-revisions-padding-left);
186
+ position: relative;
187
+
188
+ &::before {
189
+ content: '';
190
+ position: absolute;
191
+ left: 22px;
192
+ top: 0;
193
+ bottom: 0;
194
+ width: 1px;
195
+ background-color: var(
196
+ --catalog-history-sidebar-revision-line-color,
197
+ var(--border-color-secondary)
198
+ );
199
+ }
200
+ `;
201
+ const RevisionsLimitMessage = styled_components_1.default.div `
202
+ padding: var(--catalog-history-sidebar-revision-item-padding);
203
+ margin-left: calc(-1 * var(--catalog-history-sidebar-revisions-padding-left));
204
+ padding-left: var(--catalog-history-sidebar-revisions-padding-left);
205
+ font-family: var(--catalog-history-sidebar-revision-name-font-family);
206
+ font-size: var(--font-size-sm);
207
+ font-weight: var(--catalog-history-sidebar-revision-name-font-weight);
208
+ line-height: var(--catalog-history-sidebar-revision-name-line-height);
209
+ color: var(--catalog-history-sidebar-revisions-limit-message-color);
210
+ text-align: center;
211
+ `;
212
+ //# sourceMappingURL=CatalogEntityVersionItem.js.map