@eccenca/gui-elements 23.2.0 → 23.3.0-rc.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 (149) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/dist/cjs/cmem/react-flow/ReactFlow/ReactFlow.js +5 -1
  3. package/dist/cjs/cmem/react-flow/ReactFlow/ReactFlow.js.map +1 -1
  4. package/dist/cjs/cmem/react-flow/StickyNoteModal/StickyNoteModal.js +9 -11
  5. package/dist/cjs/cmem/react-flow/StickyNoteModal/StickyNoteModal.js.map +1 -1
  6. package/dist/cjs/cmem/react-flow/extensions/ReactFlowHotkeyContext.js +12 -0
  7. package/dist/cjs/cmem/react-flow/extensions/ReactFlowHotkeyContext.js.map +1 -0
  8. package/dist/cjs/common/index.js +5 -2
  9. package/dist/cjs/common/index.js.map +1 -1
  10. package/dist/cjs/common/utils/globalVars.js +21 -0
  11. package/dist/cjs/common/utils/globalVars.js.map +1 -0
  12. package/dist/cjs/components/Application/ApplicationHeader.js +2 -3
  13. package/dist/cjs/components/Application/ApplicationHeader.js.map +1 -1
  14. package/dist/cjs/components/Dialog/Modal.js +35 -8
  15. package/dist/cjs/components/Dialog/Modal.js.map +1 -1
  16. package/dist/cjs/components/Dialog/SimpleDialog.js +15 -2
  17. package/dist/cjs/components/Dialog/SimpleDialog.js.map +1 -1
  18. package/dist/cjs/components/Icon/IconButton.js +1 -1
  19. package/dist/cjs/components/Icon/IconButton.js.map +1 -1
  20. package/dist/cjs/components/Icon/canonicalIconNames.js +1 -0
  21. package/dist/cjs/components/Icon/canonicalIconNames.js.map +1 -1
  22. package/dist/cjs/components/OverviewItem/OverviewItemDepiction.js +3 -6
  23. package/dist/cjs/components/OverviewItem/OverviewItemDepiction.js.map +1 -1
  24. package/dist/cjs/components/PropertyValuePair/PropertyName.js +3 -3
  25. package/dist/cjs/components/PropertyValuePair/PropertyName.js.map +1 -1
  26. package/dist/cjs/components/Separation/Spacing.js +18 -4
  27. package/dist/cjs/components/Separation/Spacing.js.map +1 -1
  28. package/dist/cjs/components/Table/TableExpandHeader.js +7 -8
  29. package/dist/cjs/components/Table/TableExpandHeader.js.map +1 -1
  30. package/dist/cjs/components/TextField/TextField.js +23 -3
  31. package/dist/cjs/components/TextField/TextField.js.map +1 -1
  32. package/dist/cjs/extensions/codemirror/CodeMirror.js +39 -7
  33. package/dist/cjs/extensions/codemirror/CodeMirror.js.map +1 -1
  34. package/dist/cjs/extensions/react-flow/edges/EdgeLabel.js +10 -9
  35. package/dist/cjs/extensions/react-flow/edges/EdgeLabel.js.map +1 -1
  36. package/dist/cjs/extensions/react-flow/handles/HandleContent.js +4 -4
  37. package/dist/cjs/extensions/react-flow/handles/HandleContent.js.map +1 -1
  38. package/dist/cjs/extensions/react-flow/handles/HandleDefault.js +56 -6
  39. package/dist/cjs/extensions/react-flow/handles/HandleDefault.js.map +1 -1
  40. package/dist/cjs/extensions/react-flow/handles/HandleTools.js +41 -0
  41. package/dist/cjs/extensions/react-flow/handles/HandleTools.js.map +1 -0
  42. package/dist/cjs/extensions/react-flow/index.js +2 -0
  43. package/dist/cjs/extensions/react-flow/index.js.map +1 -1
  44. package/dist/cjs/extensions/react-flow/nodes/NodeContent.js +42 -13
  45. package/dist/cjs/extensions/react-flow/nodes/NodeContent.js.map +1 -1
  46. package/dist/esm/cmem/markdown/Markdown.js +1 -1
  47. package/dist/esm/cmem/react-flow/ReactFlow/ReactFlow.js +5 -1
  48. package/dist/esm/cmem/react-flow/ReactFlow/ReactFlow.js.map +1 -1
  49. package/dist/esm/cmem/react-flow/StickyNoteModal/StickyNoteModal.js +9 -11
  50. package/dist/esm/cmem/react-flow/StickyNoteModal/StickyNoteModal.js.map +1 -1
  51. package/dist/esm/cmem/react-flow/extensions/ReactFlowHotkeyContext.js +6 -0
  52. package/dist/esm/cmem/react-flow/extensions/ReactFlowHotkeyContext.js.map +1 -0
  53. package/dist/esm/common/index.js +5 -2
  54. package/dist/esm/common/index.js.map +1 -1
  55. package/dist/esm/common/utils/globalVars.js +16 -0
  56. package/dist/esm/common/utils/globalVars.js.map +1 -0
  57. package/dist/esm/components/Application/ApplicationHeader.js +2 -3
  58. package/dist/esm/components/Application/ApplicationHeader.js.map +1 -1
  59. package/dist/esm/components/Dialog/Modal.js +36 -9
  60. package/dist/esm/components/Dialog/Modal.js.map +1 -1
  61. package/dist/esm/components/Dialog/SimpleDialog.js +14 -1
  62. package/dist/esm/components/Dialog/SimpleDialog.js.map +1 -1
  63. package/dist/esm/components/Icon/IconButton.js +1 -1
  64. package/dist/esm/components/Icon/IconButton.js.map +1 -1
  65. package/dist/esm/components/Icon/canonicalIconNames.js +1 -0
  66. package/dist/esm/components/Icon/canonicalIconNames.js.map +1 -1
  67. package/dist/esm/components/OverviewItem/OverviewItemDepiction.js +3 -6
  68. package/dist/esm/components/OverviewItem/OverviewItemDepiction.js.map +1 -1
  69. package/dist/esm/components/PropertyValuePair/PropertyName.js +3 -3
  70. package/dist/esm/components/PropertyValuePair/PropertyName.js.map +1 -1
  71. package/dist/esm/components/Separation/Spacing.js +28 -4
  72. package/dist/esm/components/Separation/Spacing.js.map +1 -1
  73. package/dist/esm/components/Table/TableExpandHeader.js +7 -8
  74. package/dist/esm/components/Table/TableExpandHeader.js.map +1 -1
  75. package/dist/esm/components/TextField/TextField.js +25 -5
  76. package/dist/esm/components/TextField/TextField.js.map +1 -1
  77. package/dist/esm/extensions/codemirror/CodeMirror.js +49 -6
  78. package/dist/esm/extensions/codemirror/CodeMirror.js.map +1 -1
  79. package/dist/esm/extensions/react-flow/edges/EdgeLabel.js +10 -9
  80. package/dist/esm/extensions/react-flow/edges/EdgeLabel.js.map +1 -1
  81. package/dist/esm/extensions/react-flow/handles/HandleContent.js +16 -5
  82. package/dist/esm/extensions/react-flow/handles/HandleContent.js.map +1 -1
  83. package/dist/esm/extensions/react-flow/handles/HandleDefault.js +75 -9
  84. package/dist/esm/extensions/react-flow/handles/HandleDefault.js.map +1 -1
  85. package/dist/esm/extensions/react-flow/handles/HandleTools.js +61 -0
  86. package/dist/esm/extensions/react-flow/handles/HandleTools.js.map +1 -0
  87. package/dist/esm/extensions/react-flow/index.js +2 -0
  88. package/dist/esm/extensions/react-flow/index.js.map +1 -1
  89. package/dist/esm/extensions/react-flow/nodes/NodeContent.js +49 -20
  90. package/dist/esm/extensions/react-flow/nodes/NodeContent.js.map +1 -1
  91. package/dist/types/cmem/react-flow/extensions/ReactFlowHotkeyContext.d.ts +8 -0
  92. package/dist/types/common/index.d.ts +4 -0
  93. package/dist/types/common/utils/globalVars.d.ts +2 -0
  94. package/dist/types/components/Application/ApplicationHeader.d.ts +1 -2
  95. package/dist/types/components/Dialog/Modal.d.ts +22 -7
  96. package/dist/types/components/Dialog/SimpleDialog.d.ts +12 -1
  97. package/dist/types/components/Icon/canonicalIconNames.d.ts +1 -1
  98. package/dist/types/components/PropertyValuePair/PropertyName.d.ts +7 -1
  99. package/dist/types/components/Separation/Spacing.d.ts +2 -2
  100. package/dist/types/components/Table/TableExpandHeader.d.ts +5 -1
  101. package/dist/types/components/TextField/TextField.d.ts +4 -2
  102. package/dist/types/extensions/codemirror/CodeMirror.d.ts +17 -3
  103. package/dist/types/extensions/react-flow/edges/EdgeLabel.d.ts +7 -3
  104. package/dist/types/extensions/react-flow/handles/HandleContent.d.ts +7 -2
  105. package/dist/types/extensions/react-flow/handles/HandleDefault.d.ts +15 -6
  106. package/dist/types/extensions/react-flow/handles/HandleTools.d.ts +7 -0
  107. package/dist/types/extensions/react-flow/index.d.ts +2 -0
  108. package/dist/types/extensions/react-flow/nodes/NodeContent.d.ts +24 -8
  109. package/package.json +19 -17
  110. package/scripts/compile-sass.ts +1 -1
  111. package/src/cmem/react-flow/ReactFlow/ReactFlow.tsx +10 -0
  112. package/src/cmem/react-flow/StickyNoteModal/StickyNoteModal.tsx +10 -12
  113. package/src/cmem/react-flow/extensions/ReactFlowHotkeyContext.ts +14 -0
  114. package/src/common/index.ts +6 -3
  115. package/src/common/utils/globalVars.ts +18 -0
  116. package/src/components/Application/ApplicationHeader.tsx +8 -13
  117. package/src/components/Application/_header.scss +17 -17
  118. package/src/components/Application/_toolbar.scss +22 -33
  119. package/src/components/Application/application.scss +8 -6
  120. package/src/components/AutoSuggestion/tests/AutoSuggestion.test.tsx +34 -21
  121. package/src/components/AutoSuggestion/tests/SingleLineCodeEditor.test.tsx +20 -9
  122. package/src/components/Dialog/Modal.tsx +96 -39
  123. package/src/components/Dialog/SimpleDialog.tsx +19 -1
  124. package/src/components/Dialog/dialog.scss +33 -17
  125. package/src/components/Icon/IconButton.tsx +1 -1
  126. package/src/components/Icon/canonicalIconNames.tsx +2 -0
  127. package/src/components/OverviewItem/OverviewItemDepiction.tsx +8 -16
  128. package/src/components/PropertyValuePair/PropertyName.tsx +15 -4
  129. package/src/components/PropertyValuePair/propertyvalue.scss +1 -0
  130. package/src/components/Separation/Spacing.tsx +12 -8
  131. package/src/components/Table/TableExpandHeader.tsx +21 -18
  132. package/src/components/TextField/TextField.tsx +32 -6
  133. package/src/components/Tooltip/tooltip.scss +15 -1
  134. package/src/extensions/codemirror/CodeMirror.tsx +62 -8
  135. package/src/extensions/codemirror/_codemirror.scss +53 -8
  136. package/src/extensions/react-flow/edges/EdgeLabel.tsx +78 -81
  137. package/src/extensions/react-flow/edges/_edges.scss +62 -67
  138. package/src/extensions/react-flow/edges/stories/EdgeDefault.stories.tsx +43 -44
  139. package/src/extensions/react-flow/handles/HandleContent.tsx +14 -13
  140. package/src/extensions/react-flow/handles/HandleDefault.tsx +121 -44
  141. package/src/extensions/react-flow/handles/HandleTools.tsx +46 -0
  142. package/src/extensions/react-flow/handles/_handles.scss +135 -50
  143. package/src/extensions/react-flow/handles/stories/HandleDefault.stories.tsx +69 -25
  144. package/src/extensions/react-flow/index.ts +2 -0
  145. package/src/extensions/react-flow/nodes/NodeContent.tsx +97 -32
  146. package/src/extensions/react-flow/nodes/_nodes.scss +170 -110
  147. package/src/extensions/react-flow/nodes/stories/NodeContent.stories.tsx +75 -52
  148. package/src/extensions/react-flow/nodes/stories/NodeDefault.stories.tsx +34 -36
  149. package/src/extensions/react-flow/nodes/stories/nodeTypes.ts +11 -0
