@likec4/diagram 1.22.1 → 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 (238) 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.js +9 -22
  9. package/dist/{style.css → diagram.css} +1 -1
  10. package/dist/hooks/index.d.ts +0 -1
  11. package/dist/hooks/safeContext.d.ts +7 -0
  12. package/dist/hooks/safeContext.js +14 -0
  13. package/dist/hooks/useCurrentViewId.js +1 -1
  14. package/dist/hooks/useDiagram.d.ts +6587 -5969
  15. package/dist/hooks/useDiagram.js +26 -14
  16. package/dist/index.js +1 -1
  17. package/dist/likec4diagram/DiagramUI.js +12 -5
  18. package/dist/likec4diagram/XYFlow.js +3 -4
  19. package/dist/likec4diagram/custom/edges/NotePopover.js +1 -2
  20. package/dist/likec4diagram/custom/edges/RelationshipEdge.d.ts +1 -1
  21. package/dist/likec4diagram/custom/edges/RelationshipEdge.js +1 -1
  22. package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.js +6 -7
  23. package/dist/likec4diagram/custom/index.d.ts +1 -1
  24. package/dist/likec4diagram/custom/nodes/toolbar/Toolbar.js +1 -1
  25. package/dist/likec4diagram/ui/controls/ChangeAutoLayoutButton.js +1 -2
  26. package/dist/likec4diagram/ui/controls/Controls.js +3 -13
  27. package/dist/likec4diagram/ui/controls/NavigationButtons.js +1 -2
  28. package/dist/likec4diagram/ui/controls/ToggleReadonly.js +1 -2
  29. package/dist/likec4diagram/ui/diagram-title/DiagramTitlePanel.js +8 -9
  30. package/dist/likec4diagram/ui/notation/NotationPanel.js +1 -2
  31. package/dist/likec4diagram/ui/search/LikeC4Search.js +2 -4
  32. package/dist/likec4diagram/ui/search/ViewsColum.js +1 -1
  33. package/dist/likec4diagram/ui/search/state.js +1 -1
  34. package/dist/likec4diagram/ui/walkthrough/DynamicViewWalkthrough.js +1 -2
  35. package/dist/likec4diagram/useViewToNodesEdges.d.ts +0 -1
  36. package/dist/likec4diagram/useViewToNodesEdges.js +0 -2
  37. 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
  38. 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
  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/Affix/Affix.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/Alert/Alert.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/Anchor/Anchor.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/AngleSlider/AngleSlider.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/AppShell/AppShell.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/AspectRatio/AspectRatio.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/Avatar/Avatar.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/BackgroundImage/BackgroundImage.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/Badge/Badge.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/Blockquote/Blockquote.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/Breadcrumbs/Breadcrumbs.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/Burger/Burger.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/Button/Button.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/Card/Card.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/Center/Center.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/Checkbox/Checkbox.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/Checkbox/CheckboxCard/CheckboxCard.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/CheckboxIndicator/CheckboxIndicator.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/Chip/Chip.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/CloseButton/CloseButton.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/Code/Code.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/ColorInput/ColorInput.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/ColorPicker/ColorPicker.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/ColorSwatch/ColorSwatch.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/Combobox/Combobox.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/Container/Container.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/Dialog/Dialog.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/Divider/Divider.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/Drawer/Drawer.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/Fieldset/Fieldset.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/Flex/Flex.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/FloatingIndicator/FloatingIndicator.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/Grid/Grid.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/Group/Group.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/Image/Image.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/Indicator/Indicator.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/InlineInput/InlineInput.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/Input/Input.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/Kbd/Kbd.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/List/List.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/Loader/Loader.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/LoadingOverlay/LoadingOverlay.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/Mark/Mark.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/Menu/Menu.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/Modal/Modal.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/ModalBase/ModalBase.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/NavLink/NavLink.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/Notification/Notification.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/NumberInput/NumberInput.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/Overlay/Overlay.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/Pagination/Pagination.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/Paper/Paper.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/PasswordInput/PasswordInput.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/Pill/Pill.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/PillsInput/PillsInput.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/PinInput/PinInput.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/Popover/Popover.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/Progress/Progress.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/Radio/Radio.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/Radio/RadioCard/RadioCard.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/RadioIndicator/RadioIndicator.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/Rating/Rating.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/RingProgress/RingProgress.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/ScrollArea/ScrollArea.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/SegmentedControl/SegmentedControl.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/SemiCircleProgress/SemiCircleProgress.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/SimpleGrid/SimpleGrid.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/Skeleton/Skeleton.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/Slider/Slider.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/Spoiler/Spoiler.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/Stack/Stack.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/Stepper/Stepper.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/Switch/Switch.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/Table/Table.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/TableOfContents/TableOfContents.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/Tabs/Tabs.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/Text/Text.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/ThemeIcon/ThemeIcon.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/Timeline/Timeline.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/Title/Title.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/Tooltip/Tooltip.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/Tree/Tree.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/TypographyStylesProvider/TypographyStylesProvider.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/UnstyledButton/UnstyledButton.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/VisuallyHidden/VisuallyHidden.module.css.mjs.vanilla.css.js +1 -0
  124. package/dist/overlays/Overlays.d.ts +4 -1
  125. package/dist/overlays/Overlays.js +72 -60
  126. package/dist/overlays/element-details/ElementDetails.d.ts +6 -0
  127. package/dist/overlays/element-details/ElementDetails.js +31 -0
  128. package/dist/overlays/element-details/ElementDetailsCard.js +4 -9
  129. package/dist/overlays/element-details/TabPanelDeployments.js +1 -1
  130. package/dist/overlays/element-details/TabPanelRelationships.d.ts +3 -4
  131. package/dist/overlays/element-details/TabPanelRelationships.js +20 -20
  132. package/dist/overlays/element-details/actor.d.ts +20626 -0
  133. package/dist/overlays/element-details/actor.js +68 -0
  134. package/dist/overlays/element-details/actorContext.d.ts +7 -0
  135. package/dist/overlays/element-details/actorContext.js +14 -0
  136. package/dist/overlays/overlay/Overlay.css.js +87 -87
  137. package/dist/overlays/overlay/Overlay.js +16 -1
  138. package/dist/overlays/overlaysActor.d.ts +190 -0
  139. package/dist/overlays/overlaysActor.js +233 -0
  140. package/dist/overlays/relationship-details/actor.d.ts +130 -4
  141. package/dist/overlays/relationship-details/actor.js +2 -2
  142. package/dist/overlays/relationship-details/custom/edgeTypes.d.ts +1 -1
  143. package/dist/overlays/relationship-details/custom/nodeTypes.js +17 -0
  144. package/dist/overlays/relationships-browser/RelationshipsBrowser.js +17 -19
  145. package/dist/overlays/relationships-browser/actor.d.ts +1095 -8
  146. package/dist/overlays/relationships-browser/actor.js +181 -173
  147. package/dist/overlays/relationships-browser/custom/ElementActions.js +3 -2
  148. package/dist/overlays/relationships-browser/custom/edgeTypes.d.ts +1 -1
  149. package/dist/overlays/relationships-browser/custom/nodeTypes.js +17 -0
  150. package/dist/overlays/relationships-browser/hooks.d.ts +1 -1
  151. package/dist/overlays/relationships-browser/hooks.js +7 -5
  152. package/dist/overlays/types.d.ts +29 -0
  153. package/dist/{likec4diagram/DiagramActor.d.ts → state/DiagramActorProvider.d.ts} +2 -2
  154. package/dist/state/DiagramActorProvider.js +77 -0
  155. package/dist/{likec4diagram/state → state}/assign.d.ts +2 -2
  156. package/dist/{likec4diagram/state → state}/assign.js +2 -2
  157. package/dist/state/diagram-machine.d.ts +11680 -0
  158. package/dist/{likec4diagram/state/machine.js → state/diagram-machine.js} +105 -194
  159. package/dist/{likec4diagram/state → state}/hotkeyActor.d.ts +1 -1
  160. package/dist/state/hotkeyActor.js +26 -0
  161. package/dist/state/inspector.d.ts +4 -0
  162. package/dist/{likec4diagram/state → state}/syncManualLayoutActor.d.ts +7 -8
  163. package/dist/{likec4diagram/state → state}/syncManualLayoutActor.js +3 -5
  164. package/dist/state/types.d.ts +19 -0
  165. package/dist/state/utils.d.ts +17 -0
  166. package/dist/{likec4diagram/state → state}/utils.js +20 -1
  167. package/package.json +20 -24
  168. package/src/LikeC4Diagram.tsx +3 -5
  169. package/src/base/BaseXYFlow.tsx +2 -1
  170. package/src/base/primitives/compound/CompoundTitle.css.ts +0 -5
  171. package/src/context/DiagramEventHandlers.tsx +27 -13
  172. package/src/context/DiagramFeatures.tsx +8 -21
  173. package/src/hooks/index.ts +0 -1
  174. package/src/hooks/safeContext.tsx +16 -0
  175. package/src/hooks/useCurrentViewId.ts +2 -2
  176. package/src/hooks/useDiagram.ts +42 -15
  177. package/src/likec4diagram/DiagramUI.tsx +14 -11
  178. package/src/likec4diagram/XYFlow.tsx +4 -5
  179. package/src/likec4diagram/custom/edges/NotePopover.tsx +1 -2
  180. package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +1 -1
  181. package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.tsx +6 -7
  182. package/src/likec4diagram/custom/nodes/toolbar/Toolbar.tsx +1 -1
  183. package/src/likec4diagram/ui/controls/ChangeAutoLayoutButton.tsx +2 -3
  184. package/src/likec4diagram/ui/controls/Controls.tsx +2 -4
  185. package/src/likec4diagram/ui/controls/NavigationButtons.tsx +1 -2
  186. package/src/likec4diagram/ui/controls/ToggleReadonly.tsx +2 -3
  187. package/src/likec4diagram/ui/diagram-title/DiagramTitlePanel.tsx +8 -11
  188. package/src/likec4diagram/ui/notation/NotationPanel.tsx +2 -3
  189. package/src/likec4diagram/ui/search/LikeC4Search.tsx +1 -4
  190. package/src/likec4diagram/ui/search/ViewsColum.tsx +1 -1
  191. package/src/likec4diagram/ui/search/state.ts +1 -1
  192. package/src/likec4diagram/ui/walkthrough/DynamicViewWalkthrough.tsx +1 -2
  193. package/src/likec4diagram/useViewToNodesEdges.ts +0 -4
  194. package/src/overlays/Overlays.tsx +81 -71
  195. package/src/overlays/element-details/ElementDetails.tsx +33 -0
  196. package/src/overlays/element-details/ElementDetailsCard.tsx +8 -18
  197. package/src/overlays/element-details/TabPanelDeployments.tsx +1 -1
  198. package/src/overlays/element-details/TabPanelRelationships.tsx +33 -32
  199. package/src/overlays/element-details/actor.ts +102 -0
  200. package/src/overlays/element-details/actorContext.tsx +16 -0
  201. package/src/overlays/overlay/Overlay.tsx +14 -11
  202. package/src/overlays/overlaysActor.ts +278 -0
  203. package/src/overlays/relationship-details/actor.ts +8 -11
  204. package/src/overlays/relationship-details/custom/nodeTypes.tsx +18 -0
  205. package/src/overlays/relationships-browser/RelationshipsBrowser.tsx +23 -29
  206. package/src/overlays/relationships-browser/actor.ts +216 -220
  207. package/src/overlays/relationships-browser/custom/ElementActions.tsx +3 -2
  208. package/src/overlays/relationships-browser/custom/nodeTypes.tsx +20 -0
  209. package/src/overlays/relationships-browser/hooks.ts +7 -5
  210. package/src/overlays/types.ts +39 -0
  211. package/src/state/DiagramActorProvider.tsx +97 -0
  212. package/src/{likec4diagram/state → state}/assign.ts +4 -4
  213. package/src/{likec4diagram/state/machine.ts → state/diagram-machine.ts} +130 -205
  214. package/src/state/hotkeyActor.ts +29 -0
  215. package/src/state/inspector.ts +5 -0
  216. package/src/{likec4diagram/state → state}/syncManualLayoutActor.ts +8 -12
  217. package/src/state/types.ts +23 -0
  218. package/src/{likec4diagram/state → state}/utils.ts +24 -2
  219. package/dist/hooks/useDiagramActor.d.ts +0 -5
  220. package/dist/hooks/useDiagramActor.js +0 -21
  221. package/dist/hooks/useDiagramContext.d.ts +0 -3
  222. package/dist/hooks/useDiagramContext.js +0 -10
  223. package/dist/likec4diagram/DiagramActor.js +0 -82
  224. package/dist/likec4diagram/state/actorContext.d.ts +0 -52075
  225. package/dist/likec4diagram/state/actorContext.js +0 -12
  226. package/dist/likec4diagram/state/hotkeyActor.js +0 -18
  227. package/dist/likec4diagram/state/inspector.d.ts +0 -5
  228. package/dist/likec4diagram/state/machine.d.ts +0 -11025
  229. package/dist/likec4diagram/state/utils.d.ts +0 -8
  230. package/src/hooks/useDiagramActor.ts +0 -27
  231. package/src/hooks/useDiagramContext.ts +0 -14
  232. package/src/likec4diagram/DiagramActor.tsx +0 -92
  233. package/src/likec4diagram/state/actorContext.ts +0 -8
  234. package/src/likec4diagram/state/hotkeyActor.ts +0 -20
  235. package/src/likec4diagram/state/inspector.ts +0 -23
  236. /package/dist/{likec4diagram/state → state}/aligners.d.ts +0 -0
  237. /package/dist/{likec4diagram/state → state}/aligners.js +0 -0
  238. /package/src/{likec4diagram/state → state}/aligners.ts +0 -0
