@eccenca/gui-elements 23.1.0-easynav.0 → 23.1.0-easynav.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/dist/cjs/components/Depiction/Depiction.js +13 -13
  3. package/dist/cjs/components/Depiction/Depiction.js.map +1 -1
  4. package/dist/cjs/extensions/react-flow/edges/EdgeDefault.js +20 -5
  5. package/dist/cjs/extensions/react-flow/edges/EdgeDefault.js.map +1 -1
  6. package/dist/cjs/extensions/react-flow/edges/EdgeLabel.js +74 -0
  7. package/dist/cjs/extensions/react-flow/edges/EdgeLabel.js.map +1 -0
  8. package/dist/cjs/extensions/react-flow/edges/edgeTypes.js +10 -9
  9. package/dist/cjs/extensions/react-flow/edges/edgeTypes.js.map +1 -1
  10. package/dist/cjs/extensions/react-flow/handles/HandleDefault.js +10 -2
  11. package/dist/cjs/extensions/react-flow/handles/HandleDefault.js.map +1 -1
  12. package/dist/cjs/extensions/react-flow/index.js +13 -3
  13. package/dist/cjs/extensions/react-flow/index.js.map +1 -1
  14. package/dist/cjs/extensions/react-flow/nodes/NodeContent.js +86 -15
  15. package/dist/cjs/extensions/react-flow/nodes/NodeContent.js.map +1 -1
  16. package/dist/cjs/extensions/react-flow/nodes/NodeDefault.js +2 -1
  17. package/dist/cjs/extensions/react-flow/nodes/NodeDefault.js.map +1 -1
  18. package/dist/cjs/extensions/react-flow/versionsupport.js +17 -0
  19. package/dist/cjs/extensions/react-flow/versionsupport.js.map +1 -1
  20. package/dist/esm/components/Depiction/Depiction.js +15 -14
  21. package/dist/esm/components/Depiction/Depiction.js.map +1 -1
  22. package/dist/esm/extensions/react-flow/edges/EdgeDefault.js +20 -4
  23. package/dist/esm/extensions/react-flow/edges/EdgeDefault.js.map +1 -1
  24. package/dist/esm/extensions/react-flow/edges/EdgeLabel.js +63 -0
  25. package/dist/esm/extensions/react-flow/edges/EdgeLabel.js.map +1 -0
  26. package/dist/esm/extensions/react-flow/edges/edgeTypes.js +10 -9
  27. package/dist/esm/extensions/react-flow/edges/edgeTypes.js.map +1 -1
  28. package/dist/esm/extensions/react-flow/handles/HandleDefault.js +10 -2
  29. package/dist/esm/extensions/react-flow/handles/HandleDefault.js.map +1 -1
  30. package/dist/esm/extensions/react-flow/index.js +2 -1
  31. package/dist/esm/extensions/react-flow/index.js.map +1 -1
  32. package/dist/esm/extensions/react-flow/nodes/NodeContent.js +94 -21
  33. package/dist/esm/extensions/react-flow/nodes/NodeContent.js.map +1 -1
  34. package/dist/esm/extensions/react-flow/nodes/NodeDefault.js +2 -1
  35. package/dist/esm/extensions/react-flow/nodes/NodeDefault.js.map +1 -1
  36. package/dist/esm/extensions/react-flow/versionsupport.js +31 -1
  37. package/dist/esm/extensions/react-flow/versionsupport.js.map +1 -1
  38. package/dist/types/extensions/react-flow/edges/EdgeDefault.d.ts +16 -1
  39. package/dist/types/extensions/react-flow/edges/EdgeLabel.d.ts +44 -0
  40. package/dist/types/extensions/react-flow/edges/edgeTypes.d.ts +10 -9
  41. package/dist/types/extensions/react-flow/index.d.ts +2 -2
  42. package/dist/types/extensions/react-flow/nodes/NodeContent.d.ts +40 -3
  43. package/dist/types/extensions/react-flow/versionsupport.d.ts +2 -1
  44. package/package.json +1 -1
  45. package/src/cmem/react-flow/ReactFlow/ReactFlow.stories.tsx +2 -2
  46. package/src/cmem/react-flow/_edges.scss +3 -2
  47. package/src/components/Depiction/Depiction.tsx +11 -10
  48. package/src/extensions/react-flow/_config.scss +8 -4
  49. package/src/extensions/react-flow/edges/EdgeDefault.tsx +60 -5
  50. package/src/extensions/react-flow/edges/EdgeLabel.tsx +127 -0
  51. package/src/extensions/react-flow/edges/_edges.scss +206 -31
  52. package/src/extensions/react-flow/edges/edgeTypes.ts +13 -9
  53. package/src/extensions/react-flow/edges/stories/EdgeDefault.stories.tsx +34 -13
  54. package/src/extensions/react-flow/edges/stories/EdgeLabel.stories.tsx +39 -0
  55. package/src/extensions/react-flow/handles/HandleDefault.tsx +18 -11
  56. package/src/extensions/react-flow/index.ts +3 -2
  57. package/src/extensions/react-flow/nodes/NodeContent.tsx +161 -26
  58. package/src/extensions/react-flow/nodes/NodeDefault.tsx +2 -2
  59. package/src/extensions/react-flow/nodes/_nodes.scss +220 -60
  60. package/src/extensions/react-flow/nodes/stories/NodeContent.stories.tsx +62 -1
  61. package/src/extensions/react-flow/versionsupport.ts +17 -1
