likec4 1.25.0 → 1.26.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,4 @@
1
- import type { LikeC4Model } from '@likec4/core/model'
2
- import type { DiagramView, ViewId } from '@likec4/core/types'
1
+ import type { ViewId } from '@likec4/core'
3
2
  import {
4
3
  type LikeC4ViewProps,
5
4
  type ReactLikeC4Props as GenericReactLikeC4Props,
@@ -7,42 +6,27 @@ import {
7
6
  LikeC4View as GenericLikeC4View,
8
7
  ReactLikeC4 as GenericReactLikeC4,
9
8
  } from 'likec4/react'
9
+ import { $likec4data, $likec4model, IconRenderer } from 'likec4:single-project'
10
10
  import { type PropsWithChildren } from 'react'
11
- import { Icons } from 'virtual:likec4/icons'
12
- import { likeC4Model, LikeC4Views, useLikeC4Model } from 'virtual:likec4/model'
13
11
 
14
- type IconRendererProps = {
15
- node: {
16
- id: string
17
- title: string
18
- icon?: string | null | undefined
19
- }
20
- }
21
-
22
- export function RenderIcon({ node }: IconRendererProps) {
23
- const IconComponent = Icons[node.icon ?? '']
24
- return IconComponent ? <IconComponent /> : null
25
- }
12
+ export const likeC4Model = $likec4model.get()
26
13
 
27
- export { likeC4Model, useLikeC4Model }
14
+ export {
15
+ IconRenderer as RenderIcon,
16
+ useLikeC4Model,
17
+ useLikeC4View,
18
+ } from 'likec4:single-project'
28
19
 
29
- export function useLikeC4ViewModel(viewId: ViewId): LikeC4Model.View {
30
- return useLikeC4Model().view(viewId as any)
31
- }
32
-
33
- export function useLikeC4View(viewId: ViewId): DiagramView {
34
- return useLikeC4Model().view(viewId as any).$view as DiagramView
35
- }
36
20
  export function isLikeC4ViewId(value: unknown): value is ViewId {
21
+ const model = $likec4data.get()
37
22
  return (
38
23
  value != null
39
24
  && typeof value === 'string'
40
- && value in LikeC4Views
25
+ && !!model.views[value]
41
26
  )
42
27
  }
43
28
 
44
29
  export function LikeC4ModelProvider({ children }: PropsWithChildren) {
45
- const likeC4Model = useLikeC4Model()
46
30
  return (
47
31
  <GenericLikeC4ModelProvider likec4model={likeC4Model}>
48
32
  {children}
@@ -54,7 +38,7 @@ export function LikeC4View(props: LikeC4ViewProps<string, string, string>) {
54
38
  return (
55
39
  <LikeC4ModelProvider>
56
40
  <GenericLikeC4View
57
- renderIcon={RenderIcon}
41
+ renderIcon={IconRenderer}
58
42
  {...props} />
59
43
  </LikeC4ModelProvider>
60
44
  )
@@ -66,7 +50,7 @@ export function ReactLikeC4(props: ReactLikeC4Props) {
66
50
  return (
67
51
  <LikeC4ModelProvider>
68
52
  <GenericReactLikeC4
69
- renderIcon={RenderIcon}
53
+ renderIcon={IconRenderer}
70
54
  {...props}
71
55
  />
72
56
  </LikeC4ModelProvider>