@likec4/diagram 1.36.1 → 1.37.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.
Files changed (173) hide show
  1. package/bundle/{chunk-DHvr-RGh.js → chunk-DSORWspW.js} +1008 -988
  2. package/bundle/custom.js +64 -56
  3. package/bundle/index.js +3539 -3315
  4. package/dist/LikeC4Diagram.props.d.ts +5 -5
  5. package/dist/LikeC4Styles.js +17 -15
  6. package/dist/StaticLikeC4Diagram.d.ts +1 -1
  7. package/dist/StaticLikeC4Diagram.js +3 -0
  8. package/dist/base/BaseXYFlow.d.ts +1 -1
  9. package/dist/base/BaseXYFlow.js +25 -27
  10. package/dist/base/const.d.ts +4 -4
  11. package/dist/base/const.js +5 -4
  12. package/dist/base/primitives/MarkdownBlock.js +4 -1
  13. package/dist/base/primitives/compound/CompoundActionButton.js +27 -42
  14. package/dist/base/primitives/compound/CompoundDetailsButton.js +23 -48
  15. package/dist/base/primitives/compound/CompoundNodeContainer.js +16 -48
  16. package/dist/base/primitives/compound/CompoundTitle.js +5 -80
  17. package/dist/base/primitives/compound/actionbtns.css.js +1 -13
  18. package/dist/base/primitives/customEdge.d.ts +1 -1
  19. package/dist/base/primitives/customNode.d.ts +4 -4
  20. package/dist/base/primitives/customNode.js +7 -7
  21. package/dist/base/primitives/edge/EdgeLabel.d.ts +5 -4
  22. package/dist/base/primitives/edge/EdgeLabel.js +39 -21
  23. package/dist/base/primitives/edge/EdgeLabelContainer.js +11 -23
  24. package/dist/base/primitives/edge/edge.css.js +19 -11
  25. package/dist/base/primitives/element/ElementShape.js +38 -18
  26. package/dist/base/primitives/element/ElementTags.js +7 -4
  27. package/dist/base/primitives/element/ElementTitle.js +10 -2
  28. package/dist/base/types.d.ts +17 -21
  29. package/dist/bundle/LikeC4View.d.ts +2 -2
  30. package/dist/bundle/LikeC4View.js +4 -1
  31. package/dist/bundle/LikeC4View.props.d.ts +2 -2
  32. package/dist/bundle/ReactLikeC4.d.ts +3 -3
  33. package/dist/bundle/custom.js +2 -1
  34. package/dist/bundle/index.js +2 -1
  35. package/dist/components/Link.js +3 -2
  36. package/dist/context/ReduceGraphics.js +2 -5
  37. package/dist/context/RootContainer.js +1 -5
  38. package/dist/custom/customNodes.d.ts +32 -26
  39. package/dist/custom/customNodes.js +12 -8
  40. package/dist/custom/hooks.d.ts +2 -1
  41. package/dist/custom/index.js +2 -1
  42. package/dist/globals.css.js +1 -1
  43. package/dist/hooks/index.d.ts +1 -1
  44. package/dist/hooks/useDiagram.d.ts +18 -1
  45. package/dist/hooks/useDiagram.js +18 -2
  46. package/dist/hooks/useXYFlow.d.ts +40 -21
  47. package/dist/index.d.ts +1 -1
  48. package/dist/index.js +2 -1
  49. package/dist/likec4diagram/DiagramUI.js +5 -2
  50. package/dist/likec4diagram/DiagramXYFlow.js +9 -9
  51. package/dist/likec4diagram/custom/edges/RelationshipEdge.d.ts +3 -3
  52. package/dist/likec4diagram/custom/edges/RelationshipEdge.js +27 -44
  53. package/dist/likec4diagram/custom/index.js +3 -3
  54. package/dist/likec4diagram/custom/nodes/nodes.d.ts +8 -6
  55. package/dist/likec4diagram/custom/nodes/nodes.js +13 -14
  56. package/dist/likec4diagram/custom/nodes/toolbar/CompoundToolbar.js +3 -2
  57. package/dist/likec4diagram/custom/nodes/toolbar/_shared.d.ts +2 -2
  58. package/dist/likec4diagram/relationship-popover/RelationshipPopover.d.ts +2 -0
  59. package/dist/likec4diagram/relationship-popover/RelationshipPopover.js +441 -0
  60. package/dist/likec4diagram/relationship-popover/actor.d.ts +177 -0
  61. package/dist/likec4diagram/relationship-popover/actor.js +155 -0
  62. package/dist/likec4diagram/relationship-popover/styles.css.d.ts +2 -0
  63. package/dist/likec4diagram/{custom/edges/RelationshipsDropdownMenu.css.js → relationship-popover/styles.css.js} +4 -17
  64. package/dist/likec4diagram/useLayoutConstraints.js +0 -1
  65. package/dist/likec4model/useLikeC4ElementsTree.js +1 -1
  66. package/dist/likec4model/useLikeC4Project.js +15 -1
  67. package/dist/navigationpanel/NavigationPanelDropdown.js +1 -2
  68. package/dist/navigationpanel/actor.js +1 -2
  69. package/dist/navigationpanel/controls/NavigationButtons.js +1 -5
  70. package/dist/navigationpanel/controls/ViewDetailsCard.js +2 -0
  71. package/dist/overlays/element-details/actor.d.ts +564 -8
  72. package/dist/overlays/overlay/Overlay.css.d.ts +1 -1
  73. package/dist/overlays/relationship-details/actor.d.ts +3 -1
  74. package/dist/overlays/relationship-details/hooks.d.ts +19 -1
  75. package/dist/overlays/relationship-details/layout-to-xyflow.js +0 -1
  76. package/dist/overlays/relationship-details/layout.js +1 -2
  77. package/dist/overlays/relationships-browser/actor.d.ts +26 -2
  78. package/dist/overlays/relationships-browser/custom/nodeTypes.d.ts +16 -0
  79. package/dist/overlays/relationships-browser/custom/nodeTypes.js +18 -8
  80. package/dist/overlays/relationships-browser/useViewToNodesEdges.js +0 -1
  81. package/dist/search/components/_shared.css.d.ts +1 -1
  82. package/dist/state/DiagramActorProvider.js +2 -19
  83. package/dist/state/assign.js +24 -10
  84. package/dist/state/diagram-machine.d.ts +149 -474
  85. package/dist/state/diagram-machine.js +94 -54
  86. package/dist/state/types.d.ts +1 -1
  87. package/dist/styles-min.css +1 -1
  88. package/dist/styles-xyflow.css +1 -1
  89. package/dist/styles.css +1 -1
  90. package/dist/styles.css2.js +1 -1
  91. package/dist/utils/index.d.ts +2 -1
  92. package/dist/utils/roundDpr.d.ts +1 -0
  93. package/dist/utils/roundDpr.js +20 -0
  94. package/dist/utils/xyflow.d.ts +0 -1
  95. package/dist/utils/xyflow.js +1 -7
  96. package/package.json +11 -10
  97. package/panda.buildinfo.json +90 -155
  98. package/src/LikeC4Diagram.props.ts +5 -5
  99. package/src/LikeC4Styles.tsx +22 -14
  100. package/src/StaticLikeC4Diagram.tsx +3 -0
  101. package/src/base/BaseXYFlow.tsx +26 -29
  102. package/src/base/const.ts +5 -4
  103. package/src/base/primitives/MarkdownBlock.tsx +6 -1
  104. package/src/base/primitives/compound/CompoundActionButton.tsx +31 -43
  105. package/src/base/primitives/compound/CompoundDetailsButton.tsx +26 -48
  106. package/src/base/primitives/compound/CompoundNodeContainer.tsx +15 -43
  107. package/src/base/primitives/compound/CompoundTitle.tsx +4 -76
  108. package/src/base/primitives/compound/actionbtns.css.ts +0 -12
  109. package/src/base/primitives/customEdge.ts +1 -1
  110. package/src/base/primitives/customNode.tsx +20 -24
  111. package/src/base/primitives/edge/EdgeLabel.tsx +23 -8
  112. package/src/base/primitives/edge/EdgeLabelContainer.tsx +9 -21
  113. package/src/base/primitives/edge/edge.css.ts +19 -11
  114. package/src/base/primitives/element/ElementShape.tsx +40 -18
  115. package/src/base/primitives/element/ElementTags.tsx +7 -4
  116. package/src/base/primitives/element/ElementTitle.tsx +23 -11
  117. package/src/base/types.ts +21 -25
  118. package/src/bundle/LikeC4View.props.ts +2 -2
  119. package/src/bundle/LikeC4View.tsx +8 -5
  120. package/src/bundle/ReactLikeC4.tsx +3 -3
  121. package/src/components/Link.tsx +3 -2
  122. package/src/context/RootContainer.tsx +1 -5
  123. package/src/context/TagStylesContext.tsx +2 -0
  124. package/src/custom/{customNodes.tsx → customNodes.ts} +58 -52
  125. package/src/custom/hooks.ts +7 -0
  126. package/src/globals.css +58 -5
  127. package/src/hooks/index.ts +1 -1
  128. package/src/hooks/useDiagram.ts +39 -5
  129. package/src/hooks/useXYFlow.ts +3 -1
  130. package/src/index.ts +1 -0
  131. package/src/likec4diagram/DiagramUI.tsx +3 -0
  132. package/src/likec4diagram/DiagramXYFlow.tsx +9 -11
  133. package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +25 -49
  134. package/src/likec4diagram/custom/index.ts +5 -4
  135. package/src/likec4diagram/custom/nodes/nodes.tsx +13 -11
  136. package/src/likec4diagram/custom/nodes/toolbar/CompoundToolbar.tsx +3 -2
  137. package/src/likec4diagram/relationship-popover/RelationshipPopover.tsx +535 -0
  138. package/src/likec4diagram/relationship-popover/actor.ts +192 -0
  139. package/src/likec4diagram/{custom/edges/RelationshipsDropdownMenu.css.ts → relationship-popover/styles.css.ts} +3 -19
  140. package/src/likec4diagram/useLayoutConstraints.ts +0 -1
  141. package/src/likec4model/useLikeC4ElementsTree.ts +1 -1
  142. package/src/navigationpanel/NavigationPanelDropdown.tsx +1 -2
  143. package/src/navigationpanel/actor.ts +2 -2
  144. package/src/navigationpanel/controls/NavigationButtons.tsx +1 -5
  145. package/src/navigationpanel/controls/ViewDetailsCard.tsx +2 -0
  146. package/src/overlays/relationship-details/layout-to-xyflow.ts +0 -1
  147. package/src/overlays/relationship-details/layout.ts +4 -3
  148. package/src/overlays/relationships-browser/custom/nodeTypes.tsx +22 -8
  149. package/src/overlays/relationships-browser/useViewToNodesEdges.ts +0 -1
  150. package/src/state/DiagramActorProvider.tsx +2 -20
  151. package/src/state/assign.ts +24 -10
  152. package/src/state/diagram-machine.ts +101 -53
  153. package/src/state/types.ts +4 -1
  154. package/src/utils/index.ts +2 -1
  155. package/src/utils/roundDpr.ts +27 -0
  156. package/src/utils/xyflow.ts +0 -7
  157. package/dist/base/primitives/compound/CompoundNodeContainer.css.d.ts +0 -35
  158. package/dist/base/primitives/compound/CompoundNodeContainer.css.js +0 -132
  159. package/dist/base/primitives/edge/EdgeLabel.css.d.ts +0 -7
  160. package/dist/base/primitives/edge/EdgeLabel.css.js +0 -57
  161. package/dist/base/primitives/element/ElementShape.css.d.ts +0 -6
  162. package/dist/base/primitives/element/ElementShape.css.js +0 -107
  163. package/dist/likec4diagram/custom/edges/NotePopover.css.js +0 -21
  164. package/dist/likec4diagram/custom/edges/NotePopover.js +0 -91
  165. package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.css.d.ts +0 -5
  166. package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.d.ts +0 -13
  167. package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.js +0 -215
  168. package/dist/likec4diagram/custom/index.d.ts +0 -62
  169. package/dist/overlays/relationship-details/custom/nodeTypes.d.ts +0 -10
  170. package/src/base/primitives/compound/CompoundNodeContainer.css.ts +0 -138
  171. package/src/base/primitives/edge/EdgeLabel.css.ts +0 -64
  172. package/src/base/primitives/element/ElementShape.css.ts +0 -112
  173. package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.tsx +0 -281
