likec4 1.9.0 → 1.10.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.
@@ -1,5 +1,11 @@
1
- import type { LikeC4ViewBaseProps } from 'likec4/react'
2
- import { LikeC4Browser, LikeC4ViewElement, useColorScheme } from 'likec4/react'
1
+ import {
2
+ LikeC4Browser,
3
+ LikeC4ViewEmbedded,
4
+ type LikeC4ViewProps as BaseLikeC4ViewProps,
5
+ ReactLikeC4 as GenericReactLikeC4,
6
+ type ReactLikeC4Props as GenericReactLikeC4Props,
7
+ useColorScheme
8
+ } from 'likec4/react'
3
9
  import { memo, useCallback, useState } from 'react'
4
10
  import { Icons } from 'virtual:likec4/icons'
5
11
  import {
@@ -18,16 +24,34 @@ type IconRendererProps = {
18
24
  }
19
25
  }
20
26
 
21
- const RenderIcon = ({ node }: IconRendererProps) => {
27
+ function RenderIcon({ node }: IconRendererProps) {
22
28
  const IconComponent = Icons[node.icon ?? '']
23
29
  return IconComponent ? <IconComponent /> : null
24
30
  }
25
31
 
26
- export { isLikeC4ViewId, LikeC4Views }
32
+ export { isLikeC4ViewId, LikeC4Views, RenderIcon }
33
+
34
+ export type LikeC4ViewProps = BaseLikeC4ViewProps<LikeC4ViewId, LikeC4Tag, LikeC4ElementKind>
27
35
 
28
- export type LikeC4ViewProps = LikeC4ViewBaseProps<LikeC4ViewId, LikeC4Tag, LikeC4ElementKind>
36
+ const NotFound = ({ viewId }: { viewId: string }) => (
37
+ <div
38
+ style={{
39
+ margin: '1rem 0'
40
+ }}>
41
+ <div
42
+ style={{
43
+ margin: '0 auto',
44
+ display: 'inline-block',
45
+ padding: '2rem',
46
+ background: 'rgba(250,82,82,.15)',
47
+ color: '#ffa8a8'
48
+ }}>
49
+ View <code>{viewId}</code> not found
50
+ </div>
51
+ </div>
52
+ )
29
53
 
30
- export const LikeC4View = /* @__PURE__ */ memo<LikeC4ViewProps>(function LikeC4ViewComponent({
54
+ const LikeC4ViewMemo = /* @__PURE__ */ memo<LikeC4ViewProps>(function LikeC4View({
31
55
  viewId,
32
56
  interactive = true,
33
57
  colorScheme: explicitColorScheme,
@@ -40,6 +64,9 @@ export const LikeC4View = /* @__PURE__ */ memo<LikeC4ViewProps>(function LikeC4V
40
64
  showNavigationButtons = false,
41
65
  showNotations = false,
42
66
  enableFocusMode = false,
67
+ browserClassName,
68
+ browserStyle,
69
+ mantineTheme,
43
70
  ...props
44
71
  }) {
45
72
  const view = LikeC4Views[viewId]
@@ -52,23 +79,23 @@ export const LikeC4View = /* @__PURE__ */ memo<LikeC4ViewProps>(function LikeC4V
52
79
  onNavigateTo(null)
53
80
  }, [onNavigateTo])
54
81
 
82
+ const colorScheme = useColorScheme(explicitColorScheme)
83
+
55
84
  if (!view) {
56
- throw new Error(`View with id ${viewId} not found`)
85
+ return <NotFound viewId={viewId} />
57
86
  }
58
87
 
59
88
  if (browserViewId && !browserView) {
60
- throw new Error(`View with id ${browserViewId} not found`)
89
+ return <NotFound viewId={browserViewId} />
61
90
  }
62
91
 
63
92
  if (interactive && enableFocusMode) {
64
93
  console.warn('Focus mode is not supported in interactive mode')
65
94
  }
66
95
 
67
- const colorScheme = useColorScheme(explicitColorScheme)
68
-
69
96
  return (
70
97
  <>
71
- <LikeC4ViewElement<LikeC4ViewId, LikeC4Tag, LikeC4ElementKind>
98
+ <LikeC4ViewEmbedded<LikeC4ViewId, LikeC4Tag, LikeC4ElementKind>
72
99
  view={view}
73
100
  colorScheme={colorScheme}
74
101
  injectFontCss={injectFontCss}
@@ -81,6 +108,7 @@ export const LikeC4View = /* @__PURE__ */ memo<LikeC4ViewProps>(function LikeC4V
81
108
  showNotations={showNotations}
82
109
  enableFocusMode={enableFocusMode}
83
110
  where={where}
111
+ mantineTheme={mantineTheme}
84
112
  {...props}
85
113
  />
86
114
  {browserView && (
@@ -93,9 +121,33 @@ export const LikeC4View = /* @__PURE__ */ memo<LikeC4ViewProps>(function LikeC4V
93
121
  onClose={closeBrowser}
94
122
  renderIcon={RenderIcon}
95
123
  where={where}
124
+ className={browserClassName}
125
+ style={browserStyle}
126
+ mantineTheme={mantineTheme}
96
127
  />
97
128
  )}
98
129
  </>
99
130
  )
100
131
  })
101
- LikeC4View.displayName = 'LikeC4View'
132
+ LikeC4ViewMemo.displayName = 'LikeC4ViewMemo'
133
+ export { LikeC4ViewMemo as LikeC4View }
134
+
135
+ export type ReactLikeC4Props =
136
+ & Omit<GenericReactLikeC4Props<LikeC4ViewId, LikeC4Tag, LikeC4ElementKind>, 'view' | 'renderIcon'>
137
+ & {
138
+ viewId: LikeC4ViewId
139
+ }
140
+
141
+ export function ReactLikeC4({ viewId, ...props }: ReactLikeC4Props) {
142
+ const view = LikeC4Views[viewId]
143
+ if (!view) {
144
+ return <NotFound viewId={viewId} />
145
+ }
146
+ return (
147
+ <GenericReactLikeC4
148
+ view={view}
149
+ renderIcon={RenderIcon}
150
+ {...props}
151
+ />
152
+ )
153
+ }
@@ -1,10 +1,10 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import { useOverviewGraph } from "virtual:likec4/overview-graph";
3
- import { u, c as createReactComponent, I as IconFolderFilled, e, a as useUpdateEffect, n as nonexhaustive } from "./main-BZtdykGF.js";
3
+ import { u, c as createReactComponent, I as IconFolderFilled, e, a as useUpdateEffect, n as nonexhaustive } from "./main-KEhBGhZ8.js";
4
4
  import { u as useRouter } from "./tanstack-router-Bc_WYOzY.js";
5
5
  import { B as BaseEdge, H as Handle, P as Position, u as useNodesState, a as useEdgesState, i as index, b as Background, c as BackgroundVariant } from "./likec4-BqIZe8Y0.js";
6
6
  import { memo, useRef, useMemo } from "react";
7
- import { P as Paper, c as clsx, G as Group, T as ThemeIcon, a as Text, C as Card, b as CardSection, d as Center, I as Image, B as Box, u as useMantineColorScheme } from "./mantine-Bhi3pgTf.js";
7
+ import { P as Paper, c as clsx, G as Group, T as ThemeIcon, a as Text, C as Card, b as CardSection, d as Center, I as Image, B as Box, u as useMantineColorScheme } from "./mantine-BnwtT_Nz.js";
8
8
  import { usePreviewUrl } from "virtual:likec4/previews";
9
9
  function a(...n) {
10
10
  return u(c, n);