@likec4/diagram 1.7.2 → 1.7.4

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 (70) hide show
  1. package/dist/LikeC4Diagram.d.ts +1 -1
  2. package/dist/LikeC4Diagram.props.d.ts +38 -22
  3. package/dist/StaticLikeC4Diagram.d.ts +1 -1
  4. package/dist/hooks/index.d.ts +2 -0
  5. package/dist/{state/useDiagramStore.d.ts → hooks/useDiagramState.d.ts} +2 -3
  6. package/dist/{xyflow/hooks → hooks}/useXYFlow.d.ts +10 -10
  7. package/dist/index.d.ts +2 -2
  8. package/dist/index.mjs +818 -448
  9. package/dist/state/DiagramContext.d.ts +74 -30
  10. package/dist/state/diagram-to-xyflow.d.ts +2 -0
  11. package/dist/state/diagramStore.d.ts +71 -22
  12. package/dist/style.css +58 -37
  13. package/dist/ui/top-left/ChangeAutoLayoutButton.d.ts +3 -0
  14. package/dist/ui/top-left/TopLeftPanel.d.ts +4 -0
  15. package/dist/ui/top-left/_shared.d.ts +5 -0
  16. package/dist/ui/top-left/styles.css.d.ts +3 -0
  17. package/dist/xyflow/XYFlowInner.d.ts +0 -1
  18. package/dist/xyflow/const.d.ts +1 -0
  19. package/dist/xyflow/edges/edges.css.d.ts +1 -1
  20. package/dist/xyflow/{hooks/useLayoutConstraints.d.ts → useLayoutConstraints.d.ts} +1 -1
  21. package/dist/xyflow/utils.d.ts +11 -1
  22. package/package.json +6 -6
  23. package/src/LikeC4Diagram.props.ts +66 -32
  24. package/src/LikeC4Diagram.tsx +19 -12
  25. package/src/StaticLikeC4Diagram.tsx +2 -0
  26. package/src/hooks/index.ts +2 -0
  27. package/src/{state/useDiagramStore.ts → hooks/useDiagramState.ts} +3 -4
  28. package/src/{xyflow/hooks → hooks}/useXYFlow.ts +1 -1
  29. package/src/index.ts +2 -2
  30. package/src/state/DiagramContext.tsx +15 -7
  31. package/src/state/diagram-to-xyflow.ts +17 -3
  32. package/src/state/diagramStore.ts +73 -38
  33. package/src/ui/DiagramTitlePanel.css.ts +2 -2
  34. package/src/ui/DiagramTitlePanel.tsx +62 -44
  35. package/src/ui/DynamicViewWalkthrough.tsx +1 -2
  36. package/src/ui/OptionsPanel.tsx +1 -1
  37. package/src/ui/options/EdgeOptions.tsx +1 -16
  38. package/src/ui/options/NodeOptions.tsx +38 -13
  39. package/src/ui/top-left/ChangeAutoLayoutButton.tsx +131 -0
  40. package/src/ui/top-left/TopLeftPanel.tsx +213 -0
  41. package/src/ui/top-left/_shared.ts +19 -0
  42. package/src/ui/top-left/styles.css.ts +38 -0
  43. package/src/xyflow/FitviewOnDiagramChange.tsx +2 -2
  44. package/src/xyflow/SelectEdgesOnNodeFocus.tsx +87 -59
  45. package/src/xyflow/XYFlow.tsx +11 -10
  46. package/src/xyflow/XYFlowEvents.tsx +44 -18
  47. package/src/xyflow/XYFlowInner.tsx +5 -7
  48. package/src/xyflow/const.ts +1 -0
  49. package/src/xyflow/edges/RelationshipEdge.tsx +60 -27
  50. package/src/xyflow/edges/edges.css.ts +29 -25
  51. package/src/xyflow/nodes/compound/CompoundNode.tsx +1 -1
  52. package/src/xyflow/nodes/element/ElementLink.tsx +1 -2
  53. package/src/xyflow/nodes/element/ElementNode.tsx +7 -5
  54. package/src/xyflow/nodes/shared/NavigateToBtn.tsx +1 -1
  55. package/src/xyflow/{hooks/useLayoutConstraints.ts → useLayoutConstraints.ts} +3 -3
  56. package/src/xyflow/utils.ts +25 -1
  57. package/dist/state/hooks.d.ts +0 -4
  58. package/dist/state/index.d.ts +0 -2
  59. package/dist/state/useNavigationHistory.d.ts +0 -5
  60. package/dist/types.d.ts +0 -20
  61. package/dist/ui/BackwardForwardPanel.css.d.ts +0 -1
  62. package/dist/ui/BackwardForwardPanel.d.ts +0 -1
  63. package/dist/xyflow/hooks/index.d.ts +0 -2
  64. package/src/state/hooks.ts +0 -5
  65. package/src/state/index.ts +0 -2
  66. package/src/state/useNavigationHistory.ts +0 -39
  67. package/src/types.ts +0 -22
  68. package/src/ui/BackwardForwardPanel.css.ts +0 -22
  69. package/src/ui/BackwardForwardPanel.tsx +0 -76
  70. package/src/xyflow/hooks/index.ts +0 -3
