@likec4/diagram 1.39.2 → 1.39.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 (38) hide show
  1. package/bundle/{chunk-CaxOLfbm.js → chunk-CW_KClZe.js} +762 -770
  2. package/bundle/custom.js +20 -20
  3. package/bundle/index.js +660 -630
  4. package/dist/LikeC4Diagram.js +2 -2
  5. package/dist/LikeC4Styles.js +0 -10
  6. package/dist/base/primitives/edge/EdgeLabelContainer.js +1 -7
  7. package/dist/bundle/ShadowRoot.js +1 -7
  8. package/dist/bundle/styles.css.js +6 -5
  9. package/dist/hooks/index.d.ts +1 -0
  10. package/dist/hooks/useId.d.ts +1 -0
  11. package/dist/hooks/useId.js +7 -0
  12. package/dist/likec4diagram/DiagramXYFlow.js +2 -4
  13. package/dist/likec4diagram/relationship-popover/RelationshipPopover.js +1 -1
  14. package/dist/navigationpanel/NavigationPanel.js +2 -3
  15. package/dist/navigationpanel/NavigationPanelDropdown.js +7 -0
  16. package/dist/state/DiagramActorProvider.js +12 -19
  17. package/dist/state/diagram-machine.d.ts +111 -91
  18. package/dist/state/diagram-machine.js +57 -19
  19. package/dist/styles-min.css +1 -1
  20. package/dist/styles.css +1 -1
  21. package/dist/styles.css2.js +1 -1
  22. package/package.json +8 -8
  23. package/panda.buildinfo.json +5 -5
  24. package/src/LikeC4Diagram.tsx +2 -2
  25. package/src/LikeC4Styles.tsx +0 -6
  26. package/src/base/primitives/edge/EdgeLabelContainer.tsx +0 -6
  27. package/src/bundle/ShadowRoot.tsx +1 -7
  28. package/src/bundle/styles.css.ts +5 -6
  29. package/src/hooks/index.ts +1 -0
  30. package/src/hooks/useId.ts +5 -0
  31. package/src/likec4diagram/DiagramXYFlow.tsx +2 -4
  32. package/src/likec4diagram/relationship-popover/RelationshipPopover.tsx +1 -1
  33. package/src/navigationpanel/NavigationPanel.tsx +2 -3
  34. package/src/navigationpanel/NavigationPanelDropdown.tsx +9 -0
  35. package/src/state/DiagramActorProvider.tsx +12 -24
  36. package/src/state/diagram-machine.ts +69 -28
  37. package/dist/globals.css.js +0 -3
  38. package/src/globals.css +0 -124