@@ -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
+ }
@@ -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,15 +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
7
  import type { FeatureName } from '../context/DiagramFeatures'
5
- import { useDiagramActor } from '../hooks/useDiagramActor'
6
8
  import type { OpenSourceParams } from '../LikeC4Diagram.props'
7
- import type { AlignmentMode } from '../likec4diagram/state/aligners'
8
- import { DiagramContext } from '../likec4diagram/state/machine'
9
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 }
10
16
 
11
17
  export function useDiagram() {
12
- const actor = useDiagramActor()
18
+ const actor = useDiagramActorRef()
13
19
  const [, startTransition] = useTransition()
14
20
  return useMemo(() => ({
15
21
  send: actor.send,
@@ -50,11 +56,7 @@ export function useDiagram() {
50
56
  actor.send({ type: 'open.relationshipDetails', edgeId })
51
57
  })
52
58
  },
53
- closeOverlay: () => {
54
- startTransition(() => {
55
- actor.send({ type: 'close.overlay' })
56
- })
57
- },
59
+
58
60
  updateNodeData: (nodeId: NodeId, data: PartialDeep<Types.NodeData>) => {
59
61
  actor.send({ type: 'update.nodeData', nodeId, data })
60
62
  },
@@ -73,7 +75,7 @@ export function useDiagram() {
73
75
  * @returns true if there was pending request to save layout
74
76
  */
75
77
  cancelSaveManualLayout: () => {
76
- const syncState = actor.getSnapshot().context.syncLayoutActorRef.getSnapshot().value
78
+ const syncState = actor.getSnapshot().children.syncLayout?.getSnapshot().value
77
79
  actor.send({ type: 'saveManualLayout.cancel' })
78
80
  return syncState === 'pending' || syncState === 'paused'
79
81
  },
@@ -93,11 +95,13 @@ export function useDiagram() {
93
95
  /**
94
96
  * @warning Do not use in render phase
95
97
  */
96
- currentView: () => actor.getSnapshot().context.view,
98
+ get currentView(): DiagramView {
99
+ return actor.getSnapshot().context.view
100
+ },
97
101
  /**
98
102
  * @warning Do not use in render phase
99
103
  */
100
- getState: () => actor.getSnapshot(),
104
+ getSnapshot: () => actor.getSnapshot(),
101
105
  /**
102
106
  * @warning Do not use in render phase
103
107
  */
@@ -106,13 +110,13 @@ export function useDiagram() {
106
110
  * @warning Do not use in render phase
107
111
  */
108
112
  findDiagramNode: (xynodeId: string) => {
109
- return DiagramContext.findDiagramNode(actor.getSnapshot().context, xynodeId)
113
+ return findDiagramNode(actor.getSnapshot().context, xynodeId)
110
114
  },
111
115
  /**
112
116
  * @warning Do not use in render phase
113
117
  */
114
118
  findDiagramEdge: (xyedgeId: string) => {
115
- return DiagramContext.findDiagramEdge(actor.getSnapshot().context, xyedgeId)
119
+ return findDiagramEdge(actor.getSnapshot().context, xyedgeId)
116
120
  },
117
121
 
118
122
  startWalkthrough: () => {
@@ -132,3 +136,26 @@ export function useDiagram() {
132
136
  },
133
137
  }), [actor])
134
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,7 @@ 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,
27
26
  ...(!ctx.features.enableFitView && {
28
27
  viewport: {
29
28
  x: -Math.min(ctx.view.bounds.x, 0),
@@ -146,7 +145,7 @@ export const LikeC4DiagramXYFlow = memo<LikeC4DiagramXYFlowProps>(({ background,
146
145
  {...enableFitView && {
147
146
  onViewportResize,
148
147
  }}
149
- nodesDraggable={nodesDraggable}
148
+ nodesDraggable={notReadOnly && nodesDraggable}
150
149
  nodesSelectable={nodesSelectable}
151
150
  {...(notReadOnly && nodesDraggable && layoutConstraints)}
152
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'
@@ -102,7 +100,7 @@ export const Controls = memo(() => {
102
100
  </Stack>
103
101
  <Group>
104
102
  {enableSearch && <LikeC4Search />}
105
- {notReadOnly && <SyncLayoutBadge />}
103
+ {/* {notReadOnly && <SyncLayoutBadge />} */}
106
104
  </Group>
107
105
  </Group>
108
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 = () => {
@@ -1,7 +1,6 @@
1
1
  import { IconLock, IconLockOpen2 } from '@tabler/icons-react'
2
- import { useDiagram } from '../../../hooks/useDiagram'
3
- import { useDiagramContext } from '../../../hooks/useDiagramContext'
4
- import type { DiagramContext } from '../../state/machine'
2
+ import { useDiagram, useDiagramContext } from '../../../hooks/useDiagram'
3
+ import type { DiagramContext } from '../../../state/types'
5
4
  import { ActionIcon, Tooltip } from './_shared'
6
5
 
7
6
  const selector = (state: DiagramContext) => ({
@@ -4,20 +4,17 @@ import { IconMenu } from '@tabler/icons-react'
4
4
  import clsx from 'clsx'
5
5
  import { AnimatePresence, m } from 'framer-motion'
6
6
  import { Link } from '../../../components/Link'
7
- import { useDiagramContext } from '../../../hooks/useDiagramContext'
8
- import type { DiagramContext } from '../../state/machine'
7
+ import { useDiagramContext } from '../../../hooks/useDiagram'
9
8
  import * as css from './DiagramTitlePanel.css'
10
9
 
11
- const selector = (s: DiagramContext) => ({
12
- id: s.view.id,
13
- title: s.view.title ?? 'untitled',
14
- description: s.view.description,
15
- links: s.view.links,
16
- isNotActiveWalkthrough: s.activeWalkthrough === null,
17
- })
18
-
19
10
  export function DiagramTitlePanel() {
20
- const { id, title, description, links, isNotActiveWalkthrough } = useDiagramContext(selector)
11
+ const { id, title, description, links, isNotActiveWalkthrough } = useDiagramContext(s => ({
12
+ id: s.view.id,
13
+ title: s.view.title ?? 'untitled',
14
+ description: s.view.description,
15
+ links: s.view.links,
16
+ isNotActiveWalkthrough: s.activeWalkthrough === null,
17
+ }))
21
18
  const [isCollapsed, setCollapsed] = useLocalStorage({
22
19
  key: 'diagram-title-webview-collapsed',
23
20
  defaultValue: false,
@@ -24,10 +24,9 @@ import { memo, useState } from 'react'
24
24
  import { ceil, isNonNullish } from 'remeda'
25
25
  import { ElementShape } from '../../../base/primitives'
26
26
  import { useMantinePortalProps } from '../../../hooks'
27
- import { useDiagram } from '../../../hooks/useDiagram'
28
- import { useDiagramContext } from '../../../hooks/useDiagramContext'
27
+ import { useDiagram, useDiagramContext } from '../../../hooks/useDiagram'
29
28
  import { useXYStore } from '../../../hooks/useXYFlow'
30
- import { DiagramContext } from '../../../likec4diagram/state/machine'
29
+ import type { DiagramContext } from '../../../state/types'
31
30
  import { vars } from '../../../theme-vars'
32
31
  import * as css from './NotationPanel.css'
33
32
 
@@ -105,10 +105,7 @@ export function LikeC4Search() {
105
105
 
106
106
  function LikeC4SearchOverlay() {
107
107
  const close = useCloseSearch()
108
- const focusTrapRef = useFocusTrap()
109
- const { ref: forcusRef, focused } = useFocusWithin()
110
-
111
- const ref = useMergedRef(forcusRef, focusTrapRef)
108
+ const ref = useFocusTrap()
112
109
 
113
110
  useWindowEvent(
114
111
  'keydown',
@@ -20,7 +20,7 @@ import { IconStack2, IconZoomScan } from '@tabler/icons-react'
20
20
  import clsx from 'clsx'
21
21
  import { m } from 'framer-motion'
22
22
  import { first } from 'remeda'
23
- import { useCurrentViewId } from '../../../hooks'
23
+ import { useCurrentViewId } from '../../../hooks/useCurrentViewId'
24
24
  import { useLikeC4Model } from '../../../likec4model/useLikeC4Model'
25
25
  import { emptyBoX } from './_shared.css'
26
26
  import { useCloseSearchAndNavigateTo, useNormalizedSearch } from './state'
@@ -66,7 +66,7 @@ export function useCloseSearchAndNavigateTo() {
66
66
  const fromNode = fromElementFqn
67
67
  ? diagram.getContext().view.nodes.find(n => DiagramNode.modelRef(n) === fromElementFqn)?.id
68
68
  : undefined
69
- if (diagram.currentView().id === viewId && fromNode) {
69
+ if (diagram.currentView.id === viewId && fromNode) {
70
70
  diagram.focusNode(fromNode)
71
71
  return
72
72
  }
@@ -9,8 +9,7 @@ import clsx from 'clsx'
9
9
  import { AnimatePresence, m } from 'framer-motion'
10
10
  import { isNonNull, isTruthy } from 'remeda'
11
11
  import { useXYStore } from '../../../hooks'
12
- import { useDiagram } from '../../../hooks/useDiagram'
13
- import { useDiagramContext } from '../../../hooks/useDiagramContext'
12
+ import { useDiagram, useDiagramContext } from '../../../hooks/useDiagram'
14
13
  import * as css from './DynamicViewWalkthrough.css'
15
14
 
16
15
  export function DynamicViewWalkthrough() {
@@ -21,7 +21,6 @@ import type { Types } from './types'
21
21
  function viewToNodesEdge(opts: {
22
22
  view: Pick<DiagramView, 'id' | 'nodes' | 'edges' | '__'>
23
23
  where: WhereOperator<string, string> | undefined
24
- nodesDraggable: boolean
25
24
  nodesSelectable: boolean
26
25
  }): {
27
26
  xynodes: Types.Node[]
@@ -29,7 +28,6 @@ function viewToNodesEdge(opts: {
29
28
  } {
30
29
  const {
31
30
  view,
32
- nodesDraggable: draggable,
33
31
  nodesSelectable: selectable,
34
32
  } = opts
35
33
  const isDynamicView = view.__ === 'dynamic',
@@ -95,7 +93,6 @@ function viewToNodesEdge(opts: {
95
93
 
96
94
  const base = {
97
95
  id,
98
- draggable: draggable,
99
96
  selectable: selectable && node.kind !== ElementKind.Group,
100
97
  focusable: selectable && !isCompound,
101
98
  deletable: false,
@@ -281,7 +278,6 @@ export function useViewToNodesEdges({
281
278
  }: {
282
279
  view: DiagramView
283
280
  where: WhereOperator<string, string> | undefined
284
- nodesDraggable: boolean
285
281
  nodesSelectable: boolean
286
282
  }) {
287
283
  return useDeepCompareMemo(() => {