@likec4/diagram 1.22.0 → 1.23.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 (240) hide show
  1. package/dist/LikeC4Diagram.js +2 -3
  2. package/dist/base/BaseXYFlow.js +0 -1
  3. package/dist/base/example/custom.d.ts +1 -1
  4. package/dist/base/primitives/customEdge.d.ts +1 -1
  5. package/dist/base/primitives/edge/EdgePath.d.ts +1 -1
  6. package/dist/context/DiagramEventHandlers.d.ts +6 -2
  7. package/dist/context/DiagramEventHandlers.js +25 -20
  8. package/dist/context/DiagramFeatures.d.ts +1 -1
  9. package/dist/context/DiagramFeatures.js +9 -22
  10. package/dist/{style.css → diagram.css} +1 -1
  11. package/dist/hooks/index.d.ts +0 -1
  12. package/dist/hooks/safeContext.d.ts +7 -0
  13. package/dist/hooks/safeContext.js +14 -0
  14. package/dist/hooks/useCurrentViewId.js +1 -1
  15. package/dist/hooks/useDiagram.d.ts +7250 -6596
  16. package/dist/hooks/useDiagram.js +29 -14
  17. package/dist/index.js +1 -1
  18. package/dist/likec4diagram/DiagramUI.js +12 -5
  19. package/dist/likec4diagram/XYFlow.js +11 -5
  20. package/dist/likec4diagram/custom/edges/NotePopover.js +1 -2
  21. package/dist/likec4diagram/custom/edges/RelationshipEdge.d.ts +1 -1
  22. package/dist/likec4diagram/custom/edges/RelationshipEdge.js +1 -1
  23. package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.js +6 -7
  24. package/dist/likec4diagram/custom/index.d.ts +1 -1
  25. package/dist/likec4diagram/custom/nodes/toolbar/Toolbar.js +1 -1
  26. package/dist/likec4diagram/ui/controls/ChangeAutoLayoutButton.js +1 -2
  27. package/dist/likec4diagram/ui/controls/Controls.js +5 -13
  28. package/dist/likec4diagram/ui/controls/NavigationButtons.js +1 -2
  29. package/dist/likec4diagram/ui/controls/ToggleReadonly.d.ts +1 -0
  30. package/dist/likec4diagram/ui/controls/ToggleReadonly.js +28 -0
  31. package/dist/likec4diagram/ui/diagram-title/DiagramTitlePanel.js +8 -9
  32. package/dist/likec4diagram/ui/notation/NotationPanel.js +1 -2
  33. package/dist/likec4diagram/ui/search/LikeC4Search.js +2 -4
  34. package/dist/likec4diagram/ui/search/ViewsColum.js +1 -1
  35. package/dist/likec4diagram/ui/search/state.js +1 -1
  36. package/dist/likec4diagram/ui/walkthrough/DynamicViewWalkthrough.js +1 -2
  37. package/dist/likec4diagram/useViewToNodesEdges.d.ts +0 -1
  38. package/dist/likec4diagram/useViewToNodesEdges.js +0 -2
  39. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Accordion/Accordion.module.css.mjs.vanilla.css.js +1 -0
  40. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/ActionIcon/ActionIcon.module.css.mjs.vanilla.css.js +1 -0
  41. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Affix/Affix.module.css.mjs.vanilla.css.js +1 -0
  42. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Alert/Alert.module.css.mjs.vanilla.css.js +1 -0
  43. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Anchor/Anchor.module.css.mjs.vanilla.css.js +1 -0
  44. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/AngleSlider/AngleSlider.module.css.mjs.vanilla.css.js +1 -0
  45. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/AppShell/AppShell.module.css.mjs.vanilla.css.js +1 -0
  46. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/AspectRatio/AspectRatio.module.css.mjs.vanilla.css.js +1 -0
  47. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Avatar/Avatar.module.css.mjs.vanilla.css.js +1 -0
  48. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/BackgroundImage/BackgroundImage.module.css.mjs.vanilla.css.js +1 -0
  49. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Badge/Badge.module.css.mjs.vanilla.css.js +1 -0
  50. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Blockquote/Blockquote.module.css.mjs.vanilla.css.js +1 -0
  51. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Breadcrumbs/Breadcrumbs.module.css.mjs.vanilla.css.js +1 -0
  52. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Burger/Burger.module.css.mjs.vanilla.css.js +1 -0
  53. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Button/Button.module.css.mjs.vanilla.css.js +1 -0
  54. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Card/Card.module.css.mjs.vanilla.css.js +1 -0
  55. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Center/Center.module.css.mjs.vanilla.css.js +1 -0
  56. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Checkbox/Checkbox.module.css.mjs.vanilla.css.js +1 -0
  57. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Checkbox/CheckboxCard/CheckboxCard.module.css.mjs.vanilla.css.js +1 -0
  58. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Checkbox/CheckboxIndicator/CheckboxIndicator.module.css.mjs.vanilla.css.js +1 -0
  59. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Chip/Chip.module.css.mjs.vanilla.css.js +1 -0
  60. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/CloseButton/CloseButton.module.css.mjs.vanilla.css.js +1 -0
  61. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Code/Code.module.css.mjs.vanilla.css.js +1 -0
  62. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/ColorInput/ColorInput.module.css.mjs.vanilla.css.js +1 -0
  63. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/ColorPicker/ColorPicker.module.css.mjs.vanilla.css.js +1 -0
  64. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/ColorSwatch/ColorSwatch.module.css.mjs.vanilla.css.js +1 -0
  65. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Combobox/Combobox.module.css.mjs.vanilla.css.js +1 -0
  66. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Container/Container.module.css.mjs.vanilla.css.js +1 -0
  67. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Dialog/Dialog.module.css.mjs.vanilla.css.js +1 -0
  68. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Divider/Divider.module.css.mjs.vanilla.css.js +1 -0
  69. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Drawer/Drawer.module.css.mjs.vanilla.css.js +1 -0
  70. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Fieldset/Fieldset.module.css.mjs.vanilla.css.js +1 -0
  71. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Flex/Flex.module.css.mjs.vanilla.css.js +1 -0
  72. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/FloatingIndicator/FloatingIndicator.module.css.mjs.vanilla.css.js +1 -0
  73. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Grid/Grid.module.css.mjs.vanilla.css.js +1 -0
  74. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Group/Group.module.css.mjs.vanilla.css.js +1 -0
  75. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Image/Image.module.css.mjs.vanilla.css.js +1 -0
  76. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Indicator/Indicator.module.css.mjs.vanilla.css.js +1 -0
  77. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/InlineInput/InlineInput.module.css.mjs.vanilla.css.js +1 -0
  78. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Input/Input.module.css.mjs.vanilla.css.js +1 -0
  79. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Kbd/Kbd.module.css.mjs.vanilla.css.js +1 -0
  80. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/List/List.module.css.mjs.vanilla.css.js +1 -0
  81. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Loader/Loader.module.css.mjs.vanilla.css.js +1 -0
  82. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/LoadingOverlay/LoadingOverlay.module.css.mjs.vanilla.css.js +1 -0
  83. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Mark/Mark.module.css.mjs.vanilla.css.js +1 -0
  84. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Menu/Menu.module.css.mjs.vanilla.css.js +1 -0
  85. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Modal/Modal.module.css.mjs.vanilla.css.js +1 -0
  86. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/ModalBase/ModalBase.module.css.mjs.vanilla.css.js +1 -0
  87. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/NavLink/NavLink.module.css.mjs.vanilla.css.js +1 -0
  88. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Notification/Notification.module.css.mjs.vanilla.css.js +1 -0
  89. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/NumberInput/NumberInput.module.css.mjs.vanilla.css.js +1 -0
  90. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Overlay/Overlay.module.css.mjs.vanilla.css.js +1 -0
  91. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Pagination/Pagination.module.css.mjs.vanilla.css.js +1 -0
  92. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Paper/Paper.module.css.mjs.vanilla.css.js +1 -0
  93. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/PasswordInput/PasswordInput.module.css.mjs.vanilla.css.js +1 -0
  94. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Pill/Pill.module.css.mjs.vanilla.css.js +1 -0
  95. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/PillsInput/PillsInput.module.css.mjs.vanilla.css.js +1 -0
  96. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/PinInput/PinInput.module.css.mjs.vanilla.css.js +1 -0
  97. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Popover/Popover.module.css.mjs.vanilla.css.js +1 -0
  98. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Progress/Progress.module.css.mjs.vanilla.css.js +1 -0
  99. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Radio/Radio.module.css.mjs.vanilla.css.js +1 -0
  100. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Radio/RadioCard/RadioCard.module.css.mjs.vanilla.css.js +1 -0
  101. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Radio/RadioIndicator/RadioIndicator.module.css.mjs.vanilla.css.js +1 -0
  102. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Rating/Rating.module.css.mjs.vanilla.css.js +1 -0
  103. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/RingProgress/RingProgress.module.css.mjs.vanilla.css.js +1 -0
  104. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/ScrollArea/ScrollArea.module.css.mjs.vanilla.css.js +1 -0
  105. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/SegmentedControl/SegmentedControl.module.css.mjs.vanilla.css.js +1 -0
  106. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/SemiCircleProgress/SemiCircleProgress.module.css.mjs.vanilla.css.js +1 -0
  107. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/SimpleGrid/SimpleGrid.module.css.mjs.vanilla.css.js +1 -0
  108. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Skeleton/Skeleton.module.css.mjs.vanilla.css.js +1 -0
  109. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Slider/Slider.module.css.mjs.vanilla.css.js +1 -0
  110. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Spoiler/Spoiler.module.css.mjs.vanilla.css.js +1 -0
  111. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Stack/Stack.module.css.mjs.vanilla.css.js +1 -0
  112. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Stepper/Stepper.module.css.mjs.vanilla.css.js +1 -0
  113. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Switch/Switch.module.css.mjs.vanilla.css.js +1 -0
  114. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Table/Table.module.css.mjs.vanilla.css.js +1 -0
  115. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/TableOfContents/TableOfContents.module.css.mjs.vanilla.css.js +1 -0
  116. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Tabs/Tabs.module.css.mjs.vanilla.css.js +1 -0
  117. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Text/Text.module.css.mjs.vanilla.css.js +1 -0
  118. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/ThemeIcon/ThemeIcon.module.css.mjs.vanilla.css.js +1 -0
  119. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Timeline/Timeline.module.css.mjs.vanilla.css.js +1 -0
  120. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Title/Title.module.css.mjs.vanilla.css.js +1 -0
  121. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Tooltip/Tooltip.module.css.mjs.vanilla.css.js +1 -0
  122. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/Tree/Tree.module.css.mjs.vanilla.css.js +1 -0
  123. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/TypographyStylesProvider/TypographyStylesProvider.module.css.mjs.vanilla.css.js +1 -0
  124. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/UnstyledButton/UnstyledButton.module.css.mjs.vanilla.css.js +1 -0
  125. package/dist/node_modules/.pnpm/@mantine_core@7.17.0_@mantine_hooks@7.17.0_react@19.0.0__@types_react@19.0.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@mantine/core/esm/components/VisuallyHidden/VisuallyHidden.module.css.mjs.vanilla.css.js +1 -0
  126. package/dist/overlays/Overlays.d.ts +4 -1
  127. package/dist/overlays/Overlays.js +72 -60
  128. package/dist/overlays/element-details/ElementDetails.d.ts +6 -0
  129. package/dist/overlays/element-details/ElementDetails.js +31 -0
  130. package/dist/overlays/element-details/ElementDetailsCard.js +4 -9
  131. package/dist/overlays/element-details/TabPanelDeployments.js +1 -1
  132. package/dist/overlays/element-details/TabPanelRelationships.d.ts +3 -4
  133. package/dist/overlays/element-details/TabPanelRelationships.js +20 -20
  134. package/dist/overlays/element-details/actor.d.ts +20626 -0
  135. package/dist/overlays/element-details/actor.js +68 -0
  136. package/dist/overlays/element-details/actorContext.d.ts +7 -0
  137. package/dist/overlays/element-details/actorContext.js +14 -0
  138. package/dist/overlays/overlay/Overlay.css.js +87 -87
  139. package/dist/overlays/overlay/Overlay.js +16 -1
  140. package/dist/overlays/overlaysActor.d.ts +190 -0
  141. package/dist/overlays/overlaysActor.js +233 -0
  142. package/dist/overlays/relationship-details/actor.d.ts +130 -4
  143. package/dist/overlays/relationship-details/actor.js +2 -2
  144. package/dist/overlays/relationship-details/custom/edgeTypes.d.ts +1 -1
  145. package/dist/overlays/relationship-details/custom/nodeTypes.js +17 -0
  146. package/dist/overlays/relationships-browser/RelationshipsBrowser.js +17 -19
  147. package/dist/overlays/relationships-browser/actor.d.ts +1095 -8
  148. package/dist/overlays/relationships-browser/actor.js +181 -173
  149. package/dist/overlays/relationships-browser/custom/ElementActions.js +3 -2
  150. package/dist/overlays/relationships-browser/custom/edgeTypes.d.ts +1 -1
  151. package/dist/overlays/relationships-browser/custom/nodeTypes.js +17 -0
  152. package/dist/overlays/relationships-browser/hooks.d.ts +1 -1
  153. package/dist/overlays/relationships-browser/hooks.js +7 -5
  154. package/dist/overlays/types.d.ts +29 -0
  155. package/dist/{likec4diagram/DiagramActor.d.ts → state/DiagramActorProvider.d.ts} +2 -2
  156. package/dist/state/DiagramActorProvider.js +77 -0
  157. package/dist/{likec4diagram/state → state}/assign.d.ts +2 -2
  158. package/dist/{likec4diagram/state → state}/assign.js +2 -2
  159. package/dist/state/diagram-machine.d.ts +11680 -0
  160. package/dist/{likec4diagram/state/machine.js → state/diagram-machine.js} +120 -192
  161. package/dist/{likec4diagram/state → state}/hotkeyActor.d.ts +1 -1
  162. package/dist/state/hotkeyActor.js +26 -0
  163. package/dist/state/inspector.d.ts +4 -0
  164. package/dist/{likec4diagram/state → state}/syncManualLayoutActor.d.ts +7 -8
  165. package/dist/{likec4diagram/state → state}/syncManualLayoutActor.js +7 -13
  166. package/dist/state/types.d.ts +19 -0
  167. package/dist/state/utils.d.ts +17 -0
  168. package/dist/{likec4diagram/state → state}/utils.js +20 -1
  169. package/package.json +20 -25
  170. package/src/LikeC4Diagram.tsx +3 -5
  171. package/src/base/BaseXYFlow.tsx +2 -1
  172. package/src/base/primitives/compound/CompoundTitle.css.ts +0 -5
  173. package/src/context/DiagramEventHandlers.tsx +27 -13
  174. package/src/context/DiagramFeatures.tsx +9 -22
  175. package/src/hooks/index.ts +0 -1
  176. package/src/hooks/safeContext.tsx +16 -0
  177. package/src/hooks/useCurrentViewId.ts +2 -2
  178. package/src/hooks/useDiagram.ts +47 -15
  179. package/src/likec4diagram/DiagramUI.tsx +14 -11
  180. package/src/likec4diagram/XYFlow.tsx +13 -6
  181. package/src/likec4diagram/custom/edges/NotePopover.tsx +1 -2
  182. package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +1 -1
  183. package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.tsx +6 -7
  184. package/src/likec4diagram/custom/nodes/toolbar/Toolbar.tsx +1 -1
  185. package/src/likec4diagram/ui/controls/ChangeAutoLayoutButton.tsx +2 -3
  186. package/src/likec4diagram/ui/controls/Controls.tsx +4 -4
  187. package/src/likec4diagram/ui/controls/NavigationButtons.tsx +1 -2
  188. package/src/likec4diagram/ui/controls/ToggleReadonly.tsx +30 -0
  189. package/src/likec4diagram/ui/diagram-title/DiagramTitlePanel.tsx +8 -11
  190. package/src/likec4diagram/ui/notation/NotationPanel.tsx +2 -3
  191. package/src/likec4diagram/ui/search/LikeC4Search.tsx +1 -4
  192. package/src/likec4diagram/ui/search/ViewsColum.tsx +1 -1
  193. package/src/likec4diagram/ui/search/state.ts +1 -1
  194. package/src/likec4diagram/ui/walkthrough/DynamicViewWalkthrough.tsx +1 -2
  195. package/src/likec4diagram/useViewToNodesEdges.ts +0 -4
  196. package/src/overlays/Overlays.tsx +81 -71
  197. package/src/overlays/element-details/ElementDetails.tsx +33 -0
  198. package/src/overlays/element-details/ElementDetailsCard.tsx +8 -18
  199. package/src/overlays/element-details/TabPanelDeployments.tsx +1 -1
  200. package/src/overlays/element-details/TabPanelRelationships.tsx +33 -32
  201. package/src/overlays/element-details/actor.ts +102 -0
  202. package/src/overlays/element-details/actorContext.tsx +16 -0
  203. package/src/overlays/overlay/Overlay.tsx +14 -11
  204. package/src/overlays/overlaysActor.ts +278 -0
  205. package/src/overlays/relationship-details/actor.ts +8 -11
  206. package/src/overlays/relationship-details/custom/nodeTypes.tsx +18 -0
  207. package/src/overlays/relationships-browser/RelationshipsBrowser.tsx +23 -29
  208. package/src/overlays/relationships-browser/actor.ts +216 -220
  209. package/src/overlays/relationships-browser/custom/ElementActions.tsx +3 -2
  210. package/src/overlays/relationships-browser/custom/nodeTypes.tsx +20 -0
  211. package/src/overlays/relationships-browser/hooks.ts +7 -5
  212. package/src/overlays/types.ts +39 -0
  213. package/src/state/DiagramActorProvider.tsx +97 -0
  214. package/src/{likec4diagram/state → state}/assign.ts +4 -4
  215. package/src/{likec4diagram/state/machine.ts → state/diagram-machine.ts} +152 -203
  216. package/src/state/hotkeyActor.ts +29 -0
  217. package/src/state/inspector.ts +5 -0
  218. package/src/{likec4diagram/state → state}/syncManualLayoutActor.ts +14 -21
  219. package/src/state/types.ts +23 -0
  220. package/src/{likec4diagram/state → state}/utils.ts +24 -2
  221. package/dist/hooks/useDiagramActor.d.ts +0 -5
  222. package/dist/hooks/useDiagramActor.js +0 -21
  223. package/dist/hooks/useDiagramContext.d.ts +0 -3
  224. package/dist/hooks/useDiagramContext.js +0 -10
  225. package/dist/likec4diagram/DiagramActor.js +0 -71
  226. package/dist/likec4diagram/state/actorContext.d.ts +0 -51923
  227. package/dist/likec4diagram/state/actorContext.js +0 -12
  228. package/dist/likec4diagram/state/hotkeyActor.js +0 -18
  229. package/dist/likec4diagram/state/inspector.d.ts +0 -5
  230. package/dist/likec4diagram/state/machine.d.ts +0 -10979
  231. package/dist/likec4diagram/state/utils.d.ts +0 -8
  232. package/src/hooks/useDiagramActor.ts +0 -27
  233. package/src/hooks/useDiagramContext.ts +0 -14
  234. package/src/likec4diagram/DiagramActor.tsx +0 -79
  235. package/src/likec4diagram/state/actorContext.ts +0 -8
  236. package/src/likec4diagram/state/hotkeyActor.ts +0 -20
  237. package/src/likec4diagram/state/inspector.ts +0 -23
  238. /package/dist/{likec4diagram/state → state}/aligners.d.ts +0 -0
  239. /package/dist/{likec4diagram/state → state}/aligners.js +0 -0
  240. /package/src/{likec4diagram/state → state}/aligners.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@likec4/diagram",