@@ -2,6 +2,7 @@
2
2
  $eccgui-size-typo-tooltip: $eccgui-size-typo-caption !default;
3
3
  $eccgui-size-typo-tooltip-lineheight: $eccgui-size-typo-caption-lineheight !default;
4
4
  $eccgui-size-tooltip-width: 20em !default;
5
+
5
6
  // library vars
6
7
  $tooltip2-background-color: $eccgui-color-applicationheader-text; // !default;
7
8
  $tooltip2-text-color: $eccgui-color-applicationheader-background; // !default;
@@ -15,8 +16,8 @@ $tooltip2-padding-horizontal: $eccgui-size-block-whitespace * 0.5; // !default;
15
16
  .#{$ns}-tooltip2 {
16
17
  font-size: $eccgui-size-typo-tooltip;
17
18
  line-height: $eccgui-size-typo-tooltip-lineheight;
18
- white-space: normal;
19
19
  overflow-wrap: break-word;
20
+ white-space: normal;
20
21
  }
21
22
 
22
23
  .#{$eccgui}-tooltip--small {
@@ -39,3 +40,16 @@ $tooltip2-padding-horizontal: $eccgui-size-block-whitespace * 0.5; // !default;
39
40
  text-decoration: none;
40
41
  }
41
42
  }
