@eccenca/gui-elements 23.1.0-rc.3 → 23.1.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.
Files changed (66) hide show
  1. package/CHANGELOG.md +4 -4
  2. package/dist/cjs/components/Badge/Badge.js +1 -0
  3. package/dist/cjs/components/Badge/Badge.js.map +1 -1
  4. package/dist/cjs/components/Button/Button.js +32 -2
  5. package/dist/cjs/components/Button/Button.js.map +1 -1
  6. package/dist/cjs/components/Icon/BaseIcon.js +4 -2
  7. package/dist/cjs/components/Icon/BaseIcon.js.map +1 -1
  8. package/dist/cjs/components/Icon/canonicalIconNames.js +8 -0
  9. package/dist/cjs/components/Icon/canonicalIconNames.js.map +1 -1
  10. package/dist/cjs/extensions/react-flow/edges/EdgeLabel.js +18 -10
  11. package/dist/cjs/extensions/react-flow/edges/EdgeLabel.js.map +1 -1
  12. package/dist/cjs/extensions/react-flow/handles/HandleContent.js.map +1 -1
  13. package/dist/cjs/extensions/react-flow/handles/HandleDefault.js.map +1 -1
  14. package/dist/cjs/extensions/react-flow/index.js +1 -0
  15. package/dist/cjs/extensions/react-flow/index.js.map +1 -1
  16. package/dist/cjs/extensions/react-flow/minimap/utils.js +4 -2
  17. package/dist/cjs/extensions/react-flow/minimap/utils.js.map +1 -1
  18. package/dist/cjs/extensions/react-flow/nodes/NodeContent.js +5 -2
  19. package/dist/cjs/extensions/react-flow/nodes/NodeContent.js.map +1 -1
  20. package/dist/esm/components/Badge/Badge.js +1 -0
  21. package/dist/esm/components/Badge/Badge.js.map +1 -1
  22. package/dist/esm/components/Button/Button.js +33 -2
  23. package/dist/esm/components/Button/Button.js.map +1 -1
  24. package/dist/esm/components/Icon/BaseIcon.js +4 -2
  25. package/dist/esm/components/Icon/BaseIcon.js.map +1 -1
  26. package/dist/esm/components/Icon/canonicalIconNames.js +8 -0
  27. package/dist/esm/components/Icon/canonicalIconNames.js.map +1 -1
  28. package/dist/esm/extensions/react-flow/edges/EdgeLabel.js +19 -11
  29. package/dist/esm/extensions/react-flow/edges/EdgeLabel.js.map +1 -1
  30. package/dist/esm/extensions/react-flow/handles/HandleContent.js.map +1 -1
  31. package/dist/esm/extensions/react-flow/handles/HandleDefault.js.map +1 -1
  32. package/dist/esm/extensions/react-flow/index.js +1 -0
  33. package/dist/esm/extensions/react-flow/index.js.map +1 -1
  34. package/dist/esm/extensions/react-flow/minimap/utils.js +4 -2
  35. package/dist/esm/extensions/react-flow/minimap/utils.js.map +1 -1
  36. package/dist/esm/extensions/react-flow/nodes/NodeContent.js +5 -2
  37. package/dist/esm/extensions/react-flow/nodes/NodeContent.js.map +1 -1
  38. package/dist/types/components/Badge/Badge.d.ts +1 -0
  39. package/dist/types/components/Button/Button.d.ts +12 -1
  40. package/dist/types/components/Icon/BaseIcon.d.ts +1 -1
  41. package/dist/types/components/Icon/canonicalIconNames.d.ts +1 -1
  42. package/dist/types/components/interfaces.d.ts +3 -0
  43. package/dist/types/extensions/react-flow/edges/EdgeLabel.d.ts +6 -1
  44. package/dist/types/extensions/react-flow/handles/HandleContent.d.ts +3 -0
  45. package/dist/types/extensions/react-flow/handles/HandleDefault.d.ts +6 -0
  46. package/dist/types/extensions/react-flow/index.d.ts +1 -0
  47. package/package.json +1 -1
  48. package/src/components/Badge/Badge.tsx +2 -0
  49. package/src/components/Button/Button.stories.tsx +3 -2
  50. package/src/components/Button/Button.tsx +54 -0
  51. package/src/components/Button/button.scss +2 -0
  52. package/src/components/Icon/BaseIcon.tsx +3 -0
  53. package/src/components/Icon/canonicalIconNames.tsx +16 -0
  54. package/src/components/Icon/icon.scss +21 -0
  55. package/src/components/PropertyValuePair/propertyvalue.scss +4 -0
  56. package/src/components/Table/table.scss +2 -1
  57. package/src/components/interfaces.ts +3 -0
  58. package/src/extensions/react-flow/edges/EdgeLabel.tsx +22 -10
  59. package/src/extensions/react-flow/handles/HandleContent.tsx +3 -0
  60. package/src/extensions/react-flow/handles/HandleDefault.tsx +6 -0
  61. package/src/extensions/react-flow/handles/stories/HandleDefault.stories.tsx +71 -0
  62. package/src/extensions/react-flow/index.ts +1 -0
  63. package/src/extensions/react-flow/minimap/_minimap.scss +20 -4
  64. package/src/extensions/react-flow/minimap/utils.ts +3 -1
  65. package/src/extensions/react-flow/nodes/NodeContent.tsx +6 -2
  66. package/src/extensions/react-flow/nodes/_nodes.scss +4 -4
