@darajs/components 1.6.3 → 1.7.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/dara_components-1.7.0-py3-none-any.whl +0 -0
- package/dist/graphs/causal-graph-viewer.d.ts +4 -3
- package/dist/graphs/causal-graph-viewer.d.ts.map +1 -1
- package/dist/graphs/causal-graph-viewer.js +14 -3
- package/dist/graphs/causal-graph-viewer.js.map +1 -1
- package/dist/graphs/index.d.ts +1 -0
- package/dist/graphs/index.d.ts.map +1 -1
- package/dist/graphs/index.js +1 -0
- package/dist/graphs/index.js.map +1 -1
- package/dist/graphs/utils.d.ts +10 -0
- package/dist/graphs/utils.d.ts.map +1 -0
- package/dist/graphs/utils.js +31 -0
- package/dist/graphs/utils.js.map +1 -0
- package/dist/graphs/visual-edge-encoder.d.ts +5 -1
- package/dist/graphs/visual-edge-encoder.d.ts.map +1 -1
- package/dist/graphs/visual-edge-encoder.js +13 -1
- package/dist/graphs/visual-edge-encoder.js.map +1 -1
- package/dist/umd/dara.components.umd.js +2753 -2700
- package/package.json +13 -13
- package/dist/dara_components-1.6.3-py3-none-any.whl +0 -0
|
Binary file
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { ComponentProps } from 'react';
|
|
2
1
|
import { Action, StyledComponentProps, Variable } from '@darajs/core';
|
|
3
|
-
import { CausalGraph, EditorMode,
|
|
2
|
+
import { CausalGraph, EditorMode, GraphLegendDefinition, ZoomThresholds } from '@darajs/ui-causal-graph-editor';
|
|
4
3
|
import { GraphLayoutDefinition } from './graph-layout';
|
|
5
4
|
export interface CausalGraphViewerProps extends StyledComponentProps {
|
|
6
5
|
/** Optional additional legends to show */
|
|
7
|
-
additional_legends?:
|
|
6
|
+
additional_legends?: GraphLegendDefinition[];
|
|
8
7
|
/** Whether to allow node/edge selection even when editable = false */
|
|
9
8
|
allow_selection_when_not_editable?: boolean;
|
|
10
9
|
/** All available inputs; used to check which nodes are latent */
|
|
11
10
|
available_inputs?: string[];
|
|
12
11
|
/** The graph data to render */
|
|
13
12
|
causal_graph: Variable<CausalGraph> | CausalGraph;
|
|
13
|
+
/** Default legends dict for each editor mode available */
|
|
14
|
+
default_legends?: Record<EditorMode, GraphLegendDefinition[]>;
|
|
14
15
|
/** Flag for disabling edge addition */
|
|
15
16
|
disable_edge_add?: boolean;
|
|
16
17
|
/** Flag for disabling latent node addition */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"causal-graph-viewer.d.ts","sourceRoot":"","sources":["../../js/graphs/causal-graph-viewer.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"causal-graph-viewer.d.ts","sourceRoot":"","sources":["../../js/graphs/causal-graph-viewer.tsx"],"names":[],"mappings":"AAEA,OAAO,EACH,MAAM,EAEN,oBAAoB,EACpB,QAAQ,EAKX,MAAM,cAAc,CAAC;AAEtB,OAAO,EACH,WAAW,EACX,UAAU,EACV,qBAAqB,EAErB,cAAc,EACjB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,qBAAqB,EAAyB,MAAM,gBAAgB,CAAC;AAG9E,MAAM,WAAW,sBAAuB,SAAQ,oBAAoB;IAChE,0CAA0C;IAC1C,kBAAkB,CAAC,EAAE,qBAAqB,EAAE,CAAC;IAC7C,sEAAsE;IACtE,iCAAiC,CAAC,EAAE,OAAO,CAAC;IAC5C,iEAAiE;IACjE,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,+BAA+B;IAC/B,YAAY,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC;IAClD,0DAA0D;IAC1D,eAAe,CAAC,EAAE,MAAM,CAAC,UAAU,EAAE,qBAAqB,EAAE,CAAC,CAAC;IAC9D,uCAAuC;IACvC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,8CAA8C;IAC9C,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,sCAAsC;IACtC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,oBAAoB;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,wBAAwB;IACxB,WAAW,CAAC,EAAE,UAAU,CAAC;IACzB,qCAAqC;IACrC,YAAY,EAAE,qBAAqB,CAAC;IACpC,iDAAiD;IACjD,mBAAmB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpC,sDAAsD;IACtD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qDAAqD;IACrD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0FAA0F;IAC1F,gCAAgC,CAAC,EAAE,OAAO,CAAC;IAC3C,0EAA0E;IAC1E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+DAA+D;IAC/D,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,uEAAuE;IACvE,eAAe,CAAC,EAAE,cAAc,CAAC;CACpC;AAID;;;;;;GAMG;AACH,iBAAS,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,GAAG,GAAG,CAAC,OAAO,CA2DrE;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/* eslint-disable react-hooks/exhaustive-deps */
|
|
3
2
|
import { useMemo } from 'react';
|
|
4
3
|
import { Notifications, injectCss, useAction, useComponentStyles, useVariable, } from '@darajs/core';
|
|
4
|
+
import { useTheme } from '@darajs/styled-components';
|
|
5
5
|
import { CausalGraphViewer as UICausalGraphViewer, } from '@darajs/ui-causal-graph-editor';
|
|
6
6
|
import { parseLayoutDefinition } from './graph-layout';
|
|
7
|
+
import { transformLegendColor } from './utils';
|
|
7
8
|
const StyledGraphViewer = injectCss(UICausalGraphViewer);
|
|
8
9
|
/**
|
|
9
10
|
* A simple wrapper around the UICausalGraphViewer that calls into the Causalnet Extension to get the causal graph
|
|
@@ -15,11 +16,21 @@ const StyledGraphViewer = injectCss(UICausalGraphViewer);
|
|
|
15
16
|
function CausalGraphViewer(props) {
|
|
16
17
|
const { pushNotification } = Notifications.useNotifications();
|
|
17
18
|
const [style, css] = useComponentStyles(props);
|
|
19
|
+
const theme = useTheme();
|
|
18
20
|
const [graphData, setCausalGraphVariable] = useVariable(props.causal_graph);
|
|
19
21
|
const [onClickNode] = useAction(props.on_click_node);
|
|
20
22
|
const [onClickEdge] = useAction(props.on_click_edge);
|
|
21
23
|
const [onUpdate] = useAction(props.on_update);
|
|
22
|
-
const graphLayout = useMemo(() => parseLayoutDefinition(props.graph_layout), []);
|
|
24
|
+
const graphLayout = useMemo(() => parseLayoutDefinition(props.graph_layout), [props.graph_layout]);
|
|
25
|
+
const formattedDefaultLegends = useMemo(() => {
|
|
26
|
+
return Object.fromEntries(Object.entries(props.default_legends).map(([editorMode, defaultLegends]) => {
|
|
27
|
+
return [editorMode, defaultLegends.map((legend) => transformLegendColor(theme, legend))];
|
|
28
|
+
}));
|
|
29
|
+
}, [props.default_legends, theme]);
|
|
30
|
+
const formattedAdditionalLegends = useMemo(() => {
|
|
31
|
+
var _a;
|
|
32
|
+
return (_a = props.additional_legends) === null || _a === void 0 ? void 0 : _a.map((legend) => transformLegendColor(theme, legend));
|
|
33
|
+
}, [props.additional_legends, theme]);
|
|
23
34
|
const onGraphUpdate = (value) => {
|
|
24
35
|
setCausalGraphVariable(value);
|
|
25
36
|
onUpdate(value);
|
|
@@ -27,7 +38,7 @@ function CausalGraphViewer(props) {
|
|
|
27
38
|
if (!props.causal_graph) {
|
|
28
39
|
return null;
|
|
29
40
|
}
|
|
30
|
-
return (_jsx(StyledGraphViewer, { "$rawCss": css, additionalLegends:
|
|
41
|
+
return (_jsx(StyledGraphViewer, { "$rawCss": css, additionalLegends: formattedAdditionalLegends, allowSelectionWhenNotEditable: props.allow_selection_when_not_editable, availableInputs: props.available_inputs, defaultLegends: formattedDefaultLegends, disableEdgeAdd: props.disable_edge_add, disableLatentNodeAdd: props.disable_latent_node_add, disableNodeRemoval: props.disable_node_removal, editable: props.editable, editorMode: props.editor_mode, graphData: graphData, graphLayout: graphLayout, nonRemovableNodes: props.non_removable_nodes, onClickEdge: onClickEdge, onClickNode: onClickNode, onNotify: pushNotification, onUpdate: onGraphUpdate, simultaneousEdgeNodeSelection: props.simultaneous_edge_node_selection, style: style, tooltipSize: props.tooltip_size, verboseDescriptions: props.verbose_descriptions, zoomThresholds: props.zoom_thresholds }));
|
|
31
42
|
}
|
|
32
43
|
export default CausalGraphViewer;
|
|
33
44
|
//# sourceMappingURL=causal-graph-viewer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"causal-graph-viewer.js","sourceRoot":"","sources":["../../js/graphs/causal-graph-viewer.tsx"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"file":"causal-graph-viewer.js","sourceRoot":"","sources":["../../js/graphs/causal-graph-viewer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAEH,aAAa,EAGb,SAAS,EACT,SAAS,EACT,kBAAkB,EAClB,WAAW,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAIH,iBAAiB,IAAI,mBAAmB,GAE3C,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAyB,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AA2C/C,MAAM,iBAAiB,GAAG,SAAS,CAAC,mBAAmB,CAAC,CAAC;AAEzD;;;;;;GAMG;AACH,SAAS,iBAAiB,CAAC,KAA6B;IACpD,MAAM,EAAE,gBAAgB,EAAE,GAAG,aAAa,CAAC,gBAAgB,EAAE,CAAC;IAC9D,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,kBAAkB,CAAC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K,CAAC,CAAC,CAAC;IAEtC,MAAM,aAAa,GAAG,CAAC,KAAkB,EAAQ,EAAE;QAC/C,sBAAsB,CAAC,KAAK,CAAC,CAAC;QAC9B,QAAQ,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC,CAAC;IAEF,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,CACH,KAAC,iBAAiB,eACL,GAAG,EACZ,iBAAiB,EAAE,0BAA0B,EAC7C,6BAA6B,EAAE,KAAK,CAAC,iCAAiC,EACtE,eAAe,EAAE,KAAK,CAAC,gBAAgB,EACvC,cAAc,EAAE,uBAAuB,EACvC,cAAc,EAAE,KAAK,CAAC,gBAAgB,EACtC,oBAAoB,EAAE,KAAK,CAAC,uBAAuB,EACnD,kBAAkB,EAAE,KAAK,CAAC,oBAAoB,EAC9C,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,UAAU,EAAE,KAAK,CAAC,WAAW,EAC7B,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,iBAAiB,EAAE,KAAK,CAAC,mBAAmB,EAC5C,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,aAAa,EACvB,6BAA6B,EAAE,KAAK,CAAC,gCAAgC,EACrE,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,KAAK,CAAC,YAAY,EAC/B,mBAAmB,EAAE,KAAK,CAAC,oBAAoB,EAC/C,cAAc,EAAE,KAAK,CAAC,eAAe,GACvC,CACL,CAAC;AACN,CAAC;AAED,eAAe,iBAAiB,CAAC"}
|
package/dist/graphs/index.d.ts
CHANGED
|
@@ -3,5 +3,6 @@ export { default as CausalGraphViewer } from './causal-graph-viewer';
|
|
|
3
3
|
export { default as NodeHierarchyBuilder } from './node-hierarchy-builder';
|
|
4
4
|
export { default as VisualEdgeEncoder } from './visual-edge-encoder';
|
|
5
5
|
export { parseLayoutDefinition } from './graph-layout';
|
|
6
|
+
export { transformLegendColor } from './utils';
|
|
6
7
|
export type { GraphLayoutDefinition };
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../js/graphs/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE5D,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../js/graphs/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE5D,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAG/C,YAAY,EAAE,qBAAqB,EAAE,CAAC"}
|
package/dist/graphs/index.js
CHANGED
|
@@ -2,4 +2,5 @@ export { default as CausalGraphViewer } from './causal-graph-viewer';
|
|
|
2
2
|
export { default as NodeHierarchyBuilder } from './node-hierarchy-builder';
|
|
3
3
|
export { default as VisualEdgeEncoder } from './visual-edge-encoder';
|
|
4
4
|
export { parseLayoutDefinition } from './graph-layout';
|
|
5
|
+
export { transformLegendColor } from './utils';
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
package/dist/graphs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../js/graphs/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../js/graphs/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DefaultTheme } from '@darajs/styled-components';
|
|
2
|
+
import { GraphLegendDefinition } from '@darajs/ui-causal-graph-editor';
|
|
3
|
+
/**
|
|
4
|
+
* Tranform the color properties of a legend object to use the theme colors if necessary
|
|
5
|
+
*
|
|
6
|
+
* @param theme the currently active theme
|
|
7
|
+
* @param legend a legend object
|
|
8
|
+
*/
|
|
9
|
+
export declare function transformLegendColor(theme: DefaultTheme, legend: GraphLegendDefinition): GraphLegendDefinition;
|
|
10
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../js/graphs/utils.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAevE;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,qBAAqB,GAAG,qBAAqB,CAkB9G"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Based on a color string, return the color from the theme if it starts with 'theme.'
|
|
3
|
+
*
|
|
4
|
+
* @param theme the currently active theme
|
|
5
|
+
* @param colorString the string passed to the color property
|
|
6
|
+
*/
|
|
7
|
+
function getThemeColor(theme, colorString) {
|
|
8
|
+
if (colorString.startsWith('theme')) {
|
|
9
|
+
return theme.colors[colorString.replace('theme.', '')];
|
|
10
|
+
}
|
|
11
|
+
return colorString;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Tranform the color properties of a legend object to use the theme colors if necessary
|
|
15
|
+
*
|
|
16
|
+
* @param theme the currently active theme
|
|
17
|
+
* @param legend a legend object
|
|
18
|
+
*/
|
|
19
|
+
export function transformLegendColor(theme, legend) {
|
|
20
|
+
if (legend.type === 'edge') {
|
|
21
|
+
const transformedLegend = Object.assign(Object.assign({}, legend), { color: getThemeColor(theme, legend === null || legend === void 0 ? void 0 : legend.color) });
|
|
22
|
+
return transformedLegend;
|
|
23
|
+
}
|
|
24
|
+
if (legend.type === 'node') {
|
|
25
|
+
const transformedLegend = Object.assign(Object.assign({}, legend), { color: getThemeColor(theme, legend === null || legend === void 0 ? void 0 : legend.color), highlight_color: getThemeColor(theme, legend === null || legend === void 0 ? void 0 : legend.highlight_color) });
|
|
26
|
+
return transformedLegend;
|
|
27
|
+
}
|
|
28
|
+
// For 'spacer' we don't need to transform anything
|
|
29
|
+
return legend;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../js/graphs/utils.tsx"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,SAAS,aAAa,CAAC,KAAmB,EAAE,WAAmB;IAC3D,IAAI,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAClC,OAAO,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAiC,CAAC,CAAC;IAC3F,CAAC;IACD,OAAO,WAAW,CAAC;AACvB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAmB,EAAE,MAA6B;IACnF,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QACzB,MAAM,iBAAiB,mCAChB,MAAM,KACT,KAAK,EAAE,aAAa,CAAC,KAAK,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,GAC7C,CAAC;QACF,OAAO,iBAAiB,CAAC;IAC7B,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QACzB,MAAM,iBAAiB,mCAChB,MAAM,KACT,KAAK,EAAE,aAAa,CAAC,KAAK,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,EAC1C,eAAe,EAAE,aAAa,CAAC,KAAK,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,eAAe,CAAC,GACjE,CAAC;QACF,OAAO,iBAAiB,CAAC;IAC7B,CAAC;IACD,mDAAmD;IACnD,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { Action, StyledComponentProps, Variable } from '@darajs/core';
|
|
2
|
-
import { CausalGraphNode, EdgeConstraint, ZoomThresholds } from '@darajs/ui-causal-graph-editor';
|
|
2
|
+
import { CausalGraphNode, EdgeConstraint, EditorMode, GraphLegendDefinition, ZoomThresholds } from '@darajs/ui-causal-graph-editor';
|
|
3
3
|
import { GraphLayoutDefinition } from './graph-layout';
|
|
4
4
|
interface VisualEdgeEncoderProps extends StyledComponentProps {
|
|
5
|
+
/** Optional additional legends to show */
|
|
6
|
+
additional_legends?: GraphLegendDefinition[];
|
|
5
7
|
/** Whether to allow node/edge selection even when editable = false */
|
|
6
8
|
allow_selection_when_not_editable?: boolean;
|
|
9
|
+
/** Default legends dict for each editor mode available */
|
|
10
|
+
default_legends?: Record<EditorMode, GraphLegendDefinition[]>;
|
|
7
11
|
/** Allow editing */
|
|
8
12
|
editable?: boolean;
|
|
9
13
|
/** Graph layout definition object */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visual-edge-encoder.d.ts","sourceRoot":"","sources":["../../js/graphs/visual-edge-encoder.tsx"],"names":[],"mappings":"AAIA,OAAO,EACH,MAAM,EAEN,oBAAoB,EACpB,QAAQ,EAKX,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"visual-edge-encoder.d.ts","sourceRoot":"","sources":["../../js/graphs/visual-edge-encoder.tsx"],"names":[],"mappings":"AAIA,OAAO,EACH,MAAM,EAEN,oBAAoB,EACpB,QAAQ,EAKX,MAAM,cAAc,CAAC;AAEtB,OAAO,EAGH,eAAe,EAEf,cAAc,EAEd,UAAU,EACV,qBAAqB,EACrB,cAAc,EACjB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,qBAAqB,EAAyB,MAAM,gBAAgB,CAAC;AAG9E,UAAU,sBAAuB,SAAQ,oBAAoB;IACzD,0CAA0C;IAC1C,kBAAkB,CAAC,EAAE,qBAAqB,EAAE,CAAC;IAC7C,sEAAsE;IACtE,iCAAiC,CAAC,EAAE,OAAO,CAAC;IAC5C,0DAA0D;IAC1D,eAAe,CAAC,EAAE,MAAM,CAAC,UAAU,EAAE,qBAAqB,EAAE,CAAC,CAAC;IAC9D,oBAAoB;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qCAAqC;IACrC,YAAY,EAAE,qBAAqB,CAAC;IACpC,+BAA+B;IAC/B,mBAAmB,CAAC,EAAE,QAAQ,CAAC,cAAc,EAAE,CAAC,GAAG,cAAc,EAAE,CAAC;IACpE,sBAAsB;IACtB,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACzG,sDAAsD;IACtD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qDAAqD;IACrD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0EAA0E;IAC1E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,eAAe,CAAC,EAAE,cAAc,CAAC;CACpC;AA+CD;;;GAGG;AACH,iBAAS,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,GAAG,GAAG,CAAC,OAAO,CA0ErE;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -2,8 +2,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
4
|
import { Notifications, injectCss, useAction, useComponentStyles, useVariable, } from '@darajs/core';
|
|
5
|
+
import { useTheme } from '@darajs/styled-components';
|
|
5
6
|
import { CausalGraphViewer, EdgeType, EditorMode, } from '@darajs/ui-causal-graph-editor';
|
|
6
7
|
import { parseLayoutDefinition } from './graph-layout';
|
|
8
|
+
import { transformLegendColor } from './utils';
|
|
7
9
|
const StyledGraphEditor = injectCss(CausalGraphViewer);
|
|
8
10
|
/**
|
|
9
11
|
* Parse initially defined constraints.
|
|
@@ -47,12 +49,22 @@ function VisualEdgeEncoder(props) {
|
|
|
47
49
|
const [style, css] = useComponentStyles(props);
|
|
48
50
|
const [nodes] = useVariable(props.nodes);
|
|
49
51
|
const parsedNodes = useMemo(() => parseNodes(nodes), [nodes]);
|
|
52
|
+
const theme = useTheme();
|
|
50
53
|
const [initialConstraints] = useVariable(props.initial_constraints);
|
|
51
54
|
const parsedConstraints = useMemo(() => parseConstraints(initialConstraints), [initialConstraints]);
|
|
52
55
|
const graphLayout = useMemo(() => parseLayoutDefinition(props.graph_layout), []);
|
|
53
56
|
const [onClickEdge] = useAction(props.on_click_edge);
|
|
54
57
|
const [onClickNode] = useAction(props.on_click_node);
|
|
55
58
|
const [onUpdate] = useAction(props.on_update);
|
|
59
|
+
const formattedDefaultLegends = useMemo(() => {
|
|
60
|
+
return Object.fromEntries(Object.entries(props.default_legends).map(([editorMode, defaultLegends]) => {
|
|
61
|
+
return [editorMode, defaultLegends.map((legend) => transformLegendColor(theme, legend))];
|
|
62
|
+
}));
|
|
63
|
+
}, [props.default_legends, theme]);
|
|
64
|
+
const formattedAdditionalLegends = useMemo(() => {
|
|
65
|
+
var _a;
|
|
66
|
+
return (_a = props.additional_legends) === null || _a === void 0 ? void 0 : _a.map((legend) => transformLegendColor(theme, legend));
|
|
67
|
+
}, [props.additional_legends, theme]);
|
|
56
68
|
// Parse provided list of nodes into a graph data object that's understood by the graph editor
|
|
57
69
|
const graphData = useMemo(() => {
|
|
58
70
|
return {
|
|
@@ -76,7 +88,7 @@ function VisualEdgeEncoder(props) {
|
|
|
76
88
|
version: 'none', // doesn't matter as we don't output a whole graph
|
|
77
89
|
};
|
|
78
90
|
}, [parsedNodes, parsedConstraints]);
|
|
79
|
-
return (_jsx(StyledGraphEditor, { "$rawCss": css, allowSelectionWhenNotEditable: props.allow_selection_when_not_editable, editable: props.editable, editorMode: EditorMode.EDGE_ENCODER, graphData: graphData, graphLayout: graphLayout, initialConstraints: parsedConstraints, onClickEdge: onClickEdge, onClickNode: onClickNode, onEdgeConstraintsUpdate: onUpdate, onNotify: pushNotification, style: style, tooltipSize: props.tooltip_size, zoomThresholds: props.zoom_thresholds }));
|
|
91
|
+
return (_jsx(StyledGraphEditor, { "$rawCss": css, additionalLegends: formattedAdditionalLegends, allowSelectionWhenNotEditable: props.allow_selection_when_not_editable, defaultLegends: formattedDefaultLegends, editable: props.editable, editorMode: EditorMode.EDGE_ENCODER, graphData: graphData, graphLayout: graphLayout, initialConstraints: parsedConstraints, onClickEdge: onClickEdge, onClickNode: onClickNode, onEdgeConstraintsUpdate: onUpdate, onNotify: pushNotification, style: style, tooltipSize: props.tooltip_size, zoomThresholds: props.zoom_thresholds }));
|
|
80
92
|
}
|
|
81
93
|
export default VisualEdgeEncoder;
|
|
82
94
|
//# sourceMappingURL=visual-edge-encoder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visual-edge-encoder.js","sourceRoot":"","sources":["../../js/graphs/visual-edge-encoder.tsx"],"names":[],"mappings":";AAAA,gDAAgD;AAEhD,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAEH,aAAa,EAGb,SAAS,EACT,SAAS,EACT,kBAAkB,EAClB,WAAW,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAIH,iBAAiB,EAEjB,QAAQ,EACR,UAAU,
|
|
1
|
+
{"version":3,"file":"visual-edge-encoder.js","sourceRoot":"","sources":["../../js/graphs/visual-edge-encoder.tsx"],"names":[],"mappings":";AAAA,gDAAgD;AAEhD,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAEH,aAAa,EAGb,SAAS,EACT,SAAS,EACT,kBAAkB,EAClB,WAAW,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAIH,iBAAiB,EAEjB,QAAQ,EACR,UAAU,GAGb,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAyB,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO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