@eccenca/gui-elements 22.0.0-rc.7 → 22.0.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.
Files changed (32) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +21 -7
  3. package/dist/cjs/extensions/react-flow/index.js +5 -1
  4. package/dist/cjs/extensions/react-flow/index.js.map +1 -1
  5. package/dist/cjs/extensions/react-flow/minimap/utils.js +2 -2
  6. package/dist/cjs/extensions/react-flow/nodes/NodeContent.js +138 -0
  7. package/dist/cjs/extensions/react-flow/nodes/NodeContent.js.map +1 -0
  8. package/dist/cjs/extensions/react-flow/nodes/NodeContentExtension.js +40 -0
  9. package/dist/cjs/extensions/react-flow/nodes/NodeContentExtension.js.map +1 -0
  10. package/dist/cjs/extensions/react-flow/nodes/NodeDefault.js +3 -130
  11. package/dist/cjs/extensions/react-flow/nodes/NodeDefault.js.map +1 -1
  12. package/dist/es5/extensions/react-flow/index.js +2 -0
  13. package/dist/es5/extensions/react-flow/index.js.map +1 -1
  14. package/dist/es5/extensions/react-flow/minimap/utils.js +1 -1
  15. package/dist/es5/extensions/react-flow/nodes/NodeContent.js +143 -0
  16. package/dist/es5/extensions/react-flow/nodes/NodeContent.js.map +1 -0
  17. package/dist/es5/extensions/react-flow/nodes/NodeContentExtension.js +44 -0
  18. package/dist/es5/extensions/react-flow/nodes/NodeContentExtension.js.map +1 -0
  19. package/dist/es5/extensions/react-flow/nodes/NodeDefault.js +2 -129
  20. package/dist/es5/extensions/react-flow/nodes/NodeDefault.js.map +1 -1
  21. package/dist/types/extensions/react-flow/index.d.ts +4 -0
  22. package/dist/types/extensions/react-flow/nodes/NodeContent.d.ts +121 -0
  23. package/dist/types/extensions/react-flow/nodes/NodeContentExtension.d.ts +30 -0
  24. package/dist/types/extensions/react-flow/nodes/NodeDefault.d.ts +2 -119
  25. package/package.json +14 -4
  26. package/src/extensions/react-flow/index.ts +4 -0
  27. package/src/extensions/react-flow/minimap/utils.ts +1 -1
  28. package/src/extensions/react-flow/nodes/NodeContent.stories.tsx +1 -1
  29. package/src/extensions/react-flow/nodes/NodeContent.tsx +329 -0
  30. package/src/extensions/react-flow/nodes/NodeDefault.stories.tsx +2 -1
  31. package/src/extensions/react-flow/nodes/NodeDefault.tsx +2 -324
  32. package/src/components/Icon/canonicalIconNames.json +0 -120
@@ -3,128 +3,8 @@ import {
3
3
  NodeProps as ReactFlowNodeProps,
4
4
  Position
5
5
  } from "react-flow-renderer";