@@ -22,6 +22,10 @@
22
22
  margin-top: $eccgui-size-block-whitespace * 0.5;
23
23
  }
24
24
  }
25
+
26
+ .#{$eccgui}-label {
27
+ color: inherit;
28
+ }
25
29
  }
26
30
 
27
31
  .#{$eccgui}-propertyvalue__property,
@@ -179,7 +179,8 @@ $eccgui-color-tablerow-border: $pt-divider-black !default;
179
179
  .#{$prefix}--data-table--zebra > tbody > tr[data-parent-row]:nth-child(4n+3),
180
180
  .#{$prefix}--data-table--zebra > tbody > tr[data-child-row]:nth-child(4n+4),
181
181
  .#{$prefix}--data-table > tbody > tr.#{eccgui}-simpletable__row--zebra,
182
- .#{$prefix}--data-table > tbody > tr.#{eccgui}-simpletable__row--zebra + tr[data-child-row] {
182
+ .#{$prefix}--data-table > tbody > tr.#{eccgui}-simpletable__row--zebra + tr[data-child-row],
183
+ .#{$prefix}--data-table--zebra > tbody > tr:not([data-parent-row]):not([data-child-row]):nth-child(2n+0) {
183
184
  // even rows
184
185
 
185
186
  &.#{$prefix}--expandable-row:not([data-child-row]) {
@@ -1,4 +1,7 @@
1
1
  export interface TestableComponent {
2
+ /**
3
+ * Can be set to use it as selector in test environments.
4
+ */
2
5
  "data-test-id"?: string
3
6
  }
4
7
 
@@ -1,4 +1,4 @@
1
- import React, { memo, useEffect, useRef } from "react";
1
+ import React, { memo } from "react";
2
2
  import { Icon, Depiction, DepictionProps, OverflowText } from "../../../index";
3
3
  import { CLASSPREFIX as eccgui } from "../../../configuration/constants";
4
4
  import { ValidIconName } from "../../../components/Icon/canonicalIconNames";
@@ -91,30 +91,42 @@ interface EdgeLabelObjectProps extends React.SVGAttributes<SVGForeignObjectEleme
91
91
  * Property from the `renderLabel` callback method.
92
92
  */
93
93
  edgeCenter: [number, number, number, number];
94
+ /**
95
+ * Number of milliseconds.
96
+ * If set and larger then zero then the re-sizing process is repeated after this time.
97
+ */
98
+ resizeTimeout?: number;
94
99
  }
95
100
 