43
+
44
+ .#{$prefix}--tooltip-content {
45
+ max-width: $eccgui-size-tooltip-width;
46
+ padding: 0.25 * $eccgui-size-block-whitespace 0.5 * $eccgui-size-block-whitespace;
47
+ // align Carbon tooltips, they are used automatically by a few carbon based elements, e.g. pagination buttons
48
+ font-size: $eccgui-size-typo-tooltip;
49
+ line-height: $eccgui-size-typo-tooltip-lineheight;
50
+ overflow-wrap: break-word;
51
+ white-space: normal;
52
+
53
+ --cds-popover-background-color: #{$tooltip2-background-color};
54
+ --cds-popover-text-color: #{$tooltip2-text-color};
55
+ }
@@ -1,12 +1,32 @@
1
- import React, { useEffect, useRef } from "react";
2
- import CodeMirror from "codemirror";
3
- import { CLASSPREFIX as eccgui } from "../../configuration/constants";
1
+ import React, { TextareaHTMLAttributes, useEffect, useRef } from "react";
2
+ import CodeMirror, { ModeSpec, ModeSpecOptions } from "codemirror";
3
+
4
4
  import "codemirror/mode/markdown/markdown.js";
5
5
  import "codemirror/mode/python/python.js";
6
6
  import "codemirror/mode/sparql/sparql.js";
