@eventcatalog/core 2.22.0 → 2.23.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.
@@ -0,0 +1,264 @@
1
+ .TreeViewRootUlStyles {
2
+ padding: 0;
3
+ margin: 0;
4
+ list-style: none;
5
+
6
+ /*
7
+ * WARNING: This is a performance optimization.
8
+ *
9
+ * We define styles for the tree items at the root level of the tree
10
+ * to avoid recomputing the styles for each item when the tree updates.
11
+ * We're sacrificing maintainability for performance because TreeView
12
+ * needs to be performant enough to handle large trees (thousands of items).
13
+ *
14
+ * This is intended to be a temporary solution until we can improve the
15
+ * performance of our styling patterns.
16
+ *
17
+ * Do NOT copy this pattern without understanding the tradeoffs.
18
+ */
19
+ .TreeViewItem {
20
+ outline: none;
21
+
22
+ &:focus-visible > div,
23
+ &.focus-visible > div {
24
+ box-shadow: var(--boxShadow-thick) /* var(--fgColor-accent) */ slategray;
25
+
26
+ @media (forced-colors: active) {
27
+ outline: 2px solid HighlightText;
28
+ outline-offset: -2;
29
+ }
30
+ }
31
+
32
+ &[data-has-leading-action] {
33
+ --has-leading-action: 1;
34
+ }
35
+ }
36
+
37
+ .TreeViewItemContainer {
38
+ --level: 1;
39
+ --toggle-width: 1rem;
40
+ --min-item-height: 2rem;
41
+
42
+ position: relative;
43
+ display: grid;
44
+ width: 100%;
45
+ font-size: var(--text-body-size-medium);
46
+ color: var(--fgColor-default);
47
+ cursor: pointer;
48
+ border-radius: var(--borderRadius-medium);
49
+ grid-template-columns: var(--spacer-width) var(--leading-action-width) 1fr var(--toggle-width);
50
+ grid-template-areas: 'spacer leadingAction content toggle';
51
+
52
+ --leading-action-width: calc(var(--has-leading-action, 0) * 1.5rem);
53
+ --spacer-width: calc(calc(var(--level) - 1) * (var(--toggle-width) / 2));
54
+
55
+ &:hover {
56
+ background-color: var(--control-transparent-bgColor-hover);
57
+
58
+ @media (forced-colors: active) {
59
+ outline: 2px solid transparent;
60
+ outline-offset: -2px;
61
+ }
62
+ }
63
+
64
+ @media (pointer: coarse) {
65
+ --toggle-width: 1.5rem;
66
+ --min-item-height: 2.75rem;
67
+ }
68
+
69
+ &:has(.TreeViewItemSkeleton):hover {
70
+ cursor: default;
71
+ background-color: transparent;
72
+
73
+ @media (forced-colors: active) {
74
+ outline: none;
75
+ }
76
+ }
77
+ }
78
+
79
+ &:where([data-omit-spacer='true']) .TreeViewItemContainer {
80
+ grid-template-columns: 0 0 1fr 0;
81
+ }
82
+
83
+ .TreeViewItem[aria-current='true'] > .TreeViewItemContainer {
84
+ background-color: var(--control-transparent-bgColor-selected);
85
+
86
+ /* Current item indicator */
87
+ /* stylelint-disable-next-line selector-max-specificity */
88
+ &::after {
89
+ position: absolute;
90
+ top: calc(50% - var(--base-size-12));
91
+ left: calc(-1 * var(--base-size-8));
92
+ width: 0.25rem;
93
+ height: 1.5rem;
94
+ content: '';
95
+
96
+ /*
97
+ * Use fgColor accent for consistency across all themes. Using the "correct" variable,
98
+ * --bgColor-accent-emphasis, causes vrt failures for dark high contrast mode
99
+ */
100
+ /* stylelint-disable-next-line primer/colors */
101
+ background-color: var(--fgColor-accent);
102
+ border-radius: var(--borderRadius-medium);
103
+
104
+ @media (forced-colors: active) {
105
+ background-color: HighlightText;
106
+ }
107
+ }
108
+ }
109
+
110
+ .TreeViewItemToggle {
111
+ display: flex;
112
+ height: 100%;
113
+
114
+ /* The toggle should appear vertically centered for single-line items, but remain at the top for items that wrap
115
+ across more lines. */
116
+ /* stylelint-disable-next-line primer/spacing */
117
+ padding-top: calc(var(--min-item-height) / 2 - var(--base-size-12) / 2);
118
+ color: var(--fgColor-muted);
119
+ grid-area: toggle;
120
+ justify-content: center;
121
+ align-items: flex-start;
122
+ }
123
+
124
+ .TreeViewItemToggleHover:hover {
125
+ background-color: var(--control-transparent-bgColor-hover);
126
+ }
127
+
128
+ .TreeViewItemToggleEnd {
129
+ border-top-left-radius: var(--borderRadius-medium);
130
+ border-bottom-left-radius: var(--borderRadius-medium);
131
+ }
132
+
133
+ .TreeViewItemContent {
134
+ display: flex;
135
+ height: 100%;
136
+ padding: 0 var(--base-size-8);
137
+
138
+ /* The dynamic top and bottom padding to maintain the minimum item height for single line items */
139
+ /* stylelint-disable-next-line primer/spacing */
140
+ padding-top: calc((var(--min-item-height) - var(--custom-line-height, 1.3rem)) / 2);
141
+ /* stylelint-disable-next-line primer/spacing */
142
+ padding-bottom: calc((var(--min-item-height) - var(--custom-line-height, 1.3rem)) / 2);
143
+ line-height: var(--custom-line-height, var(--text-body-lineHeight-medium, 1.4285));
144
+ grid-area: content;
145
+ gap: var(--stack-gap-condensed);
146
+ }
147
+
148
+ .TreeViewItemContentText {
149
+ flex: 1 1 auto;
150
+ width: 0;
151
+ }
152
+
153
+ &:where([data-truncate-text='true']) .TreeViewItemContentText {
154
+ overflow: hidden;
155
+ text-overflow: ellipsis;
156
+ white-space: nowrap;
157
+ }
158
+
159
+ &:where([data-truncate-text='false']) .TreeViewItemContentText {
160
+ word-break: break-word;
161
+ }
162
+
163
+ .TreeViewItemVisual {
164
+ display: flex;
165
+
166
+ /* The visual icons should appear vertically centered for single-line items, but remain at the top for items that wrap
167
+ across more lines. */
168
+ height: var(--custom-line-height, 1.3rem);
169
+ color: var(--fgColor-muted);
170
+ align-items: center;
171
+ }
172
+
173
+ .TreeViewItemLeadingAction {
174
+ display: flex;
175
+ color: var(--fgColor-muted);
176
+ grid-area: leadingAction;
177
+
178
+ & > button {
179
+ flex-shrink: 1;
180
+ }
181
+ }
182
+
183
+ .TreeViewItemLevelLine {
184
+ width: 100%;
185
+ height: 100%;
186
+
187
+ /*
188
+ * On devices without hover, the nesting indicator lines
189
+ * appear at all times.
190
+ */
191
+ border-color: var(--borderColor-muted);
192
+ border-right: var(--borderWidth-thin) solid;
193
+ }
194
+
195
+ /*
196
+ * On devices with :hover support, the nesting indicator lines
197
+ * fade in when the user mouses over the entire component,
198
+ * or when there's focus inside the component. This makes
199
+ * sure the component remains simple when not in use.
200
+ */
201
+ @media (hover: hover) {
202
+ .TreeViewItemLevelLine {
203
+ border-color: transparent;
204
+ }
205
+
206
+ &:hover .TreeViewItemLevelLine,
207
+ &:focus-within .TreeViewItemLevelLine {
208
+ border-color: var(--borderColor-muted);
209
+ }
210
+ }
211
+
212
+ .TreeViewDirectoryIcon {
213
+ display: grid;
214
+ color: var(--treeViewItem-leadingVisual-iconColor-rest);
215
+ }
216
+
217
+ .TreeViewVisuallyHidden {
218
+ position: absolute;
219
+ width: 1px;
220
+ height: 1px;
221
+ padding: 0;
222
+ /* stylelint-disable-next-line primer/spacing */
223
+ margin: -1px;
224
+ overflow: hidden;
225
+ clip: rect(0, 0, 0, 0);
226
+ white-space: nowrap;
227
+ border-width: 0;
228
+ }
229
+ }
230
+
231
+ .TreeViewSkeletonItemContainerStyle {
232
+ display: flex;
233
+ align-items: center;
234
+ column-gap: 0.5rem;
235
+ height: 2rem;
236
+
237
+ @media (pointer: coarse) {
238
+ height: 2.75rem;
239
+ }
240
+
241
+ &:nth-of-type(5n + 1) {
242
+ --tree-item-loading-width: 67%;
243
+ }
244
+
245
+ &:nth-of-type(5n + 2) {
246
+ --tree-item-loading-width: 47%;
247
+ }
248
+
249
+ &:nth-of-type(5n + 3) {
250
+ --tree-item-loading-width: 73%;
251
+ }
252
+
253
+ &:nth-of-type(5n + 4) {
254
+ --tree-item-loading-width: 64%;
255
+ }
256
+
257
+ &:nth-of-type(5n + 5) {
258
+ --tree-item-loading-width: 50%;
259
+ }
260
+ }
261
+
262
+ .TreeItemSkeletonTextStyles {
263
+ width: var(--tree-item-loading-width, 67%);
264
+ }
@@ -0,0 +1,95 @@
1
+ import React from 'react';
2
+ // import {warning} from '../utils/warning'
3
+
4
+ // slot config allows 2 options:
5
+ // 1. Component to match, example: { leadingVisual: LeadingVisual }
6
+ type ComponentMatcher = React.ElementType<Props>;
7
+ // 2. Component to match + a test function, example: { blockDescription: [Description, props => props.variant === 'block'] }
8
+ type ComponentAndPropsMatcher = [ComponentMatcher, (props: Props) => boolean];
9
+
10
+ export type SlotConfig = Record<string, ComponentMatcher | ComponentAndPropsMatcher>;
11
+
12
+ // We don't know what the props are yet, we set them later based on slot config
13
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
+ type Props = any;
15
+
16
+ type SlotElements<Config extends SlotConfig> = {
17
+ [Property in keyof Config]: SlotValue<Config, Property>;
18
+ };
19
+
20
+ type SlotValue<Config, Property extends keyof Config> = Config[Property] extends React.ElementType // config option 1
21
+ ? React.ReactElement<React.ComponentPropsWithoutRef<Config[Property]>, Config[Property]>
22
+ : Config[Property] extends readonly [
23
+ infer ElementType extends React.ElementType, // config option 2, infer array[0] as component
24
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
25
+ infer _testFn, // even though we don't use testFn, we need to infer it to support types for slots.*.props
26
+ ]
27
+ ? React.ReactElement<React.ComponentPropsWithoutRef<ElementType>, ElementType>
28
+ : never; // useful for narrowing types, third option is not possible
29
+
30
+ /**
31
+ * Extract components from `children` so we can render them in different places,
32
+ * allowing us to implement components with SSR-compatible slot APIs.
33
+ * Note: We can only extract direct children, not nested ones.
34
+ */
35
+ export function useSlots<Config extends SlotConfig>(
36
+ children: React.ReactNode,
37
+ config: Config
38
+ ): [Partial<SlotElements<Config>>, React.ReactNode[]] {
39
+ // Object mapping slot names to their elements
40
+ const slots: Partial<SlotElements<Config>> = mapValues(config, () => undefined);
41
+
42
+ // Array of elements that are not slots
43
+ const rest: React.ReactNode[] = [];
44
+
45
+ const keys = Object.keys(config) as Array<keyof Config>;
46
+ const values = Object.values(config);
47
+
48
+ // eslint-disable-next-line github/array-foreach
49
+ React.Children.forEach(children, (child) => {
50
+ if (!React.isValidElement(child)) {
51
+ rest.push(child);
52
+ return;
53
+ }
54
+
55
+ const index = values.findIndex((value) => {
56
+ if (Array.isArray(value)) {
57
+ const [component, testFn] = value;
58
+ return child.type === component && testFn(child.props);
59
+ } else {
60
+ return child.type === value;
61
+ }
62
+ });
63
+
64
+ // If the child is not a slot, add it to the `rest` array
65
+ if (index === -1) {
66
+ rest.push(child);
67
+ return;
68
+ }
69
+
70
+ const slotKey = keys[index];
71
+
72
+ // If slot is already filled, ignore duplicates
73
+ if (slots[slotKey]) {
74
+ // warning(true, `Found duplicate "${String(slotKey)}" slot. Only the first will be rendered.`)
75
+ return;
76
+ }
77
+
78
+ // If the child is a slot, add it to the `slots` object
79
+
80
+ slots[slotKey] = child as SlotValue<Config, keyof Config>;
81
+ });
82
+
83
+ return [slots, rest];
84
+ }
85
+
86
+ /** Map the values of an object */
87
+ function mapValues<T extends Record<string, unknown>, V>(obj: T, fn: (value: T[keyof T]) => V) {
88
+ return Object.keys(obj).reduce(
89
+ (result, key: keyof T) => {
90
+ result[key] = fn(obj[key]);
91
+ return result;
92
+ },
93
+ {} as Record<keyof T, V>
94
+ );
95
+ }
@@ -8,6 +8,7 @@ interface Props {
8
8
  import { BookOpenText, Workflow, TableProperties, House, BookUser } from 'lucide-react';
9
9
  import Header from '../components/Header.astro';
10
10
  import SEO from '../components/Seo.astro';
11
+ import SideNav from '../components/SideNav/SideNav.astro';
11
12
 
12
13
  import { getCommands } from '@utils/commands';
13
14
  import { getDomains } from '@utils/collections/domains';
@@ -17,8 +18,6 @@ import { getFlows } from '@utils/collections/flows';
17
18
  import { isCollectionVisibleInCatalog } from '@eventcatalog';
18
19
  import { buildUrl } from '@utils/url-builder';
19
20
  import { getQueries } from '@utils/queries';
20
- import { getChannels } from '@utils/channels';
21
- import CatalogResourcesSideBar from '@components/SideBars/CatalogResourcesSideBar';
22
21
  import { hasLandingPageForDocs } from '@utils/pages';
23
22
 
24
23
  const events = await getEvents({ getAllVersions: false });
@@ -26,14 +25,8 @@ const commands = await getCommands({ getAllVersions: false });
26
25
  const queries = await getQueries({ getAllVersions: false });
27
26
  const services = await getServices({ getAllVersions: false });
28
27
  const domains = await getDomains({ getAllVersions: false });
29
- const channels = await getChannels({ getAllVersions: false });
30
28
  const flows = await getFlows({ getAllVersions: false });
31
29
 
32
- const messages = [...events, ...commands, ...queries];
33
-
34
- // @ts-ignore for large catalogs https://github.com/event-catalog/eventcatalog/issues/552
35
- const allData = [...domains, ...services, ...messages, ...channels, ...flows];
36
-
37
30
  const currentPath = Astro.url.pathname;
38
31
 
39
32
  const catalogHasDefaultLandingPageForDocs = await hasLandingPageForDocs();
@@ -101,45 +94,8 @@ const navigationItems = [
101
94
  },
102
95
  ];
