@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,111 +1,52 @@
1
1
  import React from "react";
2
- import { IconProps as CarbonIconProps } from "carbon-components-react";
3
- import { CLASSPREFIX as eccgui } from "../../configuration/constants";
4
- import { IntentTypes } from "../../common/Intent";
5
- import Tooltip, { TooltipProps } from "./../Tooltip/Tooltip";
6
- import canonicalIcons, {IconSized, ValidIconName} from "./canonicalIconNames"
2
+ import BaseIcon, { BaseIconProps } from "./BaseIcon";
3
+ import canonicalIcons, { CarbonIconType, ValidIconName } from "./canonicalIconNames"
7
4
 
8
- export interface IconProps extends Omit<CarbonIconProps, "icon" | "description" | "name"> {
5
+ export interface IconProps extends Omit<BaseIconProps, "iconComponent"> {
9
6
  /**
10
7
  * Canonical icon name, or an array of strings.
11
8
  * In case of the array the first valid icon name is used.
12
9
  */
13
10
  name: ValidIconName | string[],
14
- /**
15
- * Add tooltip text to icon
16
- */
17
- tooltipText?: string,
18
- /**
19
- * Intent state of icon.
20
- * Currently only `success`, `info`, `warning` and `danger` are implemented for icons, even there are more states available.
21
- */
22
- intent?: IntentTypes
23
- /**
24
- * Display large icon version.
25
- */
26
- large?: boolean,
27
- /**
28
- * Display small icon version.
29
- */
30
- small?: boolean,
31
- /**
32
- * Additional CSS classes.
33
- */
34
- className?: string,
35
- /**
36
- * Description for icon as accessibility fallback.
37
- */
38
- description?: string,
39
- /**
40
- * Additonal tooltip properties, e.g. `hoverOpenDelay`.
41
- */
42
- tooltipProps?: Partial<Omit<TooltipProps, "content" | "children">>,
43
11
  }
44
12
 
45
13
  /** Returns the first icon that exists or the fallback icon. */
46
- const findExistingIcon = (iconName: ValidIconName | string[],
47
- fallbackItem: IconSized = canonicalIcons["Undefined"]): IconSized => {
14
+ const findExistingIcon = (
15
+ iconName: ValidIconName | string[],
16
+ fallbackItem: CarbonIconType = canonicalIcons["undefined"]
17
+ ): CarbonIconType => {
48
18
  if (typeof iconName === "string") {
49
- return canonicalIcons[iconName] ?? fallbackItem
19
+ return canonicalIcons[iconName] ?? fallbackItem;
50
20
  } else {
51
- return canonicalIcons[findExistingIconName(iconName)]
21
+ return canonicalIcons[findExistingIconName(iconName)];
52
22
  }
53
23
  }
54
24
 
55
25
  /** Returns the first icon name that exists or the fallback icon name. */
56
- export const findExistingIconName = (iconNames: string[],
57
- fallbackIconName: ValidIconName = "Undefined"): ValidIconName => {
26
+ export const findExistingIconName = (
27
+ iconNames: string[],
28
+ fallbackIconName: ValidIconName = "undefined"
29
+ ): ValidIconName => {
58
30
  let foundIconName: string = fallbackIconName;
59
- const iconNameStack = [...iconNames]
31
+ const iconNameStack = [...iconNames];
60
32
  while (foundIconName === fallbackIconName && iconNameStack.length > 0) {
61
33
  let iconNameToTest = iconNameStack.shift();
62
34
  if (iconNameToTest && (canonicalIcons as any)[iconNameToTest] != null) {
63
- foundIconName = iconNameToTest
35
+ foundIconName = iconNameToTest;
64
36
  }
65
37
  }
66
- return foundIconName as ValidIconName
38
+ return foundIconName as ValidIconName;
67
39
  }
68
40
 
41
+ /**
42
+ * The icon provides a graphical symbol that is specified by a canonical name.
43
+ * This name is hard-coded to force a homegenous usage of the [Carbon icon library](https://carbondesignsystem.com/guidelines/icons/library).
44
+ */
69
45
  function Icon({
70
- className = "",
71
- name = "undefined",
72
- large = false,
73
- small = false,
74
- tooltipText,
75
- tooltipProps,
76
- intent,
77
- ...restProps
46
+ name,
47
+ ...otherBaseIconProps
78
48
  }: IconProps) {
79
- let sizeConfig = { height: 20, width: 20 };
80
- if (small) sizeConfig = { height: 16, width: 16 };
81
- if (large) sizeConfig = { height: 32, width: 32 };
82
- const carbonIcon = findExistingIcon(name)
83
- let CarbonIconSized = carbonIcon.normal
84
- if(small) CarbonIconSized = carbonIcon.small
85
- if(large) CarbonIconSized = carbonIcon.large
86
-
87
- if (!!tooltipText && !restProps.description) {
88
- restProps['description'] = tooltipText;
89
- }
90
-
91
- const icon = (
92
- <CarbonIconSized
93
- {...restProps}
94
- {...sizeConfig}
95
- className={
96
- `${eccgui}-icon ` +
97
- (intent ? `${eccgui}-intent--${intent} ` : "") +
98
- className
99
- }
100
- />
101
- );
102
- return tooltipText ? (
103
- <Tooltip content={tooltipText} {...tooltipProps}>
104
- <span>{icon}</span>
105
- </Tooltip>
106
- ) : (
107
- icon
108
- );
49
+ return <BaseIcon iconComponent={findExistingIcon(name)} {...otherBaseIconProps} />
109
50
  }
110
51
 
111
52
  export default Icon;
@@ -2,6 +2,7 @@ import React from "react";
2
2
  import Button, { ButtonProps, AnchorOrButtonProps } from "../Button/Button";
3
3
  import {CLASSPREFIX as eccgui} from "../../configuration/constants";
4
4
  import Icon from "./Icon";
5
+ import { TestIconProps } from "./TestIcon";
5
6
  import {ValidIconName} from "./canonicalIconNames";
6
7
 
7
8
  interface IconButtonProps extends Omit<ButtonProps, "icon" | "rightIcon" | "text" | "minimal" | "tooltip"> {
@@ -9,21 +10,21 @@ interface IconButtonProps extends Omit<ButtonProps, "icon" | "rightIcon" | "text
9
10
  * Canonical icon name, or an array of strings.
10
11
  * In case of the array the first valid icon name is used.
11
12
  */
12
- name: ValidIconName | string[]
13
+ name: ValidIconName | string[] | React.ReactElement<TestIconProps>;
13
14
  /**
14
15
  * Button text, will be displayed as tooltip.
15
16
  */
16
- text?: string,
17
+ text?: string;
17
18
  /**
18
19
  * If `text` should be set as HTML `title` attribute instead of attaching it as tooltip.
19
20
  * If true then `tooltipProps` is ignored.
20
21
  */
21
- tooltipAsTitle?: boolean
22
+ tooltipAsTitle?: boolean;
22
23
  /**
23
24
  * Description for icon as accessibility fallback.
24
25
  * If not set then `text` is used.
25
26
  */
26
- description?: string
27
+ description?: string;
27
28
  /**
28
29
  * Button is displayed with minimal styles (no borders, no background color).
29
30
  */
@@ -41,20 +42,23 @@ function IconButton({
41
42
  minimal=true,
42
43
  ...restProps
43
44
  }: IconButtonProps & AnchorOrButtonProps) {
45
+ const iconProps = {
46
+ small: restProps.small,
47
+ large: restProps.large,
48
+ tooltipText: tooltipAsTitle ? undefined : text,
49
+ tooltipProps: !!tooltipProps ? {hoverOpenDelay: 1000, ...tooltipProps} : {hoverOpenDelay: 1000},
50
+ description: description ? description : text,
51
+ };
52
+
44
53
  return (
45
54
  <Button
46
55
  title={tooltipAsTitle && text ? text : undefined}
47
56
  {...restProps}
48
- icon={
49
- <Icon
50
- name={name}
51
- small={restProps.small}
52
- large={restProps.large}
53
- tooltipText={tooltipAsTitle ? undefined : text}
54
- tooltipProps={!!tooltipProps ? {hoverOpenDelay: 1000, ...tooltipProps} : {hoverOpenDelay: 1000}}
55
- description={description ? description : text}
56
- />
57
- }
57
+ icon={(typeof name === "string" || Array.isArray(name)) ? (
58
+ <Icon name={name} {...iconProps} />
59
+ ) : (
60
+ React.cloneElement(name, iconProps)
61
+ )}
58
62
  className={`${eccgui}-button--icon ` + className}
59
63
  minimal={minimal}
60
64
  />
@@ -0,0 +1,39 @@
1
+ import React from "react";
2
+ import BaseIcon, { BaseIconProps } from "./BaseIcon";
3
+ import { CarbonIconType } from "./canonicalIconNames"
4
+ import { CLASSPREFIX as eccgui } from "../../configuration/constants";
5
+
6
+ export interface TestIconProps extends Omit<BaseIconProps, "iconComponent"> {
7
+ /**
8
+ * Carbon icon that is used instead of the via `name` defined canonical named icon.
9
+ */
10
+ tryout: CarbonIconType;
11
+ }
12
+
13
+ /**
14
+ * This component is primarily provided to test icons in a third application without defining them via a canonical name before.
15
+ *
16
+ * Example usage:
17
+ * ```
18
+ * import { LogoReact } from "@carbon/icons-react";
19
+ * const testIcon = <TestIcon tryout={LogoReact} />
20
+ * ```
21
+ */
22
+ function TestIcon({
23
+ className = "",
24
+ tryout,
25
+ ...otherBaseIconProps
26
+ }: TestIconProps) {
27
+ return (
28
+ <BaseIcon
29
+ iconComponent={tryout}
30
+ className={
31
+ `${eccgui}-icon--test` +
32
+ (className ? ` ${className}` : "")
33
+ }
34
+ {...otherBaseIconProps}
35
+ />
36
+ );
37
+ }
38
+
39
+ export default TestIcon;