likec4 1.3.0 → 1.4.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,10 +1,8 @@
1
- import { LikeC4Browser, type LikeC4ViewBaseProps, LikeC4ViewElement as LikeC4ViewComponent } from 'likec4/react'
2
- import { useState } from 'react'
3
- import { createPortal } from 'react-dom'
1
+ import { LikeC4Browser, type LikeC4ViewBaseProps, LikeC4ViewElement } from 'likec4/react'
2
+ import { useCallback, useState } from 'react'
4
3
  import { isLikeC4ViewId, type LikeC4ViewId, LikeC4Views } from 'virtual:likec4/views'
5
4
 
6
5
  export { isLikeC4ViewId }
7
-
8
6
  export type LikeC4ViewProps = LikeC4ViewBaseProps<LikeC4ViewId>
9
7
 
10
8
  export function LikeC4View({
@@ -12,7 +10,6 @@ export function LikeC4View({
12
10
  interactive = true,
13
11
  colorScheme,
14
12
  injectFontCss = true,
15
- overlay,
16
13
  ...props
17
14
  }: LikeC4ViewProps) {
18
15
  const view = LikeC4Views[viewId]
@@ -21,6 +18,10 @@ export function LikeC4View({
21
18
 
22
19
  const browserView = browserViewId ? LikeC4Views[browserViewId] : null
23
20
 
21
+ const closeBrowser = useCallback(() => {
22
+ onNavigateTo(null)
23
+ }, [onNavigateTo])
24
+
24
25
  if (!view) {
25
26
  throw new Error(`View with id ${viewId} not found`)
26
27
  }
@@ -31,26 +32,23 @@ export function LikeC4View({
31
32
 
32
33
  return (
33
34
  <>
34
- <LikeC4ViewComponent<LikeC4ViewId>
35
+ <LikeC4ViewElement<LikeC4ViewId>
35
36
  view={view}
36
37
  colorScheme={colorScheme}
37
38
  injectFontCss={injectFontCss}
38
39
  onNavigateTo={interactive ? onNavigateTo : undefined}
39
40
  {...props}
40
41
  />
41
- {browserView && (createPortal(
42
+ {browserView && (
42
43
  <LikeC4Browser<LikeC4ViewId>
43
44
  view={browserView}
44
45
  injectFontCss={false}
45
46
  colorScheme={colorScheme}
46
- overlay={overlay}
47
47
  onNavigateTo={onNavigateTo}
48
48
  background="dots"
49
- onClose={() => onNavigateTo(null)}
50
- />,
51
- document.body,
52
- view.id
53
- ))}
49
+ onClose={closeBrowser}
50
+ />
51
+ )}
54
52
  </>
55
53
  )
56
54
  }