@eccenca/gui-elements 23.0.0 → 23.1.0-rc.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 (248) hide show
  1. package/CHANGELOG.md +35 -1
  2. package/README.md +7 -0
  3. package/dist/cjs/cmem/ActivityControl/ActivityControlWidget.js.map +1 -1
  4. package/dist/cjs/cmem/react-flow/ReactFlow/ReactFlow.js +7 -2
  5. package/dist/cjs/cmem/react-flow/ReactFlow/ReactFlow.js.map +1 -1
  6. package/dist/cjs/cmem/react-flow/StickyNoteModal/StickyNoteModal.js +3 -7
  7. package/dist/cjs/cmem/react-flow/StickyNoteModal/StickyNoteModal.js.map +1 -1
  8. package/dist/cjs/cmem/react-flow/extensions/scrollOnDragHook.js +200 -0
  9. package/dist/cjs/cmem/react-flow/extensions/scrollOnDragHook.js.map +1 -0
  10. package/dist/cjs/common/Intent/index.js +7 -3
  11. package/dist/cjs/common/Intent/index.js.map +1 -1
  12. package/dist/cjs/common/utils/characters.js +82 -0
  13. package/dist/cjs/common/utils/characters.js.map +1 -0
  14. package/dist/cjs/components/Application/ApplicationTitle.js +2 -2
  15. package/dist/cjs/components/Application/ApplicationTitle.js.map +1 -1
  16. package/dist/cjs/components/Badge/Badge.js +44 -0
  17. package/dist/cjs/components/Badge/Badge.js.map +1 -0
  18. package/dist/cjs/components/Depiction/Depiction.js +111 -0
  19. package/dist/cjs/components/Depiction/Depiction.js.map +1 -0
  20. package/dist/cjs/components/Grid/Grid.js +7 -2
  21. package/dist/cjs/components/Grid/Grid.js.map +1 -1
  22. package/dist/cjs/components/Grid/GridColumn.js +6 -2
  23. package/dist/cjs/components/Grid/GridColumn.js.map +1 -1
  24. package/dist/cjs/components/Grid/GridRow.js +3 -0
  25. package/dist/cjs/components/Grid/GridRow.js.map +1 -1
  26. package/dist/cjs/components/Icon/BaseIcon.js +38 -0
  27. package/dist/cjs/components/Icon/BaseIcon.js.map +1 -0
  28. package/dist/cjs/components/Icon/Icon.js +9 -24
  29. package/dist/cjs/components/Icon/Icon.js.map +1 -1
  30. package/dist/cjs/components/Icon/IconButton.js +8 -1
  31. package/dist/cjs/components/Icon/IconButton.js.map +1 -1
  32. package/dist/cjs/components/Icon/TestIcon.js +35 -0
  33. package/dist/cjs/components/Icon/TestIcon.js.map +1 -0
  34. package/dist/cjs/components/Icon/canonicalIconNames.js +123 -621
  35. package/dist/cjs/components/Icon/canonicalIconNames.js.map +1 -1
  36. package/dist/cjs/components/Icon/index.js +11 -0
  37. package/dist/cjs/components/Icon/index.js.map +1 -0
  38. package/dist/cjs/components/Menu/MenuItem.js +1 -1
  39. package/dist/cjs/components/Menu/MenuItem.js.map +1 -1
  40. package/dist/cjs/components/MultiSelect/MultiSelect.js +56 -23
  41. package/dist/cjs/components/MultiSelect/MultiSelect.js.map +1 -1
  42. package/dist/cjs/components/Notification/Notification.js +10 -2
  43. package/dist/cjs/components/Notification/Notification.js.map +1 -1
  44. package/dist/cjs/components/OverviewItem/OverviewItemDepiction.js +24 -0
  45. package/dist/cjs/components/OverviewItem/OverviewItemDepiction.js.map +1 -1
  46. package/dist/cjs/components/Tag/Tag.js +6 -2
  47. package/dist/cjs/components/Tag/Tag.js.map +1 -1
  48. package/dist/cjs/components/TextField/TextArea.js +4 -2
  49. package/dist/cjs/components/TextField/TextArea.js.map +1 -1
  50. package/dist/cjs/components/TextField/TextField.js +4 -2
  51. package/dist/cjs/components/TextField/TextField.js.map +1 -1
  52. package/dist/cjs/components/TextField/useTextValidation.js +84 -0
  53. package/dist/cjs/components/TextField/useTextValidation.js.map +1 -0
  54. package/dist/cjs/components/Tree/Tree.js.map +1 -1
  55. package/dist/cjs/components/Typography/Highlighter.js.map +1 -1
  56. package/dist/cjs/components/Typography/OverflowText.js.map +1 -1
  57. package/dist/cjs/components/Typography/WhiteSpaceContainer.js +35 -12
  58. package/dist/cjs/components/Typography/WhiteSpaceContainer.js.map +1 -1
  59. package/dist/cjs/components/Typography/index.js +21 -0
  60. package/dist/cjs/components/Typography/index.js.map +1 -0
  61. package/dist/cjs/components/Workspace/WorkspaceContent.js +1 -1
  62. package/dist/cjs/components/Workspace/WorkspaceContent.js.map +1 -1
  63. package/dist/cjs/components/index.js +18 -0
  64. package/dist/cjs/components/index.js.map +1 -0
  65. package/dist/cjs/index.js +7 -17
  66. package/dist/cjs/index.js.map +1 -1
  67. package/dist/esm/cmem/ActivityControl/ActivityControlWidget.js.map +1 -1
  68. package/dist/esm/cmem/react-flow/ReactFlow/ReactFlow.js +7 -2
  69. package/dist/esm/cmem/react-flow/ReactFlow/ReactFlow.js.map +1 -1
  70. package/dist/esm/cmem/react-flow/StickyNoteModal/StickyNoteModal.js +3 -6
  71. package/dist/esm/cmem/react-flow/StickyNoteModal/StickyNoteModal.js.map +1 -1
  72. package/dist/esm/cmem/react-flow/extensions/scrollOnDragHook.js +194 -0
  73. package/dist/esm/cmem/react-flow/extensions/scrollOnDragHook.js.map +1 -0
  74. package/dist/esm/common/Intent/index.js +5 -13
  75. package/dist/esm/common/Intent/index.js.map +1 -1
  76. package/dist/esm/common/utils/characters.js +96 -0
  77. package/dist/esm/common/utils/characters.js.map +1 -0
  78. package/dist/esm/components/Application/ApplicationTitle.js +2 -2
  79. package/dist/esm/components/Application/ApplicationTitle.js.map +1 -1
  80. package/dist/esm/components/Badge/Badge.js +48 -0
  81. package/dist/esm/components/Badge/Badge.js.map +1 -0
  82. package/dist/esm/components/Depiction/Depiction.js +96 -0
  83. package/dist/esm/components/Depiction/Depiction.js.map +1 -0
  84. package/dist/esm/components/Grid/Grid.js +7 -2
  85. package/dist/esm/components/Grid/Grid.js.map +1 -1
  86. package/dist/esm/components/Grid/GridColumn.js +6 -2
  87. package/dist/esm/components/Grid/GridColumn.js.map +1 -1
  88. package/dist/esm/components/Grid/GridRow.js +3 -0
  89. package/dist/esm/components/Grid/GridRow.js.map +1 -1
  90. package/dist/esm/components/Icon/BaseIcon.js +44 -0
  91. package/dist/esm/components/Icon/BaseIcon.js.map +1 -0
  92. package/dist/esm/components/Icon/Icon.js +9 -24
  93. package/dist/esm/components/Icon/Icon.js.map +1 -1
  94. package/dist/esm/components/Icon/IconButton.js +8 -1
  95. package/dist/esm/components/Icon/IconButton.js.map +1 -1
  96. package/dist/esm/components/Icon/TestIcon.js +41 -0
  97. package/dist/esm/components/Icon/TestIcon.js.map +1 -0
  98. package/dist/esm/components/Icon/canonicalIconNames.js +123 -621
  99. package/dist/esm/components/Icon/canonicalIconNames.js.map +1 -1
  100. package/dist/esm/components/Icon/index.js +4 -0
  101. package/dist/esm/components/Icon/index.js.map +1 -0
  102. package/dist/esm/components/Menu/MenuItem.js +1 -1
  103. package/dist/esm/components/Menu/MenuItem.js.map +1 -1
  104. package/dist/esm/components/MultiSelect/MultiSelect.js +61 -44
  105. package/dist/esm/components/MultiSelect/MultiSelect.js.map +1 -1
  106. package/dist/esm/components/Notification/Notification.js +12 -4
  107. package/dist/esm/components/Notification/Notification.js.map +1 -1
  108. package/dist/esm/components/OverviewItem/OverviewItemDepiction.js +24 -0
  109. package/dist/esm/components/OverviewItem/OverviewItemDepiction.js.map +1 -1
  110. package/dist/esm/components/Tag/Tag.js +6 -2
  111. package/dist/esm/components/Tag/Tag.js.map +1 -1
  112. package/dist/esm/components/TextField/TextArea.js +4 -2
  113. package/dist/esm/components/TextField/TextArea.js.map +1 -1
  114. package/dist/esm/components/TextField/TextField.js +4 -2
  115. package/dist/esm/components/TextField/TextField.js.map +1 -1
  116. package/dist/esm/components/TextField/useTextValidation.js +78 -0
  117. package/dist/esm/components/TextField/useTextValidation.js.map +1 -0
  118. package/dist/esm/components/Tree/Tree.js.map +1 -1
  119. package/dist/esm/components/Typography/Highlighter.js.map +1 -1
  120. package/dist/esm/components/Typography/OverflowText.js.map +1 -1
  121. package/dist/esm/components/Typography/WhiteSpaceContainer.js +16 -14
  122. package/dist/esm/components/Typography/WhiteSpaceContainer.js.map +1 -1
  123. package/dist/esm/components/Typography/index.js +12 -0
  124. package/dist/esm/components/Typography/index.js.map +1 -0
  125. package/dist/esm/components/Workspace/WorkspaceContent.js +1 -1
  126. package/dist/esm/components/Workspace/WorkspaceContent.js.map +1 -1
  127. package/dist/esm/components/index.js +6 -0
  128. package/dist/esm/components/index.js.map +1 -0
  129. package/dist/esm/index.js +5 -10
  130. package/dist/esm/index.js.map +1 -1
  131. package/dist/types/cmem/ActivityControl/ActivityControlWidget.d.ts +2 -1
  132. package/dist/types/cmem/react-flow/ReactFlow/ReactFlow.d.ts +14 -0
  133. package/dist/types/cmem/react-flow/extensions/scrollOnDragHook.d.ts +22 -0
  134. package/dist/types/common/Intent/index.d.ts +4 -3
  135. package/dist/types/common/utils/characters.d.ts +19 -0
  136. package/dist/types/components/Badge/Badge.d.ts +42 -0
  137. package/dist/types/components/Depiction/Depiction.d.ts +71 -0
  138. package/dist/types/components/Grid/Grid.d.ts +21 -2
  139. package/dist/types/components/Grid/GridColumn.d.ts +20 -2
  140. package/dist/types/components/Grid/GridRow.d.ts +17 -1
  141. package/dist/types/components/Icon/BaseIcon.d.ts +45 -0
  142. package/dist/types/components/Icon/Icon.d.ts +7 -34
  143. package/dist/types/components/Icon/IconButton.d.ts +3 -2
  144. package/dist/types/components/Icon/TestIcon.d.ts +20 -0
  145. package/dist/types/components/Icon/canonicalIconNames.d.ts +9 -7
  146. package/dist/types/components/Icon/index.d.ts +4 -0
  147. package/dist/types/components/Menu/MenuItem.d.ts +2 -1
  148. package/dist/types/components/MultiSelect/MultiSelect.d.ts +3 -1
  149. package/dist/types/components/Notification/Notification.d.ts +13 -4
  150. package/dist/types/components/Tabs/Tab.d.ts +2 -0
  151. package/dist/types/components/Tag/Tag.d.ts +16 -3
  152. package/dist/types/components/TextField/TextArea.d.ts +7 -2
  153. package/dist/types/components/TextField/TextField.d.ts +6 -1
  154. package/dist/types/components/TextField/useTextValidation.d.ts +28 -0
  155. package/dist/types/components/Tree/Tree.d.ts +2 -1
  156. package/dist/types/components/Typography/Highlighter.d.ts +2 -2
  157. package/dist/types/components/Typography/OverflowText.d.ts +2 -2
  158. package/dist/types/components/Typography/WhiteSpaceContainer.d.ts +45 -4
  159. package/dist/types/components/Typography/index.d.ts +12 -0
  160. package/dist/types/components/index.d.ts +5 -0
  161. package/dist/types/index.d.ts +6 -11
  162. package/package.json +13 -16
  163. package/scripts/compile-sass.ts +9 -1
  164. package/src/_shame.scss +1 -1
  165. package/src/cmem/ActivityControl/ActivityControlWidget.stories.tsx +6 -4
  166. package/src/cmem/ActivityControl/ActivityControlWidget.tsx +3 -2
  167. package/src/cmem/react-flow/ReactFlow/ReactFlow.tsx +26 -1
  168. package/src/cmem/react-flow/StickyNoteModal/StickyNoteModal.tsx +10 -6
  169. package/src/cmem/react-flow/extensions/scrollOnDragHook.ts +247 -0
  170. package/src/common/Intent/index.ts +16 -12
  171. package/src/common/utils/characters.ts +111 -0
  172. package/src/components/Accordion/accordion.scss +4 -3
  173. package/src/components/Application/ApplicationTitle.tsx +2 -2
  174. package/src/components/Application/_config.scss +1 -1
  175. package/src/components/Application/_content.scss +1 -1
  176. package/src/components/Application/_header.scss +2 -2
  177. package/src/components/Application/_sidebar.scss +2 -9
  178. package/src/components/Application/_toolbar.scss +1 -1
  179. package/src/components/Application/application.scss +4 -4
  180. package/src/components/AutocompleteField/autoCompleteFieldUtils.tsx +13 -8
  181. package/src/components/Badge/Badge.stories.tsx +47 -0
  182. package/src/components/Badge/Badge.tsx +93 -0
  183. package/src/components/Badge/badge.scss +44 -0
  184. package/src/components/Depiction/Depiction.tsx +198 -0
  185. package/src/components/Depiction/depiction.scss +176 -0
  186. package/src/components/Depiction/stories/Depiction.stories.tsx +69 -0
  187. package/src/components/Depiction/stories/test-16to9.png +0 -0
  188. package/src/components/Depiction/stories/test-16to9.svg +41 -0
  189. package/src/components/Depiction/stories/test-16to9.tobase64.svg +41 -0
  190. package/src/components/Depiction/stories/test-16to9.tsx +44 -0
  191. package/src/components/Depiction/stories/test-9to16.png +0 -0
  192. package/src/components/Depiction/stories/test-9to16.svg +44 -0
  193. package/src/components/Depiction/stories/test-9to16.tobase64.svg +44 -0
  194. package/src/components/Depiction/stories/test-9to16.tsx +48 -0
  195. package/src/components/Grid/Grid.tsx +22 -4
  196. package/src/components/Grid/GridColumn.tsx +23 -6
  197. package/src/components/Grid/GridRow.tsx +17 -2
  198. package/src/components/Grid/grid.scss +14 -13
  199. package/src/components/Grid/stories/Grid.stories.tsx +27 -0
  200. package/src/components/Grid/stories/GridColumn.stories.tsx +66 -0
  201. package/src/components/Grid/stories/GridRow.stories.tsx +47 -0
  202. package/src/components/Icon/BaseIcon.tsx +84 -0
  203. package/src/components/Icon/Icon.tsx +23 -82
  204. package/src/components/Icon/IconButton.tsx +18 -14
  205. package/src/components/Icon/TestIcon.tsx +39 -0
  206. package/src/components/Icon/canonicalIconNames.tsx +132 -633
  207. package/src/components/Icon/index.ts +5 -0
  208. package/src/components/Icon/stories/Icon.stories.tsx +13 -0
  209. package/src/components/Icon/stories/IconButton.stories.tsx +14 -7
  210. package/src/components/Icon/stories/TestIcon.stories.tsx +28 -0
  211. package/src/components/Link/link.scss +2 -1
  212. package/src/components/Menu/MenuItem.tsx +14 -4
  213. package/src/components/Menu/Stories/MenuItem.stories.tsx +16 -2
  214. package/src/components/MultiSelect/MultiSelect.tsx +58 -27
  215. package/src/components/Notification/Notification.stories.tsx +4 -0
  216. package/src/components/Notification/Notification.tsx +26 -6
  217. package/src/components/OverviewItem/OverviewItemDepiction.tsx +31 -0
  218. package/src/components/OverviewItem/overviewitem.scss +2 -1
  219. package/src/components/OverviewItem/stories/OverviewItem.stories.tsx +22 -1
  220. package/src/components/OverviewItem/stories/OverviewItemDepiction.stories.tsx +8 -3
  221. package/src/components/Pagination/pagination.scss +3 -2
  222. package/src/components/SimpleTable/simpletable.scss +11 -12
  223. package/src/components/Tag/Tag.stories.tsx +7 -2
  224. package/src/components/Tag/Tag.tsx +24 -4
  225. package/src/components/Tag/tag.scss +84 -3
  226. package/src/components/TagInput/taginput.scss +6 -0
  227. package/src/components/TextField/TextArea.tsx +10 -1
  228. package/src/components/TextField/TextField.tsx +9 -0
  229. package/src/components/TextField/stories/SearchField.stories.tsx +1 -1
  230. package/src/components/TextField/textfield.scss +12 -0
  231. package/src/components/TextField/useTextValidation.ts +103 -0
  232. package/src/components/Tooltip/tooltip.scss +1 -1
  233. package/src/components/Tree/Tree.stories.tsx +7 -1
  234. package/src/components/Tree/Tree.tsx +2 -1
  235. package/src/components/Typography/Highlighter.tsx +2 -2
  236. package/src/components/Typography/OverflowText.tsx +2 -2
  237. package/src/components/Typography/WhiteSpaceContainer.tsx +69 -21
  238. package/src/components/Typography/index.ts +25 -0
  239. package/src/components/Typography/stories/WhiteSpaceContainer.stories.tsx +55 -0
  240. package/src/components/Typography/typography.scss +3 -2
  241. package/src/components/Workspace/WorkspaceContent.tsx +1 -1
  242. package/src/components/index.scss +5 -0
  243. package/src/components/index.ts +5 -0
  244. package/src/includes/carbon-components/_components.scss +11 -0
  245. package/src/includes/carbon-components/_requisits.scss +18 -0
  246. package/src/includes/carbon-components/_variables.scss +50 -53
  247. package/src/index.scss +4 -105
  248. package/src/index.ts +6 -16