3
- "version": "1.22.0",
3
+ "version": "1.23.0",
4
4
  "license": "MIT",
5
5
  "bugs": "https://github.com/likec4/likec4/issues",
6
6
  "homepage": "https://likec4.dev",
@@ -29,24 +29,14 @@
29
29
  },
30
30
  "./style.css": "./dist/style.css"
31
31
  },
32
- "packageManager": "yarn@4.6.0",
33
- "scripts": {
34
- "typecheck": "tsc --noEmit",
35
- "build": "vite build",
36
- "lint": "run -T eslint src/ --fix",
37
- "clean": "rm -r -f -g 'dist/*' .tsbuildinfo",
38
- "test": "vitest run --no-isolate"
39
- },
40
32
  "dependencies": {
41
33
  "@dagrejs/dagre": "1.1.4",
42
- "@likec4/core": "1.22.0",
43
- "@mantine/vanilla-extract": "7.16.3",
34
+ "@mantine/vanilla-extract": "7.17.0",
44
35
  "@nanostores/react": "0.8.4",
45
36
  "@react-hookz/web": "^25.0.1",
46
37
  "@tabler/icons-react": "3.29.0",
47
38
  "@vanilla-extract/dynamic": "^2.1.2",
48
39
  "@xstate/react": "^5.0.2",
49
- "@xstate/store": "^2.6.2",
50
40
  "@xyflow/react": "12.4.2",
51
41
  "@xyflow/system": "0.0.50",
52
42
  "bezier-js": "^6.1.4",
@@ -60,18 +50,16 @@
60
50
  "react-error-boundary": "^5.0.0",
61
51
  "remeda": "^2.20.1",
62
52
  "type-fest": "4.34.1",
63
- "xstate": "^5.19.2"
53
+ "xstate": "^5.19.2",
54
+ "@likec4/core": "1.23.0"
64
55
  },