7
7
  import "codemirror/mode/sql/sql.js";
8
8
  import "codemirror/mode/turtle/turtle.js";
9
9
  import "codemirror/mode/xml/xml.js";
10
+ import "codemirror/mode/jinja2/jinja2.js";
11
+ import "codemirror/mode/yaml/yaml.js";
12
+ import "codemirror/mode/javascript/javascript.js";
13
+
14
+ import { CLASSPREFIX as eccgui } from "../../configuration/constants";
15
+
16
+ export const supportedCodeEditorModes = [
17
+ "markdown",
18
+ "python",
19
+ "sparql",
20
+ "sql",
21
+ "turtle",
22
+ "xml",
23
+ "jinja2",
24
+ "yaml",
25
+ "json",
26
+ "undefined",
27
+ ] as const;
28
+ type SupportedModesTuple = typeof supportedCodeEditorModes;
29
+ export type SupportedCodeEditorModes = SupportedModesTuple[number];
10
30
 
11
31
  export interface CodeEditorProps {
12
32
  /**
@@ -26,7 +46,7 @@ export interface CodeEditorProps {
26
46
  /**
27
47
  * Syntax mode of the code editor.
28
48
  */
29
- mode?: "markdown" | "python" | "sparql" | "sql" | "turtle" | "xml" | "undefined";
49
+ mode?: SupportedCodeEditorModes;
30
50
  /**
31
51
  * Default value used first when the editor is instanciated.
32
52
  */
@@ -35,6 +55,17 @@ export interface CodeEditorProps {
35
55
  * If enabled the code editor won't show numbers before each line.
36
56
  */
37
57
  preventLineNumbers?: boolean;
58
+
59
+ /** Set read-only mode. Default: false */
60
+ readOnly?: boolean;
61
+
62
+ /** Optional height of the component */
63
+ height?: number | string;
64
+
65
+ /** Long lines are wrapped and displayed on multiple lines */
66
+ wrapLines?: boolean;
67
+
68
+ outerDivAttributes?: Partial<TextareaHTMLAttributes<HTMLDivElement>>;
38
69
  }
39
70
 
40
71
  /**
@@ -47,29 +78,38 @@ export const CodeEditor = ({
47
78
  mode = "undefined",
48
79
  preventLineNumbers = false,
49
80
  defaultValue,
81
+ readOnly = false,
82
+ height,
83
+ wrapLines = false,
84
+ outerDivAttributes,
50
85
  }: CodeEditorProps) => {
51
86
  const domRef = useRef<HTMLTextAreaElement>(null);
52
87
 
53
88
  useEffect(() => {
54
89
  const editorInstance = CodeMirror.fromTextArea(domRef.current!, {
55
- mode: mode === "undefined" ? undefined : mode,
56
- lineWrapping: true,
90
+ mode: convertMode(mode),
91
+ lineWrapping: wrapLines,
57
92
  lineNumbers: !preventLineNumbers,
58
93
  tabSize: 2,
59
94
  theme: "xq-light",
95
+ readOnly: readOnly,
60
96
  });
61
97
 
62
98
  editorInstance.on("change", (api) => {
63
99
  onChange(api.getValue());
64
100
  });
65
101
 
102
+ if (height) {
103
+ editorInstance.setSize(null, height);
104
+ }
105
+
66
106
  return function cleanup() {
67
107
  editorInstance.toTextArea();
68
108
  };
69
109
  }, [onChange, mode, preventLineNumbers]);
70
110
 
71
111
  return (
72
- <div className={`${eccgui}-codeeditor`}>
112
+ <div {...outerDivAttributes} className={`${eccgui}-codeeditor`}>
73
113
  <textarea
74
114
  ref={domRef}
75
115
  /**
@@ -78,10 +118,24 @@ export const CodeEditor = ({
78
118
  * unchanged from the code what was took over here.
79
119
  */
80
120
  data-test-id="codemirror-wrapper"
81
- id={!!id ? id : `codemirror-${name}`}
121
+ id={id ? id : `codemirror-${name}`}
82
122
  name={name}
83
123
  defaultValue={defaultValue}
84
124
  />
85
125
  </div>
86
126
  );