96
101
  export const EdgeLabelObject = memo(({
97
102
  children,
98
103
  edgeCenter,
104
+ resizeTimeout = -1,
99
105
  ...otherForeignObjectProps
100
106
  } : EdgeLabelObjectProps) => {
101
- const containerRef = useRef<SVGForeignObjectElement>(null);
107
+ const containerCallback = React.useCallback((containerRef) => {
108
+ if (containerRef) labelSize(containerRef);
109
+ }, [edgeCenter]);
102
110
 
103
- useEffect(() => {
104
- const labelElement = containerRef.current!.getElementsByClassName(`${eccgui}-graphviz__edge-label`);
111
+ const labelSize = (container: SVGForeignObjectElement) => {
112
+ const labelElement = container.getElementsByClassName(`${eccgui}-graphviz__edge-label`);
105
113
  if (labelElement.length > 0) {
106
114
  const width = (labelElement[0] as HTMLElement).offsetWidth;
107
115
  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());
116
+ container.setAttribute("x", (edgeCenter[0] - width/2).toString());
117
+ container.setAttribute("y", (edgeCenter[1] - height/2).toString());
118
+ container.setAttribute("width", width.toString());
119
+ container.setAttribute("height", height.toString());
120
+ } else if (resizeTimeout > 0){
121
+ // Content is not ready yet, recall resizing process after timeout.
122
+ // This can happen in case the children is actually not a `EdgeLabel`.
123
+ setTimeout(() => { labelSize(container)}, resizeTimeout);
112
124
  }
113
- })
125
+ }
114
126
 
115
127
  return (
116
128
  <foreignObject
117
- ref={containerRef}
129
+ ref={containerCallback}
118
130
  className={`${eccgui}-graphviz__edge-labelobject`}
119
131
  width="1"
120
132
  height="1"
@@ -4,6 +4,9 @@ import { Tooltip } from "../../../index";
4
4
 
5
5
  export interface HandleContentProps {
6
6
  children?: JSX.Element | string;
7
+ /**
8
+ * Tooltip displayed as overlay on hover.
9
+ */
7
10
  extendedTooltip?: JSX.Element | string;
8
11
  }
9
12
 
@@ -11,7 +11,13 @@ import { HandleContent, HandleContentProps } from "./HandleContent";
11
11
  import { ReacFlowVersionSupportProps, useReactFlowVersion } from "../versionsupport";
12
12
 
13
13
  interface HandleExtensionProps extends ReacFlowVersionSupportProps {
14
+ /**
15
+ * Extended handle data.
16
+ */
14
17
  data?: HandleContentProps;
18
+ /**
19
+ * Simple text tooltip displayed as title on hover.
20
+ */
15
21
  tooltip?: string;
16
22
  children?: JSX.Element | string;
17
23
  onClick?: () => void;
@@ -0,0 +1,71 @@
1
+ import React, { useState, useEffect, useCallback } from "react";
2
+ import { ComponentStory, ComponentMeta } from "@storybook/react";
3
+ import { ReactFlow, HandleDefault, HandleProps } from "./../../../../../index";
4
+ import { Elements, ReactFlowProvider } from 'react-flow-renderer';
5
+ import { edgeTypes } from "./../../edges/edgeTypes";
6
+
7
+ const HandleDefaultDataProps = (data: HandleProps["data"]) => {
8
+ // this is only a mock to get it as sub element in the table
9
+ return <>{data.extendedTooltip}</>;
10
+ }
11
+
12
+ export default {
13
+ title: "Extensions/React Flow/Default Handle",
14
+ component: HandleDefault,
15
+ subcomponents: { HandleDefaultDataProps },
16
+ argTypes: {
17
+ },
18
+ } as ComponentMeta<typeof HandleDefault>;
19
+
20
+ const HandleDefaultExample = (args: any) => {
21
+ const [reactflowInstance, setReactflowInstance] = useState(null);
22
+ const [elements, setElements] = useState([] as Elements);
23
+
24
+ useEffect(() => {
25
+ setElements([
26
+ {
27
+ id: "node-1",
28
+ type: "default",
29
+ data: {
30
+ label: "Default ",
31
+ content: "Example content.",
32
+ minimalShape: "none",
33
+ handles: [
34
+ { ...args }
35
+ ],
36
+ },
37
+ position: { x: 50, y: 200 },
38
+ },
39
+ ] as Elements);
40
+ }, [args]);
41
+
42
+ const onLoad = useCallback(
43
+ (rfi) => {
44
+ if (!reactflowInstance) {
45
+ setReactflowInstance(rfi);
46
+ }
47
+ },
48
+ [reactflowInstance]
49
+ );
50
+
51
+ return <ReactFlowProvider>
52
+ <ReactFlow
53
+ elements={elements}
54
+ style={{ height: '400px' }}
55
+ onLoad={onLoad}
56
+ edgeTypes={ edgeTypes }
57
+ defaultZoom={1}
58
+ />
59
+ </ReactFlowProvider>
60
+ }
61
+
62
+ const Template: ComponentStory<typeof HandleDefault> = (args) => (
63
+ <HandleDefaultExample {...args} />
64
+ );
65
+
66
+ export const Default = Template.bind({});
67
+ Default.args = {
68
+ type: "target",
69
+ tooltip: "this is a target handle",
70
+ isConnectable: false,
71
+ };
@@ -21,3 +21,4 @@ export type { EdgeStepProps } from "./edges/EdgeStep";
21
21
  export type { MiniMapProps } from "./minimap/MiniMap";
22
22
 
23
23
  export * from "./edges/EdgeDefault";
24
+ export * from "./handles/HandleDefault";
@@ -10,25 +10,41 @@
10
10
  .#{$eccgui}-graphviz__minimap__node--highlight-match {
11
11
  stroke: $eccgui-color-accent;
12
12
  stroke-width: 5;
13
- //fill: $reactflow-node-background-color;
14
13
  }
15
14
  .#{$eccgui}-graphviz__minimap__node--highlight-altmatch {
16
15
  stroke: complement($eccgui-color-primary);
17
16
  stroke-width: 5;
18
- //fill: $reactflow-node-background-color;
19
17
  }
20
18
  .#{$eccgui}-graphviz__minimap__node--highlight-success {
21
19
  stroke: $eccgui-color-success-text;
22
20
  stroke-width: 5;
23
- //fill: $reactflow-node-background-color;
24
21
  }
