@eventcatalog/core 5.0.0-beta.2 → 5.0.0-beta.3

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 (64) hide show
  1. package/dist/analytics/analytics.cjs +1 -1
  2. package/dist/analytics/analytics.js +2 -2
  3. package/dist/analytics/log-build.cjs +1 -1
  4. package/dist/analytics/log-build.js +3 -3
  5. package/dist/{chunk-AYNZXUB5.js → chunk-3PKS2IIP.js} +4 -4
  6. package/dist/{chunk-HGRFXTFC.js → chunk-423S2KHN.js} +1 -1
  7. package/dist/{chunk-KIDISU6X.js → chunk-6OC46WQJ.js} +1 -1
  8. package/dist/{chunk-4J2ZM2HX.js → chunk-BH2F5WPN.js} +1 -1
  9. package/dist/{chunk-62EV4IJA.js → chunk-GYIVJXOJ.js} +1 -1
  10. package/dist/{chunk-XARPIXWF.js → chunk-NDJOAITI.js} +1 -1
  11. package/dist/constants.cjs +1 -1
  12. package/dist/constants.js +1 -1
  13. package/dist/eventcatalog.cjs +1 -1
  14. package/dist/eventcatalog.js +13 -13
  15. package/dist/federation/federate.js +4 -4
  16. package/dist/federation/source-provider.js +2 -2
  17. package/dist/generate.cjs +1 -1
  18. package/dist/generate.js +3 -3
  19. package/dist/utils/cli-logger.cjs +1 -1
  20. package/dist/utils/cli-logger.js +2 -2
  21. package/eventcatalog/src/components/Grids/utils.tsx +0 -23
  22. package/eventcatalog/src/components/MDX/CodeGroup/CodeGroup.tsx +6 -1
  23. package/eventcatalog/src/components/SchemaExplorer/SchemaDetailsPanel.tsx +12 -4
  24. package/eventcatalog/src/components/Tables/Discover/DiscoverTable.tsx +4 -62
  25. package/eventcatalog/src/components/Tables/Discover/columns.tsx +17 -150
  26. package/eventcatalog/src/components/Tables/Resources/ResourcesTable.tsx +425 -0
  27. package/eventcatalog/src/components/Tables/RowActionsMenu.tsx +157 -0
  28. package/eventcatalog/src/components/Tables/TablePagination.tsx +82 -0
  29. package/eventcatalog/src/features/ai/chat-api.ts +3 -3
  30. package/eventcatalog/src/features/mcp/apps/generated/viewer.html +75 -74
  31. package/eventcatalog/src/layouts/VerticalSideBarLayout.astro +0 -2
  32. package/eventcatalog/src/pages/architecture/[type]/[id]/[version]/_index.data.spec.ts +52 -63
  33. package/eventcatalog/src/pages/architecture/[type]/[id]/[version]/_index.data.ts +34 -46
  34. package/eventcatalog/src/pages/architecture/[type]/[id]/[version]/index.astro +11 -29
  35. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/resources/_ResourcesPage.astro +79 -0
  36. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/resources/_index.data.spec.ts +32 -14
  37. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/resources/_index.data.ts +63 -58
  38. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/resources/index.astro +2 -62
  39. package/eventcatalog/src/pages/docs/services/[id]/[version]/resources/index.astro +13 -0
  40. package/eventcatalog/src/stores/sidebar-store/builders/domain.ts +24 -42
  41. package/eventcatalog/src/stores/sidebar-store/builders/flow.ts +2 -0
  42. package/eventcatalog/src/stores/sidebar-store/builders/message.ts +2 -0
  43. package/eventcatalog/src/stores/sidebar-store/builders/service.ts +23 -23
  44. package/eventcatalog/src/stores/sidebar-store/builders/shared.ts +13 -0
  45. package/eventcatalog/src/stores/sidebar-store/builders/system.ts +18 -27
  46. package/eventcatalog/src/stores/sidebar-store/state.ts +5 -0
  47. package/eventcatalog/src/styles/tailwind.css +2 -2
  48. package/eventcatalog/src/utils/collections/channels.ts +56 -1
  49. package/eventcatalog/src/utils/collections/flows.ts +50 -1
  50. package/eventcatalog/src/utils/collections/message-connections.ts +60 -0
  51. package/eventcatalog/src/utils/collections/message-triggers.ts +2 -1
  52. package/eventcatalog/src/utils/collections/resource-owners.ts +193 -0
  53. package/eventcatalog/src/utils/collections/resources.ts +310 -0
  54. package/eventcatalog/src/utils/collections/util.ts +31 -0
  55. package/package.json +6 -6
  56. package/eventcatalog/src/components/Grids/DomainGrid.tsx +0 -838
  57. package/eventcatalog/src/components/Grids/MessageGrid.tsx +0 -344
  58. package/eventcatalog/src/components/Grids/SystemGrid.tsx +0 -185
  59. package/eventcatalog/src/components/Grids/components.tsx +0 -170
  60. package/eventcatalog/src/components/Grids/message-link.ts +0 -38
  61. package/eventcatalog/src/components/Tables/SystemResources/SystemResourcesTable.tsx +0 -294
  62. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/resources/_resources.spec.ts +0 -65
  63. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/resources/_resources.ts +0 -46
  64. package/dist/{chunk-A2RZR3U4.js → chunk-6K7XZAYI.js} +3 -3