87
127
  };
128
+
129
+ const convertMode = (mode: SupportedCodeEditorModes | undefined): string | ModeSpec<ModeSpecOptions> | undefined => {
130
+ switch (mode) {
131
+ case "undefined":
132
+ return undefined;
133
+ case "json":
134
+ return {
135
+ name: "javascript",
136
+ json: true,
137
+ };
138
+ default:
139
+ return mode;
140
+ }
141
+ };
@@ -2,31 +2,76 @@
2
2
  @import "~codemirror/theme/xq-light";
3
3
 
4
4
  // adjustments
5
-
5
+ // stylelint-disable selector-class-pattern
6
6
  .#{$eccgui}-codeeditor {
7
+ max-width: 100%;
8
+
7
9
  .CodeMirror {
8
- border-radius: $pt-border-radius;
9
10
  clip-path: unset !important; // we may check later why they set inset(0) now
11
+ border-radius: $pt-border-radius;
10
12
 
11
13
  // get them a "border" like input boxes from blueprintjs
12
14
  box-shadow: input-transition-shadow($input-shadow-color-focus), $pt-input-box-shadow;
15
+
13
16
  &.CodeMirror-focused {
14
17
  box-shadow: input-transition-shadow($input-shadow-color-focus, true), $input-box-shadow-focus;
15
18
  }
16
19
 
17
- .CodeMirror-gutters {
18
- // allow "borders" to shine through
19
- background-color: rgba(0,0,0,0.05);
20
- }
21
-
22
20
  .CodeMirror-scroll {
21
+ width: calc(100% - 2px);
22
+ height: calc(100% - 2px);
23
+
24
+ // fix size to prevent wrong calculation of other elements
25
+ padding: 0;
26
+ margin: 1px;
23
27
  cursor: text;
28
+
29
+ // remove scrollbars, codemirrow has own elements to fake them
30
+ scrollbar-width: none; // Firefox
31
+ -ms-overflow-style: none; // IE, Edge
32
+ &::-webkit-scrollbar {
33
+ display: none; // Chrome, Safari and Opera
34
+ }
35
+ }
36
+
37
+ .CodeMirror-hscrollbar {
38
+ bottom: 1px;
39
+ height: $eccgui-size-inline-whitespace !important;
40
+ }
41
+
42
+ .CodeMirror-vscrollbar {
43
+ top: 1px;
44
+ right: 1px;
45
+ width: $eccgui-size-inline-whitespace !important;
46
+ }
47
+
48
+ .CodeMirror-scrollbar-filler {
49
+ right: 1px;
50
+ bottom: 1px;
51
+ }
52
+
53
+ .CodeMirror-sizer {
54
+ border-right-width: $eccgui-size-inline-whitespace !important;
24
55
  }
25
56
  }