@@ -1,16 +1,33 @@
1
1
  import React from "react";
2
2
  import {default as ReactFlowOriginal, ReactFlowProps as ReactFlowOriginalProps} from "react-flow-renderer";
3
- import { ReactFlowMarkers } from "../../../extensions/react-flow/markers/ReactFlowMarkers";
3
+ import {ReactFlowMarkers} from "../../../extensions/react-flow/markers/ReactFlowMarkers";
4
4
  import * as unspecifiedConfig from "./../configuration/unspecified";
5
5
  import * as graphConfig from "./../configuration/graph";
6
6
  import * as workflowConfig from "./../configuration/workflow";
7
7
  import * as linkingConfig from "./../configuration/linking";
8
+ import {useReactFlowScrollOnDrag} from "../extensions/scrollOnDragHook";
8
9
 
9
10
  export interface ReactFlowProps extends ReactFlowOriginalProps {
10
11
  /**
11
12
  * Load `ReactFlow` component with pre-configured values for `nodeTypes` and `edgeTypes`
12
13
  */
13
14
  configuration?: "unspecified" | "graph" | "workflow" | "linking";
15
+
16
+ /** If defined the canvas scrolls on all drag operations (node, selection, edge connect)
17
+ * when the mouse pointer comes near the canvas borders or goes beyond them.
18
+ * The `id` property of the ReactFlow component must be set in order for this to work.
19
+ *
20
+ * NOTE: If scrollOnDrag is defined, a ReactFlowProvider must be wrapped around this component (or a parent). */
21
+ scrollOnDrag?: {
22
+ /** Time in milliseconds to wait before the canvas scrolls the next step. */
23
+ scrollInterval: number
24
+
25
+ /**
26
+ * The size of each scroll step.
27
+ * This should be a number between 0.0 - 1.0.
28
+ * E.g. a value of 0.25 will lead to a scroll step size of a quarter of the visible canvas. */
29
+ scrollStepSize: number
30
+ }
14
31
  }