@@ -36,7 +36,7 @@ module.exports = __toCommonJS(analytics_exports);
36
36
  var import_os = __toESM(require("os"), 1);
37
37
 
38
38
  // package.json
39
- var version = "5.0.0-beta.2";
39
+ var version = "5.0.0-beta.3";
40
40
 
41
41
  // src/constants.ts
42
42
  var VERSION = version;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  raiseEvent
3
- } from "../chunk-XARPIXWF.js";
4
- import "../chunk-62EV4IJA.js";
3
+ } from "../chunk-NDJOAITI.js";
4
+ import "../chunk-GYIVJXOJ.js";
5
5
  export {
6
6
  raiseEvent
7
7
  };
@@ -176,7 +176,7 @@ var verifyRequiredFieldsAreInCatalogConfigFile = async (projectDirectory) => {
176
176
  var import_os = __toESM(require("os"), 1);
177
177
 
178
178
  // package.json
179
- var version = "5.0.0-beta.2";
179
+ var version = "5.0.0-beta.3";
180
180
 
181
181
  // src/constants.ts
182
182
  var VERSION = version;
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  log_build_default
3
- } from "../chunk-KIDISU6X.js";
3
+ } from "../chunk-6OC46WQJ.js";
4
4
  import "../chunk-TQLRG35T.js";
5
5
  import "../chunk-ZAZHAVKB.js";
6
- import "../chunk-XARPIXWF.js";
7
- import "../chunk-62EV4IJA.js";
6
+ import "../chunk-NDJOAITI.js";
7
+ import "../chunk-GYIVJXOJ.js";
8
8
  import "../chunk-RFIXKATC.js";
9
9
  export {
10
10
  log_build_default as default
@@ -1,9 +1,12 @@
1
+ import {
2
+ withFederationOutputTransaction
3
+ } from "./chunk-WRNH5C3U.js";
1
4
  import {
2
5
  composePublicAssets
3
6
  } from "./chunk-5EPNFDT5.js";
4
7
  import {
5
8
  createFederationSourceProvider
6
- } from "./chunk-A2RZR3U4.js";
9
+ } from "./chunk-6K7XZAYI.js";
7
10
  import {
8
11
  createFederationContentCache
9
12
  } from "./chunk-R7Z5ALYI.js";
@@ -11,9 +14,6 @@ import {
11
14
  getFederationDiagnostics,
12
15
  resolveFederationRules
13
16
  } from "./chunk-JJPB6EOZ.js";
14
- import {
15
- withFederationOutputTransaction
16
- } from "./chunk-WRNH5C3U.js";
17
17
  import {
18
18
  getEventCatalogConfigFile
19
19
  } from "./chunk-RFIXKATC.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  logger
3
- } from "./chunk-4J2ZM2HX.js";
3
+ } from "./chunk-BH2F5WPN.js";
4
4
  import {
5
5
  cleanup,
6
6
  getEventCatalogConfigFile
@@ -8,7 +8,7 @@ import {
8
8
  } from "./chunk-ZAZHAVKB.js";
9
9
  import {
10
10
  raiseEvent
11
- } from "./chunk-XARPIXWF.js";
11
+ } from "./chunk-NDJOAITI.js";
12
12
  import {
13
13
  getEventCatalogConfigFile,
14
14
  verifyRequiredFieldsAreInCatalogConfigFile
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  VERSION
3
- } from "./chunk-62EV4IJA.js";
3
+ } from "./chunk-GYIVJXOJ.js";
4
4
 
5
5
  // src/utils/cli-logger.ts
6
6
  import pc from "picocolors";
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "5.0.0-beta.2";
2
+ var version = "5.0.0-beta.3";
3
3
 