@@ -1,39 +0,0 @@
1
- import { useStateHistory } from '@mantine/hooks'
2
- import { useMemo } from 'react'
3
- import { useUpdateEffect } from '../hooks/useUpdateEffect'
4
- import { useDiagramState, useDiagramStoreApi } from './useDiagramStore'
5
-
6
- export function useNavigationHistory() {
7
- const store = useDiagramStoreApi()
8
- const viewId = useDiagramState(s => s.view.id)
9
-
10
- const [historyViewId, historyOps, {
11
- history,
12
- current: historyIndex
13
- }] = useStateHistory(viewId)
14
-
15
- const hasBack = historyIndex > 0
16
- const hasForward = historyIndex < history.length - 1
17
-
18
- useUpdateEffect(() => {
19
- if (viewId !== historyViewId) {
20
- historyOps.set(viewId)
21
- }
22
- }, [viewId])
23
-
24
- useUpdateEffect(() => {
25
- if (viewId !== historyViewId) {
26
- store.getState().onNavigateTo?.(historyViewId)
27
- }
28
- }, [historyViewId])
29
-
30
- return useMemo(() => ({
31
- hasBack,
32
- hasForward,
33
- ops: historyOps
34
- }), [
35
- hasBack,
36
- hasForward,
37
- historyOps
38
- ])
39
- }
package/src/types.ts DELETED
@@ -1,22 +0,0 @@
1
- import type { Fqn, RelationID, ViewID } from '@likec4/core'
2
- import type { Simplify } from 'type-fest'
3
-
4
- type TaggedUnion<
5
- TagKey extends string,
6
- UnionMembers extends Record<string, Record<string, unknown>>
7
- > = {
8
- [Name in keyof UnionMembers]: Simplify<{ [Key in TagKey]: Name } & UnionMembers[Name]>
9
- }[keyof UnionMembers]
10
-
11
- export type DiagramEditorCommand = TaggedUnion<'type', {
12
- // Sources
13
- showElement: {
14
- element: Fqn
15
- }
16
- showRelation: {
17
- relation: RelationID
18
- }
19
- showView: {
20
- view: ViewID
21
- }
22
- }>
@@ -1,22 +0,0 @@
1
- import { fallbackVar, globalStyle, style } from '@vanilla-extract/css'
2
- import { mantine } from '../mantine.css'
3
- import { vars } from '../theme.css'
4
-
5
- export const panel = style({
6
- top: fallbackVar(vars.navigationPanel.top, '0.8rem'),
7
- left: fallbackVar(vars.navigationPanel.left, '1rem'),
8
- margin: 0
9
- })
10
-
11
- globalStyle(`${panel} .mantine-ActionIcon-root`, {
12
- vars: {
13
- ['--ai-size']: 'var(--ai-size-lg)'
14
- }
15
- // '@media': {
16
- // [mantine.largerThan('lg')]: {
17
- // vars: {
18
- // ['--ai-size']: 'var(--ai-size-xl)'
19
- // }
20
- // }
21
- // }
22
- })
@@ -1,76 +0,0 @@
1
- import { ActionIcon, Group } from '@mantine/core'
2
- import { IconChevronLeft, IconChevronRight } from '@tabler/icons-react'
3
- import clsx from 'clsx'
4
- import { AnimatePresence, m } from 'framer-motion'
5
- import { type DiagramState, useDiagramState } from '../state/hooks'
6
- import * as css from './BackwardForwardPanel.css'
7
-
8
- const historySelector = (s: DiagramState) => ({
9
- hasStepBack: s.navigationHistoryIndex > 0,
10
- hasStepForward: s.navigationHistoryIndex < s.navigationHistory.length - 1,
11
- goBack: s.goBack,
12
- goForward: s.goForward
13
- })
14
-
15
- export function BackwardForwardPanel() {
16
- const {
17
- hasStepBack,
18
- hasStepForward,
19
- goBack,
20
- goForward
21
- } = useDiagramState(historySelector)
22
- return (
23
- <Group
24
- className={clsx(
25
- 'react-flow__panel',
26
- css.panel,
27
- 'likec4-navigation-panel'
28
- )}
29
- gap={'xs'}>
30
- <AnimatePresence>
31
- {hasStepBack && (
32
- <m.div
33
- layout
34
- initial={{ opacity: 0.05, transform: 'translateX(-10px)' }}
35
- animate={{ opacity: 1, transform: 'translateX(0)' }}
36
- exit={{
37
- opacity: 0.05,
38
- transform: 'translateX(-10px)'
39
- }}
40
- key={'back'}>
41
- <ActionIcon
42
- variant="light"
43
- color="gray"
44
- onClick={e => {
45
- e.stopPropagation()
46
- goBack()
47
- }}>
48
- <IconChevronLeft />
49
- </ActionIcon>
50
- </m.div>
51
- )}
52
- {hasStepForward && (
53
- <m.div
54
- layout
55
- initial={{ opacity: 0.05, transform: 'translateX(10px)' }}
56
- animate={{ opacity: 1, transform: 'translateX(0)' }}
57
- exit={{
58
- opacity: 0,
59
- transform: 'translateX(10px)'
60
- }}
61
- key={'forward'}>
62
- <ActionIcon
63
- variant="light"
64
- color="gray"
65
- onClick={e => {
66
- e.stopPropagation()
67
- goForward()
68
- }}>
69
- <IconChevronRight />
70
- </ActionIcon>
71
- </m.div>
72
- )}
73
- </AnimatePresence>
74
- </Group>
75
- )
76
- }
@@ -1,3 +0,0 @@
1
- export { useXYFlow, useXYNodesData, useXYStore, useXYStoreApi } from './useXYFlow'
2
-
3
- export type * from './useXYFlow'