103
96
 
104
- const allDataAsSideNav = allData.reduce((acc, item) => {
105
- const title = item.collection;
106
- const group = acc[title] || [];
107
- const currentPath = Astro.url.pathname;
108
- const route = currentPath.includes('visualiser') ? 'visualiser' : 'docs';
109
-
110
- const navigationItem = {
111
- label: item.data.name,
112
- version: item.data.version,
113
- visible: isCollectionVisibleInCatalog(item.collection),
114
- // @ts-ignore
115
- href: item.data.version
116
- ? // @ts-ignore
117
- buildUrl(`/${route}/${item.collection}/${item.data.id}/${item.data.version}`)
118
- : buildUrl(`/${route}/${item.collection}/${item.data.id}`),
119
- collection: item.collection,
120
- };
121
-
122
- group.push(navigationItem);
123
-
124
- return {
125
- ...acc,
126
- [title]: group,
127
- };
128
- }, {} as any);
129
-
130
- const sideNav = {
131
- ...(currentPath.includes('visualiser')
132
- ? {
133
- 'bounded context map': [
134
- { label: 'Domain map', href: buildUrl('/visualiser/context-map'), collection: 'bounded-context-map' },
135
- ],
136
- }
137
- : {}),
138
- ...allDataAsSideNav,
139
- };
140
-
141
97
  const currentNavigationItem = navigationItems.find((item) => item.current);