@@ -1,2 +1,32 @@
1
- export {};
1
+ var __read = (this && this.__read) || function (o, n) {
2
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
3
+ if (!m) return o;
4
+ var i = m.call(o), r, ar = [], e;
5
+ try {
6
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
7
+ }
8
+ catch (error) { e = { error: error }; }
9
+ finally {
10
+ try {
11
+ if (r && !r.done && (m = i["return"])) m.call(i);
12
+ }
13
+ finally { if (e) throw e.error; }
14
+ }
15
+ return ar;
16
+ };
17
+ import { useStoreState as useStoreStateFlowLegacy } from "react-flow-renderer";
18
+ import { useStore as useStoreStateFlowNext } from "react-flow-renderer-lts";
19
+ export var useReactFlowVersion = function () {
20
+ try {
21
+ var _a = __read(useStoreStateFlowLegacy(function (state) { return state.transform; }), 3), zoom = _a[2];
22
+ return !!zoom ? "legacy" : "none";
23
+ }
24
+ catch (_b) { }
25
+ try {
26
+ var _c = __read(useStoreStateFlowNext(function (state) { return state.transform; }), 3), zoom = _c[2];
27
+ return !!zoom ? "next" : "none";
28
+ }
29
+ catch (_d) { }
30
+ return "none";
31
+ };
2
32
  //# sourceMappingURL=versionsupport.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"versionsupport.js","sourceRoot":"","sources":["../../../../src/extensions/react-flow/versionsupport.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"versionsupport.js","sourceRoot":"","sources":["../../../../src/extensions/react-flow/versionsupport.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,aAAa,IAAI,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,QAAQ,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAS5E,MAAM,CAAC,IAAM,mBAAmB,GAAG;IAC/B,IAAI;QACM,IAAA,KAAA,OAAa,uBAAuB,CAAC,UAAC,KAAK,IAAK,OAAA,KAAK,CAAC,SAAS,EAAf,CAAe,CAAC,IAAA,EAA3D,IAAI,QAAuD,CAAC;QACvE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;KACrC;IAAC,WAAM,GAAE;IACV,IAAI;QACM,IAAA,KAAA,OAAa,qBAAqB,CAAC,UAAC,KAAK,IAAK,OAAA,KAAK,CAAC,SAAS,EAAf,CAAe,CAAC,IAAA,EAAzD,IAAI,QAAqD,CAAC;QACrE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;KACnC;IAAC,WAAM,GAAE;IAEV,OAAO,MAAM,CAAC;AAClB,CAAC,CAAA"}
@@ -1,13 +1,27 @@
1
1
  import React from 'react';
2
2
  import { EdgeProps as ReactFlowEdgeProps } from "react-flow-renderer/dist/types";