@@ -2,7 +2,7 @@ import { nonNullable, invariant, nonexhaustive, BBox, isStepEdgeId, getParallelS
2
2
  import { getViewportForBounds, applyEdgeChanges, applyNodeChanges } from '@xyflow/react';
3
3
  import { nodeToRect } from '@xyflow/system';
4
4
  import { hasAtLeast, prop, clamp, first } from 'remeda';
5
- import { setup, assign, enqueueActions, sendTo, emit, assertEvent, cancel, stopChild, raise, spawnChild, and, or } from 'xstate';
5
+ import { setup, emit, assign, enqueueActions, sendTo, assertEvent, cancel, stopChild, raise, spawnChild, and, or } from 'xstate';
6
6
  import { MinZoom } from '../base/const.js';
7
7
  import { AllDisabled } from '../context/DiagramFeatures.js';
8
8
  import { createLayoutConstraints } from '../likec4diagram/useLayoutConstraints.js';
@@ -222,6 +222,10 @@ const _diagramMachine = setup({
222
222
  features: { ...event.features }
223
223
  };
224
224
  }),
225
+ "updateInputs": assign(({ event }) => {
226
+ assertEvent(event, "update.inputs");
227
+ return { ...event.inputs };
228
+ }),
225
229
  "closeSearch": sendTo(
226
230
  ({ system }) => typedSystem(system).searchActorRef,
227
231
  {
@@ -267,25 +271,41 @@ const _diagramMachine = setup({
267
271
  })
268
272
  };
269
273
  }),
