@eccenca/gui-elements 23.2.0-rc.0 → 23.2.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 (140) hide show
  1. package/CHANGELOG.md +32 -3
  2. package/dist/cjs/components/AutoSuggestion/AutoSuggestion.js +24 -20
  3. package/dist/cjs/components/AutoSuggestion/AutoSuggestion.js.map +1 -1
  4. package/dist/cjs/components/AutocompleteField/AutoCompleteField.js +59 -50
  5. package/dist/cjs/components/AutocompleteField/AutoCompleteField.js.map +1 -1
  6. package/dist/cjs/components/AutocompleteField/autoCompleteFieldUtils.js +3 -3
  7. package/dist/cjs/components/AutocompleteField/autoCompleteFieldUtils.js.map +1 -1
  8. package/dist/cjs/components/Breadcrumb/BreadcrumbItem.js +9 -6
  9. package/dist/cjs/components/Breadcrumb/BreadcrumbItem.js.map +1 -1
  10. package/dist/cjs/components/CodeAutocompleteField/CodeAutocompleteField.js +33 -0
  11. package/dist/cjs/components/CodeAutocompleteField/CodeAutocompleteField.js.map +1 -0
  12. package/dist/cjs/components/CodeAutocompleteField/index.js +14 -0
  13. package/dist/cjs/components/CodeAutocompleteField/index.js.map +1 -0
  14. package/dist/cjs/components/Depiction/Depiction.js +13 -13
  15. package/dist/cjs/components/Depiction/Depiction.js.map +1 -1
  16. package/dist/cjs/components/Dialog/SimpleDialog.js +5 -5
  17. package/dist/cjs/components/Dialog/SimpleDialog.js.map +1 -1
  18. package/dist/cjs/components/Icon/IconButton.js +9 -3
  19. package/dist/cjs/components/Icon/IconButton.js.map +1 -1
  20. package/dist/cjs/components/Icon/canonicalIconNames.js +2 -0
  21. package/dist/cjs/components/Icon/canonicalIconNames.js.map +1 -1
  22. package/dist/cjs/components/MultiSelect/MultiSelect.js +45 -17
  23. package/dist/cjs/components/MultiSelect/MultiSelect.js.map +1 -1
  24. package/dist/cjs/components/MultiSuggestField/MultiSuggestField.js +33 -0
  25. package/dist/cjs/components/MultiSuggestField/MultiSuggestField.js.map +1 -0
  26. package/dist/cjs/components/OverviewItem/OverviewItem.js +8 -10
  27. package/dist/cjs/components/OverviewItem/OverviewItem.js.map +1 -1
  28. package/dist/cjs/components/PropertyValuePair/PropertyName.js +4 -3
  29. package/dist/cjs/components/PropertyValuePair/PropertyName.js.map +1 -1
  30. package/dist/cjs/components/Select/Select.js +18 -3
  31. package/dist/cjs/components/Select/Select.js.map +1 -1
  32. package/dist/cjs/components/SuggestField/SuggestField.js +39 -0
  33. package/dist/cjs/components/SuggestField/SuggestField.js.map +1 -0
  34. package/dist/cjs/components/SuggestField/index.js +19 -0
  35. package/dist/cjs/components/SuggestField/index.js.map +1 -0
  36. package/dist/cjs/components/index.js +3 -0
  37. package/dist/cjs/components/index.js.map +1 -1
  38. package/dist/cjs/extensions/react-flow/nodes/NodeContent.js +54 -41
  39. package/dist/cjs/extensions/react-flow/nodes/NodeContent.js.map +1 -1
  40. package/dist/cjs/index.js +1 -0
  41. package/dist/cjs/index.js.map +1 -1
  42. package/dist/esm/components/AutoSuggestion/AutoSuggestion.js +23 -18
  43. package/dist/esm/components/AutoSuggestion/AutoSuggestion.js.map +1 -1
  44. package/dist/esm/components/AutocompleteField/AutoCompleteField.js +68 -59
  45. package/dist/esm/components/AutocompleteField/AutoCompleteField.js.map +1 -1
  46. package/dist/esm/components/AutocompleteField/autoCompleteFieldUtils.js +3 -3
  47. package/dist/esm/components/AutocompleteField/autoCompleteFieldUtils.js.map +1 -1
  48. package/dist/esm/components/Breadcrumb/BreadcrumbItem.js +9 -6
  49. package/dist/esm/components/Breadcrumb/BreadcrumbItem.js.map +1 -1
  50. package/dist/esm/components/CodeAutocompleteField/CodeAutocompleteField.js +37 -0
  51. package/dist/esm/components/CodeAutocompleteField/CodeAutocompleteField.js.map +1 -0
  52. package/dist/esm/components/CodeAutocompleteField/index.js +2 -0
  53. package/dist/esm/components/CodeAutocompleteField/index.js.map +1 -0
  54. package/dist/esm/components/Depiction/Depiction.js +12 -12
  55. package/dist/esm/components/Depiction/Depiction.js.map +1 -1
  56. package/dist/esm/components/Dialog/SimpleDialog.js +7 -7
  57. package/dist/esm/components/Dialog/SimpleDialog.js.map +1 -1
  58. package/dist/esm/components/Icon/IconButton.js +10 -4
  59. package/dist/esm/components/Icon/IconButton.js.map +1 -1
  60. package/dist/esm/components/Icon/canonicalIconNames.js +2 -0
  61. package/dist/esm/components/Icon/canonicalIconNames.js.map +1 -1
  62. package/dist/esm/components/MultiSelect/MultiSelect.js +52 -22
  63. package/dist/esm/components/MultiSelect/MultiSelect.js.map +1 -1
  64. package/dist/esm/components/MultiSuggestField/MultiSuggestField.js +37 -0
  65. package/dist/esm/components/MultiSuggestField/MultiSuggestField.js.map +1 -0
  66. package/dist/esm/components/OverviewItem/OverviewItem.js +8 -10
  67. package/dist/esm/components/OverviewItem/OverviewItem.js.map +1 -1
  68. package/dist/esm/components/PropertyValuePair/PropertyName.js +4 -3
  69. package/dist/esm/components/PropertyValuePair/PropertyName.js.map +1 -1
  70. package/dist/esm/components/Select/Select.js +19 -4
  71. package/dist/esm/components/Select/Select.js.map +1 -1
  72. package/dist/esm/components/SuggestField/SuggestField.js +43 -0
  73. package/dist/esm/components/SuggestField/SuggestField.js.map +1 -0
  74. package/dist/esm/components/SuggestField/index.js +6 -0
  75. package/dist/esm/components/SuggestField/index.js.map +1 -0
  76. package/dist/esm/components/index.js +3 -0
  77. package/dist/esm/components/index.js.map +1 -1
  78. package/dist/esm/extensions/react-flow/nodes/NodeContent.js +51 -39
  79. package/dist/esm/extensions/react-flow/nodes/NodeContent.js.map +1 -1
  80. package/dist/esm/index.js +2 -1
  81. package/dist/esm/index.js.map +1 -1
  82. package/dist/types/components/AutoSuggestion/AutoSuggestion.d.ts +35 -4
  83. package/dist/types/components/AutocompleteField/AutoCompleteField.d.ts +23 -6
  84. package/dist/types/components/AutocompleteField/autoCompleteFieldUtils.d.ts +3 -3
  85. package/dist/types/components/AutocompleteField/index.d.ts +1 -1
  86. package/dist/types/components/AutocompleteField/interfaces.d.ts +1 -1
  87. package/dist/types/components/CodeAutocompleteField/CodeAutocompleteField.d.ts +10 -0
  88. package/dist/types/components/CodeAutocompleteField/index.d.ts +1 -0
  89. package/dist/types/components/Dialog/SimpleDialog.d.ts +2 -2
  90. package/dist/types/components/Icon/IconButton.d.ts +2 -2
  91. package/dist/types/components/Icon/canonicalIconNames.d.ts +1 -1
  92. package/dist/types/components/MultiSelect/MultiSelect.d.ts +20 -2
  93. package/dist/types/components/MultiSuggestField/MultiSuggestField.d.ts +10 -0
  94. package/dist/types/components/PropertyValuePair/PropertyName.d.ts +5 -1
  95. package/dist/types/components/Select/Select.d.ts +28 -9
  96. package/dist/types/components/SuggestField/SuggestField.d.ts +16 -0
  97. package/dist/types/components/SuggestField/index.d.ts +5 -0
  98. package/dist/types/components/index.d.ts +3 -0
  99. package/dist/types/extensions/react-flow/nodes/NodeContent.d.ts +7 -7
  100. package/dist/types/index.d.ts +2 -1
  101. package/package.json +1 -1
  102. package/src/components/Application/_header.scss +49 -58
  103. package/src/components/AutoSuggestion/AutoSuggestion.stories.tsx +14 -0
  104. package/src/components/AutoSuggestion/AutoSuggestion.tsx +280 -221
  105. package/src/components/AutocompleteField/AutoCompleteField.stories.tsx +14 -0
  106. package/src/components/AutocompleteField/AutoCompleteField.tsx +157 -121
  107. package/src/components/AutocompleteField/autoCompleteFieldUtils.tsx +10 -16
  108. package/src/components/AutocompleteField/interfaces.ts +5 -6
  109. package/src/components/Breadcrumb/BreadcrumbItem.tsx +19 -18
  110. package/src/components/Breadcrumb/breadcrumb.scss +18 -16
  111. package/src/components/Breadcrumb/stories/BreadcrumbList.stories.tsx +18 -15
  112. package/src/components/CodeAutocompleteField/CodeAutocompleteField.stories.tsx +89 -0
  113. package/src/components/CodeAutocompleteField/CodeAutocompleteField.tsx +22 -0
  114. package/src/components/CodeAutocompleteField/index.ts +1 -0
  115. package/src/components/ContextOverlay/contextoverlay.scss +10 -2
  116. package/src/components/Depiction/Depiction.tsx +57 -55
  117. package/src/components/Dialog/SimpleDialog.tsx +20 -33
  118. package/src/components/Icon/IconButton.tsx +25 -11
  119. package/src/components/Icon/canonicalIconNames.tsx +4 -0
  120. package/src/components/MultiSelect/MultiSelect.stories.tsx +9 -47
  121. package/src/components/MultiSelect/MultiSelect.tsx +110 -66
  122. package/src/components/MultiSuggestField/MultiSuggestField.stories.tsx +58 -0
  123. package/src/components/MultiSuggestField/MultiSuggestField.tsx +22 -0
  124. package/src/components/Notification/notification.scss +20 -17
  125. package/src/components/OverviewItem/OverviewItem.tsx +11 -20
  126. package/src/components/PropertyValuePair/PropertyName.tsx +17 -4
  127. package/src/components/PropertyValuePair/propertyvalue.scss +17 -1
  128. package/src/components/Select/Select.stories.tsx +49 -20
  129. package/src/components/Select/Select.tsx +96 -18
  130. package/src/components/Select/_select.scss +13 -1
  131. package/src/components/SuggestField/SuggestField.stories.tsx +99 -0
  132. package/src/components/SuggestField/SuggestField.tsx +28 -0
  133. package/src/components/SuggestField/index.ts +5 -0
  134. package/src/components/TagInput/taginput.scss +14 -0
  135. package/src/components/index.scss +1 -1
  136. package/src/components/index.ts +3 -0
  137. package/src/extensions/react-flow/nodes/NodeContent.tsx +105 -87
  138. package/src/index.ts +2 -5
  139. package/src/components/AutoSuggestion/stories/AutoSuggestion.stories.tsx +0 -83
  140. package/src/components/AutocompleteField/stories/AutoCompleteField.stories.tsx +0 -86