15
32
 
16
33
  /**
@@ -20,10 +37,17 @@ export interface ReactFlowProps extends ReactFlowOriginalProps {
20
37
  export const ReactFlow = React.forwardRef<HTMLDivElement, ReactFlowProps>((
21
38
  {
22
39
  configuration = "unspecified",
40
+ scrollOnDrag,
23
41
  children,
24
42
  ...originalProps
25
43
  },
26
44
  ref) => {
45
+
46
+ const scrollOnDragFunctions = useReactFlowScrollOnDrag({
47
+ reactFlowProps: originalProps,
48
+ scrollOnDrag
49
+ })
50
+
27
51
  const configReactFlow = {
28
52
  unspecified: unspecifiedConfig,
29
53
  graph: graphConfig,
@@ -37,6 +61,7 @@ export const ReactFlow = React.forwardRef<HTMLDivElement, ReactFlowProps>((
37
61
  nodeTypes={ configReactFlow[configuration].nodeTypes }
38
62
  edgeTypes={ configReactFlow[configuration].edgeTypes }
39
63
  {...originalProps}
64
+ {...scrollOnDragFunctions}
40
65
  >
41
66
  { children }
42
67
  <ReactFlowMarkers />
@@ -27,13 +27,17 @@ export interface StickyNoteModalProps {
27
27
  translate: (key: StickyNoteModalTranslationKeys) => string;
28
28
  }
29
29
 
30
- export const StickyNoteModal: React.FC<StickyNoteModalProps> = ({ metaData, onClose, onSubmit, translate }) => {
30
+ export const StickyNoteModal: React.FC<StickyNoteModalProps> = React.memo(({
31
+ metaData,
32
+ onClose,
33
+ onSubmit,
34
+ translate
35
+ }) => {
31
36
  const refNote = React.useRef<string>(metaData?.note ?? "");
32
37
  const [color, setSelectedColor] = React.useState<string>(metaData?.color ?? "");
33
- const noteColors: [string, string][] = Object.entries(getColorConfiguration("stickynotes")).map(([key, value]) => [
34
- key,
35
- value as string,
36
- ]);
38
+ const noteColors: [string, string][] = Object.entries(getColorConfiguration("stickynotes")).map(
39
+ ([key, value]) => [key, value as string]
40
+ );
37
41
 
38
42
  React.useEffect(() => {
39
43
  if (!color && noteColors[0][1]) {
@@ -131,4 +135,4 @@ export const StickyNoteModal: React.FC<StickyNoteModalProps> = ({ metaData, onCl
131
135
  </FieldItem>
132
136
  </SimpleDialog>
133
137
  );
134
- };
138
+ });
@@ -0,0 +1,247 @@
1
+ import {OnLoadParams, useStoreState} from "react-flow-renderer";
2
+ import React, {MouseEvent as ReactMouseEvent, useCallback} from "react";
3
+ import {
4
+ Edge,
5
+ Node,
6
+ OnConnectStartFunc,
7
+ OnConnectStartParams,
8
+ OnConnectStopFunc,
9
+ Transform
10
+ } from "react-flow-renderer/dist/types";
11
+ import {ReactFlowProps} from "../ReactFlow/ReactFlow";
12
+
13
+ interface IProps {
14
+ /** The original react-flow props. */
15
+ reactFlowProps: ReactFlowProps
16
+ /** If defined the canvas scrolls on all drag operations (node, selection, edge connect)
17
+ * when the mouse pointer comes near the canvas borders or goes beyond them.
18
+ * The `id` property of the ReactFlow component must be set in order for this to work. */
19
+ scrollOnDrag?: {
20
+ /** Time in milliseconds to wait before the canvas scrolls the next step. */
21
+ scrollInterval: number
22
+
23
+ /**
24
+ * The size of each scroll step.
25
+ * This should be a number between 0.0 - 1.0.
26
+ * E.g. a value of 0.25 will lead to a scroll step size of a quarter of the visible canvas. */
27
+ scrollStepSize: number
28
+ }
29
+ }
30
+
31
+ interface ScrollState {
32
+ // The react-flow instance
33
+ reactFlowInstance?: OnLoadParams
34
+ // The current x position of the react-flow view
35
+ currentX: number
36
+ // The current y position of the react-flow view
37
+ currentY: number
38
+ // The current Zoom level
39
+ currentZoom: number
40
+ // The current scroll function callback, when scrolling is active
41
+ scrollTaskId?: NodeJS.Timeout
42
+ // If a warning of the react-flow instance with the given ID has not been found
43
+ loggedWarning: boolean,
44
+ // If the x-axis is currently being scrolled
45
+ scrollX: boolean,
46
+ // If the y-axis is currently being scrolled
47
+ scrollY: boolean
48
+ // Only if this is true the canvas will scroll when moving the mouse past it
49
+ draggingOperationActive: boolean
50
+ }
51
+
52
+ type ReturnType = Pick<ReactFlowProps, "onLoad" | "onNodeDragStart" | "onNodeDragStop" | "onConnectStart" | "onConnectStop" |
53
+ "onSelectionDragStart" | "onSelectionDragStop" | "onEdgeUpdateStart" | "onEdgeUpdateEnd">
54
+
55
+ /** Handles the scrolling of the react-flow canvas on all drag operations when the mouse pointer gets near or over the borders.
56
+ * The return value contains the wrapped react-flow callback functions that need to be handed over to the react-flow component. */
57
+ export const useReactFlowScrollOnDrag = ({
58
+ reactFlowProps,
59
+ scrollOnDrag
60
+ }: IProps): ReturnType => {
61
+ /** Tracks the zoom on drag to border functionality. */
62
+ const scrollState = React.useRef<ScrollState>({
63
+ reactFlowInstance: undefined,
64
+ currentX: 0,
65
+ currentY: 0,
66
+ currentZoom: 1,
67
+ loggedWarning: false,
68
+ scrollX: false,
69
+ scrollY: false,
70
+ draggingOperationActive: false
71
+ })
72
+
73
+ const useStoreStateInternal = (): Transform => {
74
+ try {
75
+ return useStoreState((state) => state.transform)
76
+ } catch(ex) {
77
+ if(reactFlowProps.id && scrollOnDrag) {
78
+ console.warn("Scroll on drag is not correctly working. Reason: " + ex)
79
+ }
80
+ return [0, 0, 1]
81
+ }
82
+ }
83
+
84
+ /** The current position and zoom factor of the view port. */
85
+ const [currentX, currentY, currentZoom] = useStoreStateInternal()
86
+ scrollState.current.currentX = currentX
87
+ scrollState.current.currentY = currentY
88
+ scrollState.current.currentZoom = currentZoom
89
+
90
+ const originalOnLoad = reactFlowProps.onLoad
91
+ const originalOnNodeDragStart = reactFlowProps.onNodeDragStart
92
+ const originalOnNodeDragStop = reactFlowProps.onNodeDragStop
93
+ const originalOnConnectStart = reactFlowProps.onConnectStart
94
+ const originalOnConnectStop = reactFlowProps.onConnectStop
95
+ const originalOnSelectionDragStart = reactFlowProps.onSelectionDragStart
96
+ const originalOnSelectionDragStop = reactFlowProps.onSelectionDragStop
97
+ const originalOnEdgeUpdateStart = reactFlowProps.onEdgeUpdateStart
98
+ const originalOnEdgeUpdateEnd = reactFlowProps.onEdgeUpdateEnd
99
+
100
+ const scrollInterval = scrollOnDrag?.scrollInterval
101
+ const scrollStepSize = scrollOnDrag?.scrollStepSize
102
+
103
+ const reactFlowInstanceId = reactFlowProps.id
104
+
105
+ const clearIntervalIfExists = React.useCallback(() => {
106
+ if(scrollState.current.scrollTaskId) {
107
+ clearInterval(scrollState.current.scrollTaskId)
108
+ }
109
+ }, [])
110
+
111
+ const setScrolling = React.useCallback((active: boolean) => {
112
+ scrollState.current.draggingOperationActive = active
113
+ if(!active) {
114
+ clearIntervalIfExists()
115
+ }
116
+ }, [clearIntervalIfExists])
117
+
118
+ // Handle scrolling if any operation is active e.g. connecting or dragging a node
119
+ React.useEffect(() => {
120
+ if(scrollInterval && scrollStepSize && reactFlowInstanceId) {
121
+ const handleScrolling = (event: MouseEvent) => {
122
+ const state = scrollState.current
123
+ if(!state.draggingOperationActive) {
124
+ clearIntervalIfExists()
125
+ return
126
+ }
127
+ // Check if mouse pointer is outside of the canvas
128
+ const canvasElement = document.getElementById(reactFlowInstanceId)
129
+ if (!canvasElement) {
130
+ if (!state.loggedWarning) {
131
+ console.warn("No element found with ID " + reactFlowInstanceId)
132
+ state.loggedWarning = true
133
+ }
134
+ return
135
+ }
136
+ const boundingRect = canvasElement.getBoundingClientRect()
137
+ const xStepSize = boundingRect.width * scrollStepSize
138
+ const yStepSize = boundingRect.height * scrollStepSize
139
+ if (boundingRect.top > event.clientY || boundingRect.bottom < event.clientY ||
140
+ boundingRect.left > event.clientX || boundingRect.right < event.clientX) {
141
+ const scrollX: number = boundingRect.left > event.clientX ?
142
+ xStepSize :
143
+ boundingRect.right < event.clientX ?
144
+ -xStepSize :
145
+ 0
146
+ const scrollY: number = boundingRect.top > event.clientY ?
147
+ yStepSize :
148
+ boundingRect.bottom < event.clientY ?
149
+ -yStepSize :
150
+ 0
151
+ if (state.scrollY === (scrollY !== 0) && state.scrollX === (scrollX !== 0)) {
152
+ // Nothing has changed, do not change interval function
153
+ return
154
+ }
155
+ clearIntervalIfExists()
156
+ state.scrollTaskId = setInterval(() => {
157
+ state.reactFlowInstance?.setTransform({
158
+ x: state.currentX + scrollX,
159
+ y: state.currentY + scrollY,
160
+ zoom: state.currentZoom
161
+ })
162
+ }, scrollInterval)
163
+ } else {
164
+ clearIntervalIfExists()
165
+ }
166
+ }
167
+ const disableScrollingOnMouseUp = () => {
168
+ scrollState.current.draggingOperationActive = false
169
+ clearIntervalIfExists()
170
+ }
171
+ document.addEventListener('mousemove', handleScrolling);
172
+ document.addEventListener("mouseup", disableScrollingOnMouseUp)
173
+ return () => {
174
+ document.removeEventListener('mousemove', handleScrolling)
175
+ document.removeEventListener("mouseup", disableScrollingOnMouseUp)
176
+ }
177
+ } else {
178
+ return undefined
179
+ }
180
+ }, [scrollInterval, scrollStepSize, reactFlowInstanceId, clearIntervalIfExists])
181
+
182
+ const onLoad = useCallback(
183
+ (rfi: OnLoadParams) => {
184
+ scrollState.current.reactFlowInstance = rfi;
185
+ originalOnLoad?.(rfi)
186
+ },
187
+ [originalOnLoad]
188
+ );
189
+
190
+ /** Wrap original callbacks to turn scrolling on and off. */
191
+ const onConnectStart: OnConnectStartFunc = React.useCallback((event: ReactMouseEvent, params: OnConnectStartParams) => {
192
+ setScrolling(true)
193
+ originalOnConnectStart?.(event, params)
194
+ }, [originalOnConnectStart, setScrolling])
195
+
196
+ const onConnectStop: OnConnectStopFunc = React.useCallback((event: MouseEvent) => {
197
+ setScrolling(false)
198
+ originalOnConnectStop?.(event)
199
+ }, [originalOnConnectStop, setScrolling])
200
+
201
+ const onNodeDragStart = React.useCallback((event: ReactMouseEvent, node: Node) => {
202
+ setScrolling(true)
203
+ originalOnNodeDragStart?.(event, node)
204
+ }, [originalOnNodeDragStart, setScrolling])
205
+
206
+ const onNodeDragStop = React.useCallback((event: ReactMouseEvent, node: Node) => {
207
+ setScrolling(false)
208
+ originalOnNodeDragStop?.(event, node)
209
+ }, [originalOnNodeDragStop, setScrolling])
210
+
211
+ const onSelectionDragStart = React.useCallback((event: ReactMouseEvent, nodes: Node[]) => {
212
+ setScrolling(true)
213
+ originalOnSelectionDragStart?.(event, nodes)
214
+ }, [originalOnSelectionDragStart, setScrolling])
215
+
216
+ const onSelectionDragStop = React.useCallback((event: ReactMouseEvent, nodes: Node[]) => {
217
+ setScrolling(false)
218
+ originalOnSelectionDragStop?.(event, nodes)
219
+ }, [originalOnSelectionDragStop, setScrolling])
220
+
221
+ const onEdgeUpdateStart = React.useCallback((event: ReactMouseEvent, edge: Edge) => {
222
+ setScrolling(true)
223
+ originalOnEdgeUpdateStart?.(event, edge)
224
+ }, [originalOnEdgeUpdateStart, setScrolling])
225
+
226
+ const onEdgeUpdateEnd = React.useCallback((event: MouseEvent, edge: Edge) => {
227
+ setScrolling(false)
228
+ originalOnEdgeUpdateEnd?.(event, edge)
229
+ }, [originalOnEdgeUpdateEnd, setScrolling])
230
+
231
+ if (!reactFlowProps.id || !scrollOnDrag) {
232
+ // No instance ID or config available, return empty object that will not overwrite any react-flow config parameters
233
+ return {}
234
+ } else {
235
+ return {
236
+ onLoad,
237
+ onNodeDragStart,
238
+ onNodeDragStop,
239
+ onConnectStart,
240
+ onConnectStop,
241
+ onSelectionDragStart,
242
+ onSelectionDragStop,
243
+ onEdgeUpdateStart,
244
+ onEdgeUpdateEnd
245
+ }
246
+ }
247
+ }
@@ -1,23 +1,27 @@
1
1
  import { CLASSPREFIX as eccgui } from "../../configuration/constants";
