@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.
- package/dist/LikeC4Diagram.js +2 -3
- package/dist/base/BaseXYFlow.js +0 -1
- package/dist/base/example/custom.d.ts +1 -1
- package/dist/base/primitives/customEdge.d.ts +1 -1
- package/dist/base/primitives/edge/EdgePath.d.ts +1 -1
- package/dist/context/DiagramEventHandlers.d.ts +6 -2
- package/dist/context/DiagramEventHandlers.js +25 -20
- package/dist/context/DiagramFeatures.d.ts +1 -1
- package/dist/context/DiagramFeatures.js +9 -22
- package/dist/{style.css → diagram.css} +1 -1
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/safeContext.d.ts +7 -0
- package/dist/hooks/safeContext.js +14 -0
- package/dist/hooks/useCurrentViewId.js +1 -1
- package/dist/hooks/useDiagram.d.ts +7250 -6596
- package/dist/hooks/useDiagram.js +29 -14
- package/dist/index.js +1 -1
- package/dist/likec4diagram/DiagramUI.js +12 -5
- package/dist/likec4diagram/XYFlow.js +11 -5
- package/dist/likec4diagram/custom/edges/NotePopover.js +1 -2
- package/dist/likec4diagram/custom/edges/RelationshipEdge.d.ts +1 -1
- package/dist/likec4diagram/custom/edges/RelationshipEdge.js +1 -1
- package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.js +6 -7
- package/dist/likec4diagram/custom/index.d.ts +1 -1
- package/dist/likec4diagram/custom/nodes/toolbar/Toolbar.js +1 -1
- package/dist/likec4diagram/ui/controls/ChangeAutoLayoutButton.js +1 -2
- package/dist/likec4diagram/ui/controls/Controls.js +5 -13
- package/dist/likec4diagram/ui/controls/NavigationButtons.js +1 -2
- package/dist/likec4diagram/ui/controls/ToggleReadonly.d.ts +1 -0
- package/dist/likec4diagram/ui/controls/ToggleReadonly.js +28 -0
- package/dist/likec4diagram/ui/diagram-title/DiagramTitlePanel.js +8 -9
- package/dist/likec4diagram/ui/notation/NotationPanel.js +1 -2
- package/dist/likec4diagram/ui/search/LikeC4Search.js +2 -4
- package/dist/likec4diagram/ui/search/ViewsColum.js +1 -1
- package/dist/likec4diagram/ui/search/state.js +1 -1
- package/dist/likec4diagram/ui/walkthrough/DynamicViewWalkthrough.js +1 -2
- package/dist/likec4diagram/useViewToNodesEdges.d.ts +0 -1
- package/dist/likec4diagram/useViewToNodesEdges.js +0 -2
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- package/dist/overlays/Overlays.d.ts +4 -1
- package/dist/overlays/Overlays.js +72 -60
- package/dist/overlays/element-details/ElementDetails.d.ts +6 -0
- package/dist/overlays/element-details/ElementDetails.js +31 -0
- package/dist/overlays/element-details/ElementDetailsCard.js +4 -9
- package/dist/overlays/element-details/TabPanelDeployments.js +1 -1
- package/dist/overlays/element-details/TabPanelRelationships.d.ts +3 -4
- package/dist/overlays/element-details/TabPanelRelationships.js +20 -20
- package/dist/overlays/element-details/actor.d.ts +20626 -0
- package/dist/overlays/element-details/actor.js +68 -0
- package/dist/overlays/element-details/actorContext.d.ts +7 -0
- package/dist/overlays/element-details/actorContext.js +14 -0
- package/dist/overlays/overlay/Overlay.css.js +87 -87
- package/dist/overlays/overlay/Overlay.js +16 -1
- package/dist/overlays/overlaysActor.d.ts +190 -0
- package/dist/overlays/overlaysActor.js +233 -0
- package/dist/overlays/relationship-details/actor.d.ts +130 -4
- package/dist/overlays/relationship-details/actor.js +2 -2
- package/dist/overlays/relationship-details/custom/edgeTypes.d.ts +1 -1
- package/dist/overlays/relationship-details/custom/nodeTypes.js +17 -0
- package/dist/overlays/relationships-browser/RelationshipsBrowser.js +17 -19
- package/dist/overlays/relationships-browser/actor.d.ts +1095 -8
- package/dist/overlays/relationships-browser/actor.js +181 -173
- package/dist/overlays/relationships-browser/custom/ElementActions.js +3 -2
- package/dist/overlays/relationships-browser/custom/edgeTypes.d.ts +1 -1
- package/dist/overlays/relationships-browser/custom/nodeTypes.js +17 -0
- package/dist/overlays/relationships-browser/hooks.d.ts +1 -1
- package/dist/overlays/relationships-browser/hooks.js +7 -5
- package/dist/overlays/types.d.ts +29 -0
- package/dist/{likec4diagram/DiagramActor.d.ts → state/DiagramActorProvider.d.ts} +2 -2
- package/dist/state/DiagramActorProvider.js +77 -0
- package/dist/{likec4diagram/state → state}/assign.d.ts +2 -2
- package/dist/{likec4diagram/state → state}/assign.js +2 -2
- package/dist/state/diagram-machine.d.ts +11680 -0
- package/dist/{likec4diagram/state/machine.js → state/diagram-machine.js} +120 -192
- package/dist/{likec4diagram/state → state}/hotkeyActor.d.ts +1 -1
- package/dist/state/hotkeyActor.js +26 -0
- package/dist/state/inspector.d.ts +4 -0
- package/dist/{likec4diagram/state → state}/syncManualLayoutActor.d.ts +7 -8
- package/dist/{likec4diagram/state → state}/syncManualLayoutActor.js +7 -13
- package/dist/state/types.d.ts +19 -0
- package/dist/state/utils.d.ts +17 -0
- package/dist/{likec4diagram/state → state}/utils.js +20 -1
- package/package.json +20 -25
- package/src/LikeC4Diagram.tsx +3 -5
- package/src/base/BaseXYFlow.tsx +2 -1
- package/src/base/primitives/compound/CompoundTitle.css.ts +0 -5
- package/src/context/DiagramEventHandlers.tsx +27 -13
- package/src/context/DiagramFeatures.tsx +9 -22
- package/src/hooks/index.ts +0 -1
- package/src/hooks/safeContext.tsx +16 -0
- package/src/hooks/useCurrentViewId.ts +2 -2
- package/src/hooks/useDiagram.ts +47 -15
- package/src/likec4diagram/DiagramUI.tsx +14 -11
- package/src/likec4diagram/XYFlow.tsx +13 -6
- package/src/likec4diagram/custom/edges/NotePopover.tsx +1 -2
- package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +1 -1
- package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.tsx +6 -7
- package/src/likec4diagram/custom/nodes/toolbar/Toolbar.tsx +1 -1
- package/src/likec4diagram/ui/controls/ChangeAutoLayoutButton.tsx +2 -3
- package/src/likec4diagram/ui/controls/Controls.tsx +4 -4
- package/src/likec4diagram/ui/controls/NavigationButtons.tsx +1 -2
- package/src/likec4diagram/ui/controls/ToggleReadonly.tsx +30 -0
- package/src/likec4diagram/ui/diagram-title/DiagramTitlePanel.tsx +8 -11
- package/src/likec4diagram/ui/notation/NotationPanel.tsx +2 -3
- package/src/likec4diagram/ui/search/LikeC4Search.tsx +1 -4
- package/src/likec4diagram/ui/search/ViewsColum.tsx +1 -1
- package/src/likec4diagram/ui/search/state.ts +1 -1
- package/src/likec4diagram/ui/walkthrough/DynamicViewWalkthrough.tsx +1 -2
- package/src/likec4diagram/useViewToNodesEdges.ts +0 -4
- package/src/overlays/Overlays.tsx +81 -71
- package/src/overlays/element-details/ElementDetails.tsx +33 -0
- package/src/overlays/element-details/ElementDetailsCard.tsx +8 -18
- package/src/overlays/element-details/TabPanelDeployments.tsx +1 -1
- package/src/overlays/element-details/TabPanelRelationships.tsx +33 -32
- package/src/overlays/element-details/actor.ts +102 -0
- package/src/overlays/element-details/actorContext.tsx +16 -0
- package/src/overlays/overlay/Overlay.tsx +14 -11
- package/src/overlays/overlaysActor.ts +278 -0
- package/src/overlays/relationship-details/actor.ts +8 -11
- package/src/overlays/relationship-details/custom/nodeTypes.tsx +18 -0
- package/src/overlays/relationships-browser/RelationshipsBrowser.tsx +23 -29
- package/src/overlays/relationships-browser/actor.ts +216 -220
- package/src/overlays/relationships-browser/custom/ElementActions.tsx +3 -2
- package/src/overlays/relationships-browser/custom/nodeTypes.tsx +20 -0
- package/src/overlays/relationships-browser/hooks.ts +7 -5
- package/src/overlays/types.ts +39 -0
- package/src/state/DiagramActorProvider.tsx +97 -0
- package/src/{likec4diagram/state → state}/assign.ts +4 -4
- package/src/{likec4diagram/state/machine.ts → state/diagram-machine.ts} +152 -203
- package/src/state/hotkeyActor.ts +29 -0
- package/src/state/inspector.ts +5 -0
- package/src/{likec4diagram/state → state}/syncManualLayoutActor.ts +14 -21
- package/src/state/types.ts +23 -0
- package/src/{likec4diagram/state → state}/utils.ts +24 -2
- package/dist/hooks/useDiagramActor.d.ts +0 -5
- package/dist/hooks/useDiagramActor.js +0 -21
- package/dist/hooks/useDiagramContext.d.ts +0 -3
- package/dist/hooks/useDiagramContext.js +0 -10
- package/dist/likec4diagram/DiagramActor.js +0 -71
- package/dist/likec4diagram/state/actorContext.d.ts +0 -51923
- package/dist/likec4diagram/state/actorContext.js +0 -12
- package/dist/likec4diagram/state/hotkeyActor.js +0 -18
- package/dist/likec4diagram/state/inspector.d.ts +0 -5
- package/dist/likec4diagram/state/machine.d.ts +0 -10979
- package/dist/likec4diagram/state/utils.d.ts +0 -8
- package/src/hooks/useDiagramActor.ts +0 -27
- package/src/hooks/useDiagramContext.ts +0 -14
- package/src/likec4diagram/DiagramActor.tsx +0 -79
- package/src/likec4diagram/state/actorContext.ts +0 -8
- package/src/likec4diagram/state/hotkeyActor.ts +0 -20
- package/src/likec4diagram/state/inspector.ts +0 -23
- /package/dist/{likec4diagram/state → state}/aligners.d.ts +0 -0
- /package/dist/{likec4diagram/state → state}/aligners.js +0 -0
- /package/src/{likec4diagram/state → state}/aligners.ts +0 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { ViewId } from '@likec4/core'
|
|
2
|
+
import { useCallbackRef } from '@mantine/hooks'
|
|
3
|
+
import { useActorRef, useSelector } from '@xstate/react'
|
|
4
|
+
import { useStoreApi } from '@xyflow/react'
|
|
5
|
+
import { shallowEqual } from 'fast-equals'
|
|
6
|
+
import { type PropsWithChildren, useEffect } from 'react'
|
|
7
|
+
import { useDiagramEventHandlersRef } from '../context/DiagramEventHandlers'
|
|
8
|
+
import { DiagramFeatures, useEnabledFeatures } from '../context/DiagramFeatures'
|
|
9
|
+
import { DiagramActorSafeContext } from '../hooks/safeContext'
|
|
10
|
+
import { useUpdateEffect } from '../hooks/useUpdateEffect'
|
|
11
|
+
import type { Types } from '../likec4diagram/types'
|
|
12
|
+
import { type Input, diagramMachine } from './diagram-machine'
|
|
13
|
+
// import { inspector } from './inspector'
|
|
14
|
+
import { syncManualLayoutActorLogic } from './syncManualLayoutActor'
|
|
15
|
+
import type { DiagramActorRef } from './types'
|
|
16
|
+
|
|
17
|
+
type ActorContextInput = Omit<Input, 'xystore' | 'features'>
|
|
18
|
+
|
|
19
|
+
export function DiagramActorProvider({ input, children }: PropsWithChildren<{ input: ActorContextInput }>) {
|
|
20
|
+
const handlersRef = useDiagramEventHandlersRef()
|
|
21
|
+
const xystore = useStoreApi<Types.Node, Types.Edge>()
|
|
22
|
+
|
|
23
|
+
const actorRef = useActorRef(
|
|
24
|
+
diagramMachine.provide({
|
|
25
|
+
actions: {
|
|
26
|
+
'trigger:NavigateTo': ((_, { viewId }) => {
|
|
27
|
+
handlersRef.current.onNavigateTo?.(viewId as ViewId)
|
|
28
|
+
}),
|
|
29
|
+
|
|
30
|
+
'trigger:OnChange': ((_, params) => {
|
|
31
|
+
handlersRef.current.onChange?.(params)
|
|
32
|
+
}),
|
|
33
|
+
|
|
34
|
+
'trigger:OpenSource': ((_, params) => {
|
|
35
|
+
handlersRef.current.onOpenSource?.(params)
|
|
36
|
+
}),
|
|
37
|
+
},
|
|
38
|
+
actors: {
|
|
39
|
+
syncManualLayoutActorLogic: syncManualLayoutActorLogic.provide({
|
|
40
|
+
actions: {
|
|
41
|
+
'trigger:OnChange': ((_, params) => {
|
|
42
|
+
handlersRef.current.onChange?.(params)
|
|
43
|
+
}),
|
|
44
|
+
},
|
|
45
|
+
}),
|
|
46
|
+
},
|
|
47
|
+
}),
|
|
48
|
+
{
|
|
49
|
+
id: `diagram:${input.view.id}`,
|
|
50
|
+
systemId: 'diagram',
|
|
51
|
+
// ...inspector,
|
|
52
|
+
input: {
|
|
53
|
+
xystore,
|
|
54
|
+
...input,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
(
|
|
61
|
+
<DiagramActorSafeContext value={actorRef}>
|
|
62
|
+
<SyncStore input={input} actorRef={actorRef} />
|
|
63
|
+
<DiagramActorToggledFeatures actorRef={actorRef}>
|
|
64
|
+
{children}
|
|
65
|
+
</DiagramActorToggledFeatures>
|
|
66
|
+
</DiagramActorSafeContext>
|
|
67
|
+
)
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const SyncStore = (
|
|
72
|
+
{ input: { view, xyedges, xynodes, ...inputs }, actorRef }: { input: ActorContextInput; actorRef: DiagramActorRef },
|
|
73
|
+
) => {
|
|
74
|
+
const features = useEnabledFeatures()
|
|
75
|
+
useUpdateEffect(() => {
|
|
76
|
+
actorRef.send({ type: 'update.inputs', inputs })
|
|
77
|
+
}, [actorRef, inputs])
|
|
78
|
+
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
actorRef.send({ type: 'update.features', features })
|
|
81
|
+
}, [actorRef, features])
|
|
82
|
+
|
|
83
|
+
useUpdateEffect(() => {
|
|
84
|
+
actorRef.send({ type: 'update.view', view, xyedges, xynodes })
|
|
85
|
+
}, [actorRef, view, xyedges, xynodes])
|
|
86
|
+
|
|
87
|
+
return null
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function DiagramActorToggledFeatures({ children, actorRef }: PropsWithChildren<{ actorRef: DiagramActorRef }>) {
|
|
91
|
+
const toggledFeatures = useSelector(actorRef, useCallbackRef(s => s.context.toggledFeatures), shallowEqual)
|
|
92
|
+
return (
|
|
93
|
+
<DiagramFeatures overrides={toggledFeatures}>
|
|
94
|
+
{children}
|
|
95
|
+
</DiagramFeatures>
|
|
96
|
+
)
|
|
97
|
+
}
|
|
@@ -3,10 +3,10 @@ import { getNodeDimensions } from '@xyflow/system'
|
|
|
3
3
|
import { deepEqual as eq } from 'fast-equals'
|
|
4
4
|
import { isEmpty, mergeDeep, omit } from 'remeda'
|
|
5
5
|
import { assertEvent } from 'xstate'
|
|
6
|
-
import { Base } from '
|
|
7
|
-
import
|
|
8
|
-
import type
|
|
9
|
-
import type { ActionArg, DiagramContext } from './machine'
|
|
6
|
+
import { Base } from '../base/types'
|
|
7
|
+
import type { Types } from '../likec4diagram/types'
|
|
8
|
+
import { type Vector, vector, VectorImpl } from '../utils/vector'
|
|
9
|
+
import type { ActionArg, Context as DiagramContext } from './diagram-machine'
|
|
10
10
|
|
|
11
11
|
export function lastClickedNode(
|
|
12
12
|
params: { context: DiagramContext; event: { node: Types.Node } },
|
|
@@ -25,8 +25,10 @@ import {
|
|
|
25
25
|
import { type EdgeChange, type NodeChange, type Rect, type Viewport, nodeToRect } from '@xyflow/system'
|
|
26
26
|
import { clamp, first, hasAtLeast, prop } from 'remeda'
|
|
27
27
|
import {
|
|
28
|
-
type
|
|
29
|
-
type
|
|
28
|
+
type ActorLogicFrom,
|
|
29
|
+
type ActorRef,
|
|
30
|
+
type AnyEventObject,
|
|
31
|
+
type Snapshot,
|
|
30
32
|
and,
|
|
31
33
|
assertEvent,
|
|
32
34
|
assign,
|
|
@@ -39,14 +41,12 @@ import {
|
|
|
39
41
|
spawnChild,
|
|
40
42
|
stopChild,
|
|
41
43
|
} from 'xstate'
|
|
42
|
-
import { MinZoom } from '
|
|
43
|
-
import type
|
|
44
|
-
import {
|
|
45
|
-
import type {
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
import type { Types } from '../types'
|
|
49
|
-
import { createLayoutConstraints } from '../useLayoutConstraints'
|
|
44
|
+
import { MinZoom } from '../base/const'
|
|
45
|
+
import { type EnabledFeatures, type FeatureName, AllDisabled } from '../context/DiagramFeatures'
|
|
46
|
+
import type { OpenSourceParams } from '../LikeC4Diagram.props'
|
|
47
|
+
import type { Types } from '../likec4diagram/types'
|
|
48
|
+
import { createLayoutConstraints } from '../likec4diagram/useLayoutConstraints'
|
|
49
|
+
import { overlaysActorLogic } from '../overlays/overlaysActor'
|
|
50
50
|
import { type AlignmentMode, getAligner, toNodeRect } from './aligners'
|
|
51
51
|
import {
|
|
52
52
|
focusNodesEdges,
|
|
@@ -61,9 +61,9 @@ import {
|
|
|
61
61
|
updateNavigationHistory,
|
|
62
62
|
updateNodeData,
|
|
63
63
|
} from './assign'
|
|
64
|
-
import { type HotKeyEvent,
|
|
65
|
-
import {
|
|
66
|
-
import { focusedBounds } from './utils'
|
|
64
|
+
import { type HotKeyEvent, hotkeyActorLogic } from './hotkeyActor'
|
|
65
|
+
import { type Events as SyncLayoutEvents, syncManualLayoutActorLogic } from './syncManualLayoutActor'
|
|
66
|
+
import { focusedBounds, typedSystem } from './utils'
|
|
67
67
|
|
|
68
68
|
type XYStoreApi = ReturnType<typeof useStoreApi<Types.Node, Types.Edge>>
|
|
69
69
|
|
|
@@ -86,8 +86,12 @@ export interface Input {
|
|
|
86
86
|
fitViewPadding: number
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
type ToggledFeatures = Partial<EnabledFeatures>
|
|
90
|
+
|
|
91
|
+
export interface Context extends Input {
|
|
90
92
|
features: EnabledFeatures
|
|
93
|
+
// This is used to override features from props
|
|
94
|
+
toggledFeatures: ToggledFeatures
|
|
91
95
|
initialized: boolean
|
|
92
96
|
viewport: Viewport
|
|
93
97
|
viewportChangedManually: boolean
|
|
@@ -113,7 +117,8 @@ export interface DiagramContext extends Input {
|
|
|
113
117
|
}
|
|
114
118
|
viewportBeforeFocus: null | Viewport
|
|
115
119
|
xyflow: ReactFlowInstance<Types.Node, Types.Edge> | null
|
|
116
|
-
|
|
120
|
+
|
|
121
|
+
syncLayoutActorRef: ActorRef<Snapshot<unknown>, SyncLayoutEvents, AnyEventObject>
|
|
117
122
|
|
|
118
123
|
// If Dynamic View
|
|
119
124
|
activeWalkthrough: null | {
|
|
@@ -122,16 +127,6 @@ export interface DiagramContext extends Input {
|
|
|
122
127
|
}
|
|
123
128
|
}
|
|
124
129
|
|
|
125
|
-
export namespace DiagramContext {
|
|
126
|
-
export function findDiagramNode(ctx: DiagramContext, xynodeId: string) {
|
|
127
|
-
return ctx.view.nodes.find(n => n.id === xynodeId) ?? null
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export function findDiagramEdge(ctx: DiagramContext, xyedgeId: string) {
|
|
131
|
-
return ctx.view.edges.find(e => e.id === xyedgeId) ?? null
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
130
|
export type Events =
|
|
136
131
|
| HotKeyEvent
|
|
137
132
|
| { type: 'xyflow.init'; instance: ReactFlowInstance<Types.Node, Types.Edge> }
|
|
@@ -153,7 +148,7 @@ export type Events =
|
|
|
153
148
|
| { type: 'open.elementDetails'; fqn: Fqn; fromNode?: NodeId | undefined }
|
|
154
149
|
| { type: 'open.relationshipDetails'; edgeId: EdgeId }
|
|
155
150
|
| { type: 'open.relationshipsBrowser'; fqn: Fqn }
|
|
156
|
-
| { type: 'close.overlay' }
|
|
151
|
+
// | { type: 'close.overlay' }
|
|
157
152
|
| { type: 'navigate.to'; viewId: ViewId; fromNode?: NodeId | undefined }
|
|
158
153
|
| { type: 'navigate.back' }
|
|
159
154
|
| { type: 'navigate.forward' }
|
|
@@ -165,27 +160,26 @@ export type Events =
|
|
|
165
160
|
| { type: 'walkthrough.start'; stepId?: StepEdgeId }
|
|
166
161
|
| { type: 'walkthrough.step'; direction: 'next' | 'previous' }
|
|
167
162
|
| { type: 'walkthrough.end' }
|
|
163
|
+
| { type: 'toggle.feature'; feature: FeatureName; forceValue?: boolean }
|
|
168
164
|
|
|
169
|
-
export type ActionArg = { context:
|
|
165
|
+
export type ActionArg = { context: Context; event: Events }
|
|
170
166
|
|
|
171
167
|
// TODO: naming convention for actors
|
|
172
168
|
export const diagramMachine = setup({
|
|
173
169
|
types: {
|
|
174
|
-
context: {} as
|
|
170
|
+
context: {} as Context,
|
|
175
171
|
input: {} as Input,
|
|
176
172
|
children: {} as {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
relationshipsBrowser: 'relationshipsBrowserActor'
|
|
173
|
+
syncLayout: 'syncManualLayoutActorLogic'
|
|
174
|
+
hotkey: 'hotkeyActorLogic'
|
|
175
|
+
overlays: 'overlaysActorLogic'
|
|
181
176
|
},
|
|
182
177
|
events: {} as Events,
|
|
183
178
|
},
|
|
184
179
|
actors: {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
relationshipDetailsActor,
|
|
180
|
+
syncManualLayoutActorLogic,
|
|
181
|
+
hotkeyActorLogic,
|
|
182
|
+
overlaysActorLogic,
|
|
189
183
|
},
|
|
190
184
|
guards: {
|
|
191
185
|
'enabled: FitView': ({ context }) => context.features.enableFitView,
|
|
@@ -306,12 +300,49 @@ export const diagramMachine = setup({
|
|
|
306
300
|
})
|
|
307
301
|
})
|
|
308
302
|
},
|
|
303
|
+
|
|
304
|
+
'updateFeatures': enqueueActions(({ enqueue, system, event }) => {
|
|
305
|
+
assertEvent(event, 'update.features')
|
|
306
|
+
const { features } = event
|
|
307
|
+
enqueue.assign({
|
|
308
|
+
features: { ...features },
|
|
309
|
+
})
|
|
310
|
+
|
|
311
|
+
const enableOverlays = features.enableElementDetails || features.enableRelationshipDetails ||
|
|
312
|
+
features.enableRelationshipBrowser
|
|
313
|
+
const hasRunning = typedSystem(system).overlaysActorRef
|
|
314
|
+
if (enableOverlays && !hasRunning) {
|
|
315
|
+
enqueue.spawnChild('overlaysActorLogic', { id: 'overlays', systemId: 'overlays' })
|
|
316
|
+
return
|
|
317
|
+
}
|
|
318
|
+
if (!enableOverlays && hasRunning) {
|
|
319
|
+
enqueue.stopChild('overlays')
|
|
320
|
+
}
|
|
321
|
+
}),
|
|
322
|
+
|
|
323
|
+
'closeAllOverlays': enqueueActions(({ system, enqueue }) => {
|
|
324
|
+
const overlays = typedSystem(system).overlaysActorRef
|
|
325
|
+
if (overlays) {
|
|
326
|
+
enqueue.sendTo(overlays, { type: 'close.all' })
|
|
327
|
+
}
|
|
328
|
+
}),
|
|
329
|
+
|
|
330
|
+
'stopSyncLayout': enqueueActions(({ context, enqueue }) => {
|
|
331
|
+
enqueue.sendTo(context.syncLayoutActorRef, { type: 'stop' })
|
|
332
|
+
enqueue.stopChild(context.syncLayoutActorRef)
|
|
333
|
+
enqueue.assign({
|
|
334
|
+
syncLayoutActorRef: null as any,
|
|
335
|
+
})
|
|
336
|
+
}),
|
|
309
337
|
},
|
|
310
338
|
}).createMachine({
|
|
311
339
|
initial: 'initializing',
|
|
312
340
|
context: ({ input, self, spawn }) => ({
|
|
313
341
|
...input,
|
|
314
342
|
features: { ...AllDisabled },
|
|
343
|
+
toggledFeatures: {
|
|
344
|
+
enableReadOnly: true,
|
|
345
|
+
},
|
|
315
346
|
initialized: false,
|
|
316
347
|
viewportChangedManually: false,
|
|
317
348
|
lastOnNavigate: null,
|
|
@@ -325,7 +356,7 @@ export const diagramMachine = setup({
|
|
|
325
356
|
},
|
|
326
357
|
viewport: { x: 0, y: 0, zoom: 1 },
|
|
327
358
|
xyflow: null,
|
|
328
|
-
syncLayoutActorRef: spawn('
|
|
359
|
+
syncLayoutActorRef: spawn('syncManualLayoutActorLogic', {
|
|
329
360
|
id: 'syncLayout',
|
|
330
361
|
input: { parent: self, viewId: input.view.id },
|
|
331
362
|
}),
|
|
@@ -427,12 +458,25 @@ export const diagramMachine = setup({
|
|
|
427
458
|
...focusNodesEdges(s),
|
|
428
459
|
viewportBeforeFocus: { ...s.context.viewport },
|
|
429
460
|
})),
|
|
430
|
-
spawnChild('
|
|
461
|
+
spawnChild('hotkeyActorLogic', { id: 'hotkey' }),
|
|
431
462
|
{
|
|
432
463
|
type: 'xyflow:fitDiagram',
|
|
433
464
|
params: focusedBounds,
|
|
434
465
|
},
|
|
435
466
|
],
|
|
467
|
+
exit: enqueueActions(({ enqueue, context }) => {
|
|
468
|
+
enqueue.stopChild('hotkey')
|
|
469
|
+
if (context.viewportBeforeFocus) {
|
|
470
|
+
enqueue({ type: 'xyflow:setViewport', params: { viewport: context.viewportBeforeFocus } })
|
|
471
|
+
} else {
|
|
472
|
+
enqueue({ type: 'xyflow:fitDiagram' })
|
|
473
|
+
}
|
|
474
|
+
enqueue.assign((s) => ({
|
|
475
|
+
...unfocusNodesEdges(s),
|
|
476
|
+
viewportBeforeFocus: null,
|
|
477
|
+
focusedNode: null,
|
|
478
|
+
}))
|
|
479
|
+
}),
|
|
436
480
|
on: {
|
|
437
481
|
'xyflow.nodeClick': [
|
|
438
482
|
{
|
|
@@ -487,143 +531,6 @@ export const diagramMachine = setup({
|
|
|
487
531
|
}),
|
|
488
532
|
},
|
|
489
533
|
},
|
|
490
|
-
exit: [
|
|
491
|
-
stopChild('hotkey'),
|
|
492
|
-
enqueueActions(({ enqueue, context }) => {
|
|
493
|
-
if (context.viewportBeforeFocus) {
|
|
494
|
-
enqueue({ type: 'xyflow:setViewport', params: { viewport: context.viewportBeforeFocus } })
|
|
495
|
-
} else {
|
|
496
|
-
enqueue({ type: 'xyflow:fitDiagram' })
|
|
497
|
-
}
|
|
498
|
-
enqueue.assign((s) => ({
|
|
499
|
-
...unfocusNodesEdges(s),
|
|
500
|
-
viewportBeforeFocus: null,
|
|
501
|
-
focusedNode: null,
|
|
502
|
-
}))
|
|
503
|
-
}),
|
|
504
|
-
],
|
|
505
|
-
},
|
|
506
|
-
overlay: {
|
|
507
|
-
entry: spawnChild('hotkeyActor', { id: 'hotkey' }),
|
|
508
|
-
initial: 'hole',
|
|
509
|
-
states: {
|
|
510
|
-
hole: {
|
|
511
|
-
target: '#idle',
|
|
512
|
-
},
|
|
513
|
-
elementDetails: {
|
|
514
|
-
guard: ({ context }: { context: DiagramContext }) => context.activeElementDetails !== null,
|
|
515
|
-
entry: assign({
|
|
516
|
-
activeElementDetails: ({ context }) => {
|
|
517
|
-
const fqn = context.activeElementDetails!.fqn
|
|
518
|
-
const fromNode = context.activeElementDetails!.fromNode
|
|
519
|
-
if (fromNode) {
|
|
520
|
-
const internalNode = nonNullable(
|
|
521
|
-
context.xystore.getState().nodeLookup.get(fromNode),
|
|
522
|
-
'XY Internal Node not found',
|
|
523
|
-
)
|
|
524
|
-
const nodeRect = nodeToRect(internalNode)
|
|
525
|
-
const zoom = context.xyflow!.getZoom()
|
|
526
|
-
|
|
527
|
-
const nodeRectScreen = {
|
|
528
|
-
...context.xyflow!.flowToScreenPosition(nodeRect),
|
|
529
|
-
width: nodeRect.width * zoom,
|
|
530
|
-
height: nodeRect.height * zoom,
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
return { fqn, fromNode, nodeRect, nodeRectScreen }
|
|
534
|
-
} else {
|
|
535
|
-
return { fqn, fromNode }
|
|
536
|
-
}
|
|
537
|
-
},
|
|
538
|
-
}),
|
|
539
|
-
on: {
|
|
540
|
-
// Catch event and do nothing
|
|
541
|
-
'open.elementDetails': {
|
|
542
|
-
actions: assign({
|
|
543
|
-
activeElementDetails: ({ event, context }) => ({
|
|
544
|
-
...context.activeElementDetails,
|
|
545
|
-
fqn: event.fqn,
|
|
546
|
-
fromNode: context.activeElementDetails?.fromNode ?? null,
|
|
547
|
-
}),
|
|
548
|
-
}),
|
|
549
|
-
},
|
|
550
|
-
'close.overlay': {
|
|
551
|
-
target: '#idle',
|
|
552
|
-
},
|
|
553
|
-
'key.esc': {
|
|
554
|
-
target: '#idle',
|
|
555
|
-
},
|
|
556
|
-
},
|
|
557
|
-
exit: assign({
|
|
558
|
-
activeElementDetails: null,
|
|
559
|
-
}),
|
|
560
|
-
},
|
|
561
|
-
relationshipsBrowser: {
|
|
562
|
-
invoke: {
|
|
563
|
-
id: 'relationshipsBrowser',
|
|
564
|
-
src: 'relationshipsBrowserActor',
|
|
565
|
-
input: ({ context, event }) => {
|
|
566
|
-
assertEvent(event, 'open.relationshipsBrowser')
|
|
567
|
-
return {
|
|
568
|
-
subject: event.fqn,
|
|
569
|
-
scope: context.view,
|
|
570
|
-
}
|
|
571
|
-
},
|
|
572
|
-
onDone: {
|
|
573
|
-
target: '#idle',
|
|
574
|
-
},
|
|
575
|
-
},
|
|
576
|
-
on: {
|
|
577
|
-
'open.relationshipsBrowser': {
|
|
578
|
-
actions: sendTo('relationshipsBrowser', ({ event }) => ({
|
|
579
|
-
type: 'navigate.to',
|
|
580
|
-
subject: event.fqn,
|
|
581
|
-
})),
|
|
582
|
-
},
|
|
583
|
-
'close.overlay': {
|
|
584
|
-
actions: sendTo('relationshipsBrowser', { type: 'close' }),
|
|
585
|
-
},
|
|
586
|
-
'key.esc': {
|
|
587
|
-
actions: sendTo('relationshipsBrowser', { type: 'close' }),
|
|
588
|
-
},
|
|
589
|
-
},
|
|
590
|
-
},
|
|
591
|
-
relationshipDetails: {
|
|
592
|
-
invoke: {
|
|
593
|
-
id: 'relationshipDetails',
|
|
594
|
-
src: 'relationshipDetailsActor',
|
|
595
|
-
input: ({ event, context }) => {
|
|
596
|
-
assertEvent(event, 'open.relationshipDetails')
|
|
597
|
-
return {
|
|
598
|
-
edgeId: event.edgeId,
|
|
599
|
-
view: context.view,
|
|
600
|
-
}
|
|
601
|
-
},
|
|
602
|
-
onDone: {
|
|
603
|
-
target: '#idle',
|
|
604
|
-
},
|
|
605
|
-
},
|
|
606
|
-
on: {
|
|
607
|
-
'close.overlay': {
|
|
608
|
-
actions: sendTo('relationshipDetails', { type: 'close' }),
|
|
609
|
-
},
|
|
610
|
-
'key.esc': {
|
|
611
|
-
actions: sendTo('relationshipDetails', { type: 'close' }),
|
|
612
|
-
},
|
|
613
|
-
},
|
|
614
|
-
},
|
|
615
|
-
},
|
|
616
|
-
on: {
|
|
617
|
-
// We received another view, close overlay and process event again
|
|
618
|
-
'update.view': {
|
|
619
|
-
guard: 'is another view',
|
|
620
|
-
actions: raise(({ event }) => event, { delay: 50 }),
|
|
621
|
-
target: '#idle',
|
|
622
|
-
},
|
|
623
|
-
},
|
|
624
|
-
exit: [
|
|
625
|
-
stopChild('hotkey'),
|
|
626
|
-
],
|
|
627
534
|
},
|
|
628
535
|
// Navigating to another view (after `navigateTo` event)
|
|
629
536
|
navigating: {
|
|
@@ -632,8 +539,8 @@ export const diagramMachine = setup({
|
|
|
632
539
|
states: {
|
|
633
540
|
pending: {
|
|
634
541
|
entry: enqueueActions(({ enqueue }) => {
|
|
635
|
-
enqueue
|
|
636
|
-
enqueue
|
|
542
|
+
enqueue('closeAllOverlays')
|
|
543
|
+
enqueue('stopSyncLayout')
|
|
637
544
|
enqueue({
|
|
638
545
|
type: 'trigger:NavigateTo',
|
|
639
546
|
params: ({ context }) => ({
|
|
@@ -680,13 +587,17 @@ export const diagramMachine = setup({
|
|
|
680
587
|
},
|
|
681
588
|
exit: assign({
|
|
682
589
|
syncLayoutActorRef: ({ self, context, spawn }) =>
|
|
683
|
-
spawn('
|
|
590
|
+
spawn('syncManualLayoutActorLogic', {
|
|
591
|
+
id: 'syncLayout',
|
|
592
|
+
systemId: 'syncLayout',
|
|
593
|
+
input: { parent: self, viewId: context.view.id },
|
|
594
|
+
}),
|
|
684
595
|
lastOnNavigate: null,
|
|
685
596
|
}),
|
|
686
597
|
},
|
|
687
598
|
walkthrough: {
|
|
688
599
|
entry: [
|
|
689
|
-
spawnChild('hotkeyActor', { id: 'hotkey' }),
|
|
600
|
+
// spawnChild('hotkeyActor', { id: 'hotkey' }),
|
|
690
601
|
assign({
|
|
691
602
|
viewportBeforeFocus: ({ context }) => context.viewport,
|
|
692
603
|
activeWalkthrough: ({ context, event }) => {
|
|
@@ -819,12 +730,16 @@ export const diagramMachine = setup({
|
|
|
819
730
|
const isAnotherView = check('is another view')
|
|
820
731
|
if (isAnotherView) {
|
|
821
732
|
const viewId = event.view.id
|
|
822
|
-
|
|
823
|
-
enqueue
|
|
733
|
+
|
|
734
|
+
enqueue('closeAllOverlays')
|
|
735
|
+
enqueue('stopSyncLayout')
|
|
824
736
|
enqueue.assign({
|
|
825
737
|
focusedNode: null,
|
|
826
738
|
syncLayoutActorRef: ({ self, spawn }) =>
|
|
827
|
-
spawn('
|
|
739
|
+
spawn('syncManualLayoutActorLogic', {
|
|
740
|
+
id: 'syncLayout',
|
|
741
|
+
input: { parent: self, viewId },
|
|
742
|
+
}),
|
|
828
743
|
})
|
|
829
744
|
const { fromNode, toNode } = findCorrespondingNode(context, event)
|
|
830
745
|
if (fromNode && toNode) {
|
|
@@ -863,9 +778,7 @@ export const diagramMachine = setup({
|
|
|
863
778
|
actions: assign(({ event }) => ({ ...event.inputs })),
|
|
864
779
|
},
|
|
865
780
|
'update.features': {
|
|
866
|
-
actions:
|
|
867
|
-
features: ({ event }) => event.features,
|
|
868
|
-
}),
|
|
781
|
+
actions: 'updateFeatures',
|
|
869
782
|
},
|
|
870
783
|
'update.nodeData': {
|
|
871
784
|
actions: assign(updateNodeData),
|
|
@@ -888,28 +801,55 @@ export const diagramMachine = setup({
|
|
|
888
801
|
],
|
|
889
802
|
},
|
|
890
803
|
'xyflow.resized': {
|
|
891
|
-
guard: ({ context }: { context:
|
|
892
|
-
context.features.enableFitView && !context.viewportChangedManually,
|
|
804
|
+
guard: ({ context }: { context: Context }) => context.features.enableFitView && !context.viewportChangedManually,
|
|
893
805
|
actions: [
|
|
894
806
|
cancel('fitDiagram'),
|
|
895
807
|
raise({ type: 'fitDiagram' }, { id: 'fitDiagram', delay: 200 }),
|
|
896
808
|
],
|
|
897
809
|
},
|
|
898
810
|
'open.elementDetails': {
|
|
899
|
-
actions:
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
811
|
+
actions: enqueueActions(({ context, enqueue, system, event }) => {
|
|
812
|
+
let initiatedFrom = null as null | {
|
|
813
|
+
node: NodeId
|
|
814
|
+
clientRect: Rect
|
|
815
|
+
}
|
|
816
|
+
const fromNodeId = event.fromNode ?? context.view.nodes.find(n => DiagramNode.modelRef(n) === event.fqn)?.id
|
|
817
|
+
const internalNode = fromNodeId ? context.xystore.getState().nodeLookup.get(fromNodeId) : null
|
|
818
|
+
if (fromNodeId && internalNode) {
|
|
819
|
+
const nodeRect = nodeToRect(internalNode)
|
|
820
|
+
const zoom = context.xyflow!.getZoom()
|
|
821
|
+
|
|
822
|
+
const clientRect = {
|
|
823
|
+
...context.xyflow!.flowToScreenPosition(nodeRect),
|
|
824
|
+
width: nodeRect.width * zoom,
|
|
825
|
+
height: nodeRect.height * zoom,
|
|
826
|
+
}
|
|
827
|
+
initiatedFrom = {
|
|
828
|
+
node: fromNodeId,
|
|
829
|
+
clientRect,
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
enqueue.sendTo(typedSystem(system).overlaysActorRef!, {
|
|
833
|
+
type: 'open.elementDetails' as const,
|
|
834
|
+
subject: event.fqn,
|
|
835
|
+
currentView: context.view,
|
|
836
|
+
...(initiatedFrom && { initiatedFrom }),
|
|
837
|
+
})
|
|
905
838
|
}),
|
|
906
|
-
target: '.overlay.elementDetails',
|
|
907
|
-
},
|
|
908
|
-
'open.relationshipDetails': {
|
|
909
|
-
target: '.overlay.relationshipDetails',
|
|
910
839
|
},
|
|
911
840
|
'open.relationshipsBrowser': {
|
|
912
|
-
|
|
841
|
+
actions: sendTo(({ system }) => typedSystem(system).overlaysActorRef!, ({ context, event }) => ({
|
|
842
|
+
type: 'open.relationshipsBrowser',
|
|
843
|
+
subject: event.fqn,
|
|
844
|
+
scope: context.view,
|
|
845
|
+
})),
|
|
846
|
+
},
|
|
847
|
+
'open.relationshipDetails': {
|
|
848
|
+
actions: sendTo(({ system }) => typedSystem(system).overlaysActorRef!, ({ context, event }) => ({
|
|
849
|
+
type: 'open.relationshipDetails',
|
|
850
|
+
view: context.view,
|
|
851
|
+
edgeId: event.edgeId,
|
|
852
|
+
})),
|
|
913
853
|
},
|
|
914
854
|
'open.source': {
|
|
915
855
|
actions: {
|
|
@@ -921,9 +861,18 @@ export const diagramMachine = setup({
|
|
|
921
861
|
guard: 'is dynamic view',
|
|
922
862
|
target: '.walkthrough',
|
|
923
863
|
},
|
|
864
|
+
'toggle.feature': {
|
|
865
|
+
actions: assign({
|
|
866
|
+
toggledFeatures: ({ context, event }) => ({
|
|
867
|
+
...context.toggledFeatures,
|
|
868
|
+
[`enable${event.feature}`]: event.forceValue ??
|
|
869
|
+
!(context.toggledFeatures[`enable${event.feature}`] ?? context.features[`enable${event.feature}`]),
|
|
870
|
+
}),
|
|
871
|
+
}),
|
|
872
|
+
},
|
|
924
873
|
},
|
|
925
874
|
exit: [
|
|
926
|
-
|
|
875
|
+
'stopSyncLayout',
|
|
927
876
|
stopChild('hotkey'),
|
|
928
877
|
assign({
|
|
929
878
|
xyflow: null,
|
|
@@ -935,7 +884,7 @@ export const diagramMachine = setup({
|
|
|
935
884
|
})
|
|
936
885
|
|
|
937
886
|
const nodeRef = (node: DiagramNode) => DiagramNode.modelRef(node) ?? DiagramNode.deploymentRef(node)
|
|
938
|
-
function findCorrespondingNode(context:
|
|
887
|
+
function findCorrespondingNode(context: Context, event: { view: DiagramView }) {
|
|
939
888
|
const fromNodeId = context.lastOnNavigate?.fromNode
|
|
940
889
|
const fromNode = fromNodeId && context.view.nodes.find(n => n.id === fromNodeId)
|
|
941
890
|
const fromRef = fromNode && nodeRef(fromNode)
|
|
@@ -943,6 +892,6 @@ function findCorrespondingNode(context: DiagramContext, event: { view: DiagramVi
|
|
|
943
892
|
return { fromNode, toNode }
|
|
944
893
|
}
|
|
945
894
|
|
|
946
|
-
export type
|
|
947
|
-
export type MachineSnapshot = SnapshotFrom<Machine>
|
|
948
|
-
export type LikeC4ViewActorRef = ActorRefFromLogic<Machine>
|
|
895
|
+
export type DiagramMachineLogic = ActorLogicFrom<typeof diagramMachine>
|
|
896
|
+
// export type MachineSnapshot = SnapshotFrom<Machine>
|
|
897
|
+
// export type LikeC4ViewActorRef = ActorRefFromLogic<Machine>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { getHotkeyHandler } from '@mantine/hooks'
|
|
2
|
+
import { type AnyEventObject, type NonReducibleUnknown, fromCallback } from 'xstate'
|
|
3
|
+
|
|
4
|
+
export type HotKeyEvent = { type: 'key.esc' | `key.arrow.${'left' | 'right'}` }
|
|
5
|
+
|
|
6
|
+
export const hotkeyActorLogic = fromCallback<AnyEventObject, NonReducibleUnknown, HotKeyEvent>(({ sendBack }: {
|
|
7
|
+
sendBack: (event: HotKeyEvent) => void
|
|
8
|
+
}) => {
|
|
9
|
+
const escHandler = getHotkeyHandler([
|
|
10
|
+
['Escape', () => sendBack({ type: 'key.esc' }), {
|
|
11
|
+
preventDefault: true,
|
|
12
|
+
}],
|
|
13
|
+
])
|
|
14
|
+
|
|
15
|
+
const arrowshandler = getHotkeyHandler([
|
|
16
|
+
['ArrowLeft', () => sendBack({ type: 'key.arrow.left' }), {
|
|
17
|
+
preventDefault: true,
|
|
18
|
+
}],
|
|
19
|
+
['ArrowRight', () => sendBack({ type: 'key.arrow.right' }), {
|
|
20
|
+
preventDefault: true,
|
|
21
|
+
}],
|
|
22
|
+
])
|
|
23
|
+
document.body.addEventListener('keydown', escHandler)
|
|
24
|
+
document.body.addEventListener('keydown', arrowshandler, { capture: true })
|
|
25
|
+
return () => {
|
|
26
|
+
document.body.removeEventListener('keydown', escHandler)
|
|
27
|
+
document.body.removeEventListener('keydown', arrowshandler, { capture: true })
|
|
28
|
+
}
|
|
29
|
+
})
|