@@ -1,17 +1,19 @@
1
1
  import React from "react";
2
- import Color from "color";
3
- import { Resizable } from "re-resizable";
4
2
  import { Position, useStoreState as getStoreStateFlowLegacy } from "react-flow-renderer";
5
3
  import { useStore as getStoreStateFlowNext } from "react-flow-renderer-lts";
6
- import { Icon, Depiction, OverflowText } from "../../../index";
7
- import { CLASSPREFIX as eccgui } from "../../../configuration/constants";
8
- import { ValidIconName } from "../../../components/Icon/canonicalIconNames";
4
+ import Color from "color";
5
+ import { Resizable } from "re-resizable";
6
+
7
+ import { intentClassName, IntentTypes } from "../../../common/Intent";
9
8
  import { DepictionProps } from "../../../components/Depiction/Depiction";
10
- import { IntentTypes, intentClassName } from "../../../common/Intent";
9
+ import { ValidIconName } from "../../../components/Icon/canonicalIconNames";
10
+ import { CLASSPREFIX as eccgui } from "../../../configuration/constants";
11
+ import { Depiction, Icon, OverflowText } from "../../../index";
11
12
  import { ReacFlowVersionSupportProps, useReactFlowVersion } from "../versionsupport";
12
- import { HandleDefault, HandleProps, HandleNextProps } from "./../handles/HandleDefault";
13
- import { NodeProps } from "./NodeDefault";
13
+
14
+ import { HandleDefault, HandleNextProps, HandleProps } from "./../handles/HandleDefault";
14
15
  import { NodeContentExtensionProps } from "./NodeContentExtension";