26
57
  }
27
58
 
28
59
  .#{$prefix}--accordion__content {
29
- .CodeMirror-scroll, .CodeMirror-sizer, .CodeMirror-gutter, .CodeMirror-gutters, .CodeMirror-linenumber {
60
+ .CodeMirror-scroll,
61
+ .CodeMirror-sizer,
62
+ .CodeMirror-gutter,
63
+ .CodeMirror-gutters,
64
+ .CodeMirror-linenumber {
30
65
  box-sizing: content-box;
31
66
  }
32
67
  }
68
+
69
+ // fix a few xq-light colors regarding bad contrasts
70
+
71
+ .cm-s-xq-light {
72
+ // add other classes if necessary
73
+ .cm-meta {
74
+ filter: invert(1);
75
+ }
76
+ }
77
+ // stylelint-enable selector-class-pattern
@@ -1,8 +1,9 @@
1
1
  import React, { memo } from "react";
2
- import { Icon, Depiction, DepictionProps, OverflowText } from "../../../index";
3
- import { CLASSPREFIX as eccgui } from "../../../configuration/constants";
2
+
3
+ import { intentClassName, IntentTypes } from "../../../common/Intent";
4
4
  import { ValidIconName } from "../../../components/Icon/canonicalIconNames";
5
- import { IntentTypes, intentClassName } from "../../../common/Intent";
5
+ import { CLASSPREFIX as eccgui } from "../../../configuration/constants";
6
+ import { Depiction, DepictionProps, Icon, OverflowText } from "../../../index";
6
7
 