270
- "onEdgeMouseEnter": assign(({ context }, params) => {
271
- return {
274
+ "onEdgeMouseEnter": enqueueActions(({ enqueue, context, event }) => {
275
+ assertEvent(event, "xyflow.edgeMouseEnter");
276
+ let edge = event.edge;
277
+ enqueue.assign({
272
278
  xyedges: context.xyedges.map((e) => {
273
- if (e.id === params.edge.id) {
274
- return setHovered(e, true);
279
+ if (e.id === event.edge.id) {
280
+ edge = setHovered(e, true);
281
+ return edge;
275
282
  }
276
283
  return e;
277
284
  })
278
- };
285
+ });
286
+ enqueue.emit({
287
+ type: "edgeMouseEnter",
288
+ edge,
289
+ event: event.event
290
+ });
279
291
  }),
280
- "onEdgeMouseLeave": assign(({ context }, params) => {
281
- return {
292
+ "onEdgeMouseLeave": enqueueActions(({ enqueue, context, event }) => {
293
+ assertEvent(event, "xyflow.edgeMouseLeave");
294
+ let edge = event.edge;
295
+ enqueue.assign({
282
296
  xyedges: context.xyedges.map((e) => {
283
- if (e.id === params.edge.id) {
284
- return setHovered(e, false);
297
+ if (e.id === event.edge.id) {
298
+ edge = setHovered(e, false);
299
+ return edge;
285
300
  }
286
301
  return e;
287
302
  })
288
- };
303
+ });
304
+ enqueue.emit({
305
+ type: "edgeMouseLeave",
306
+ edge,
307
+ event: event.event
308
+ });
289
309
  }),
290
310
  "focus on nodes and edges": assign(focusNodesEdges),
291
311
  "notations.highlight": assign(({ context }, params) => {
@@ -320,7 +340,34 @@ const _diagramMachine = setup({
320
340
  active: false
321
341
  }))
322
342
  })),
323
- "update active walkthrough": assign(updateActiveWalkthrough)
343
+ "update active walkthrough": assign(updateActiveWalkthrough),
344
+ "emit: walkthroughStarted": emit(({ context }) => {
345
+ const edge = context.xyedges.find((x) => x.id === context.activeWalkthrough?.stepId);
346
+ invariant(edge, "Invalid walkthrough state");
347
+ return {
348
+ type: "walkthroughStarted",
349
+ edge
350
+ };
351
+ }),
352
+ "emit: walkthroughStep": emit(({ context }) => {
353
+ const edge = context.xyedges.find((x) => x.id === context.activeWalkthrough?.stepId);
354
+ invariant(edge, "Invalid walkthrough state");
355
+ return {
356
+ type: "walkthroughStep",
357
+ edge
358
+ };
359
+ }),
360
+ "emit: walkthroughStopped": emit(() => ({
361
+ type: "walkthroughStopped"
362
+ })),
363
+ "emit: edgeEditingStarted": emit(({ context, event }) => {
364
+ assertEvent(event, "xyflow.edgeEditingStarted");
365
+ const edge = nonNullable(context.xyedges.find((x) => x.id === event.edge.id), `Edge ${event.edge.id} not found`);
366
+ return {
367
+ type: "edgeEditingStarted",
368
+ edge
369
+ };
370
+ })
324
371
  }
325
372
  }).createMachine({
326
373
  initial: "initializing",
@@ -529,16 +576,10 @@ const _diagramMachine = setup({
529
576
  }
530
577
  },
531
578
  "xyflow.edgeMouseEnter": {
532
- actions: {
533
- type: "onEdgeMouseEnter",
534
- params: prop("event")
535
- }
579
+ actions: "onEdgeMouseEnter"
536
580
  },
537
581
  "xyflow.edgeMouseLeave": {
538
- actions: {
539
- type: "onEdgeMouseLeave",
540
- params: prop("event")
541
- }
582
+ actions: "onEdgeMouseLeave"
542
583
  },
543
584
  "notations.highlight": {
544
585
  actions: {
@@ -628,7 +669,7 @@ const _diagramMachine = setup({
628
669
  }),
629
670
  target: "focused"
630
671
  },
631
- "xyflow.edgeClick": [{
672
+ "xyflow.edgeClick": {
632
673
  guard: and([
633
674
  "is dynamic view",
634
675
  "click: selected edge"
@@ -637,17 +678,7 @@ const _diagramMachine = setup({
637
678
  type: "walkthrough.start",
638
679
  stepId: event.edge.id
639
680
  }))
640
- }, {
641
- guard: and([
642
- "enabled: RelationshipDetails",
643
- "click: selected edge"
644
- ]),
645
- actions: sendTo(({ system }) => typedSystem(system).overlaysActorRef, ({ context, event }) => ({
646
- type: "open.relationshipDetails",
647
- viewId: context.view.id,
648
- edgeId: event.edge.id
649
- }))
650
- }]
681
+ }
651
682
  }
652
683
  },
653
684
  focused: {
@@ -733,7 +764,8 @@ const _diagramMachine = setup({
733
764
  }
734
765
  }),
735
766
  "update active walkthrough",
736
- "xyflow:fitFocusedBounds"
767
+ "xyflow:fitFocusedBounds",
768
+ "emit: walkthroughStarted"
737
769
  ],
738
770
  on: {
739
771
  "key.esc": {
@@ -746,26 +778,29 @@ const _diagramMachine = setup({
746
778
  actions: raise({ type: "walkthrough.step", direction: "next" })
747
779
  },
748
780
  "walkthrough.step": {
749
- actions: enqueueActions(({ enqueue, context, event }) => {
750
- const { stepId } = context.activeWalkthrough;
751
- const stepIndex = context.xyedges.findIndex((e) => e.id === stepId);
752
- const nextStepIndex = clamp(event.direction === "next" ? stepIndex + 1 : stepIndex - 1, {
753
- min: 0,
754
- max: context.xyedges.length - 1
755
- });
756
- if (nextStepIndex === stepIndex) {
757
- return;
758
- }
759
- const nextStepId = context.xyedges[nextStepIndex].id;
760
- enqueue.assign({
761
- activeWalkthrough: {
762
- stepId: nextStepId,
763
- parallelPrefix: getParallelStepsPrefix(nextStepId)
781
+ actions: [
782
+ assign(({ context, event }) => {
783
+ const { stepId } = context.activeWalkthrough;
784
+ const stepIndex = context.xyedges.findIndex((e) => e.id === stepId);
785
+ const nextStepIndex = clamp(event.direction === "next" ? stepIndex + 1 : stepIndex - 1, {
786
+ min: 0,
787
+ max: context.xyedges.length - 1
788
+ });
789
+ if (nextStepIndex === stepIndex) {
790
+ return {};
764
791
  }
765
- });
766
- enqueue("update active walkthrough");
767
- enqueue("xyflow:fitFocusedBounds");
768
- })
792
+ const nextStepId = context.xyedges[nextStepIndex].id;
793
+ return {
794
+ activeWalkthrough: {
795
+ stepId: nextStepId,
796
+ parallelPrefix: getParallelStepsPrefix(nextStepId)
797
+ }
798
+ };
799
+ }),
800
+ "update active walkthrough",
801
+ "xyflow:fitFocusedBounds",
802
+ "emit: walkthroughStep"
803
+ ]
769
804
  },
770
805
  "xyflow.edgeClick": {
771
806
  actions: [
@@ -781,7 +816,8 @@ const _diagramMachine = setup({
781
816
  };
782
817
  }),
783
818
  "update active walkthrough",
784
- "xyflow:fitFocusedBounds"
819
+ "xyflow:fitFocusedBounds",
820
+ "emit: walkthroughStep"
785
821
  ]
786
822
  },
787
823
  "notations.unhighlight": {
@@ -815,6 +851,7 @@ const _diagramMachine = setup({
815
851
  activeWalkthrough: null,
816
852
  viewportBeforeFocus: null
817
853
  });
854
+ enqueue("emit: walkthroughStopped");
818
855
  })
819
856
  }
820
857
  }
@@ -879,6 +916,9 @@ const _diagramMachine = setup({
879
916
  viewport: ({ event }) => event.viewport
880
917
  })
881
918
  },
919
+ "xyflow.edgeEditingStarted": {
920
+ actions: "emit: edgeEditingStarted"
921
+ },
882
922
  "fitDiagram": {
883
923
  guard: "enabled: FitView",
884
924
  actions: {
@@ -941,7 +981,7 @@ const _diagramMachine = setup({
941
981
  ]
942
982
  },
943
983
  "update.inputs": {
944
- actions: assign(({ event }) => ({ ...event.inputs }))
984
+ actions: "updateInputs"
945
985
  },
946
986
  "update.features": {
947
987
  actions: [
@@ -15,7 +15,7 @@ export interface DiagramActorRef extends ActorRefFromLogic<DiagramMachineLogic>
15
15
  }
16
16
  export type DiagramActorSnapshot = SnapshotFrom<DiagramMachineLogic>;
17
17
  export type DiagramActorEvent = EventFromLogic<DiagramMachineLogic>;
18
- export type { Context as DiagramContext } from './diagram-machine';
18
+ export type { Context as DiagramContext, EmittedEvents as DiagramEmittedEvents, } from './diagram-machine';
19
19
  export type SyncLayoutActorRef = Omit<ActorRefFromLogic<SyncLayoutActorLogic>, 'system'> & {
20
20
  system: System;
21
21
  };