142
- const { title, description, sidebar: showSideBarOverride } = Astro.props;
98
+ const { title, description } = Astro.props;
143
99
 
144
100
  const showSideBarOnLoad = currentNavigationItem?.sidebar;
145
101
 
@@ -198,12 +154,10 @@ const canPageBeEmbedded = process.env.ENABLE_EMBED === 'true';
198
154
  </nav>
199
155
  </div>
200
156
 
201
- <div
157
+ <SideNav
202
158
  id="sidebar"
203
- class={`sidebar-transition h-content px-5 py-4 overflow-y-auto bg-white bg-gradient-to-b border-r border-gray-100 w-60 ml-16 ${showSideBarOnLoad ? 'block' : 'hidden'}`}
204
- >
205
- <CatalogResourcesSideBar resources={sideNav} currentPath={currentPath} client:load />
206
- </div>
159
+ class={`sidebar-transition h-content overflow-y-auto bg-white border-r border-gray-100 w-60 ml-16 ${showSideBarOnLoad ? 'block' : 'hidden'}`}
160
+ />
207
161
  </aside>
208
162
  <main
209
163
  class={`sidebar-transition w-full max-h-content overflow-y-auto ${showSideBarOnLoad ? 'ml-0' : 'ml-16'}`}
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "url": "https://github.com/event-catalog/eventcatalog.git"
7
7
  },