7
8
  export interface EdgeLabelProps extends React.HTMLAttributes<HTMLDivElement> {
8
9
  /**
@@ -26,62 +27,56 @@ export interface EdgeLabelProps extends React.HTMLAttributes<HTMLDivElement> {
26
27
  * Stretches the label component to the full available width.
27
28
  */
28
29
  fullWidth?: boolean;
30
+ /**
31
+ * Label is diaplayed without a box that comes with borders and background color.
32
+ */
33
+ loose?: boolean;
29
34
  /**
30
35
  * Add a info state to the label, visualized by color.
31
36
  */
32
37
  intent?: IntentTypes;
33
38
  }
34
39
 
35
- export const EdgeLabel = memo(({
36
- depiction,
37
- text,
38
- actions,
39
- large,
40
- fullWidth,
41
- intent,
42
- title,
43
- ...otherDivProps
44
- } : EdgeLabelProps) => {
45
-
46
- const depEl = (!!depiction && typeof depiction === "string")
47
- ? <Depiction image={<Icon name={depiction as ValidIconName} />} />
48
- : depiction;
40
+ export const EdgeLabel = memo(
41
+ ({ depiction, text, actions, large, fullWidth, loose, intent, title, ...otherDivProps }: EdgeLabelProps) => {
42
+ const depEl =
43
+ !!depiction && typeof depiction === "string" ? (
44
+ <Depiction image={<Icon name={depiction as ValidIconName} />} />
45
+ ) : (
46
+ depiction
47
+ );
49
48
 
50
- return (
51
- <div
52
- className={
53
- `${eccgui}-graphviz__edge-label` +
54
- (large ? ` ${eccgui}-graphviz__edge-label--large` : "") +
55
- (fullWidth ? ` ${eccgui}-graphviz__edge-label--fullwidth` : "") +
56
- (!!intent ? ` ${intentClassName(intent)}` : '')
57
- }
58
- {...otherDivProps}
59
- >
60
- {!!depEl && (
61
- <div className={`${eccgui}-graphviz__edge-label__depiction`}>
62
- {
63
- React.cloneElement(depEl, {
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
+ (loose ? ` ${eccgui}-graphviz__edge-label--loose` : "") +
56
+ (intent ? ` ${intentClassName(intent)}` : "")
57
+ }
58
+ {...otherDivProps}
59
+ >
60
+ {!!depEl && (
61
+ <div className={`${eccgui}-graphviz__edge-label__depiction`}>
62
+ {React.cloneElement(depEl, {
64
63
  padding: "tiny",
65
64
  ratio: "1:1",
66
65
  resizing: "contain",
67
66
  forceInlineSvg: true,
68
67
  border: false,
69
68
  backgroundColor: undefined,
70
- })
71
- }
69
+ })}
70
+ </div>
71
+ )}
72
+ <div className={`${eccgui}-graphviz__edge-label__text`} title={title}>
73
+ {typeof text === "string" ? <OverflowText>{text}</OverflowText> : text}
72
74
  </div>
73
- )}
74
- <div className={`${eccgui}-graphviz__edge-label__text`} title={title}>
75
- { typeof text === "string" ? <OverflowText>{ text }</OverflowText> : text }
75
+ {!!actions && <div className={`${eccgui}-graphviz__edge-label__aux`}>{actions}</div>}
76
76
  </div>
77
- {!!actions && (
78
- <div className={`${eccgui}-graphviz__edge-label__aux`}>
79
- { actions }
80
- </div>
81
- )}
82
- </div>
83
- )
84
- });
77
+ );
78
+ }
79
+ );
85
80
 