4
4
  // src/constants.ts
5
5
  var VERSION = version;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  VERSION
3
- } from "./chunk-62EV4IJA.js";
3
+ } from "./chunk-GYIVJXOJ.js";
4
4
 
5
5
  // src/analytics/analytics.js
6
6
  import os from "os";
@@ -25,7 +25,7 @@ __export(constants_exports, {
25
25
  module.exports = __toCommonJS(constants_exports);
26
26
 
27
27
  // package.json
28
- var version = "5.0.0-beta.2";
28
+ var version = "5.0.0-beta.3";
29
29
 
30
30
  // src/constants.ts
31
31
  var VERSION = version;
package/dist/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  VERSION
3
- } from "./chunk-62EV4IJA.js";
3
+ } from "./chunk-GYIVJXOJ.js";
4
4
  export {
5
5
  VERSION
6
6
  };
@@ -181,7 +181,7 @@ var verifyRequiredFieldsAreInCatalogConfigFile = async (projectDirectory) => {
181
181
  var import_picocolors = __toESM(require("picocolors"), 1);
182
182
 
183
183
  // package.json
184
- var version = "5.0.0-beta.2";
184
+ var version = "5.0.0-beta.3";
185
185
 
186
186
  // src/constants.ts
187
187
  var VERSION = version;
@@ -1,30 +1,30 @@
1
- import {
2
- runMigrations
3
- } from "./chunk-XUAF2H54.js";
4
- import "./chunk-CA4U2JP7.js";
5
1
  import {
6
2
  log_build_default
7
- } from "./chunk-KIDISU6X.js";
3
+ } from "./chunk-6OC46WQJ.js";
8
4
  import {
9
5
  getLicenseStatus,
10
6
  printLicenseStatus
11
7
  } from "./chunk-TQLRG35T.js";
12
8
  import "./chunk-ZAZHAVKB.js";
9
+ import {
10
+ runMigrations
11
+ } from "./chunk-XUAF2H54.js";
12
+ import "./chunk-CA4U2JP7.js";
13
13
  import {
14
14
  FederationConflictError,
15
15
  FederationDiagnosticError,
16
16
  federateCatalog
17
- } from "./chunk-AYNZXUB5.js";
17
+ } from "./chunk-3PKS2IIP.js";
18
+ import "./chunk-WRNH5C3U.js";
18
19
  import "./chunk-5EPNFDT5.js";
19
- import "./chunk-A2RZR3U4.js";
20
+ import "./chunk-6K7XZAYI.js";
21
+ import "./chunk-352FGP6W.js";
20
22
  import "./chunk-R7Z5ALYI.js";
21
23
  import {
22
24
  getFederationDiagnosticCounts,
23
25
  getVisibleFederationDiagnostics
24
26
  } from "./chunk-JJPB6EOZ.js";
25
27
  import "./chunk-SDZQJTJW.js";
26
- import "./chunk-352FGP6W.js";
27
- import "./chunk-WRNH5C3U.js";
28
28
  import {
29
29
  getProjectOutDir,
30
30
  isAuthEnabled,
@@ -33,10 +33,10 @@ import {
33
33
  } from "./chunk-MDWB5HLO.js";
34
34
  import {
35
35
  generate
36
- } from "./chunk-HGRFXTFC.js";
36
+ } from "./chunk-423S2KHN.js";
37
37
  import {
38
38
  logger
39
- } from "./chunk-4J2ZM2HX.js";
39
+ } from "./chunk-BH2F5WPN.js";
40
40
  import {
41
41
  resolve_catalog_dependencies_default
42
42
  } from "./chunk-36RYTYT5.js";
@@ -50,7 +50,7 @@ import {
50
50
  import {
51
51
  watch
52
52
  } from "./chunk-U63GDPPY.js";
53
- import "./chunk-XARPIXWF.js";
53
+ import "./chunk-NDJOAITI.js";
54
54
  import {
55
55
  getAstroConfigPath
56
56
  } from "./chunk-VIJJ7JKH.js";
@@ -66,7 +66,7 @@ import {
66
66
  } from "./chunk-LFQJXLHG.js";
67
67
  import {
68
68
  VERSION
69
- } from "./chunk-62EV4IJA.js";
69
+ } from "./chunk-GYIVJXOJ.js";
70
70
  import {
71
71
  getEventCatalogConfigFile,
72
72
  verifyRequiredFieldsAreInCatalogConfigFile
@@ -2,14 +2,14 @@ import {
2
2
  FederationConflictError,
3
3
  FederationDiagnosticError,
4
4
  federateCatalog
5
- } from "../chunk-AYNZXUB5.js";
5
+ } from "../chunk-3PKS2IIP.js";
6
+ import "../chunk-WRNH5C3U.js";
6
7
  import "../chunk-5EPNFDT5.js";