3
+ import { IntentTypes } from "../../../common/Intent";
4
+ import { NodeHighlightColor } from "./../nodes/NodeContent";
3
5
  export interface EdgeDefaultDataProps {
6
+ /**
7
+ * Overwrites the default style how the edge stroke is displayed.
8
+ */
9
+ strokeType?: "solid" | "dashed" | "dotted" | "double" | "doubledashed";
10
+ /**
11
+ * Feedback state of the node.
12
+ */
13
+ intent?: IntentTypes;
14
+ /**
15
+ * Set the color of used highlights to mark the edge.
16
+ */
17
+ highlightColor?: NodeHighlightColor | [NodeHighlightColor, NodeHighlightColor];
4
18
  /**
5
19
  * Size of the "glow" effect when the edge is hovered.
6
20
  */
7
21
  pathGlowWidth?: number;
8
22
  inversePath?: boolean;
9
23
  /**
10
- * Reference linnk to the SVG marker used for the start of the edge
24
+ * Reference link to the SVG marker used for the start of the edge
11
25
  */
12
26
  markerStart?: string;
13
27
  /**
@@ -26,3 +40,4 @@ export interface EdgeDefaultProps extends ReactFlowEdgeProps {
26
40
  drawSvgPath?: (edge: ReactFlowEdgeProps) => string;
27
41
  }
28
42
  export declare const EdgeDefault: React.MemoExoticComponent<(edge: EdgeDefaultProps) => JSX.Element>;
43
+ export declare const createEdgeDefaultClassName: ({ strokeType, intent, highlightColor, }: EdgeDefaultDataProps, baseClass?: string) => string;
@@ -0,0 +1,44 @@
1
+ import React from "react";
2
+ import { DepictionProps } from "../../../index";
3
+ import { ValidIconName } from "../../../components/Icon/canonicalIconNames";
4
+ import { IntentTypes } from "../../../common/Intent";
5
+ export interface EdgeLabelProps extends React.HTMLAttributes<HTMLDivElement> {
6
+ /**
7
+ * Depiction element displayed left from the label.
8
+ */
9
+ depiction?: ValidIconName | React.ReactElement<DepictionProps>;
10
+ /**
11
+ * Label of the edge.
12
+ * Cannot overflow the parent container.
13
+ */
14
+ text: string | JSX.Element;
15
+ /**
16
+ * One or multiple other elements displayed right from label.
17
+ */
18
+ actions?: JSX.Element | JSX.Element[];
19
+ /**
20
+ * The element is increased in its size.
21
+ */
22
+ large?: boolean;
23
+ /**
24
+ * Stretches the label component to the full available width.
25
+ */
26
+ fullWidth?: boolean;
27
+ /**
28
+ * Add a info state to the label, visualized by color.
29
+ */
30
+ intent?: IntentTypes;
31
+ }
32
+ export declare const EdgeLabel: React.MemoExoticComponent<({ depiction, text, actions, large, fullWidth, intent, ...otherDivProps }: EdgeLabelProps) => JSX.Element>;
33
+ interface EdgeLabelObjectProps extends React.SVGAttributes<SVGForeignObjectElement> {
34
+ /**
35
+ * The `<EdgeLabel />` element that need to be displayed.
36
+ */
37
+ children: React.ReactElement<EdgeLabelProps>;
38
+ /**
39
+ * Property from the `renderLabel` callback method.
40
+ */
41
+ edgeCenter: [number, number, number, number];
42
+ }
43
+ export declare const EdgeLabelObject: React.MemoExoticComponent<({ children, edgeCenter, ...otherForeignObjectProps }: EdgeLabelObjectProps) => JSX.Element>;
44
+ export {};
@@ -3,13 +3,14 @@ export declare const edgeTypes: {
3
3
  default: import("react").MemoExoticComponent<(edge: import("./EdgeDefault").EdgeDefaultProps) => JSX.Element>;
4
4
  straight: import("react").MemoExoticComponent<(edge: import("./EdgeDefault").EdgeDefaultProps) => JSX.Element>;
5
5
  step: import("react").MemoExoticComponent<(edge: import("./EdgeStep").EdgeStepProps) => JSX.Element>;
6
- smoothstep: import("react").MemoExoticComponent<(edge: import("./EdgeStep").EdgeStepProps) => JSX.Element>;
7
- implicitEdge: import("react").MemoExoticComponent<(edge: import("./EdgeDefault").EdgeDefaultProps) => JSX.Element>;
8
- importEdge: import("react").MemoExoticComponent<(edge: import("./EdgeDefault").EdgeDefaultProps) => JSX.Element>;
9
- subclassEdge: import("react").MemoExoticComponent<(edge: import("./EdgeDefault").EdgeDefaultProps) => JSX.Element>;
10
- subpropertyEdge: import("react").MemoExoticComponent<(edge: import("./EdgeDefault").EdgeDefaultProps) => JSX.Element>;
11
- rdftypeEdge: import("react").MemoExoticComponent<(edge: import("./EdgeDefault").EdgeDefaultProps) => JSX.Element>;
12
- successStep: import("react").MemoExoticComponent<(edge: import("./EdgeStep").EdgeStepProps) => JSX.Element>;
13
- warningStep: import("react").MemoExoticComponent<(edge: import("./EdgeStep").EdgeStepProps) => JSX.Element>;
14
- dangerStep: import("react").MemoExoticComponent<(edge: import("./EdgeStep").EdgeStepProps) => JSX.Element>;
6
+ success: import("react").MemoExoticComponent<(edge: import("./EdgeDefault").EdgeDefaultProps) => JSX.Element>;
7
+ warning: import("react").MemoExoticComponent<(edge: import("./EdgeDefault").EdgeDefaultProps) => JSX.Element>;
8
+ danger: import("react").MemoExoticComponent<(edge: import("./EdgeDefault").EdgeDefaultProps) => JSX.Element>;
9
+ implicit: import("react").MemoExoticComponent<(edge: import("./EdgeDefault").EdgeDefaultProps) => JSX.Element>;
10
+ import: import("react").MemoExoticComponent<(edge: import("./EdgeDefault").EdgeDefaultProps) => JSX.Element>;
11
+ subclass: import("react").MemoExoticComponent<(edge: import("./EdgeDefault").EdgeDefaultProps) => JSX.Element>;
12
+ subproperty: import("react").MemoExoticComponent<(edge: import("./EdgeDefault").EdgeDefaultProps) => JSX.Element>;
13
+ rdftype: import("react").MemoExoticComponent<(edge: import("./EdgeDefault").EdgeDefaultProps) => JSX.Element>;
14
+ value: import("react").MemoExoticComponent<(edge: import("./EdgeStep").EdgeStepProps) => JSX.Element>;
15
+ score: import("react").MemoExoticComponent<(edge: import("./EdgeStep").EdgeStepProps) => JSX.Element>;
15
16
  };
