@onewelcome/react-lib-components 0.1.0-alpha → 0.1.3-alpha
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 +16 -1
- package/dist/Breadcrumbs/Breadcrumbs.d.ts +3 -3
- package/dist/Button/BaseButton.d.ts +3 -4
- package/dist/Button/Button.d.ts +3 -4
- package/dist/Button/IconButton.d.ts +4 -5
- package/dist/ContextMenu/ContextMenu.d.ts +3 -3
- package/dist/Form/Checkbox/Checkbox.d.ts +5 -5
- package/dist/Form/Fieldset/Fieldset.d.ts +9 -7
- package/dist/Form/FormControl/FormControl.d.ts +6 -5
- package/dist/Form/FormGroup/FormGroup.d.ts +4 -4
- package/dist/Form/FormHelperText/FormHelperText.d.ts +4 -5
- package/dist/Form/FormSelectorWrapper/FormSelectorWrapper.d.ts +8 -12
- package/dist/Form/Input/Input.d.ts +7 -6
- package/dist/Form/Label/Label.d.ts +4 -5
- package/dist/Form/Radio/Radio.d.ts +5 -5
- package/dist/Form/Select/Option.d.ts +3 -4
- package/dist/Form/Select/Select.d.ts +4 -4
- package/dist/Form/Textarea/Textarea.d.ts +9 -5
- package/dist/Form/Toggle/Toggle.d.ts +3 -3
- package/dist/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.d.ts +4 -3
- package/dist/Form/Wrapper/InputWrapper/InputWrapper.d.ts +5 -5
- package/dist/Form/Wrapper/RadioWrapper/RadioWrapper.d.ts +4 -4
- package/dist/Form/Wrapper/SelectWrapper/SelectWrapper.d.ts +8 -4
- package/dist/Form/Wrapper/TextareaWrapper/TextareaWrapper.d.ts +3 -3
- package/dist/Form/Wrapper/Wrapper/Wrapper.d.ts +6 -6
- package/dist/Form/form.interfaces.d.ts +4 -3
- package/dist/Icon/Icon.d.ts +4 -4
- package/dist/Link/Link.d.ts +3 -5
- package/dist/Notifications/BaseModal/BaseModal.d.ts +17 -0
- package/dist/Notifications/BaseModal/BaseModalActions/BaseModalActions.d.ts +5 -0
- package/dist/Notifications/BaseModal/BaseModalContent/BaseModalContent.d.ts +8 -0
- package/dist/{BaseModal → Notifications/BaseModal}/BaseModalContext.d.ts +0 -0
- package/dist/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.d.ts +8 -0
- package/dist/Notifications/Dialog/Dialog.d.ts +19 -0
- package/dist/Notifications/Dialog/DialogActions/DialogActions.d.ts +6 -0
- package/dist/Notifications/Dialog/DialogTitle/DialogTitle.d.ts +6 -0
- package/dist/Notifications/DiscardChangesModal/DiscardChangesDialog/DiscardChangesDialog.d.ts +13 -0
- package/dist/Notifications/DiscardChangesModal/DiscardChangesModal.d.ts +13 -0
- package/dist/{Modal → Notifications/Modal}/Modal.d.ts +0 -0
- package/dist/{Modal → Notifications/Modal}/ModalActions/ModalActions.d.ts +0 -0
- package/dist/{Modal → Notifications/Modal}/ModalContent/ModalContent.d.ts +0 -0
- package/dist/{Modal → Notifications/Modal}/ModalHeader/ModalHeader.d.ts +0 -0
- package/dist/{Snackbar → Notifications/Snackbar}/SnackbarContainer/SnackbarContainer.d.ts +0 -0
- package/dist/{Snackbar → Notifications/Snackbar}/SnackbarItem/SnackbarItem.d.ts +0 -0
- package/dist/{Snackbar → Notifications/Snackbar}/SnackbarProvider/SnackbarProvider.d.ts +1 -1
- package/dist/{Snackbar → Notifications/Snackbar}/SnackbarProvider/SnackbarStateProvider.d.ts +0 -0
- package/dist/{Snackbar → Notifications/Snackbar}/interfaces.d.ts +0 -0
- package/dist/{Snackbar → Notifications/Snackbar}/useSnackbar.d.ts +0 -0
- package/dist/Pagination/Pagination.d.ts +19 -0
- package/dist/Popover/Popover.d.ts +3 -3
- package/dist/Tabs/Tab.d.ts +11 -0
- package/dist/Tabs/TabButton.d.ts +10 -0
- package/dist/Tabs/TabPanel.d.ts +8 -0
- package/dist/Tabs/Tabs.d.ts +9 -0
- package/dist/TextEllipsis/TextEllipsis.d.ts +6 -0
- package/dist/Tiles/Tile.d.ts +6 -7
- package/dist/Tiles/Tiles.d.ts +3 -3
- package/dist/Tooltip/Tooltip.d.ts +3 -3
- package/dist/Typography/Typography.d.ts +6 -4
- package/dist/Wizard/BaseWizardSteps/BaseWizardSteps.d.ts +3 -3
- package/dist/Wizard/WizardSteps/WizardSteps.d.ts +3 -3
- package/dist/_BaseStyling_/BaseStyling.d.ts +9 -0
- package/dist/hooks/useRepeater.d.ts +10 -0
- package/dist/hooks/useSpacing.d.ts +2 -2
- package/dist/hooks/useWrapper.d.ts +1 -1
- package/dist/index.d.ts +12 -7
- package/dist/interfaces.d.ts +2 -11
- package/dist/react-lib-components.cjs.development.js +1861 -1287
- 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 +1858 -1289
- package/dist/react-lib-components.esm.js.map +1 -1
- package/dist/util/helper.d.ts +6 -1
- package/package.json +30 -24
- package/src/Breadcrumbs/Breadcrumbs.tsx +39 -37
- package/src/Button/BaseButton.test.tsx +65 -19
- package/src/Button/BaseButton.tsx +2 -3
- package/src/Button/Button.test.tsx +63 -17
- package/src/Button/Button.tsx +15 -4
- package/src/Button/IconButton.test.tsx +57 -22
- package/src/Button/IconButton.tsx +21 -12
- package/src/ContextMenu/ContextMenu.test.tsx +27 -1
- package/src/ContextMenu/ContextMenu.tsx +70 -65
- package/src/Form/Checkbox/Checkbox.module.scss +4 -0
- package/src/Form/Checkbox/Checkbox.test.tsx +28 -2
- package/src/Form/Checkbox/Checkbox.tsx +132 -117
- package/src/Form/Fieldset/Fieldset.module.scss +11 -1
- package/src/Form/Fieldset/Fieldset.test.tsx +30 -4
- package/src/Form/Fieldset/Fieldset.tsx +101 -43
- package/src/Form/FormControl/FormControl.test.tsx +27 -1
- package/src/Form/FormControl/FormControl.tsx +37 -37
- package/src/Form/FormGroup/FormGroup.test.tsx +27 -1
- package/src/Form/FormGroup/FormGroup.tsx +64 -58
- package/src/Form/FormHelperText/FormHelperText.test.tsx +27 -1
- package/src/Form/FormHelperText/FormHelperText.tsx +20 -16
- package/src/Form/FormSelectorWrapper/FormSelectorWrapper.test.tsx +78 -0
- package/src/Form/FormSelectorWrapper/FormSelectorWrapper.tsx +61 -55
- package/src/Form/Input/Input.module.scss +34 -15
- package/src/Form/Input/Input.test.tsx +27 -1
- package/src/Form/Input/Input.tsx +88 -47
- package/src/Form/Label/Label.test.tsx +27 -1
- package/src/Form/Label/Label.tsx +18 -14
- package/src/Form/Radio/Radio.module.scss +4 -0
- package/src/Form/Radio/Radio.test.tsx +28 -2
- package/src/Form/Radio/Radio.tsx +98 -80
- package/src/Form/Select/Option.test.tsx +27 -1
- package/src/Form/Select/Option.tsx +49 -42
- package/src/Form/Select/Select.module.scss +5 -1
- package/src/Form/Select/Select.test.tsx +224 -30
- package/src/Form/Select/Select.tsx +248 -182
- package/src/Form/Textarea/Textarea.module.scss +2 -1
- package/src/Form/Textarea/Textarea.test.tsx +28 -2
- package/src/Form/Textarea/Textarea.tsx +44 -29
- package/src/Form/Toggle/Toggle.module.scss +9 -0
- package/src/Form/Toggle/Toggle.test.tsx +27 -1
- package/src/Form/Toggle/Toggle.tsx +25 -12
- package/src/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.test.tsx +28 -2
- package/src/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.tsx +45 -48
- package/src/Form/Wrapper/InputWrapper/InputWrapper.module.scss +17 -1
- package/src/Form/Wrapper/InputWrapper/InputWrapper.test.tsx +89 -1
- package/src/Form/Wrapper/InputWrapper/InputWrapper.tsx +134 -74
- package/src/Form/Wrapper/RadioWrapper/RadioWrapper.test.tsx +1 -1
- package/src/Form/Wrapper/RadioWrapper/RadioWrapper.tsx +64 -59
- package/src/Form/Wrapper/SelectWrapper/SelectWrapper.module.scss +1 -1
- package/src/Form/Wrapper/SelectWrapper/SelectWrapper.test.tsx +43 -1
- package/src/Form/Wrapper/SelectWrapper/SelectWrapper.tsx +55 -44
- package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.module.scss +5 -7
- package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.test.tsx +43 -1
- package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.tsx +100 -85
- package/src/Form/Wrapper/Wrapper/Wrapper.module.scss +1 -1
- package/src/Form/Wrapper/Wrapper/Wrapper.test.tsx +27 -1
- package/src/Form/Wrapper/Wrapper/Wrapper.tsx +76 -71
- package/src/Form/form.interfaces.ts +4 -3
- package/src/Icon/Icon.module.scss +4 -0
- package/src/Icon/Icon.test.tsx +30 -2
- package/src/Icon/Icon.tsx +5 -5
- package/src/Link/Link.test.tsx +27 -1
- package/src/Link/Link.tsx +4 -6
- package/src/{BaseModal → Notifications/BaseModal}/BaseModal.module.scss +0 -0
- package/src/{BaseModal → Notifications/BaseModal}/BaseModal.test.tsx +35 -16
- package/src/Notifications/BaseModal/BaseModal.tsx +105 -0
- package/src/{BaseModal → Notifications/BaseModal}/BaseModalActions/BaseModalActions.module.scss +0 -0
- package/src/Notifications/BaseModal/BaseModalActions/BaseModalActions.test.tsx +42 -0
- package/src/Notifications/BaseModal/BaseModalActions/BaseModalActions.tsx +16 -0
- package/src/{BaseModal → Notifications/BaseModal}/BaseModalContent/BaseModalContent.module.scss +0 -0
- package/src/{BaseModal → Notifications/BaseModal}/BaseModalContent/BaseModalContent.test.tsx +27 -1
- package/src/Notifications/BaseModal/BaseModalContent/BaseModalContent.tsx +36 -0
- package/src/{BaseModal → Notifications/BaseModal}/BaseModalContext.ts +0 -0
- package/src/{BaseModal → Notifications/BaseModal}/BaseModalHeader/BaseModalHeader.module.scss +0 -0
- package/src/{BaseModal → Notifications/BaseModal}/BaseModalHeader/BaseModalHeader.test.tsx +29 -1
- package/src/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.tsx +30 -0
- package/src/{Dialog → Notifications/Dialog}/Dialog.module.scss +0 -0
- package/src/{Dialog → Notifications/Dialog}/Dialog.test.tsx +52 -17
- package/src/Notifications/Dialog/Dialog.tsx +113 -0
- package/src/{Dialog → Notifications/Dialog}/DialogActions/DialogActions.module.scss +0 -0
- package/src/Notifications/Dialog/DialogActions/DialogActions.test.tsx +51 -0
- package/src/Notifications/Dialog/DialogActions/DialogActions.tsx +24 -0
- package/src/{Dialog → Notifications/Dialog}/DialogTitle/DialogTitle.module.scss +0 -0
- package/src/Notifications/Dialog/DialogTitle/DialogTitle.test.tsx +44 -0
- package/src/Notifications/Dialog/DialogTitle/DialogTitle.tsx +20 -0
- package/src/Notifications/DiscardChangesModal/DiscardChangesDialog/DiscardChangesDialog.test.tsx +95 -0
- package/src/Notifications/DiscardChangesModal/DiscardChangesDialog/DiscardChangesDialog.tsx +55 -0
- package/src/Notifications/DiscardChangesModal/DiscardChangesModal.test.tsx +162 -0
- package/src/Notifications/DiscardChangesModal/DiscardChangesModal.tsx +61 -0
- package/src/{Modal → Notifications/Modal}/Modal.test.tsx +0 -0
- package/src/{Modal → Notifications/Modal}/Modal.tsx +0 -0
- package/src/{Modal → Notifications/Modal}/ModalActions/ModalActions.tsx +0 -0
- package/src/{Modal → Notifications/Modal}/ModalContent/ModalContent.tsx +0 -0
- package/src/{Modal → Notifications/Modal}/ModalHeader/ModalHeader.tsx +0 -0
- package/src/{Snackbar → Notifications/Snackbar}/SnackbarContainer/SnackbarContainer.module.scss +0 -0
- package/src/{Snackbar → Notifications/Snackbar}/SnackbarContainer/SnackbarContainer.test.tsx +0 -0
- package/src/{Snackbar → Notifications/Snackbar}/SnackbarContainer/SnackbarContainer.tsx +0 -0
- package/src/{Snackbar → Notifications/Snackbar}/SnackbarItem/SnackbarItem.module.scss +1 -1
- package/src/{Snackbar → Notifications/Snackbar}/SnackbarItem/SnackbarItem.test.tsx +0 -0
- package/src/{Snackbar → Notifications/Snackbar}/SnackbarItem/SnackbarItem.tsx +6 -7
- package/src/{Snackbar → Notifications/Snackbar}/SnackbarProvider/SnackbarProvider.test.tsx +0 -0
- package/src/{Snackbar → Notifications/Snackbar}/SnackbarProvider/SnackbarProvider.tsx +2 -2
- package/src/{Snackbar → Notifications/Snackbar}/SnackbarProvider/SnackbarStateProvider.tsx +0 -0
- package/src/{Snackbar → Notifications/Snackbar}/interfaces.ts +0 -0
- package/src/{Snackbar → Notifications/Snackbar}/useSnackbar.ts +0 -0
- package/src/Pagination/Pagination.module.scss +120 -0
- package/src/Pagination/Pagination.test.tsx +176 -0
- package/src/Pagination/Pagination.tsx +205 -0
- package/src/Popover/Popover.test.tsx +3 -3
- package/src/Popover/Popover.tsx +3 -3
- package/src/Tabs/Tab.test.tsx +71 -0
- package/src/Tabs/Tab.tsx +17 -0
- package/src/Tabs/TabButton.module.scss +36 -0
- package/src/Tabs/TabButton.test.tsx +77 -0
- package/src/Tabs/TabButton.tsx +58 -0
- package/src/Tabs/TabPanel.module.scss +7 -0
- package/src/Tabs/TabPanel.test.tsx +76 -0
- package/src/Tabs/TabPanel.tsx +27 -0
- package/src/Tabs/Tabs.module.scss +41 -0
- package/src/Tabs/Tabs.test.tsx +268 -0
- package/src/Tabs/Tabs.tsx +149 -0
- package/src/TextEllipsis/TextEllipsis.module.scss +18 -0
- package/src/TextEllipsis/TextEllipsis.test.tsx +80 -0
- package/src/TextEllipsis/TextEllipsis.tsx +55 -0
- package/src/Tiles/Tile.module.scss +1 -1
- package/src/Tiles/Tile.test.tsx +48 -12
- package/src/Tiles/Tile.tsx +68 -34
- package/src/Tiles/Tiles.test.tsx +38 -10
- package/src/Tiles/Tiles.tsx +42 -39
- package/src/Tooltip/Tooltip.test.tsx +27 -1
- package/src/Tooltip/Tooltip.tsx +104 -92
- package/src/Typography/Typography.test.tsx +27 -1
- package/src/Typography/Typography.tsx +66 -68
- package/src/Wizard/BaseWizardSteps/BaseWizardSteps.tsx +67 -62
- package/src/Wizard/Wizard.tsx +2 -2
- package/src/Wizard/WizardActions/WizardActions.tsx +3 -3
- package/src/Wizard/WizardSteps/WizardSteps.tsx +24 -21
- package/src/_BaseStyling_/BaseStyling.tsx +19 -1
- package/src/hooks/usePosition.test.tsx +3 -3
- package/src/hooks/useRepeater.test.tsx +139 -0
- package/src/hooks/useRepeater.ts +34 -0
- package/src/hooks/useSpacing.ts +1 -1
- package/src/hooks/useWrapper.ts +7 -2
- package/src/index.ts +20 -8
- package/src/interfaces.ts +2 -12
- package/src/util/helper.test.tsx +38 -1
- package/src/util/helper.tsx +21 -0
- package/dist/BaseModal/BaseModal.d.ts +0 -16
- package/dist/BaseModal/BaseModalActions/BaseModalActions.d.ts +0 -5
- package/dist/BaseModal/BaseModalContent/BaseModalContent.d.ts +0 -8
- package/dist/BaseModal/BaseModalHeader/BaseModalHeader.d.ts +0 -8
- package/dist/Dialog/Dialog.d.ts +0 -18
- package/dist/Dialog/DialogActions/DialogActions.d.ts +0 -6
- package/dist/Dialog/DialogTitle/DialogTitle.d.ts +0 -6
- package/src/BaseModal/BaseModal.tsx +0 -113
- package/src/BaseModal/BaseModalActions/BaseModalActions.test.tsx +0 -17
- package/src/BaseModal/BaseModalActions/BaseModalActions.tsx +0 -14
- package/src/BaseModal/BaseModalContent/BaseModalContent.tsx +0 -35
- package/src/BaseModal/BaseModalHeader/BaseModalHeader.tsx +0 -28
- package/src/Dialog/Dialog.tsx +0 -96
- package/src/Dialog/DialogActions/DialogActions.test.tsx +0 -25
- package/src/Dialog/DialogActions/DialogActions.tsx +0 -21
- package/src/Dialog/DialogTitle/DialogTitle.test.tsx +0 -18
- package/src/Dialog/DialogTitle/DialogTitle.tsx +0 -18
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import React, { ReactElement } from 'react';
|
|
1
|
+
import React, { ComponentPropsWithRef, ReactElement } from 'react';
|
|
2
2
|
import { FormGroup, Props as FormGroupProps } from '../../FormGroup/FormGroup';
|
|
3
3
|
import { Label, Props as LabelProps } from '../../Label/Label';
|
|
4
4
|
import classes from './Wrapper.module.scss';
|
|
5
5
|
import { Props as HelperProps } from '../../FormHelperText/FormHelperText';
|
|
6
|
-
import {
|
|
6
|
+
import { FormElement } from '../../form.interfaces';
|
|
7
7
|
|
|
8
|
-
export interface Props extends
|
|
8
|
+
export interface Props extends ComponentPropsWithRef<'div'>, FormGroupProps {
|
|
9
9
|
children: ReactElement | ReactElement[];
|
|
10
10
|
floatingLabelActive?: boolean;
|
|
11
11
|
floatingLabel?: boolean;
|
|
@@ -19,83 +19,88 @@ export interface Props extends Omit<FormGroupProps, 'children'> {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
/** For components that extend this component we create an interface (InputWrapper, SelectWrapper, etc.) */
|
|
22
|
-
export interface WrapperProps extends
|
|
22
|
+
export interface WrapperProps extends FormElement {
|
|
23
23
|
errorMessage?: string;
|
|
24
|
-
error: boolean;
|
|
25
24
|
helperText?: string;
|
|
26
25
|
helperProps?: HelperProps;
|
|
27
26
|
label?: string;
|
|
28
27
|
name: string;
|
|
29
28
|
required?: boolean;
|
|
29
|
+
disabled?: boolean;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export const Wrapper = (
|
|
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
|
-
|
|
32
|
+
export const Wrapper = React.forwardRef<HTMLDivElement, Props>(
|
|
33
|
+
(
|
|
34
|
+
{
|
|
35
|
+
children,
|
|
36
|
+
className,
|
|
37
|
+
error,
|
|
38
|
+
errorMessage,
|
|
39
|
+
errorId,
|
|
40
|
+
errorMessageIcon,
|
|
41
|
+
errorMessageIconPosition,
|
|
42
|
+
helperText,
|
|
43
|
+
helperId,
|
|
44
|
+
floatingLabel = true,
|
|
45
|
+
floatingLabelActive,
|
|
46
|
+
required,
|
|
47
|
+
helperProps,
|
|
48
|
+
helperIndent,
|
|
49
|
+
labelProps,
|
|
50
|
+
label,
|
|
51
|
+
disabled,
|
|
52
|
+
name,
|
|
53
|
+
innerClassName,
|
|
54
|
+
...rest
|
|
55
|
+
}: Props,
|
|
56
|
+
ref
|
|
57
|
+
) => {
|
|
58
|
+
const renderChildren = () =>
|
|
59
|
+
React.Children.map(children, (child) =>
|
|
60
|
+
React.cloneElement(child, {
|
|
61
|
+
disabled,
|
|
62
|
+
})
|
|
63
|
+
);
|
|
60
64
|
|
|
61
|
-
|
|
65
|
+
const labelClasses = [];
|
|
62
66
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
floatingLabel && labelClasses.push(classes['floating-label']);
|
|
68
|
+
floatingLabel && floatingLabelActive && labelClasses.push(classes['floating-label-active']);
|
|
69
|
+
labelProps?.className && labelClasses.push(labelProps.className);
|
|
70
|
+
required && labelClasses.push(classes['required']);
|
|
71
|
+
error && labelClasses.push(classes['error']);
|
|
68
72
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
>
|
|
82
|
-
<div
|
|
83
|
-
className={`${floatingLabel ? classes['floating-wrapper'] : ''} ${
|
|
84
|
-
innerClassName ? innerClassName : ''
|
|
85
|
-
}`}
|
|
73
|
+
return (
|
|
74
|
+
<div {...rest} ref={ref} className={`${classes.wrapper} ${className ? className : ''}`}>
|
|
75
|
+
<FormGroup
|
|
76
|
+
error={error}
|
|
77
|
+
errorMessage={errorMessage}
|
|
78
|
+
errorId={errorId}
|
|
79
|
+
errorMessageIcon={errorMessageIcon}
|
|
80
|
+
errorMessageIconPosition={errorMessageIconPosition}
|
|
81
|
+
helperText={helperText}
|
|
82
|
+
helperId={helperId}
|
|
83
|
+
helperProps={helperProps}
|
|
84
|
+
helperIndent={helperIndent}
|
|
86
85
|
>
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
86
|
+
<div
|
|
87
|
+
className={`${floatingLabel ? classes['floating-wrapper'] : ''} ${
|
|
88
|
+
innerClassName ? innerClassName : ''
|
|
89
|
+
}`}
|
|
90
|
+
>
|
|
91
|
+
{label && (
|
|
92
|
+
<Label
|
|
93
|
+
{...labelProps}
|
|
94
|
+
className={`${classes.label} ${labelClasses.join(' ')}`}
|
|
95
|
+
htmlFor={name}
|
|
96
|
+
>
|
|
97
|
+
{label}
|
|
98
|
+
</Label>
|
|
99
|
+
)}
|
|
100
|
+
{renderChildren()}
|
|
101
|
+
</div>
|
|
102
|
+
</FormGroup>
|
|
103
|
+
</div>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DataAttributeKey } from '../interfaces';
|
|
2
2
|
|
|
3
3
|
/** Radios */
|
|
4
|
-
export interface FormSelector
|
|
4
|
+
export interface FormSelector extends FormElement {
|
|
5
5
|
helperText?: string;
|
|
6
6
|
errorMessage?: string;
|
|
7
7
|
parentHelperId?: string;
|
|
@@ -9,6 +9,7 @@ export interface FormSelector<T> extends FormElement<T> {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
/** Default form elements */
|
|
12
|
-
export interface FormElement
|
|
12
|
+
export interface FormElement {
|
|
13
13
|
error?: boolean;
|
|
14
|
+
[dataAttribute: DataAttributeKey]: any;
|
|
14
15
|
}
|
package/src/Icon/Icon.test.tsx
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
2
|
import { Icon, Props, Icons } from './Icon';
|
|
3
3
|
import { render } from '@testing-library/react';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
interface PartialProps extends Omit<Props, 'ref'> {}
|
|
6
|
+
|
|
7
|
+
const initParams: PartialProps = {
|
|
6
8
|
icon: Icons.Calendar,
|
|
7
9
|
color: 'rgb(26, 153, 60)',
|
|
8
10
|
};
|
|
@@ -37,3 +39,29 @@ describe('Icon', () => {
|
|
|
37
39
|
expect(icon.tagName.toLowerCase()).toBe(tag);
|
|
38
40
|
});
|
|
39
41
|
});
|
|
42
|
+
|
|
43
|
+
describe('ref should work', () => {
|
|
44
|
+
it('should give back the proper data prop, this also checks if the component propagates ...rest properly', () => {
|
|
45
|
+
const ExampleComponent = ({
|
|
46
|
+
propagateRef,
|
|
47
|
+
}: {
|
|
48
|
+
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
49
|
+
}) => {
|
|
50
|
+
const ref = useRef(null);
|
|
51
|
+
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (ref.current) {
|
|
54
|
+
propagateRef && propagateRef(ref);
|
|
55
|
+
}
|
|
56
|
+
}, [ref]);
|
|
57
|
+
|
|
58
|
+
return <Icon {...initParams} data-ref="testing" ref={ref} />;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
62
|
+
expect(ref.current).toHaveAttribute('data-ref', 'testing');
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
render(<ExampleComponent propagateRef={refCheck} />);
|
|
66
|
+
});
|
|
67
|
+
});
|
package/src/Icon/Icon.tsx
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ComponentPropsWithRef } from 'react';
|
|
2
2
|
import classes from './Icon.module.scss';
|
|
3
|
-
import { HTMLAttributes } from '../interfaces';
|
|
4
3
|
|
|
5
4
|
export enum Icons {
|
|
6
5
|
Bell = 'bell',
|
|
@@ -26,6 +25,7 @@ export enum Icons {
|
|
|
26
25
|
Ellipsis = 'ellipsis',
|
|
27
26
|
EllipsisAlt = 'ellipsis-alt',
|
|
28
27
|
Equal = 'equal',
|
|
28
|
+
Error = 'error-circle',
|
|
29
29
|
Eye = 'eye',
|
|
30
30
|
Filter = 'filter',
|
|
31
31
|
FilterAlt = 'filter-alt',
|
|
@@ -69,21 +69,21 @@ export enum Icons {
|
|
|
69
69
|
|
|
70
70
|
type Tag = 'span' | 'div' | 'i';
|
|
71
71
|
|
|
72
|
-
export interface Props extends
|
|
72
|
+
export interface Props extends ComponentPropsWithRef<'div'> {
|
|
73
73
|
icon: Icons;
|
|
74
74
|
color?: string;
|
|
75
75
|
size?: string;
|
|
76
76
|
tag?: Tag;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
export const Icon = React.forwardRef(
|
|
79
|
+
export const Icon = React.forwardRef<HTMLDivElement, Props>(
|
|
80
80
|
({ icon, color, className, style, size, tag = 'span', ...rest }: Props, ref) => {
|
|
81
81
|
const Component = tag;
|
|
82
82
|
|
|
83
83
|
return (
|
|
84
84
|
<Component
|
|
85
85
|
{...rest}
|
|
86
|
-
ref={ref
|
|
86
|
+
ref={ref}
|
|
87
87
|
style={{ color: color, ...style, fontSize: size }}
|
|
88
88
|
data-icon
|
|
89
89
|
aria-hidden="true"
|
package/src/Link/Link.test.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
2
|
import { Link, Props } from './Link';
|
|
3
3
|
import { render } from '@testing-library/react';
|
|
4
4
|
import { BrowserRouter, Link as RouterLink } from 'react-router-dom';
|
|
@@ -101,6 +101,32 @@ describe('Link should render', () => {
|
|
|
101
101
|
});
|
|
102
102
|
});
|
|
103
103
|
|
|
104
|
+
describe('ref should work', () => {
|
|
105
|
+
it('should give back the proper data prop, this also checks if the component propagates ...rest properly', () => {
|
|
106
|
+
const ExampleComponent = ({
|
|
107
|
+
propagateRef,
|
|
108
|
+
}: {
|
|
109
|
+
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
110
|
+
}) => {
|
|
111
|
+
const ref = useRef(null);
|
|
112
|
+
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
if (ref.current) {
|
|
115
|
+
propagateRef && propagateRef(ref);
|
|
116
|
+
}
|
|
117
|
+
}, [ref]);
|
|
118
|
+
|
|
119
|
+
return <Link {...defaultParams} data-ref="testing" ref={ref} />;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
123
|
+
expect(ref.current).toHaveAttribute('data-ref', 'testing');
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
render(<ExampleComponent propagateRef={refCheck} />);
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
104
130
|
describe('colors', () => {
|
|
105
131
|
it('should be color primary', () => {
|
|
106
132
|
const { link } = createLink((defaultParams) => ({ ...defaultParams, color: 'primary' }));
|
package/src/Link/Link.tsx
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import { HTMLProps } from '../interfaces';
|
|
1
|
+
import React, { ComponentPropsWithRef, ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
3
2
|
import classes from './Link.module.scss';
|
|
4
3
|
import { LinkProps } from './types';
|
|
5
4
|
|
|
6
5
|
type AnchorType = 'external' | 'internal' | 'download';
|
|
7
6
|
|
|
8
|
-
export interface Props extends
|
|
7
|
+
export interface Props extends ComponentPropsWithRef<'a'> {
|
|
9
8
|
children?: string;
|
|
10
9
|
color?: 'primary' | 'secondary' | 'tertiary';
|
|
11
10
|
type?: AnchorType;
|
|
12
11
|
to: string;
|
|
13
12
|
disabled?: boolean;
|
|
14
13
|
component?: ForwardRefExoticComponent<LinkProps & RefAttributes<HTMLAnchorElement>>;
|
|
15
|
-
ref?: Ref<HTMLAnchorElement>;
|
|
16
14
|
}
|
|
17
15
|
|
|
18
|
-
export const Link = React.forwardRef(
|
|
16
|
+
export const Link = React.forwardRef<HTMLAnchorElement, Props>(
|
|
19
17
|
(
|
|
20
18
|
{
|
|
21
19
|
children,
|
|
@@ -27,7 +25,7 @@ export const Link = React.forwardRef(
|
|
|
27
25
|
component,
|
|
28
26
|
...rest
|
|
29
27
|
}: Props,
|
|
30
|
-
ref
|
|
28
|
+
ref
|
|
31
29
|
) => {
|
|
32
30
|
const determineTarget = () => {
|
|
33
31
|
if (rest.target) {
|
|
File without changes
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
2
|
import { BaseModal, Props } from './BaseModal';
|
|
3
|
-
import {
|
|
4
|
-
render,
|
|
5
|
-
getByRole,
|
|
6
|
-
getByText,
|
|
7
|
-
queryByText,
|
|
8
|
-
queryByRole,
|
|
9
|
-
fireEvent,
|
|
10
|
-
} from '@testing-library/react';
|
|
3
|
+
import { render, getByText, queryByText, fireEvent } from '@testing-library/react';
|
|
11
4
|
import userEvent from '@testing-library/user-event';
|
|
12
5
|
|
|
13
6
|
const classNames = ['class11', 'class12'];
|
|
@@ -24,8 +17,8 @@ const initParams: Props = {
|
|
|
24
17
|
|
|
25
18
|
describe('BaseModal', () => {
|
|
26
19
|
it('renders without crashing', () => {
|
|
27
|
-
const {
|
|
28
|
-
const dialog = getByRole(
|
|
20
|
+
const { getByRole } = render(<BaseModal {...initParams} />);
|
|
21
|
+
const dialog = getByRole('dialog');
|
|
29
22
|
expect(dialog).toHaveAttribute('aria-modal', 'true');
|
|
30
23
|
expect(dialog).toHaveAttribute('aria-labelledby', 'modal-label');
|
|
31
24
|
expect(dialog).toHaveAttribute('aria-describedby', 'modal-description');
|
|
@@ -36,17 +29,17 @@ describe('BaseModal', () => {
|
|
|
36
29
|
});
|
|
37
30
|
|
|
38
31
|
it('should render close modal without content', () => {
|
|
39
|
-
const {
|
|
40
|
-
const dialogByRole = queryByRole(
|
|
41
|
-
const dialog =
|
|
32
|
+
const { queryByRole } = render(<BaseModal {...initParams} open={false} />);
|
|
33
|
+
const dialogByRole = queryByRole('dialog');
|
|
34
|
+
const dialog = document.body.children[1] as HTMLElement;
|
|
42
35
|
expect(dialogByRole).toBeNull();
|
|
43
36
|
expect(dialog).toHaveAttribute('aria-hidden', 'true');
|
|
44
37
|
expect(queryByText(dialog, initParams.children as string)).toBeNull();
|
|
45
38
|
});
|
|
46
39
|
|
|
47
40
|
it('should handle clicking on backdrop & ESC key', () => {
|
|
48
|
-
const {
|
|
49
|
-
const modal = getByRole(
|
|
41
|
+
const { getByRole } = render(<BaseModal {...initParams} />);
|
|
42
|
+
const modal = getByRole('dialog');
|
|
50
43
|
const backdrop = modal.querySelector('.backdrop') as HTMLElement;
|
|
51
44
|
expect(initParams.onClose).toHaveBeenCalledTimes(0);
|
|
52
45
|
|
|
@@ -57,3 +50,29 @@ describe('BaseModal', () => {
|
|
|
57
50
|
expect(initParams.onClose).toHaveBeenCalledTimes(2);
|
|
58
51
|
});
|
|
59
52
|
});
|
|
53
|
+
|
|
54
|
+
describe('ref should work', () => {
|
|
55
|
+
it('should give back the proper data prop, this also checks if the component propagates ...rest properly', () => {
|
|
56
|
+
const ExampleComponent = ({
|
|
57
|
+
propagateRef,
|
|
58
|
+
}: {
|
|
59
|
+
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
60
|
+
}) => {
|
|
61
|
+
const ref = useRef(null);
|
|
62
|
+
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (ref.current) {
|
|
65
|
+
propagateRef && propagateRef(ref);
|
|
66
|
+
}
|
|
67
|
+
}, [ref]);
|
|
68
|
+
|
|
69
|
+
return <BaseModal id="test" children="test" open={true} data-ref="testing" ref={ref} />;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
73
|
+
expect(ref.current).toHaveAttribute('data-ref', 'testing');
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
render(<ExampleComponent propagateRef={refCheck} />);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import React, { ComponentPropsWithRef, useEffect } from 'react';
|
|
2
|
+
import { createPortal } from 'react-dom';
|
|
3
|
+
import classes from './BaseModal.module.scss';
|
|
4
|
+
import { labelId, descriptionId } from './BaseModalContext';
|
|
5
|
+
|
|
6
|
+
const SCROLL_PROPERTY_NAME = 'overflow';
|
|
7
|
+
const SCROLL_PROPERTY_VALUE = 'hidden';
|
|
8
|
+
|
|
9
|
+
export interface Props extends ComponentPropsWithRef<'div'> {
|
|
10
|
+
id: string;
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
open: boolean;
|
|
13
|
+
onClose?: (event?: React.MouseEvent<HTMLElement>) => unknown;
|
|
14
|
+
className?: string;
|
|
15
|
+
containerClassName?: string;
|
|
16
|
+
labelledby?: string;
|
|
17
|
+
describedby?: string;
|
|
18
|
+
disableEscapeKeyDown?: boolean;
|
|
19
|
+
disableBackdrop?: boolean;
|
|
20
|
+
zIndex?: number;
|
|
21
|
+
domRoot?: HTMLElement;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const useSetBodyScroll = (open: boolean) => {
|
|
25
|
+
const hideBodyScroll = () => {
|
|
26
|
+
document.body.style[SCROLL_PROPERTY_NAME] = SCROLL_PROPERTY_VALUE;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const showBodyScroll = () => {
|
|
30
|
+
const allModalsClosed =
|
|
31
|
+
document.querySelectorAll('[role=dialog][data-hidden=false]').length === 0;
|
|
32
|
+
if (allModalsClosed) {
|
|
33
|
+
document.body.style.removeProperty(SCROLL_PROPERTY_NAME);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (open) {
|
|
39
|
+
hideBodyScroll();
|
|
40
|
+
} else {
|
|
41
|
+
showBodyScroll();
|
|
42
|
+
}
|
|
43
|
+
}, [open]);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const BaseModal = React.forwardRef<HTMLDivElement, Props>(
|
|
47
|
+
(
|
|
48
|
+
{
|
|
49
|
+
id,
|
|
50
|
+
children,
|
|
51
|
+
open,
|
|
52
|
+
onClose,
|
|
53
|
+
className = '',
|
|
54
|
+
containerClassName = '',
|
|
55
|
+
labelledby,
|
|
56
|
+
describedby,
|
|
57
|
+
disableEscapeKeyDown = false,
|
|
58
|
+
disableBackdrop = false,
|
|
59
|
+
zIndex,
|
|
60
|
+
domRoot = document.body,
|
|
61
|
+
...rest
|
|
62
|
+
}: Props,
|
|
63
|
+
ref
|
|
64
|
+
) => {
|
|
65
|
+
useSetBodyScroll(open);
|
|
66
|
+
|
|
67
|
+
const handleEscKeyPress = (event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
68
|
+
if (!disableEscapeKeyDown && event.key === 'Escape') {
|
|
69
|
+
event.stopPropagation();
|
|
70
|
+
onClose && onClose();
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const handleBackdropClick = () => !disableBackdrop && onClose && onClose();
|
|
75
|
+
|
|
76
|
+
return createPortal(
|
|
77
|
+
<div
|
|
78
|
+
{...rest}
|
|
79
|
+
ref={ref}
|
|
80
|
+
id={id}
|
|
81
|
+
className={`${classes['modal']} ${open && classes['visible']} ${className}`}
|
|
82
|
+
role="dialog"
|
|
83
|
+
aria-modal="true"
|
|
84
|
+
aria-labelledby={labelledby || labelId(id)}
|
|
85
|
+
aria-describedby={describedby || descriptionId(id)}
|
|
86
|
+
aria-hidden={!open}
|
|
87
|
+
tabIndex={-1}
|
|
88
|
+
data-hidden={!open}
|
|
89
|
+
onKeyDown={handleEscKeyPress}
|
|
90
|
+
style={{ zIndex }}
|
|
91
|
+
>
|
|
92
|
+
<div className={classes['backdrop']} onClick={handleBackdropClick}></div>
|
|
93
|
+
{open && (
|
|
94
|
+
<div
|
|
95
|
+
style={{ zIndex: zIndex && zIndex + 1 }}
|
|
96
|
+
className={`${classes['container']} ${containerClassName}`}
|
|
97
|
+
>
|
|
98
|
+
{children}
|
|
99
|
+
</div>
|
|
100
|
+
)}
|
|
101
|
+
</div>,
|
|
102
|
+
domRoot
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
);
|
package/src/{BaseModal → Notifications/BaseModal}/BaseModalActions/BaseModalActions.module.scss
RENAMED
|
File without changes
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import { BaseModalActions } from './BaseModalActions';
|
|
3
|
+
import { render } from '@testing-library/react';
|
|
4
|
+
|
|
5
|
+
describe('BaseModalActions', () => {
|
|
6
|
+
it('renders without crashing', () => {
|
|
7
|
+
const children = 'Content';
|
|
8
|
+
const classNames = ['class1', 'class2'];
|
|
9
|
+
const { container } = render(
|
|
10
|
+
<BaseModalActions className={classNames.join(' ')}>{children}</BaseModalActions>
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
const dialogActionsContainer = container.children[0];
|
|
14
|
+
expect(dialogActionsContainer).toHaveClass('actions', classNames[0], classNames[1]);
|
|
15
|
+
expect(dialogActionsContainer).toHaveTextContent(children);
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
describe('ref should work', () => {
|
|
19
|
+
it('should give back the proper data prop, this also checks if the component propagates ...rest properly', () => {
|
|
20
|
+
const ExampleComponent = ({
|
|
21
|
+
propagateRef,
|
|
22
|
+
}: {
|
|
23
|
+
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
24
|
+
}) => {
|
|
25
|
+
const ref = useRef(null);
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (ref.current) {
|
|
29
|
+
propagateRef && propagateRef(ref);
|
|
30
|
+
}
|
|
31
|
+
}, [ref]);
|
|
32
|
+
|
|
33
|
+
return <BaseModalActions data-ref="testing" ref={ref} />;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
37
|
+
expect(ref.current).toHaveAttribute('data-ref', 'testing');
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
render(<ExampleComponent propagateRef={refCheck} />);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React, { ComponentPropsWithRef } from 'react';
|
|
2
|
+
import classes from './BaseModalActions.module.scss';
|
|
3
|
+
|
|
4
|
+
export interface Props extends ComponentPropsWithRef<'footer'> {
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const BaseModalActions = React.forwardRef<HTMLElement, Props>(
|
|
9
|
+
({ children, className = '', ...rest }: Props, ref) => {
|
|
10
|
+
return (
|
|
11
|
+
<footer {...rest} ref={ref} className={`${classes['actions']} ${className}`}>
|
|
12
|
+
{children}
|
|
13
|
+
</footer>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
);
|
package/src/{BaseModal → Notifications/BaseModal}/BaseModalContent/BaseModalContent.module.scss
RENAMED
|
File without changes
|
package/src/{BaseModal → Notifications/BaseModal}/BaseModalContent/BaseModalContent.test.tsx
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
2
|
import { BaseModalContent, Props } from './BaseModalContent';
|
|
3
3
|
import { render } from '@testing-library/react';
|
|
4
4
|
import { descriptionId } from '../BaseModalContext';
|
|
@@ -20,6 +20,32 @@ describe('BaseModalContent', () => {
|
|
|
20
20
|
expect(dialogContentContainer).toEqual(document.activeElement);
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
+
describe('ref should work', () => {
|
|
24
|
+
it('should give back the proper data prop, this also checks if the component propagates ...rest properly', () => {
|
|
25
|
+
const ExampleComponent = ({
|
|
26
|
+
propagateRef,
|
|
27
|
+
}: {
|
|
28
|
+
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
29
|
+
}) => {
|
|
30
|
+
const ref = useRef(null);
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (ref.current) {
|
|
34
|
+
propagateRef && propagateRef(ref);
|
|
35
|
+
}
|
|
36
|
+
}, [ref]);
|
|
37
|
+
|
|
38
|
+
return <BaseModalContent children="test" data-ref="testing" ref={ref} />;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
42
|
+
expect(ref.current).toHaveAttribute('data-ref', 'testing');
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
render(<ExampleComponent propagateRef={refCheck} />);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
23
49
|
it('should renders not focused div', () => {
|
|
24
50
|
const { container } = render(<BaseModalContent {...initParams} disableAutoFocus />);
|
|
25
51
|
|