@onewelcome/react-lib-components 1.3.0 → 1.5.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/README.md +7 -0
- package/dist/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/dist/Button/IconButton.d.ts +2 -1
- package/dist/ContextMenu/ContextMenu.d.ts +4 -1
- package/dist/DataGrid/DataGrid.d.ts +1 -0
- package/dist/DataGrid/DataGridActions/DataGridActions.d.ts +2 -1
- package/dist/DataGrid/DataGridActions/DataGridColumnsToggle.d.ts +1 -1
- package/dist/DataGrid/datagrid.interfaces.d.ts +4 -4
- package/dist/Form/Form.d.ts +3 -3
- package/dist/Form/FormControl/FormControl.d.ts +1 -1
- package/dist/Form/Input/Input.d.ts +1 -1
- package/dist/Form/Select/Select.d.ts +1 -1
- package/dist/Form/Select/Select.interfaces.d.ts +1 -1
- package/dist/Icon/Icon.d.ts +1 -1
- package/dist/Link/Link.d.ts +1 -1
- package/dist/Notifications/SlideInModal/SlideInModal.d.ts +1 -1
- package/dist/Notifications/Snackbar/interfaces.d.ts +2 -2
- package/dist/Pagination/Pagination.d.ts +3 -3
- package/dist/Popover/Popover.d.ts +3 -1
- package/dist/Tabs/Tab.d.ts +5 -9
- package/dist/Tabs/TabButton.d.ts +3 -6
- package/dist/Tabs/Tabs.d.ts +1 -2
- package/dist/Typography/Typography.d.ts +2 -2
- package/dist/Wizard/Wizard.d.ts +1 -1
- package/dist/Wizard/wizardStateReducer.d.ts +2 -2
- package/dist/_BaseStyling_/BaseStyling.d.ts +2 -0
- package/dist/hooks/usePosition.d.ts +6 -5
- package/dist/hooks/useSpacing.d.ts +3 -3
- package/dist/interfaces.d.ts +1 -1
- package/dist/react-lib-components.cjs.development.js +507 -440
- package/dist/react-lib-components.cjs.development.js.map +1 -1
- package/dist/react-lib-components.cjs.production.min.js +1 -1
- package/dist/react-lib-components.cjs.production.min.js.map +1 -1
- package/dist/react-lib-components.esm.js +508 -441
- package/dist/react-lib-components.esm.js.map +1 -1
- package/dist/util/helper.d.ts +1 -1
- package/package.json +36 -35
- package/src/Breadcrumbs/Breadcrumbs.tsx +46 -38
- package/src/Button/BaseButton.tsx +23 -20
- package/src/Button/Button.tsx +40 -40
- package/src/Button/IconButton.tsx +28 -28
- package/src/ContextMenu/ContextMenu.tsx +180 -168
- package/src/ContextMenu/ContextMenuItem.tsx +55 -49
- package/src/DataGrid/DataGrid.tsx +1 -0
- package/src/DataGrid/DataGridActions/DataGridActions.module.scss +1 -1
- package/src/DataGrid/DataGridActions/DataGridActions.test.tsx +4 -2
- package/src/DataGrid/DataGridActions/DataGridActions.tsx +95 -87
- package/src/DataGrid/DataGridActions/DataGridColumnsToggle.tsx +64 -64
- package/src/DataGrid/DataGridBody/DataGridCell.tsx +42 -44
- package/src/DataGrid/DataGridBody/DataGridRow.tsx +29 -29
- package/src/DataGrid/DataGridHeader/DataGridHeader.tsx +78 -78
- package/src/DataGrid/DataGridHeader/DataGridHeaderCell.tsx +48 -48
- package/src/Form/Checkbox/Checkbox.tsx +134 -130
- package/src/Form/Fieldset/Fieldset.tsx +81 -78
- package/src/Form/Form.tsx +9 -4
- package/src/Form/FormControl/FormControl.module.scss +1 -20
- package/src/Form/FormControl/FormControl.tsx +36 -35
- package/src/Form/FormGroup/FormGroup.tsx +62 -62
- package/src/Form/FormHelperText/FormHelperText.tsx +19 -18
- package/src/Form/FormSelectorWrapper/FormSelectorWrapper.tsx +58 -53
- package/src/Form/Input/Input.test.tsx +12 -0
- package/src/Form/Input/Input.tsx +91 -87
- package/src/Form/Label/Label.tsx +17 -16
- package/src/Form/Radio/Radio.tsx +91 -91
- package/src/Form/Select/Option.tsx +66 -60
- package/src/Form/Select/Select.tsx +207 -209
- package/src/Form/Textarea/Textarea.tsx +51 -53
- package/src/Form/Toggle/Toggle.tsx +26 -23
- package/src/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.tsx +51 -43
- package/src/Form/Wrapper/InputWrapper/InputWrapper.tsx +112 -106
- package/src/Form/Wrapper/RadioWrapper/RadioWrapper.tsx +67 -62
- package/src/Form/Wrapper/SelectWrapper/SelectWrapper.tsx +42 -37
- package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.tsx +94 -94
- package/src/Form/Wrapper/Wrapper/Wrapper.tsx +73 -73
- package/src/Icon/Icon.tsx +19 -16
- package/src/Link/Link.tsx +68 -63
- package/src/Notifications/BaseModal/BaseModal.tsx +68 -68
- package/src/Notifications/BaseModal/BaseModalActions/BaseModalActions.tsx +13 -10
- package/src/Notifications/BaseModal/BaseModalContent/BaseModalContent.tsx +33 -25
- package/src/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.tsx +20 -17
- package/src/Notifications/Dialog/Dialog.tsx +83 -83
- package/src/Notifications/Dialog/DialogActions/DialogActions.tsx +17 -14
- package/src/Notifications/Dialog/DialogTitle/DialogTitle.tsx +15 -12
- package/src/Notifications/DiscardChangesModal/DiscardChangesDialog/DiscardChangesDialog.tsx +40 -40
- package/src/Notifications/SlideInModal/SlideInModal.module.scss +5 -5
- package/src/Notifications/SlideInModal/SlideInModal.test.tsx +7 -2
- package/src/Notifications/SlideInModal/SlideInModal.tsx +47 -27
- package/src/Pagination/Pagination.tsx +169 -169
- package/src/Popover/Popover.module.scss +1 -0
- package/src/Popover/Popover.test.tsx +4 -1
- package/src/Popover/Popover.tsx +74 -32
- package/src/ProgressBar/ProgressBar.tsx +17 -14
- package/src/Skeleton/Skeleton.tsx +23 -20
- package/src/StatusIndicator/StatusIndicator.tsx +18 -15
- package/src/Tabs/{TabPanel.module.scss → Tab.module.scss} +1 -1
- package/src/Tabs/Tab.test.tsx +1 -39
- package/src/Tabs/Tab.tsx +16 -10
- package/src/Tabs/TabButton.module.scss +0 -4
- package/src/Tabs/TabButton.test.tsx +3 -31
- package/src/Tabs/TabButton.tsx +35 -49
- package/src/Tabs/Tabs.test.tsx +40 -33
- package/src/Tabs/Tabs.tsx +107 -101
- package/src/TextEllipsis/TextEllipsis.tsx +50 -41
- package/src/Tiles/Tile.tsx +58 -56
- package/src/Tiles/Tiles.tsx +44 -41
- package/src/Tooltip/Tooltip.test.tsx +5 -5
- package/src/Tooltip/Tooltip.tsx +101 -100
- package/src/Typography/Typography.tsx +47 -44
- package/src/Wizard/BaseWizardSteps/BaseWizardSteps.tsx +55 -52
- package/src/Wizard/WizardSteps/WizardSteps.tsx +25 -22
- package/src/_BaseStyling_/BaseStyling.tsx +4 -0
- package/src/hooks/usePosition.test.tsx +85 -85
- package/src/hooks/usePosition.ts +6 -3
- package/src/mixins.module.scss +7 -7
- package/src/util/helper.test.tsx +0 -28
- package/dist/Tabs/TabPanel.d.ts +0 -8
- package/src/Tabs/TabPanel.test.tsx +0 -92
- package/src/Tabs/TabPanel.tsx +0 -43
package/dist/util/helper.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
+
"homepage": "http://onewelcome.github.io/react-lib-components",
|
|
2
3
|
"name": "@onewelcome/react-lib-components",
|
|
3
|
-
"version": "1.
|
|
4
|
+
"version": "1.5.0",
|
|
4
5
|
"license": "Apache-2.0",
|
|
5
6
|
"author": "OneWelcome B.V.",
|
|
6
7
|
"main": "dist/index.js",
|
|
@@ -51,60 +52,60 @@
|
|
|
51
52
|
}
|
|
52
53
|
],
|
|
53
54
|
"devDependencies": {
|
|
54
|
-
"@babel/core": "^7.
|
|
55
|
+
"@babel/core": "^7.20.12",
|
|
55
56
|
"@mdx-js/react": "^1.6.22",
|
|
56
57
|
"@onewelcome/eslint-config-shared-codestyle": "^9.0.3",
|
|
57
58
|
"@size-limit/preset-small-lib": "^7.0.8",
|
|
58
|
-
"@storybook/addon-a11y": "^6.5.
|
|
59
|
-
"@storybook/addon-docs": "^6.5.
|
|
60
|
-
"@storybook/addon-essentials": "^6.5.
|
|
61
|
-
"@storybook/addon-links": "^6.5.
|
|
62
|
-
"@storybook/addons": "^6.5.
|
|
63
|
-
"@storybook/builder-webpack5": "^6.5.
|
|
64
|
-
"@storybook/manager-webpack5": "^6.5.
|
|
59
|
+
"@storybook/addon-a11y": "^6.5.15",
|
|
60
|
+
"@storybook/addon-docs": "^6.5.15",
|
|
61
|
+
"@storybook/addon-essentials": "^6.5.15",
|
|
62
|
+
"@storybook/addon-links": "^6.5.15",
|
|
63
|
+
"@storybook/addons": "^6.5.15",
|
|
64
|
+
"@storybook/builder-webpack5": "^6.5.15",
|
|
65
|
+
"@storybook/manager-webpack5": "^6.5.15",
|
|
65
66
|
"@storybook/preset-scss": "^1.0.3",
|
|
66
|
-
"@storybook/react": "^6.5.
|
|
67
|
-
"@storybook/theming": "^6.5.
|
|
68
|
-
"@testing-library/dom": "^8.
|
|
67
|
+
"@storybook/react": "^6.5.15",
|
|
68
|
+
"@storybook/theming": "^6.5.15",
|
|
69
|
+
"@testing-library/dom": "^8.19.1",
|
|
69
70
|
"@testing-library/jest-dom": "^5.16.5",
|
|
70
71
|
"@testing-library/react": "^12.1.5",
|
|
71
|
-
"@testing-library/react-hooks": "^
|
|
72
|
+
"@testing-library/react-hooks": "^8.0.1",
|
|
72
73
|
"@testing-library/user-event": "^13.5.0",
|
|
73
|
-
"@tsconfig/create-react-app": "^1.0.
|
|
74
|
+
"@tsconfig/create-react-app": "^1.0.3",
|
|
74
75
|
"@tsconfig/recommended": "^1.0.1",
|
|
75
76
|
"@types/color-convert": "^2.0.0",
|
|
76
|
-
"@types/mdx": "^2.0.
|
|
77
|
-
"@types/react": "^17.0.
|
|
78
|
-
"@types/react-dom": "^17.0.
|
|
79
|
-
"@types/react-router": "^5.1.
|
|
77
|
+
"@types/mdx": "^2.0.3",
|
|
78
|
+
"@types/react": "^17.0.52",
|
|
79
|
+
"@types/react-dom": "^17.0.18",
|
|
80
|
+
"@types/react-router": "^5.1.20",
|
|
80
81
|
"@types/react-router-dom": "^5.3.3",
|
|
81
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
82
|
-
"@typescript-eslint/parser": "^5.
|
|
83
|
-
"babel-loader": "^
|
|
84
|
-
"dts-cli": "^1.6.
|
|
85
|
-
"eslint": "^8.
|
|
86
|
-
"eslint-config-prettier": "^8.
|
|
82
|
+
"@typescript-eslint/eslint-plugin": "^5.48.1",
|
|
83
|
+
"@typescript-eslint/parser": "^5.48.1",
|
|
84
|
+
"babel-loader": "^9.1.0",
|
|
85
|
+
"dts-cli": "^1.6.3",
|
|
86
|
+
"eslint": "^8.31.0",
|
|
87
|
+
"eslint-config-prettier": "^8.6.0",
|
|
87
88
|
"eslint-plugin-cypress": "^2.12.1",
|
|
88
|
-
"eslint-plugin-jest": "^
|
|
89
|
+
"eslint-plugin-jest": "^27.2.1",
|
|
89
90
|
"eslint-plugin-license-header": "^0.6.0",
|
|
90
91
|
"eslint-plugin-prettier": "^4.2.1",
|
|
91
92
|
"html-webpack-plugin": "^5.5.0",
|
|
92
|
-
"husky": "^
|
|
93
|
+
"husky": "^8.0.3",
|
|
93
94
|
"identity-obj-proxy": "^3.0.0",
|
|
94
|
-
"jest-junit": "^
|
|
95
|
-
"lint-staged": "^13.0
|
|
95
|
+
"jest-junit": "^15.0.0",
|
|
96
|
+
"lint-staged": "^13.1.0",
|
|
96
97
|
"npm-run-all": "^4.1.5",
|
|
97
|
-
"prettier": "^2.
|
|
98
|
+
"prettier": "^2.8.2",
|
|
98
99
|
"react": "^17.0.2",
|
|
99
100
|
"react-dom": "^17.0.2",
|
|
100
|
-
"react-is": "^
|
|
101
|
-
"react-router": "^6.
|
|
102
|
-
"react-router-dom": "^6.
|
|
101
|
+
"react-is": "^18.2.0",
|
|
102
|
+
"react-router": "^6.6.2",
|
|
103
|
+
"react-router-dom": "^6.6.2",
|
|
103
104
|
"rollup-plugin-cleanup": "^3.2.1",
|
|
104
105
|
"rollup-plugin-styles": "^4.0.0",
|
|
105
|
-
"sass": "^1.
|
|
106
|
+
"sass": "^1.57.1",
|
|
106
107
|
"size-limit": "^7.0.8",
|
|
107
|
-
"tslib": "^2.4.
|
|
108
|
-
"typescript": "^4.
|
|
108
|
+
"tslib": "^2.4.1",
|
|
109
|
+
"typescript": "^4.9.4"
|
|
109
110
|
}
|
|
110
111
|
}
|
|
@@ -14,7 +14,12 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import React, {
|
|
17
|
+
import React, {
|
|
18
|
+
ComponentPropsWithRef,
|
|
19
|
+
ForwardRefRenderFunction,
|
|
20
|
+
Fragment,
|
|
21
|
+
ReactElement
|
|
22
|
+
} from "react";
|
|
18
23
|
import { Icon, Icons } from "../Icon/Icon";
|
|
19
24
|
import { Link, Props as LinkProps } from "../Link/Link";
|
|
20
25
|
import { Typography } from "../Typography/Typography";
|
|
@@ -27,40 +32,43 @@ export interface Props extends ComponentPropsWithRef<"div"> {
|
|
|
27
32
|
ariaLabel: string;
|
|
28
33
|
}
|
|
29
34
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
);
|
|
35
|
+
const BreadcrumbsComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
|
|
36
|
+
{ children, ariaLabel, className = "", ...rest }: Props,
|
|
37
|
+
ref
|
|
38
|
+
) => {
|
|
39
|
+
const items = React.Children.map(children, (child, index) => {
|
|
40
|
+
const isLastElement = Array.isArray(children) ? index === children.length - 1 : true;
|
|
41
|
+
if (isLastElement) {
|
|
42
|
+
return (
|
|
43
|
+
<Typography
|
|
44
|
+
key={child.key}
|
|
45
|
+
variant="body"
|
|
46
|
+
tag="span"
|
|
47
|
+
className={classes["last"]}
|
|
48
|
+
aria-current="page"
|
|
49
|
+
>
|
|
50
|
+
{child.props.children}
|
|
51
|
+
</Typography>
|
|
52
|
+
);
|
|
53
|
+
} else {
|
|
54
|
+
return (
|
|
55
|
+
<Fragment key={child.key}>
|
|
56
|
+
{React.cloneElement(child)}
|
|
57
|
+
<Icon icon={Icons.ChevronRight} className={classes["icon"]} />
|
|
58
|
+
</Fragment>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return (
|
|
63
|
+
<nav
|
|
64
|
+
{...rest}
|
|
65
|
+
ref={ref}
|
|
66
|
+
aria-label={ariaLabel}
|
|
67
|
+
className={`${classes["breadcrumbs"]} ${className}`}
|
|
68
|
+
>
|
|
69
|
+
{items}
|
|
70
|
+
</nav>
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const Breadcrumbs = React.forwardRef(BreadcrumbsComponent);
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import React, { ComponentPropsWithRef } from "react";
|
|
17
|
+
import React, { ForwardRefRenderFunction, ComponentPropsWithRef } from "react";
|
|
18
18
|
import classes from "./BaseButton.module.scss";
|
|
19
19
|
|
|
20
20
|
export interface Props extends ComponentPropsWithRef<"button"> {
|
|
@@ -23,24 +23,27 @@ export interface Props extends ComponentPropsWithRef<"button"> {
|
|
|
23
23
|
color?: "primary" | "secondary" | "tertiary" | "default";
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
const BaseButtonComponent: ForwardRefRenderFunction<HTMLButtonElement, Props> = (
|
|
27
|
+
{ children, type = "button", className, ...rest },
|
|
28
|
+
ref
|
|
29
|
+
) => {
|
|
30
|
+
const validTypes = ["submit", "button", "reset"];
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<button
|
|
37
|
-
{...rest}
|
|
38
|
-
ref={ref}
|
|
39
|
-
type={type}
|
|
40
|
-
className={`${classes.button} ${className ? className : ""}`}
|
|
41
|
-
>
|
|
42
|
-
{children}
|
|
43
|
-
</button>
|
|
32
|
+
if (!validTypes.includes(type))
|
|
33
|
+
throw new Error(
|
|
34
|
+
`You have entered an invalid button type. Expected 'submit', 'button' or 'reset' got ${type}`
|
|
44
35
|
);
|
|
45
|
-
|
|
46
|
-
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<button
|
|
39
|
+
{...rest}
|
|
40
|
+
ref={ref}
|
|
41
|
+
type={type}
|
|
42
|
+
className={`${classes.button} ${className ? className : ""}`}
|
|
43
|
+
>
|
|
44
|
+
{children}
|
|
45
|
+
</button>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const BaseButton = React.forwardRef(BaseButtonComponent);
|
package/src/Button/Button.tsx
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import React from "react";
|
|
17
|
+
import React, { ForwardRefRenderFunction } from "react";
|
|
18
18
|
import { BaseButton, Props as BaseButtonProps } from "./BaseButton";
|
|
19
19
|
import classes from "./Button.module.scss";
|
|
20
20
|
|
|
@@ -25,47 +25,47 @@ export interface Props extends BaseButtonProps {
|
|
|
25
25
|
variant?: "text" | "fill" | "outline";
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const additionalClasses = [];
|
|
28
|
+
const ButtonComponent: ForwardRefRenderFunction<HTMLButtonElement, Props> = (
|
|
29
|
+
{
|
|
30
|
+
children,
|
|
31
|
+
variant = "fill",
|
|
32
|
+
color = "primary",
|
|
33
|
+
startIcon = false,
|
|
34
|
+
endIcon = false,
|
|
35
|
+
className,
|
|
36
|
+
...rest
|
|
37
|
+
},
|
|
38
|
+
ref
|
|
39
|
+
) => {
|
|
40
|
+
const additionalClasses = [];
|
|
42
41
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (startIcon) {
|
|
48
|
-
additionalClasses.push(classes["start-icon"]);
|
|
49
|
-
}
|
|
42
|
+
if (startIcon || endIcon) {
|
|
43
|
+
additionalClasses.push(classes["has-icon"]);
|
|
44
|
+
}
|
|
50
45
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
if (startIcon) {
|
|
47
|
+
additionalClasses.push(classes["start-icon"]);
|
|
48
|
+
}
|
|
54
49
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
if (endIcon) {
|
|
51
|
+
additionalClasses.push(classes["end-icon"]);
|
|
52
|
+
}
|
|
58
53
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
{...rest}
|
|
62
|
-
ref={ref}
|
|
63
|
-
className={`${classes[color]} ${classes[variant]} ${additionalClasses.join(" ")}`}
|
|
64
|
-
>
|
|
65
|
-
{startIcon && <i>{startIcon}</i>}
|
|
66
|
-
<span>{children}</span>
|
|
67
|
-
{endIcon && <i> {endIcon}</i>}
|
|
68
|
-
</BaseButton>
|
|
69
|
-
);
|
|
54
|
+
if (className) {
|
|
55
|
+
additionalClasses.push(className);
|
|
70
56
|
}
|
|
71
|
-
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<BaseButton
|
|
60
|
+
{...rest}
|
|
61
|
+
ref={ref}
|
|
62
|
+
className={`${classes[color]} ${classes[variant]} ${additionalClasses.join(" ")}`}
|
|
63
|
+
>
|
|
64
|
+
{startIcon && <i>{startIcon}</i>}
|
|
65
|
+
<span>{children}</span>
|
|
66
|
+
{endIcon && <i> {endIcon}</i>}
|
|
67
|
+
</BaseButton>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const Button = React.forwardRef(ButtonComponent);
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import React, { Fragment } from "react";
|
|
17
|
+
import React, { ForwardRefRenderFunction, Fragment } from "react";
|
|
18
18
|
import { BaseButton, Props as BaseButtonProps } from "./BaseButton";
|
|
19
19
|
import classes from "./IconButton.module.scss";
|
|
20
20
|
import readyclasses from "../readyclasses.module.scss";
|
|
@@ -27,33 +27,33 @@ export interface Props extends BaseButtonProps {
|
|
|
27
27
|
title?: string;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const iconButtonClasses = [
|
|
40
|
-
classes["icon-button"],
|
|
41
|
-
classes[variant],
|
|
42
|
-
classes[color],
|
|
43
|
-
classes["button-" + iconSize]
|
|
44
|
-
];
|
|
30
|
+
export const IconButtonComponent: ForwardRefRenderFunction<HTMLButtonElement, Props> = (
|
|
31
|
+
{ children, color = "primary", variant = "text", iconSize = "m", title, className, ...rest },
|
|
32
|
+
ref
|
|
33
|
+
) => {
|
|
34
|
+
if (!title) {
|
|
35
|
+
console.error("Please make sure to specify a 'title' prop to your IconButton component! ");
|
|
36
|
+
}
|
|
45
37
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
const iconButtonClasses = [
|
|
39
|
+
classes["icon-button"],
|
|
40
|
+
classes[variant],
|
|
41
|
+
classes[color],
|
|
42
|
+
classes["button-" + iconSize]
|
|
43
|
+
];
|
|
49
44
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
<Fragment>
|
|
53
|
-
{children}
|
|
54
|
-
<span className={readyclasses["sr-only"]}>{title}</span>
|
|
55
|
-
</Fragment>
|
|
56
|
-
</BaseButton>
|
|
57
|
-
);
|
|
45
|
+
if (className) {
|
|
46
|
+
iconButtonClasses.push(className);
|
|
58
47
|
}
|
|
59
|
-
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<BaseButton {...rest} ref={ref} className={iconButtonClasses.join(" ")}>
|
|
51
|
+
<Fragment>
|
|
52
|
+
{children}
|
|
53
|
+
<span className={readyclasses["sr-only"]}>{title}</span>
|
|
54
|
+
</Fragment>
|
|
55
|
+
</BaseButton>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const IconButton = React.forwardRef(IconButtonComponent);
|