7
- import "../chunk-A2RZR3U4.js";
8
+ import "../chunk-6K7XZAYI.js";
9
+ import "../chunk-352FGP6W.js";
8
10
  import "../chunk-R7Z5ALYI.js";
9
11
  import "../chunk-JJPB6EOZ.js";
10
12
  import "../chunk-SDZQJTJW.js";
11
- import "../chunk-352FGP6W.js";
12
- import "../chunk-WRNH5C3U.js";
13
13
  import "../chunk-RFIXKATC.js";
14
14
  export {
15
15
  FederationConflictError,
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  createFederationSourceProvider
3
- } from "../chunk-A2RZR3U4.js";
4
- import "../chunk-SDZQJTJW.js";
3
+ } from "../chunk-6K7XZAYI.js";
5
4
  import "../chunk-352FGP6W.js";
5
+ import "../chunk-SDZQJTJW.js";
6
6
  export {
7
7
  createFederationSourceProvider
8
8
  };
package/dist/generate.cjs CHANGED
@@ -112,7 +112,7 @@ var getEventCatalogConfigFile = async (projectDirectory) => {
112
112
  var import_picocolors = __toESM(require("picocolors"), 1);
113
113
 
114
114
  // package.json
115
- var version = "5.0.0-beta.2";
115
+ var version = "5.0.0-beta.3";
116
116
 
117
117
  // src/constants.ts
118
118
  var VERSION = version;
package/dist/generate.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  generate
3
- } from "./chunk-HGRFXTFC.js";
4
- import "./chunk-4J2ZM2HX.js";
5
- import "./chunk-62EV4IJA.js";
3
+ } from "./chunk-423S2KHN.js";
4
+ import "./chunk-BH2F5WPN.js";
5
+ import "./chunk-GYIVJXOJ.js";
6
6
  import "./chunk-RFIXKATC.js";
7
7
  export {
8
8
  generate
@@ -36,7 +36,7 @@ module.exports = __toCommonJS(cli_logger_exports);
36
36
  var import_picocolors = __toESM(require("picocolors"), 1);
37
37
 
38
38
  // package.json
39
- var version = "5.0.0-beta.2";
39
+ var version = "5.0.0-beta.3";
40
40
 
41
41
  // src/constants.ts
42
42
  var VERSION = version;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  logger
3
- } from "../chunk-4J2ZM2HX.js";
4
- import "../chunk-62EV4IJA.js";
3
+ } from "../chunk-BH2F5WPN.js";
4
+ import "../chunk-GYIVJXOJ.js";
5
5
  export {
6
6
  logger
7
7
  };
@@ -24,26 +24,3 @@ export const getCollectionStyles = (collection: CollectionMessageTypes | Collect
24
24
  return { color: 'gray', Icon: EnvelopeIcon };
25
25
  }
26
26
  };
27
-
28
- export interface PaginationProps {
29
- currentPage: number;
30
- totalPages: number;
31
- totalItems: number;
32
- itemsPerPage: number;
33
- onPageChange: (page: number) => void;
34
- }
35
-
36
- export interface SearchBarProps {
37
- searchQuery: string;
38
- onSearchChange: (query: string) => void;
39
- placeholder?: string;
40
- totalResults?: number;
41
- totalItems?: number;
42
- }
43
-
44
- export interface TypeFilterProps {
45
- selectedTypes: CollectionMessageTypes[];
46
- onTypeChange: (types: CollectionMessageTypes[]) => void;
47
- filteredCount?: number;
48
- totalCount?: number;
49
- }
@@ -167,7 +167,12 @@ export default function CodeGroup({
167
167
  hidden={index !== active}
168
168
  tabIndex={0}
169
169
  >
170
- {item.html !== undefined ? <div dangerouslySetInnerHTML={{ __html: item.html }} /> : item.content}
170
+ {/* Astro's router marks scripts in this HTML with data-astro-exec before hydration, so it never matches exactly. */}
171
+ {item.html !== undefined ? (
172
+ <div suppressHydrationWarning dangerouslySetInnerHTML={{ __html: item.html }} />
173
+ ) : (
174
+ item.content
175
+ )}
171
176
  </div>
172
177
  ))}
173
178
  </div>