25
22
  .#{$eccgui}-graphviz__minimap__node--highlight-warning {
26
23
  stroke: $eccgui-color-warning-text;
27
24
  stroke-width: 7;
28
- //fill: $reactflow-node-background-color;
29
25
  }
30
26
  .#{$eccgui}-graphviz__minimap__node--highlight-danger {
31
27
  fill: $eccgui-color-danger-text;
32
28
  stroke: $eccgui-color-danger-text;
33
29
  stroke-width: 9;
34
30
  }
31
+
32
+ .react-flow__minimap-node {
33
+
34
+ // FIXME: this is a first basic implementation, later it should be possible to highlight without overwriting stroke/fill colors
35
+
36
+ &[class*="#{$eccgui}-intent--"] {
37
+ stroke-width: 20;
38
+ }
39
+
40
+ &.#{$eccgui}-intent--success {
41
+ stroke: $eccgui-color-success-text;
42
+ }
43
+ &.#{$eccgui}-intent--warning {
44
+ stroke: $eccgui-color-warning-text;
45
+ }
46
+ &.#{$eccgui}-intent--danger {
47
+ stroke: $eccgui-color-danger-text;
48
+ fill: $eccgui-color-danger-text !important;
49
+ }
50
+ }
@@ -1,10 +1,12 @@
1
1
  import { CLASSPREFIX as eccgui } from "./../../../configuration/constants";
2
2
  import { gethighlightedStateClasses } from "./../nodes/NodeContent";
3
+ import { intentClassName } from "../../../common/Intent";
3
4
 
4
5
  export const minimapNodeClassName = (node: any) => {
5
6
  const typeClass = `${eccgui}-graphviz__minimap__node--` + node.type;
6
7
  const stateClass = node.data?.highlightedState ? gethighlightedStateClasses(node.data.highlightedState, `${eccgui}-graphviz__minimap__node`) : "";
7
- return typeClass + (stateClass ? " " + stateClass : "");
8
+ const intentClass = node.data?.intent ? intentClassName(node.data.intent) : "";
9
+ return `${typeClass} ${intentClass} ${stateClass}`;
8
10
  };
9
11
 
10
12
  export const minimapNodeColor = (node: any) => {
@@ -271,8 +271,12 @@ export const gethighlightedStateClasses = (
271
271
  const MemoHandler = React.memo(
272
272
  (props: MemoHandlerProps) => <HandleDefault {...props} />,
273
273
  (prev, next) => {
274
- const styleHasChanged = prev.style[prev.posdirection] === next.style[next.posdirection];
275
- return styleHasChanged;
274
+ return (
275
+ // we only test a few properties to control re-rendering
276
+ // need to be extended if also other properties need to be changed late
277
+ prev.style[prev.posdirection] === next.style[next.posdirection]
278
+ && prev.isConnectable === next.isConnectable
279
+ )
276
280
  }
277
281
  );
278
282
 
@@ -501,7 +501,7 @@
501
501
  bottom: -2 * $reactflow-node-border-width;
502
502
  right: -2 * $reactflow-node-border-width;
503
503
  border-radius: inherit;
504
- box-shadow: 0 0 0 2 * $reactflow-node-border-width $eccgui-color-danger-text;
504
+ box-shadow: 0 0 0 2 * $reactflow-node-border-width $eccgui-color-danger-text !important;
505
505
  z-index: -1;
506
506
  }
507
507
  }
@@ -535,18 +535,18 @@
535
535
 
536
536
  .#{$eccgui}-graphviz__node--highlight-success {
537
537
  &:before {
538
- box-shadow: 0 0 0 2 * $reactflow-node-border-width $eccgui-color-success-text;
538
+ box-shadow: 0 0 0 2 * $reactflow-node-border-width $eccgui-color-success-text !important;
539
539
  }
540
540
  }
541
541
 
542
542
  .#{$eccgui}-graphviz__node--highlight-warning {
543
543
  &:before {
544
- box-shadow: 0 0 0 2 * $reactflow-node-border-width $eccgui-color-warning-text;
544
+ box-shadow: 0 0 0 2 * $reactflow-node-border-width $eccgui-color-warning-text !important;
545
545
  }
546
546
  }
547
547
 
548
548
  .#{$eccgui}-graphviz__node--highlight-altmatch {
549
549
  &:after {
550
- box-shadow: 0 0 0 2 * $reactflow-node-border-width complement($eccgui-color-primary);
550
+ box-shadow: 0 0 0 2 * $reactflow-node-border-width complement($eccgui-color-primary) !important;
551
551
  }
552
552
  }