@@ -3,10 +3,10 @@ export { NodeContent } from "./nodes/NodeContent";
3
3
  export { NodeContentExtension } from "./nodes/NodeContentExtension";
4
4
  export { NodeTools } from "./nodes/NodeTools";
5
5
  export { nodeTypes } from "./nodes/nodeTypes";
6
- export { EdgeDefault } from "./edges/EdgeDefault";
7
6
  export { EdgeStep } from "./edges/EdgeStep";
8
7
  export { EdgeTools } from "./edges/EdgeTools";
9
8
  export { edgeTypes } from "./edges/edgeTypes";
9
+ export * from "./edges/EdgeLabel";
10
10
  export { MarkerArrowClosedInverse } from "./markers/MarkerArrowClosedInverse";
11
11
  export { ReactFlowMarkers } from "./markers/ReactFlowMarkers";
12
12
  export { MiniMap } from "./minimap/MiniMap";
@@ -16,6 +16,6 @@ export type { NodeProps } from "./nodes/NodeDefault";
16
16
  export type { NodeContentProps } from "./nodes/NodeContent";
17
17
  export type { NodeContentExtensionProps } from "./nodes/NodeContentExtension";
18
18
  export type { NodeToolsProps } from "./nodes/NodeTools";
19
- export type { EdgeDefaultProps } from "./edges/EdgeDefault";
20
19
  export type { EdgeStepProps } from "./edges/EdgeStep";
21
20
  export type { MiniMapProps } from "./minimap/MiniMap";
21
+ export * from "./edges/EdgeDefault";
@@ -1,12 +1,15 @@
1
1
  import React from "react";
2
+ import Color from "color";
2
3
  import { Position } from "react-flow-renderer";
3
4
  import { ValidIconName } from "../../../components/Icon/canonicalIconNames";
4
5
  import { DepictionProps } from "../../../components/Depiction/Depiction";
6
+ import { IntentTypes } from "../../../common/Intent";
5
7
  import { ReacFlowVersionSupportProps } from "../versionsupport";
6
8
  import { HandleProps, HandleNextProps } from "./../handles/HandleDefault";
7
9
  import { NodeProps } from "./NodeDefault";
8
10
  import { NodeContentExtensionProps } from "./NodeContentExtension";
9
11
  export declare type HighlightingState = "success" | "warning" | "danger" | "match" | "altmatch";
12
+ export declare type NodeHighlightColor = "default" | "alternate" | Color | string;
10
13
  export interface IHandleProps extends HandleProps {
11
14
  category?: "configuration";
12
15
  }
@@ -35,7 +38,11 @@ interface NodeContentData<CONTENT_PROPS = any> {
35
38
  /**
36
39
  * Label that is displayed in the node header.
37
40
  */
38
- label: string;
41
+ label: string | JSX.Element;
42
+ /**
43
+ * Element that is displayed as subline under the label in the header.
44
+ */
45
+ labelSubline?: JSX.Element;
39
46
  /**
40
47
  * Content element, displayed in the node body.
41
48
  */
@@ -61,9 +68,35 @@ export interface NodeContentProps<NODE_DATA, NODE_CONTENT_PROPS = any> extends N
61
68
  */
62
69
  minimalShape?: "none" | "circular" | "rectangular";
63
70
  /**
71
+ * Stretches the node to the full available width.
72
+ */
73
+ fullWidth?: boolean;
74
+ /**
75
+ * Increase the hight of the node header.
76
+ * Use this for example if you need more space for a label subline.
77
+ * Also the depiction is displayed larger.
78
+ */
79
+ enlargeHeader?: boolean;
80
+ /**
81
+ * @deprecated
64
82
  * Set the type of used highlights to mark the node.
83
+ * Replaced by `intent` and `highlightColor` properties.
65
84
  */
66
85
  highlightedState?: HighlightingState | HighlightingState[];
86
+ /**
87
+ * Defines how the borders of a node are displayed.
88
+ * Use this property to overwrite default styles.
89
+ * You can use this to visuaize different states or type without depending only on color.
90
+ */
91
+ border?: "solid" | "double" | "dashed" | "dotted";
92
+ /**
93
+ * Feedback state of the node.
94
+ */
95
+ intent?: IntentTypes;
96
+ /**
97
+ * Set the type of used highlights to mark the node.
98
+ */
99
+ highlightColor?: NodeHighlightColor | [NodeHighlightColor, NodeHighlightColor];
67
100
  /**
68
101
  * Text used for tooltip used on icon and depiction.
69
102
  */
@@ -144,10 +177,14 @@ export interface NodeContentProps<NODE_DATA, NODE_CONTENT_PROPS = any> extends N
144
177
  */
145
178
  nodeDimensions?: NodeDimensions;
146
179
  }
