@eccenca/gui-elements 25.0.0-rc.2 → 25.1.0-featurev2510colorfield.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 (244) hide show
  1. package/CHANGELOG.md +94 -18
  2. package/dist/cjs/cmem/ActivityControl/ActivityControlWidget.js +17 -13
  3. package/dist/cjs/cmem/ActivityControl/ActivityControlWidget.js.map +1 -1
  4. package/dist/cjs/cmem/ActivityControl/SilkActivityControl.js +1 -3
  5. package/dist/cjs/cmem/ActivityControl/SilkActivityControl.js.map +1 -1
  6. package/dist/cjs/cmem/ContentBlobToggler/ContentBlobToggler.js +1 -0
  7. package/dist/cjs/cmem/ContentBlobToggler/ContentBlobToggler.js.map +1 -1
  8. package/dist/cjs/cmem/ContentBlobToggler/StringPreviewContentBlobToggler.js +34 -11
  9. package/dist/cjs/cmem/ContentBlobToggler/StringPreviewContentBlobToggler.js.map +1 -1
  10. package/dist/cjs/cmem/react-flow/ReactFlow/ReactFlowV12.js.map +1 -1
  11. package/dist/cjs/common/Intent/index.js +1 -1
  12. package/dist/cjs/common/Intent/index.js.map +1 -1
  13. package/dist/cjs/common/index.js +4 -1
  14. package/dist/cjs/common/index.js.map +1 -1
  15. package/dist/cjs/common/utils/colorHash.js +25 -11
  16. package/dist/cjs/common/utils/colorHash.js.map +1 -1
  17. package/dist/cjs/common/utils/reduceToText.js +26 -1
  18. package/dist/cjs/common/utils/reduceToText.js.map +1 -1
  19. package/dist/cjs/components/Application/ApplicationViewability.js +33 -0
  20. package/dist/cjs/components/Application/ApplicationViewability.js.map +1 -0
  21. package/dist/cjs/components/Application/index.js +1 -0
  22. package/dist/cjs/components/Application/index.js.map +1 -1
  23. package/dist/cjs/components/ColorField/ColorField.js +115 -0
  24. package/dist/cjs/components/ColorField/ColorField.js.map +1 -0
  25. package/dist/cjs/components/ContextOverlay/ContextMenu.js +2 -2
  26. package/dist/cjs/components/ContextOverlay/ContextMenu.js.map +1 -1
  27. package/dist/cjs/components/ContextOverlay/ContextOverlay.js +67 -29
  28. package/dist/cjs/components/ContextOverlay/ContextOverlay.js.map +1 -1
  29. package/dist/cjs/components/DecoupledOverlay/DecoupledOverlay.js +47 -0
  30. package/dist/cjs/components/DecoupledOverlay/DecoupledOverlay.js.map +1 -0
  31. package/dist/cjs/components/Icon/IconButton.js.map +1 -1
  32. package/dist/cjs/components/Icon/canonicalIconNames.js +3 -0
  33. package/dist/cjs/components/Icon/canonicalIconNames.js.map +1 -1
  34. package/dist/cjs/components/Icon/transformIcon.js +14 -0
  35. package/dist/cjs/components/Icon/transformIcon.js.map +1 -0
  36. package/dist/cjs/components/MultiSelect/MultiSelect.js +2 -1
  37. package/dist/cjs/components/MultiSelect/MultiSelect.js.map +1 -1
  38. package/dist/cjs/components/RadioButton/RadioButton.js +5 -2
  39. package/dist/cjs/components/RadioButton/RadioButton.js.map +1 -1
  40. package/dist/cjs/components/TextReducer/TextReducer.js +15 -3
  41. package/dist/cjs/components/TextReducer/TextReducer.js.map +1 -1
  42. package/dist/cjs/components/Typography/InlineText.js +29 -0
  43. package/dist/cjs/components/Typography/InlineText.js.map +1 -0
  44. package/dist/cjs/components/Typography/index.js +1 -0
  45. package/dist/cjs/components/Typography/index.js.map +1 -1
  46. package/dist/cjs/components/VisualTour/VisualTour.js +24 -32
  47. package/dist/cjs/components/VisualTour/VisualTour.js.map +1 -1
  48. package/dist/cjs/components/index.js +2 -0
  49. package/dist/cjs/components/index.js.map +1 -1
  50. package/dist/cjs/extensions/codemirror/CodeMirror.js +18 -6
  51. package/dist/cjs/extensions/codemirror/CodeMirror.js.map +1 -1
  52. package/dist/cjs/extensions/codemirror/hooks/useCodemirrorModeExtension.hooks.js +1 -1
  53. package/dist/cjs/extensions/codemirror/hooks/useCodemirrorModeExtension.hooks.js.map +1 -1
  54. package/dist/cjs/extensions/codemirror/tests/codemirrorTestHelper.js +2 -2
  55. package/dist/cjs/extensions/codemirror/tests/codemirrorTestHelper.js.map +1 -1
  56. package/dist/cjs/extensions/react-flow/edges/EdgeLabel.js +1 -1
  57. package/dist/cjs/extensions/react-flow/edges/EdgeLabel.js.map +1 -1
  58. package/dist/cjs/extensions/react-flow/edges/EdgeNew.js +1 -1
  59. package/dist/cjs/extensions/react-flow/edges/EdgeNew.js.map +1 -1
  60. package/dist/cjs/extensions/react-flow/handles/HandleDefault.js +1 -1
  61. package/dist/cjs/extensions/react-flow/handles/HandleDefault.js.map +1 -1
  62. package/dist/cjs/extensions/react-flow/minimap/MiniMap.js +1 -1
  63. package/dist/cjs/extensions/react-flow/minimap/MiniMap.js.map +1 -1
  64. package/dist/cjs/extensions/react-flow/minimap/MiniMapV12.js.map +1 -1
  65. package/dist/cjs/extensions/react-flow/nodes/nodeUtils.js.map +1 -1
  66. package/dist/esm/cmem/ActivityControl/ActivityControlWidget.js +19 -14
  67. package/dist/esm/cmem/ActivityControl/ActivityControlWidget.js.map +1 -1
  68. package/dist/esm/cmem/ActivityControl/SilkActivityControl.js +1 -3
  69. package/dist/esm/cmem/ActivityControl/SilkActivityControl.js.map +1 -1
  70. package/dist/esm/cmem/ContentBlobToggler/ContentBlobToggler.js +1 -0
  71. package/dist/esm/cmem/ContentBlobToggler/ContentBlobToggler.js.map +1 -1
  72. package/dist/esm/cmem/ContentBlobToggler/StringPreviewContentBlobToggler.js +32 -9
  73. package/dist/esm/cmem/ContentBlobToggler/StringPreviewContentBlobToggler.js.map +1 -1
  74. package/dist/esm/cmem/react-flow/ReactFlow/ReactFlowV12.js.map +1 -1
  75. package/dist/esm/common/Intent/index.js +1 -1
  76. package/dist/esm/common/Intent/index.js.map +1 -1
  77. package/dist/esm/common/index.js +5 -2
  78. package/dist/esm/common/index.js.map +1 -1
  79. package/dist/esm/common/utils/colorHash.js +25 -12
  80. package/dist/esm/common/utils/colorHash.js.map +1 -1
  81. package/dist/esm/common/utils/reduceToText.js +37 -1
  82. package/dist/esm/common/utils/reduceToText.js.map +1 -1
  83. package/dist/esm/components/Application/ApplicationViewability.js +28 -0
  84. package/dist/esm/components/Application/ApplicationViewability.js.map +1 -0
  85. package/dist/esm/components/Application/index.js +1 -0
  86. package/dist/esm/components/Application/index.js.map +1 -1
  87. package/dist/esm/components/ColorField/ColorField.js +141 -0
  88. package/dist/esm/components/ColorField/ColorField.js.map +1 -0
  89. package/dist/esm/components/ContextOverlay/ContextMenu.js +2 -2
  90. package/dist/esm/components/ContextOverlay/ContextMenu.js.map +1 -1
  91. package/dist/esm/components/ContextOverlay/ContextOverlay.js +67 -29
  92. package/dist/esm/components/ContextOverlay/ContextOverlay.js.map +1 -1
  93. package/dist/esm/components/DecoupledOverlay/DecoupledOverlay.js +41 -0
  94. package/dist/esm/components/DecoupledOverlay/DecoupledOverlay.js.map +1 -0
  95. package/dist/esm/components/Icon/IconButton.js.map +1 -1
  96. package/dist/esm/components/Icon/canonicalIconNames.js +3 -0
  97. package/dist/esm/components/Icon/canonicalIconNames.js.map +1 -1
  98. package/dist/esm/components/Icon/transformIcon.js +21 -0
  99. package/dist/esm/components/Icon/transformIcon.js.map +1 -0
  100. package/dist/esm/components/MultiSelect/MultiSelect.js +3 -2
  101. package/dist/esm/components/MultiSelect/MultiSelect.js.map +1 -1
  102. package/dist/esm/components/RadioButton/RadioButton.js +6 -2
  103. package/dist/esm/components/RadioButton/RadioButton.js.map +1 -1
  104. package/dist/esm/components/TextReducer/TextReducer.js +14 -3
  105. package/dist/esm/components/TextReducer/TextReducer.js.map +1 -1
  106. package/dist/esm/components/Typography/InlineText.js +33 -0
  107. package/dist/esm/components/Typography/InlineText.js.map +1 -0
  108. package/dist/esm/components/Typography/index.js +1 -0
  109. package/dist/esm/components/Typography/index.js.map +1 -1
  110. package/dist/esm/components/VisualTour/VisualTour.js +25 -33
  111. package/dist/esm/components/VisualTour/VisualTour.js.map +1 -1
  112. package/dist/esm/components/index.js +2 -0
  113. package/dist/esm/components/index.js.map +1 -1
  114. package/dist/esm/extensions/codemirror/CodeMirror.js +19 -7
  115. package/dist/esm/extensions/codemirror/CodeMirror.js.map +1 -1
  116. package/dist/esm/extensions/codemirror/hooks/useCodemirrorModeExtension.hooks.js +1 -1
  117. package/dist/esm/extensions/codemirror/hooks/useCodemirrorModeExtension.hooks.js.map +1 -1
  118. package/dist/esm/extensions/codemirror/tests/codemirrorTestHelper.js +3 -3
  119. package/dist/esm/extensions/codemirror/tests/codemirrorTestHelper.js.map +1 -1
  120. package/dist/esm/extensions/react-flow/edges/EdgeLabel.js +1 -1
  121. package/dist/esm/extensions/react-flow/edges/EdgeLabel.js.map +1 -1
  122. package/dist/esm/extensions/react-flow/edges/EdgeNew.js +1 -1
  123. package/dist/esm/extensions/react-flow/edges/EdgeNew.js.map +1 -1
  124. package/dist/esm/extensions/react-flow/handles/HandleDefault.js +1 -1
  125. package/dist/esm/extensions/react-flow/handles/HandleDefault.js.map +1 -1
  126. package/dist/esm/extensions/react-flow/minimap/MiniMap.js +1 -1
  127. package/dist/esm/extensions/react-flow/minimap/MiniMap.js.map +1 -1
  128. package/dist/esm/extensions/react-flow/minimap/MiniMapV12.js.map +1 -1
  129. package/dist/esm/extensions/react-flow/nodes/nodeUtils.js.map +1 -1
  130. package/dist/types/cmem/ActivityControl/ActivityControlWidget.d.ts +9 -0
  131. package/dist/types/cmem/ContentBlobToggler/StringPreviewContentBlobToggler.d.ts +26 -10
  132. package/dist/types/common/index.d.ts +4 -1
  133. package/dist/types/common/utils/colorHash.d.ts +4 -3
  134. package/dist/types/common/utils/reduceToText.d.ts +1 -1
  135. package/dist/types/components/Application/ApplicationViewability.d.ts +36 -0
  136. package/dist/types/components/Application/index.d.ts +1 -0
  137. package/dist/types/components/ColorField/ColorField.d.ts +31 -0
  138. package/dist/types/components/ContextOverlay/ContextMenu.d.ts +1 -1
  139. package/dist/types/components/ContextOverlay/ContextOverlay.d.ts +7 -1
  140. package/dist/types/components/DecoupledOverlay/DecoupledOverlay.d.ts +20 -0
  141. package/dist/types/components/Icon/IconButton.d.ts +1 -1
  142. package/dist/types/components/Icon/canonicalIconNames.d.ts +2 -0
  143. package/dist/types/components/Icon/transformIcon.d.ts +2 -0
  144. package/dist/types/components/MultiSelect/MultiSelect.d.ts +1 -1
  145. package/dist/types/components/RadioButton/RadioButton.d.ts +8 -2
  146. package/dist/types/components/Structure/TitleSubsection.d.ts +1 -1
  147. package/dist/types/components/Tabs/Tab.d.ts +2 -2
  148. package/dist/types/components/TextReducer/TextReducer.d.ts +13 -1
  149. package/dist/types/components/Typography/InlineText.d.ts +13 -0
  150. package/dist/types/components/Typography/index.d.ts +1 -0
  151. package/dist/types/components/index.d.ts +2 -0
  152. package/dist/types/extensions/codemirror/hooks/useCodemirrorModeExtension.hooks.d.ts +1 -1
  153. package/dist/types/extensions/codemirror/tests/codemirrorTestHelper.d.ts +1 -1
  154. package/package.json +54 -53
  155. package/src/cmem/ActivityControl/ActivityControlWidget.tsx +68 -35
  156. package/src/cmem/ActivityControl/SilkActivityControl.tsx +1 -1
  157. package/src/cmem/ContentBlobToggler/ContentBlobToggler.tsx +1 -1
  158. package/src/cmem/ContentBlobToggler/StringPreviewContentBlobToggler.tsx +66 -18
  159. package/src/cmem/ContentBlobToggler/stories/StringPreviewContentBlobToggler.stories.tsx +27 -0
  160. package/src/cmem/ContentBlobToggler/tests/StringPreviewContentBlobToggler.test.tsx +98 -0
  161. package/src/cmem/react-flow/ReactFlow/ReactFlowV12.tsx +1 -0
  162. package/src/common/Intent/index.ts +2 -1
  163. package/src/common/index.ts +8 -3
  164. package/src/common/utils/colorHash.ts +36 -18
  165. package/src/common/utils/reduceToText.tsx +30 -2
  166. package/src/components/Application/ApplicationViewability.tsx +61 -0
  167. package/src/components/Application/_colors.scss +15 -0
  168. package/src/components/Application/_content.scss +7 -0
  169. package/src/components/Application/_header.scss +12 -3
  170. package/src/components/Application/_viewability.scss +13 -0
  171. package/src/components/Application/application.scss +1 -0
  172. package/src/components/Application/index.ts +1 -0
  173. package/src/components/Application/stories/ApplicationViewability.stories.tsx +37 -0
  174. package/src/components/Application/tests/ApplicationViewability.test.tsx +43 -0
  175. package/src/components/AutoSuggestion/tests/ExtendedCodeEditor.test.tsx +1 -1
  176. package/src/components/Card/card.scss +6 -0
  177. package/src/components/Checkbox/checkbox.scss +14 -2
  178. package/src/components/ColorField/ColorField.stories.tsx +69 -0
  179. package/src/components/ColorField/ColorField.test.tsx +125 -0
  180. package/src/components/ColorField/ColorField.tsx +200 -0
  181. package/src/components/ColorField/_colorfield.scss +56 -0
  182. package/src/components/ContentGroup/_contentgroup.scss +9 -0
  183. package/src/components/ContextOverlay/ContextMenu.tsx +4 -1
  184. package/src/components/ContextOverlay/ContextOverlay.tsx +94 -25
  185. package/src/components/ContextOverlay/tests/ContextMenu.test.tsx +43 -0
  186. package/src/components/ContextOverlay/tests/ContextOverlay.test.tsx +71 -0
  187. package/src/components/DecoupledOverlay/DecoupledOverlay.stories.tsx +30 -0
  188. package/src/components/DecoupledOverlay/DecoupledOverlay.tsx +97 -0
  189. package/src/components/DecoupledOverlay/_decoupledoverlay.scss +46 -0
  190. package/src/components/Depiction/depiction.scss +6 -0
  191. package/src/components/Dialog/stories/Modal.stories.tsx +12 -150
  192. package/src/components/Dialog/stories/ModalContext.stories.tsx +153 -0
  193. package/src/components/FlexibleLayout/flexiblelayout.scss +16 -0
  194. package/src/components/Grid/grid.scss +17 -0
  195. package/src/components/Grid/stories/Grid.stories.tsx +10 -7
  196. package/src/components/Grid/stories/GridRow.stories.tsx +13 -7
  197. package/src/components/Icon/IconButton.tsx +1 -1
  198. package/src/components/Icon/canonicalIconNames.tsx +3 -0
  199. package/src/components/Icon/transformIcon.tsx +17 -0
  200. package/src/components/Link/Link.stories.tsx +30 -0
  201. package/src/components/Link/link.scss +28 -2
  202. package/src/components/MultiSelect/MultiSelect.tsx +12 -3
  203. package/src/components/Notification/notification.scss +6 -0
  204. package/src/components/OverviewItem/overviewitem.scss +9 -0
  205. package/src/components/OverviewItem/stories/OverviewItem.stories.tsx +28 -0
  206. package/src/components/OverviewItem/stories/OverviewItemActions.stories.tsx +2 -2
  207. package/src/components/OverviewItem/stories/OverviewItemDescription.stories.tsx +1 -1
  208. package/src/components/OverviewItem/stories/OverviewItemLine.stories.tsx +1 -1
  209. package/src/components/PropertyValuePair/propertyvalue.scss +23 -1
  210. package/src/components/RadioButton/RadioButton.tsx +15 -3
  211. package/src/components/RadioButton/radiobutton.scss +13 -0
  212. package/src/components/Separation/separation.scss +6 -0
  213. package/src/components/Table/table.scss +22 -0
  214. package/src/components/Tabs/stories/TabTitle.stories.tsx +7 -2
  215. package/src/components/Tag/stories/TagList.stories.tsx +2 -2
  216. package/src/components/Tag/tag.scss +19 -9
  217. package/src/components/TextReducer/TextReducer.stories.tsx +2 -1
  218. package/src/components/TextReducer/TextReducer.test.tsx +44 -0
  219. package/src/components/TextReducer/TextReducer.tsx +14 -4
  220. package/src/components/Typography/InlineText.tsx +24 -0
  221. package/src/components/Typography/_reset.scss +1 -0
  222. package/src/components/Typography/index.ts +1 -0
  223. package/src/components/Typography/stories/InlineText.stories.tsx +27 -0
  224. package/src/components/Typography/typography.scss +28 -2
  225. package/src/components/VisualTour/VisualTour.tsx +30 -50
  226. package/src/components/VisualTour/visualTour.scss +0 -34
  227. package/src/components/index.scss +2 -0
  228. package/src/components/index.ts +2 -0
  229. package/src/configuration/_customproperties.scss +32 -0
  230. package/src/configuration/stories/customproperties.stories.tsx +118 -0
  231. package/src/extensions/codemirror/CodeMirror.tsx +20 -9
  232. package/src/extensions/codemirror/hooks/useCodemirrorModeExtension.hooks.ts +1 -2
  233. package/src/extensions/codemirror/tests/codemirrorTestHelper.ts +3 -3
  234. package/src/extensions/react-flow/_config.scss +3 -3
  235. package/src/extensions/react-flow/edges/EdgeLabel.tsx +5 -3
  236. package/src/extensions/react-flow/edges/EdgeNew.tsx +2 -1
  237. package/src/extensions/react-flow/edges/_edges.scss +3 -2
  238. package/src/extensions/react-flow/handles/HandleDefault.tsx +2 -2
  239. package/src/extensions/react-flow/minimap/MiniMap.tsx +2 -1
  240. package/src/extensions/react-flow/minimap/MiniMapV12.tsx +1 -1
  241. package/src/extensions/react-flow/nodes/_nodes.scss +4 -3
  242. package/src/extensions/react-flow/nodes/nodeUtils.tsx +1 -0
  243. package/src/extensions/react-flow/nodes/stories/NodeContent.stories.tsx +2 -2
  244. package/src/index.scss +1 -0