6
- import { CLASSPREFIX as eccgui } from "../../../configuration/constants";
7
- import { Icon, Tooltip } from "../../../index";
8
- import { HandleDefault, HandleProps } from "./../handles/HandleDefault";
9
- import {ValidIconName} from "../../../components/Icon/canonicalIconNames";
10
-
11
- type HighlightingState = "success" | "warning" | "danger" | "match" | "altmatch";
12
-
13
- export interface IHandleProps extends HandleProps {
14
- category?: "configuration";
15
- }
16
-
17
- interface NodeContentData {
18
- /**
19
- * Name of icon that should be displayed before the node label.
20
- * Must be a name from our list of canonical icon names.
21
- */
22
- iconName?: ValidIconName;
23
- /**
24
- * Valid and accessible URL or `data-uri` for an image that should be displayed before the node label.
25
- */
26
- depiction?: string;
27
- /**
28
- * Label that is displayed in the node header.
29
- */
30
- label: string;
31
- /**
32
- * Content element, displayed in the node body.
33
- */
34
- content?: React.ReactNode;
35
- /**
36
- * Content extension, displayed at the bottom side of a node.
37
- */
38
- contentExtension?: React.ReactNode;
39
- }
40
-
41
- export interface NodeContentProps<T> extends NodeContentData, React.HTMLAttributes<HTMLDivElement> {
42
- /**
43
- * Size of the node.
44
- * If `minimalShape` is not set to `none`then the configured size definition is only used for the selected node state.
45
- */
46
- size?: "tiny" | "small" | "medium" | "large";
47
- /**
48
- * Defines if the node is initially displayed within a very small shape.
49
- * If not set to `none` then the node is only displayed in normal size when it is selected.
50
- */
51
- minimalShape?: "none" | "circular" | "rectangular";
52
- /**
53
- * Set the type of used highlights to mark the node.
54
- */
55
- highlightedState?: HighlightingState | HighlightingState[];
56
- /**
57
- * Text used for tooltip used on icon and depiction.
58
- */
59
- typeLabel?: string;
60
- /**
61
- * If `executionButtons` content is included or not.
62
- * It is displayed in the node header between label and menu.
63
- */
64
- showExecutionButtons?: boolean;
65
- // For some still unknown reason this has to be a function instead of just a ReactNode. Else sometimes the nodes "froze".
66
- /**
67
- * Set of defined buttons and icons that can be displayed.
68
- */
69
- executionButtons?: () => React.ReactNode;
70
- /**
71
- * Can be used for permanent action button or context menu.
72
- * It is displayed at the node header right to the label.
73
- */
74
- menuButtons?: React.ReactNode;
75
- /**
76
- * Array of property definition objects for `Handle` components that need to be created for the node.
77
- * @see https://reactflow.dev/docs/api/handle/
78
- */
79
- handles?: IHandleProps[];
80
- /**
81
- * Set the minimal number of handles on left or right side of the node to activate the recalculation of the minimal height of the node.
82
- */
83
- adaptHeightForHandleMinCount?: number;
84
- /**
85
- * Height per handle in px (without the unit) used for minimal height calculation of the node.
86
- */
87
- adaptSizeIncrement?: number;
88
- /**
89
- * Callback function to provide content for the tooltip on a node with a defined `minimalShape`.
90
- * If you do not want a tooltip in this state you need to provide a callback that returns an empty value.
91
- */
92
- getMinimalTooltipData?: (node: NodeProps<T>) => NodeContentData;
93
- /**
94
- * Set if a handle is displayed even if it does not allow a connection to an edge.
95
- */
96
- showUnconnectableHandles?: boolean;
97
- /**
98
- * The node is displayed with some animated shadow for highlighting purposes.
99
- */
100
- animated?:boolean;
101
-
102
- /** Additional data stored in the node. */
103
- businessData?: T;
104
-
105
- // we need to forward some ReactFlowNodeProps here
106
-
107
- /**
108
- * This property is only forwarded from the `NodeDefault` element.
109
- * If set then it will be always overwritten internally.
110
- */
111
- targetPosition?: typeof Position[keyof typeof Position];
112
- /**
113
- * This property is only forwarded from the `NodeDefault` element.
114
- * If set then it will be always overwritten internally.
115
- */
116
- sourcePosition?: typeof Position[keyof typeof Position];
117
- /**
118
- * This property is only forwarded from the `NodeDefault` element.
119
- * If set then it will be always overwritten internally.
120
- */
121
- isConnectable?: boolean;
122
- /**
123
- * This property is only forwarded from the `NodeDefault` element.
124
- * If set then it will be always overwritten internally.
125
- */
126
- selected?: boolean;
127
- }
6
+ import { Tooltip } from "../../../index";
7
+ import { NodeContent, NodeContentProps } from "./NodeContent";
128
8
 