147
- export declare const gethighlightedStateClasses: (state: any, baseClassName: any) => any;
180
+ export declare const gethighlightedStateClasses: (state: HighlightingState | HighlightingState[], baseClassName: string) => string;
148
181
  /**
149
182
  * The `NodeContent` element manages the main view of how a node is displaying which content.
150
183
  * This element cannot be used directly, all properties must be routed through the `data` property of an `elements` property item inside the `ReactFlow` container.
151
184
  */
152
- export declare function NodeContent<CONTENT_PROPS = any>({ flowVersion, iconName, depiction, leftElement, typeLabel, label, showExecutionButtons, executionButtons, menuButtons, content, contentExtension, footerContent, size, minimalShape, highlightedState, handles, adaptHeightForHandleMinCount, adaptSizeIncrement, getMinimalTooltipData, style, showUnconnectableHandles, animated, onNodeResize, nodeDimensions, targetPosition, sourcePosition, isConnectable, selected, letPassWheelEvents, businessData, ...otherProps }: NodeContentProps<any>): JSX.Element;
185
+ export declare function NodeContent<CONTENT_PROPS = any>({ flowVersion, iconName, depiction, leftElement, typeLabel, label, labelSubline, enlargeHeader, fullWidth, showExecutionButtons, executionButtons, menuButtons, content, contentExtension, footerContent, size, minimalShape, highlightedState, intent, border, highlightColor, handles, adaptHeightForHandleMinCount, adaptSizeIncrement, getMinimalTooltipData, style, showUnconnectableHandles, animated, onNodeResize, nodeDimensions, targetPosition, sourcePosition, isConnectable, selected, letPassWheelEvents, businessData, ...otherProps }: NodeContentProps<any>): JSX.Element;
186
+ export declare const evaluateHighlightColors: (baseCustomProperty: string, highlightColor?: NodeHighlightColor | NodeHighlightColor[] | undefined) => {
187
+ highlightClassNameSuffix: string[];
188
+ highlightCustomPropertySettings: React.CSSProperties;
189
+ };
153
190
  export {};
@@ -2,5 +2,6 @@ export interface ReacFlowVersionSupportProps {
2
2
  /**
3
3
  * Spevifies the context of the react flow renderer version that is used for the component.
4
4
  */
5
- flowVersion?: "legacy" | "next";
5
+ flowVersion?: "legacy" | "next" | "none";
6
6
  }
7
+ export declare const useReactFlowVersion: () => "none" | "legacy" | "next";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@eccenca/gui-elements",
3
3
  "description": "GUI elements based on other libraries, usable in React application, written in Typescript.",
4
- "version": "23.1.0-easynav.0",
4
+ "version": "23.1.0-easynav.2",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/eccenca/gui-elements",
7
7
  "bugs": "https://github.com/eccenca/gui-elements/issues",
@@ -125,8 +125,8 @@ const nodeExamples = {
125
125
  },
126
126
  position: { x: 50, y: 300 },
127
127
  },
128
- { id: 'workflow-e1', arrowHeadType: "arrowclosed",source: 'workflow-1', target: 'workflow-2' },
129
- { id: 'workflow-e2', arrowHeadType: "arrowclosed",source: 'workflow-2', target: 'workflow-3' },
128
+ { id: 'workflow-e1', label: "default", arrowHeadType: "arrowclosed",source: 'workflow-1', target: 'workflow-2' },
129
+ { id: 'workflow-e2', label: "default", arrowHeadType: "arrowclosed",source: 'workflow-2', target: 'workflow-3' },
130
130
  { id: 'workflow-e3', type: 'success', label: "success edge", arrowHeadType: "arrowclosed",source: 'workflow-3', target: 'workflow-4' },
