@onewelcome/react-lib-components 1.2.0 → 1.4.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/dist/Button/IconButton.d.ts +2 -1
- package/dist/DataGrid/DataGrid.d.ts +1 -0
- package/dist/DataGrid/DataGridActions/DataGridActions.d.ts +2 -1
- package/dist/Form/Form.d.ts +3 -3
- package/dist/Notifications/SlideInModal/SlideInModal.d.ts +1 -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/hooks/useDebouncedCallback.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/react-lib-components.cjs.development.js +472 -395
- 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 +473 -397
- package/dist/react-lib-components.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/Breadcrumbs/Breadcrumbs.tsx +46 -38
- package/src/Button/BaseButton.tsx +23 -20
- package/src/Button/Button.module.scss +9 -0
- package/src/Button/Button.tsx +40 -40
- package/src/Button/IconButton.tsx +28 -28
- package/src/ContextMenu/ContextMenu.tsx +161 -160
- 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.tsx +90 -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.module.scss +1 -0
- 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.tsx +43 -33
- 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.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/hooks/useDebouncedCallback.test.ts +140 -0
- package/src/hooks/useDebouncedCallback.tsx +32 -0
- package/src/index.ts +1 -0
- package/src/mixins.module.scss +2 -2
- 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
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import React, { ComponentPropsWithRef, useState } from "react";
|
|
17
|
+
import React, { ForwardRefRenderFunction, ComponentPropsWithRef, useState } from "react";
|
|
18
18
|
import classes from "./TextareaWrapper.module.scss";
|
|
19
19
|
import { Wrapper, WrapperProps } from "../Wrapper/Wrapper";
|
|
20
20
|
import { Textarea, Props as TextareaProps } from "../../Textarea/Textarea";
|
|
@@ -36,101 +36,101 @@ export interface Props
|
|
|
36
36
|
onMouseLeave?: (event: React.MouseEvent<HTMLTextAreaElement>) => void;
|
|
37
37
|
}
|
|
38
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
|
-
|
|
67
|
-
|
|
68
|
-
const [hover, setHover] = useState(false);
|
|
39
|
+
const TextareaWrapperComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
|
|
40
|
+
{
|
|
41
|
+
name,
|
|
42
|
+
error,
|
|
43
|
+
value,
|
|
44
|
+
label,
|
|
45
|
+
placeholder,
|
|
46
|
+
textareaProps,
|
|
47
|
+
helperProps,
|
|
48
|
+
onChange,
|
|
49
|
+
onFocus,
|
|
50
|
+
onBlur,
|
|
51
|
+
onMouseEnter,
|
|
52
|
+
onMouseLeave,
|
|
53
|
+
disabled,
|
|
54
|
+
...rest
|
|
55
|
+
}: Props,
|
|
56
|
+
ref
|
|
57
|
+
) => {
|
|
58
|
+
const {
|
|
59
|
+
errorId,
|
|
60
|
+
floatingLabelActive,
|
|
61
|
+
setFloatingLabelActive,
|
|
62
|
+
hasFocus,
|
|
63
|
+
setHasFocus,
|
|
64
|
+
helperId,
|
|
65
|
+
labelId
|
|
66
|
+
} = useWrapper(value, placeholder);
|
|
67
|
+
const [hover, setHover] = useState(false);
|
|
69
68
|
|
|
70
|
-
|
|
69
|
+
const wrapperClasses: string[] = [];
|
|
71
70
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
hasFocus && wrapperClasses.push(classes["focus"]);
|
|
72
|
+
hover && wrapperClasses.push(classes["hover"]);
|
|
73
|
+
disabled && wrapperClasses.push(classes["disabled"]);
|
|
74
|
+
error && wrapperClasses.push(classes["error"]);
|
|
76
75
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
76
|
+
return (
|
|
77
|
+
<Wrapper
|
|
78
|
+
{...rest}
|
|
79
|
+
ref={ref}
|
|
80
|
+
disabled={disabled}
|
|
81
|
+
labelProps={{
|
|
82
|
+
id: labelId,
|
|
83
|
+
className: `${classes["textarea-label"]} ${wrapperClasses.join(" ")}`
|
|
84
|
+
}}
|
|
85
|
+
name={name}
|
|
86
|
+
label={label}
|
|
87
|
+
helperId={helperId}
|
|
88
|
+
helperProps={{
|
|
89
|
+
...helperProps,
|
|
90
|
+
className: classes["textarea-helper-text"]
|
|
91
|
+
}}
|
|
92
|
+
error={error}
|
|
93
|
+
floatingLabelActive={floatingLabelActive}
|
|
94
|
+
errorId={errorId}
|
|
95
|
+
>
|
|
96
|
+
<Textarea
|
|
97
|
+
{...textareaProps}
|
|
98
|
+
error={error}
|
|
99
|
+
aria-labelledby={label && labelId}
|
|
100
|
+
aria-describedby={error ? errorId : helperId}
|
|
101
|
+
placeholder={placeholder}
|
|
86
102
|
name={name}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
103
|
+
id={name}
|
|
104
|
+
value={value}
|
|
105
|
+
onChange={onChange}
|
|
106
|
+
onFocus={e => {
|
|
107
|
+
onFocus && onFocus(e);
|
|
108
|
+
setHasFocus(true);
|
|
109
|
+
setFloatingLabelActive(true);
|
|
92
110
|
}}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
onMouseEnter={e => {
|
|
120
|
-
onMouseEnter && onMouseEnter(e);
|
|
121
|
-
setHover(true);
|
|
122
|
-
}}
|
|
123
|
-
onMouseLeave={e => {
|
|
124
|
-
onMouseLeave && onMouseLeave(e);
|
|
125
|
-
setHover(false);
|
|
126
|
-
}}
|
|
127
|
-
className={`${classes["textarea"]} ${error ? classes["error"] : ""}`}
|
|
128
|
-
wrapperProps={{
|
|
129
|
-
className: `${wrapperClasses.join(" ")} ${classes["textarea-wrapper"]}`
|
|
130
|
-
}}
|
|
131
|
-
errorProps={{ className: classes["error-icon"] }}
|
|
132
|
-
/>
|
|
133
|
-
</Wrapper>
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
);
|
|
111
|
+
onBlur={e => {
|
|
112
|
+
onBlur && onBlur(e);
|
|
113
|
+
setHasFocus(false);
|
|
114
|
+
e.target.value || e.target.placeholder || textareaProps?.placeholder?.length
|
|
115
|
+
? setFloatingLabelActive(true)
|
|
116
|
+
: setFloatingLabelActive(false);
|
|
117
|
+
}}
|
|
118
|
+
onMouseEnter={e => {
|
|
119
|
+
onMouseEnter && onMouseEnter(e);
|
|
120
|
+
setHover(true);
|
|
121
|
+
}}
|
|
122
|
+
onMouseLeave={e => {
|
|
123
|
+
onMouseLeave && onMouseLeave(e);
|
|
124
|
+
setHover(false);
|
|
125
|
+
}}
|
|
126
|
+
className={`${classes["textarea"]} ${error ? classes["error"] : ""}`}
|
|
127
|
+
wrapperProps={{
|
|
128
|
+
className: `${wrapperClasses.join(" ")} ${classes["textarea-wrapper"]}`
|
|
129
|
+
}}
|
|
130
|
+
errorProps={{ className: classes["error-icon"] }}
|
|
131
|
+
/>
|
|
132
|
+
</Wrapper>
|
|
133
|
+
);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export const TextareaWrapper = React.forwardRef(TextareaWrapperComponent);
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import React, { ComponentPropsWithRef, ReactElement } from "react";
|
|
17
|
+
import React, { ForwardRefRenderFunction, ComponentPropsWithRef, ReactElement } from "react";
|
|
18
18
|
import { FormGroup, Props as FormGroupProps } from "../../FormGroup/FormGroup";
|
|
19
19
|
import { Label, Props as LabelProps } from "../../Label/Label";
|
|
20
20
|
import classes from "./Wrapper.module.scss";
|
|
@@ -45,79 +45,79 @@ export interface WrapperProps extends FormElement {
|
|
|
45
45
|
disabled?: boolean;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
) =>
|
|
74
|
-
|
|
75
|
-
React.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
);
|
|
48
|
+
const WrapperComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
|
|
49
|
+
{
|
|
50
|
+
children,
|
|
51
|
+
className,
|
|
52
|
+
error,
|
|
53
|
+
errorMessage,
|
|
54
|
+
errorId,
|
|
55
|
+
errorMessageIcon,
|
|
56
|
+
errorMessageIconPosition,
|
|
57
|
+
helperText,
|
|
58
|
+
helperId,
|
|
59
|
+
floatingLabel = true,
|
|
60
|
+
floatingLabelActive,
|
|
61
|
+
required,
|
|
62
|
+
helperProps,
|
|
63
|
+
helperIndent,
|
|
64
|
+
labelProps,
|
|
65
|
+
label,
|
|
66
|
+
disabled,
|
|
67
|
+
name,
|
|
68
|
+
innerClassName,
|
|
69
|
+
...rest
|
|
70
|
+
}: Props,
|
|
71
|
+
ref
|
|
72
|
+
) => {
|
|
73
|
+
const renderChildren = () =>
|
|
74
|
+
React.Children.map(children, child =>
|
|
75
|
+
React.cloneElement(child, {
|
|
76
|
+
disabled
|
|
77
|
+
})
|
|
78
|
+
);
|
|
80
79
|
|
|
81
|
-
|
|
80
|
+
const labelClasses = [];
|
|
82
81
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
82
|
+
floatingLabel && labelClasses.push(classes["floating-label"]);
|
|
83
|
+
floatingLabel && floatingLabelActive && labelClasses.push(classes["floating-label-active"]);
|
|
84
|
+
labelProps?.className && labelClasses.push(labelProps.className);
|
|
85
|
+
required && labelClasses.push(classes["required"]);
|
|
86
|
+
error && labelClasses.push(classes["error"]);
|
|
87
|
+
disabled && labelClasses.push(classes["disabled"]);
|
|
89
88
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
89
|
+
return (
|
|
90
|
+
<div {...rest} ref={ref} className={`${classes.wrapper} ${className ?? ""}`}>
|
|
91
|
+
<FormGroup
|
|
92
|
+
error={error}
|
|
93
|
+
errorMessage={errorMessage}
|
|
94
|
+
errorId={errorId}
|
|
95
|
+
errorMessageIcon={errorMessageIcon}
|
|
96
|
+
errorMessageIconPosition={errorMessageIconPosition}
|
|
97
|
+
helperText={helperText}
|
|
98
|
+
helperId={helperId}
|
|
99
|
+
helperProps={helperProps}
|
|
100
|
+
helperIndent={helperIndent}
|
|
101
|
+
>
|
|
102
|
+
<div
|
|
103
|
+
className={`${floatingLabel ? classes["floating-wrapper"] : ""} ${
|
|
104
|
+
innerClassName ? innerClassName : ""
|
|
105
|
+
}`}
|
|
102
106
|
>
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
</div>
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
);
|
|
107
|
+
{label && (
|
|
108
|
+
<Label
|
|
109
|
+
{...labelProps}
|
|
110
|
+
className={`${classes.label} ${labelClasses.join(" ")}`}
|
|
111
|
+
htmlFor={name}
|
|
112
|
+
>
|
|
113
|
+
{label}
|
|
114
|
+
</Label>
|
|
115
|
+
)}
|
|
116
|
+
{renderChildren()}
|
|
117
|
+
</div>
|
|
118
|
+
</FormGroup>
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export const Wrapper = React.forwardRef(WrapperComponent);
|
package/src/Icon/Icon.tsx
CHANGED
|
@@ -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 "./Icon.module.scss";
|
|
19
19
|
|
|
20
20
|
export enum Icons {
|
|
@@ -93,19 +93,22 @@ export interface Props extends ComponentPropsWithRef<"div"> {
|
|
|
93
93
|
tag?: Tag;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
const IconComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
|
|
97
|
+
{ icon, color, className, style, size, tag = "span", ...rest }: Props,
|
|
98
|
+
ref
|
|
99
|
+
) => {
|
|
100
|
+
const Component = tag;
|
|
99
101
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
102
|
+
return (
|
|
103
|
+
<Component
|
|
104
|
+
{...rest}
|
|
105
|
+
ref={ref}
|
|
106
|
+
style={{ color: color, ...style, fontSize: size }}
|
|
107
|
+
data-icon
|
|
108
|
+
aria-hidden="true"
|
|
109
|
+
className={`${classes["icon"]} ${classes["icon-" + icon]} ${className ? className : ""}`}
|
|
110
|
+
/>
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export const Icon = React.forwardRef(IconComponent);
|
package/src/Link/Link.tsx
CHANGED
|
@@ -14,7 +14,12 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import React, {
|
|
17
|
+
import React, {
|
|
18
|
+
ForwardRefRenderFunction,
|
|
19
|
+
ComponentPropsWithRef,
|
|
20
|
+
ForwardRefExoticComponent,
|
|
21
|
+
ReactNode
|
|
22
|
+
} from "react";
|
|
18
23
|
import classes from "./Link.module.scss";
|
|
19
24
|
|
|
20
25
|
export type AnchorType = "external" | "internal" | "download";
|
|
@@ -30,70 +35,70 @@ export interface Props extends ComponentPropsWithRef<"a"> {
|
|
|
30
35
|
component?: ForwardRefExoticComponent<any>;
|
|
31
36
|
}
|
|
32
37
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
) => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (type === "external") {
|
|
55
|
-
return "_blank";
|
|
56
|
-
}
|
|
38
|
+
const LinkComponent: ForwardRefRenderFunction<HTMLAnchorElement, Props> = (
|
|
39
|
+
{
|
|
40
|
+
children,
|
|
41
|
+
className,
|
|
42
|
+
disabled = false,
|
|
43
|
+
to,
|
|
44
|
+
color = "primary",
|
|
45
|
+
type = "internal",
|
|
46
|
+
display = "link",
|
|
47
|
+
buttonVariant = "fill",
|
|
48
|
+
component,
|
|
49
|
+
...rest
|
|
50
|
+
}: Props,
|
|
51
|
+
ref
|
|
52
|
+
) => {
|
|
53
|
+
const determineTarget = () => {
|
|
54
|
+
if (rest.target) {
|
|
55
|
+
return rest.target;
|
|
56
|
+
}
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
if (type === "external") {
|
|
59
|
+
return "_blank";
|
|
60
|
+
}
|
|
60
61
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
display === "button" && classNames.push(classes["button"], classes[buttonVariant]);
|
|
64
|
-
disabled && classNames.push(classes["disabled"]);
|
|
65
|
-
className && classNames.push(className);
|
|
62
|
+
return "";
|
|
63
|
+
};
|
|
66
64
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
className: classNames.join(" "),
|
|
73
|
-
"aria-disabled": disabled,
|
|
74
|
-
style: {
|
|
75
|
-
...rest.style
|
|
76
|
-
},
|
|
77
|
-
children: children
|
|
78
|
-
});
|
|
79
|
-
}
|
|
65
|
+
const classNames = [classes[color]];
|
|
66
|
+
display === "link" && classNames.push(classes["link"]);
|
|
67
|
+
display === "button" && classNames.push(classes["button"], classes[buttonVariant]);
|
|
68
|
+
disabled && classNames.push(classes["disabled"]);
|
|
69
|
+
className && classNames.push(className);
|
|
80
70
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}}
|
|
94
|
-
>
|
|
95
|
-
{children}
|
|
96
|
-
</a>
|
|
97
|
-
);
|
|
71
|
+
if (component) {
|
|
72
|
+
return React.createElement(component, {
|
|
73
|
+
...rest,
|
|
74
|
+
ref: ref,
|
|
75
|
+
to: to,
|
|
76
|
+
className: classNames.join(" "),
|
|
77
|
+
"aria-disabled": disabled,
|
|
78
|
+
style: {
|
|
79
|
+
...rest.style
|
|
80
|
+
},
|
|
81
|
+
children: children
|
|
82
|
+
});
|
|
98
83
|
}
|
|
99
|
-
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<a
|
|
87
|
+
{...rest}
|
|
88
|
+
ref={ref}
|
|
89
|
+
download={type === "download"}
|
|
90
|
+
rel={type === "external" ? "noopener noreferer" : undefined}
|
|
91
|
+
href={!disabled ? to : undefined}
|
|
92
|
+
className={classNames.join(" ")}
|
|
93
|
+
aria-disabled={disabled}
|
|
94
|
+
target={determineTarget()}
|
|
95
|
+
style={{
|
|
96
|
+
...rest.style
|
|
97
|
+
}}
|
|
98
|
+
>
|
|
99
|
+
{children}
|
|
100
|
+
</a>
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export const Link = React.forwardRef(LinkComponent);
|