@darajs/ui-causal-graph-editor 1.0.0-a.1
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/LICENSE +201 -0
- package/dist/graph-viewer/causal-graph-editor.d.ts +44 -0
- package/dist/graph-viewer/causal-graph-editor.d.ts.map +1 -0
- package/dist/graph-viewer/causal-graph-editor.js +357 -0
- package/dist/graph-viewer/causal-graph-editor.js.map +1 -0
- package/dist/graph-viewer/utils/use-iterate-edges.d.ts +32 -0
- package/dist/graph-viewer/utils/use-iterate-edges.d.ts.map +1 -0
- package/dist/graph-viewer/utils/use-iterate-edges.js +34 -0
- package/dist/graph-viewer/utils/use-iterate-edges.js.map +1 -0
- package/dist/graph-viewer/utils/use-iterate-nodes.d.ts +32 -0
- package/dist/graph-viewer/utils/use-iterate-nodes.d.ts.map +1 -0
- package/dist/graph-viewer/utils/use-iterate-nodes.js +30 -0
- package/dist/graph-viewer/utils/use-iterate-nodes.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/jest-setup.d.ts +18 -0
- package/dist/jest-setup.d.ts.map +1 -0
- package/dist/jest-setup.js +18 -0
- package/dist/jest-setup.js.map +1 -0
- package/dist/node-hierarchy-builder/index.d.ts +19 -0
- package/dist/node-hierarchy-builder/index.d.ts.map +1 -0
- package/dist/node-hierarchy-builder/index.js +18 -0
- package/dist/node-hierarchy-builder/index.js.map +1 -0
- package/dist/node-hierarchy-builder/layer-divider.d.ts +15 -0
- package/dist/node-hierarchy-builder/layer-divider.d.ts.map +1 -0
- package/dist/node-hierarchy-builder/layer-divider.js +122 -0
- package/dist/node-hierarchy-builder/layer-divider.js.map +1 -0
- package/dist/node-hierarchy-builder/layer-label-editor.d.ts +24 -0
- package/dist/node-hierarchy-builder/layer-label-editor.d.ts.map +1 -0
- package/dist/node-hierarchy-builder/layer-label-editor.js +93 -0
- package/dist/node-hierarchy-builder/layer-label-editor.js.map +1 -0
- package/dist/node-hierarchy-builder/layer.d.ts +35 -0
- package/dist/node-hierarchy-builder/layer.d.ts.map +1 -0
- package/dist/node-hierarchy-builder/layer.js +114 -0
- package/dist/node-hierarchy-builder/layer.js.map +1 -0
- package/dist/node-hierarchy-builder/node-hierarchy-builder.d.ts +27 -0
- package/dist/node-hierarchy-builder/node-hierarchy-builder.d.ts.map +1 -0
- package/dist/node-hierarchy-builder/node-hierarchy-builder.js +190 -0
- package/dist/node-hierarchy-builder/node-hierarchy-builder.js.map +1 -0
- package/dist/node-hierarchy-builder/node.d.ts +21 -0
- package/dist/node-hierarchy-builder/node.d.ts.map +1 -0
- package/dist/node-hierarchy-builder/node.js +90 -0
- package/dist/node-hierarchy-builder/node.js.map +1 -0
- package/dist/node-hierarchy-builder/shared.d.ts +93 -0
- package/dist/node-hierarchy-builder/shared.d.ts.map +1 -0
- package/dist/node-hierarchy-builder/shared.js +88 -0
- package/dist/node-hierarchy-builder/shared.js.map +1 -0
- package/dist/shared/causal-graph-store.d.ts +107 -0
- package/dist/shared/causal-graph-store.d.ts.map +1 -0
- package/dist/shared/causal-graph-store.js +142 -0
- package/dist/shared/causal-graph-store.js.map +1 -0
- package/dist/shared/editor-overlay/buttons/add-node-button.d.ts +7 -0
- package/dist/shared/editor-overlay/buttons/add-node-button.d.ts.map +1 -0
- package/dist/shared/editor-overlay/buttons/add-node-button.js +31 -0
- package/dist/shared/editor-overlay/buttons/add-node-button.js.map +1 -0
- package/dist/shared/editor-overlay/buttons/center-graph-button.d.ts +7 -0
- package/dist/shared/editor-overlay/buttons/center-graph-button.d.ts.map +1 -0
- package/dist/shared/editor-overlay/buttons/center-graph-button.js +32 -0
- package/dist/shared/editor-overlay/buttons/center-graph-button.js.map +1 -0
- package/dist/shared/editor-overlay/buttons/drag-mode-button.d.ts +27 -0
- package/dist/shared/editor-overlay/buttons/drag-mode-button.d.ts.map +1 -0
- package/dist/shared/editor-overlay/buttons/drag-mode-button.js +35 -0
- package/dist/shared/editor-overlay/buttons/drag-mode-button.js.map +1 -0
- package/dist/shared/editor-overlay/buttons/index.d.ts +21 -0
- package/dist/shared/editor-overlay/buttons/index.d.ts.map +1 -0
- package/dist/shared/editor-overlay/buttons/index.js +21 -0
- package/dist/shared/editor-overlay/buttons/index.js.map +1 -0
- package/dist/shared/editor-overlay/buttons/recalculate-layout-button.d.ts +7 -0
- package/dist/shared/editor-overlay/buttons/recalculate-layout-button.d.ts.map +1 -0
- package/dist/shared/editor-overlay/buttons/recalculate-layout-button.js +28 -0
- package/dist/shared/editor-overlay/buttons/recalculate-layout-button.js.map +1 -0
- package/dist/shared/editor-overlay/floating-elements.d.ts +29 -0
- package/dist/shared/editor-overlay/floating-elements.d.ts.map +1 -0
- package/dist/shared/editor-overlay/floating-elements.js +17 -0
- package/dist/shared/editor-overlay/floating-elements.js.map +1 -0
- package/dist/shared/editor-overlay/index.d.ts +22 -0
- package/dist/shared/editor-overlay/index.d.ts.map +1 -0
- package/dist/shared/editor-overlay/index.js +22 -0
- package/dist/shared/editor-overlay/index.js.map +1 -0
- package/dist/shared/editor-overlay/legend/index.d.ts +19 -0
- package/dist/shared/editor-overlay/legend/index.d.ts.map +1 -0
- package/dist/shared/editor-overlay/legend/index.js +19 -0
- package/dist/shared/editor-overlay/legend/index.js.map +1 -0
- package/dist/shared/editor-overlay/legend/legend-data.d.ts +34 -0
- package/dist/shared/editor-overlay/legend/legend-data.d.ts.map +1 -0
- package/dist/shared/editor-overlay/legend/legend-data.js +41 -0
- package/dist/shared/editor-overlay/legend/legend-data.js.map +1 -0
- package/dist/shared/editor-overlay/legend/legend-list.d.ts +6 -0
- package/dist/shared/editor-overlay/legend/legend-list.d.ts.map +1 -0
- package/dist/shared/editor-overlay/legend/legend-list.js +96 -0
- package/dist/shared/editor-overlay/legend/legend-list.js.map +1 -0
- package/dist/shared/editor-overlay/legend/legend.d.ts +7 -0
- package/dist/shared/editor-overlay/legend/legend.d.ts.map +1 -0
- package/dist/shared/editor-overlay/legend/legend.js +80 -0
- package/dist/shared/editor-overlay/legend/legend.js.map +1 -0
- package/dist/shared/editor-overlay/overlay.d.ts +35 -0
- package/dist/shared/editor-overlay/overlay.d.ts.map +1 -0
- package/dist/shared/editor-overlay/overlay.js +41 -0
- package/dist/shared/editor-overlay/overlay.js.map +1 -0
- package/dist/shared/editor-overlay/panel-content/edge/edge-editor.d.ts +8 -0
- package/dist/shared/editor-overlay/panel-content/edge/edge-editor.d.ts.map +1 -0
- package/dist/shared/editor-overlay/panel-content/edge/edge-editor.js +40 -0
- package/dist/shared/editor-overlay/panel-content/edge/edge-editor.js.map +1 -0
- package/dist/shared/editor-overlay/panel-content/edge/edge-info-content.d.ts +22 -0
- package/dist/shared/editor-overlay/panel-content/edge/edge-info-content.d.ts.map +1 -0
- package/dist/shared/editor-overlay/panel-content/edge/edge-info-content.js +36 -0
- package/dist/shared/editor-overlay/panel-content/edge/edge-info-content.js.map +1 -0
- package/dist/shared/editor-overlay/panel-content/edge/editor-props.d.ts +35 -0
- package/dist/shared/editor-overlay/panel-content/edge/editor-props.d.ts.map +1 -0
- package/dist/shared/editor-overlay/panel-content/edge/editor-props.js +2 -0
- package/dist/shared/editor-overlay/panel-content/edge/editor-props.js.map +1 -0
- package/dist/shared/editor-overlay/panel-content/edge/encoder-editor.d.ts +23 -0
- package/dist/shared/editor-overlay/panel-content/edge/encoder-editor.d.ts.map +1 -0
- package/dist/shared/editor-overlay/panel-content/edge/encoder-editor.js +10 -0
- package/dist/shared/editor-overlay/panel-content/edge/encoder-editor.js.map +1 -0
- package/dist/shared/editor-overlay/panel-content/edge/index.d.ts +18 -0
- package/dist/shared/editor-overlay/panel-content/edge/index.d.ts.map +1 -0
- package/dist/shared/editor-overlay/panel-content/edge/index.js +18 -0
- package/dist/shared/editor-overlay/panel-content/edge/index.js.map +1 -0
- package/dist/shared/editor-overlay/panel-content/edge/pag-editor.d.ts +23 -0
- package/dist/shared/editor-overlay/panel-content/edge/pag-editor.d.ts.map +1 -0
- package/dist/shared/editor-overlay/panel-content/edge/pag-editor.js +10 -0
- package/dist/shared/editor-overlay/panel-content/edge/pag-editor.js.map +1 -0
- package/dist/shared/editor-overlay/panel-content/edge/resolver-editor.d.ts +7 -0
- package/dist/shared/editor-overlay/panel-content/edge/resolver-editor.d.ts.map +1 -0
- package/dist/shared/editor-overlay/panel-content/edge/resolver-editor.js +31 -0
- package/dist/shared/editor-overlay/panel-content/edge/resolver-editor.js.map +1 -0
- package/dist/shared/editor-overlay/panel-content/edge/sections/constraint-editor.d.ts +27 -0
- package/dist/shared/editor-overlay/panel-content/edge/sections/constraint-editor.d.ts.map +1 -0
- package/dist/shared/editor-overlay/panel-content/edge/sections/constraint-editor.js +53 -0
- package/dist/shared/editor-overlay/panel-content/edge/sections/constraint-editor.js.map +1 -0
- package/dist/shared/editor-overlay/panel-content/edge/sections/description-editor.d.ts +15 -0
- package/dist/shared/editor-overlay/panel-content/edge/sections/description-editor.d.ts.map +1 -0
- package/dist/shared/editor-overlay/panel-content/edge/sections/description-editor.js +60 -0
- package/dist/shared/editor-overlay/panel-content/edge/sections/description-editor.js.map +1 -0
- package/dist/shared/editor-overlay/panel-content/edge/sections/direction-editor.d.ts +21 -0
- package/dist/shared/editor-overlay/panel-content/edge/sections/direction-editor.d.ts.map +1 -0
- package/dist/shared/editor-overlay/panel-content/edge/sections/direction-editor.js +90 -0
- package/dist/shared/editor-overlay/panel-content/edge/sections/direction-editor.js.map +1 -0
- package/dist/shared/editor-overlay/panel-content/edge/sections/edge-type-editor.d.ts +17 -0
- package/dist/shared/editor-overlay/panel-content/edge/sections/edge-type-editor.d.ts.map +1 -0
- package/dist/shared/editor-overlay/panel-content/edge/sections/edge-type-editor.js +61 -0
- package/dist/shared/editor-overlay/panel-content/edge/sections/edge-type-editor.js.map +1 -0
- package/dist/shared/editor-overlay/panel-content/edge/sections/index.d.ts +19 -0
- package/dist/shared/editor-overlay/panel-content/edge/sections/index.d.ts.map +1 -0
- package/dist/shared/editor-overlay/panel-content/edge/sections/index.js +19 -0
- package/dist/shared/editor-overlay/panel-content/edge/sections/index.js.map +1 -0
- package/dist/shared/editor-overlay/panel-content/index.d.ts +20 -0
- package/dist/shared/editor-overlay/panel-content/index.d.ts.map +1 -0
- package/dist/shared/editor-overlay/panel-content/index.js +20 -0
- package/dist/shared/editor-overlay/panel-content/index.js.map +1 -0
- package/dist/shared/editor-overlay/panel-content/node/index.d.ts +18 -0
- package/dist/shared/editor-overlay/panel-content/node/index.d.ts.map +1 -0
- package/dist/shared/editor-overlay/panel-content/node/index.js +18 -0
- package/dist/shared/editor-overlay/panel-content/node/index.js.map +1 -0
- package/dist/shared/editor-overlay/panel-content/node/label-editor.d.ts +11 -0
- package/dist/shared/editor-overlay/panel-content/node/label-editor.d.ts.map +1 -0
- package/dist/shared/editor-overlay/panel-content/node/label-editor.js +89 -0
- package/dist/shared/editor-overlay/panel-content/node/label-editor.js.map +1 -0
- package/dist/shared/editor-overlay/panel-content/node/node-info-content.d.ts +32 -0
- package/dist/shared/editor-overlay/panel-content/node/node-info-content.d.ts.map +1 -0
- package/dist/shared/editor-overlay/panel-content/node/node-info-content.js +12 -0
- package/dist/shared/editor-overlay/panel-content/node/node-info-content.js.map +1 -0
- package/dist/shared/editor-overlay/panel-content/panel-content.d.ts +17 -0
- package/dist/shared/editor-overlay/panel-content/panel-content.d.ts.map +1 -0
- package/dist/shared/editor-overlay/panel-content/panel-content.js +27 -0
- package/dist/shared/editor-overlay/panel-content/panel-content.js.map +1 -0
- package/dist/shared/editor-overlay/panel-content/panel-title.d.ts +12 -0
- package/dist/shared/editor-overlay/panel-content/panel-title.d.ts.map +1 -0
- package/dist/shared/editor-overlay/panel-content/panel-title.js +48 -0
- package/dist/shared/editor-overlay/panel-content/panel-title.js.map +1 -0
- package/dist/shared/editor-overlay/panel-content/styled.d.ts +9 -0
- package/dist/shared/editor-overlay/panel-content/styled.d.ts.map +1 -0
- package/dist/shared/editor-overlay/panel-content/styled.js +43 -0
- package/dist/shared/editor-overlay/panel-content/styled.js.map +1 -0
- package/dist/shared/editor-overlay/positional-divs.d.ts +14 -0
- package/dist/shared/editor-overlay/positional-divs.d.ts.map +1 -0
- package/dist/shared/editor-overlay/positional-divs.js +117 -0
- package/dist/shared/editor-overlay/positional-divs.js.map +1 -0
- package/dist/shared/editor-overlay/search-bar/index.d.ts +19 -0
- package/dist/shared/editor-overlay/search-bar/index.d.ts.map +1 -0
- package/dist/shared/editor-overlay/search-bar/index.js +19 -0
- package/dist/shared/editor-overlay/search-bar/index.js.map +1 -0
- package/dist/shared/editor-overlay/search-bar/search-bar.d.ts +21 -0
- package/dist/shared/editor-overlay/search-bar/search-bar.d.ts.map +1 -0
- package/dist/shared/editor-overlay/search-bar/search-bar.js +160 -0
- package/dist/shared/editor-overlay/search-bar/search-bar.js.map +1 -0
- package/dist/shared/editor-overlay/search-bar/use-search.d.ts +32 -0
- package/dist/shared/editor-overlay/search-bar/use-search.d.ts.map +1 -0
- package/dist/shared/editor-overlay/search-bar/use-search.js +75 -0
- package/dist/shared/editor-overlay/search-bar/use-search.js.map +1 -0
- package/dist/shared/graph-layout/circular-layout.d.ts +18 -0
- package/dist/shared/graph-layout/circular-layout.d.ts.map +1 -0
- package/dist/shared/graph-layout/circular-layout.js +38 -0
- package/dist/shared/graph-layout/circular-layout.js.map +1 -0
- package/dist/shared/graph-layout/common.d.ts +64 -0
- package/dist/shared/graph-layout/common.d.ts.map +1 -0
- package/dist/shared/graph-layout/common.js +42 -0
- package/dist/shared/graph-layout/common.js.map +1 -0
- package/dist/shared/graph-layout/custom-layout.d.ts +35 -0
- package/dist/shared/graph-layout/custom-layout.d.ts.map +1 -0
- package/dist/shared/graph-layout/custom-layout.js +29 -0
- package/dist/shared/graph-layout/custom-layout.js.map +1 -0
- package/dist/shared/graph-layout/fcose-layout.d.ts +88 -0
- package/dist/shared/graph-layout/fcose-layout.d.ts.map +1 -0
- package/dist/shared/graph-layout/fcose-layout.js +196 -0
- package/dist/shared/graph-layout/fcose-layout.js.map +1 -0
- package/dist/shared/graph-layout/force-atlas-layout.d.ts +79 -0
- package/dist/shared/graph-layout/force-atlas-layout.d.ts.map +1 -0
- package/dist/shared/graph-layout/force-atlas-layout.js +163 -0
- package/dist/shared/graph-layout/force-atlas-layout.js.map +1 -0
- package/dist/shared/graph-layout/index.d.ts +25 -0
- package/dist/shared/graph-layout/index.d.ts.map +1 -0
- package/dist/shared/graph-layout/index.js +25 -0
- package/dist/shared/graph-layout/index.js.map +1 -0
- package/dist/shared/graph-layout/marketing-layout.d.ts +30 -0
- package/dist/shared/graph-layout/marketing-layout.d.ts.map +1 -0
- package/dist/shared/graph-layout/marketing-layout.js +105 -0
- package/dist/shared/graph-layout/marketing-layout.js.map +1 -0
- package/dist/shared/graph-layout/planar-layout.d.ts +32 -0
- package/dist/shared/graph-layout/planar-layout.d.ts.map +1 -0
- package/dist/shared/graph-layout/planar-layout.js +95 -0
- package/dist/shared/graph-layout/planar-layout.js.map +1 -0
- package/dist/shared/graph-layout/spring-layout.d.ts +56 -0
- package/dist/shared/graph-layout/spring-layout.d.ts.map +1 -0
- package/dist/shared/graph-layout/spring-layout.js +148 -0
- package/dist/shared/graph-layout/spring-layout.js.map +1 -0
- package/dist/shared/parsers.d.ts +63 -0
- package/dist/shared/parsers.d.ts.map +1 -0
- package/dist/shared/parsers.js +176 -0
- package/dist/shared/parsers.js.map +1 -0
- package/dist/shared/pointer-context.d.ts +21 -0
- package/dist/shared/pointer-context.d.ts.map +1 -0
- package/dist/shared/pointer-context.js +23 -0
- package/dist/shared/pointer-context.js.map +1 -0
- package/dist/shared/rendering/background.d.ts +32 -0
- package/dist/shared/rendering/background.d.ts.map +1 -0
- package/dist/shared/rendering/background.js +91 -0
- package/dist/shared/rendering/background.js.map +1 -0
- package/dist/shared/rendering/colors.d.ts +27 -0
- package/dist/shared/rendering/colors.d.ts.map +1 -0
- package/dist/shared/rendering/colors.js +14 -0
- package/dist/shared/rendering/colors.js.map +1 -0
- package/dist/shared/rendering/edge/curve.d.ts +51 -0
- package/dist/shared/rendering/edge/curve.d.ts.map +1 -0
- package/dist/shared/rendering/edge/curve.js +122 -0
- package/dist/shared/rendering/edge/curve.js.map +1 -0
- package/dist/shared/rendering/edge/definitions.d.ts +71 -0
- package/dist/shared/rendering/edge/definitions.d.ts.map +1 -0
- package/dist/shared/rendering/edge/definitions.js +31 -0
- package/dist/shared/rendering/edge/definitions.js.map +1 -0
- package/dist/shared/rendering/edge/edge-object.d.ts +93 -0
- package/dist/shared/rendering/edge/edge-object.d.ts.map +1 -0
- package/dist/shared/rendering/edge/edge-object.js +483 -0
- package/dist/shared/rendering/edge/edge-object.js.map +1 -0
- package/dist/shared/rendering/edge/index.d.ts +19 -0
- package/dist/shared/rendering/edge/index.d.ts.map +1 -0
- package/dist/shared/rendering/edge/index.js +19 -0
- package/dist/shared/rendering/edge/index.js.map +1 -0
- package/dist/shared/rendering/edge/symbols.d.ts +40 -0
- package/dist/shared/rendering/edge/symbols.d.ts.map +1 -0
- package/dist/shared/rendering/edge/symbols.js +150 -0
- package/dist/shared/rendering/edge/symbols.js.map +1 -0
- package/dist/shared/rendering/engine.d.ts +342 -0
- package/dist/shared/rendering/engine.d.ts.map +1 -0
- package/dist/shared/rendering/engine.js +990 -0
- package/dist/shared/rendering/engine.js.map +1 -0
- package/dist/shared/rendering/node/definitions.d.ts +57 -0
- package/dist/shared/rendering/node/definitions.d.ts.map +1 -0
- package/dist/shared/rendering/node/definitions.js +2 -0
- package/dist/shared/rendering/node/definitions.js.map +1 -0
- package/dist/shared/rendering/node/index.d.ts +20 -0
- package/dist/shared/rendering/node/index.d.ts.map +1 -0
- package/dist/shared/rendering/node/index.js +19 -0
- package/dist/shared/rendering/node/index.js.map +1 -0
- package/dist/shared/rendering/node/node-object.d.ts +77 -0
- package/dist/shared/rendering/node/node-object.d.ts.map +1 -0
- package/dist/shared/rendering/node/node-object.js +241 -0
- package/dist/shared/rendering/node/node-object.js.map +1 -0
- package/dist/shared/rendering/node/utils.d.ts +33 -0
- package/dist/shared/rendering/node/utils.d.ts.map +1 -0
- package/dist/shared/rendering/node/utils.js +27 -0
- package/dist/shared/rendering/node/utils.js.map +1 -0
- package/dist/shared/rendering/svg.d.ts +26 -0
- package/dist/shared/rendering/svg.d.ts.map +1 -0
- package/dist/shared/rendering/svg.js +44 -0
- package/dist/shared/rendering/svg.js.map +1 -0
- package/dist/shared/rendering/text.d.ts +33 -0
- package/dist/shared/rendering/text.d.ts.map +1 -0
- package/dist/shared/rendering/text.js +107 -0
- package/dist/shared/rendering/text.js.map +1 -0
- package/dist/shared/rendering/texture-cache.d.ts +32 -0
- package/dist/shared/rendering/texture-cache.d.ts.map +1 -0
- package/dist/shared/rendering/texture-cache.js +76 -0
- package/dist/shared/rendering/texture-cache.js.map +1 -0
- package/dist/shared/rendering/use-render-engine.d.ts +86 -0
- package/dist/shared/rendering/use-render-engine.d.ts.map +1 -0
- package/dist/shared/rendering/use-render-engine.js +89 -0
- package/dist/shared/rendering/use-render-engine.js.map +1 -0
- package/dist/shared/rendering/utils.d.ts +24 -0
- package/dist/shared/rendering/utils.d.ts.map +1 -0
- package/dist/shared/rendering/utils.js +60 -0
- package/dist/shared/rendering/utils.js.map +1 -0
- package/dist/shared/serializer.d.ts +39 -0
- package/dist/shared/serializer.d.ts.map +1 -0
- package/dist/shared/serializer.js +131 -0
- package/dist/shared/serializer.js.map +1 -0
- package/dist/shared/settings-context.d.ts +56 -0
- package/dist/shared/settings-context.d.ts.map +1 -0
- package/dist/shared/settings-context.js +36 -0
- package/dist/shared/settings-context.js.map +1 -0
- package/dist/shared/styles.d.ts +4 -0
- package/dist/shared/styles.d.ts.map +1 -0
- package/dist/shared/styles.js +52 -0
- package/dist/shared/styles.js.map +1 -0
- package/dist/shared/use-causal-graph-editor.d.ts +19 -0
- package/dist/shared/use-causal-graph-editor.d.ts.map +1 -0
- package/dist/shared/use-causal-graph-editor.js +58 -0
- package/dist/shared/use-causal-graph-editor.js.map +1 -0
- package/dist/shared/use-drag-mode.d.ts +33 -0
- package/dist/shared/use-drag-mode.d.ts.map +1 -0
- package/dist/shared/use-drag-mode.js +75 -0
- package/dist/shared/use-drag-mode.js.map +1 -0
- package/dist/shared/use-edge-encoder.d.ts +45 -0
- package/dist/shared/use-edge-encoder.d.ts.map +1 -0
- package/dist/shared/use-edge-encoder.js +121 -0
- package/dist/shared/use-edge-encoder.js.map +1 -0
- package/dist/shared/utils.d.ts +52 -0
- package/dist/shared/utils.d.ts.map +1 -0
- package/dist/shared/utils.js +99 -0
- package/dist/shared/utils.js.map +1 -0
- package/dist/types.d.ts +213 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +98 -0
- package/dist/types.js.map +1 -0
- package/package.json +123 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Impulse Innovations Limited
|
|
3
|
+
*
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { EdgeType, } from '../types';
|
|
18
|
+
const RENDERING_META_PREFIX = 'meta.rendering_properties.';
|
|
19
|
+
function isPrefixed(key) {
|
|
20
|
+
return key.startsWith(RENDERING_META_PREFIX);
|
|
21
|
+
}
|
|
22
|
+
function removeEdgePrefix(key) {
|
|
23
|
+
return key.slice(RENDERING_META_PREFIX.length);
|
|
24
|
+
}
|
|
25
|
+
function removeNodePrefix(key) {
|
|
26
|
+
return key.slice(RENDERING_META_PREFIX.length);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Serialize a simulation edge into a causal graph edge
|
|
30
|
+
*
|
|
31
|
+
* @param attributes simulation edge data
|
|
32
|
+
* @param source optional source to include in output data
|
|
33
|
+
* @param destination optional destination to include in output data
|
|
34
|
+
*/
|
|
35
|
+
export function serializeGraphEdge(attributes, source, destination) {
|
|
36
|
+
const entries = Object.entries(attributes);
|
|
37
|
+
const unflattenedMeta = Object.fromEntries(entries
|
|
38
|
+
.filter(([key]) => isPrefixed(key))
|
|
39
|
+
.map(([key, val]) => {
|
|
40
|
+
const newKey = removeEdgePrefix(key);
|
|
41
|
+
return [newKey, val];
|
|
42
|
+
}));
|
|
43
|
+
const output = {
|
|
44
|
+
edge_type: attributes.edge_type,
|
|
45
|
+
meta: Object.assign(Object.assign({}, attributes.originalMeta), { rendering_properties: unflattenedMeta }),
|
|
46
|
+
};
|
|
47
|
+
if (source) {
|
|
48
|
+
output.source = source;
|
|
49
|
+
}
|
|
50
|
+
if (destination) {
|
|
51
|
+
output.destination = destination;
|
|
52
|
+
}
|
|
53
|
+
// Reverse the edge if it is a backwards directed edge
|
|
54
|
+
if (output.edge_type === EdgeType.BACKWARDS_DIRECTED_EDGE) {
|
|
55
|
+
output.edge_type = EdgeType.DIRECTED_EDGE;
|
|
56
|
+
if (output.source) {
|
|
57
|
+
output.source = destination;
|
|
58
|
+
}
|
|
59
|
+
if (output.destination) {
|
|
60
|
+
output.destination = source;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return output;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Serialize a simulation node into a causal graph node
|
|
67
|
+
*
|
|
68
|
+
* @param attributes simulation node data
|
|
69
|
+
* @param includeIdentifier whether to include data to identify the node
|
|
70
|
+
*/
|
|
71
|
+
export function serializeGraphNode(attributes, includeIdentifier = false) {
|
|
72
|
+
const entries = Object.entries(attributes);
|
|
73
|
+
const unflattenedMeta = Object.fromEntries(entries
|
|
74
|
+
.filter(([key]) => isPrefixed(key))
|
|
75
|
+
.map(([key, val]) => {
|
|
76
|
+
const newKey = removeNodePrefix(key);
|
|
77
|
+
return [newKey, val];
|
|
78
|
+
}));
|
|
79
|
+
const output = {
|
|
80
|
+
meta: Object.assign(Object.assign({}, attributes.originalMeta), { rendering_properties: unflattenedMeta }),
|
|
81
|
+
variable_type: attributes.variable_type,
|
|
82
|
+
};
|
|
83
|
+
if (includeIdentifier) {
|
|
84
|
+
output.identifier = attributes.id;
|
|
85
|
+
}
|
|
86
|
+
return output;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Serialize internal graph representation into a CausalGraph
|
|
90
|
+
*
|
|
91
|
+
* @param graph internal graph representation
|
|
92
|
+
*/
|
|
93
|
+
export function causalGraphSerializer(state) {
|
|
94
|
+
const edges = state.graph.reduceEdges((acc, id, attributes, source, target) => {
|
|
95
|
+
const serializedEdge = serializeGraphEdge(attributes);
|
|
96
|
+
// if the edge is backwards, we need to swap the source and target
|
|
97
|
+
if (attributes.edge_type === EdgeType.BACKWARDS_DIRECTED_EDGE) {
|
|
98
|
+
if (!(target in acc)) {
|
|
99
|
+
acc[target] = {};
|
|
100
|
+
}
|
|
101
|
+
acc[target][source] = serializedEdge;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
if (!(source in acc)) {
|
|
105
|
+
acc[source] = {};
|
|
106
|
+
}
|
|
107
|
+
acc[source][target] = serializedEdge;
|
|
108
|
+
}
|
|
109
|
+
return acc;
|
|
110
|
+
}, {});
|
|
111
|
+
const nodes = state.graph.reduceNodes((acc, id, attributes) => {
|
|
112
|
+
const entries = Object.entries(attributes);
|
|
113
|
+
const unflattenedMeta = Object.fromEntries(entries
|
|
114
|
+
.filter(([key]) => isPrefixed(key))
|
|
115
|
+
.map(([key, val]) => {
|
|
116
|
+
const newKey = removeNodePrefix(key);
|
|
117
|
+
return [newKey, val];
|
|
118
|
+
}));
|
|
119
|
+
acc[id] = {
|
|
120
|
+
meta: Object.assign(Object.assign({}, attributes.originalMeta), { rendering_properties: unflattenedMeta }),
|
|
121
|
+
variable_type: attributes.variable_type,
|
|
122
|
+
};
|
|
123
|
+
return acc;
|
|
124
|
+
}, {});
|
|
125
|
+
return {
|
|
126
|
+
edges,
|
|
127
|
+
nodes,
|
|
128
|
+
version: state.graph.getAttribute('version'),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=serializer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../../src/shared/serializer.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAKH,QAAQ,GAOX,MAAM,UAAU,CAAC;AAElB,MAAM,qBAAqB,GAAG,4BAA4B,CAAC;AAE3D,SAAS,UAAU,CAAmB,GAAW;IAC7C,OAAO,GAAG,CAAC,UAAU,CAAC,qBAAqB,CAAC,CAAC;AACjD,CAAC;AAED,SAAS,gBAAgB,CAAwC,GAAM;IACnE,OAAO,GAAG,CAAC,KAAK,CAAC,qBAAqB,CAAC,MAAM,CAA4B,CAAC;AAC9E,CAAC;AAED,SAAS,gBAAgB,CAAwC,GAAM;IACnE,OAAO,GAAG,CAAC,KAAK,CAAC,qBAAqB,CAAC,MAAM,CAA4B,CAAC;AAC9E,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,UAA0B,EAAE,MAAe,EAAE,WAAoB;IAChG,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAA4B,CAAC;IACtE,MAAM,eAAe,GAAsB,MAAM,CAAC,WAAW,CACzD,OAAO;SACF,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,UAAU,CAA8B,GAAG,CAAC,CAAC;SAC/D,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE;QAChB,MA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GAAsB,MAAM,CAAC,WAAW,CACzD,OAAO;aACF,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,UAAU,CAA8B,GAAG,CAAC,CAAC;aAC/D,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE;YAChB,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAkC,CAAC,CAAC;YACpE,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACzB,CAAC,CAAC,CACT,CAAC;QAEF,GAAG,CAAC,EAAE,CAAC,GAAG;YACN,IAAI,kCACG,UAAU,CAAC,YAAY,KAC1B,oBAAoB,EAAE,eAAe,GACxC;YACD,aAAa,EAAE,UAAU,CAAC,aAAa;SAC1C,CAAC;QAEF,OAAO,GAAG,CAAC;IACf,CAAC,EACD,EAAE,CACL,CAAC;IAEF,OAAO;QACH,KAAK;QACL,KAAK;QACL,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC;KAC/C,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Impulse Innovations Limited
|
|
3
|
+
*
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import * as React from 'react';
|
|
18
|
+
import { NotificationPayload } from '@darajs/ui-notifications';
|
|
19
|
+
import { EditorMode } from '../types';
|
|
20
|
+
/**
|
|
21
|
+
* Common graph settings used inside graph sub-components
|
|
22
|
+
*/
|
|
23
|
+
export interface Settings {
|
|
24
|
+
/** Whether node dragging is enabled */
|
|
25
|
+
allowNodeDrag?: boolean;
|
|
26
|
+
/** Whether to show the details panel when the graph is not editable */
|
|
27
|
+
allowSelectionWhenNotEditable?: boolean;
|
|
28
|
+
/** Flag for disabling edge addition */
|
|
29
|
+
disableEdgeAdd?: boolean;
|
|
30
|
+
/** Flag for disabling latent node addition */
|
|
31
|
+
disableLatentNodeAdd?: boolean;
|
|
32
|
+
/** Flag for disabling node removal */
|
|
33
|
+
disableNodeRemoval?: boolean;
|
|
34
|
+
/** Allow editing */
|
|
35
|
+
editable?: boolean;
|
|
36
|
+
/** Mode the graph viewer should operate in */
|
|
37
|
+
editorMode?: EditorMode;
|
|
38
|
+
/** On notify handler to show a notification */
|
|
39
|
+
onNotify?: (payload: NotificationPayload) => void | Promise<void>;
|
|
40
|
+
/** Whether to show verbose descriptions in the editor frame */
|
|
41
|
+
verboseDescriptions?: boolean;
|
|
42
|
+
}
|
|
43
|
+
interface SettingsProviderProps {
|
|
44
|
+
children: React.ReactNode;
|
|
45
|
+
settings: Settings;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Wrapper around SettingsContext which requires settings to be set
|
|
49
|
+
*/
|
|
50
|
+
export declare function SettingsProvider({ children, settings }: SettingsProviderProps): JSX.Element;
|
|
51
|
+
/**
|
|
52
|
+
* Helper hook that pulls in Settings from the SettingsContext
|
|
53
|
+
*/
|
|
54
|
+
export declare function useSettings(): Settings;
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=settings-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings-context.d.ts","sourceRoot":"","sources":["../../src/shared/settings-context.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC;;GAEG;AACH,MAAM,WAAW,QAAQ;IACrB,uCAAuC;IACvC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,uEAAuE;IACvE,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC,uCAAuC;IACvC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,8CAA8C;IAC9C,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,sCAAsC;IACtC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,oBAAoB;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,8CAA8C;IAC9C,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,+DAA+D;IAC/D,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC;AAID,UAAU,qBAAqB;IAC3B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,QAAQ,EAAE,QAAQ,CAAC;CACtB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,qBAAqB,GAAG,GAAG,CAAC,OAAO,CAE3F;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,QAAQ,CAQtC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2023 Impulse Innovations Limited
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
import * as React from 'react';
|
|
19
|
+
const SettingsContext = React.createContext(undefined);
|
|
20
|
+
/**
|
|
21
|
+
* Wrapper around SettingsContext which requires settings to be set
|
|
22
|
+
*/
|
|
23
|
+
export function SettingsProvider({ children, settings }) {
|
|
24
|
+
return _jsx(SettingsContext.Provider, { value: settings, children: children });
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Helper hook that pulls in Settings from the SettingsContext
|
|
28
|
+
*/
|
|
29
|
+
export function useSettings() {
|
|
30
|
+
const settings = React.useContext(SettingsContext);
|
|
31
|
+
if (settings === undefined) {
|
|
32
|
+
throw new Error('useSettings must be used within a SettingsProvider');
|
|
33
|
+
}
|
|
34
|
+
return settings;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=settings-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings-context.js","sourceRoot":"","sources":["../../src/shared/settings-context.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA8B/B,MAAM,eAAe,GAAG,KAAK,CAAC,aAAa,CAAuB,SAAS,CAAC,CAAC;AAO7E;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAyB;IAC1E,OAAO,KAAC,eAAe,CAAC,QAAQ,IAAC,KAAK,EAAE,QAAQ,YAAG,QAAQ,GAA4B,CAAC;AAC5F,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW;IACvB,MAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;IAEnD,IAAI,QAAQ,KAAK,SAAS,EAAE;QACxB,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;KACzE;IAED,OAAO,QAAQ,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const Wrapper: import("styled-components").StyledComponent<"div", import("@darajs/styled-components").DefaultTheme, {}, never>;
|
|
2
|
+
export declare const Center: import("styled-components").StyledComponent<"div", import("@darajs/styled-components").DefaultTheme, {}, never>;
|
|
3
|
+
export declare const Graph: import("styled-components").StyledComponent<"div", import("@darajs/styled-components").DefaultTheme, {}, never>;
|
|
4
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/shared/styles.tsx"],"names":[],"mappings":"AAkBA,eAAO,MAAM,OAAO,iHAOnB,CAAC;AAEF,eAAO,MAAM,MAAM,iHAMlB,CAAC;AAEF,eAAO,MAAM,KAAK,iHAkBjB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Impulse Innovations Limited
|
|
3
|
+
*
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import styled from '@darajs/styled-components';
|
|
18
|
+
export const Wrapper = styled.div `
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
display: flex;
|
|
21
|
+
flex: 1 1 auto;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
|
|
24
|
+
width: 100%;
|
|
25
|
+
`;
|
|
26
|
+
export const Center = styled.div `
|
|
27
|
+
display: flex;
|
|
28
|
+
flex: 1 1 auto;
|
|
29
|
+
flex-direction: column;
|
|
30
|
+
align-items: center;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
`;
|
|
33
|
+
export const Graph = styled.div `
|
|
34
|
+
cursor: grab;
|
|
35
|
+
|
|
36
|
+
/* This is a CSS trick for the graph to fill the available space of the flex container */
|
|
37
|
+
position: absolute;
|
|
38
|
+
top: 0;
|
|
39
|
+
right: 0;
|
|
40
|
+
bottom: 0;
|
|
41
|
+
left: 0;
|
|
42
|
+
|
|
43
|
+
overflow: hidden;
|
|
44
|
+
flex: 1 1 auto;
|
|
45
|
+
|
|
46
|
+
width: 100%;
|
|
47
|
+
height: 100%;
|
|
48
|
+
|
|
49
|
+
border: 1px solid ${(props) => props.theme.colors.grey2};
|
|
50
|
+
border-radius: 4px;
|
|
51
|
+
`;
|
|
52
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/shared/styles.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAE/C,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;CAOhC,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;CAM/B,CAAC;AAEF,MAAM,CAAC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;wBAgBP,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK;;CAE1D,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CausalGraph, EditorMode, GraphState } from '../types';
|
|
2
|
+
import { GraphActionCreators } from './causal-graph-store';
|
|
3
|
+
export interface UseCausalGraphEditorApi {
|
|
4
|
+
api: GraphApi;
|
|
5
|
+
state: GraphState;
|
|
6
|
+
}
|
|
7
|
+
type ActionName = keyof typeof GraphActionCreators;
|
|
8
|
+
/**
|
|
9
|
+
* Graph API object containing all available methods to modify the graph
|
|
10
|
+
*/
|
|
11
|
+
export type GraphApi = {
|
|
12
|
+
[k in ActionName]: (...args: Parameters<typeof GraphActionCreators[k]>) => void;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* A helper hook to inject causal graph editor API for given initial graphdata
|
|
16
|
+
*/
|
|
17
|
+
export default function useCausalGraphEditor(graphData: CausalGraph, editorMode: EditorMode, availableInputs?: string[], newNodesRequirePosition?: boolean): UseCausalGraphEditorApi;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=use-causal-graph-editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-causal-graph-editor.d.ts","sourceRoot":"","sources":["../../src/shared/use-causal-graph-editor.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAiC,MAAM,sBAAsB,CAAC;AAG1F,MAAM,WAAW,uBAAuB;IACpC,GAAG,EAAE,QAAQ,CAAC;IACd,KAAK,EAAE,UAAU,CAAC;CACrB;AAED,KAAK,UAAU,GAAG,MAAM,OAAO,mBAAmB,CAAC;AAGnD;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG;KAClB,CAAC,IAAI,UAAU,GAAG,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI;CAClF,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CACxC,SAAS,EAAE,WAAW,EACtB,UAAU,EAAE,UAAU,EACtB,eAAe,CAAC,EAAE,MAAM,EAAE,EAC1B,uBAAuB,CAAC,EAAE,OAAO,GAClC,uBAAuB,CA6CzB"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Impulse Innovations Limited
|
|
3
|
+
*
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import isEqual from 'lodash/isEqual';
|
|
18
|
+
import { useEffect, useMemo, useReducer, useRef } from 'react';
|
|
19
|
+
import { GraphActionCreators, GraphActionType, GraphReducer } from './causal-graph-store';
|
|
20
|
+
import { causalGraphParser } from './parsers';
|
|
21
|
+
const actionNames = Object.keys(GraphActionCreators);
|
|
22
|
+
/**
|
|
23
|
+
* A helper hook to inject causal graph editor API for given initial graphdata
|
|
24
|
+
*/
|
|
25
|
+
export default function useCausalGraphEditor(graphData, editorMode, availableInputs, newNodesRequirePosition) {
|
|
26
|
+
const [state, dispatch] = useReducer(GraphReducer, {
|
|
27
|
+
editorMode,
|
|
28
|
+
newNodesRequirePosition,
|
|
29
|
+
}, (initState) => {
|
|
30
|
+
return Object.assign(Object.assign({}, initState), { graph: causalGraphParser(graphData, availableInputs) });
|
|
31
|
+
});
|
|
32
|
+
// bind each action creator to dispatch
|
|
33
|
+
const api = useMemo(() => {
|
|
34
|
+
return actionNames.reduce((acc, actionName) => {
|
|
35
|
+
const actionCreator = GraphActionCreators[actionName];
|
|
36
|
+
// eslint-disable-next-line prefer-spread
|
|
37
|
+
acc[actionName] = (...args) => dispatch(actionCreator.apply(null, args));
|
|
38
|
+
return acc;
|
|
39
|
+
}, {});
|
|
40
|
+
}, [dispatch]);
|
|
41
|
+
// Init graph data, update when outside graph nodes/edges changes
|
|
42
|
+
const lastParentData = useRef(graphData); // keep track of last parent data to skip unnecessary updates
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (!isEqual(lastParentData.current.nodes, graphData.nodes) ||
|
|
45
|
+
!isEqual(lastParentData.current.edges, graphData.edges)) {
|
|
46
|
+
dispatch({
|
|
47
|
+
graph: causalGraphParser(graphData, availableInputs, state.graph),
|
|
48
|
+
type: GraphActionType.INIT_GRAPH,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
lastParentData.current = graphData;
|
|
52
|
+
}, [graphData]);
|
|
53
|
+
return {
|
|
54
|
+
api,
|
|
55
|
+
state,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=use-causal-graph-editor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-causal-graph-editor.js","sourceRoot":"","sources":["../../src/shared/use-causal-graph-editor.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAG/D,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAQ9C,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,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EAAE,eAAe,CAAC,UAAU;aACnC,CAAC,CAAC;SACN;QAED,cAAc,CAAC,OAAO,GAAG,SAAS,CAAC;IACvC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,OAAO;QACH,GAAG;QACH,KAAK;KACR,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Impulse Innovations Limited
|
|
3
|
+
*
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import React from 'react';
|
|
18
|
+
export type DragMode = 'create_edge' | 'move_node';
|
|
19
|
+
/**
|
|
20
|
+
* Helper hook controlling switching and enabling drag mode
|
|
21
|
+
*
|
|
22
|
+
* @param editMode whether app is in edit mode
|
|
23
|
+
* @param allowEdgeAdd whether to allow adding edges
|
|
24
|
+
* @param allowNodeDrag whether to allow node dragging
|
|
25
|
+
* @param onDragModeChange callback to execute whenever drag mode changes
|
|
26
|
+
*/
|
|
27
|
+
declare function useDragMode(editMode: boolean, allowEdgeAdd: boolean, allowNodeDrag: boolean, onDragModeChange: (dragMode: DragMode | null) => void): {
|
|
28
|
+
dragEnabled: boolean;
|
|
29
|
+
dragMode: DragMode;
|
|
30
|
+
setDragMode: React.Dispatch<React.SetStateAction<DragMode>>;
|
|
31
|
+
};
|
|
32
|
+
export default useDragMode;
|
|
33
|
+
//# sourceMappingURL=use-drag-mode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-drag-mode.d.ts","sourceRoot":"","sources":["../../src/shared/use-drag-mode.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAuC,MAAM,OAAO,CAAC;AAE5D,MAAM,MAAM,QAAQ,GAAG,aAAa,GAAG,WAAW,CAAC;AAEnD;;;;;;;GAOG;AACH,iBAAS,WAAW,CAChB,QAAQ,EAAE,OAAO,EACjB,YAAY,EAAE,OAAO,EACrB,aAAa,EAAE,OAAO,EACtB,gBAAgB,EAAE,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,KAAK,IAAI,GACtD;IAAE,WAAW,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAC;IAAC,WAAW,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAA;CAAE,CAsD3G;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Impulse Innovations Limited
|
|
3
|
+
*
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
18
|
+
/**
|
|
19
|
+
* Helper hook controlling switching and enabling drag mode
|
|
20
|
+
*
|
|
21
|
+
* @param editMode whether app is in edit mode
|
|
22
|
+
* @param allowEdgeAdd whether to allow adding edges
|
|
23
|
+
* @param allowNodeDrag whether to allow node dragging
|
|
24
|
+
* @param onDragModeChange callback to execute whenever drag mode changes
|
|
25
|
+
*/
|
|
26
|
+
function useDragMode(editMode, allowEdgeAdd, allowNodeDrag, onDragModeChange) {
|
|
27
|
+
const [dragMode, setDragMode] = useState(() => {
|
|
28
|
+
if (editMode && allowEdgeAdd) {
|
|
29
|
+
return 'create_edge';
|
|
30
|
+
}
|
|
31
|
+
return allowNodeDrag ? 'move_node' : null;
|
|
32
|
+
});
|
|
33
|
+
const dragEnabled = useMemo(() => {
|
|
34
|
+
if (dragMode === 'create_edge') {
|
|
35
|
+
return editMode && allowEdgeAdd;
|
|
36
|
+
}
|
|
37
|
+
if (dragMode === 'move_node') {
|
|
38
|
+
return allowNodeDrag;
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}, [dragMode, editMode, allowEdgeAdd]);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (!dragEnabled) {
|
|
44
|
+
onDragModeChange(null);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
onDragModeChange(dragMode);
|
|
48
|
+
}
|
|
49
|
+
}, [dragMode, dragEnabled]);
|
|
50
|
+
// Register listener to switch modes in edit mode
|
|
51
|
+
// In non-edit mode we stay in one mode only
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
const cmdHandler = (ev) => {
|
|
54
|
+
// Left Alt (for Windows&Mac) or Left CMD (for OSX)
|
|
55
|
+
const codes = ['AltLeft', 'MetaLeft', 'OSLeft'];
|
|
56
|
+
if (codes.includes(ev.code)) {
|
|
57
|
+
setDragMode(dragMode === 'move_node' ? 'create_edge' : 'move_node');
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
// If both edge adding and node dragging is not allowed, there is no point in switching modes
|
|
61
|
+
if (editMode && allowEdgeAdd && allowNodeDrag) {
|
|
62
|
+
document.addEventListener('keydown', cmdHandler);
|
|
63
|
+
document.addEventListener('keyup', cmdHandler);
|
|
64
|
+
}
|
|
65
|
+
return () => {
|
|
66
|
+
if (editMode && allowEdgeAdd && allowNodeDrag) {
|
|
67
|
+
document.removeEventListener('keydown', cmdHandler);
|
|
68
|
+
document.removeEventListener('keyup', cmdHandler);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}, [dragMode]);
|
|
72
|
+
return { dragEnabled, dragMode, setDragMode };
|
|
73
|
+
}
|
|
74
|
+
export default useDragMode;
|
|
75
|
+
//# sourceMappingURL=use-drag-mode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-drag-mode.js","sourceRoot":"","sources":["../../src/shared/use-drag-mode.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAc,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAI5D;;;;;;;GAOG;AACH,SAAS,WAAW,CAChB,QAAiB,EACjB,YAAqB,EACrB,aAAsB,EACtB,gBAAqD;IAErD,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAW,GAAG,EAAE;QACpD,IAAI,QAAQ,IAAI,YAAY,EAAE;YAC1B,OAAO,aAAa,CAAC;SACxB;QAED,OAAO,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC;IAC9C,CAAC,CAAC,CAAC;IACH,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE;QAC7B,IAAI,QAAQ,KAAK,aAAa,EAAE;YAC5B,OAAO,QAAQ,IAAI,YAAY,CAAC;SACnC;QAED,IAAI,QAAQ,KAAK,WAAW,EAAE;YAC1B,OAAO,aAAa,CAAC;SACxB;QAED,OAAO,KAAK,CAAC;IACjB,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC;IAEvC,SA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from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Parse edge constraints into internal representation
|
|
4
|
+
*
|
|
5
|
+
* @param constraints edge constraints to parse
|
|
6
|
+
*/
|
|
7
|
+
export declare function parseConstraints(constraints: EdgeConstraint[]): EdgeConstraintItem[];
|
|
8
|
+
/**
|
|
9
|
+
* Parse internal edge constraint items to external representation
|
|
10
|
+
*
|
|
11
|
+
* @param constraintItems edge constraint items to parse
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseConstraintItems(constraintItems: EdgeConstraintItem[]): EdgeConstraint[];
|
|
14
|
+
interface EdgeConstraintEncoderApi {
|
|
15
|
+
/**
|
|
16
|
+
* Add a new constraint
|
|
17
|
+
*/
|
|
18
|
+
addConstraint: (source?: string, target?: string) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Current constraints
|
|
21
|
+
*/
|
|
22
|
+
constraints: EdgeConstraintItem[];
|
|
23
|
+
/**
|
|
24
|
+
* Remove a constraint with the given id
|
|
25
|
+
*/
|
|
26
|
+
removeConstraint: (id: string) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Reverse a given constraint - switch source and target
|
|
29
|
+
*/
|
|
30
|
+
reverseConstraint: (edgeConstraint: EdgeConstraintItem) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Update given constraint
|
|
33
|
+
*/
|
|
34
|
+
updateConstraint: (edgeConstraint: EdgeConstraintItem) => void;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Hook exposing common logic to manage edge constraints
|
|
38
|
+
* Can be re-used with different frontends to maintain the same functionality
|
|
39
|
+
*
|
|
40
|
+
* @param initialConstraints Initial constraints to show
|
|
41
|
+
* @param onUpdate Handler called whenever constraints are updated
|
|
42
|
+
*/
|
|
43
|
+
export declare function useEdgeConstraintEncoder(initialConstraints: EdgeConstraint[], onUpdate?: (constraints: EdgeConstraint[]) => void | Promise<void>): EdgeConstraintEncoderApi;
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=use-edge-encoder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-edge-encoder.d.ts","sourceRoot":"","sources":["../../src/shared/use-edge-encoder.tsx"],"names":[],"mappings":"AAqBA,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAsB,MAAM,UAAU,CAAC;AAElF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,cAAc,EAAE,GAAG,kBAAkB,EAAE,CAyBpF;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,kBAAkB,EAAE,GAAG,cAAc,EAAE,CAK5F;AAED,UAAU,wBAAwB;IAC9B;;OAEG;IACH,aAAa,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1D;;OAEG;IACH,WAAW,EAAE,kBAAkB,EAAE,CAAC;IAClC;;OAEG;IACH,gBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC;;OAEG;IACH,iBAAiB,EAAE,CAAC,cAAc,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAChE;;OAEG;IACH,gBAAgB,EAAE,CAAC,cAAc,EAAE,kBAAkB,KAAK,IAAI,CAAC;CAClE;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACpC,kBAAkB,EAAE,cAAc,EAAE,EACpC,QAAQ,CAAC,EAAE,CAAC,WAAW,EAAE,cAAc,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GACnE,wBAAwB,CAmD1B"}
|