16
+ import { NodeProps } from "./NodeDefault";
15
17
  import { HighlightingState, NodeHighlightColor } from "./sharedTypes";
16
18
 
17
19
  // @deprecated use `NodeContentProps<any>['highlightedState']` (or import from `src/extensions/react-flow/nodes/sharedTypes`)
@@ -24,7 +26,7 @@ interface NodeContentHandleLegacyProps extends HandleProps {
24
26
  // @deprecated use `NodeContentHandleProps`
25
27
  export type IHandleProps = NodeContentHandleLegacyProps;
26
28
 
27
- interface NodeContentHandleNextProps extends HandleNextProps {
29
+ export interface NodeContentHandleNextProps extends HandleNextProps {
28
30
  category?: "configuration";
29
31
  }
30
32
 
@@ -74,7 +76,8 @@ interface NodeContentData<CONTENT_PROPS = any> {
74
76
  }
75
77
 
76
78
  export interface NodeContentProps<NODE_DATA, NODE_CONTENT_PROPS = any>
77
- extends NodeContentData, ReacFlowVersionSupportProps,
79
+ extends NodeContentData,
80
+ ReacFlowVersionSupportProps,
78
81
  Omit<React.HTMLAttributes<HTMLDivElement>, "content"> {
79
82
  /**
80
83
  * Size of the node.
@@ -174,12 +177,12 @@ export interface NodeContentProps<NODE_DATA, NODE_CONTENT_PROPS = any>
174
177
  * This property is only forwarded from the `NodeDefault` element.
175
178
  * If set then it will be always overwritten internally.
176
179
  */
177
- targetPosition?: typeof Position[keyof typeof Position];
180
+ targetPosition?: (typeof Position)[keyof typeof Position];
178
181
  /**
179
182
  * This property is only forwarded from the `NodeDefault` element.
180
183
  * If set then it will be always overwritten internally.
181
184
  */
182
- sourcePosition?: typeof Position[keyof typeof Position];
185
+ sourcePosition?: (typeof Position)[keyof typeof Position];
183
186
  /**
184
187
  * This property is only forwarded from the `NodeDefault` element.
185
188
  * If set then it will be always overwritten internally.
@@ -230,7 +233,7 @@ const defaultHandles = (flowVersion: ReacFlowVersionSupportProps["flowVersion"])
230
233
  default:
231
234
  return [];
232
235
  }
233
- }
236
+ };
234
237
 
235
238
  const getDefaultMinimalTooltipData = (node: any) => {
236
239
  return {
@@ -241,7 +244,14 @@ const getDefaultMinimalTooltipData = (node: any) => {
241
244
  };
242
245
  };
243
246
 
244
- const addHandles = (handles: any, position: any, posDirection: any, isConnectable: any, nodeStyle: any, flowVersion: any = "legacy") => {
247
+ const addHandles = (
248
+ handles: any,
249
+ position: any,
250
+ posDirection: any,
251
+ isConnectable: any,
252
+ nodeStyle: any,
253
+ flowVersion: any = "legacy"
254
+ ) => {
245
255
  return handles[position].map((handle: any, idx: any) => {
246
256
  const { className, style = {}, category } = handle;
247
257
  const styleAdditions: { [key: string]: string } = {
@@ -255,7 +265,7 @@ const addHandles = (handles: any, position: any, posDirection: any, isConnectabl
255
265
  style: { ...style, ...styleAdditions },
256
266
  posdirection: posDirection,
257
267
  isConnectable: typeof handle.isConnectable !== "undefined" ? handle.isConnectable : isConnectable,
258
- className: !!category
268
+ className: category
259
269
  ? (className ? className + " " : "") +
260
270
  gethighlightedStateClasses(category, `${eccgui}-graphviz__handle`)
261
271
  : className,
@@ -265,14 +275,9 @@ const addHandles = (handles: any, position: any, posDirection: any, isConnectabl
265
275
  });
266
276
  };
267
277
 
268
- const gethighlightedStateClasses = (
269
- state: HighlightingState | HighlightingState[],
270
- baseClassName: string
271
- ) => {
272
- let hightlights = typeof state === "string" ? [state] : state;
273
- return hightlights.map(
274
- (item : HighlightingState) => `${baseClassName}--highlight-${item}`
275
- ).join(" ");
278
+ const gethighlightedStateClasses = (state: HighlightingState | HighlightingState[], baseClassName: string) => {
279
+ const hightlights = typeof state === "string" ? [state] : state;
280
+ return hightlights.map((item: HighlightingState) => `${baseClassName}--highlight-${item}`).join(" ");
276
281
  };
277
282
 
278
283
  const MemoHandler = React.memo(
@@ -281,9 +286,8 @@ const MemoHandler = React.memo(
281
286
  return (
282
287
  // we only test a few properties to control re-rendering
283
288
  // need to be extended if also other properties need to be changed late
284
- prev.style[prev.posdirection] === next.style[next.posdirection]
285
- && prev.isConnectable === next.isConnectable
286
- )
289
+ prev.style[prev.posdirection] === next.style[next.posdirection] && prev.isConnectable === next.isConnectable
290
+ );
287
291
  }
288
292
  );
289
293
 
@@ -336,27 +340,36 @@ export function NodeContent<CONTENT_PROPS = any>({
336
340
  const evaluateFlowVersion = useReactFlowVersion();
337
341
  const flowVersionCheck = flowVersion || evaluateFlowVersion;
338
342
 
339
- const {
340
- handles = defaultHandles(flowVersionCheck),
341
- ...otherProps
342
- } = otherDomProps;
343
+ const { handles = defaultHandles(flowVersionCheck), ...otherProps } = otherDomProps;
343
344
 
344
- const isResizeable = (!!onNodeResize && minimalShape === "none");
345
+ const isResizeable = !!onNodeResize && minimalShape === "none";
345
346
  const [width, setWidth] = React.useState<number>(nodeDimensions?.width ?? 0);
346
347
  const [height, setHeight] = React.useState<number>(nodeDimensions?.height ?? 0);
347
348
  let zoom = 1;
348
- if (isResizeable) try {
349
- [, , zoom] = flowVersionCheck === "legacy"
350
- ? getStoreStateFlowLegacy((state) => state.transform)
351
- : getStoreStateFlowNext((state) => state.transform);
352
- } catch {}
349
+ if (isResizeable)
350
+ try {
351
+ [, , zoom] =
352
+ flowVersionCheck === "legacy"
353
+ ? getStoreStateFlowLegacy((state) => state.transform)
354
+ : getStoreStateFlowNext((state) => state.transform);
355
+ } catch (error) {
356
+ // do not handle error but at least push it to the console
357
+ console.error(error);
358
+ }
353
359
  const [adjustedContentProps, setAdjustedContentProps] = React.useState<Partial<CONTENT_PROPS>>({});
354
360
  const nodeContentRef = React.useRef<any>();
355
- const handleStack = flowVersionCheck==="legacy" ? {} as { [key: string]: NodeContentHandleLegacyProps[] } : {} as { [key: string]: NodeContentHandleNextProps[] };
356
- handleStack[Position.Top] = flowVersionCheck==="legacy" ? [] as NodeContentHandleLegacyProps[] : [] as NodeContentHandleNextProps[];
357
- handleStack[Position.Right] = flowVersionCheck==="legacy" ? [] as NodeContentHandleLegacyProps[] : [] as NodeContentHandleNextProps[];
358
- handleStack[Position.Bottom] = flowVersionCheck==="legacy" ? [] as NodeContentHandleLegacyProps[] : [] as NodeContentHandleNextProps[];
359
- handleStack[Position.Left] = flowVersionCheck==="legacy" ? [] as NodeContentHandleLegacyProps[] : [] as NodeContentHandleNextProps[];
361
+ const handleStack =
362
+ flowVersionCheck === "legacy"
363
+ ? ({} as { [key: string]: NodeContentHandleLegacyProps[] })
364
+ : ({} as { [key: string]: NodeContentHandleNextProps[] });
365
+ handleStack[Position.Top] =
366
+ flowVersionCheck === "legacy" ? ([] as NodeContentHandleLegacyProps[]) : ([] as NodeContentHandleNextProps[]);
367
+ handleStack[Position.Right] =
368
+ flowVersionCheck === "legacy" ? ([] as NodeContentHandleLegacyProps[]) : ([] as NodeContentHandleNextProps[]);
369
+ handleStack[Position.Bottom] =
370
+ flowVersionCheck === "legacy" ? ([] as NodeContentHandleLegacyProps[]) : ([] as NodeContentHandleNextProps[]);
371
+ handleStack[Position.Left] =
372
+ flowVersionCheck === "legacy" ? ([] as NodeContentHandleLegacyProps[]) : ([] as NodeContentHandleNextProps[]);
360
373
 
361
374
  // initial dimension before resize
362
375
  React.useEffect(() => {
@@ -383,7 +396,7 @@ export function NodeContent<CONTENT_PROPS = any>({
383
396
 
384
397
  if (handles.length > 0) {
385
398
  handles.forEach((handle) => {
386
- if (!!handle.position) {
399
+ if (handle.position) {
387
400
  handleStack[handle.position].push(handle);
388
401
  } else if (handle.category === "configuration") {
389
402
  handleStack[Position.Top].push(handle);
@@ -397,7 +410,7 @@ export function NodeContent<CONTENT_PROPS = any>({
397
410
  }
398
411
  });
399
412
  }
400
- const styleExpandDimensions: { [key: string]: string | number } = {};
413
+ const styleExpandDimensions: { [key: string]: string | number } = Object.create(null);
401
414
  if (
402
415
  typeof adaptHeightForHandleMinCount !== "undefined" &&
403
416
  (minimalShape === "none" || !!selected) &&
@@ -410,12 +423,13 @@ export function NodeContent<CONTENT_PROPS = any>({
410
423
  styleExpandDimensions["minHeight"] = Math.max(minHeightLeft, minHeightRight);
411
424
  }
412
425
 
413
- const {
414
- highlightClassNameSuffix,
415
- highlightCustomPropertySettings
416
- } = evaluateHighlightColors("--node-highlight", highlightColor);
426
+ const { highlightClassNameSuffix, highlightCustomPropertySettings } = evaluateHighlightColors(
427
+ "--node-highlight",
428
+ highlightColor
429
+ );
417
430
 
418
- const resizableStyles = (!!onNodeResize === true && minimalShape === "none" && (width + height > 0)) ? { width, height } : {};
431
+ const resizableStyles =
432
+ !!onNodeResize === true && minimalShape === "none" && width + height > 0 ? { width, height } : {};
419
433
  const nodeContent = (
420
434
  <>
421
435
  <section
@@ -430,10 +444,11 @@ export function NodeContent<CONTENT_PROPS = any>({
430
444
  (border ? ` ${eccgui}-graphviz__node--border-${border}` : "") +
431
445
  (intent ? ` ${intentClassName(intent)}` : "") +
432
446
  (highlightClassNameSuffix.length > 0
433
- ? highlightClassNameSuffix.map(highlight => ` ${eccgui}-graphviz__node--highlight-${highlight}`).join("")
434
- : ""
435
- ) +
436
- (!!highlightedState
447
+ ? highlightClassNameSuffix
448
+ .map((highlight) => ` ${eccgui}-graphviz__node--highlight-${highlight}`)
449
+ .join("")
450
+ : "") +
451
+ (highlightedState
437
452
  ? " " + gethighlightedStateClasses(highlightedState, `${eccgui}-graphviz__node`)
438
453
  : "") +
439
454
  (animated ? ` ${eccgui}-graphviz__node--animated` : "") +
@@ -441,13 +456,15 @@ export function NodeContent<CONTENT_PROPS = any>({
441
456
  (letPassWheelEvents === false ? ` nowheel` : "")
442
457
  }
443
458
  >
444
- <header className={
445
- `${eccgui}-graphviz__node__header` +
446
- ((enlargeHeader && minimalShape==="none") ? ` ${eccgui}-graphviz__node__header--large` : "")
447
- }>
459
+ <header
460
+ className={
461
+ `${eccgui}-graphviz__node__header` +
462
+ (enlargeHeader && minimalShape === "none" ? ` ${eccgui}-graphviz__node__header--large` : "")
463
+ }
464
+ >
448
465
  {(!!iconName || !!depiction || !!leftElement) && (
449
466
  <div className={`${eccgui}-graphviz__node__header-depiction`}>
450
- { leftElement }
467
+ {leftElement}
451
468
  {!!depiction && !leftElement && typeof depiction === "string" && (
452
469
  <Depiction
453
470
  image={<img src={depiction} alt="" />}
@@ -459,7 +476,9 @@ export function NodeContent<CONTENT_PROPS = any>({
459
476
  forceInlineSvg
460
477
  />
461
478
  )}
462
- {!!depiction && !leftElement && typeof depiction !== "string" && (
479
+ {!!depiction &&
480
+ !leftElement &&
481
+ typeof depiction !== "string" &&
463
482
  React.cloneElement(depiction, {
464
483
  caption: minimalShape === "none" || selected ? typeLabel : undefined,
465
484
  captionPosition: "tooltip",
@@ -467,8 +486,7 @@ export function NodeContent<CONTENT_PROPS = any>({
467
486
  ratio: "1:1",
468
487
  resizing: "contain",
469
488
  forceInlineSvg: true,
470
- })
471
- )}
489
+ })}
472
490
  {!!iconName && !leftElement && !depiction && (
473
491
  <Depiction
474
492
  image={<Icon name={iconName} />}
@@ -482,16 +500,19 @@ export function NodeContent<CONTENT_PROPS = any>({
482
500
  )}
483
501
  </div>
484
502
  )}
485
- <div className={`${eccgui}-graphviz__node__header-label`} title={typeof label==="string" ? label : undefined}>
486
- {
487
- typeof label === "string"
488
- ? <OverflowText className={`${eccgui}-graphviz__node__header-label__mainline`}>{label}</OverflowText>
489
- : <div className={`${eccgui}-graphviz__node__header-label__mainline`}>{label}</div>
490
- }
503
+ <div
504
+ className={`${eccgui}-graphviz__node__header-label`}
505
+ title={typeof label === "string" ? label : undefined}
506
+ >
507
+ {typeof label === "string" ? (
508
+ <OverflowText className={`${eccgui}-graphviz__node__header-label__mainline`}>
509
+ {label}
510
+ </OverflowText>
511
+ ) : (
512
+ <div className={`${eccgui}-graphviz__node__header-label__mainline`}>{label}</div>
513
+ )}
491
514
  {!!labelSubline && (
492
- <div className={`${eccgui}-graphviz__node__header-label__subline`}>
493
- { labelSubline }
494
- </div>
515
+ <div className={`${eccgui}-graphviz__node__header-label__subline`}>{labelSubline}</div>
495
516
  )}
496
517
  </div>
497
518
  {(menuButtons || (showExecutionButtons && executionButtons)) && (
@@ -509,11 +530,7 @@ export function NodeContent<CONTENT_PROPS = any>({
509
530
  </div>
510
531
  )}
511
532
  {contentExtension}
512
- {footerContent && (
513
- <footer className={`${eccgui}-graphviz__node__footer`}>
514
- { footerContent }
515
- </footer>
516
- )}
533
+ {footerContent && <footer className={`${eccgui}-graphviz__node__footer`}>{footerContent}</footer>}
517
534
  </section>
518
535
  {!!handles && (
519
536
  <>
@@ -553,7 +570,7 @@ export function NodeContent<CONTENT_PROPS = any>({
553
570
  </Resizable>
554
571
  );
555
572
 
556
- return (isResizeable) ? resizableNode() : nodeContent;
573
+ return isResizeable ? resizableNode() : nodeContent;
557
574
  }
558
575
 
559
576
  const evaluateHighlightColors = (
@@ -565,8 +582,8 @@ const evaluateHighlightColors = (
565
582
  [`${baseCustomProperty}-alternate-color`]: undefined,
566
583
  } as React.CSSProperties;
567
584
  const classesHightlightColors = [] as string[];
568
- if (!!highlightColor) {
569
- const highlightingColors = (typeof highlightColor === "string") ? [highlightColor] : highlightColor;
585
+ if (highlightColor) {
586
+ const highlightingColors = typeof highlightColor === "string" ? [highlightColor] : highlightColor;
570
587
  (highlightingColors as Array<string>).map((color, idx) => {
571
588
  switch (color) {
572
589
  case "default":
@@ -575,26 +592,27 @@ const evaluateHighlightColors = (
575
592
  case "alternate":
576
593
  classesHightlightColors.push("alternate");
577
594
  break;
578
- default:
595
+ default: {
579
596
  classesHightlightColors.push("custom");
580
- let customColor = Color("#ffffff")
597
+ let customColor = Color("#ffffff");
581
598
  try {
582
599
  customColor = Color(color);
583
- } catch(ex) {
584
- console.warn("Received invalid color for highlight: " + color)
600
+ } catch (ex) {
601
+ console.warn("Received invalid color for highlight: " + color);
585
602
  }
586
603
  if (idx === 0) {
587
604
  styleHighlightColors = {
588
605
  ...styleHighlightColors,
589
606
  [`${baseCustomProperty}-default-color`]: customColor.rgb().toString(),
590
- } as React.CSSProperties
607
+ } as React.CSSProperties;
591
608
  } else {
592
609
  styleHighlightColors = {
593
610
  ...styleHighlightColors,
594
611
  [`${baseCustomProperty}-alternate-color`]: customColor.rgb().toString(),
595
- } as React.CSSProperties
612
+ } as React.CSSProperties;
596
613
  }
597
614
  break;
615
+ }
598
616
  }
599
617
  return color;
600
618
  });
@@ -603,10 +621,10 @@ const evaluateHighlightColors = (
603
621
  return {
604
622
  highlightClassNameSuffix: classesHightlightColors,
605
623
  highlightCustomPropertySettings: styleHighlightColors,
606
- }
607
- }
624
+ };
625
+ };
608
626
 
609
627
  export const nodeContentUtils = {
610
628
  evaluateHighlightColors,
611
- gethighlightedStateClasses
612
- }
629
+ gethighlightedStateClasses,
630
+ };
package/src/index.ts CHANGED
@@ -9,13 +9,10 @@ const ClassNames = {
9
9
  // @deprecated use `ClassNames`
10
10
  const HelperClasses = ClassNames;
11
11
 
12
+ export * from "./configuration/constants";
12
13
  export * from "./common";
13
14
  export * from "./components";
14
15
  export * from "./extensions";
15
16
  export * from "./cmem";
16
17
 
17
- export {
18
- ClassNames,
19
- HelperClasses,
20
- LegacyReplacements,
21
- };
18
+ export { ClassNames, HelperClasses, LegacyReplacements };
@@ -1,83 +0,0 @@
1
- import React from "react";
2
- import { StoryFn, Meta } from "@storybook/react";
3
- import { AutoSuggestion, AutoSuggestionProps } from "../../../../index";
4
- import { IPartialAutoCompleteResult } from "../AutoSuggestion";
5
-
6
- export default {
7
- title: "Forms/AutoSuggestion",
8
- component: AutoSuggestion,
9
- argTypes: {}
10
- } as Meta<typeof AutoSuggestion>;
11
-
12
- const Template: StoryFn<typeof AutoSuggestion> = (args) => (
13
- <AutoSuggestion {...args}></AutoSuggestion>
14
- );
15
-
16
- const resultList = [
17
- "find me",
18
- "item",
19
- "auto-completion result"
20
- ]
21
-
22
- const defaultProps: AutoSuggestionProps = {
23
- initialValue: "",
24
- fetchSuggestions(inputString: string, cursorPosition: number): IPartialAutoCompleteResult | undefined | Promise<IPartialAutoCompleteResult | undefined> {
25
- const stringBeforeCursor = inputString.substring(0, cursorPosition)
26
- const lastSpaceIdx = stringBeforeCursor.lastIndexOf(" ")
27
- const searchWordStart = lastSpaceIdx >= 0 ? lastSpaceIdx + 1 : 0
28
- const lastWordBeforeCursor = stringBeforeCursor.substring(searchWordStart, stringBeforeCursor.length).toLowerCase().trim()
29
- const replacements = resultList.filter(item => item.toLowerCase().includes(lastWordBeforeCursor))
30
- if (replacements.length) {
31
- return {
32
- cursorPosition: cursorPosition,
33
- inputString: inputString,
34
- replacementResults: [{
35
- extractedQuery: lastWordBeforeCursor,
36
- replacementInterval: {
37
- from: searchWordStart,
38
- length: lastWordBeforeCursor.length
39
- },
40
- replacements: replacements.map((v) => ({
41
- label: `Label of '${v}'`,
42
- description: `Description of '${v}'`,
43
- value: v
44
- }))
45
- }]
46
- }
47
- }
48
- },
49
- placeholder: "The word before the cursor will be auto-completed. At the beginning or after a space, all results are shown.",
50
- onChange(): any {
51
- // Do nothing
52
- },
53
- }
54
-
55
- /** Offers basic auto-completion for the word right before the cursor. */
56
- export const Default = Template.bind({});
57
-
58
- Default.args = defaultProps
59
-
60
- /** Shows validation error if the input string contains the word 'not'. */
61
- export const WithValidation = Template.bind({});
62
-
63
- WithValidation.args = {
64
- ...defaultProps,
65
- initialValue: "Contains not",
66
- checkInput: (inputString) => {
67
- const notIndex = inputString.indexOf("not")
68
- if(notIndex >= 0) {
69
- return {
70
- valid: false,
71
- parseError: {
72
- message: "Strings containing the sub-string 'not' are NOT allowed.",
73
- start: notIndex,
74
- end: notIndex + 3
75
- }
76
- }
77
- } else {
78
- return {
79
- valid: true
80
- }
81
- }
82
- }
83
- }
@@ -1,86 +0,0 @@
1
- import React from "react";
2
- import {ComponentMeta, ComponentStory} from "@storybook/react";
3
-
4
- import {AutoCompleteField, IAutoCompleteFieldProps} from "../AutoCompleteField";
5
- import {extractSearchWords, matchesAllWords} from "../../Typography/Highlighter";
6
- import {createNewItemRendererFactory} from "../autoCompleteFieldUtils";
7
-
8
- const AutoCompleteFieldStory: ComponentMeta<typeof AutoCompleteField> = {
9
- title: "Forms/AutoCompleteField",
10
- component: AutoCompleteField,
11
- argTypes: {
12
- },
13
- }
14
-
15
- const Template: ComponentStory<typeof AutoCompleteField> = (args) => (
16
- <AutoCompleteField {...args}></AutoCompleteField>
17
- );
18
-
19
- export const Default = Template.bind({});
20
- export const AdaptQueryAfterSelection = Template.bind({})
21
- export const AllowReset = Template.bind({})
22
- export const AllowCustomValues = Template.bind({})
23
- export const ReadOnlyState = Template.bind({})
24
-
25
- // Renders string values as string
26
- const defaultRenderer = (item: string) => item
27
-
28
- const defaultArgs: IAutoCompleteFieldProps<string, string> = {
29
- itemRenderer: (item: string) => `Rendered item: ${item}`,
30
- itemValueRenderer: (item: string) => `Selected item: ${item}`,
31
- itemValueString: (item: string) => `Query: ${item}`,
32
- onSearch: (query: string) => {
33
- const multiWord = extractSearchWords(query, true)
34
- return ["search item A", "search element B", "search object C"]
35
- .filter(word => matchesAllWords(word.toLowerCase(), multiWord))
36
- },
37
- onChange: elem => {
38
- console.log(`Entry '${elem}' selected!`)
39
- },
40
- itemValueSelector: defaultRenderer,
41
- noResultText: "No result",
42
- }
43
-
44
- // Changes the search query for the selected item, e.g. when the rendered item text should be different from the query finding this item.
45
- const adaptQueryAfterSelection: IAutoCompleteFieldProps<string, string> = {
46
- ...defaultArgs,
47
- resetQueryToValue: (selectedValue: string) => selectedValue
48
- }
49
-
50
- // Allows to reset a selection
51
- const resetSelection: IAutoCompleteFieldProps<string, string> = {
52
- ...defaultArgs,
53
- reset: {
54
- resetValue: "",
55
- resetButtonText: "Clear selected value",
56
- resettableValue: (value: string) => true
57
- }
58
- }
59
-
60
- const allowCustomValues: IAutoCompleteFieldProps<string, string> = {
61
- ...defaultArgs,
62
- createNewItem: {
63
- itemRenderer: createNewItemRendererFactory(
64
- (query: string) => `Create new item: ${query}`,
65
- "item-add-artefact"
66
- ),
67
- itemFromQuery: item => item,
68
- }
69
- }
70
-
71
- // Changes the search query for the selected item, e.g. when the rendered item text should be different from the query finding this item.
72
- const readOnlyState: IAutoCompleteFieldProps<string, string> = {
73
- ...defaultArgs,
74
- initialValue: "search item B",
75
- inputProps: {
76
- readOnly: true
77
- }
78
- }
79
-
80
- Default.args = defaultArgs;
81
- AdaptQueryAfterSelection.args = adaptQueryAfterSelection;
82
- AllowReset.args = resetSelection;
83
- AllowCustomValues.args = allowCustomValues;
84
- ReadOnlyState.args = readOnlyState;
85
-
86
- export default AutoCompleteFieldStory