@@ -384,6 +384,9 @@ export default function SchemaDetailsPanel({
384
384
  [diffToVersion, uniqueAvailableVersions]
385
385
  );
386
386
  const comparing = (activeTab === 'versions' && hasMultipleVersions) || isDiffModalOpen;
387
+ const contentReady = !content.loading && !content.error;
388
+ // Server-rendered examples stay mounted and are only shown on the Examples tab (see the tab content below).
389
+ const showRenderedExamples = !!renderedExamples && activeTab === 'examples' && contentReady;
387
390
 
388
391
  const compareWithCurrent = (version: string) => {
389
392
  setDiffFromVersion(version);
@@ -705,11 +708,16 @@ export default function SchemaDetailsPanel({
705
708
 
706
709
  {/* Tab content */}
707
710
  <div className="flex-1 min-h-0 overflow-hidden p-6">
708
- {content.loading || content.error ? (
711
+ {/* Always render the examples slot and hide it on other tabs. Astro moves a slot missing from the
712
+ server HTML into a <template>, where its island scripts never run and no island on the page hydrates. */}
713
+ {renderedExamples && (
714
+ <div className="h-full overflow-auto pr-1" hidden={!showRenderedExamples}>
715
+ {renderedExamples}
716
+ </div>
717
+ )}
718
+ {!contentReady ? (
709
719
  <SchemaLoadingState loading={content.loading} error={content.error} retry={content.retry} />
710
- ) : activeTab === 'examples' && renderedExamples ? (
711
- <div className="h-full overflow-auto pr-1">{renderedExamples}</div>
712
- ) : activeTab === 'examples' && examples.length > 0 ? (
720
+ ) : showRenderedExamples ? null : activeTab === 'examples' && examples.length > 0 ? (
713
721
  <ExamplesViewer examples={examples} />
714
722
  ) : activeTab === 'metadata' ? (
715
723
  <SchemaMetadata message={message} owners={showOwners ? owners : []} />
@@ -11,7 +11,7 @@ import {
11
11
  type ColumnFiltersState,
12
12
  type SortingState,
13
13
  } from '@tanstack/react-table';
14
- import { ArrowDown, ArrowUp, ArrowUpDown, ChevronLeft, ChevronRight, SearchX, X, Search, Users } from 'lucide-react';
14
+ import { ArrowDown, ArrowUp, ArrowUpDown, SearchX, X, Search, Users } from 'lucide-react';
15
15
  import { UserIcon } from '@heroicons/react/24/outline';
16
16
  import { useEffect, useMemo, useState } from 'react';
17
17
  import type { TableConfiguration } from '@types';
@@ -19,6 +19,7 @@ import { isSameVersion } from '@utils/collections/version-compare';
19
19
  import { resolveIconUrl } from '@utils/icon';
20
20
  import { FilterDropdown, CheckboxItem } from './FilterComponents';
21
21
  import { getDiscoverColumns } from './columns';
22
+ import { TablePagination, useStoredPageSize } from '../TablePagination';
22
23
  import { formatAdrStatus, type AdrStatus } from '@utils/collections/adr-constants';
23
24
  import { buildDiscoverFilterSearch, filterKnownValues, parseDiscoverFilterSearch } from './url-filters';
24
25
 
@@ -243,18 +244,7 @@ export function DiscoverTable<T extends DiscoverTableData>({
243
244
  const [columnFilters, setColumnFilters] = useState<ColumnFiltersState>([]);
244
245
  const [sorting, setSorting] = useState<SortingState>([]);
245
246
  const [tableFilter, setTableFilter] = useState(initialUrlFilters.q);
246
- const PAGE_SIZE_OPTIONS = [10, 25, 50, 100];
247
- const PAGE_SIZE_STORAGE_KEY = 'eventcatalog-discover-page-size';
248
- const [pageSize, setPageSize] = useState<number>(() => {
249
- if (typeof window === 'undefined') return 10;
250
- const stored = Number(window.localStorage.getItem(PAGE_SIZE_STORAGE_KEY));
251
- return PAGE_SIZE_OPTIONS.includes(stored) ? stored : 10;
252
- });
253
- useEffect(() => {
254
- if (typeof window !== 'undefined') {
255
- window.localStorage.setItem(PAGE_SIZE_STORAGE_KEY, String(pageSize));
256
- }
257
- }, [pageSize]);
247
+ const [pageSize, setPageSize] = useStoredPageSize('eventcatalog-discover-page-size');
258
248
  const [showOnlyLatest, setShowOnlyLatest] = useState(initialUrlFilters.showOnlyLatest);
259
249
  const [onlyShowDrafts, setOnlyShowDrafts] = useState(initialUrlFilters.onlyShowDrafts);
260
250
  const [selectedDomains, setSelectedDomains] = useState<string[]>(() =>
@@ -1287,55 +1277,7 @@ export function DiscoverTable<T extends DiscoverTableData>({
1287
1277
  </div>
1288
1278
  </div>
1289
1279
 
1290
- {/* Pagination */}
1291
- <div className="flex-shrink-0 flex items-center justify-between px-6 py-3 border-t border-[rgb(var(--ec-page-border))]">
1292
- <div className="flex items-center gap-3 text-xs text-[rgb(var(--ec-page-text-muted))]">
1293
- {totalResults > 0 && (
1294
- <span>
1295
- <span className="font-medium text-[rgb(var(--ec-page-text))]">{table.getRowModel().rows.length}</span> of{' '}
1296
- <span className="font-medium text-[rgb(var(--ec-page-text))]">{totalResults}</span> results
1297
- </span>
1298
- )}
1299
- {totalResults > 0 && <span aria-hidden className="h-3 w-px bg-[rgb(var(--ec-page-border))]" />}
1300
- <label className="flex items-center gap-1.5">
1301
- <span>Per page</span>
1302
- <select
1303
- value={pageSize}
1304
- onChange={(e) => setPageSize(Number(e.target.value))}
1305
- className="cursor-pointer rounded bg-transparent px-1 py-0.5 font-medium text-[rgb(var(--ec-page-text))] hover:bg-[rgb(var(--ec-content-hover))] focus:bg-[rgb(var(--ec-content-hover))] focus:outline-none"
1306
- >
1307
- {PAGE_SIZE_OPTIONS.map((size) => (
1308
- <option key={size} value={size}>
1309
- {size}
1310
- </option>
1311
- ))}
1312
- </select>
1313
- </label>
1314
- </div>
1315
- <div className="flex items-center gap-1.5">
1316
- <button
1317
- className="p-1.5 text-[rgb(var(--ec-icon-color))] hover:text-[rgb(var(--ec-page-text))] disabled:opacity-30 disabled:cursor-not-allowed transition-colors"
1318
- onClick={() => table.previousPage()}
1319
- disabled={!table.getCanPreviousPage()}
1320
- title="Previous page"
1321
- >
1322
- <ChevronLeft className="w-4 h-4" />
1323
- </button>
1324
- <span className="text-xs tabular-nums text-[rgb(var(--ec-page-text-muted))] min-w-[60px] text-center">
1325
- <span className="font-medium text-[rgb(var(--ec-page-text))]">{table.getState().pagination.pageIndex + 1}</span>
1326
- {' / '}
1327
- <span>{table.getPageCount() || 1}</span>
1328
- </span>
1329
- <button
1330
- className="p-1.5 text-[rgb(var(--ec-icon-color))] hover:text-[rgb(var(--ec-page-text))] disabled:opacity-30 disabled:cursor-not-allowed transition-colors"
1331
- onClick={() => table.nextPage()}
1332
- disabled={!table.getCanNextPage()}
1333
- title="Next page"
1334
- >
1335
- <ChevronRight className="w-4 h-4" />
1336
- </button>
1337
- </div>
1338
- </div>
1280
+ <TablePagination table={table} pageSize={pageSize} onPageSizeChange={setPageSize} />
1339
1281
  </div>
1340
1282
  </div>
1341
1283
  );
@@ -1,25 +1,16 @@
1
1
  import { createColumnHelper } from '@tanstack/react-table';
2
- import { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
3
- import { createPortal } from 'react-dom';
4
- import { DocumentTextIcon, MapIcon } from '@heroicons/react/24/solid';
5
- import {
6
- ArrowDownIcon,
7
- ArrowTopRightOnSquareIcon,
8
- ArrowUpIcon,
9
- EllipsisVerticalIcon,
10
- StarIcon,
11
- } from '@heroicons/react/24/outline';
2
+ import { useMemo, useState } from 'react';
3
+ import { ArrowDownIcon, ArrowTopRightOnSquareIcon, ArrowUpIcon } from '@heroicons/react/24/outline';
12
4
  import { buildUrl } from '@utils/url-builder';
13
5
  import { getColorAndIconForCollection } from '@utils/collections/icons';
14
6
  import { getCollectionTextColorClass } from '@utils/collection-colors';
15
7
  import { getBadgeHref, getBadgeReactStyle } from '@utils/badge-styles';
16
8
  import { isIconPath, resolveIconUrl } from '@utils/icon';
17
- import { useStore } from '@nanostores/react';
18
- import { favoritesStore, toggleFavorite, type FavoriteItem } from '../../../stores/favorites-store';
19
9
  import type { DiscoverTableData, CollectionType } from './DiscoverTable';
20
10
  import type { TableConfiguration } from '@types';
21
11
  import { formatAdrDate, isAdrCollection } from '@utils/collections/adr-constants';
22
12
  import { CornerDownRight } from 'lucide-react';
13
+ import { RowActionsMenu } from '../RowActionsMenu';
23
14
 
24
15
  const columnHelper = createColumnHelper<DiscoverTableData>();
25
16
 
@@ -167,147 +158,23 @@ const ResourceNameCell = ({ item }: { item: DiscoverTableData }) => {
167
158
  );
168
159
  };
169
160
 
170
- const MENU_WIDTH = 280;
171
- const MENU_GAP = 6;
172
-
173
- const RowActionsMenu = ({ item, collectionType }: { item: DiscoverTableData; collectionType: CollectionType }) => {
174
- const [isOpen, setIsOpen] = useState(false);
175
- const buttonRef = useRef<HTMLButtonElement>(null);
176
- const menuRef = useRef<HTMLDivElement>(null);
177
- const [menuPosition, setMenuPosition] = useState<{ top: number; left: number } | null>(null);
178
- const favorites = useStore(favoritesStore);
179
- const href = buildUrl(`/docs/${item.collection}/${item.data.id}/${item.data.version}`);
180
- const visualiserHref = buildUrl(`/visualiser/${item.collection}/${item.data.id}/${item.data.version}`);
181
- const hasVisualiser = !isAdrCollection(item.collection);
182
- const nodeKey = `${item.collection}-${item.data.id}-${item.data.version}`;
183
- const badgeLabel =
161
+ // Discover keys favorites as `${collection}-${id}-${version}`; keep that so existing favorites still match.
162
+ const DiscoverRowActions = ({ item, collectionType }: { item: DiscoverTableData; collectionType: CollectionType }) => {
163
+ const badge =
184
164
  collectionType === 'external-systems'
185
165
  ? 'External System'
186
166
  : collectionType.charAt(0).toUpperCase() + collectionType.slice(1, -1);
187
- const isFavorite = favorites.some((fav) => fav.nodeKey === nodeKey);
188
-
189
- // The table lives inside scrollable, overflow-hidden containers, so the menu is
190
- // rendered in a portal with fixed positioning to avoid being clipped.
191
- const updatePosition = () => {
192
- const button = buttonRef.current;
193
- if (!button) return;
194
- const rect = button.getBoundingClientRect();
195
- const menuHeight = menuRef.current?.offsetHeight ?? 0;
196
- const spaceBelow = window.innerHeight - rect.bottom;
197
-
198
- // Flip above the trigger when there isn't enough room below it.
199
- const openUpwards = menuHeight > 0 && spaceBelow < menuHeight + MENU_GAP && rect.top > spaceBelow;
200
- const top = openUpwards ? rect.top - menuHeight - MENU_GAP : rect.bottom + MENU_GAP;
201
- const left = Math.max(MENU_GAP, rect.right - MENU_WIDTH);
202
-
203
- setMenuPosition({ top, left });
204
- };
205
-
206
- useLayoutEffect(() => {
207
- if (!isOpen) return;
208
- updatePosition();
209
- // eslint-disable-next-line react-hooks/exhaustive-deps
210
- }, [isOpen]);
211
-
212
- useEffect(() => {
213
- if (!isOpen) return;
214
-
215
- const handlePointerDown = (event: MouseEvent) => {
216
- const target = event.target as Node;
217
- if (!menuRef.current?.contains(target) && !buttonRef.current?.contains(target)) {
218
- setIsOpen(false);
219
- }
220
- };
221
-
222
- const handleEscape = (event: KeyboardEvent) => {
223
- if (event.key === 'Escape') {
224
- setIsOpen(false);
225
- }
226
- };
227
-
228
- const handleReposition = () => updatePosition();
229
-
230
- document.addEventListener('mousedown', handlePointerDown);
231
- document.addEventListener('keydown', handleEscape);
232
- window.addEventListener('resize', handleReposition);
233
- window.addEventListener('scroll', handleReposition, true);
234
-
235
- return () => {
236
- document.removeEventListener('mousedown', handlePointerDown);
237
- document.removeEventListener('keydown', handleEscape);
238
- window.removeEventListener('resize', handleReposition);
239
- window.removeEventListener('scroll', handleReposition, true);
240
- };
241
- }, [isOpen]);
242
-
243
- const handleToggleFavorite = () => {
244
- const favoriteItem: FavoriteItem = {
245
- nodeKey,
246
- path: [],
247
- title: item.data.name,
248
- badge: badgeLabel,
249
- href,
250
- };
251
- toggleFavorite(favoriteItem);
252
- setIsOpen(false);
253
- };
254
-
255
167
  return (
256
- <div className="relative flex justify-end">
257
- <button
258
- ref={buttonRef}
259
- type="button"
260
- aria-haspopup="menu"
261
- aria-expanded={isOpen}
262
- onClick={() => setIsOpen((prev) => !prev)}
263
- className="rounded-md p-1.5 text-[rgb(var(--ec-icon-color))] transition-colors hover:bg-[rgb(var(--ec-content-hover)/0.5)] hover:text-[rgb(var(--ec-page-text))]"
264
- >
265
- <EllipsisVerticalIcon className="h-4 w-4" />
266
- </button>
267
-
268
- {isOpen &&
269
- typeof document !== 'undefined' &&
270
- createPortal(
271
- <div
272
- ref={menuRef}
273
- role="menu"
274
- style={{
275
- position: 'fixed',
276
- top: menuPosition?.top ?? -9999,
277
- left: menuPosition?.left ?? -9999,
278
- width: MENU_WIDTH,
279
- visibility: menuPosition ? 'visible' : 'hidden',
280
- }}
281
- className="z-50 overflow-hidden rounded-xl border border-[rgb(var(--ec-page-border))] bg-[rgb(var(--ec-dropdown-bg))] shadow-xl"
282
- >
283
- <a
284
- href={href}
285
- className="flex items-center gap-2.5 px-3 py-2.5 text-xs font-medium text-[rgb(var(--ec-page-text))] transition-colors hover:bg-[rgb(var(--ec-content-hover))] hover:text-[rgb(var(--ec-accent))]"
286
- >
287
- <DocumentTextIcon className="h-3.5 w-3.5 text-[rgb(var(--ec-page-text-muted))]" />
288
- View documentation
289
- </a>
290
- {hasVisualiser && (
291
- <a
292
- href={visualiserHref}
293
- className="flex items-center gap-2.5 px-3 py-2.5 text-xs font-medium text-[rgb(var(--ec-page-text))] transition-colors hover:bg-[rgb(var(--ec-content-hover))] hover:text-[rgb(var(--ec-accent))]"
294
- >
295
- <MapIcon className="h-3.5 w-3.5 text-[rgb(var(--ec-page-text-muted))]" />
296
- View in visualiser
297
- </a>
298
- )}
299
- <button
300
- type="button"
301
- onClick={handleToggleFavorite}
302
- className="flex w-full items-center gap-2.5 px-3 py-2.5 text-left text-xs font-medium text-[rgb(var(--ec-page-text))] transition-colors hover:bg-[rgb(var(--ec-content-hover))] hover:text-[rgb(var(--ec-accent))]"
303
- >
304
- <StarIcon className="h-3.5 w-3.5 text-[rgb(var(--ec-page-text-muted))]" />
305
- {isFavorite ? 'Remove from favorites' : 'Add to favorites'}
306
- </button>
307
- </div>,
308
- document.body
309
- )}
310
- </div>
168
+ <RowActionsMenu
169
+ title={item.data.name}
170
+ href={buildUrl(`/docs/${item.collection}/${item.data.id}/${item.data.version}`)}
171
+ visualiserHref={
172
+ isAdrCollection(item.collection)
173
+ ? undefined
174
+ : buildUrl(`/visualiser/${item.collection}/${item.data.id}/${item.data.version}`)
175
+ }
176
+ favorite={{ nodeKey: `${item.collection}-${item.data.id}-${item.data.version}`, badge }}
177
+ />
311
178
  );
312
179
  };
313
180
 
@@ -319,7 +186,7 @@ const createActionsColumn = (collectionType: CollectionType, tableConfiguration:
319
186
  enableSorting: false,
320
187
  cell: (info) => {
321
188
  const item = info.row.original;
322
- return <RowActionsMenu item={item} collectionType={collectionType} />;
189
+ return <DiscoverRowActions item={item} collectionType={collectionType} />;
323
190
  },
324
191
  meta: {
325
192
  showFilter: false,