2
2
 
3
- export const Definitions: { [key: string]: string; } = {
4
- PRIMARY: "primary" as "primary",
5
- ACCENT: "accent" as "accent",
6
- NEUTRAL: "neutral" as "neutral",
7
- SUCCESS: "success" as "success",
8
- INFO: "info" as "info",
9
- WARNING: "warning" as "warning",
10
- DANGER: "danger" as "danger",
3
+ export type IntentTypes = "neutral" | "primary" | "accent" | "info" | "success" | "warning" | "danger";
4
+
5
+ export const Definitions: { [key: string]: IntentTypes; } = {
6
+ PRIMARY: "primary",
7
+ ACCENT: "accent",
8
+ NEUTRAL: "neutral",
9
+ SUCCESS: "success",
10
+ INFO: "info",
11
+ WARNING: "warning",
12
+ DANGER: "danger",
13
+ }
14
+
15
+ export const intentClassName = (intent: IntentTypes) => {
16
+ return `${eccgui}-intent--${intent}`
11
17
  }
12
18
 
13
19
  const classNamesCreation = () => {
14
- const intentClasses = {...Definitions};
20
+ const intentClasses : { [key: string]: string; } = {};
15
21
  for (let intentDefinition in Definitions) {
16
- intentClasses[intentDefinition] = `${eccgui}-intent--${Definitions[intentDefinition]}`;
22
+ intentClasses[intentDefinition] = intentClassName(Definitions[intentDefinition]);
17
23
  }
18
24
  return intentClasses;
19
25
  }
20
26
 
21
27
  export const ClassNames = classNamesCreation();
22
-
23
- export type IntentTypes = typeof Definitions[keyof typeof Definitions];
@@ -0,0 +1,111 @@
1
+ /** Zero width invisible characters, i.e. they do not change the space between 2 other characters. */
2
+ const internalInvisibleZeroWidthCharacterCodePoints: InternalInvisibleCharacter[] = [
3
+ { codePoint: 11, label: "Vertical Tabulation" },
4
+ { codePoint: 173, label: "Soft hyphen" },
5
+ { codePoint: 847, label: "Combining grapheme joiner" },
6
+ { codePoint: 1564, label: "Arabic letter mark" },
7
+ { codePoint: [6068, 6069], label: "Khmer vowel inherent" },
8
+ { codePoint: [6155, 6158], label: "Mongolian special characters" },
9
+ { codePoint: 8203, label: "Zero Width Space" },
10
+ { codePoint: 8204, label: "Zero Width Non-Joiner" },
11
+ { codePoint: 8205, label: "Zero Width Joiner" },
12
+ { codePoint: 8206, label: "Left-To-Right Mark" },
13
+ { codePoint: 8207, label: "Right-To-Left Mark" },
14
+ { codePoint: [8234, 8238], label: "zero width character" },
15
+ // Word joiner - Nominal Digit Shapes
16
+ { codePoint: [8288, 8303], label: "zero width character" },
17
+ { codePoint: [65024, 65039], label: "Variation selectors" },
18
+ { codePoint: 65279, label: "Zero Width No-Break Space" },
19
+ { codePoint: [65520, 65528], label: "Specials" },
20
+ { codePoint: 65532, label: "Object Replacement Character" },
21
+ { codePoint: [119155, 119162], label: "Invisible Musical Symbol" },
22
+ { codePoint: [917504, 917631], label: "Tags" },
23
+ { codePoint: [917760, 917999], label: "Variation Selectors" }
24
+ ]
25
+
26
+ const toHex = (codepoint: number): string => codepoint.toString(16).toUpperCase()
27
+
28
+ const padWithZeroes = (hexString: string): string => {
29
+ if(hexString.length % 2 === 1) {
30
+ return `0${hexString}`
31
+ }
32
+ return hexString
33
+ }
34
+
35
+ /** All characters that are considered invisible zero-width characters that e.g. need to be handled in input fields. */
36
+ const invisibleZeroWidthCharacterCodePoints: InvisibleCharacter[] = internalInvisibleZeroWidthCharacterCodePoints.map(cp => {
37
+ const create = (codePoint: number, label?: string) => {
38
+ const hexString = toHex(codePoint)
39
+ const unicodeHexRepresentation = `U+${padWithZeroes(hexString)}`
40
+ return {
41
+ codePoint: codePoint,
42
+ label: label ?? unicodeHexRepresentation,
43
+ hexString,
44
+ fullLabel: label ? `${label} (${unicodeHexRepresentation})` : unicodeHexRepresentation
45
+ }
46
+ }
47
+ if(Array.isArray(cp.codePoint)) {
48
+ const codePoints: InvisibleCharacter[] = []
49
+ const [from, to] = cp.codePoint
50
+ if(from < 0 || to < 0 || from > to) {
51
+ throw new Error(`Invalid code point range specified: [${from}, ${to}]`)
52
+ }
53
+ for(let currentCp = from; currentCp <= to; currentCp++) {
54
+ codePoints.push(create(currentCp, cp.label))
55
+ }
56
+ return codePoints
57
+ } else {
58
+ return create(cp.codePoint, cp.label)
59
+ }
60
+ }).flat()
61
+
62
+ const createInvisibleZeroWidthCharacterCodePointsRegex = () => {
63
+ return new RegExp(
64
+ `([${
65
+ invisibleZeroWidthCharacterCodePoints
66
+ .map(cp => `\\u{${cp.hexString}}`)
67
+ .join("")
68
+ }])`,
69
+ "ug"
70
+ )
71
+ }
72
+
73
+ /** Map from codepoint to invisible character. */
74
+ const invisibleZeroWidthCharacterCodePointsMap: Map<number, InvisibleCharacter> = new Map(
75
+ invisibleZeroWidthCharacterCodePoints.map(cp => [cp.codePoint, cp])
76
+ )
77
+
78
+ const clearStringFromInvisibleCharacters = (inputString: string): string => {
79
+ const regex = createInvisibleZeroWidthCharacterCodePointsRegex()
80
+ return inputString.replaceAll(regex, "")
81
+ }
82
+
83
+ interface InternalInvisibleCharacter {
84
+ /** Code point or code point range (inclusive on both sides). */
85
+ codePoint: number | [number, number],
86
+ /** Human readable label for code point. */
87
+ label?: string
88
+ }
89
+
90
+ type InvisibleCharacter = {
91
+ /** Code point. */
92
+ codePoint: number,
93
+ /** Human readable label for code point. */
94
+ label: string
95
+ /** The hex representation of the code point, e.g. "200B" */
96
+ hexString: string
97
+ /** The label plus the hex value. */
98
+ fullLabel: string
99
+ }
100
+
101
+ const invisibleZeroWidthCharacters = {
102
+ codePoints: invisibleZeroWidthCharacterCodePoints,
103
+ codePointMap: invisibleZeroWidthCharacterCodePointsMap,
104
+ createRegex: createInvisibleZeroWidthCharacterCodePointsRegex,
105
+ clearString: clearStringFromInvisibleCharacters
106
+ }
107
+
108
+ const moduleObject = {
109
+ invisibleZeroWidthCharacters
110
+ }
111
+ export default moduleObject
@@ -1,11 +1,12 @@
1
+ // lib import
2
+ @use "~@carbon/styles/scss/components/accordion/accordion";
3
+ @include accordion.accordion;
4
+
1
5
  // own vars
2
6
  $eccgui-color-accordion-background-elevated: rgba($eccgui-color-accent, 0.1) !default;
3
7
  $eccgui-color-accordion-toggler-hover: $menu-item-color-hover !default;
4
8
  $eccgui-color-accordion-toggler-elevated-hover: mix($eccgui-color-accordion-background-elevated, $eccgui-color-accordion-toggler-hover, 50%) !default;
5
9
 
6
- // lib import
7
- @import "~carbon-components/scss/components/accordion/accordion";
8
-
9
10
  // changes
10
11
 
11
12
  .#{$prefix}--accordion__heading {
@@ -58,7 +58,7 @@ function ApplicationTitle({
58
58
  }: IApplicationTitleProps) {
59
59
 
60
60
  const classApplication = `${eccgui}-application__title`;
61
- const classNotDisplayed = isNotDisplayed || (!isApplicationSidebarExpanded && typeof isNotDisplayed === "undefined") ? "bx--visually-hidden" : "";
61
+ const classNotDisplayed = isNotDisplayed || (!isApplicationSidebarExpanded && typeof isNotDisplayed === "undefined") ? "cds--visually-hidden" : "";
62
62
  const classAlignedSidebar = isAlignedWithSidebar || isApplicationSidebarExpanded ? `${eccgui}-application__title--withsidebar` : "";
63
63
 
64
64
  return (
@@ -77,7 +77,7 @@ function ApplicationTitle({
77
77
  )}
78
78
  {!!prefix && (
79
79
  <>
80
- <span className="bx--header__name--prefix">{prefix}</span>
80
+ <span className="cds--header__name--prefix">{prefix}</span>
81
81
  &nbsp;
82
82
  </>
83
83
  )}
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  /// should be already imported
8
- //@import '~carbon-components/scss/globals/scss/colors';
8
+ //@import '~@carbon/styles/scss/colors';
9
9
 
10
10
  /*
11
11
  //----------------------------------------------------------------------------
@@ -1,6 +1,6 @@
1
1
  $ui-02: $eccgui-color-workspace-background !default;
2
2
 
3
- @import "~carbon-components/scss/components/ui-shell/content";
3
+ @import "~@carbon/styles/scss/components/ui-shell/content/index";
4
4
 
5
5
  // tweack original layout
6
6
 
@@ -45,10 +45,10 @@ $shell-header-icon-02: $eccgui-color-applicationheader-text !default;
45
45
  $shell-header-icon-03: $eccgui-color-applicationheader-text !default;
46
46
 
47
47
  /// Item link
48
- $shell-header-link: $carbon--blue-60 !default;
48
+ $shell-header-link: $blue-60 !default;
49
49
 
50
50
  // load library sub component
51
- @import '~carbon-components/scss/components/ui-shell/header';
51
+ @import '~@carbon/styles/scss/components/ui-shell/header/index';
52
52
 
53
53
  // tweack original layout
54
54
 
@@ -1,8 +1,8 @@
1
1
  $ui-02: $eccgui-color-workspace-background !default;
2
2
 
3
- @import '~carbon-components/scss/components/ui-shell/side-nav';
3
+ @import '~@carbon/styles/scss/components/ui-shell/side-nav/index';
4
4
 
5
- // tweack original layout
5
+ // tweak original layout
6
6
 
7
7
  .#{$prefix}--side-nav--ux {
8
8
  top: mini-units(8);
@@ -10,13 +10,6 @@ $ui-02: $eccgui-color-workspace-background !default;
10
10
  max-width: mini-units(40);
11
11
  }
12
12
 
13
- /*
14
- .#{$prefix}--side-nav.#{$prefix}--side-nav--rail:not(.#{$prefix}--side-nav--fixed):hover,
15
- .#{$prefix}--side-nav--expanded, .#{$prefix}--side-nav--collapsed {
16
- width: mini-units(40);
17
- }
18
- */
19
-
20
13
  .#{$prefix}--side-nav.#{$prefix}--side-nav--rail:not(.#{$prefix}--side-nav--fixed) {
21
14
  transform: translateX(0);
22
15
  width: mini-units(8);
@@ -30,7 +30,7 @@ $shell-panel-text-02: $eccgui-color-applicationheader-text !default;
30
30
  /// Header panel focus border
31
31
  $shell-panel-focus: adjust-color($eccgui-color-applicationheader-text, $lightness: 39%) !default;
32
32
 
33
- @import "~carbon-components/scss/components/ui-shell/header-panel";
33
+ @import "~@carbon/styles/scss/components/ui-shell/header-panel/index";
34
34
 
35
35
  // tweack original layout
36
36
 
@@ -1,9 +1,9 @@
1
1
  // @import 'config';
2
- @import '~carbon-components/scss/components/ui-shell/functions';
2
+ @import '~@carbon/styles/scss/components/ui-shell/functions';
3
3
  @import 'header';
4
4
  @import 'toolbar';
5
- // @import '~carbon-components/scss/components/ui-shell/product-switcher'; // TODO needs to be depracated and redone to match react
6
- // @import '~carbon-components/scss/components/ui-shell/switcher';
5
+ // @import '~@carbon/styles/scss/components/ui-shell/product-switcher';
6
+ // @import '~@carbon/styles/scss/components/ui-shell/switcher';
7
7
  @import 'sidebar';
8
- // @import '~carbon-components/scss/components/ui-shell/navigation-menu';
8
+ // @import '~@carbon/styles/scss/components/ui-shell/navigation-menu';
9
9
  @import 'content';
@@ -1,24 +1,29 @@
1
1
  import React from "react";
2
- import {IElementWidth, IRenderModifiers} from "./AutoCompleteField";
2
+ import { IElementWidth, IRenderModifiers } from "./AutoCompleteField";
3
3
  import OverflowText from "../Typography/OverflowText";
4
4
  import MenuItem from "../Menu/MenuItem";
5
- import {ValidIconName} from "../Icon/canonicalIconNames";
5
+ import { TestIconProps } from "./../Icon/TestIcon";
6
+ import { ValidIconName } from "../Icon/canonicalIconNames";
6
7
 
7
- /** Returns a function to be used in an AutoComplete widget for rendering custom elements based on the query string.
8
+ /**
9
+ * Returns a function to be used in an AutoComplete widget for rendering custom elements based on the query string.
8
10
  *
9
11
  * @param itemTextRenderer The text or element that should be displayed for the new custom item suggestion.
10
12
  * @param iconName Optional icon to show left to the text.
11
13
  */
12
14
  export const createNewItemRendererFactory = (
13
15
  itemTextRenderer: (query: string, styleWidth: IElementWidth) => string | JSX.Element,
14
- iconName?: ValidIconName) => {
16
+ iconName?: ValidIconName | React.ReactElement<TestIconProps>
17
+ ) => {
15
18
  // Return custom render function
16
19
  return (query: string, modifiers: IRenderModifiers, handleClick: React.MouseEventHandler<HTMLElement>) => {
17
20
  let textElement = itemTextRenderer(query, modifiers.styleWidth)
18
- if(typeof textElement === "string") {
19
- textElement = <OverflowText style={modifiers.styleWidth}>
20
- {textElement.trim() !== "" ? textElement : `Create option '${query}'`}
21
- </OverflowText>
21
+ if (typeof textElement === "string") {
22
+ textElement = (
23
+ <OverflowText style={modifiers.styleWidth}>
24
+ {textElement.trim() !== "" ? textElement : `Create option '${query}'`}
25
+ </OverflowText>
26
+ )
22
27
  }
23
28
  return (
24
29
  <MenuItem