131
131
  { id: 'workflow-e4', type: 'warning', label: "warning edge", arrowHeadType: "arrowclosed",source: 'workflow-4', target: 'workflow-5' },
132
132
  { id: 'workflow-e5', type: 'danger', label: "danger edge", arrowHeadType: "arrowclosed",source: 'workflow-5', target: 'workflow-1' },
@@ -5,8 +5,9 @@
5
5
  }
6
6
 
7
7
  @mixin edgecoloring($color) {
8
- stroke: $color;
9
- color: $color;
8
+ --#{$eccgui}-reactflow-node-color-default: #{$color};
9
+ --#{$eccgui}-reactflow-node-color-hover: #{$color};
10
+ --#{$eccgui}-reactflow-node-color-selected: #{$color};
10
11
  }
11
12
 
12
13
  // Graph edge types
@@ -92,18 +92,18 @@ export function Depiction({
92
92
  }: DepictionProps) {
93
93
  const containerRef = useRef<HTMLDivElement>(null);
94
94
 
95
- useEffect(() => {
96
- if (!!backgroundColor && backgroundColor !== "light" && backgroundColor !== "dark") {
97
- let color = Color("#ffffff")
98
- try {
99
- color = Color(backgroundColor);
100
- } catch(ex) {
101
- console.warn("Received invalid background color for depiction: " + backgroundColor)
95
+ let styleDepictionColors = {};
96
+ if (!!backgroundColor && backgroundColor !== "light" && backgroundColor !== "dark") {
97
+ try {
98
+ const color = Color(backgroundColor);
99
+ styleDepictionColors = {
100
+ [`--${eccgui}-depiction-background`]: color.rgb().toString(),
101
+ [`--${eccgui}-depiction-color`]: decideContrastColorValue({testColor: color})
102
102
  }
103
- containerRef.current!.style.setProperty(`--${eccgui}-depiction-background`, color.rgb().toString());
104
- containerRef.current!.style.setProperty(`--${eccgui}-depiction-color`, decideContrastColorValue({testColor: color}));
103
+ } catch(ex) {
104
+ console.warn("Received invalid background color for depiction: " + backgroundColor)
105
105
  }
106
- }, [backgroundColor]);
106
+ }
107
107
 
108
108
  const updateSvgResizing = React.useCallback((el: SVGElement) => {
109
109
  let preserveAspectRatio = "";
@@ -164,6 +164,7 @@ export function Depiction({
164
164
  (rounded ? ` ${eccgui}-depiction__image--roundedborder` : '') +
165
165
  (padding && padding !== "none" ? ` ${eccgui}-depiction__image--padding-${padding}` : '')
166
166
  }
167
+ style={styleDepictionColors as React.CSSProperties}
167
168
  >
168
169
  {depiction}
169
170
  </div>
@@ -1,16 +1,20 @@
1
1
  $reactflow-node-basesize: $button-height !default;
2
+ $reactflow-node-largesize: mini-units(6) !default;
2
3
  $reactflow-node-border-color: $eccgui-color-workspace-text !default;
3
4
  $reactflow-node-background-color: $button-background-color !default;
4
5
  $reactflow-node-color: $eccgui-color-workspace-text !default;
5
6
  $reactflow-node-font-size: $eccgui-size-typo-caption !default;
6
7
  $reactflow-node-border-width: 2 * $button-border-width !default;
7
8
  $reactflow-node-border-radius: $button-border-radius !default;
8
- $reactflow-edge-stroke-color: rgba($eccgui-color-workspace-text, .61) !default;
9
+
10
+ $reactflow-edge-stroke-opacity-default: 0.6 !default;
11
+ $reactflow-edge-stroke-opacity-hover: 0.8 !default;
12
+ $reactflow-edge-stroke-opacity-selected: 1 !default;
13
+ $reactflow-edge-stroke-color-default: $eccgui-color-workspace-text !default;
9
14
  $reactflow-edge-stroke-color-hover: $eccgui-color-workspace-text !default;
10
15
  $reactflow-edge-stroke-color-selected: $eccgui-color-accent !default;
16
+
11
17
  $reactflow-transition-time: 0.25s !default;
12
18
  $reactflow-transition-function: "" !default;
13
19
 
14
- $reactflow-edge-stroke-opacity: alpha($reactflow-edge-stroke-color) !default;
15
- $reactflow-edge-stroke-opacity-hover: alpha($reactflow-edge-stroke-color) !default;
16
- $reactflow-edge-stroke-opacity-selected: alpha($reactflow-edge-stroke-color) !default;
20
+ $reactflow-transition-anglestart: 270deg;
@@ -7,9 +7,24 @@ import {
7
7
  getEdgeCenter,
8
8
  EdgeText,
9
9
  } from "react-flow-renderer";
10
+ import { CLASSPREFIX as eccgui } from "../../../configuration/constants";
11
+ import { IntentTypes, intentClassName } from "../../../common/Intent";
12
+ import { NodeHighlightColor, evaluateHighlightColors } from "./../nodes/NodeContent";
10
13
  import { drawEdgeStraight} from "./utils";
11
14
 
12
15
  export interface EdgeDefaultDataProps {
16
+ /**
17
+ * Overwrites the default style how the edge stroke is displayed.
18
+ */
19
+ strokeType?: "solid" | "dashed" | "dotted" | "double" | "doubledashed";
20
+ /**
21
+ * Feedback state of the node.
22
+ */
23
+ intent?: IntentTypes;
24
+ /**
25
+ * Set the color of used highlights to mark the edge.
26
+ */
27
+ highlightColor?: NodeHighlightColor | [NodeHighlightColor, NodeHighlightColor];
13
28
  /**
14
29
  * Size of the "glow" effect when the edge is hovered.
15
30
  */
@@ -20,7 +35,7 @@ export interface EdgeDefaultDataProps {
20
35
  */
21
36
  inversePath?: boolean;
22
37
  /**
23
- * Reference linnk to the SVG marker used for the start of the edge
38
+ * Reference link to the SVG marker used for the start of the edge
24
39
  */
25
40
  markerStart?: string;
26
41
  /**
@@ -49,7 +64,10 @@ export const EdgeDefault = memo(
49
64
  } = edge;
50
65
  const {
51
66
  pathGlowWidth = 10,
52
- markerStart
67
+ markerStart,
68
+ strokeType,
69
+ intent,
70
+ highlightColor,
53
71
  } = data;
54
72
 
55
73
  const pathDisplay = drawSvgPath({...edgeOriginalProperties, data});
@@ -78,18 +96,38 @@ export const EdgeDefault = memo(
78
96
  ) : null);
79
97
 
80
98
  const edgeStyle = edgeOriginalProperties.style ?? {};
99
+ const {
100
+ highlightCustomPropertySettings
101
+ } = evaluateHighlightColors("--edge-highlight", highlightColor);
102
+
81
103
  return (
82
- <g style={{...edgeStyle, color: edgeStyle.color || edgeStyle.stroke}}>
104
+ <g
105
+ className={createEdgeDefaultClassName({intent}, "")}
106
+ style={{
107
+ ...edgeStyle,
108
+ color: edgeStyle.color || edgeStyle.stroke
109
+ }}
110
+ >
111
+ { highlightColor && (
112
+ <path
113
+ d={pathDisplay}
114
+ className={createEdgeDefaultClassName({highlightColor}, "react-flow__edge-path-highlight")}
115
+ strokeWidth={pathGlowWidth}
116
+ style={{
117
+ ...highlightCustomPropertySettings,
118
+ }}
119
+ />
120
+ )}
83
121
  { pathGlowWidth && (
84
122
  <path
85
123
  d={pathDisplay}
86
- className="react-flow__edge-path-glow"
124
+ className={createEdgeDefaultClassName({}, "react-flow__edge-path-glow")}
87
125
  strokeWidth={pathGlowWidth}
88
126
  />
89
127
  )}
90
128
  <path
91
129
  d={pathDisplay}
92
- className="react-flow__edge-path"
130
+ className={createEdgeDefaultClassName({strokeType})}
93
131
  markerStart={markerStart}
94
132
  markerEnd={markerEnd}
95
133
  />
@@ -98,3 +136,20 @@ export const EdgeDefault = memo(
98
136
  );
99
137
  }
100
138
  );
139
+
140
+ export const createEdgeDefaultClassName = ({
141
+ strokeType,
142
+ intent,
143
+ highlightColor,
144
+ }: EdgeDefaultDataProps, baseClass: string = "react-flow__edge-path") => {
145
+ const {
146
+ highlightClassNameSuffix,
147
+ } = evaluateHighlightColors("--edge-highlight", highlightColor);
148
+ return baseClass +
149
+ (strokeType ? ` ${baseClass}--stroke-${strokeType}` : "") +
150
+ (intent ? ` ${intentClassName(intent)}` : "") +
151
+ (highlightClassNameSuffix.length > 0
152
+ ? highlightClassNameSuffix.map(highlight => ` ${eccgui}-graphviz__edge--highlight-${highlight}`).join("")
153
+ : ""
154
+ );
155
+ }
@@ -0,0 +1,127 @@
1
+ import React, { memo, useEffect, useRef } from "react";
2
+ import { Icon, Depiction, DepictionProps, OverflowText } from "../../../index";
3
+ import { CLASSPREFIX as eccgui } from "../../../configuration/constants";
4
+ import { ValidIconName } from "../../../components/Icon/canonicalIconNames";
5
+ import { IntentTypes, intentClassName } from "../../../common/Intent";
6
+
7
+ export interface EdgeLabelProps extends React.HTMLAttributes<HTMLDivElement> {
8
+ /**
9
+ * Depiction element displayed left from the label.
10
+ */
11
+ depiction?: ValidIconName | React.ReactElement<DepictionProps>;
12
+ /**
13
+ * Label of the edge.
14
+ * Cannot overflow the parent container.
15
+ */
16
+ text: string | JSX.Element;
17
+ /**
18
+ * One or multiple other elements displayed right from label.
19
+ */
20
+ actions?: JSX.Element | JSX.Element[];
21
+ /**
22
+ * The element is increased in its size.
23
+ */
24
+ large?: boolean;
25
+ /**
26
+ * Stretches the label component to the full available width.
27
+ */
28
+ fullWidth?: boolean;
29
+ /**
30
+ * Add a info state to the label, visualized by color.
31
+ */
32
+ intent?: IntentTypes;
33
+ }
34
+
35
+ export const EdgeLabel = memo(({
36
+ depiction,
37
+ text,
38
+ actions,
39
+ large,
40
+ fullWidth,
41
+ intent,
42
+ ...otherDivProps
43
+ } : EdgeLabelProps) => {
44
+
45
+ const depEl = (!!depiction && typeof depiction === "string")
46
+ ? <Depiction image={<Icon name={depiction as ValidIconName} />} />
47
+ : depiction;
48
+
49
+ return (
50
+ <div
51
+ className={
52
+ `${eccgui}-graphviz__edge-label` +
53
+ (large ? ` ${eccgui}-graphviz__edge-label--large` : "") +
54
+ (fullWidth ? ` ${eccgui}-graphviz__edge-label--fullwidth` : "") +
55
+ (!!intent ? ` ${intentClassName(intent)}` : '')
56
+ }
57
+ {...otherDivProps}
58
+ >
59
+ {!!depEl && (
60
+ <div className={`${eccgui}-graphviz__edge-label__depiction`}>
61
+ {
62
+ React.cloneElement(depEl, {
63
+ padding: "tiny",
64
+ ratio: "1:1",
65
+ resizing: "contain",
66
+ forceInlineSvg: true,
67
+ border: false,
68
+ backgroundColor: undefined,
69
+ })
70
+ }
71
+ </div>
72
+ )}
73
+ <div className={`${eccgui}-graphviz__edge-label__text`}>
74
+ { typeof text === "string" ? <OverflowText>{ text }</OverflowText> : text }
75
+ </div>
76
+ {!!actions && (
77
+ <div className={`${eccgui}-graphviz__edge-label__aux`}>
78
+ { actions }
79
+ </div>
80
+ )}
81
+ </div>
82
+ )
83
+ });
84
+
85
+ interface EdgeLabelObjectProps extends React.SVGAttributes<SVGForeignObjectElement> {
86
+ /**
87
+ * The `<EdgeLabel />` element that need to be displayed.
88
+ */
89
+ children: React.ReactElement<EdgeLabelProps>;
90
+ /**
91
+ * Property from the `renderLabel` callback method.
92
+ */
93
+ edgeCenter: [number, number, number, number];
94
+ }
95
+
96
+ export const EdgeLabelObject = memo(({
97
+ children,
98
+ edgeCenter,
99
+ ...otherForeignObjectProps
100
+ } : EdgeLabelObjectProps) => {
101
+ const containerRef = useRef<SVGForeignObjectElement>(null);
102
+
103
+ useEffect(() => {
104
+ const labelElement = containerRef.current!.getElementsByClassName(`${eccgui}-graphviz__edge-label`);
105
+ if (labelElement.length > 0) {
106
+ const width = (labelElement[0] as HTMLElement).offsetWidth;
107
+ const height = (labelElement[0] as HTMLElement).offsetHeight;
108
+ containerRef.current!.setAttribute("width", width.toString());
109
+ containerRef.current!.setAttribute("height", height.toString());
110
+ containerRef.current!.setAttribute("x", (edgeCenter[0] - width/2).toString());
111
+ containerRef.current!.setAttribute("y", (edgeCenter[1] - height/2).toString());
112
+ }
113
+ })
114
+
115
+ return (
116
+ <foreignObject
117
+ ref={containerRef}
118
+ className={`${eccgui}-graphviz__edge-labelobject`}
119
+ width="1"
120
+ height="1"
121
+ {...otherForeignObjectProps}
122
+ requiredExtensions="http://www.w3.org/1999/xhtml"
123
+ >
124
+ { children }
125
+ </foreignObject>
126
+ )
127
+ });