@eccenca/gui-elements 23.3.0-rc.0 → 23.3.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/CHANGELOG.md +39 -19
- package/dist/cjs/common/index.js +5 -2
- package/dist/cjs/common/index.js.map +1 -1
- package/dist/cjs/common/utils/globalVars.js +21 -0
- package/dist/cjs/common/utils/globalVars.js.map +1 -0
- package/dist/cjs/components/ContextOverlay/ContextOverlay.js +3 -2
- package/dist/cjs/components/ContextOverlay/ContextOverlay.js.map +1 -1
- package/dist/cjs/components/Dialog/Modal.js +20 -2
- package/dist/cjs/components/Dialog/Modal.js.map +1 -1
- package/dist/cjs/components/Icon/canonicalIconNames.js +4 -0
- package/dist/cjs/components/Icon/canonicalIconNames.js.map +1 -1
- package/dist/cjs/components/Table/TableExpandHeader.js +7 -8
- package/dist/cjs/components/Table/TableExpandHeader.js.map +1 -1
- package/dist/cjs/extensions/react-flow/edges/EdgeLabel.js +10 -9
- package/dist/cjs/extensions/react-flow/edges/EdgeLabel.js.map +1 -1
- package/dist/cjs/extensions/react-flow/handles/HandleContent.js +4 -4
- package/dist/cjs/extensions/react-flow/handles/HandleContent.js.map +1 -1
- package/dist/cjs/extensions/react-flow/handles/HandleDefault.js +62 -24
- package/dist/cjs/extensions/react-flow/handles/HandleDefault.js.map +1 -1
- package/dist/cjs/extensions/react-flow/handles/HandleTools.js +16 -2
- package/dist/cjs/extensions/react-flow/handles/HandleTools.js.map +1 -1
- package/dist/cjs/extensions/react-flow/nodes/NodeContent.js +17 -8
- package/dist/cjs/extensions/react-flow/nodes/NodeContent.js.map +1 -1
- package/dist/esm/common/index.js +5 -2
- package/dist/esm/common/index.js.map +1 -1
- package/dist/esm/common/utils/globalVars.js +16 -0
- package/dist/esm/common/utils/globalVars.js.map +1 -0
- package/dist/esm/components/ContextOverlay/ContextOverlay.js +5 -4
- package/dist/esm/components/ContextOverlay/ContextOverlay.js.map +1 -1
- package/dist/esm/components/Dialog/Modal.js +20 -2
- package/dist/esm/components/Dialog/Modal.js.map +1 -1
- package/dist/esm/components/Icon/canonicalIconNames.js +4 -0
- package/dist/esm/components/Icon/canonicalIconNames.js.map +1 -1
- package/dist/esm/components/Table/TableExpandHeader.js +7 -8
- package/dist/esm/components/Table/TableExpandHeader.js.map +1 -1
- package/dist/esm/extensions/react-flow/edges/EdgeLabel.js +10 -9
- package/dist/esm/extensions/react-flow/edges/EdgeLabel.js.map +1 -1
- package/dist/esm/extensions/react-flow/handles/HandleContent.js +16 -5
- package/dist/esm/extensions/react-flow/handles/HandleContent.js.map +1 -1
- package/dist/esm/extensions/react-flow/handles/HandleDefault.js +62 -24
- package/dist/esm/extensions/react-flow/handles/HandleDefault.js.map +1 -1
- package/dist/esm/extensions/react-flow/handles/HandleTools.js +32 -2
- package/dist/esm/extensions/react-flow/handles/HandleTools.js.map +1 -1
- package/dist/esm/extensions/react-flow/nodes/NodeContent.js +17 -8
- package/dist/esm/extensions/react-flow/nodes/NodeContent.js.map +1 -1
- package/dist/types/common/index.d.ts +4 -0
- package/dist/types/common/utils/globalVars.d.ts +2 -0
- package/dist/types/components/ContextOverlay/ContextOverlay.d.ts +7 -2
- package/dist/types/components/Dialog/Modal.d.ts +11 -3
- package/dist/types/components/Icon/canonicalIconNames.d.ts +1 -1
- package/dist/types/components/Table/TableExpandHeader.d.ts +5 -1
- package/dist/types/extensions/react-flow/edges/EdgeLabel.d.ts +7 -3
- package/dist/types/extensions/react-flow/handles/HandleContent.d.ts +7 -2
- package/dist/types/extensions/react-flow/handles/HandleDefault.d.ts +13 -4
- package/dist/types/extensions/react-flow/handles/HandleTools.d.ts +2 -1
- package/dist/types/extensions/react-flow/nodes/NodeContent.d.ts +3 -7
- package/package.json +8 -7
- package/src/common/index.ts +6 -3
- package/src/common/utils/globalVars.ts +18 -0
- package/src/components/Application/application.scss +7 -9
- package/src/components/ContextOverlay/ContextOverlay.tsx +20 -12
- package/src/components/ContextOverlay/contextoverlay.scss +8 -0
- package/src/components/Dialog/Modal.tsx +35 -3
- package/src/components/Dialog/dialog.scss +4 -0
- package/src/components/Icon/canonicalIconNames.tsx +9 -0
- package/src/components/PropertyValuePair/propertyvalue.scss +1 -0
- package/src/components/Table/TableExpandHeader.tsx +21 -18
- package/src/configuration/_variables.scss +27 -36
- package/src/extensions/react-flow/edges/EdgeLabel.tsx +78 -81
- package/src/extensions/react-flow/edges/_edges.scss +62 -67
- package/src/extensions/react-flow/handles/HandleContent.tsx +14 -13
- package/src/extensions/react-flow/handles/HandleDefault.tsx +127 -44
- package/src/extensions/react-flow/handles/HandleTools.tsx +28 -4
- package/src/extensions/react-flow/handles/_handles.scss +86 -21
- package/src/extensions/react-flow/handles/stories/HandleDefault.stories.tsx +41 -3
- package/src/extensions/react-flow/nodes/NodeContent.tsx +35 -30
- package/src/extensions/react-flow/nodes/stories/NodeContent.stories.tsx +75 -52
- package/src/extensions/react-flow/nodes/stories/NodeDefault.stories.tsx +4 -4
- package/src/extensions/react-flow/nodes/stories/nodeTypes.ts +11 -0
|
@@ -1,63 +1,128 @@
|
|
|
1
|
+
$eccgui-size-flow-handle: $eccgui-size-block-whitespace * 0.7;
|
|
2
|
+
$eccgui-size-flow-handle-border: $eccgui-size-flow-handle * 0.4;
|
|
3
|
+
|
|
1
4
|
div.react-flow__handle {
|
|
2
5
|
z-index: 2;
|
|
3
|
-
width: $eccgui-size-
|
|
4
|
-
height: $eccgui-size-
|
|
6
|
+
width: $eccgui-size-flow-handle;
|
|
7
|
+
height: $eccgui-size-flow-handle;
|
|
5
8
|
color: $reactflow-node-border-color;
|
|
6
9
|
background-color: currentcolor;
|
|
7
|
-
border
|
|
10
|
+
border: 2px solid currentcolor;
|
|
8
11
|
border-radius: 100%;
|
|
9
12
|
|
|
13
|
+
&.eccgui-intent--primary {
|
|
14
|
+
color: $eccgui-color-primary;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&.eccgui-intent--accent {
|
|
18
|
+
color: $eccgui-color-accent;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&.eccgui-intent--success {
|
|
22
|
+
color: $eccgui-color-success-text;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&.eccgui-intent--info {
|
|
26
|
+
color: $eccgui-color-info-text;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&.eccgui-intent--warning {
|
|
30
|
+
color: $eccgui-color-warning-text;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&.eccgui-intent--danger {
|
|
34
|
+
color: $eccgui-color-danger-text;
|
|
35
|
+
}
|
|
36
|
+
|
|
10
37
|
.react-flow__node-default & {
|
|
11
38
|
background-color: currentcolor;
|
|
12
39
|
}
|
|
13
40
|
|
|
14
41
|
&::before {
|
|
15
42
|
position: absolute;
|
|
16
|
-
inset: $eccgui-size-
|
|
17
|
-
z-index: 1;
|
|
43
|
+
inset: $eccgui-size-flow-handle * -0.75;
|
|
44
|
+
z-index: -1;
|
|
18
45
|
display: none;
|
|
19
46
|
content: " ";
|
|
20
|
-
background-color:
|
|
21
|
-
border: solid
|
|
47
|
+
background-color: transparent;
|
|
48
|
+
border: solid $eccgui-size-flow-handle * 0.75 currentcolor;
|
|
22
49
|
border-radius: 100%;
|
|
23
50
|
opacity: 0.61;
|
|
24
51
|
}
|
|
25
52
|
|
|
26
|
-
|
|
53
|
+
&:is(
|
|
54
|
+
// Polyfill for FF that does not support the `:has()` pseudo selector until at least version 119 or 120
|
|
55
|
+
// usally `&:has(.#{$eccgui}-graphviz__handletools-target)` should be enough
|
|
56
|
+
// need to be re-evaluated then
|
|
57
|
+
.ffpolyfill-has-#{$eccgui}-graphviz__handletools-target,
|
|
58
|
+
div:has(.#{$eccgui}-graphviz__handletools-target)
|
|
59
|
+
) {
|
|
27
60
|
&::after {
|
|
28
61
|
position: absolute;
|
|
29
|
-
inset:
|
|
30
|
-
z-index: -1;
|
|
62
|
+
inset: 0;
|
|
31
63
|
display: none;
|
|
32
64
|
cursor: pointer;
|
|
33
65
|
content: " ";
|
|
34
66
|
border-radius: 100%;
|
|
35
|
-
outline: dotted $eccgui-size-
|
|
67
|
+
outline: dotted $eccgui-size-flow-handle-border currentcolor;
|
|
68
|
+
outline-offset: $eccgui-size-flow-handle * 0.75 + $eccgui-size-flow-handle-border * 0.5;
|
|
69
|
+
|
|
70
|
+
.react-flow__node:hover & {
|
|
71
|
+
display: block;
|
|
72
|
+
}
|
|
36
73
|
}
|
|
37
74
|
}
|
|
38
75
|
|
|
39
76
|
&:hover {
|
|
40
77
|
&::before {
|
|
41
|
-
box-shadow: 0 0 $eccgui-size-
|
|
78
|
+
box-shadow: 0 0 $eccgui-size-flow-handle $eccgui-size-flow-handle * 0.5 currentcolor;
|
|
42
79
|
}
|
|
43
80
|
}
|
|
44
81
|
|
|
45
|
-
|
|
82
|
+
&[data-category="configuration"] {
|
|
46
83
|
border-radius: 0;
|
|
47
84
|
|
|
85
|
+
&::after,
|
|
48
86
|
&::before {
|
|
49
87
|
border-radius: 0;
|
|
88
|
+
transform: scale(0.9);
|
|
50
89
|
}
|
|
51
90
|
}
|
|
52
91
|
|
|
53
|
-
|
|
92
|
+
&[data-category="dependency"] {
|
|
93
|
+
background-color: color-mix(in srgb, currentcolor 39%, white);
|
|
94
|
+
border-radius: 0;
|
|
95
|
+
transform: rotate(45deg);
|
|
96
|
+
|
|
97
|
+
&[data-category="dependency"].react-flow__handle-left {
|
|
98
|
+
transform-origin: 125% 100%;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
&[data-category="dependency"].react-flow__handle-right {
|
|
102
|
+
transform-origin: 75% -50%;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
&::after,
|
|
54
106
|
&::before {
|
|
55
|
-
|
|
107
|
+
border-radius: 0;
|
|
108
|
+
transform: scale(0.9);
|
|
56
109
|
}
|
|
57
110
|
}
|
|
58
111
|
|
|
59
|
-
|
|
60
|
-
|
|
112
|
+
&[data-category="flexible"] {
|
|
113
|
+
background-color: white;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
&[data-category="fixed"] {
|
|
117
|
+
border-color: currentcolor; // no change, only here to have a "fixed" rule
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
&[data-category="unknown"] {
|
|
121
|
+
background-color: color-mix(in srgb, currentcolor 39%, white);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.react-flow__node:hover &.connectable {
|
|
125
|
+
&::before {
|
|
61
126
|
display: block;
|
|
62
127
|
}
|
|
63
128
|
}
|
|
@@ -85,22 +150,22 @@ div.react-flow__handle {
|
|
|
85
150
|
}
|
|
86
151
|
|
|
87
152
|
div.react-flow__handle-right {
|
|
88
|
-
right: -1 * $eccgui-size-
|
|
153
|
+
right: -1 * $eccgui-size-flow-handle;
|
|
89
154
|
transform: translateX(-50%) translateY(-50%);
|
|
90
155
|
}
|
|
91
156
|
|
|
92
157
|
div.react-flow__handle-left {
|
|
93
|
-
left: -1 * $eccgui-size-
|
|
158
|
+
left: -1 * $eccgui-size-flow-handle;
|
|
94
159
|
transform: translateX(50%) translateY(-50%);
|
|
95
160
|
}
|
|
96
161
|
|
|
97
162
|
div.react-flow__handle-top {
|
|
98
|
-
top: -1 * $eccgui-size-
|
|
163
|
+
top: -1 * $eccgui-size-flow-handle;
|
|
99
164
|
transform: translateX(-50%) translateY(50%);
|
|
100
165
|
}
|
|
101
166
|
|
|
102
167
|
div.react-flow__handle-bottom {
|
|
103
|
-
bottom: -1 * $eccgui-size-
|
|
168
|
+
bottom: -1 * $eccgui-size-flow-handle;
|
|
104
169
|
transform: translateX(-50%) translateY(-50%);
|
|
105
170
|
}
|
|
106
171
|
|
|
@@ -2,7 +2,18 @@ import React, { useCallback, useEffect, useState } from "react";
|
|
|
2
2
|
import { Elements, ReactFlowProvider } from "react-flow-renderer";
|
|
3
3
|
import { Meta, StoryFn } from "@storybook/react";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Definitions } from "../../../../common/Intent";
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
Button,
|
|
9
|
+
HandleDefault,
|
|
10
|
+
HandleProps,
|
|
11
|
+
HandleTools,
|
|
12
|
+
Menu,
|
|
13
|
+
MenuItem,
|
|
14
|
+
ReactFlow,
|
|
15
|
+
SimpleDialog,
|
|
16
|
+
} from "./../../../../../index";
|
|
6
17
|
import { edgeTypes } from "./../../edges/edgeTypes";
|
|
7
18
|
|
|
8
19
|
const HandleDefaultDataProps = (data: HandleProps["data"]) => {
|
|
@@ -14,7 +25,12 @@ export default {
|
|
|
14
25
|
title: "Extensions/React Flow/Handle",
|
|
15
26
|
component: HandleDefault,
|
|
16
27
|
subcomponents: { HandleDefaultDataProps, HandleTools },
|
|
17
|
-
argTypes: {
|
|
28
|
+
argTypes: {
|
|
29
|
+
intent: {
|
|
30
|
+
control: "select",
|
|
31
|
+
options: { "Not set": undefined, ...Definitions },
|
|
32
|
+
},
|
|
33
|
+
},
|
|
18
34
|
} as Meta<typeof HandleDefault>;
|
|
19
35
|
|
|
20
36
|
const HandleDefaultExample = (args: any) => {
|
|
@@ -59,6 +75,24 @@ const HandleDefaultExample = (args: any) => {
|
|
|
59
75
|
);
|
|
60
76
|
};
|
|
61
77
|
|
|
78
|
+
const HandleTestMenu = () => {
|
|
79
|
+
const [menuOpen, setMenuOpen] = useState<boolean>(false);
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<>
|
|
83
|
+
<HandleTools>
|
|
84
|
+
<Menu>
|
|
85
|
+
<MenuItem onClick={() => alert("Thank you for the click!")} text={"Click me!"} />
|
|
86
|
+
<MenuItem onClick={() => setMenuOpen(!menuOpen)} text="Open modal" />
|
|
87
|
+
</Menu>
|
|
88
|
+
</HandleTools>
|
|
89
|
+
<SimpleDialog isOpen={menuOpen} actions={<Button onClick={() => setMenuOpen(false)}>Close</Button>}>
|
|
90
|
+
Open modal.
|
|
91
|
+
</SimpleDialog>
|
|
92
|
+
</>
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
|
|
62
96
|
const Template: StoryFn<typeof HandleDefault> = (args) => <HandleDefaultExample {...args} />;
|
|
63
97
|
|
|
64
98
|
export const Default = Template.bind({});
|
|
@@ -66,6 +100,7 @@ Default.args = {
|
|
|
66
100
|
type: "target",
|
|
67
101
|
tooltip: "this is a target handle",
|
|
68
102
|
isConnectable: true,
|
|
103
|
+
onClick: () => alert("Clicked handle."),
|
|
69
104
|
};
|
|
70
105
|
|
|
71
106
|
export const UsingHandleTools = Template.bind({});
|
|
@@ -73,5 +108,8 @@ UsingHandleTools.args = {
|
|
|
73
108
|
type: "source",
|
|
74
109
|
tooltip: "this is a handle with tools overlay",
|
|
75
110
|
isConnectable: true,
|
|
76
|
-
children: <
|
|
111
|
+
children: <HandleTestMenu />,
|
|
112
|
+
data: {
|
|
113
|
+
extendedTooltip: "This is another Tooltip",
|
|
114
|
+
},
|
|
77
115
|
};
|
|
@@ -16,21 +16,17 @@ import { NodeContentExtensionProps } from "./NodeContentExtension";
|
|
|
16
16
|
import { NodeProps } from "./NodeDefault";
|
|
17
17
|
import { HighlightingState, NodeHighlightColor } from "./sharedTypes";
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
export type { HighlightingState };
|
|
19
|
+
type NodeContentHandleLegacyProps = HandleProps;
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
category?: "configuration";
|
|
24
|
-
}
|
|
21
|
+
type NodeContentHandleNextProps = HandleNextProps;
|
|
25
22
|
|
|
26
|
-
|
|
27
|
-
export type IHandleProps = NodeContentHandleLegacyProps;
|
|
23
|
+
export type NodeContentHandleProps = NodeContentHandleLegacyProps | NodeContentHandleNextProps;
|
|
28
24
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
25
|
+
// @deprecated use `NodeContentProps<any>['highlightedState']` (or import from `src/extensions/react-flow/nodes/sharedTypes`)
|
|
26
|
+
export type { HighlightingState };
|
|
32
27
|
|
|
33
|
-
|
|
28
|
+
// @deprecated use `HandleDefaultProps`
|
|
29
|
+
export type IHandleProps = NodeContentHandleLegacyProps;
|
|
34
30
|
|
|
35
31
|
// @deprecated use `NodeContentProps<any>['nodeDimensions']`
|
|
36
32
|
export type NodeDimensions = {
|
|
@@ -274,22 +270,18 @@ const addHandles = (
|
|
|
274
270
|
flowVersion: any = "legacy"
|
|
275
271
|
) => {
|
|
276
272
|
return handles[position].map((handle: any, idx: any) => {
|
|
277
|
-
const {
|
|
273
|
+
const { style = {}, ...otherHandleProps } = handle;
|
|
278
274
|
const styleAdditions: { [key: string]: string } = {
|
|
279
275
|
color: nodeStyle.borderColor ?? undefined,
|
|
280
276
|
};
|
|
281
277
|
styleAdditions[posDirection] = (100 / (handles[position].length + 1)) * (idx + 1) + "%";
|
|
282
278
|
const handleProperties = {
|
|
283
|
-
...
|
|
279
|
+
...otherHandleProps,
|
|
284
280
|
...{
|
|
285
281
|
position: handle.position ?? position,
|
|
286
282
|
style: { ...style, ...styleAdditions },
|
|
287
283
|
posdirection: posDirection,
|
|
288
284
|
isConnectable: typeof handle.isConnectable !== "undefined" ? handle.isConnectable : isConnectable,
|
|
289
|
-
className: category
|
|
290
|
-
? (className ? className + " " : "") +
|
|
291
|
-
gethighlightedStateClasses(category, `${eccgui}-graphviz__handle`)
|
|
292
|
-
: className,
|
|
293
285
|
},
|
|
294
286
|
};
|
|
295
287
|
return <MemoHandler flowVersion={flowVersion} {...handleProperties} key={"handle" + idx} />;
|
|
@@ -307,7 +299,10 @@ const MemoHandler = React.memo(
|
|
|
307
299
|
return (
|
|
308
300
|
// we only test a few properties to control re-rendering
|
|
309
301
|
// need to be extended if also other properties need to be changed late
|
|
310
|
-
prev.style[prev.posdirection] === next.style[next.posdirection] &&
|
|
302
|
+
prev.style[prev.posdirection] === next.style[next.posdirection] &&
|
|
303
|
+
prev.isConnectable === next.isConnectable &&
|
|
304
|
+
prev.intent === next.intent &&
|
|
305
|
+
prev.category === next.category
|
|
311
306
|
);
|
|
312
307
|
}
|
|
313
308
|
);
|
|
@@ -437,20 +432,30 @@ export function NodeContent<CONTENT_PROPS = any>({
|
|
|
437
432
|
}, [nodeContentRef, introductionTime]);
|
|
438
433
|
|
|
439
434
|
if (handles.length > 0) {
|
|
440
|
-
handles
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
handleStack[Position.Top].push(handle);
|
|
445
|
-
} else {
|
|
446
|
-
if (handle.type === "target") {
|
|
447
|
-
handleStack[targetPosition].push(handle);
|
|
435
|
+
handles
|
|
436
|
+
.sort((a, b) => {
|
|
437
|
+
if (a.category === "dependency") {
|
|
438
|
+
return 1;
|
|
448
439
|
}
|
|
449
|
-
if (
|
|
450
|
-
|
|
440
|
+
if (b.category === "dependency") {
|
|
441
|
+
return -1;
|
|
451
442
|
}
|
|
452
|
-
|
|
453
|
-
|
|
443
|
+
return 0;
|
|
444
|
+
})
|
|
445
|
+
.forEach((handle) => {
|
|
446
|
+
if (handle.position) {
|
|
447
|
+
handleStack[handle.position].push(handle);
|
|
448
|
+
} else if (handle.category === "configuration") {
|
|
449
|
+
handleStack[Position.Top].push(handle);
|
|
450
|
+
} else {
|
|
451
|
+
if (handle.type === "target") {
|
|
452
|
+
handleStack[targetPosition].push(handle);
|
|
453
|
+
}
|
|
454
|
+
if (handle.type === "source") {
|
|
455
|
+
handleStack[sourcePosition].push(handle);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
});
|
|
454
459
|
}
|
|
455
460
|
const styleExpandDimensions: { [key: string]: string | number } = Object.create(null);
|
|
456
461
|
if (
|
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import {
|
|
3
|
-
import { LoremIpsum, loremIpsum } from
|
|
4
|
-
import
|
|
1
|
+
import React, { useCallback, useEffect, useState } from "react";
|
|
2
|
+
import ReactFlow, { Elements, ReactFlowProvider } from "react-flow-renderer";
|
|
3
|
+
import { LoremIpsum, loremIpsum } from "react-lorem-ipsum";
|
|
4
|
+
import { Meta, StoryFn } from "@storybook/react";
|
|
5
|
+
|
|
6
|
+
import { Definitions } from "../../../../common/Intent";
|
|
7
|
+
|
|
8
|
+
import canonicalIcons from "./../../../../components/Icon/canonicalIconNames";
|
|
5
9
|
import {
|
|
6
10
|
Badge,
|
|
7
11
|
ContextMenu,
|
|
8
|
-
MenuItem,
|
|
9
|
-
OverflowText,
|
|
10
12
|
HtmlContentBlock,
|
|
11
13
|
IconButton,
|
|
14
|
+
MenuItem,
|
|
15
|
+
OverflowText,
|
|
12
16
|
Tag,
|
|
13
17
|
TagList,
|
|
14
18
|
} from "./../../../../index";
|
|
15
|
-
import canonicalIcons from "./../../../../components/Icon/canonicalIconNames";
|
|
16
|
-
import { Definitions } from "../../../../common/Intent";
|
|
17
|
-
|
|
18
19
|
import { NodeContent } from "./../NodeContent";
|
|
19
|
-
import { nodeTypes } from "./../nodeTypes";
|
|
20
20
|
import { NodeContentExtension } from "./../NodeContentExtension";
|
|
21
21
|
import {
|
|
22
22
|
Default as ContentExtensionExample,
|
|
23
23
|
SlideOutOfNode as ContentExtensionExampleSlideOut,
|
|
24
24
|
} from "./NodeContentExtension.stories";
|
|
25
|
+
import { nodeTypes } from "./nodeTypes";
|
|
25
26
|
|
|
26
27
|
export default {
|
|
27
28
|
title: "Extensions/React Flow/Node Content",
|
|
@@ -42,14 +43,32 @@ export default {
|
|
|
42
43
|
options: ["Not set", "Text string", "OverflowText element", "Tag list"],
|
|
43
44
|
mapping: {
|
|
44
45
|
"Not set": undefined,
|
|
45
|
-
"Text string": loremIpsum({
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
"Text string": loremIpsum({
|
|
47
|
+
p: 1,
|
|
48
|
+
avgSentencesPerParagraph: 1,
|
|
49
|
+
avgWordsPerSentence: 8,
|
|
50
|
+
random: false,
|
|
51
|
+
}).toString(),
|
|
52
|
+
"OverflowText element": (
|
|
53
|
+
<OverflowText>
|
|
54
|
+
{loremIpsum({
|
|
55
|
+
p: 1,
|
|
56
|
+
avgSentencesPerParagraph: 2,
|
|
57
|
+
avgWordsPerSentence: 4,
|
|
58
|
+
random: false,
|
|
59
|
+
}).toString()}
|
|
60
|
+
</OverflowText>
|
|
61
|
+
),
|
|
62
|
+
"Tag list": (
|
|
63
|
+
<TagList>
|
|
64
|
+
{loremIpsum({ p: 1, avgSentencesPerParagraph: 1, avgWordsPerSentence: 5, random: false })
|
|
65
|
+
.toString()
|
|
66
|
+
.split(" ")
|
|
67
|
+
.map((term) => (
|
|
68
|
+
<Tag small>{term}</Tag>
|
|
69
|
+
))}
|
|
70
|
+
</TagList>
|
|
71
|
+
),
|
|
53
72
|
},
|
|
54
73
|
},
|
|
55
74
|
menuButtons: {
|
|
@@ -57,14 +76,18 @@ export default {
|
|
|
57
76
|
options: ["Not set", "Icon button", "Context Menu", "Info badge"],
|
|
58
77
|
mapping: {
|
|
59
78
|
"Not set": undefined,
|
|
60
|
-
"Icon button": <IconButton name="item-info" text="Icon button" onClick={()=>alert("Click info")} />,
|
|
61
|
-
"Context Menu":
|
|
79
|
+
"Icon button": <IconButton name="item-info" text="Icon button" onClick={() => alert("Click info")} />,
|
|
80
|
+
"Context Menu": (
|
|
81
|
+
<ContextMenu>
|
|
82
|
+
<MenuItem text="Context menu" />
|
|
83
|
+
</ContextMenu>
|
|
84
|
+
),
|
|
62
85
|
"Info badge": <Badge intent="info">Info</Badge>,
|
|
63
86
|
},
|
|
64
87
|
},
|
|
65
88
|
iconName: {
|
|
66
89
|
control: "select",
|
|
67
|
-
options: [...
|
|
90
|
+
options: [...Object.keys(canonicalIcons)],
|
|
68
91
|
},
|
|
69
92
|
highlightedState: {
|
|
70
93
|
control: "select",
|
|
@@ -80,20 +103,20 @@ export default {
|
|
|
80
103
|
},
|
|
81
104
|
intent: {
|
|
82
105
|
control: "select",
|
|
83
|
-
options: {"Not set": undefined, ...Definitions},
|
|
106
|
+
options: { "Not set": undefined, ...Definitions },
|
|
84
107
|
},
|
|
85
108
|
highlightColor: {
|
|
86
109
|
control: "select",
|
|
87
110
|
options: {
|
|
88
111
|
"Not set": undefined,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
"Default + alternate": ["default"
|
|
112
|
+
Default: "default",
|
|
113
|
+
Alternate: "alternate",
|
|
114
|
+
"Default + alternate": ["default", "alternate"],
|
|
92
115
|
"Custom (red)": "red",
|
|
93
116
|
"Default + Custom (red)": ["default", "red"],
|
|
94
117
|
"Custom (green) + alternate": ["green", "alternate"],
|
|
95
118
|
"Custom (purple) + custom (yellow)": ["purple", "yellow"],
|
|
96
|
-
}
|
|
119
|
+
},
|
|
97
120
|
},
|
|
98
121
|
content: { control: "none" },
|
|
99
122
|
footerContent: { control: "none" },
|
|
@@ -103,7 +126,7 @@ export default {
|
|
|
103
126
|
selected: { table: { disable: true } },
|
|
104
127
|
businessData: { table: { disable: true } },
|
|
105
128
|
},
|
|
106
|
-
} as
|
|
129
|
+
} as Meta<typeof NodeContent>;
|
|
107
130
|
|
|
108
131
|
const NodeContentExample = (args: any) => {
|
|
109
132
|
const [reactflowInstance, setReactflowInstance] = useState(null);
|
|
@@ -113,11 +136,11 @@ const NodeContentExample = (args: any) => {
|
|
|
113
136
|
useEffect(() => {
|
|
114
137
|
setElements([
|
|
115
138
|
{
|
|
116
|
-
id:
|
|
117
|
-
type:
|
|
139
|
+
id: "example-1",
|
|
140
|
+
type: "default",
|
|
118
141
|
data: args,
|
|
119
142
|
position: { x: 50, y: 50 },
|
|
120
|
-
}
|
|
143
|
+
},
|
|
121
144
|
] as Elements);
|
|
122
145
|
}, [args]);
|
|
123
146
|
|
|
@@ -130,33 +153,31 @@ const NodeContentExample = (args: any) => {
|
|
|
130
153
|
[reactflowInstance]
|
|
131
154
|
);
|
|
132
155
|
|
|
133
|
-
return
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
156
|
+
return (
|
|
157
|
+
<ReactFlowProvider>
|
|
158
|
+
<ReactFlow
|
|
159
|
+
elements={elements}
|
|
160
|
+
style={{ height: "400px" }}
|
|
161
|
+
onLoad={onLoad}
|
|
162
|
+
nodeTypes={nodeTypes}
|
|
163
|
+
defaultZoom={1}
|
|
164
|
+
/>
|
|
165
|
+
</ReactFlowProvider>
|
|
166
|
+
);
|
|
167
|
+
};
|
|
141
168
|
|
|
142
|
-
const Template:
|
|
143
|
-
<NodeContentExample {...args} /*some comment*/ />
|
|
144
|
-
);
|
|
169
|
+
const Template: StoryFn<typeof NodeContent> = (args) => <NodeContentExample {...args} /*some comment*/ />;
|
|
145
170
|
|
|
146
171
|
export const Default = Template.bind({});
|
|
147
172
|
Default.args = {
|
|
148
|
-
label:
|
|
173
|
+
label: "Node title",
|
|
149
174
|
content: (
|
|
150
175
|
<HtmlContentBlock>
|
|
151
176
|
<h4>Node body</h4>
|
|
152
177
|
<LoremIpsum p={4} avgSentencesPerParagraph={3} random={false} />
|
|
153
178
|
</HtmlContentBlock>
|
|
154
179
|
),
|
|
155
|
-
footerContent:
|
|
156
|
-
<OverflowText passDown>
|
|
157
|
-
Node footer with some text information.
|
|
158
|
-
</OverflowText>
|
|
159
|
-
),
|
|
180
|
+
footerContent: <OverflowText passDown>Node footer with some text information.</OverflowText>,
|
|
160
181
|
contentExtension: undefined,
|
|
161
182
|
minimalShape: "none",
|
|
162
183
|
getMinimalTooltipData: (node: any) => {
|
|
@@ -165,7 +186,7 @@ Default.args = {
|
|
|
165
186
|
content: node.data?.content,
|
|
166
187
|
iconName: node.data?.iconName,
|
|
167
188
|
depiction: node.data?.depiction,
|
|
168
|
-
}
|
|
189
|
+
};
|
|
169
190
|
},
|
|
170
191
|
handles: [
|
|
171
192
|
{
|
|
@@ -174,8 +195,8 @@ Default.args = {
|
|
|
174
195
|
},
|
|
175
196
|
{
|
|
176
197
|
type: "source",
|
|
177
|
-
data: {extendedTooltip: "this is a source handle"}
|
|
178
|
-
}
|
|
198
|
+
data: { extendedTooltip: "this is a source handle" },
|
|
199
|
+
},
|
|
179
200
|
],
|
|
180
201
|
onNodeResize: false, // workaround that storybook do not automatically include empty handle function
|
|
181
202
|
};
|
|
@@ -183,5 +204,7 @@ Default.args = {
|
|
|
183
204
|
export const Resizeable = Template.bind({});
|
|
184
205
|
Resizeable.args = {
|
|
185
206
|
...Default.args,
|
|
186
|
-
onNodeResize: (dimensions) => {
|
|
187
|
-
}
|
|
207
|
+
onNodeResize: (dimensions) => {
|
|
208
|
+
console.log("onNodeResize", `new dimensions: ${dimensions.width}x${dimensions.height}`);
|
|
209
|
+
},
|
|
210
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useState } from "react";
|
|
2
2
|
import { Elements } from "react-flow-renderer";
|
|
3
|
-
import {
|
|
3
|
+
import { Meta, StoryFn } from "@storybook/react";
|
|
4
4
|
|
|
5
5
|
import { ReactFlow } from "./../../../../cmem";
|
|
6
6
|
import { NodeContent } from "./../NodeContent";
|
|
7
7
|
import { NodeDefault } from "./../NodeDefault";
|
|
8
|
-
import { nodeTypes } from "./../nodeTypes";
|
|
9
8
|
import { Default as NodeContentExample } from "./NodeContent.stories";
|
|
9
|
+
import { nodeTypes } from "./nodeTypes";
|
|
10
10
|
|
|
11
11
|
export default {
|
|
12
12
|
title: "Extensions/React Flow/Node",
|
|
@@ -96,7 +96,7 @@ export default {
|
|
|
96
96
|
description: "selector for specifying an element as a drag handle",
|
|
97
97
|
},
|
|
98
98
|
},
|
|
99
|
-
} as
|
|
99
|
+
} as Meta<typeof NodeDefault>;
|
|
100
100
|
|
|
101
101
|
const NodeDefaultExample = (args: any) => {
|
|
102
102
|
const [reactflowInstance, setReactflowInstance] = useState(null);
|
|
@@ -127,7 +127,7 @@ const NodeDefaultExample = (args: any) => {
|
|
|
127
127
|
);
|
|
128
128
|
};
|
|
129
129
|
|
|
130
|
-
const Template:
|
|
130
|
+
const Template: StoryFn<typeof NodeDefault> = (args) => <NodeDefaultExample {...args} /*some comment*/ />;
|
|
131
131
|
|
|
132
132
|
export const Default = Template.bind({});
|
|
133
133
|
Default.args = {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { nodeTypes as nodeTypesGraph } from "./../../../../cmem/react-flow/configuration/graph";
|
|
2
|
+
import { nodeTypes as nodeTypesLinking } from "./../../../../cmem/react-flow/configuration/linking";
|
|
3
|
+
import { nodeTypes as nodeTypesUnspecified } from "./../../../../cmem/react-flow/configuration/unspecified";
|
|
4
|
+
import { nodeTypes as nodeTypesWorkflow } from "./../../../../cmem/react-flow/configuration/workflow";
|
|
5
|
+
|
|
6
|
+
export const nodeTypes = {
|
|
7
|
+
...nodeTypesUnspecified,
|
|
8
|
+
...nodeTypesWorkflow,
|
|
9
|
+
...nodeTypesLinking,
|
|
10
|
+
...nodeTypesGraph,
|
|
11
|
+
};
|