86
81
  export interface EdgeLabelObjectProps extends React.SVGAttributes<SVGForeignObjectElement> {
87
82
  /**
@@ -99,42 +94,44 @@ export interface EdgeLabelObjectProps extends React.SVGAttributes<SVGForeignObje
99
94
  resizeTimeout?: number;
100
95
  }
101
96
 
102
- export const EdgeLabelObject = memo(({
103
- children,
104
- edgeCenter,
105
- resizeTimeout = -1,
106
- ...otherForeignObjectProps
107
- } : EdgeLabelObjectProps) => {
108
- const containerCallback = React.useCallback((containerRef) => {
109
- if (containerRef) labelSize(containerRef);
110
- }, [edgeCenter]);
97
+ export const EdgeLabelObject = memo(
98
+ ({ children, edgeCenter, resizeTimeout = -1, ...otherForeignObjectProps }: EdgeLabelObjectProps) => {
99
+ const containerCallback = React.useCallback(
100
+ (containerRef) => {
101
+ if (containerRef) labelSize(containerRef);
102
+ },
103
+ [edgeCenter]
104
+ );
111
105
 
112
- const labelSize = (container: SVGForeignObjectElement) => {
113
- const labelElement = container.getElementsByClassName(`${eccgui}-graphviz__edge-label`);
114
- if (labelElement.length > 0) {
115
- const width = (labelElement[0] as HTMLElement).offsetWidth;
116
- const height = (labelElement[0] as HTMLElement).offsetHeight;
117
- container.setAttribute("x", (edgeCenter[0] - width/2).toString());
118
- container.setAttribute("y", (edgeCenter[1] - height/2).toString());
119
- container.setAttribute("width", width.toString());
120
- container.setAttribute("height", height.toString());
121
- } else if (resizeTimeout > 0){
122
- // Content is not ready yet, recall resizing process after timeout.
123
- // This can happen in case the children is actually not a `EdgeLabel`.
124
- setTimeout(() => { labelSize(container)}, resizeTimeout);
125
- }
126
- }
106
+ const labelSize = (container: SVGForeignObjectElement) => {
107
+ const labelElement = container.getElementsByClassName(`${eccgui}-graphviz__edge-label`);
108
+ if (labelElement.length > 0) {
109
+ const width = (labelElement[0] as HTMLElement).offsetWidth;
110
+ const height = (labelElement[0] as HTMLElement).offsetHeight;
111
+ container.setAttribute("x", (edgeCenter[0] - width / 2).toString());
112
+ container.setAttribute("y", (edgeCenter[1] - height / 2).toString());
113
+ container.setAttribute("width", width.toString());
114
+ container.setAttribute("height", height.toString());
115
+ } else if (resizeTimeout > 0) {
116
+ // Content is not ready yet, recall resizing process after timeout.
117
+ // This can happen in case the children is actually not a `EdgeLabel`.
118
+ setTimeout(() => {
119
+ labelSize(container);
120
+ }, resizeTimeout);
121
+ }
122
+ };
127
123
 
128
- return (
129
- <foreignObject
130
- ref={containerCallback}
131
- className={`${eccgui}-graphviz__edge-labelobject`}
132
- width="1"
133
- height="1"
134
- {...otherForeignObjectProps}
135
- requiredExtensions="http://www.w3.org/1999/xhtml"
136
- >
137
- { children }
138
- </foreignObject>
139
- )
140
- });
124
+ return (
125
+ <foreignObject
126
+ ref={containerCallback}
127
+ className={`${eccgui}-graphviz__edge-labelobject`}
128
+ width="1"
129
+ height="1"
130
+ {...otherForeignObjectProps}
131
+ requiredExtensions="http://www.w3.org/1999/xhtml"
132
+ >
133
+ {children}
134
+ </foreignObject>
135
+ );
136
+ }
137
+ );