@onewelcome/react-lib-components 0.2.0 → 0.2.3
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/Breadcrumbs/Breadcrumbs.d.ts +4 -4
- package/dist/Button/BaseButton.d.ts +4 -4
- package/dist/Button/Button.d.ts +3 -3
- package/dist/Button/IconButton.d.ts +4 -4
- package/dist/ContextMenu/ContextMenu.d.ts +5 -5
- package/dist/ContextMenu/ContextMenuItem.d.ts +2 -2
- package/dist/DataGrid/DataGrid.d.ts +6 -6
- package/dist/DataGrid/DataGridActions/DataGridActions.d.ts +4 -4
- package/dist/DataGrid/DataGridActions/DataGridColumnsToggle.d.ts +3 -3
- package/dist/DataGrid/DataGridBody/DataGridBody.d.ts +3 -3
- package/dist/DataGrid/DataGridBody/DataGridCell.d.ts +2 -2
- package/dist/DataGrid/DataGridBody/DataGridRow.d.ts +3 -3
- package/dist/DataGrid/DataGridHeader/DataGridHeader.d.ts +3 -3
- package/dist/DataGrid/DataGridHeader/DataGridHeaderCell.d.ts +3 -3
- package/dist/DataGrid/datagrid.interfaces.d.ts +1 -1
- package/dist/Form/Checkbox/Checkbox.d.ts +5 -5
- package/dist/Form/Fieldset/Fieldset.d.ts +3 -3
- package/dist/Form/Form.d.ts +1 -1
- package/dist/Form/FormControl/FormControl.d.ts +3 -3
- package/dist/Form/FormGroup/FormGroup.d.ts +5 -5
- package/dist/Form/FormHelperText/FormHelperText.d.ts +3 -3
- package/dist/Form/FormSelectorWrapper/FormSelectorWrapper.d.ts +6 -6
- package/dist/Form/Input/Input.d.ts +5 -5
- package/dist/Form/Label/Label.d.ts +2 -2
- package/dist/Form/Radio/Radio.d.ts +5 -5
- package/dist/Form/Select/Option.d.ts +2 -2
- package/dist/Form/Select/Select.d.ts +5 -5
- package/dist/Form/Textarea/Textarea.d.ts +6 -6
- package/dist/Form/Toggle/Toggle.d.ts +3 -3
- package/dist/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.d.ts +4 -4
- package/dist/Form/Wrapper/InputWrapper/InputWrapper.d.ts +4 -4
- package/dist/Form/Wrapper/RadioWrapper/RadioWrapper.d.ts +4 -4
- package/dist/Form/Wrapper/SelectWrapper/SelectWrapper.d.ts +4 -4
- package/dist/Form/Wrapper/TextareaWrapper/TextareaWrapper.d.ts +4 -4
- package/dist/Form/Wrapper/Wrapper/Wrapper.d.ts +6 -6
- package/dist/Form/form.interfaces.d.ts +1 -1
- package/dist/Icon/Icon.d.ts +3 -3
- package/dist/Link/Link.d.ts +7 -7
- package/dist/Notifications/BaseModal/BaseModal.d.ts +4 -4
- package/dist/Notifications/BaseModal/BaseModalActions/BaseModalActions.d.ts +2 -2
- package/dist/Notifications/BaseModal/BaseModalContent/BaseModalContent.d.ts +2 -2
- package/dist/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.d.ts +2 -2
- package/dist/Notifications/Dialog/Dialog.d.ts +5 -5
- package/dist/Notifications/Dialog/DialogActions/DialogActions.d.ts +3 -3
- package/dist/Notifications/Dialog/DialogTitle/DialogTitle.d.ts +2 -2
- package/dist/Notifications/DiscardChangesModal/DiscardChangesDialog/DiscardChangesDialog.d.ts +3 -3
- package/dist/Notifications/DiscardChangesModal/DiscardChangesModal.d.ts +7 -7
- package/dist/Notifications/Modal/Modal.d.ts +1 -1
- package/dist/Notifications/Modal/ModalActions/ModalActions.d.ts +1 -1
- package/dist/Notifications/Modal/ModalContent/ModalContent.d.ts +1 -1
- package/dist/Notifications/Modal/ModalHeader/ModalHeader.d.ts +1 -1
- package/dist/Notifications/SlideInModal/SlideInModal.d.ts +3 -3
- package/dist/Notifications/Snackbar/SnackbarContainer/SnackbarContainer.d.ts +3 -3
- package/dist/Notifications/Snackbar/SnackbarItem/SnackbarItem.d.ts +2 -2
- package/dist/Notifications/Snackbar/SnackbarProvider/SnackbarProvider.d.ts +3 -3
- package/dist/Notifications/Snackbar/SnackbarProvider/SnackbarStateProvider.d.ts +2 -2
- package/dist/Notifications/Snackbar/interfaces.d.ts +2 -2
- package/dist/Pagination/Pagination.d.ts +3 -3
- package/dist/Popover/Popover.d.ts +3 -3
- package/dist/Skeleton/Skeleton.d.ts +3 -3
- package/dist/StatusIndicator/StatusIndicator.d.ts +5 -5
- package/dist/Tabs/Tab.d.ts +1 -1
- package/dist/Tabs/TabButton.d.ts +2 -2
- package/dist/Tabs/TabPanel.d.ts +2 -2
- package/dist/Tabs/Tabs.d.ts +4 -4
- package/dist/TextEllipsis/TextEllipsis.d.ts +2 -2
- package/dist/Tiles/Tile.d.ts +5 -5
- package/dist/Tiles/Tiles.d.ts +2 -2
- package/dist/Tooltip/Tooltip.d.ts +3 -3
- package/dist/Typography/Typography.d.ts +3 -3
- package/dist/Wizard/BaseWizardSteps/BaseWizardSteps.d.ts +2 -2
- package/dist/Wizard/Wizard.d.ts +3 -3
- package/dist/Wizard/WizardActions/WizardActions.d.ts +2 -2
- package/dist/Wizard/WizardStateProvider.d.ts +2 -2
- package/dist/Wizard/WizardSteps/WizardSteps.d.ts +2 -2
- package/dist/Wizard/wizardStateReducer.d.ts +5 -5
- package/dist/_BaseStyling_/BaseStyling.d.ts +1 -1
- package/dist/hooks/usePosition.d.ts +4 -4
- package/dist/hooks/useRepeater.d.ts +1 -1
- package/dist/hooks/useScroll.d.ts +1 -1
- package/dist/hooks/useSpacing.d.ts +1 -1
- package/dist/hooks/useWrapper.d.ts +1 -1
- package/dist/index.d.ts +55 -55
- package/dist/react-lib-components.cjs.development.js +676 -578
- 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 +676 -578
- package/dist/react-lib-components.esm.js.map +1 -1
- package/package.json +27 -16
- package/src/Breadcrumbs/Breadcrumbs.test.tsx +15 -15
- package/src/Breadcrumbs/Breadcrumbs.tsx +11 -11
- package/src/Button/BaseButton.module.scss +1 -1
- package/src/Button/BaseButton.test.tsx +27 -27
- package/src/Button/BaseButton.tsx +8 -8
- package/src/Button/Button.module.scss +5 -5
- package/src/Button/Button.test.tsx +39 -39
- package/src/Button/Button.tsx +10 -10
- package/src/Button/IconButton.module.scss +5 -5
- package/src/Button/IconButton.test.tsx +29 -29
- package/src/Button/IconButton.tsx +11 -11
- package/src/ContextMenu/ContextMenu.test.tsx +97 -76
- package/src/ContextMenu/ContextMenu.tsx +48 -42
- package/src/ContextMenu/ContextMenuItem.module.scss +1 -1
- package/src/ContextMenu/ContextMenuItem.tsx +7 -5
- package/src/DataGrid/DataGrid.test.tsx +193 -193
- package/src/DataGrid/DataGrid.tsx +26 -26
- package/src/DataGrid/DataGridActions/DataGridActions.test.tsx +63 -63
- package/src/DataGrid/DataGridActions/DataGridActions.tsx +15 -15
- package/src/DataGrid/DataGridActions/DataGridColumnsToggle.module.scss +1 -1
- package/src/DataGrid/DataGridActions/DataGridColumnsToggle.test.tsx +21 -21
- package/src/DataGrid/DataGridActions/DataGridColumnsToggle.tsx +20 -20
- package/src/DataGrid/DataGridBody/DataGridBody.test.tsx +40 -40
- package/src/DataGrid/DataGridBody/DataGridBody.tsx +10 -10
- package/src/DataGrid/DataGridBody/DataGridCell.module.scss +1 -1
- package/src/DataGrid/DataGridBody/DataGridCell.test.tsx +25 -25
- package/src/DataGrid/DataGridBody/DataGridCell.tsx +6 -6
- package/src/DataGrid/DataGridBody/DataGridRow.test.tsx +38 -38
- package/src/DataGrid/DataGridBody/DataGridRow.tsx +8 -8
- package/src/DataGrid/DataGridHeader/DataGridHeader.module.scss +1 -2
- package/src/DataGrid/DataGridHeader/DataGridHeader.test.tsx +119 -119
- package/src/DataGrid/DataGridHeader/DataGridHeader.tsx +13 -13
- package/src/DataGrid/DataGridHeader/DataGridHeaderCell.module.scss +2 -0
- package/src/DataGrid/DataGridHeader/DataGridHeaderCell.test.tsx +51 -51
- package/src/DataGrid/DataGridHeader/DataGridHeaderCell.tsx +14 -14
- package/src/DataGrid/datagrid.interfaces.ts +1 -1
- package/src/Form/Checkbox/Checkbox.test.tsx +74 -74
- package/src/Form/Checkbox/Checkbox.tsx +27 -27
- package/src/Form/Fieldset/Fieldset.module.scss +1 -1
- package/src/Form/Fieldset/Fieldset.test.tsx +35 -35
- package/src/Form/Fieldset/Fieldset.tsx +27 -27
- package/src/Form/Form.test.tsx +18 -18
- package/src/Form/Form.tsx +3 -3
- package/src/Form/FormControl/FormControl.test.tsx +22 -22
- package/src/Form/FormControl/FormControl.tsx +10 -10
- package/src/Form/FormGroup/FormGroup.test.tsx +37 -37
- package/src/Form/FormGroup/FormGroup.tsx +16 -16
- package/src/Form/FormHelperText/FormHelperText.test.tsx +18 -18
- package/src/Form/FormHelperText/FormHelperText.tsx +7 -7
- package/src/Form/FormSelectorWrapper/FormSelectorWrapper.test.tsx +15 -15
- package/src/Form/FormSelectorWrapper/FormSelectorWrapper.tsx +14 -14
- package/src/Form/Input/Input.module.scss +20 -44
- package/src/Form/Input/Input.test.tsx +121 -73
- package/src/Form/Input/Input.tsx +96 -35
- package/src/Form/Label/Label.test.tsx +13 -13
- package/src/Form/Label/Label.tsx +6 -6
- package/src/Form/Radio/Radio.test.tsx +35 -35
- package/src/Form/Radio/Radio.tsx +17 -17
- package/src/Form/Select/Option.test.tsx +10 -10
- package/src/Form/Select/Option.tsx +8 -8
- package/src/Form/Select/Select.module.scss +7 -9
- package/src/Form/Select/Select.test.tsx +144 -141
- package/src/Form/Select/Select.tsx +79 -78
- package/src/Form/Textarea/Textarea.module.scss +8 -18
- package/src/Form/Textarea/Textarea.test.tsx +27 -27
- package/src/Form/Textarea/Textarea.tsx +33 -13
- package/src/Form/Toggle/Toggle.module.scss +1 -1
- package/src/Form/Toggle/Toggle.test.tsx +22 -22
- package/src/Form/Toggle/Toggle.tsx +10 -10
- package/src/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.test.tsx +39 -39
- package/src/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.tsx +12 -12
- package/src/Form/Wrapper/InputWrapper/InputWrapper.module.scss +2 -8
- package/src/Form/Wrapper/InputWrapper/InputWrapper.test.tsx +55 -55
- package/src/Form/Wrapper/InputWrapper/InputWrapper.tsx +30 -35
- package/src/Form/Wrapper/RadioWrapper/RadioWrapper.test.tsx +35 -35
- package/src/Form/Wrapper/RadioWrapper/RadioWrapper.tsx +12 -12
- package/src/Form/Wrapper/SelectWrapper/SelectWrapper.test.tsx +55 -55
- package/src/Form/Wrapper/SelectWrapper/SelectWrapper.tsx +12 -12
- package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.module.scss +2 -11
- package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.test.tsx +50 -50
- package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.tsx +22 -22
- package/src/Form/Wrapper/Wrapper/Wrapper.module.scss +2 -2
- package/src/Form/Wrapper/Wrapper/Wrapper.test.tsx +11 -11
- package/src/Form/Wrapper/Wrapper/Wrapper.tsx +17 -17
- package/src/Form/form.interfaces.ts +1 -1
- package/src/Icon/Icon.module.scss +71 -71
- package/src/Icon/Icon.test.tsx +18 -18
- package/src/Icon/Icon.tsx +70 -70
- package/src/Link/Link.module.scss +5 -5
- package/src/Link/Link.test.tsx +76 -76
- package/src/Link/Link.tsx +27 -27
- package/src/Link/types.d.ts +1 -1
- package/src/Notifications/BaseModal/BaseModal.module.scss +1 -1
- package/src/Notifications/BaseModal/BaseModal.test.tsx +53 -53
- package/src/Notifications/BaseModal/BaseModal.tsx +16 -16
- package/src/Notifications/BaseModal/BaseModalActions/BaseModalActions.test.tsx +13 -13
- package/src/Notifications/BaseModal/BaseModalActions/BaseModalActions.tsx +5 -5
- package/src/Notifications/BaseModal/BaseModalContent/BaseModalContent.test.tsx +16 -16
- package/src/Notifications/BaseModal/BaseModalContent/BaseModalContent.tsx +5 -5
- package/src/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.test.tsx +19 -19
- package/src/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.tsx +10 -10
- package/src/Notifications/Dialog/Dialog.test.tsx +35 -35
- package/src/Notifications/Dialog/Dialog.tsx +19 -19
- package/src/Notifications/Dialog/DialogActions/DialogActions.test.tsx +14 -14
- package/src/Notifications/Dialog/DialogActions/DialogActions.tsx +6 -6
- package/src/Notifications/Dialog/DialogTitle/DialogTitle.test.tsx +12 -12
- package/src/Notifications/Dialog/DialogTitle/DialogTitle.tsx +6 -6
- package/src/Notifications/DiscardChangesModal/DiscardChangesDialog/DiscardChangesDialog.test.tsx +20 -20
- package/src/Notifications/DiscardChangesModal/DiscardChangesDialog/DiscardChangesDialog.tsx +7 -7
- package/src/Notifications/DiscardChangesModal/DiscardChangesModal.test.tsx +36 -36
- package/src/Notifications/DiscardChangesModal/DiscardChangesModal.tsx +8 -8
- package/src/Notifications/Modal/Modal.test.tsx +6 -6
- package/src/Notifications/Modal/Modal.tsx +1 -1
- package/src/Notifications/Modal/ModalActions/ModalActions.tsx +2 -2
- package/src/Notifications/Modal/ModalContent/ModalContent.tsx +2 -2
- package/src/Notifications/Modal/ModalHeader/ModalHeader.tsx +2 -2
- package/src/Notifications/SlideInModal/SlideInModal.test.tsx +16 -16
- package/src/Notifications/SlideInModal/SlideInModal.tsx +16 -11
- package/src/Notifications/Snackbar/SnackbarContainer/SnackbarContainer.test.tsx +16 -16
- package/src/Notifications/Snackbar/SnackbarContainer/SnackbarContainer.tsx +6 -6
- package/src/Notifications/Snackbar/SnackbarItem/SnackbarItem.module.scss +2 -2
- package/src/Notifications/Snackbar/SnackbarItem/SnackbarItem.test.tsx +17 -17
- package/src/Notifications/Snackbar/SnackbarItem/SnackbarItem.tsx +23 -23
- package/src/Notifications/Snackbar/SnackbarProvider/SnackbarProvider.test.tsx +32 -32
- package/src/Notifications/Snackbar/SnackbarProvider/SnackbarProvider.tsx +18 -18
- package/src/Notifications/Snackbar/SnackbarProvider/SnackbarStateProvider.tsx +3 -3
- package/src/Notifications/Snackbar/interfaces.ts +2 -2
- package/src/Notifications/Snackbar/useSnackbar.ts +2 -2
- package/src/Pagination/Pagination.module.scss +2 -0
- package/src/Pagination/Pagination.test.tsx +47 -47
- package/src/Pagination/Pagination.tsx +35 -35
- package/src/Popover/Popover.test.tsx +19 -19
- package/src/Popover/Popover.tsx +7 -7
- package/src/Skeleton/Skeleton.module.scss +2 -2
- package/src/Skeleton/Skeleton.test.tsx +29 -29
- package/src/Skeleton/Skeleton.tsx +10 -10
- package/src/StatusIndicator/StatusIndicator.test.tsx +38 -38
- package/src/StatusIndicator/StatusIndicator.tsx +9 -9
- package/src/Tabs/Tab.test.tsx +13 -13
- package/src/Tabs/Tab.tsx +1 -1
- package/src/Tabs/TabButton.test.tsx +28 -28
- package/src/Tabs/TabButton.tsx +7 -7
- package/src/Tabs/TabPanel.test.tsx +30 -30
- package/src/Tabs/TabPanel.tsx +4 -4
- package/src/Tabs/Tabs.test.tsx +93 -93
- package/src/Tabs/Tabs.tsx +25 -25
- package/src/TextEllipsis/TextEllipsis.test.tsx +22 -22
- package/src/TextEllipsis/TextEllipsis.tsx +6 -6
- package/src/Tiles/Tile.module.scss +1 -1
- package/src/Tiles/Tile.test.tsx +42 -42
- package/src/Tiles/Tile.tsx +22 -22
- package/src/Tiles/Tiles.test.tsx +30 -30
- package/src/Tiles/Tiles.tsx +9 -9
- package/src/Tooltip/Tooltip.test.tsx +35 -35
- package/src/Tooltip/Tooltip.tsx +21 -21
- package/src/Typography/Typography.module.scss +1 -1
- package/src/Typography/Typography.test.tsx +49 -49
- package/src/Typography/Typography.tsx +42 -42
- package/src/Wizard/BaseWizardSteps/BaseWizardSteps.module.scss +1 -1
- package/src/Wizard/BaseWizardSteps/BaseWizardSteps.test.tsx +26 -26
- package/src/Wizard/BaseWizardSteps/BaseWizardSteps.tsx +24 -24
- package/src/Wizard/Wizard.test.tsx +56 -56
- package/src/Wizard/Wizard.tsx +6 -6
- package/src/Wizard/WizardActions/WizardActions.test.tsx +34 -34
- package/src/Wizard/WizardActions/WizardActions.tsx +14 -14
- package/src/Wizard/WizardStateProvider.tsx +3 -3
- package/src/Wizard/WizardSteps/WizardSteps.test.tsx +27 -27
- package/src/Wizard/WizardSteps/WizardSteps.tsx +7 -7
- package/src/Wizard/wizardStateReducer.ts +9 -9
- package/src/_BaseStyling_/BaseStyling.test.tsx +14 -14
- package/src/_BaseStyling_/BaseStyling.tsx +50 -50
- package/src/hooks/useAnimation.test.tsx +12 -12
- package/src/hooks/useAnimation.ts +4 -4
- package/src/hooks/useBodyClick.test.tsx +8 -8
- package/src/hooks/useBodyClick.ts +3 -3
- package/src/hooks/useFormSelector.test.ts +17 -17
- package/src/hooks/useFormSelector.ts +4 -4
- package/src/hooks/usePosition.test.tsx +215 -215
- package/src/hooks/usePosition.ts +68 -68
- package/src/hooks/useRepeater.test.tsx +26 -26
- package/src/hooks/useRepeater.ts +5 -5
- package/src/hooks/useScroll.test.tsx +5 -5
- package/src/hooks/useScroll.ts +3 -3
- package/src/hooks/useSpacing.test.ts +40 -40
- package/src/hooks/useSpacing.ts +3 -3
- package/src/hooks/useWrapper.test.ts +12 -12
- package/src/hooks/useWrapper.ts +14 -7
- package/src/index.ts +67 -67
- package/src/mixins.module.scss +76 -27
- package/src/types.d.ts +1 -1
- package/src/util/helper.test.tsx +25 -25
- package/src/util/helper.tsx +64 -64
package/src/Link/Link.test.tsx
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from
|
|
2
|
-
import { Link, Props } from
|
|
3
|
-
import { render } from
|
|
4
|
-
import { BrowserRouter, Link as RouterLink } from
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
|
+
import { Link, Props } from "./Link";
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
|
+
import { BrowserRouter, Link as RouterLink } from "react-router-dom";
|
|
5
5
|
|
|
6
6
|
const defaultParams: Props = {
|
|
7
|
-
type:
|
|
8
|
-
to:
|
|
7
|
+
type: "external",
|
|
8
|
+
to: "https://www.google.com"
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
const createLink = (params?: (defaultParams: Props) => Props) => {
|
|
@@ -18,126 +18,126 @@ const createLink = (params?: (defaultParams: Props) => Props) => {
|
|
|
18
18
|
link content
|
|
19
19
|
</Link>
|
|
20
20
|
);
|
|
21
|
-
const link = queries.getByTestId(
|
|
21
|
+
const link = queries.getByTestId("link");
|
|
22
22
|
|
|
23
23
|
return {
|
|
24
24
|
...queries,
|
|
25
|
-
link
|
|
25
|
+
link
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
describe(
|
|
30
|
-
it(
|
|
29
|
+
describe("Link should render", () => {
|
|
30
|
+
it("renders without crashing", () => {
|
|
31
31
|
const { link } = createLink();
|
|
32
32
|
|
|
33
33
|
expect(link).toBeTruthy();
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
-
it(
|
|
36
|
+
it("is an external link with the right attributes", () => {
|
|
37
37
|
const { link } = createLink();
|
|
38
38
|
|
|
39
|
-
expect(link).toHaveAttribute(
|
|
40
|
-
expect(link).toHaveAttribute(
|
|
41
|
-
expect(link).toHaveAttribute(
|
|
39
|
+
expect(link).toHaveAttribute("aria-disabled", "false");
|
|
40
|
+
expect(link).toHaveAttribute("rel", "noopener noreferer");
|
|
41
|
+
expect(link).toHaveAttribute("target", "_blank");
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
it(
|
|
45
|
-
const { link } = createLink(
|
|
44
|
+
it("is an internal link with the right attributes", () => {
|
|
45
|
+
const { link } = createLink(defaultParams => ({
|
|
46
46
|
...defaultParams,
|
|
47
|
-
type:
|
|
48
|
-
to:
|
|
47
|
+
type: "internal",
|
|
48
|
+
to: "/home"
|
|
49
49
|
}));
|
|
50
50
|
|
|
51
|
-
expect(link).toHaveAttribute(
|
|
52
|
-
expect(link).not.toHaveAttribute(
|
|
53
|
-
expect(link).not.toHaveAttribute(
|
|
51
|
+
expect(link).toHaveAttribute("aria-disabled", "false");
|
|
52
|
+
expect(link).not.toHaveAttribute("rel", "noopener noreferer");
|
|
53
|
+
expect(link).not.toHaveAttribute("target", "_blank");
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
it(
|
|
57
|
-
const { link } = createLink(
|
|
56
|
+
it("is a download link with the right attributes", () => {
|
|
57
|
+
const { link } = createLink(defaultParams => ({
|
|
58
58
|
...defaultParams,
|
|
59
|
-
type:
|
|
60
|
-
to:
|
|
59
|
+
type: "download",
|
|
60
|
+
to: "/test.png"
|
|
61
61
|
}));
|
|
62
62
|
|
|
63
|
-
expect(link).toHaveAttribute(
|
|
64
|
-
expect(link).not.toHaveAttribute(
|
|
65
|
-
expect(link).not.toHaveAttribute(
|
|
66
|
-
expect(link).toHaveAttribute(
|
|
63
|
+
expect(link).toHaveAttribute("aria-disabled", "false");
|
|
64
|
+
expect(link).not.toHaveAttribute("rel", "noopener noreferer");
|
|
65
|
+
expect(link).not.toHaveAttribute("target", "_blank");
|
|
66
|
+
expect(link).toHaveAttribute("download");
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
-
it(
|
|
70
|
-
const { link } = createLink(
|
|
69
|
+
it("should set the correct target", () => {
|
|
70
|
+
const { link } = createLink(defaultParams => ({ ...defaultParams, target: "_parent" }));
|
|
71
71
|
|
|
72
|
-
expect(link).toHaveAttribute(
|
|
72
|
+
expect(link).toHaveAttribute("target", "_parent");
|
|
73
73
|
});
|
|
74
74
|
|
|
75
|
-
it(
|
|
75
|
+
it("should accept this React Router Link prop and render as such", () => {
|
|
76
76
|
const queries = render(
|
|
77
77
|
<BrowserRouter>
|
|
78
78
|
<Link to="/contact" component={RouterLink} children="Routerlink" />
|
|
79
79
|
</BrowserRouter>
|
|
80
80
|
);
|
|
81
81
|
|
|
82
|
-
const routerLink = queries.getByText(
|
|
82
|
+
const routerLink = queries.getByText("Routerlink");
|
|
83
83
|
|
|
84
84
|
expect(routerLink).toBeTruthy();
|
|
85
|
-
expect(routerLink).toHaveClass(
|
|
86
|
-
expect(routerLink).toHaveAttribute(
|
|
85
|
+
expect(routerLink).toHaveClass("link");
|
|
86
|
+
expect(routerLink).toHaveAttribute("href", "/contact");
|
|
87
87
|
});
|
|
88
88
|
|
|
89
|
-
it(
|
|
90
|
-
const { link } = createLink(
|
|
89
|
+
it("should be disabled", () => {
|
|
90
|
+
const { link } = createLink(defaultParams => ({ ...defaultParams, disabled: true }));
|
|
91
91
|
|
|
92
|
-
expect(link).not.toHaveAttribute(
|
|
93
|
-
expect(link).toHaveClass(
|
|
94
|
-
expect(link).toHaveStyle({ color:
|
|
92
|
+
expect(link).not.toHaveAttribute("href");
|
|
93
|
+
expect(link).toHaveClass("disabled");
|
|
94
|
+
expect(link).toHaveStyle({ color: "var(--greyed-out)" });
|
|
95
95
|
});
|
|
96
96
|
|
|
97
|
-
it(
|
|
98
|
-
const { link } = createLink(
|
|
97
|
+
it("should have a className added", () => {
|
|
98
|
+
const { link } = createLink(defaultParams => ({ ...defaultParams, className: "classname" }));
|
|
99
99
|
|
|
100
|
-
expect(link).toHaveClass(
|
|
100
|
+
expect(link).toHaveClass("classname");
|
|
101
101
|
});
|
|
102
102
|
|
|
103
|
-
it(
|
|
104
|
-
const { link } = createLink(
|
|
103
|
+
it("should render as a filled button ", () => {
|
|
104
|
+
const { link } = createLink(defaultParams => ({
|
|
105
105
|
...defaultParams,
|
|
106
|
-
display:
|
|
107
|
-
buttonVariant:
|
|
106
|
+
display: "button",
|
|
107
|
+
buttonVariant: "fill"
|
|
108
108
|
}));
|
|
109
109
|
|
|
110
|
-
expect(link).toHaveClass(
|
|
111
|
-
expect(link).toHaveClass(
|
|
110
|
+
expect(link).toHaveClass("button");
|
|
111
|
+
expect(link).toHaveClass("fill");
|
|
112
112
|
});
|
|
113
113
|
|
|
114
|
-
it(
|
|
115
|
-
const { link } = createLink(
|
|
114
|
+
it("should render as a text button ", () => {
|
|
115
|
+
const { link } = createLink(defaultParams => ({
|
|
116
116
|
...defaultParams,
|
|
117
|
-
display:
|
|
118
|
-
buttonVariant:
|
|
117
|
+
display: "button",
|
|
118
|
+
buttonVariant: "text"
|
|
119
119
|
}));
|
|
120
120
|
|
|
121
|
-
expect(link).toHaveClass(
|
|
122
|
-
expect(link).toHaveClass(
|
|
121
|
+
expect(link).toHaveClass("button");
|
|
122
|
+
expect(link).toHaveClass("text");
|
|
123
123
|
});
|
|
124
124
|
|
|
125
|
-
it(
|
|
126
|
-
const { link } = createLink(
|
|
125
|
+
it("should render as an outline button ", () => {
|
|
126
|
+
const { link } = createLink(defaultParams => ({
|
|
127
127
|
...defaultParams,
|
|
128
|
-
display:
|
|
129
|
-
buttonVariant:
|
|
128
|
+
display: "button",
|
|
129
|
+
buttonVariant: "outline"
|
|
130
130
|
}));
|
|
131
131
|
|
|
132
|
-
expect(link).toHaveClass(
|
|
133
|
-
expect(link).toHaveClass(
|
|
132
|
+
expect(link).toHaveClass("button");
|
|
133
|
+
expect(link).toHaveClass("outline");
|
|
134
134
|
});
|
|
135
135
|
});
|
|
136
136
|
|
|
137
|
-
describe(
|
|
138
|
-
it(
|
|
137
|
+
describe("ref should work", () => {
|
|
138
|
+
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
139
139
|
const ExampleComponent = ({
|
|
140
|
-
propagateRef
|
|
140
|
+
propagateRef
|
|
141
141
|
}: {
|
|
142
142
|
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
143
143
|
}) => {
|
|
@@ -153,29 +153,29 @@ describe('ref should work', () => {
|
|
|
153
153
|
};
|
|
154
154
|
|
|
155
155
|
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
156
|
-
expect(ref.current).toHaveAttribute(
|
|
156
|
+
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
157
157
|
};
|
|
158
158
|
|
|
159
159
|
render(<ExampleComponent propagateRef={refCheck} />);
|
|
160
160
|
});
|
|
161
161
|
});
|
|
162
162
|
|
|
163
|
-
describe(
|
|
164
|
-
it(
|
|
165
|
-
const { link } = createLink(
|
|
163
|
+
describe("colors", () => {
|
|
164
|
+
it("should be color primary", () => {
|
|
165
|
+
const { link } = createLink(defaultParams => ({ ...defaultParams, color: "primary" }));
|
|
166
166
|
|
|
167
|
-
expect(link).toHaveStyle({ color:
|
|
167
|
+
expect(link).toHaveStyle({ color: "var(--color-primary)" });
|
|
168
168
|
});
|
|
169
169
|
|
|
170
|
-
it(
|
|
171
|
-
const { link } = createLink(
|
|
170
|
+
it("should be color secondary", () => {
|
|
171
|
+
const { link } = createLink(defaultParams => ({ ...defaultParams, color: "secondary" }));
|
|
172
172
|
|
|
173
|
-
expect(link).toHaveStyle({ color:
|
|
173
|
+
expect(link).toHaveStyle({ color: "var(--color-secondary)" });
|
|
174
174
|
});
|
|
175
175
|
|
|
176
|
-
it(
|
|
177
|
-
const { link } = createLink(
|
|
176
|
+
it("should be color tertiary", () => {
|
|
177
|
+
const { link } = createLink(defaultParams => ({ ...defaultParams, color: "tertiary" }));
|
|
178
178
|
|
|
179
|
-
expect(link).toHaveStyle({ color:
|
|
179
|
+
expect(link).toHaveStyle({ color: "var(--color-tertiary)" });
|
|
180
180
|
});
|
|
181
181
|
});
|
package/src/Link/Link.tsx
CHANGED
|
@@ -2,18 +2,18 @@ import React, {
|
|
|
2
2
|
ComponentPropsWithRef,
|
|
3
3
|
ForwardRefExoticComponent,
|
|
4
4
|
ReactNode,
|
|
5
|
-
RefAttributes
|
|
6
|
-
} from
|
|
7
|
-
import classes from
|
|
8
|
-
import { LinkProps } from
|
|
5
|
+
RefAttributes
|
|
6
|
+
} from "react";
|
|
7
|
+
import classes from "./Link.module.scss";
|
|
8
|
+
import { LinkProps } from "./types";
|
|
9
9
|
|
|
10
|
-
export type AnchorType =
|
|
10
|
+
export type AnchorType = "external" | "internal" | "download";
|
|
11
11
|
|
|
12
|
-
export interface Props extends ComponentPropsWithRef<
|
|
12
|
+
export interface Props extends ComponentPropsWithRef<"a"> {
|
|
13
13
|
children?: ReactNode;
|
|
14
|
-
color?:
|
|
15
|
-
display?:
|
|
16
|
-
buttonVariant?:
|
|
14
|
+
color?: "primary" | "secondary" | "tertiary";
|
|
15
|
+
display?: "link" | "button";
|
|
16
|
+
buttonVariant?: "outline" | "text" | "fill";
|
|
17
17
|
type?: AnchorType;
|
|
18
18
|
to: string;
|
|
19
19
|
disabled?: boolean;
|
|
@@ -27,10 +27,10 @@ export const Link = React.forwardRef<HTMLAnchorElement, Props>(
|
|
|
27
27
|
className,
|
|
28
28
|
disabled = false,
|
|
29
29
|
to,
|
|
30
|
-
color =
|
|
31
|
-
type =
|
|
32
|
-
display =
|
|
33
|
-
buttonVariant =
|
|
30
|
+
color = "primary",
|
|
31
|
+
type = "internal",
|
|
32
|
+
display = "link",
|
|
33
|
+
buttonVariant = "fill",
|
|
34
34
|
component,
|
|
35
35
|
...rest
|
|
36
36
|
}: Props,
|
|
@@ -41,17 +41,17 @@ export const Link = React.forwardRef<HTMLAnchorElement, Props>(
|
|
|
41
41
|
return rest.target;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
if (type ===
|
|
45
|
-
return
|
|
44
|
+
if (type === "external") {
|
|
45
|
+
return "_blank";
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
return
|
|
48
|
+
return "";
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
const classNames = [classes[color]];
|
|
52
|
-
display ===
|
|
53
|
-
display ===
|
|
54
|
-
disabled && classNames.push(classes[
|
|
52
|
+
display === "link" && classNames.push(classes["link"]);
|
|
53
|
+
display === "button" && classNames.push(classes["button"], classes[buttonVariant]);
|
|
54
|
+
disabled && classNames.push(classes["disabled"]);
|
|
55
55
|
className && classNames.push(className);
|
|
56
56
|
|
|
57
57
|
if (component) {
|
|
@@ -59,12 +59,12 @@ export const Link = React.forwardRef<HTMLAnchorElement, Props>(
|
|
|
59
59
|
...rest,
|
|
60
60
|
ref: ref,
|
|
61
61
|
to: to,
|
|
62
|
-
className: classNames.join(
|
|
63
|
-
|
|
62
|
+
className: classNames.join(" "),
|
|
63
|
+
"aria-disabled": disabled,
|
|
64
64
|
style: {
|
|
65
|
-
...rest.style
|
|
65
|
+
...rest.style
|
|
66
66
|
},
|
|
67
|
-
children: children
|
|
67
|
+
children: children
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
|
|
@@ -72,14 +72,14 @@ export const Link = React.forwardRef<HTMLAnchorElement, Props>(
|
|
|
72
72
|
<a
|
|
73
73
|
{...rest}
|
|
74
74
|
ref={ref}
|
|
75
|
-
download={type ===
|
|
76
|
-
rel={type ===
|
|
75
|
+
download={type === "download"}
|
|
76
|
+
rel={type === "external" ? "noopener noreferer" : undefined}
|
|
77
77
|
href={!disabled ? to : undefined}
|
|
78
|
-
className={classNames.join(
|
|
78
|
+
className={classNames.join(" ")}
|
|
79
79
|
aria-disabled={disabled}
|
|
80
80
|
target={determineTarget()}
|
|
81
81
|
style={{
|
|
82
|
-
...rest.style
|
|
82
|
+
...rest.style
|
|
83
83
|
}}
|
|
84
84
|
>
|
|
85
85
|
{children}
|
package/src/Link/types.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from
|
|
2
|
-
import { BaseModal, Props } from
|
|
3
|
-
import { render, getByText, queryByText, fireEvent } from
|
|
4
|
-
import userEvent from
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
|
+
import { BaseModal, Props } from "./BaseModal";
|
|
3
|
+
import { render, getByText, queryByText, fireEvent } from "@testing-library/react";
|
|
4
|
+
import userEvent from "@testing-library/user-event";
|
|
5
5
|
|
|
6
|
-
const classNames = [
|
|
7
|
-
const containerClassNames = [
|
|
6
|
+
const classNames = ["class11", "class12"];
|
|
7
|
+
const containerClassNames = ["class21", "class22"];
|
|
8
8
|
|
|
9
9
|
const defaultParams: Props = {
|
|
10
|
-
id:
|
|
10
|
+
id: "modal",
|
|
11
11
|
open: true,
|
|
12
12
|
onClose: jest.fn(),
|
|
13
|
-
className: classNames.join(
|
|
14
|
-
containerProps: { className: containerClassNames.join(
|
|
15
|
-
children:
|
|
13
|
+
className: classNames.join(" "),
|
|
14
|
+
containerProps: { className: containerClassNames.join(" ") },
|
|
15
|
+
children: "This is example dialog content."
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
const createBaseModal = (params?: (defaultParams: Props) => Props) => {
|
|
@@ -21,105 +21,105 @@ const createBaseModal = (params?: (defaultParams: Props) => Props) => {
|
|
|
21
21
|
parameters = params(defaultParams);
|
|
22
22
|
}
|
|
23
23
|
const queries = render(<BaseModal {...parameters} data-testid="BaseModal" />);
|
|
24
|
-
const slideInModal = queries.getByTestId(
|
|
24
|
+
const slideInModal = queries.getByTestId("BaseModal");
|
|
25
25
|
|
|
26
26
|
return {
|
|
27
27
|
...queries,
|
|
28
|
-
slideInModal
|
|
28
|
+
slideInModal
|
|
29
29
|
};
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
describe(
|
|
33
|
-
it(
|
|
32
|
+
describe("BaseModal", () => {
|
|
33
|
+
it("renders without crashing", () => {
|
|
34
34
|
const { getByRole } = createBaseModal();
|
|
35
|
-
const dialog = getByRole(
|
|
35
|
+
const dialog = getByRole("dialog");
|
|
36
36
|
|
|
37
|
-
expect(dialog).toHaveAttribute(
|
|
38
|
-
expect(dialog).toHaveAttribute(
|
|
39
|
-
expect(dialog).toHaveAttribute(
|
|
40
|
-
expect(dialog).toHaveAttribute(
|
|
41
|
-
expect(dialog).toHaveAttribute(
|
|
37
|
+
expect(dialog).toHaveAttribute("aria-modal", "true");
|
|
38
|
+
expect(dialog).toHaveAttribute("aria-labelledby", "modal-label");
|
|
39
|
+
expect(dialog).toHaveAttribute("aria-describedby", "modal-description");
|
|
40
|
+
expect(dialog).toHaveAttribute("data-hidden", "false");
|
|
41
|
+
expect(dialog).toHaveAttribute("aria-hidden", "false");
|
|
42
42
|
expect(getByText(dialog, defaultParams.children as string)).toBeDefined();
|
|
43
|
-
expect(document.body).toHaveStyle(
|
|
43
|
+
expect(document.body).toHaveStyle("overflow: hidden");
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
it(
|
|
47
|
-
const { queryByRole } = createBaseModal(
|
|
46
|
+
it("should render closed modal without content", () => {
|
|
47
|
+
const { queryByRole } = createBaseModal(params => ({ ...params, open: false }));
|
|
48
48
|
|
|
49
|
-
const dialogByRole = queryByRole(
|
|
49
|
+
const dialogByRole = queryByRole("dialog");
|
|
50
50
|
const dialog = document.body.children[1] as HTMLElement;
|
|
51
51
|
|
|
52
52
|
expect(dialogByRole).toBeNull();
|
|
53
|
-
expect(dialog).toHaveAttribute(
|
|
53
|
+
expect(dialog).toHaveAttribute("aria-hidden", "true");
|
|
54
54
|
expect(queryByText(dialog, defaultParams.children as string)).toBeNull();
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
-
it(
|
|
58
|
-
const { getByRole } = createBaseModal(
|
|
57
|
+
it("should render closed modal with content when forceContainerOpen is provided", () => {
|
|
58
|
+
const { getByRole } = createBaseModal(params => ({
|
|
59
59
|
...params,
|
|
60
60
|
open: false,
|
|
61
|
-
forceContainerOpen: true
|
|
61
|
+
forceContainerOpen: true
|
|
62
62
|
}));
|
|
63
63
|
|
|
64
|
-
const modal = getByRole(
|
|
65
|
-
const container = modal.querySelector(
|
|
64
|
+
const modal = getByRole("dialog", { hidden: true });
|
|
65
|
+
const container = modal.querySelector(".container") as HTMLElement;
|
|
66
66
|
|
|
67
67
|
expect(container).toBeInTheDocument();
|
|
68
|
-
expect(container).toHaveAttribute(
|
|
68
|
+
expect(container).toHaveAttribute("aria-hidden", "true");
|
|
69
69
|
});
|
|
70
70
|
|
|
71
|
-
it(
|
|
72
|
-
const { getByRole } = createBaseModal(
|
|
71
|
+
it("propagates containerProps to container element", () => {
|
|
72
|
+
const { getByRole } = createBaseModal(params => ({
|
|
73
73
|
...params,
|
|
74
74
|
open: true,
|
|
75
75
|
containerProps: {
|
|
76
|
-
id:
|
|
77
|
-
}
|
|
76
|
+
id: "container"
|
|
77
|
+
}
|
|
78
78
|
}));
|
|
79
79
|
|
|
80
|
-
const modal = getByRole(
|
|
81
|
-
const container = modal.querySelector(
|
|
80
|
+
const modal = getByRole("dialog");
|
|
81
|
+
const container = modal.querySelector(".container") as HTMLElement;
|
|
82
82
|
|
|
83
83
|
expect(container).toBeInTheDocument();
|
|
84
|
-
expect(container).toHaveAttribute(
|
|
84
|
+
expect(container).toHaveAttribute("id", "container");
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
-
it(
|
|
88
|
-
const { getByRole } = createBaseModal(
|
|
87
|
+
it("propagates backdropProps to backdrop element", () => {
|
|
88
|
+
const { getByRole } = createBaseModal(params => ({
|
|
89
89
|
...params,
|
|
90
90
|
open: true,
|
|
91
91
|
backdropProps: {
|
|
92
|
-
id:
|
|
93
|
-
}
|
|
92
|
+
id: "backdrop"
|
|
93
|
+
}
|
|
94
94
|
}));
|
|
95
95
|
|
|
96
|
-
const modal = getByRole(
|
|
97
|
-
const backdrop = modal.querySelector(
|
|
96
|
+
const modal = getByRole("dialog");
|
|
97
|
+
const backdrop = modal.querySelector(".backdrop") as HTMLElement;
|
|
98
98
|
|
|
99
99
|
expect(backdrop).toBeInTheDocument();
|
|
100
|
-
expect(backdrop).toHaveAttribute(
|
|
100
|
+
expect(backdrop).toHaveAttribute("id", "backdrop");
|
|
101
101
|
});
|
|
102
102
|
|
|
103
|
-
it(
|
|
103
|
+
it("should handle clicking on backdrop & ESC key", () => {
|
|
104
104
|
const { getByRole } = createBaseModal();
|
|
105
105
|
|
|
106
|
-
const modal = getByRole(
|
|
106
|
+
const modal = getByRole("dialog");
|
|
107
107
|
|
|
108
|
-
const backdrop = modal.querySelector(
|
|
108
|
+
const backdrop = modal.querySelector(".backdrop")!;
|
|
109
109
|
expect(defaultParams.onClose).toHaveBeenCalledTimes(0);
|
|
110
110
|
|
|
111
111
|
userEvent.click(backdrop);
|
|
112
112
|
expect(defaultParams.onClose).toHaveBeenCalledTimes(1);
|
|
113
113
|
|
|
114
|
-
fireEvent.keyDown(modal, { key:
|
|
114
|
+
fireEvent.keyDown(modal, { key: "Escape" });
|
|
115
115
|
expect(defaultParams.onClose).toHaveBeenCalledTimes(2);
|
|
116
116
|
});
|
|
117
117
|
});
|
|
118
118
|
|
|
119
|
-
describe(
|
|
120
|
-
it(
|
|
119
|
+
describe("ref should work", () => {
|
|
120
|
+
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
121
121
|
const ExampleComponent = ({
|
|
122
|
-
propagateRef
|
|
122
|
+
propagateRef
|
|
123
123
|
}: {
|
|
124
124
|
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
125
125
|
}) => {
|
|
@@ -135,7 +135,7 @@ describe('ref should work', () => {
|
|
|
135
135
|
};
|
|
136
136
|
|
|
137
137
|
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
138
|
-
expect(ref.current).toHaveAttribute(
|
|
138
|
+
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
139
139
|
};
|
|
140
140
|
|
|
141
141
|
render(<ExampleComponent propagateRef={refCheck} />);
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import React, { ComponentPropsWithRef, useEffect } from
|
|
2
|
-
import { createPortal } from
|
|
3
|
-
import classes from
|
|
4
|
-
import { labelId, descriptionId } from
|
|
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
5
|
|
|
6
|
-
const SCROLL_PROPERTY_NAME =
|
|
7
|
-
const SCROLL_PROPERTY_VALUE =
|
|
6
|
+
const SCROLL_PROPERTY_NAME = "overflow";
|
|
7
|
+
const SCROLL_PROPERTY_VALUE = "hidden";
|
|
8
8
|
|
|
9
|
-
export interface Props extends ComponentPropsWithRef<
|
|
9
|
+
export interface Props extends ComponentPropsWithRef<"div"> {
|
|
10
10
|
id: string;
|
|
11
11
|
children: React.ReactNode;
|
|
12
12
|
open: boolean;
|
|
13
13
|
onClose?: (event?: React.MouseEvent<HTMLElement>) => unknown;
|
|
14
14
|
className?: string;
|
|
15
|
-
containerProps?: ComponentPropsWithRef<
|
|
16
|
-
backdropProps?: ComponentPropsWithRef<
|
|
15
|
+
containerProps?: ComponentPropsWithRef<"div">;
|
|
16
|
+
backdropProps?: ComponentPropsWithRef<"div">;
|
|
17
17
|
labelledby?: string;
|
|
18
18
|
describedby?: string;
|
|
19
19
|
disableEscapeKeyDown?: boolean;
|
|
@@ -30,7 +30,7 @@ export const useSetBodyScroll = (open: boolean) => {
|
|
|
30
30
|
|
|
31
31
|
const showBodyScroll = () => {
|
|
32
32
|
const allModalsClosed =
|
|
33
|
-
document.querySelectorAll(
|
|
33
|
+
document.querySelectorAll("[role=dialog][data-hidden=false]").length === 0;
|
|
34
34
|
if (allModalsClosed) {
|
|
35
35
|
document.body.style.removeProperty(SCROLL_PROPERTY_NAME);
|
|
36
36
|
}
|
|
@@ -52,7 +52,7 @@ export const BaseModal = React.forwardRef<HTMLDivElement, Props>(
|
|
|
52
52
|
children,
|
|
53
53
|
open,
|
|
54
54
|
onClose,
|
|
55
|
-
className =
|
|
55
|
+
className = "",
|
|
56
56
|
containerProps,
|
|
57
57
|
backdropProps,
|
|
58
58
|
labelledby,
|
|
@@ -69,7 +69,7 @@ export const BaseModal = React.forwardRef<HTMLDivElement, Props>(
|
|
|
69
69
|
useSetBodyScroll(open);
|
|
70
70
|
|
|
71
71
|
const handleEscKeyPress = (event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
72
|
-
if (!disableEscapeKeyDown && event.key ===
|
|
72
|
+
if (!disableEscapeKeyDown && event.key === "Escape") {
|
|
73
73
|
event.stopPropagation();
|
|
74
74
|
onClose && onClose();
|
|
75
75
|
}
|
|
@@ -82,7 +82,7 @@ export const BaseModal = React.forwardRef<HTMLDivElement, Props>(
|
|
|
82
82
|
{...rest}
|
|
83
83
|
ref={ref}
|
|
84
84
|
id={id}
|
|
85
|
-
className={`${classes[
|
|
85
|
+
className={`${classes["modal"]} ${open ? classes["visible"] : ""} ${className}`}
|
|
86
86
|
role="dialog"
|
|
87
87
|
aria-modal="true"
|
|
88
88
|
aria-labelledby={labelledby || labelId(id)}
|
|
@@ -95,7 +95,7 @@ export const BaseModal = React.forwardRef<HTMLDivElement, Props>(
|
|
|
95
95
|
>
|
|
96
96
|
<div
|
|
97
97
|
{...backdropProps}
|
|
98
|
-
className={`${classes[
|
|
98
|
+
className={`${classes["backdrop"]} ${backdropProps?.className ?? ""}`}
|
|
99
99
|
onClick={handleBackdropClick}
|
|
100
100
|
></div>
|
|
101
101
|
{forceContainerOpen ? (
|
|
@@ -104,7 +104,7 @@ export const BaseModal = React.forwardRef<HTMLDivElement, Props>(
|
|
|
104
104
|
aria-hidden={!open}
|
|
105
105
|
hidden={!open}
|
|
106
106
|
style={{ zIndex: zIndex && zIndex + 1 }}
|
|
107
|
-
className={`${classes[
|
|
107
|
+
className={`${classes["container"]} ${containerProps?.className ?? ""}`}
|
|
108
108
|
>
|
|
109
109
|
{children}
|
|
110
110
|
</div>
|
|
@@ -113,7 +113,7 @@ export const BaseModal = React.forwardRef<HTMLDivElement, Props>(
|
|
|
113
113
|
<div
|
|
114
114
|
{...containerProps}
|
|
115
115
|
style={{ zIndex: zIndex && zIndex + 1 }}
|
|
116
|
-
className={`${classes[
|
|
116
|
+
className={`${classes["container"]} ${containerProps?.className ?? ""}`}
|
|
117
117
|
>
|
|
118
118
|
{children}
|
|
119
119
|
</div>
|