8
8
  "type": "module",
9
- "version": "2.22.0",
9
+ "version": "2.23.1",
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
@@ -37,7 +37,7 @@
37
37
  "@tailwindcss/typography": "^0.5.13",
38
38
  "@tanstack/react-table": "^8.17.3",
39
39
  "@xyflow/react": "^12.3.6",
40
- "astro": "^5.2.5",
40
+ "astro": "^5.3.0",
41
41
  "astro-expressive-code": "^0.40.1",
42
42
  "astro-pagefind": "^1.6.0",
43
43
  "astro-seo": "^0.8.4",
@@ -72,6 +72,7 @@
72
72
  "tailwindcss": "^3.4.3",
73
73
  "typescript": "^5.4.5",
74
74
  "unist-util-visit": "^5.0.0",
75
+ "update-notifier": "^7.3.1",
75
76
  "uuid": "^10.0.0"
76
77
  },
77
78
  "devDependencies": {
@@ -88,6 +89,7 @@
88
89
  "@types/react-dom": "^18.3.0",
89
90
  "@types/semver": "^7.5.8",
90
91
  "@types/shelljs": "^0.8.15",
92
+ "@types/update-notifier": "^6.0.8",
91
93
  "prettier": "^3.3.3",
92
94
  "prettier-plugin-astro": "^0.14.1",
93
95
  "tsup": "^8.1.0",