65
56
  "peerDependencies": {
66
- "@mantine/core": "^7.16.3",
67
- "@mantine/hooks": "^7.16.3",
68
- "react": "^18.0.0 || ^19.0.0",
69
- "react-dom": "^18.0.0 || ^19.0.0"
57
+ "@mantine/core": "7.17.0",
58
+ "@mantine/hooks": "7.17.0",
59
+ "react": "~19.0.0",
60
+ "react-dom": "~19.0.0"
70
61
  },
71
62
  "devDependencies": {
72
- "@likec4/tsconfig": "1.22.0",
73
- "@mantine/core": "7.16.3",
74
- "@mantine/hooks": "7.16.3",
75
63
  "@statelyai/inspect": "^0.4.0",
76
64
  "@types/bezier-js": "^4.1.3",
77
65
  "@types/d3-shape": "^3.1.7",
@@ -79,12 +67,19 @@
79
67
  "@types/react-dom": "~19.0.3",
80
68
  "@vanilla-extract/css": "^1.17.1",
81
69
  "@vanilla-extract/css-utils": "^0.1.4",
70
+ "@vanilla-extract/vite-plugin": "^5.0.1",
82
71
  "@vitejs/plugin-react": "4.3.4",
83
- "react": "~19.0.0",
84
- "react-dom": "~19.0.0",
85
- "typescript": "^5.7.3",
86
- "vite": "5.4.14",
72
+ "typescript": "5.7.3",
73
+ "vite": "6.1.0",
87
74
  "vite-plugin-dts": "^4.5.0",
88
- "vitest": "^3.0.4"
75
+ "vitest": "^3.0.4",
76
+ "@likec4/tsconfig": "1.23.0"
77
+ },
78
+ "scripts": {
79
+ "typecheck": "tsc --noEmit",
80
+ "build": "vite build",
81
+ "lint": "run -T eslint src/ --fix",
82
+ "clean": "rm -r -f -g 'dist/*' .tsbuildinfo",
83
+ "test": "vitest run --no-isolate"
89
84
  }
