@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.
- 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.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 +6587 -5969
- package/dist/hooks/useDiagram.js +26 -14
- package/dist/index.js +1 -1
- package/dist/likec4diagram/DiagramUI.js +12 -5
- package/dist/likec4diagram/XYFlow.js +3 -4
- 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 +3 -13
- package/dist/likec4diagram/ui/controls/NavigationButtons.js +1 -2
- package/dist/likec4diagram/ui/controls/ToggleReadonly.js +1 -2
- 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} +105 -194
- 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 +3 -5
- 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 -24
- 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 +8 -21
- 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 +42 -15
- package/src/likec4diagram/DiagramUI.tsx +14 -11
- package/src/likec4diagram/XYFlow.tsx +4 -5
- 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 +2 -4
- package/src/likec4diagram/ui/controls/NavigationButtons.tsx +1 -2
- package/src/likec4diagram/ui/controls/ToggleReadonly.tsx +2 -3
- 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} +130 -205
- package/src/state/hotkeyActor.ts +29 -0
- package/src/state/inspector.ts +5 -0
- package/src/{likec4diagram/state → state}/syncManualLayoutActor.ts +8 -12
- 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 -82
- package/dist/likec4diagram/state/actorContext.d.ts +0 -52075
- 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 -11025
- 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 -92
- 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
|
|
|
@@ -88,7 +88,7 @@ export interface Input {
|
|
|
88
88
|
|
|
89
89
|
type ToggledFeatures = Partial<EnabledFeatures>
|
|
90
90
|
|
|
91
|
-
export interface
|
|
91
|
+
export interface Context extends Input {
|
|
92
92
|
features: EnabledFeatures
|
|
93
93
|
// This is used to override features from props
|
|
94
94
|
toggledFeatures: ToggledFeatures
|
|
@@ -117,7 +117,8 @@ export interface DiagramContext extends Input {
|
|
|
117
117
|
}
|
|
118
118
|
viewportBeforeFocus: null | Viewport
|
|
119
119
|
xyflow: ReactFlowInstance<Types.Node, Types.Edge> | null
|
|
120
|
-
|
|
120
|
+
|
|
121
|
+
syncLayoutActorRef: ActorRef<Snapshot<unknown>, SyncLayoutEvents, AnyEventObject>
|
|
121
122
|
|
|
122
123
|
// If Dynamic View
|
|
123
124
|
activeWalkthrough: null | {
|
|
@@ -126,16 +127,6 @@ export interface DiagramContext extends Input {
|
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
|
|
129
|
-
export namespace DiagramContext {
|
|
130
|
-
export function findDiagramNode(ctx: DiagramContext, xynodeId: string) {
|
|
131
|
-
return ctx.view.nodes.find(n => n.id === xynodeId) ?? null
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export function findDiagramEdge(ctx: DiagramContext, xyedgeId: string) {
|
|
135
|
-
return ctx.view.edges.find(e => e.id === xyedgeId) ?? null
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
130
|
export type Events =
|
|
140
131
|
| HotKeyEvent
|
|
141
132
|
| { type: 'xyflow.init'; instance: ReactFlowInstance<Types.Node, Types.Edge> }
|
|
@@ -157,7 +148,7 @@ export type Events =
|
|
|
157
148
|
| { type: 'open.elementDetails'; fqn: Fqn; fromNode?: NodeId | undefined }
|
|
158
149
|
| { type: 'open.relationshipDetails'; edgeId: EdgeId }
|
|
159
150
|
| { type: 'open.relationshipsBrowser'; fqn: Fqn }
|
|
160
|
-
| { type: 'close.overlay' }
|
|
151
|
+
// | { type: 'close.overlay' }
|
|
161
152
|
| { type: 'navigate.to'; viewId: ViewId; fromNode?: NodeId | undefined }
|
|
162
153
|
| { type: 'navigate.back' }
|
|
163
154
|
| { type: 'navigate.forward' }
|
|
@@ -171,26 +162,24 @@ export type Events =
|
|
|
171
162
|
| { type: 'walkthrough.end' }
|
|
172
163
|
| { type: 'toggle.feature'; feature: FeatureName; forceValue?: boolean }
|
|
173
164
|
|
|
174
|
-
export type ActionArg = { context:
|
|
165
|
+
export type ActionArg = { context: Context; event: Events }
|
|
175
166
|
|
|
176
167
|
// TODO: naming convention for actors
|
|
177
168
|
export const diagramMachine = setup({
|
|
178
169
|
types: {
|
|
179
|
-
context: {} as
|
|
170
|
+
context: {} as Context,
|
|
180
171
|
input: {} as Input,
|
|
181
172
|
children: {} as {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
relationshipsBrowser: 'relationshipsBrowserActor'
|
|
173
|
+
syncLayout: 'syncManualLayoutActorLogic'
|
|
174
|
+
hotkey: 'hotkeyActorLogic'
|
|
175
|
+
overlays: 'overlaysActorLogic'
|
|
186
176
|
},
|
|
187
177
|
events: {} as Events,
|
|
188
178
|
},
|
|
189
179
|
actors: {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
relationshipDetailsActor,
|
|
180
|
+
syncManualLayoutActorLogic,
|
|
181
|
+
hotkeyActorLogic,
|
|
182
|
+
overlaysActorLogic,
|
|
194
183
|
},
|
|
195
184
|
guards: {
|
|
196
185
|
'enabled: FitView': ({ context }) => context.features.enableFitView,
|
|
@@ -312,14 +301,39 @@ export const diagramMachine = setup({
|
|
|
312
301
|
})
|
|
313
302
|
},
|
|
314
303
|
|
|
315
|
-
'updateFeatures':
|
|
304
|
+
'updateFeatures': enqueueActions(({ enqueue, system, event }) => {
|
|
316
305
|
assertEvent(event, 'update.features')
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
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')
|
|
321
320
|
}
|
|
322
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
|
+
}),
|
|
323
337
|
},
|
|
324
338
|
}).createMachine({
|
|
325
339
|
initial: 'initializing',
|
|
@@ -342,7 +356,7 @@ export const diagramMachine = setup({
|
|
|
342
356
|
},
|
|
343
357
|
viewport: { x: 0, y: 0, zoom: 1 },
|
|
344
358
|
xyflow: null,
|
|
345
|
-
syncLayoutActorRef: spawn('
|
|
359
|
+
syncLayoutActorRef: spawn('syncManualLayoutActorLogic', {
|
|
346
360
|
id: 'syncLayout',
|
|
347
361
|
input: { parent: self, viewId: input.view.id },
|
|
348
362
|
}),
|
|
@@ -444,12 +458,25 @@ export const diagramMachine = setup({
|
|
|
444
458
|
...focusNodesEdges(s),
|
|
445
459
|
viewportBeforeFocus: { ...s.context.viewport },
|
|
446
460
|
})),
|
|
447
|
-
spawnChild('
|
|
461
|
+
spawnChild('hotkeyActorLogic', { id: 'hotkey' }),
|
|
448
462
|
{
|
|
449
463
|
type: 'xyflow:fitDiagram',
|
|
450
464
|
params: focusedBounds,
|
|
451
465
|
},
|
|
452
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
|
+
}),
|
|
453
480
|
on: {
|
|
454
481
|
'xyflow.nodeClick': [
|
|
455
482
|
{
|
|
@@ -504,143 +531,6 @@ export const diagramMachine = setup({
|
|
|
504
531
|
}),
|
|
505
532
|
},
|
|
506
533
|
},
|
|
507
|
-
exit: [
|
|
508
|
-
stopChild('hotkey'),
|
|
509
|
-
enqueueActions(({ enqueue, context }) => {
|
|
510
|
-
if (context.viewportBeforeFocus) {
|
|
511
|
-
enqueue({ type: 'xyflow:setViewport', params: { viewport: context.viewportBeforeFocus } })
|
|
512
|
-
} else {
|
|
513
|
-
enqueue({ type: 'xyflow:fitDiagram' })
|
|
514
|
-
}
|
|
515
|
-
enqueue.assign((s) => ({
|
|
516
|
-
...unfocusNodesEdges(s),
|
|
517
|
-
viewportBeforeFocus: null,
|
|
518
|
-
focusedNode: null,
|
|
519
|
-
}))
|
|
520
|
-
}),
|
|
521
|
-
],
|
|
522
|
-
},
|
|
523
|
-
overlay: {
|
|
524
|
-
entry: spawnChild('hotkeyActor', { id: 'hotkey' }),
|
|
525
|
-
initial: 'hole',
|
|
526
|
-
states: {
|
|
527
|
-
hole: {
|
|
528
|
-
target: '#idle',
|
|
529
|
-
},
|
|
530
|
-
elementDetails: {
|
|
531
|
-
guard: ({ context }: { context: DiagramContext }) => context.activeElementDetails !== null,
|
|
532
|
-
entry: assign({
|
|
533
|
-
activeElementDetails: ({ context }) => {
|
|
534
|
-
const fqn = context.activeElementDetails!.fqn
|
|
535
|
-
const fromNode = context.activeElementDetails!.fromNode
|
|
536
|
-
if (fromNode) {
|
|
537
|
-
const internalNode = nonNullable(
|
|
538
|
-
context.xystore.getState().nodeLookup.get(fromNode),
|
|
539
|
-
'XY Internal Node not found',
|
|
540
|
-
)
|
|
541
|
-
const nodeRect = nodeToRect(internalNode)
|
|
542
|
-
const zoom = context.xyflow!.getZoom()
|
|
543
|
-
|
|
544
|
-
const nodeRectScreen = {
|
|
545
|
-
...context.xyflow!.flowToScreenPosition(nodeRect),
|
|
546
|
-
width: nodeRect.width * zoom,
|
|
547
|
-
height: nodeRect.height * zoom,
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
return { fqn, fromNode, nodeRect, nodeRectScreen }
|
|
551
|
-
} else {
|
|
552
|
-
return { fqn, fromNode }
|
|
553
|
-
}
|
|
554
|
-
},
|
|
555
|
-
}),
|
|
556
|
-
on: {
|
|
557
|
-
// Catch event and do nothing
|
|
558
|
-
'open.elementDetails': {
|
|
559
|
-
actions: assign({
|
|
560
|
-
activeElementDetails: ({ event, context }) => ({
|
|
561
|
-
...context.activeElementDetails,
|
|
562
|
-
fqn: event.fqn,
|
|
563
|
-
fromNode: context.activeElementDetails?.fromNode ?? null,
|
|
564
|
-
}),
|
|
565
|
-
}),
|
|
566
|
-
},
|
|
567
|
-
'close.overlay': {
|
|
568
|
-
target: '#idle',
|
|
569
|
-
},
|
|
570
|
-
'key.esc': {
|
|
571
|
-
target: '#idle',
|
|
572
|
-
},
|
|
573
|
-
},
|
|
574
|
-
exit: assign({
|
|
575
|
-
activeElementDetails: null,
|
|
576
|
-
}),
|
|
577
|
-
},
|
|
578
|
-
relationshipsBrowser: {
|
|
579
|
-
invoke: {
|
|
580
|
-
id: 'relationshipsBrowser',
|
|
581
|
-
src: 'relationshipsBrowserActor',
|
|
582
|
-
input: ({ context, event }) => {
|
|
583
|
-
assertEvent(event, 'open.relationshipsBrowser')
|
|
584
|
-
return {
|
|
585
|
-
subject: event.fqn,
|
|
586
|
-
scope: context.view,
|
|
587
|
-
}
|
|
588
|
-
},
|
|
589
|
-
onDone: {
|
|
590
|
-
target: '#idle',
|
|
591
|
-
},
|
|
592
|
-
},
|
|
593
|
-
on: {
|
|
594
|
-
'open.relationshipsBrowser': {
|
|
595
|
-
actions: sendTo('relationshipsBrowser', ({ event }) => ({
|
|
596
|
-
type: 'navigate.to',
|
|
597
|
-
subject: event.fqn,
|
|
598
|
-
})),
|
|
599
|
-
},
|
|
600
|
-
'close.overlay': {
|
|
601
|
-
actions: sendTo('relationshipsBrowser', { type: 'close' }),
|
|
602
|
-
},
|
|
603
|
-
'key.esc': {
|
|
604
|
-
actions: sendTo('relationshipsBrowser', { type: 'close' }),
|
|
605
|
-
},
|
|
606
|
-
},
|
|
607
|
-
},
|
|
608
|
-
relationshipDetails: {
|
|
609
|
-
invoke: {
|
|
610
|
-
id: 'relationshipDetails',
|
|
611
|
-
src: 'relationshipDetailsActor',
|
|
612
|
-
input: ({ event, context }) => {
|
|
613
|
-
assertEvent(event, 'open.relationshipDetails')
|
|
614
|
-
return {
|
|
615
|
-
edgeId: event.edgeId,
|
|
616
|
-
view: context.view,
|
|
617
|
-
}
|
|
618
|
-
},
|
|
619
|
-
onDone: {
|
|
620
|
-
target: '#idle',
|
|
621
|
-
},
|
|
622
|
-
},
|
|
623
|
-
on: {
|
|
624
|
-
'close.overlay': {
|
|
625
|
-
actions: sendTo('relationshipDetails', { type: 'close' }),
|
|
626
|
-
},
|
|
627
|
-
'key.esc': {
|
|
628
|
-
actions: sendTo('relationshipDetails', { type: 'close' }),
|
|
629
|
-
},
|
|
630
|
-
},
|
|
631
|
-
},
|
|
632
|
-
},
|
|
633
|
-
on: {
|
|
634
|
-
// We received another view, close overlay and process event again
|
|
635
|
-
'update.view': {
|
|
636
|
-
guard: 'is another view',
|
|
637
|
-
actions: raise(({ event }) => event, { delay: 50 }),
|
|
638
|
-
target: '#idle',
|
|
639
|
-
},
|
|
640
|
-
},
|
|
641
|
-
exit: [
|
|
642
|
-
stopChild('hotkey'),
|
|
643
|
-
],
|
|
644
534
|
},
|
|
645
535
|
// Navigating to another view (after `navigateTo` event)
|
|
646
536
|
navigating: {
|
|
@@ -649,8 +539,8 @@ export const diagramMachine = setup({
|
|
|
649
539
|
states: {
|
|
650
540
|
pending: {
|
|
651
541
|
entry: enqueueActions(({ enqueue }) => {
|
|
652
|
-
enqueue
|
|
653
|
-
enqueue
|
|
542
|
+
enqueue('closeAllOverlays')
|
|
543
|
+
enqueue('stopSyncLayout')
|
|
654
544
|
enqueue({
|
|
655
545
|
type: 'trigger:NavigateTo',
|
|
656
546
|
params: ({ context }) => ({
|
|
@@ -697,13 +587,17 @@ export const diagramMachine = setup({
|
|
|
697
587
|
},
|
|
698
588
|
exit: assign({
|
|
699
589
|
syncLayoutActorRef: ({ self, context, spawn }) =>
|
|
700
|
-
spawn('
|
|
590
|
+
spawn('syncManualLayoutActorLogic', {
|
|
591
|
+
id: 'syncLayout',
|
|
592
|
+
systemId: 'syncLayout',
|
|
593
|
+
input: { parent: self, viewId: context.view.id },
|
|
594
|
+
}),
|
|
701
595
|
lastOnNavigate: null,
|
|
702
596
|
}),
|
|
703
597
|
},
|
|
704
598
|
walkthrough: {
|
|
705
599
|
entry: [
|
|
706
|
-
spawnChild('hotkeyActor', { id: 'hotkey' }),
|
|
600
|
+
// spawnChild('hotkeyActor', { id: 'hotkey' }),
|
|
707
601
|
assign({
|
|
708
602
|
viewportBeforeFocus: ({ context }) => context.viewport,
|
|
709
603
|
activeWalkthrough: ({ context, event }) => {
|
|
@@ -836,12 +730,16 @@ export const diagramMachine = setup({
|
|
|
836
730
|
const isAnotherView = check('is another view')
|
|
837
731
|
if (isAnotherView) {
|
|
838
732
|
const viewId = event.view.id
|
|
839
|
-
|
|
840
|
-
enqueue
|
|
733
|
+
|
|
734
|
+
enqueue('closeAllOverlays')
|
|
735
|
+
enqueue('stopSyncLayout')
|
|
841
736
|
enqueue.assign({
|
|
842
737
|
focusedNode: null,
|
|
843
738
|
syncLayoutActorRef: ({ self, spawn }) =>
|
|
844
|
-
spawn('
|
|
739
|
+
spawn('syncManualLayoutActorLogic', {
|
|
740
|
+
id: 'syncLayout',
|
|
741
|
+
input: { parent: self, viewId },
|
|
742
|
+
}),
|
|
845
743
|
})
|
|
846
744
|
const { fromNode, toNode } = findCorrespondingNode(context, event)
|
|
847
745
|
if (fromNode && toNode) {
|
|
@@ -903,28 +801,55 @@ export const diagramMachine = setup({
|
|
|
903
801
|
],
|
|
904
802
|
},
|
|
905
803
|
'xyflow.resized': {
|
|
906
|
-
guard: ({ context }: { context:
|
|
907
|
-
context.features.enableFitView && !context.viewportChangedManually,
|
|
804
|
+
guard: ({ context }: { context: Context }) => context.features.enableFitView && !context.viewportChangedManually,
|
|
908
805
|
actions: [
|
|
909
806
|
cancel('fitDiagram'),
|
|
910
807
|
raise({ type: 'fitDiagram' }, { id: 'fitDiagram', delay: 200 }),
|
|
911
808
|
],
|
|
912
809
|
},
|
|
913
810
|
'open.elementDetails': {
|
|
914
|
-
actions:
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
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
|
+
})
|
|
920
838
|
}),
|
|
921
|
-
target: '.overlay.elementDetails',
|
|
922
|
-
},
|
|
923
|
-
'open.relationshipDetails': {
|
|
924
|
-
target: '.overlay.relationshipDetails',
|
|
925
839
|
},
|
|
926
840
|
'open.relationshipsBrowser': {
|
|
927
|
-
|
|
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
|
+
})),
|
|
928
853
|
},
|
|
929
854
|
'open.source': {
|
|
930
855
|
actions: {
|
|
@@ -947,7 +872,7 @@ export const diagramMachine = setup({
|
|
|
947
872
|
},
|
|
948
873
|
},
|
|
949
874
|
exit: [
|
|
950
|
-
|
|
875
|
+
'stopSyncLayout',
|
|
951
876
|
stopChild('hotkey'),
|
|
952
877
|
assign({
|
|
953
878
|
xyflow: null,
|
|
@@ -959,7 +884,7 @@ export const diagramMachine = setup({
|
|
|
959
884
|
})
|
|
960
885
|
|
|
961
886
|
const nodeRef = (node: DiagramNode) => DiagramNode.modelRef(node) ?? DiagramNode.deploymentRef(node)
|
|
962
|
-
function findCorrespondingNode(context:
|
|
887
|
+
function findCorrespondingNode(context: Context, event: { view: DiagramView }) {
|
|
963
888
|
const fromNodeId = context.lastOnNavigate?.fromNode
|
|
964
889
|
const fromNode = fromNodeId && context.view.nodes.find(n => n.id === fromNodeId)
|
|
965
890
|
const fromRef = fromNode && nodeRef(fromNode)
|
|
@@ -967,6 +892,6 @@ function findCorrespondingNode(context: DiagramContext, event: { view: DiagramVi
|
|
|
967
892
|
return { fromNode, toNode }
|
|
968
893
|
}
|
|
969
894
|
|
|
970
|
-
export type
|
|
971
|
-
export type MachineSnapshot = SnapshotFrom<Machine>
|
|
972
|
-
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
|
+
})
|