@@ -14,7 +14,7 @@ import { updateActiveWalkthrough, focusNodesEdges, lastClickedNode, updateNaviga
14
14
  import { hotkeyActorLogic } from './hotkeyActor.js';
15
15
  import { DiagramToggledFeaturesPersistence } from './persistence.js';
16
16
  import { syncManualLayoutActorLogic } from './syncManualLayoutActor.js';
17
- import { findDiagramNode, typedSystem, focusedBounds } from './utils.js';
17
+ import { findDiagramEdge, findDiagramNode, typedSystem, focusedBounds } from './utils.js';
18
18
 
19
19
  const _diagramMachine = setup({
20
20
  types: {
@@ -75,10 +75,6 @@ const _diagramMachine = setup({
75
75
  type: "navigateTo",
76
76
  viewId: nonNullable(context.lastOnNavigate, "Invalid state, lastOnNavigate is null").toView
77
77
  })),
78
- "trigger:OnChange": emit((_, _params) => ({
79
- type: "viewChange",
80
- change: _params.change
81
- })),
82
78
  "trigger:OpenSource": emit((_, _params) => ({
83
79
  type: "openSource",
84
80
  params: _params
@@ -89,6 +85,9 @@ const _diagramMachine = setup({
89
85
  lastClickedNode: lastClickedNode({ context, event })
90
86
  };
91
87
  }),
88
+ "reset lastClickedNode": assign(() => ({
89
+ lastClickedNode: null
90
+ })),
92
91
  "open source of focused or last clicked node": enqueueActions(({ context, enqueue }) => {
93
92
  const nodeId = context.focusedNode ?? context.lastClickedNode?.id;
94
93
  if (!nodeId || !context.features.enableVscode) return;
@@ -367,6 +366,27 @@ const _diagramMachine = setup({
367
366
  type: "edgeEditingStarted",
368
367
  edge
369
368
  };
369
+ }),
370
+ "emit: paneClick": emit(() => ({
371
+ type: "paneClick"
372
+ })),
373
+ "emit: nodeClick": emit(({ context, event }) => {
374
+ assertEvent(event, "xyflow.nodeClick");
375
+ const node = nonNullable(findDiagramNode(context, event.node.id), `Node ${event.node.id} not found in diagram`);
376
+ return {
377
+ type: "nodeClick",
378
+ node,
379
+ xynode: event.node
380
+ };
381
+ }),
382
+ "emit: edgeClick": emit(({ context, event }) => {
383
+ assertEvent(event, "xyflow.edgeClick");
384
+ const edge = nonNullable(findDiagramEdge(context, event.edge.id), `Edge ${event.edge.id} not found in diagram`);
385
+ return {
386
+ type: "edgeClick",
387
+ edge,
388
+ xyedge: event.edge
389
+ };
370
390
  })
371
391
  }
372
392
  }).createMachine({
@@ -638,27 +658,29 @@ const _diagramMachine = setup({
638
658
  assign({
639
659
  lastClickedNode,
640
660
  focusedNode: ({ event }) => event.node.id
641
- })
661
+ }),
662
+ "emit: nodeClick"
642
663
  ],
643
664
  target: "focused"
644
665
  },
645
666
  {
646
667
  actions: [
647
668
  "assign lastClickedNode",
648
- "open source of focused or last clicked node"
669
+ "open source of focused or last clicked node",
670
+ "emit: nodeClick"
649
671
  ]
650
672
  }
651
673
  ],
652
674
  "xyflow.paneClick": {
653
675
  actions: [
654
- assign({
655
- lastClickedNode: null
656
- })
676
+ "reset lastClickedNode",
677
+ "emit: paneClick"
657
678
  ]
658
679
  },
659
680
  "xyflow.paneDblClick": {
660
681
  actions: [
661
- { type: "xyflow:fitDiagram" },
682
+ "reset lastClickedNode",
683
+ "xyflow:fitDiagram",
662
684
  { type: "trigger:OpenSource", params: ({ context }) => ({ view: context.view.id }) }
663
685
  ]
664
686
  },
@@ -674,10 +696,13 @@ const _diagramMachine = setup({
674
696
  "is dynamic view",
675
697
  "click: selected edge"
676
698
  ]),
677
- actions: raise(({ event }) => ({
678
- type: "walkthrough.start",
679
- stepId: event.edge.id
680
- }))
699
+ actions: [
700
+ raise(({ event }) => ({
701
+ type: "walkthrough.start",
702
+ stepId: event.edge.id
703
+ })),
704
+ "emit: edgeClick"
705
+ ]
681
706
  }
682
707
  }
683
708
  },
@@ -708,6 +733,7 @@ const _diagramMachine = setup({
708
733
  "xyflow.nodeClick": [
709
734
  {
710
735
  guard: "click: focused node",
736
+ actions: "emit: nodeClick",
711
737
  target: "#idle"
712
738
  },
713
739
  {
@@ -718,7 +744,8 @@ const _diagramMachine = setup({
718
744
  raise(({ event }) => ({
719
745
  type: "focus.node",
720
746
  nodeId: event.node.id
721
- }))
747
+ })),
748
+ "emit: nodeClick"
722
749
  ]
723
750
  }
724
751
  ],
@@ -736,9 +763,10 @@ const _diagramMachine = setup({
736
763
  target: "idle"
737
764
  },
738
765
  "xyflow.paneClick": {
739
- actions: assign({
740
- lastClickedNode: null
741
- }),
766
+ actions: [
767
+ "reset lastClickedNode",
768
+ "emit: paneClick"
769
+ ],
742
770
  target: "idle"
743
771
  },
744
772
  "notations.unhighlight": {
@@ -817,6 +845,7 @@ const _diagramMachine = setup({
817
845
  }),
818
846
  "update active walkthrough",
819
847
  "xyflow:fitFocusedBounds",
848
+ "emit: edgeClick",
820
849
  "emit: walkthroughStep"
821
850
  ]
822
851
  },
@@ -900,6 +929,15 @@ const _diagramMachine = setup({
900
929
  }
901
930
  },
902
931
  on: {
932
+ "xyflow.paneClick": {
933
+ actions: "emit: paneClick"
934
+ },
935
+ "xyflow.nodeClick": {
936
+ actions: "emit: nodeClick"
937
+ },
938
+ "xyflow.edgeClick": {
939
+ actions: "emit: edgeClick"
940
+ },
903
941
  "xyflow.applyNodeChanges": {
904
942
  actions: assign({
905
943
  xynodes: ({ context, event }) => applyNodeChanges(event.changes, context.xynodes)