@@ -1,17 +1,20 @@
1
1
  import React from "react";
2
2
 
3
- import { ValidIconName } from "../../components/Icon/canonicalIconNames";
4
- import { IconProps } from "../../components/Icon/Icon";
5
- import { TestIconProps } from "../../components/Icon/TestIcon";
6
- import { TestableComponent } from "../../components/interfaces";
7
- import { ProgressBarProps } from "../../components/ProgressBar/ProgressBar";
8
- import { SpinnerProps } from "../../components/Spinner/Spinner";
9
- import { CLASSPREFIX as eccgui } from "../../configuration/constants";
3
+ import {ValidIconName} from "../../components/Icon/canonicalIconNames";
4
+ import {IconProps} from "../../components/Icon/Icon";
5
+ import {TestIconProps} from "../../components/Icon/TestIcon";
6
+ import {TestableComponent} from "../../components/interfaces";
7
+ import {ProgressBarProps} from "../../components/ProgressBar/ProgressBar";
8
+ import {SpinnerProps} from "../../components/Spinner/Spinner";
9
+ import {CLASSPREFIX as eccgui} from "../../configuration/constants";
10
10
  import {
11
11
  Card,
12
12
  ContextMenu,
13
+ DecoupledOverlay,
13
14
  IconButton,
14
15
  MenuItem,
16
+ Notification,
17
+ NotificationProps,
15
18
  OverflowText,
16
19
  OverviewItem,
17
20
  OverviewItemActions,
@@ -97,7 +100,7 @@ interface IActivityContextMenu extends TestableComponent {
97
100
  export interface ActivityControlWidgetAction extends TestableComponent {
98
101
  // The action that should be triggered
99
102
  action: () => void;
100
- // The tooltip that should be shown over the action icon
103
+ // The tooltip that should be shown over the action icon on hover
101
104
  tooltip?: string;
102
105
  // The icon of the action button
103
106
  icon: ValidIconName | React.ReactElement<TestIconProps>;
@@ -105,6 +108,16 @@ export interface ActivityControlWidgetAction extends TestableComponent {
105
108
  disabled?: boolean;
106
109
  // Warning state
107
110
  hasStateWarning?: boolean;
111
+ // Active state
112
+ active?: boolean
113
+ /** A notification that is shown in an overlay pointing at the activity action button. */
114
+ notification?: {
115
+ message: string
116
+ onClose: () => void
117
+ intent?: NotificationProps["intent"]
118
+ // Timeout in ms before notification is closed. Default: none
119
+ timeout?: number
120
+ }
108
121
  }
109
122
 
110
123
  interface IActivityMenuAction extends ActivityControlWidgetAction {
@@ -209,28 +222,11 @@ export function ActivityControlWidget(props: ActivityControlWidgetProps) {
209
222
  data-test-id={dataTestIdLegacy ? `${dataTestIdLegacy}-actions` : undefined}
210
223
  >
211
224
  {activityActions &&
212
- activityActions.map((action, idx) => {
213
- return (
214
- <IconButton
215
- key={
216
- typeof action.icon === "string"
217
- ? action.icon
218
- : action["data-test-id"] ?? action["data-testid"] ?? idx
219
- }
220
- data-test-id={action["data-test-id"]}
221
- data-testid={action["data-testid"]}
222
- name={action.icon}
223
- text={action.tooltip}
224
- onClick={action.action}
225
- disabled={action.disabled}
226
- intent={action.hasStateWarning ? "warning" : undefined}
227
- tooltipProps={{
228
- hoverOpenDelay: 200,
229
- placement: "bottom",
230
- }}
231
- />
232
- );
233
- })}
225
+ activityActions.map((action, idx) => <ActivityActionButton
226
+ key={idx}
227
+ action={action}
228
+ />
229
+ )}
234
230
  {additionalActions}
235
231
  {activityContextMenu && activityContextMenu.menuItems.length > 0 && (
236
232
  <ContextMenu
@@ -241,11 +237,7 @@ export function ActivityControlWidget(props: ActivityControlWidgetProps) {
241
237
  return (
242
238
  <MenuItem
243
239
  icon={menuAction.icon}
244
- key={
245
- typeof menuAction.icon === "string"
246
- ? menuAction.icon
247
- : menuAction["data-test-id"] ?? idx
248
- }
240
+ key={idx}
249
241
  onClick={menuAction.action}
250
242
  text={menuAction.tooltip}
251
243
  />
@@ -267,3 +259,44 @@ export function ActivityControlWidget(props: ActivityControlWidgetProps) {
267
259
  <div className={classname}>{widget}</div>
268
260
  );
269
261
  }
262
+
263
+ interface ActivityActionButtonProps {
264
+ action: ActivityControlWidgetAction
265
+ }
266
+
267
+ const ActivityActionButton = ({action}: ActivityActionButtonProps) => {
268
+ const actionButtonRef = React.useRef(null);
269
+ const ActionButton = () => (
270
+ <IconButton
271
+ data-test-id={action["data-test-id"]}
272
+ data-testid={action["data-testid"]}
273
+ name={action.icon}
274
+ text={action.tooltip}
275
+ onClick={action.action}
276
+ disabled={action.disabled}
277
+ intent={action.hasStateWarning ? "warning" : undefined}
278
+ tooltipProps={{
279
+ hoverOpenDelay: 200,
280
+ placement: "bottom"
281
+ }}
282
+ active={action.active}
283
+ />
284
+ )
285
+ return action.notification ?
286
+ <>
287
+ <span ref={actionButtonRef}>
288
+ <ActionButton/>
289
+ </span>
290
+ {actionButtonRef.current && (
291
+ <DecoupledOverlay targetSelectorOrElement={actionButtonRef.current} paddingSize={"small"}>
292
+ <Notification
293
+ message={action.notification.message}
294
+ intent={action.notification.intent ?? "neutral"}
295
+ onDismiss={action.notification.onClose}
296
+ timeout={action.notification.timeout}
297
+ />
298
+ </DecoupledOverlay>
299
+ )}
300
+ </> :
301
+ <ActionButton/>
302
+ }
@@ -196,7 +196,7 @@ export function useSilkActivityControl({
196
196
  registerForUpdates(updateActivityStatus);
197
197
  return unregisterFromUpdates;
198
198
  },
199
- // eslint-disable-next-line react-hooks/exhaustive-deps
199
+
200
200
  []
201
201
  );
202
202
 
@@ -58,7 +58,7 @@ export function ContentBlobToggler({
58
58
  {previewContent}
59
59
  {enableToggler && (
60
60
  <>
61
- &hellip;{" "}
61
+ {" "}&hellip;{" "}
62
62
  <Link
63
63
  href="#more"
64
64
  data-test-id={"content-blob-toggler-more-link"}
@@ -1,30 +1,46 @@
1
1
  import React from "react";
2
2
 
3
- import { ContentBlobToggler, ContentBlobTogglerProps, Markdown } from "./..";
3
+ import { ContentBlobToggler, ContentBlobTogglerProps, InlineText, Markdown, utils } from "./../../index";
4
4
 
5
5
  export interface StringPreviewContentBlobTogglerProps
6
6
  extends Omit<ContentBlobTogglerProps, "previewContent" | "enableToggler"> {
7
7
  /**
8
- The preview content will be cut to this length if it is too long.
8
+ * The preview content will be cut to this length if it is too long.
9
9
  */
10
10
  previewMaxLength?: number;
11
11
  /**
12
- The content string. If it is smaller than previewMaxLength this will be displayed in full, else fullviewContent will be displayed.
12
+ * The content string.
13
+ * If it is smaller than `previewMaxLength` this will be displayed in full, else `fullviewContent` will be displayed.
13
14
  */
14
15
  content: string;
15
- /** If only the first non-empty line should be shown in the preview. This will in addition also be shortened according to previewMaxLength. */
16
- firstNonEmptyLineOnly?: boolean;
17
- /** If enabled the preview is rendered as markdown. */
16
+ /**
17
+ * Use only parts of `content` in the preview.
18
+ * `firstMarkdownSection` uses the content until the first double line return.
19
+ * Currently overwritten by `firstNonEmptyLineOnly`.
20
+ */
21
+ useOnly?: "firstNonEmptyLine" | "firstMarkdownSection";
22
+ /**
23
+ * If enabled the preview is rendered as Markdown.
24
+ */
18
25
  renderPreviewAsMarkdown?: boolean;
19
- /** White-listing of HTML elements that will be rendered when renderPreviewAsMarkdown is enabled. */
26
+ /**
27
+ * White-listing of HTML elements that will be rendered when renderPreviewAsMarkdown is enabled.
28
+ */
20
29
  allowedHtmlElementsInPreview?: string[];
21
- /** Allows to add non-string elements at the end of the content if the full description is shown, i.e. no toggler is necessary.
30
+ /**
31
+ * Allows to add non-string elements at the end of the content if the full description is shown, i.e. no toggler is necessary.
22
32
  * This allows to add non-string elements to both the full-view content and the pure string content.
23
33
  */
24
34
  noTogglerContentSuffix?: JSX.Element;
35
+ /**
36
+ * If only the first non-empty line should be shown in the preview.
37
+ * This will in addition also be shortened according to `previewMaxLength`.
38
+ * @deprecated (v26) use `useOnly="firstNonEmptyLine"` instead
39
+ */
40
+ firstNonEmptyLineOnly?: boolean;
25
41
  }
26
42
 
27
- /** Version of the content toggler for text only content. */
43
+ /** Version of the content toggler for text centric content. */
28
44
  export function StringPreviewContentBlobToggler({
29
45
  className = "",
30
46
  previewMaxLength,
@@ -33,14 +49,28 @@ export function StringPreviewContentBlobToggler({
33
49
  content,
34
50
  fullviewContent,
35
51
  startExtended,
36
- firstNonEmptyLineOnly,
52
+ useOnly,
37
53
  renderPreviewAsMarkdown = false,
38
54
  allowedHtmlElementsInPreview,
39
55
  noTogglerContentSuffix,
56
+ firstNonEmptyLineOnly,
40
57
  }: StringPreviewContentBlobTogglerProps) {
41
- const previewMaybeFirstLine = firstNonEmptyLineOnly ? firstNonEmptyLine(content) : content;
42
- const previewString = previewMaxLength ? previewMaybeFirstLine.substr(0, previewMaxLength) : previewMaybeFirstLine;
43
- const enableToggler = previewString !== content;
58
+ // need to test `firstNonEmptyLineOnly` until property is removed
59
+ const useOnlyTest: StringPreviewContentBlobTogglerProps["useOnly"] = firstNonEmptyLineOnly
60
+ ? "firstNonEmptyLine"
61
+ : useOnly;
62
+
63
+ let previewString = content;
64
+ switch (useOnlyTest) {
65
+ case "firstNonEmptyLine":
66
+ previewString = useOnlyPart(content, regexFirstNonEmptyLine);
67
+ break;
68
+ case "firstMarkdownSection":
69
+ previewString = useOnlyPart(content, regexFirstMarkdownSection);
70
+ }
71
+
72
+ let enableToggler = previewString !== content;
73
+
44
74
  let previewContent = renderPreviewAsMarkdown ? (
45
75
  <Markdown key="markdown-content" allowedElements={allowedHtmlElementsInPreview}>
46
76
  {previewString}
@@ -48,6 +78,15 @@ export function StringPreviewContentBlobToggler({
48
78
  ) : (
49
79
  previewString
50
80
  );
81
+
82
+ if (
83
+ previewMaxLength &&
84
+ utils.reduceToText(previewContent, { decodeHtmlEntities: true }).length > previewMaxLength
85
+ ) {
86
+ previewContent = utils.reduceToText(previewContent, { decodeHtmlEntities: true }).slice(0, previewMaxLength);
87
+ enableToggler = true;
88
+ }
89
+
51
90
  if (!enableToggler && noTogglerContentSuffix) {
52
91
  previewContent = (
53
92
  <>
@@ -60,7 +99,7 @@ export function StringPreviewContentBlobToggler({
60
99
  return (
61
100
  <ContentBlobToggler
62
101
  className={className}
63
- previewContent={previewContent}
102
+ previewContent={<InlineText>{previewContent}</InlineText>}
64
103
  toggleExtendText={toggleExtendText}
65
104
  toggleReduceText={toggleReduceText}
66
105
  fullviewContent={fullviewContent}
@@ -70,17 +109,26 @@ export function StringPreviewContentBlobToggler({
70
109
  );
71
110
  }
72
111
 
73
- const newLineRegex = new RegExp("\r|\n"); // eslint-disable-line
112
+ const regexFirstNonEmptyLine = new RegExp("\r|\n"); // eslint-disable-line
113
+ const regexFirstMarkdownSection = new RegExp("\r\n\r\n|\n\n"); // eslint-disable-line
74
114
 
75
115
  /**
76
116
  * Takes the first non-empty line from a preview string.
77
117
  */
78
118
  function firstNonEmptyLine(preview: string) {
119
+ return useOnlyPart(preview, regexFirstNonEmptyLine);
120
+ }
121
+
122
+ /**
123
+ * Returns only the first part from a preview string.
124
+ * Or the full string as fallback.
125
+ */
126
+ function useOnlyPart(preview: string, regexTest: RegExp): string {
79
127
  const previewString = preview.trim();
80
- const result = newLineRegex.exec(previewString);
81
- return result !== null ? previewString.substr(0, result.index) : previewString;
128
+ const result = regexTest.exec(previewString);
129
+ return result !== null ? result.input.slice(0, result.index) : previewString;
82
130
  }
83
131
 
84
132
  export const stringPreviewContentBlobTogglerUtils = {
85
133
  firstNonEmptyLine,
86
- };
134
+ };
@@ -0,0 +1,27 @@
1
+ import React from "react";
2
+ import { Meta, StoryFn } from "@storybook/react";
3
+
4
+ import { Markdown, StringPreviewContentBlobToggler } from "../../../index";
5
+
6
+ const config = {
7
+ title: "CMEM/ContentBlobToggler/StringPreview",
8
+ component: StringPreviewContentBlobToggler,
9
+ } as Meta<typeof StringPreviewContentBlobToggler>;
10
+ export default config;
11
+
12
+ const Template: StoryFn<typeof StringPreviewContentBlobToggler> = (args) => (
13
+ <StringPreviewContentBlobToggler {...args} />
14
+ );
15
+
16
+ const initialTeststring =
17
+ "A library for GUI elements.\nIn order to create graphical user interfaces, please have look at the documentation at [Github](https://github.com/eccenca/gui-elements).";
18
+
19
+ export const Default = Template.bind({});
20
+ Default.args = {
21
+ content: initialTeststring,
22
+ fullviewContent: <Markdown htmlContentBlockProps={{ large: true }}>{initialTeststring}</Markdown>,
23
+ previewMaxLength: 64,
24
+ renderPreviewAsMarkdown: true,
25
+ toggleExtendText: "show more",
26
+ toggleReduceText: "show less",
27
+ };
@@ -0,0 +1,98 @@
1
+ import React from "react";
2
+ import { render, RenderResult } from "@testing-library/react";
3
+
4
+ import "@testing-library/jest-dom";
5
+
6
+ import {
7
+ StringPreviewContentBlobToggler,
8
+ StringPreviewContentBlobTogglerProps,
9
+ } from "../StringPreviewContentBlobToggler";
10
+
11
+ import { Default as StringPreviewContentBlobTogglerStory } from "./../stories/StringPreviewContentBlobToggler.stories";
12
+
13
+ describe("StringPreviewContentBlobToggler", () => {
14
+ const textMustExist = (queryByText: RenderResult["queryByText"], text: string) => {
15
+ expect(queryByText(text, { exact: false })).not.toBeNull();
16
+ };
17
+ const textMustNotExist = (queryByText: RenderResult["queryByText"], text: string) => {
18
+ expect(queryByText(text, { exact: false })).toBeNull();
19
+ };
20
+ it("should cut preview and show toggler to extend", () => {
21
+ const { queryByText } = render(
22
+ <StringPreviewContentBlobToggler
23
+ {...(StringPreviewContentBlobTogglerStory.args as StringPreviewContentBlobTogglerProps)}
24
+ />
25
+ );
26
+ textMustExist(queryByText, "A library for GUI elements.");
27
+ textMustNotExist(
28
+ queryByText,
29
+ "In order to create graphical user interfaces, please have look at the documentation at"
30
+ );
31
+ textMustExist(queryByText, "show more");
32
+ });
33
+ it("should display full view if `startExtended` is enabled, and show toggler to reduce", () => {
34
+ const { queryByText } = render(
35
+ <StringPreviewContentBlobToggler
36
+ {...(StringPreviewContentBlobTogglerStory.args as StringPreviewContentBlobTogglerProps)}
37
+ startExtended
38
+ />
39
+ );
40
+ textMustExist(
41
+ queryByText,
42
+ "In order to create graphical user interfaces, please have look at the documentation at"
43
+ );
44
+ textMustExist(queryByText, "show less");
45
+ });
46
+ it('should display only first content line on `useOnly={"firstNonEmptyLine"}`', () => {
47
+ const { queryByText } = render(
48
+ <StringPreviewContentBlobToggler
49
+ {...(StringPreviewContentBlobTogglerStory.args as StringPreviewContentBlobTogglerProps)}
50
+ useOnly={"firstNonEmptyLine"}
51
+ />
52
+ );
53
+ textMustExist(queryByText, "A library for GUI elements.");
54
+ textMustNotExist(queryByText, "In order to create");
55
+ });
56
+ it('should use first Markdown paragraph as preview content on `useOnly={"firstMarkdownSection"}` but shorten it', () => {
57
+ const { queryByText } = render(
58
+ <StringPreviewContentBlobToggler
59
+ {...(StringPreviewContentBlobTogglerStory.args as StringPreviewContentBlobTogglerProps)}
60
+ useOnly={"firstMarkdownSection"}
61
+ />
62
+ );
63
+ textMustExist(queryByText, "A library for GUI elements.");
64
+ textMustExist(queryByText, "In order to create");
65
+ textMustNotExist(queryByText, "please have look at the documentation at");
66
+ });
67
+ it("should display full preview and no toggler if content is short enough", () => {
68
+ const { queryByText } = render(
69
+ <StringPreviewContentBlobToggler
70
+ {...(StringPreviewContentBlobTogglerStory.args as StringPreviewContentBlobTogglerProps)}
71
+ previewMaxLength={144}
72
+ />
73
+ );
74
+ textMustExist(queryByText, "A library for GUI elements.");
75
+ textMustExist(
76
+ queryByText,
77
+ "In order to create graphical user interfaces, please have look at the documentation at"
78
+ );
79
+ textMustNotExist(queryByText, "https://github.com/"); // test if Markdown was rendered
80
+ textMustNotExist(queryByText, "show more");
81
+ });
82
+ it("should not use Markdown rendering on `renderPreviewAsMarkdown={false}`", () => {
83
+ const { queryByText } = render(
84
+ <StringPreviewContentBlobToggler
85
+ {...(StringPreviewContentBlobTogglerStory.args as StringPreviewContentBlobTogglerProps)}
86
+ previewMaxLength={144}
87
+ renderPreviewAsMarkdown={false}
88
+ />
89
+ );
90
+ textMustExist(queryByText, "A library for GUI elements.");
91
+ textMustExist(
92
+ queryByText,
93
+ "In order to create graphical user interfaces, please have look at the documentation at"
94
+ );
95
+ textMustExist(queryByText, "https://github.com/"); // test if Markdown was rendered
96
+ textMustExist(queryByText, "show more");
97
+ });
98
+ });
@@ -9,6 +9,7 @@ import {
9
9
  } from "@xyflow/react";
10
10
 
11
11
  import { CLASSPREFIX as eccgui } from "../../../configuration/constants";
12
+
12
13
  import { EdgeNew } from "./../../../extensions/react-flow/edges/EdgeNew";
13
14
 
14
15
  export type ReactFlowV12ContainerProps = ReactFlowV12Props;
@@ -1,6 +1,7 @@
1
- import { CLASSPREFIX as eccgui } from "../../configuration/constants";
2
1
  import { Intent as BlueprintIntent } from "@blueprintjs/core";
3
2
 
3
+ import { CLASSPREFIX as eccgui } from "../../configuration/constants";
4
+
4
5
  export type IntentBlueprint = BlueprintIntent;
5
6
  export const DefinitionsBlueprint = BlueprintIntent;
6
7
 
@@ -1,12 +1,15 @@
1
+ import { decode } from "he";
2
+
1
3
  import { invisibleZeroWidthCharacters } from "./utils/characters";
2
4
  import { colorCalculateDistance } from "./utils/colorCalculateDistance";
3
5
  import decideContrastColorValue from "./utils/colorDecideContrastvalue";
4
- import { getEnabledColorsFromPalette, textToColorHash } from "./utils/colorHash";
6
+ import { getEnabledColorPropertiesFromPalette, getEnabledColorsFromPalette, textToColorHash } from "./utils/colorHash";
5
7
  import getColorConfiguration from "./utils/getColorConfiguration";
6
8
  import { getScrollParent } from "./utils/getScrollParent";
7
9
  import { getGlobalVar, setGlobalVar } from "./utils/globalVars";
8
10
  import { openInNewTab } from "./utils/openInNewTab";
9
- import { reduceToText } from "./utils/reduceToText"
11
+ import { reduceToText } from "./utils/reduceToText";
12
+ export type { DecodeOptions as DecodeHtmlEntitiesOptions } from "he";
10
13
  export type { IntentTypes as IntentBaseTypes } from "./Intent";
11
14
 
12
15
  export const utils = {
@@ -19,6 +22,8 @@ export const utils = {
19
22
  setGlobalVar,
20
23
  getScrollParent,
21
24
  getEnabledColorsFromPalette,
25
+ getEnabledColorPropertiesFromPalette,
22
26
  textToColorHash,
23
- reduceToText
27
+ reduceToText,
28
+ decodeHtmlEntities: decode,
24
29
  };
@@ -6,8 +6,8 @@ import { colorCalculateDistance } from "./colorCalculateDistance";
6
6
  import CssCustomProperties from "./CssCustomProperties";
7
7
 
8
8
  type ColorOrFalse = Color | false;
9
- type ColorWeight = 100 | 300 | 500 | 700 | 900;
10
- type PaletteGroup = "identity" | "semantic" | "layout" | "extra";
9
+ export type ColorWeight = 100 | 300 | 500 | 700 | 900;
10
+ export type PaletteGroup = "identity" | "semantic" | "layout" | "extra";
11
11
 
12
12
  interface getEnabledColorsProps {
13
13
  /** Specify the palette groups used to define the set of colors. */
@@ -21,20 +21,43 @@ interface getEnabledColorsProps {
21
21
  }
22
22
 
23
23
  const getEnabledColorsFromPaletteCache = new Map<string, Color[]>();
24
+ const getEnabledColorPropertiesFromPaletteCache = new Map<string, string[][]>();
24
25
 
25
- export function getEnabledColorsFromPalette({
26
+ export function getEnabledColorsFromPalette(props: getEnabledColorsProps): Color[] {
27
+ const configId = JSON.stringify({
28
+ includePaletteGroup: props.includePaletteGroup,
29
+ includeColorWeight: props.includeColorWeight,
30
+ });
31
+
32
+ if (getEnabledColorsFromPaletteCache.has(configId)) {
33
+ return getEnabledColorsFromPaletteCache.get(configId)!;
34
+ }
35
+
36
+ const colorPropertiesFromPalette = Object.values(getEnabledColorPropertiesFromPalette(props));
37
+
38
+ getEnabledColorsFromPaletteCache.set(
39
+ configId,
40
+ colorPropertiesFromPalette.map((color) => {
41
+ return Color(color[1]);
42
+ })
43
+ );
44
+
45
+ return getEnabledColorsFromPaletteCache.get(configId)!;
46
+ }
47
+
48
+ export function getEnabledColorPropertiesFromPalette({
26
49
  includePaletteGroup = ["layout"],
27
50
  includeColorWeight = [100, 300, 500, 700, 900],
28
- // TODO (planned for later): includeMixedColors = false,
51
+ // (planned for later): includeMixedColors = false,
29
52
  minimalColorDistance = COLORMINDISTANCE,
30
- }: getEnabledColorsProps): Color[] {
53
+ }: getEnabledColorsProps): string[][] {
31
54
  const configId = JSON.stringify({
32
55
  includePaletteGroup,
33
56
  includeColorWeight,
34
57
  });
35
58
 
36
- if (getEnabledColorsFromPaletteCache.has(configId)) {
37
- return getEnabledColorsFromPaletteCache.get(configId)!;
59
+ if (getEnabledColorPropertiesFromPaletteCache.has(configId)) {
60
+ return getEnabledColorPropertiesFromPaletteCache.get(configId)!;
38
61
  }
39
62
 
40
63
  const colorsFromPalette = new CssCustomProperties({
@@ -50,18 +73,18 @@ export function getEnabledColorsFromPalette({
50
73
  const weight = parseInt(tint[2], 10) as ColorWeight;
51
74
  return includePaletteGroup.includes(group) && includeColorWeight.includes(weight);
52
75
  },
53
- removeDashPrefix: false,
76
+ removeDashPrefix: true,
54
77
  returnObject: true,
55
78
  }).customProperties();
56
79
 
57
- const colorsFromPaletteValues = Object.values(colorsFromPalette) as string[];
80
+ const colorsFromPaletteValues = Object.entries(colorsFromPalette) as [string, string][];
58
81
 
59
82
  const colorsFromPaletteWithEnoughDistance =
60
83
  minimalColorDistance > 0
61
- ? colorsFromPaletteValues.reduce((enoughDistance: string[], color: string) => {
84
+ ? colorsFromPaletteValues.reduce((enoughDistance: [string, string][], color: [string, string]) => {
62
85
  if (enoughDistance.includes(color)) {
63
86
  return enoughDistance.filter((checkColor) => {
64
- const distance = colorCalculateDistance({ color1: color, color2: checkColor });
87
+ const distance = colorCalculateDistance({ color1: color[1], color2: checkColor[1] });
65
88
  return checkColor === color || (distance && minimalColorDistance <= distance);
66
89
  });
67
90
  } else {
@@ -70,14 +93,9 @@ export function getEnabledColorsFromPalette({
70
93
  }, colorsFromPaletteValues)
71
94
  : colorsFromPaletteValues;
72
95
 
73
- getEnabledColorsFromPaletteCache.set(
74
- configId,
75
- colorsFromPaletteWithEnoughDistance.map((color: string) => {
76
- return Color(color);
77
- })
78
- );
96
+ getEnabledColorPropertiesFromPaletteCache.set(configId, colorsFromPaletteWithEnoughDistance);
79
97
 
80
- return getEnabledColorsFromPaletteCache.get(configId)!;
98
+ return getEnabledColorPropertiesFromPaletteCache.get(configId)!;
81
99
  }
82
100
 
83
101
  function getColorcode(text: string): ColorOrFalse {
@@ -3,6 +3,7 @@ import { renderToString } from "react-dom/server";
3
3
  import * as ReactIs from "react-is";
4
4
 
5
5
  import { TextReducerProps } from "./../../components/TextReducer/TextReducer";
6
+ import { DecodeHtmlEntitiesOptions, utils } from "./../";
6
7
 
7
8
  export interface ReduceToTextFuncType {
8
9
  (
@@ -10,12 +11,12 @@ export interface ReduceToTextFuncType {
10
11
  * Component or text to reduce HTML markup content to plain text.
11
12
  */
12
13
  input: React.ReactNode | React.ReactNode[] | string,
13
- options?: Pick<TextReducerProps, "maxNodes" | "maxLength">
14
+ options?: Pick<TextReducerProps, "maxNodes" | "maxLength" | "decodeHtmlEntities" | "decodeHtmlEntitiesOptions">
14
15
  ): string;
15
16
  }
16
17
 
17
18
  export const reduceToText: ReduceToTextFuncType = (input, options) => {
18
- const { maxNodes, maxLength } = options || {};
19
+ const { maxNodes, maxLength, decodeHtmlEntities } = options || {};
19
20
  const content: React.ReactNode | React.ReactNode[] = input;
20
21
  let nodeCount = 0;
21
22
 
@@ -46,6 +47,33 @@ export const reduceToText: ReduceToTextFuncType = (input, options) => {
46
47
  // Basic HTML cleanup
47
48
  text = text.replace(/<[^\s][^>]*>/g, "").replace(/\n/g, " ");
48
49
 
50
+ if (decodeHtmlEntities) {
51
+ const decodeDefaultOptions = {
52
+ isAttributeValue: true,
53
+ strict: true,
54
+ } as DecodeHtmlEntitiesOptions;
55
+ let decodeErrors = 0;
56
+ // we decode in pieces to apply some error tolerance even in strict mode
57
+ text = text
58
+ .split(" ")
59
+ .map((value) => {
60
+ try {
61
+ return utils.decodeHtmlEntities(value, {
62
+ ...decodeDefaultOptions,
63
+ ...options?.decodeHtmlEntitiesOptions,
64
+ });
65
+ } catch {
66
+ decodeErrors++;
67
+ return value;
68
+ }
69
+ })
70
+ .join(" ");
71
+ if (decodeErrors > 0) {
72
+ // eslint-disable-next-line no-console
73
+ console.warn(`${decodeErrors} parse error(s) for decodeHtmlEntities, return un-decoded text`, text);
74
+ }
75
+ }
76
+
49
77
  if (typeof maxLength === "number") {
50
78
  text = text.slice(0, maxLength);
51
79
  }