90
85
  }
@@ -11,12 +11,11 @@ import {
11
11
  } from './context'
12
12
  import { LikeC4CustomColors } from './LikeC4CustomColors'
13
13
  import { type LikeC4DiagramEventHandlers, type LikeC4DiagramProperties } from './LikeC4Diagram.props'
14
- import { DiagramActor } from './likec4diagram/DiagramActor'
15
- import { DiagramUI } from './likec4diagram/DiagramUI'
16
14
  import type { Types } from './likec4diagram/types'
17
15
  import { useViewToNodesEdges } from './likec4diagram/useViewToNodesEdges'
18
16
  import { LikeC4DiagramXYFlow } from './likec4diagram/XYFlow'
19
17
  import { useLikeC4Model } from './likec4model'
18
+ import { DiagramActorProvider } from './state/DiagramActorProvider'
20
19
 
21
20
  export type LikeC4DiagramProps = LikeC4DiagramProperties & LikeC4DiagramEventHandlers
22
21
  export function LikeC4Diagram({
@@ -68,7 +67,6 @@ export function LikeC4Diagram({
68
67
  const xyNodesEdges = useViewToNodesEdges({
69
68
  view,
70
69
  where,
71
- nodesDraggable,
72
70
  nodesSelectable,
73
71
  })
74
72
 
@@ -129,7 +127,7 @@ export function LikeC4Diagram({
129
127
  fitView={fitView}
130
128
  {...initialRef.current}
131
129
  >
132
- <DiagramActor
130
+ <DiagramActorProvider
133
131
  input={{
134
132
  view,
135
133
  pannable,
@@ -142,7 +140,7 @@ export function LikeC4Diagram({
142
140
  nodesSelectable={nodesSelectable}
143
141
  background={background}
144
142
  />
145
- </DiagramActor>
143
+ </DiagramActorProvider>
146
144
  </XYFlowProvider>
147
145
  </RootContainer>
148
146
  </DiagramEventHandlers>
@@ -115,7 +115,8 @@ export const BaseXYFlow = <
115
115
  {...(!pannable && {
116
116
  selectionKeyCode: null,
117
117
  })}
118
- onlyRenderVisibleElements={nodes.length > 75}
118
+ // TODO: benchmarks first
119
+ //onlyRenderVisibleElements={nodes.length > 75}
119
120
  elementsSelectable={nodesSelectable}
120
121
  nodesFocusable={nodesDraggable || nodesSelectable}
121
122
  edgesFocusable={false}
@@ -35,11 +35,6 @@ export const title = style({
35
35
  // paddingBottom: 6,
36
36
  // minHeight: 20,
37
37
  mixBlendMode: 'screen',
38
- selectors: {
39
- [`${whereLight} &`]: {
40
- mixBlendMode: 'darken',
41
- },
42
- },
43
38
  })
44
39
 
45
40
  const iconSize = '20px'
@@ -1,5 +1,5 @@
1
1
  import { useSyncedRef } from '@react-hookz/web'
2
- import { type PropsWithChildren, createContext, useContext, useMemo } from 'react'
2
+ import { type PropsWithChildren, type RefObject, createContext, useContext, useMemo } from 'react'
3
3
  import { isFunction, mapToObj } from 'remeda'
4
4
  import type { LikeC4DiagramEventHandlers } from '../LikeC4Diagram.props'
5
5
 
@@ -21,9 +21,16 @@ const HandlerNames = [
21
21
  'onCanvasDblClick',
22
22
  ] as const
23
23
 
24
- const DiagramEventHandlersContext = createContext<RequiredOrNull<LikeC4DiagramEventHandlers>>(
25
- mapToObj(HandlerNames, (name) => [name, null]),
26
- )
24
+ type DiagramEventHandlersContextValue = RequiredOrNull<LikeC4DiagramEventHandlers> & {
25
+ handlersRef: RefObject<LikeC4DiagramEventHandlers>
26
+ }
27
+
28
+ const DiagramEventHandlersContext = createContext<DiagramEventHandlersContextValue>({
29
+ ...mapToObj(HandlerNames, (name) => [name, null]),
30
+ handlersRef: {
31
+ current: {},
32
+ },
33
+ })
27
34
 
28
35
  export function DiagramEventHandlers({
29
36
  handlers,
@@ -33,16 +40,19 @@ export function DiagramEventHandlers({
33
40
 
34
41
  const deps = HandlerNames.map((name) => isFunction(handlers[name]))
35
42
 
43
+ const value = useMemo((): DiagramEventHandlersContextValue => ({
44
+ ...mapToObj(HandlerNames, (name) => {
45
+ if (handlersRef.current[name]) {
46
+ // @ts-expect-error TODO: fix this
47
+ return [name, (...args: any[]) => handlersRef.current[name]?.(...args)]
48
+ }
49
+ return [name, null]
50
+ }),
51
+ handlersRef,
52
+ }), [handlersRef, ...deps])
53
+
36
54
  return (
37
- <DiagramEventHandlersContext.Provider
38
- value={useMemo(() =>
39
- mapToObj(HandlerNames, (name) => {
40
- if (handlersRef.current[name]) {
41
- // @ts-expect-error TODO: fix this
42
- return [name, (...args: any[]) => handlersRef.current[name]?.(...args)]
43
- }
44
- return [name, null]
45
- }), [handlersRef, ...deps])}>
55
+ <DiagramEventHandlersContext.Provider value={value}>
46
56
  {children}
47
57
  </DiagramEventHandlersContext.Provider>
48
58
  )
@@ -51,3 +61,7 @@ export function DiagramEventHandlers({
51
61
  export function useDiagramEventHandlers() {
52
62
  return useContext(DiagramEventHandlersContext)
53
63
  }
64
+
65
+ export function useDiagramEventHandlersRef() {
66
+ return useContext(DiagramEventHandlersContext).handlersRef
67
+ }
@@ -28,7 +28,7 @@ const FeatureNames = [
28
28
  */
29
29
  'Vscode',
30
30
  ] as const
31
- type FeatureName = typeof FeatureNames[number]
31
+ export type FeatureName = typeof FeatureNames[number]
32
32
  export type EnabledFeatures = {
33
33
  [P in `enable${FeatureName}`]: boolean
34
34
  }
@@ -47,42 +47,29 @@ const validate = (features: EnabledFeatures) => {
47
47
  enableRelationshipDetails,
48
48
  enableRelationshipBrowser,
49
49
  enableSearch,
50
+ enableEdgeEditing,
50
51
  ...rest
51
52
  } = features
52
53
  if (!enableLikeC4Model) {
53
- if (enableElementDetails) {
54
- console.warn('enableElementDetails is ignored because requires LikeC4Model')
55
- enableElementDetails = false
56
- }
57
- if (enableRelationshipDetails) {
58
- console.warn('enableRelationshipDetails is ignored because requires enableLikeC4Model')
59
- enableRelationshipDetails = false
60
- }
61
- if (enableRelationshipBrowser) {
62
- console.warn('enableRelationshipBrowser is ignored because requires LikeC4Model')
63
- enableRelationshipBrowser = false
64
- }
65
- if (enableSearch) {
66
- console.warn('enableSearch is ignored because requires LikeC4Model')
67
- enableSearch = false
68
- }
54
+ enableElementDetails = false
55
+ enableRelationshipDetails = false
56
+ enableRelationshipBrowser = false
57
+ enableSearch = false
69
58
  }
70
59
 
71
60
  if (enableReadOnly) {
72
- if (rest.enableEdgeEditing) {
73
- console.warn('enableEdgeEditing is ignored because enabled ReadOnly')
74
- rest.enableEdgeEditing = false
75
- }
61
+ enableEdgeEditing = false
76
62
  }
77
63
 
78
64
  return {
79
- ...rest,
80
65
  enableReadOnly,
81
66
  enableLikeC4Model,
82
67
  enableElementDetails,
83
68
  enableRelationshipDetails,
84
69
  enableRelationshipBrowser,
85
70
  enableSearch,
71
+ enableEdgeEditing,
72
+ ...rest,
86
73
  }
87
74
  }
88
75
 
@@ -1,4 +1,3 @@
1
- export { useCurrentViewId } from './useCurrentViewId'
2
1
  export { useMantinePortalProps } from './useMantinePortalProps'
3
2
  export { useSetState } from './useSetState'
4
3
  export { useUpdateEffect } from './useUpdateEffect'
@@ -0,0 +1,16 @@
1
+ import { createContext, use } from 'react'
2
+ import type { DiagramActorRef } from '../state/types'
3
+
4
+ /**
5
+ * To improve experience with HMR, we use `createSafeContext` as a boundary for hoooks
6
+ */
7
+ export const DiagramActorSafeContext = createContext<DiagramActorRef>(null as any)
8
+ DiagramActorSafeContext.displayName = 'DiagramActorSafeContext'
9
+
10
+ export const useDiagramActorRef = () => {
11
+ const ctx = use(DiagramActorSafeContext)
12
+ if (ctx === null) {
13
+ throw new Error('DiagramActorRef is not provided')
14
+ }
15
+ return ctx
16
+ }
@@ -1,6 +1,6 @@
1
1
  import type { ViewId } from '@likec4/core'
2
- import type { DiagramContext } from '../likec4diagram/state/machine'
3
- import { useDiagramContext } from './useDiagramContext'
2
+ import type { DiagramContext } from '../state/types'
3
+ import { useDiagramContext } from './useDiagram'
4
4
 
5
5
  const selectViewId = (state: DiagramContext) => state.view.id
6
6
  export function useCurrentViewId(): ViewId {
@@ -1,14 +1,21 @@
1
- import type { EdgeId, Fqn, NodeId, ViewId } from '@likec4/core'
1
+ import { type DiagramView, type EdgeId, type Fqn, type NodeId, type ViewId } from '@likec4/core'
2
+ import { useCallbackRef } from '@mantine/hooks'
3
+ import { useSelector as useXstateSelector } from '@xstate/react'
4
+ import { shallowEqual } from 'fast-equals'
2
5
  import { useMemo, useTransition } from 'react'
3
6
  import type { PartialDeep } from 'type-fest'
4
- import { useDiagramActor } from '../hooks/useDiagramActor'
7
+ import type { FeatureName } from '../context/DiagramFeatures'
5
8
  import type { OpenSourceParams } from '../LikeC4Diagram.props'
6
- import type { AlignmentMode } from '../likec4diagram/state/aligners'
7
- import { DiagramContext } from '../likec4diagram/state/machine'
8
9
  import type { Types } from '../likec4diagram/types'
10
+ import type { AlignmentMode } from '../state/aligners'
11
+ import type { DiagramActorSnapshot, DiagramContext, SyncLayoutActorRef, SyncLayoutActorSnapshot } from '../state/types'
12
+ import { findDiagramEdge, findDiagramNode } from '../state/utils'
13
+ import { useDiagramActorRef } from './safeContext'
14
+
15
+ export { useDiagramActorRef }
9
16
 
10
17
  export function useDiagram() {
11
- const actor = useDiagramActor()
18
+ const actor = useDiagramActorRef()
12
19
  const [, startTransition] = useTransition()
13
20
  return useMemo(() => ({
14
21
  send: actor.send,
@@ -49,11 +56,7 @@ export function useDiagram() {
49
56
  actor.send({ type: 'open.relationshipDetails', edgeId })
50
57
  })
51
58
  },
52
- closeOverlay: () => {
53
- startTransition(() => {
54
- actor.send({ type: 'close.overlay' })
55
- })
56
- },
59
+
57
60
  updateNodeData: (nodeId: NodeId, data: PartialDeep<Types.NodeData>) => {
58
61
  actor.send({ type: 'update.nodeData', nodeId, data })
59
62
  },
@@ -72,7 +75,7 @@ export function useDiagram() {
72
75
  * @returns true if there was pending request to save layout
73
76
  */
74
77
  cancelSaveManualLayout: () => {
75
- const syncState = actor.getSnapshot().context.syncLayoutActorRef.getSnapshot().value
78
+ const syncState = actor.getSnapshot().children.syncLayout?.getSnapshot().value
76
79
  actor.send({ type: 'saveManualLayout.cancel' })
77
80
  return syncState === 'pending' || syncState === 'paused'
78
81
  },
@@ -92,11 +95,13 @@ export function useDiagram() {
92
95
  /**
93
96
  * @warning Do not use in render phase
94
97
  */
95
- currentView: () => actor.getSnapshot().context.view,
98
+ get currentView(): DiagramView {
99
+ return actor.getSnapshot().context.view
100
+ },
96
101
  /**
97
102
  * @warning Do not use in render phase
98
103
  */
99
- getState: () => actor.getSnapshot(),
104
+ getSnapshot: () => actor.getSnapshot(),
100
105
  /**
101
106
  * @warning Do not use in render phase
102
107
  */
@@ -105,13 +110,13 @@ export function useDiagram() {
105
110
  * @warning Do not use in render phase
106
111
  */
107
112
  findDiagramNode: (xynodeId: string) => {
108
- return DiagramContext.findDiagramNode(actor.getSnapshot().context, xynodeId)
113
+ return findDiagramNode(actor.getSnapshot().context, xynodeId)
109
114
  },
110
115
  /**
111
116
  * @warning Do not use in render phase
112
117
  */
113
118
  findDiagramEdge: (xyedgeId: string) => {
114
- return DiagramContext.findDiagramEdge(actor.getSnapshot().context, xyedgeId)
119
+ return findDiagramEdge(actor.getSnapshot().context, xyedgeId)
115
120
  },
116
121
 
117
122
  startWalkthrough: () => {
@@ -125,5 +130,32 @@ export function useDiagram() {
125
130
  stopWalkthrough: () => {
126
131
  actor.send({ type: 'walkthrough.end' })
127
132
  },
133
+
134
+ toggleFeature: (feature: FeatureName, forceValue?: boolean) => {
135
+ actor.send({ type: 'toggle.feature', feature, ...(forceValue !== undefined && { forceValue }) })
136
+ },
128
137
  }), [actor])
129
138
  }
139
+
140
+ export function useDiagramActorSnapshot<T = unknown>(
141
+ selector: (state: DiagramActorSnapshot) => T,
142
+ compare: (a: NoInfer<T>, b: NoInfer<T>) => boolean = shallowEqual,
143
+ ): T {
144
+ const actorRef = useDiagramActorRef()
145
+ return useXstateSelector(actorRef, useCallbackRef(selector), compare)
146
+ }
147
+
148
+ export function useDiagramSyncLayoutState<T = unknown>(
149
+ selector: (state: SyncLayoutActorSnapshot) => T,
150
+ compare: (a: NoInfer<T>, b: NoInfer<T>) => boolean = shallowEqual,
151
+ ): T {
152
+ const syncLayoutActorRef = useDiagramActorSnapshot(s => s.context.syncLayoutActorRef as SyncLayoutActorRef)
153
+ return useXstateSelector(syncLayoutActorRef, useCallbackRef(selector), compare)
154
+ }
155
+
156
+ export function useDiagramContext<T = unknown>(
157
+ selector: (state: DiagramContext) => T,
158
+ compare: (a: NoInfer<T>, b: NoInfer<T>) => boolean = shallowEqual,
159
+ ) {
160
+ return useDiagramActorSnapshot(useCallbackRef(s => selector(s.context)), compare)
161
+ }
@@ -1,21 +1,24 @@
1
- import { IfEnabled } from '../context'
1
+ import { useEnabledFeatures } from '../context'
2
+ import { useDiagramActorSnapshot } from '../hooks/useDiagram'
2
3
  import { Overlays } from '../overlays/Overlays'
3
4
  import { Controls, DiagramTitlePanel, DynamicViewWalkthrough, NotationPanel } from './ui'
4
5
 
5
6
  export function DiagramUI() {
7
+ const {
8
+ enableViewTitle,
9
+ enableNotations,
10
+ enableDynamicViewWalkthrough,
11
+ } = useEnabledFeatures()
12
+
13
+ const overlaysActorRef = useDiagramActorSnapshot(s => s.children.overlays)
14
+
6
15
  return (
7
16
  <>
8
17
  <Controls />
9
- <Overlays />
10
- <IfEnabled feature="ViewTitle">
11
- <DiagramTitlePanel />
12
- </IfEnabled>
13
- <IfEnabled feature="Notations">
14
- <NotationPanel />
15
- </IfEnabled>
16
- <IfEnabled feature="DynamicViewWalkthrough">
17
- <DynamicViewWalkthrough />
18
- </IfEnabled>
18
+ {overlaysActorRef && <Overlays overlaysActorRef={overlaysActorRef} />}
19
+ {enableViewTitle && <DiagramTitlePanel />}
20
+ {enableNotations && <NotationPanel />}
21
+ {enableDynamicViewWalkthrough && <DynamicViewWalkthrough />}
19
22
  </>
20
23
  )
21
24
  }
@@ -6,12 +6,11 @@ import { memo } from 'react'
6
6
  import type { EnforceOptional } from 'type-fest/source/enforce-optional'
7
7
  import { BaseXYFlow } from '../base/BaseXYFlow'
8
8
  import { useDiagramEventHandlers } from '../context'
9
- import { useDiagram } from '../hooks/useDiagram'
10
- import { useDiagramContext } from '../hooks/useDiagramContext'
9
+ import { useDiagram, useDiagramContext } from '../hooks/useDiagram'
11
10
  import type { LikeC4DiagramProperties } from '../LikeC4Diagram.props'
11
+ import type { DiagramContext } from '../state/types'
12
12
  import { edgeTypes, nodeTypes } from './custom'
13
13
  import { DiagramUI } from './DiagramUI'
14
- import type { DiagramContext } from './state/machine'
15
14
  import type { Types } from './types'
16
15
  import { useLayoutConstraints } from './useLayoutConstraints'
17
16
 
@@ -23,7 +22,14 @@ const selectXYProps = (ctx: DiagramContext) => ({
23
22
  zoomable: ctx.zoomable,
24
23
  fitViewPadding: ctx.fitViewPadding,
25
24
  enableFitView: ctx.features.enableFitView,
26
- enableReadOnly: ctx.features.enableReadOnly,
25
+ enableReadOnly: ctx.features.enableReadOnly || ctx.toggledFeatures.enableReadOnly,
26
+ ...(!ctx.features.enableFitView && {
27
+ viewport: {
28
+ x: -Math.min(ctx.view.bounds.x, 0),
29
+ y: -Math.min(ctx.view.bounds.y, 0),
30
+ zoom: 1,
31
+ },
32
+ }),
27
33
  })
28
34
  const equalsXYProps = (a: ReturnType<typeof selectXYProps>, b: ReturnType<typeof selectXYProps>): boolean =>
29
35
  a.initialized === b.initialized &&
@@ -33,7 +39,8 @@ const equalsXYProps = (a: ReturnType<typeof selectXYProps>, b: ReturnType<typeof
33
39
  a.enableFitView === b.enableFitView &&
34
40
  a.enableReadOnly === b.enableReadOnly &&
35
41
  shallowEqual(a.nodes, b.nodes) &&
36
- shallowEqual(a.edges, b.edges)
42
+ shallowEqual(a.edges, b.edges) &&
43
+ shallowEqual(a.viewport, b.viewport)
37
44
 
38
45
  type Picked = EnforceOptional<
39
46
  Pick<
@@ -138,7 +145,7 @@ export const LikeC4DiagramXYFlow = memo<LikeC4DiagramXYFlowProps>(({ background,
138
145
  {...enableFitView && {
139
146
  onViewportResize,
140
147
  }}
141
- nodesDraggable={nodesDraggable}
148
+ nodesDraggable={notReadOnly && nodesDraggable}
142
149
  nodesSelectable={nodesSelectable}
143
150
  {...(notReadOnly && nodesDraggable && layoutConstraints)}
144
151
  {...props}>
@@ -13,8 +13,7 @@ import { useDebouncedEffect } from '@react-hookz/web'
13
13
  import { type PropsWithChildren, useState } from 'react'
14
14
  import { isNonNull, isTruthy } from 'remeda'
15
15
  import { useMantinePortalProps } from '../../../hooks'
16
- import { useDiagram } from '../../../hooks/useDiagram'
17
- import { useDiagramContext } from '../../../hooks/useDiagramContext'
16
+ import { useDiagram, useDiagramContext } from '../../../hooks/useDiagram'
18
17
  import { stopPropagation } from '../../../utils'
19
18
  import * as edgesCss from './NotePopover.css'
20
19
 
@@ -291,7 +291,7 @@ export const RelationshipEdge = customEdge<Types.RelationshipEdgeData>((props) =
291
291
  let renderLabel: undefined | ((props: any) => any)
292
292
  if (!isControlPointDragging) {
293
293
  const notes = props.data.notes
294
- if (notes && isStepEdgeId(props.id) && diagram.getState().context.activeWalkthrough?.stepId === props.id) {
294
+ if (notes && isStepEdgeId(props.id) && diagram.getContext().activeWalkthrough?.stepId === props.id) {
295
295
  renderLabel = (props: any) => (
296
296
  <NotePopover notes={notes}>
297
297
  <div {...props} />
@@ -30,10 +30,9 @@ import { filter, isTruthy, map, partition, pipe } from 'remeda'
30
30
  import { Link } from '../../../components/Link'
31
31
  import { IfEnabled, useDiagramEventHandlers, useEnabledFeature } from '../../../context'
32
32
  import { useMantinePortalProps } from '../../../hooks'
33
- import { useDiagram } from '../../../hooks/useDiagram'
34
- import { useDiagramContext } from '../../../hooks/useDiagramContext'
33
+ import { useDiagram, useDiagramContext } from '../../../hooks/useDiagram'
35
34
  import { useLikeC4Model } from '../../../likec4model'
36
- import { DiagramContext } from '../../state/machine'
35
+ import { findDiagramEdge, findDiagramNode } from '../../../state/utils'
37
36
  import * as css from './RelationshipsDropdownMenu.css'
38
37
 
39
38
  const stopPropagation: MouseEventHandler = (e) => e.stopPropagation()
@@ -62,9 +61,9 @@ export function RelationshipsDropdownMenu({
62
61
  disabled?: boolean | undefined
63
62
  }>) {
64
63
  const { diagramEdge, sourceNode, targetNode } = useDiagramContext(ctx => ({
65
- diagramEdge: DiagramContext.findDiagramEdge(ctx, edgeId),
66
- sourceNode: DiagramContext.findDiagramNode(ctx, source),
67
- targetNode: DiagramContext.findDiagramNode(ctx, target),
64
+ diagramEdge: findDiagramEdge(ctx, edgeId),
65
+ sourceNode: findDiagramNode(ctx, source),
66
+ targetNode: findDiagramNode(ctx, target),
68
67
  }))
69
68
  const likec4model = useLikeC4Model(true)
70
69
  const diagram = useDiagram()
@@ -189,7 +188,7 @@ const Relationship = forwardRef<
189
188
  const diagram = useDiagram()
190
189
  const { enableNavigateTo } = useEnabledFeature('NavigateTo')
191
190
  const { onOpenSource } = useDiagramEventHandlers()
192
- const viewId = diagram.currentView().id
191
+ const viewId = diagram.currentView.id
193
192
 
194
193
  const sourceId = getShortId(r, r.source.id, sourceNode)
195
194
  const targetId = getShortId(r, r.target.id, targetNode)
@@ -4,7 +4,7 @@ import { type NodeToolbarProps, NodeToolbar } from '@xyflow/react'
4
4
  import clsx from 'clsx'
5
5
  import type { ReactNode } from 'react'
6
6
  import type { Base } from '../../../../base'
7
- import { useDiagramContext } from '../../../../hooks/useDiagramContext'
7
+ import { useDiagramContext } from '../../../../hooks/useDiagram'
8
8
  import { stopPropagation } from '../../../../utils/xyflow'
9
9
  import * as css from './styles.css'
10
10
 
@@ -22,9 +22,8 @@ import { useDebouncedCallback } from '@react-hookz/web'
22
22
  import { IconLayoutDashboard } from '@tabler/icons-react'
23
23
  import { forwardRef, useState } from 'react'
24
24
  import { useDiagramEventHandlers } from '../../../context'
25
- import { useDiagram } from '../../../hooks/useDiagram'
26
- import { useDiagramContext } from '../../../hooks/useDiagramContext'
27
- import type { DiagramContext } from '../../state/machine'
25
+ import { useDiagram, useDiagramContext } from '../../../hooks/useDiagram'
26
+ import type { DiagramContext } from '../../../state/types'
28
27
  import { ActionIcon, Tooltip } from './_shared'
29
28
  import * as css from './styles.css'
30
29
 
@@ -5,9 +5,7 @@ import { LayoutGroup } from 'framer-motion'
5
5
  import { memo } from 'react'
6
6
  import { useDiagramEventHandlers, useEnabledFeatures } from '../../../context'
7
7
  import { useMantinePortalProps } from '../../../hooks'
8
- import { useDiagram } from '../../../hooks/useDiagram'
9
- import { useDiagramSyncLayoutState } from '../../../hooks/useDiagramActor'
10
- import { useDiagramContext } from '../../../hooks/useDiagramContext'
8
+ import { useDiagram, useDiagramContext, useDiagramSyncLayoutState } from '../../../hooks/useDiagram'
11
9
  import { stopPropagation } from '../../../utils'
12
10
  import { LikeC4Search } from '../search/LikeC4Search'
13
11
  import { ActionIcon, Tooltip } from './_shared'
@@ -16,6 +14,7 @@ import { LayoutDriftNotification } from './LayoutDriftNotification'
16
14
  import { ManualLayoutToolsButton } from './ManualLayoutToolsButton'
17
15
  import { NavigationButtons } from './NavigationButtons'
18
16
  import * as css from './styles.css'
17
+ import { ToggleReadonly } from './ToggleReadonly'
19
18
 
20
19
  export const Controls = memo(() => {
21
20
  const { viewId, hasLayoutDrift, viewportChanged } = useDiagramContext(c => ({
@@ -78,6 +77,7 @@ export const Controls = memo(() => {
78
77
  </ActionIcon>
79
78
  </Tooltip>
80
79
  )}
80
+ {enableControls && <ToggleReadonly />}
81
81
  {enableControls && hasLayoutDrift && <LayoutDriftNotification {...portalProps} />}
82
82
  {enableControls && notReadOnly && (
83
83
  <>
@@ -100,7 +100,7 @@ export const Controls = memo(() => {
100
100
  </Stack>
101
101
  <Group>
102
102
  {enableSearch && <LikeC4Search />}
103
- {notReadOnly && <SyncLayoutBadge />}
103
+ {/* {notReadOnly && <SyncLayoutBadge />} */}
104
104
  </Group>
105
105
  </Group>
106
106
  )
@@ -3,8 +3,7 @@ import { IconChevronRight } from '@tabler/icons-react'
3
3
  import { AnimatePresence, m } from 'framer-motion'
4
4
 
5
5
  import { IconChevronLeft } from '@tabler/icons-react'
6
- import { useDiagram } from '../../../hooks/useDiagram'
7
- import { useDiagramContext } from '../../../hooks/useDiagramContext'
6
+ import { useDiagram, useDiagramContext } from '../../../hooks/useDiagram'
8
7
  import { ActionIcon } from './_shared'
9
8
 
10
9
  export const NavigationButtons = () => {
@@ -0,0 +1,30 @@
1
+ import { IconLock, IconLockOpen2 } from '@tabler/icons-react'
2
+ import { useDiagram, useDiagramContext } from '../../../hooks/useDiagram'
3
+ import type { DiagramContext } from '../../../state/types'
4
+ import { ActionIcon, Tooltip } from './_shared'
5
+
6
+ const selector = (state: DiagramContext) => ({
7
+ visible: state.features.enableReadOnly !== true,
8
+ isReadOnly: state.toggledFeatures.enableReadOnly ?? state.features.enableReadOnly,
9
+ })
10
+
11
+ export const ToggleReadonly = () => {
12
+ const { visible, isReadOnly } = useDiagramContext(selector)
13
+ const diagram = useDiagram()
14
+
15
+ if (!visible) {
16
+ return null
17
+ }
18
+
19
+ return (
20
+ <Tooltip label={isReadOnly ? 'Enable editing' : 'Disable editing'}>
21
+ <ActionIcon
22
+ onClick={e => {
23
+ e.stopPropagation()
24
+ diagram.toggleFeature('ReadOnly')
25
+ }}>
26
+ {isReadOnly ? <IconLock /> : <IconLockOpen2 />}
27
+ </ActionIcon>
28
+ </Tooltip>
29
+ )
30
+ }