@eccenca/gui-elements 23.0.0 → 23.1.0-easynav.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.
- package/CHANGELOG.md +35 -1
- package/README.md +7 -0
- package/dist/cjs/cmem/ActivityControl/ActivityControlWidget.js.map +1 -1
- package/dist/cjs/cmem/react-flow/ReactFlow/ReactFlow.js +7 -2
- package/dist/cjs/cmem/react-flow/ReactFlow/ReactFlow.js.map +1 -1
- package/dist/cjs/cmem/react-flow/StickyNoteModal/StickyNoteModal.js +3 -7
- package/dist/cjs/cmem/react-flow/StickyNoteModal/StickyNoteModal.js.map +1 -1
- package/dist/cjs/cmem/react-flow/extensions/scrollOnDragHook.js +200 -0
- package/dist/cjs/cmem/react-flow/extensions/scrollOnDragHook.js.map +1 -0
- package/dist/cjs/common/Intent/index.js +7 -3
- package/dist/cjs/common/Intent/index.js.map +1 -1
- package/dist/cjs/common/utils/characters.js +82 -0
- package/dist/cjs/common/utils/characters.js.map +1 -0
- package/dist/cjs/components/Application/ApplicationTitle.js +2 -2
- package/dist/cjs/components/Application/ApplicationTitle.js.map +1 -1
- package/dist/cjs/components/Badge/Badge.js +44 -0
- package/dist/cjs/components/Badge/Badge.js.map +1 -0
- package/dist/cjs/components/Depiction/Depiction.js +111 -0
- package/dist/cjs/components/Depiction/Depiction.js.map +1 -0
- package/dist/cjs/components/Grid/Grid.js +7 -2
- package/dist/cjs/components/Grid/Grid.js.map +1 -1
- package/dist/cjs/components/Grid/GridColumn.js +6 -2
- package/dist/cjs/components/Grid/GridColumn.js.map +1 -1
- package/dist/cjs/components/Grid/GridRow.js +3 -0
- package/dist/cjs/components/Grid/GridRow.js.map +1 -1
- package/dist/cjs/components/Icon/BaseIcon.js +38 -0
- package/dist/cjs/components/Icon/BaseIcon.js.map +1 -0
- package/dist/cjs/components/Icon/Icon.js +9 -24
- package/dist/cjs/components/Icon/Icon.js.map +1 -1
- package/dist/cjs/components/Icon/IconButton.js +8 -1
- package/dist/cjs/components/Icon/IconButton.js.map +1 -1
- package/dist/cjs/components/Icon/TestIcon.js +35 -0
- package/dist/cjs/components/Icon/TestIcon.js.map +1 -0
- package/dist/cjs/components/Icon/canonicalIconNames.js +123 -621
- package/dist/cjs/components/Icon/canonicalIconNames.js.map +1 -1
- package/dist/cjs/components/Icon/index.js +11 -0
- package/dist/cjs/components/Icon/index.js.map +1 -0
- package/dist/cjs/components/Menu/MenuItem.js +1 -1
- package/dist/cjs/components/Menu/MenuItem.js.map +1 -1
- package/dist/cjs/components/MultiSelect/MultiSelect.js +56 -23
- package/dist/cjs/components/MultiSelect/MultiSelect.js.map +1 -1
- package/dist/cjs/components/Notification/Notification.js +10 -2
- package/dist/cjs/components/Notification/Notification.js.map +1 -1
- package/dist/cjs/components/OverviewItem/OverviewItemDepiction.js +24 -0
- package/dist/cjs/components/OverviewItem/OverviewItemDepiction.js.map +1 -1
- package/dist/cjs/components/Tag/Tag.js +6 -2
- package/dist/cjs/components/Tag/Tag.js.map +1 -1
- package/dist/cjs/components/TextField/TextArea.js +4 -2
- package/dist/cjs/components/TextField/TextArea.js.map +1 -1
- package/dist/cjs/components/TextField/TextField.js +4 -2
- package/dist/cjs/components/TextField/TextField.js.map +1 -1
- package/dist/cjs/components/TextField/useTextValidation.js +84 -0
- package/dist/cjs/components/TextField/useTextValidation.js.map +1 -0
- package/dist/cjs/components/Tree/Tree.js.map +1 -1
- package/dist/cjs/components/Typography/Highlighter.js.map +1 -1
- package/dist/cjs/components/Typography/OverflowText.js.map +1 -1
- package/dist/cjs/components/Typography/WhiteSpaceContainer.js +35 -12
- package/dist/cjs/components/Typography/WhiteSpaceContainer.js.map +1 -1
- package/dist/cjs/components/Typography/index.js +21 -0
- package/dist/cjs/components/Typography/index.js.map +1 -0
- package/dist/cjs/components/Workspace/WorkspaceContent.js +1 -1
- package/dist/cjs/components/Workspace/WorkspaceContent.js.map +1 -1
- package/dist/cjs/components/index.js +18 -0
- package/dist/cjs/components/index.js.map +1 -0
- package/dist/cjs/extensions/react-flow/handles/HandleDefault.js +4 -3
- package/dist/cjs/extensions/react-flow/handles/HandleDefault.js.map +1 -1
- package/dist/cjs/extensions/react-flow/nodes/NodeContent.js +29 -25
- package/dist/cjs/extensions/react-flow/nodes/NodeContent.js.map +1 -1
- package/dist/cjs/extensions/react-flow/nodes/NodeDefault.js +2 -2
- package/dist/cjs/extensions/react-flow/nodes/NodeDefault.js.map +1 -1
- package/dist/cjs/extensions/react-flow/versionsupport.js +3 -0
- package/dist/cjs/extensions/react-flow/versionsupport.js.map +1 -0
- package/dist/cjs/index.js +7 -17
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/cmem/ActivityControl/ActivityControlWidget.js.map +1 -1
- package/dist/esm/cmem/react-flow/ReactFlow/ReactFlow.js +7 -2
- package/dist/esm/cmem/react-flow/ReactFlow/ReactFlow.js.map +1 -1
- package/dist/esm/cmem/react-flow/StickyNoteModal/StickyNoteModal.js +3 -6
- package/dist/esm/cmem/react-flow/StickyNoteModal/StickyNoteModal.js.map +1 -1
- package/dist/esm/cmem/react-flow/extensions/scrollOnDragHook.js +194 -0
- package/dist/esm/cmem/react-flow/extensions/scrollOnDragHook.js.map +1 -0
- package/dist/esm/common/Intent/index.js +5 -13
- package/dist/esm/common/Intent/index.js.map +1 -1
- package/dist/esm/common/utils/characters.js +96 -0
- package/dist/esm/common/utils/characters.js.map +1 -0
- package/dist/esm/components/Application/ApplicationTitle.js +2 -2
- package/dist/esm/components/Application/ApplicationTitle.js.map +1 -1
- package/dist/esm/components/Badge/Badge.js +48 -0
- package/dist/esm/components/Badge/Badge.js.map +1 -0
- package/dist/esm/components/Depiction/Depiction.js +96 -0
- package/dist/esm/components/Depiction/Depiction.js.map +1 -0
- package/dist/esm/components/Grid/Grid.js +7 -2
- package/dist/esm/components/Grid/Grid.js.map +1 -1
- package/dist/esm/components/Grid/GridColumn.js +6 -2
- package/dist/esm/components/Grid/GridColumn.js.map +1 -1
- package/dist/esm/components/Grid/GridRow.js +3 -0
- package/dist/esm/components/Grid/GridRow.js.map +1 -1
- package/dist/esm/components/Icon/BaseIcon.js +44 -0
- package/dist/esm/components/Icon/BaseIcon.js.map +1 -0
- package/dist/esm/components/Icon/Icon.js +9 -24
- package/dist/esm/components/Icon/Icon.js.map +1 -1
- package/dist/esm/components/Icon/IconButton.js +8 -1
- package/dist/esm/components/Icon/IconButton.js.map +1 -1
- package/dist/esm/components/Icon/TestIcon.js +41 -0
- package/dist/esm/components/Icon/TestIcon.js.map +1 -0
- package/dist/esm/components/Icon/canonicalIconNames.js +123 -621
- package/dist/esm/components/Icon/canonicalIconNames.js.map +1 -1
- package/dist/esm/components/Icon/index.js +4 -0
- package/dist/esm/components/Icon/index.js.map +1 -0
- package/dist/esm/components/Menu/MenuItem.js +1 -1
- package/dist/esm/components/Menu/MenuItem.js.map +1 -1
- package/dist/esm/components/MultiSelect/MultiSelect.js +61 -44
- package/dist/esm/components/MultiSelect/MultiSelect.js.map +1 -1
- package/dist/esm/components/Notification/Notification.js +12 -4
- package/dist/esm/components/Notification/Notification.js.map +1 -1
- package/dist/esm/components/OverviewItem/OverviewItemDepiction.js +24 -0
- package/dist/esm/components/OverviewItem/OverviewItemDepiction.js.map +1 -1
- package/dist/esm/components/Tag/Tag.js +6 -2
- package/dist/esm/components/Tag/Tag.js.map +1 -1
- package/dist/esm/components/TextField/TextArea.js +4 -2
- package/dist/esm/components/TextField/TextArea.js.map +1 -1
- package/dist/esm/components/TextField/TextField.js +4 -2
- package/dist/esm/components/TextField/TextField.js.map +1 -1
- package/dist/esm/components/TextField/useTextValidation.js +78 -0
- package/dist/esm/components/TextField/useTextValidation.js.map +1 -0
- package/dist/esm/components/Tree/Tree.js.map +1 -1
- package/dist/esm/components/Typography/Highlighter.js.map +1 -1
- package/dist/esm/components/Typography/OverflowText.js.map +1 -1
- package/dist/esm/components/Typography/WhiteSpaceContainer.js +16 -14
- package/dist/esm/components/Typography/WhiteSpaceContainer.js.map +1 -1
- package/dist/esm/components/Typography/index.js +12 -0
- package/dist/esm/components/Typography/index.js.map +1 -0
- package/dist/esm/components/Workspace/WorkspaceContent.js +1 -1
- package/dist/esm/components/Workspace/WorkspaceContent.js.map +1 -1
- package/dist/esm/components/index.js +6 -0
- package/dist/esm/components/index.js.map +1 -0
- package/dist/esm/extensions/react-flow/handles/HandleDefault.js +5 -4
- package/dist/esm/extensions/react-flow/handles/HandleDefault.js.map +1 -1
- package/dist/esm/extensions/react-flow/nodes/NodeContent.js +37 -32
- package/dist/esm/extensions/react-flow/nodes/NodeContent.js.map +1 -1
- package/dist/esm/extensions/react-flow/nodes/NodeDefault.js +2 -2
- package/dist/esm/extensions/react-flow/nodes/NodeDefault.js.map +1 -1
- package/dist/esm/extensions/react-flow/versionsupport.js +2 -0
- package/dist/esm/extensions/react-flow/versionsupport.js.map +1 -0
- package/dist/esm/index.js +5 -10
- package/dist/esm/index.js.map +1 -1
- package/dist/types/cmem/ActivityControl/ActivityControlWidget.d.ts +2 -1
- package/dist/types/cmem/react-flow/ReactFlow/ReactFlow.d.ts +14 -0
- package/dist/types/cmem/react-flow/extensions/scrollOnDragHook.d.ts +22 -0
- package/dist/types/common/Intent/index.d.ts +4 -3
- package/dist/types/common/utils/characters.d.ts +19 -0
- package/dist/types/components/Badge/Badge.d.ts +42 -0
- package/dist/types/components/Depiction/Depiction.d.ts +71 -0
- package/dist/types/components/Grid/Grid.d.ts +21 -2
- package/dist/types/components/Grid/GridColumn.d.ts +21 -3
- package/dist/types/components/Grid/GridRow.d.ts +18 -2
- package/dist/types/components/Icon/BaseIcon.d.ts +45 -0
- package/dist/types/components/Icon/Icon.d.ts +7 -34
- package/dist/types/components/Icon/IconButton.d.ts +3 -2
- package/dist/types/components/Icon/TestIcon.d.ts +20 -0
- package/dist/types/components/Icon/canonicalIconNames.d.ts +9 -7
- package/dist/types/components/Icon/index.d.ts +4 -0
- package/dist/types/components/Menu/MenuItem.d.ts +2 -1
- package/dist/types/components/MultiSelect/MultiSelect.d.ts +3 -1
- package/dist/types/components/Notification/Notification.d.ts +13 -4
- package/dist/types/components/Tabs/Tab.d.ts +2 -0
- package/dist/types/components/Tag/Tag.d.ts +16 -3
- package/dist/types/components/TextField/TextArea.d.ts +7 -2
- package/dist/types/components/TextField/TextField.d.ts +6 -1
- package/dist/types/components/TextField/useTextValidation.d.ts +28 -0
- package/dist/types/components/Tree/Tree.d.ts +2 -1
- package/dist/types/components/Typography/Highlighter.d.ts +2 -2
- package/dist/types/components/Typography/OverflowText.d.ts +2 -2
- package/dist/types/components/Typography/WhiteSpaceContainer.d.ts +45 -4
- package/dist/types/components/Typography/index.d.ts +12 -0
- package/dist/types/components/index.d.ts +5 -0
- package/dist/types/extensions/react-flow/handles/HandleDefault.d.ts +11 -3
- package/dist/types/extensions/react-flow/nodes/NodeContent.d.ts +16 -6
- package/dist/types/extensions/react-flow/nodes/NodeDefault.d.ts +2 -1
- package/dist/types/extensions/react-flow/versionsupport.d.ts +6 -0
- package/dist/types/index.d.ts +6 -11
- package/package.json +14 -16
- package/scripts/compile-sass.ts +9 -1
- package/src/_shame.scss +1 -1
- package/src/cmem/ActivityControl/ActivityControlWidget.stories.tsx +6 -4
- package/src/cmem/ActivityControl/ActivityControlWidget.tsx +3 -2
- package/src/cmem/react-flow/ReactFlow/ReactFlow.tsx +26 -1
- package/src/cmem/react-flow/StickyNoteModal/StickyNoteModal.tsx +10 -6
- package/src/cmem/react-flow/extensions/scrollOnDragHook.ts +247 -0
- package/src/common/Intent/index.ts +16 -12
- package/src/common/utils/characters.ts +111 -0
- package/src/components/Accordion/accordion.scss +4 -3
- package/src/components/Application/ApplicationTitle.tsx +2 -2
- package/src/components/Application/_config.scss +1 -1
- package/src/components/Application/_content.scss +1 -1
- package/src/components/Application/_header.scss +2 -2
- package/src/components/Application/_sidebar.scss +2 -9
- package/src/components/Application/_toolbar.scss +1 -1
- package/src/components/Application/application.scss +4 -4
- package/src/components/AutocompleteField/autoCompleteFieldUtils.tsx +13 -8
- package/src/components/Badge/Badge.stories.tsx +47 -0
- package/src/components/Badge/Badge.tsx +93 -0
- package/src/components/Badge/badge.scss +44 -0
- package/src/components/Depiction/Depiction.tsx +198 -0
- package/src/components/Depiction/depiction.scss +176 -0
- package/src/components/Depiction/stories/Depiction.stories.tsx +69 -0
- package/src/components/Depiction/stories/test-16to9.png +0 -0
- package/src/components/Depiction/stories/test-16to9.svg +41 -0
- package/src/components/Depiction/stories/test-16to9.tobase64.svg +41 -0
- package/src/components/Depiction/stories/test-16to9.tsx +44 -0
- package/src/components/Depiction/stories/test-9to16.png +0 -0
- package/src/components/Depiction/stories/test-9to16.svg +44 -0
- package/src/components/Depiction/stories/test-9to16.tobase64.svg +44 -0
- package/src/components/Depiction/stories/test-9to16.tsx +48 -0
- package/src/components/Grid/Grid.tsx +22 -4
- package/src/components/Grid/GridColumn.tsx +24 -7
- package/src/components/Grid/GridRow.tsx +18 -3
- package/src/components/Grid/grid.scss +14 -13
- package/src/components/Grid/stories/Grid.stories.tsx +27 -0
- package/src/components/Grid/stories/GridColumn.stories.tsx +66 -0
- package/src/components/Grid/stories/GridRow.stories.tsx +47 -0
- package/src/components/Icon/BaseIcon.tsx +84 -0
- package/src/components/Icon/Icon.tsx +23 -82
- package/src/components/Icon/IconButton.tsx +18 -14
- package/src/components/Icon/TestIcon.tsx +39 -0
- package/src/components/Icon/canonicalIconNames.tsx +132 -633
- package/src/components/Icon/index.ts +5 -0
- package/src/components/Icon/stories/Icon.stories.tsx +13 -0
- package/src/components/Icon/stories/IconButton.stories.tsx +14 -7
- package/src/components/Icon/stories/TestIcon.stories.tsx +28 -0
- package/src/components/Link/link.scss +2 -1
- package/src/components/Menu/MenuItem.tsx +14 -4
- package/src/components/Menu/Stories/MenuItem.stories.tsx +16 -2
- package/src/components/MultiSelect/MultiSelect.tsx +58 -27
- package/src/components/Notification/Notification.stories.tsx +4 -0
- package/src/components/Notification/Notification.tsx +26 -6
- package/src/components/OverviewItem/OverviewItemDepiction.tsx +31 -0
- package/src/components/OverviewItem/overviewitem.scss +2 -1
- package/src/components/OverviewItem/stories/OverviewItem.stories.tsx +22 -1
- package/src/components/OverviewItem/stories/OverviewItemDepiction.stories.tsx +8 -3
- package/src/components/Pagination/pagination.scss +3 -2
- package/src/components/SimpleTable/simpletable.scss +11 -12
- package/src/components/Tag/Tag.stories.tsx +7 -2
- package/src/components/Tag/Tag.tsx +24 -4
- package/src/components/Tag/tag.scss +84 -3
- package/src/components/TagInput/taginput.scss +6 -0
- package/src/components/TextField/TextArea.tsx +10 -1
- package/src/components/TextField/TextField.tsx +9 -0
- package/src/components/TextField/stories/SearchField.stories.tsx +1 -1
- package/src/components/TextField/textfield.scss +12 -0
- package/src/components/TextField/useTextValidation.ts +103 -0
- package/src/components/Tooltip/tooltip.scss +1 -1
- package/src/components/Tree/Tree.stories.tsx +7 -1
- package/src/components/Tree/Tree.tsx +2 -1
- package/src/components/Typography/Highlighter.tsx +2 -2
- package/src/components/Typography/OverflowText.tsx +2 -2
- package/src/components/Typography/WhiteSpaceContainer.tsx +69 -21
- package/src/components/Typography/index.ts +25 -0
- package/src/components/Typography/stories/WhiteSpaceContainer.stories.tsx +55 -0
- package/src/components/Typography/typography.scss +3 -2
- package/src/components/Workspace/WorkspaceContent.tsx +1 -1
- package/src/components/index.scss +5 -0
- package/src/components/index.ts +5 -0
- package/src/extensions/react-flow/handles/HandleDefault.tsx +31 -10
- package/src/extensions/react-flow/nodes/NodeContent.tsx +69 -39
- package/src/extensions/react-flow/nodes/NodeDefault.tsx +4 -2
- package/src/extensions/react-flow/nodes/_nodes.scss +13 -7
- package/src/extensions/react-flow/nodes/stories/NodeContent.stories.tsx +5 -0
- package/src/extensions/react-flow/versionsupport.ts +6 -0
- package/src/includes/carbon-components/_components.scss +11 -0
- package/src/includes/carbon-components/_requisits.scss +18 -0
- package/src/includes/carbon-components/_variables.scss +50 -53
- package/src/index.scss +4 -105
- package/src/index.ts +6 -16
|
@@ -1,111 +1,52 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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<
|
|
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 = (
|
|
47
|
-
|
|
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 = (
|
|
57
|
-
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
large = false,
|
|
73
|
-
small = false,
|
|
74
|
-
tooltipText,
|
|
75
|
-
tooltipProps,
|
|
76
|
-
intent,
|
|
77
|
-
...restProps
|
|
46
|
+
name,
|
|
47
|
+
...otherBaseIconProps
|
|
78
48
|
}: IconProps) {
|
|
79
|
-
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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;
|