129
9
  export interface NodeProps<T> extends ReactFlowNodeProps {
130
10
  /**
@@ -134,77 +14,6 @@ export interface NodeProps<T> extends ReactFlowNodeProps {
134
14
  data: NodeContentProps<T>
135
15
  }
136
16
 
137
- const defaultHandles = [
138
- { type: "target" },
139
- { type: "source" },
140
- ] as IHandleProps[];
141
-
142
- interface MemoHandlerProps extends HandleProps {
143
- posdirection: string;
144
- style: {
145
- [key:string]: string | undefined
146
- }
147
- }
148
-
149
- const MemoHandler = React.memo(
150
- (props: MemoHandlerProps) => <HandleDefault {...props} />,
151
- (prev, next) => {
152
- const styleHasChanged =
153
- prev.style[prev.posdirection] === next.style[next.posdirection];
154
- return styleHasChanged;
155
- }
156
- );
157
-
158
- const addHandles = (handles: any, position: any, posDirection: any, isConnectable: any, nodeStyle: any) => {
159
- return handles[position].map((handle: any, idx: any) => {
160
- const {
161
- className,
162
- style = {},
163
- category,
164
- } = handle;
165
- const styleAdditions : {[key: string]: string}= {
166
- color: nodeStyle.borderColor ?? undefined
167
- }
168
- styleAdditions[posDirection] = (100 / (handles[position].length + 1) * (idx + 1)) + "%";
169
- const handleProperties = {
170
- ...handle,
171
- ...{
172
- position: handle.position ?? position,
173
- style: { ...style, ...styleAdditions},
174
- posdirection: posDirection,
175
- isConnectable: typeof handle.isConnectable !== "undefined" ? handle.isConnectable : isConnectable,
176
- className: !!category ? (className?className+" ":"") + gethighlightedStateClasses(category, `${eccgui}-graphviz__handle`) : className,
177
- }
178
- };
179
- return (
180
- <MemoHandler {...handleProperties} key={"handle" + idx} />
181
- );
182
- });
183
- }
184
-
185
- const getDefaultMinimalTooltipData = (node: any) => {
186
- return {
187
- label: node.data?.label,
188
- content: node.data?.content,
189
- iconName: node.data?.iconName,
190
- depiction: node.data?.depiction,
191
- }
192
- }
193
-
194
- const imgWithTooltip = (imgEl: any, tooltipText: any) => {
195
- if (!!tooltipText) {
196
- return <Tooltip content={tooltipText}><span>{imgEl}</span></Tooltip>;
197
- }
198
-
199
- return imgEl;
200
- }
201
-
202
- export const gethighlightedStateClasses = (state: any, baseClassName: any) => {
203
- let hightlights = typeof state === "string" ? [state] : state;
204
- //@ts-ignore
205
- return hightlights.map(item => `${baseClassName}--highlight-${item}`).join(' ');
206
- }
207
-
208
17
  /**
209
18
  * The `NodeDefault` element manages the display of React-Flow nodes.
210
19
  * This element cannot be used directly, it must be connected via a `nodeTypes` definition and all properties need to be routed through the `elements` property items inside the `ReactFlow` container.
@@ -243,134 +52,3 @@ export const NodeDefault = memo(
243
52
  return nodeEl;
244
53
  }
245
54
  );
246
-
247
- /**
248
- * The `NodeContent` element manages the main view of how a node is displaying which content.
249
- * This element cannot be used directly, all properties must be routed through the `data` property of an `elements` property item inside the `ReactFlow` container.
250
- */
251
- export const NodeContent = ({
252
- iconName,
253
- depiction,
254
- typeLabel,
255
- label,
256
- showExecutionButtons = true,
257
- executionButtons,
258
- menuButtons,
259
- content,
260
- contentExtension,
261
- size = "small",
262
- minimalShape = "circular",
263
- highlightedState,
264
- handles = defaultHandles,
265
- adaptHeightForHandleMinCount,
266
- adaptSizeIncrement = 15,
267
- getMinimalTooltipData = getDefaultMinimalTooltipData,
268
- style = {},
269
- showUnconnectableHandles = false,
270
- animated = false,
271
- // forwarded props
272
- targetPosition = Position.Left,
273
- sourcePosition = Position.Right,
274
- isConnectable = true,
275
- selected,
276
- // businessData is just being ignored
277
- businessData,
278
- // other props for DOM element
279
- ...otherProps
280
- }: NodeContentProps<any>) => {
281
- const handleStack: { [key: string]: IHandleProps[] } = {};
282
- handleStack[Position.Top] = [] as IHandleProps[];
283
- handleStack[Position.Right] = [] as IHandleProps[];
284
- handleStack[Position.Bottom] = [] as IHandleProps[];
285
- handleStack[Position.Left] = [] as IHandleProps[];
286
- if (handles.length > 0) {
287
- handles.forEach(handle => {
288
- if (!!handle.position) {
289
- handleStack[handle.position].push(handle);
290
- }
291
- else if (handle.category === "configuration") {
292
- handleStack[Position.Top].push(handle);
293
- }
294
- else {
295
- if (handle.type === "target") {
296
- handleStack[targetPosition].push(handle);
297
- }
298
- if (handle.type === "source") {
299
- handleStack[sourcePosition].push(handle);
300
- }
301
- }
302
- });
303
- }
304
- const styleExpandDimensions: { [key: string]: string | number } = {};
305
- if (
306
- typeof adaptHeightForHandleMinCount !== "undefined" &&
307
- (minimalShape === "none" || !!selected) &&
308
- adaptSizeIncrement && (
309
- handleStack[Position.Left].length >= adaptHeightForHandleMinCount ||
310
- handleStack[Position.Right].length >= adaptHeightForHandleMinCount
311
- )
312
- ) {
313
- const minHeightLeft = handleStack[Position.Left].length * adaptSizeIncrement;
314
- const minHeightRight = handleStack[Position.Right].length * adaptSizeIncrement;
315
- styleExpandDimensions["minHeight"] = Math.max(minHeightLeft, minHeightRight);
316
- }
317
- return (
318
- <>
319
- <section
320
- {...otherProps}
321
- style={{...style, ...styleExpandDimensions}}
322
- className={
323
- `${eccgui}-graphviz__node` +
324
- ` ${eccgui}-graphviz__node--${size}` +
325
- ` ${eccgui}-graphviz__node--minimal-${minimalShape}` +
326
- (!!highlightedState ? " " + gethighlightedStateClasses(highlightedState, `${eccgui}-graphviz__node`) : "") +
327
- (animated ? ` ${eccgui}-graphviz__node--animated` : "") +
328
- (showUnconnectableHandles === false ? ` ${eccgui}-graphviz__node--hidehandles` : "")
329
- }
330
- >
331
- <header className={`${eccgui}-graphviz__node__header`}>
332
- {(!!iconName || !!depiction) && (
333
- <span
334
- className={`${eccgui}-graphviz__node__header-depiction`}
335
- >
336
- {!!depiction && imgWithTooltip(<img src={depiction} alt="" />, (minimalShape === "none" || selected) ? typeLabel : undefined)}
337
- {(!!iconName && !depiction) && <Icon name={iconName} tooltipText={(minimalShape === "none" || selected) ? typeLabel : undefined} />}
338
- </span>
339
- )}
340
- <span
341
- className={`${eccgui}-graphviz__node__header-label`}
342
- title={label}
343
- >
344
- {label}
345
- </span>
346
- {(menuButtons || (showExecutionButtons && executionButtons)) && (
347
- <span
348
- className={`${eccgui}-graphviz__node__header-menu`}
349
- >
350
- {(showExecutionButtons && typeof executionButtons === "function") ? executionButtons() : null}
351
- {menuButtons??null}
352
- </span>
353
- )}
354
- </header>
355
- {content && (
356
- <div className={`${eccgui}-graphviz__node__content`}>
357
- {content}
358
- </div>
359
- )}
360
- {contentExtension && (
361
- <div className={`${eccgui}-graphviz__node__footer`}>
362
- {contentExtension}
363
- </div>
364
- )}
365
- </section>
366
- {!!handles && (
367
- <>
368
- { addHandles(handleStack, Position.Top, "left", isConnectable, style) }
369
- { addHandles(handleStack, Position.Right, "top", isConnectable, style) }
370
- { addHandles(handleStack, Position.Bottom, "left", isConnectable, style) }
371
- { addHandles(handleStack, Position.Left, "top", isConnectable, style) }
372
- </>
373
- )}
374
- </>
375
- );
376
- }
@@ -1,120 +0,0 @@
1
- {
2
- "application-dataintegration": "DataUnstructured",
3
-
4
- "application-homepage": "Workspace",
5
- "application-useraccount": "UserAvatar",
6
- "application-warning": "WarningAlt",
7
- "application-mapping": "ModelBuilder",
8
- "application-explore": "Explore",
9
- "application-vocabularies": "Catalog",
10
- "application-queries": "DataView",
11
- "application-legacygui": "ResetAlt",
12
- "application-activities": "Activity",
13
- "module-timetracker": "Timer",
14
- "module-accesscontrol": "UserAdmin",
15
- "module-annotation": "WatsonHealthTextAnnotationToggle",
16
- "module-dashboard": "Dashboard",
17
- "module-search": "Search",
18
- "module-visualization": "DataVis_1",
19
- "module-reports": "ReportData",
20
- "module-thesauri": "Book",
21
- "module-linkedrules": "Connect",
22
- "module-integrations": "AppConnectivity",
23
- "module-gdprsearch": "UserProfile",
24
-
25
- "toggler-showmore": "ChevronDown",
26
- "toggler-showless": "ChevronUp",
27
- "toggler-moveright": "ChevronRight",
28
- "toggler-moveleft": "ChevronLeft",
29
- "toggler-maximize": "Maximize",
30
- "toggler-minimize": "Minimize",
31
- "toggler-tree": "TreeViewAlt",
32
-
33
- "navigation-back": "ArrowLeft",
34
- "navigation-forth": "ArrowRight",
35
- "navigation-close": "Close",
36
- "navigation-jump": "JumpLink",
37
- "navigation-last": "PageLast",
38
- "navigation-previous": "ChevronLeft",
39
- "navigation-next": "ChevronRight",
40
- "navigation-first": "PageFirst",
41
-
42
- "item-moremenu": "OverflowMenuVertical",
43
- "item-vertmenu": "OverflowMenuHorizontal",
44
- "item-viewdetails": "View",
45
- "item-clone": "Copy",
46
- "item-edit": "Edit",
47
- "item-evaluation": "Analytics",
48
- "item-execution": "Run",
49
- "item-info": "Information",
50
- "item-remove": "TrashCan",
51
- "item-add-artefact": "AddAlt",
52
- "item-launch": "Launch",
53
- "item-download": "Download",
54
- "item-question": "Help",
55
- "item-copy": "CopyFile",
56
- "item-save": "Save",
57
- "item-start": "PlayFilledAlt",
58
- "item-stop": "StopFilledAlt",
59
- "item-reload": "Renew",
60
- "item-shuffle": "Shuffle",
61
- "item-draggable": "Draggable",
62
-
63
- "operation-search": "Search",
64
- "operation-clear": "Close",
65
- "operation-undo": "Undo",
66
- "operation-redo": "Redo",
67
- "operation-logout": "Logout",
68
- "operation-filter": "Filter",
69
- "operation-filteredit": "FilterEdit",
70
- "operation-auto-graph-layout": "Flow",
71
-
72
- "list-sort": "ArrowsVertical",
73
- "list-sortasc": "ArrowDown",
74
- "list-sortdesc": "ArrowUp",
75
-
76
- "state-info": "InformationFilled",
77
- "state-success": "CheckmarkFilled",
78
- "state-warning": "WarningAltFilled",
79
- "state-danger": "ErrorFilled",
80
- "state-unchecked": "Checkbox",
81
- "state-checked": "CheckboxChecked",
82
- "state-partlychecked": "CheckboxIndeterminate",
83
-
84
- "artefact-project": "Folder",
85
- "artefact-workflow": "ModelBuilder",
86
- "artefact-dataset": "Data_2",
87
- "artefact-dataset-csv": "Csv",
88
- "artefact-dataset-multicsv": "Csv",
89
- "artefact-dataset-sparkview": "Sql",
90
- "artefact-dataset-sqlendpoint": "Sql",
91
- "artefact-dataset-jdbc": "Sql",
92
- "artefact-dataset-xml": "Xml",
93
- "artefact-dataset-json": "Json",
94
- "artefact-dataset-excel": "Xls",
95
- "artefact-dataset-file": "DataVis_1",
96
- "artefact-dataset-eccencadataplatform": "DataVis_1",
97
- "artefact-dataset-sparqlendpoint": "DataVis_1",
98
- "artefact-dataset-neo4j": "DataVis_1",
99
- "artefact-transform": "DataRefinery",
100
- "artefact-linking": "Connect",
101
- "artefact-task": "Script",
102
- "artefact-customtask": "Script",
103
- "artefact-file": "Document",
104
- "artefact-embedded": "DataBase",
105
- "artefact-remote": "VirtualMachine",
106
- "artefact-deprecated": "WarningSquare",
107
- "artefact-uncategorized": "Unknown",
108
- "artefact-rawdata": "ScriptReference",
109
- "artefact-report": "Report",
110
-
111
- "activity-error-report": "Error",
112
-
113
- "select-caret": "CaretSort",
114
-
115
- "linked-item": "Link",
116
- "unlinked-item": "Unlink",
117
-
118
- "undefined": "Undefined",
119
- "Undefined": "Undefined"
120
- }