@onewelcome/react-lib-components 0.2.1 → 0.2.4
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 +2 -2
- 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 +5 -5
- 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/interfaces.d.ts +1 -1
- package/dist/react-lib-components.cjs.development.js +683 -581
- 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 +683 -581
- 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 +8 -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 +9 -9
- 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 +2 -2
- 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 +2 -2
- 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 +73 -72
- 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 +10 -10
- package/src/index.ts +67 -67
- package/src/interfaces.ts +1 -1
- 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
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from
|
|
2
|
-
import { BaseModalActions } from
|
|
3
|
-
import { render } from
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
|
+
import { BaseModalActions } from "./BaseModalActions";
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
4
|
|
|
5
|
-
describe(
|
|
6
|
-
it(
|
|
7
|
-
const children =
|
|
8
|
-
const classNames = [
|
|
5
|
+
describe("BaseModalActions", () => {
|
|
6
|
+
it("renders without crashing", () => {
|
|
7
|
+
const children = "Content";
|
|
8
|
+
const classNames = ["class1", "class2"];
|
|
9
9
|
const { container } = render(
|
|
10
|
-
<BaseModalActions className={classNames.join(
|
|
10
|
+
<BaseModalActions className={classNames.join(" ")}>{children}</BaseModalActions>
|
|
11
11
|
);
|
|
12
12
|
|
|
13
13
|
const dialogActionsContainer = container.children[0];
|
|
14
|
-
expect(dialogActionsContainer).toHaveClass(
|
|
14
|
+
expect(dialogActionsContainer).toHaveClass("actions", classNames[0], classNames[1]);
|
|
15
15
|
expect(dialogActionsContainer).toHaveTextContent(children);
|
|
16
16
|
});
|
|
17
17
|
});
|
|
18
|
-
describe(
|
|
19
|
-
it(
|
|
18
|
+
describe("ref should work", () => {
|
|
19
|
+
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
20
20
|
const ExampleComponent = ({
|
|
21
|
-
propagateRef
|
|
21
|
+
propagateRef
|
|
22
22
|
}: {
|
|
23
23
|
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
24
24
|
}) => {
|
|
@@ -34,7 +34,7 @@ describe('ref should work', () => {
|
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
37
|
-
expect(ref.current).toHaveAttribute(
|
|
37
|
+
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
render(<ExampleComponent propagateRef={refCheck} />);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import React, { ComponentPropsWithRef } from
|
|
2
|
-
import classes from
|
|
1
|
+
import React, { ComponentPropsWithRef } from "react";
|
|
2
|
+
import classes from "./BaseModalActions.module.scss";
|
|
3
3
|
|
|
4
|
-
export interface Props extends ComponentPropsWithRef<
|
|
4
|
+
export interface Props extends ComponentPropsWithRef<"footer"> {
|
|
5
5
|
children?: React.ReactNode;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export const BaseModalActions = React.forwardRef<HTMLElement, Props>(
|
|
9
|
-
({ children, className =
|
|
9
|
+
({ children, className = "", ...rest }: Props, ref) => {
|
|
10
10
|
return (
|
|
11
|
-
<footer {...rest} ref={ref} className={`${classes[
|
|
11
|
+
<footer {...rest} ref={ref} className={`${classes["actions"]} ${className}`}>
|
|
12
12
|
{children}
|
|
13
13
|
</footer>
|
|
14
14
|
);
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from
|
|
2
|
-
import { BaseModalContent, Props } from
|
|
3
|
-
import { render } from
|
|
4
|
-
import { descriptionId } from
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
|
+
import { BaseModalContent, Props } from "./BaseModalContent";
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
|
+
import { descriptionId } from "../BaseModalContext";
|
|
5
5
|
|
|
6
|
-
const classNames = [
|
|
6
|
+
const classNames = ["class1", "class2"];
|
|
7
7
|
const initParams: Props = {
|
|
8
|
-
id: descriptionId(
|
|
9
|
-
className: classNames.join(
|
|
10
|
-
children:
|
|
8
|
+
id: descriptionId("modal"),
|
|
9
|
+
className: classNames.join(" "),
|
|
10
|
+
children: "This is example dialog content."
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
describe(
|
|
14
|
-
it(
|
|
13
|
+
describe("BaseModalContent", () => {
|
|
14
|
+
it("renders without crashing", () => {
|
|
15
15
|
const { container } = render(<BaseModalContent {...initParams} />);
|
|
16
16
|
|
|
17
17
|
const dialogContentContainer = container.children[0];
|
|
18
|
-
expect(dialogContentContainer).toHaveClass(
|
|
18
|
+
expect(dialogContentContainer).toHaveClass("content", classNames[0], classNames[1]);
|
|
19
19
|
expect(dialogContentContainer).toHaveTextContent(initParams.children as string);
|
|
20
20
|
expect(dialogContentContainer).toEqual(document.activeElement);
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
describe(
|
|
24
|
-
it(
|
|
23
|
+
describe("ref should work", () => {
|
|
24
|
+
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
25
25
|
const ExampleComponent = ({
|
|
26
|
-
propagateRef
|
|
26
|
+
propagateRef
|
|
27
27
|
}: {
|
|
28
28
|
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
29
29
|
}) => {
|
|
@@ -39,14 +39,14 @@ describe('BaseModalContent', () => {
|
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
42
|
-
expect(ref.current).toHaveAttribute(
|
|
42
|
+
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
render(<ExampleComponent propagateRef={refCheck} />);
|
|
46
46
|
});
|
|
47
47
|
});
|
|
48
48
|
|
|
49
|
-
it(
|
|
49
|
+
it("should renders not focused div", () => {
|
|
50
50
|
const { container } = render(<BaseModalContent {...initParams} disableAutoFocus />);
|
|
51
51
|
|
|
52
52
|
const dialogContentContainer = container.children[0];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React, { ComponentPropsWithRef, createRef, useEffect } from
|
|
2
|
-
import classes from
|
|
1
|
+
import React, { ComponentPropsWithRef, createRef, useEffect } from "react";
|
|
2
|
+
import classes from "./BaseModalContent.module.scss";
|
|
3
3
|
|
|
4
|
-
export interface Props extends ComponentPropsWithRef<
|
|
4
|
+
export interface Props extends ComponentPropsWithRef<"div"> {
|
|
5
5
|
id?: string;
|
|
6
6
|
children: React.ReactNode;
|
|
7
7
|
className?: string;
|
|
@@ -9,7 +9,7 @@ export interface Props extends ComponentPropsWithRef<'div'> {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export const BaseModalContent = React.forwardRef<HTMLDivElement, Props>(
|
|
12
|
-
({ id, children, className =
|
|
12
|
+
({ id, children, className = "", disableAutoFocus = false, ...rest }: Props, ref) => {
|
|
13
13
|
const contentRef = createRef<HTMLDivElement>();
|
|
14
14
|
|
|
15
15
|
useEffect(() => {
|
|
@@ -26,7 +26,7 @@ export const BaseModalContent = React.forwardRef<HTMLDivElement, Props>(
|
|
|
26
26
|
{...rest}
|
|
27
27
|
ref={ref || contentRef}
|
|
28
28
|
id={id}
|
|
29
|
-
className={`${classes[
|
|
29
|
+
className={`${classes["content"]} ${className}`}
|
|
30
30
|
tabIndex={-1}
|
|
31
31
|
>
|
|
32
32
|
{children}
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from
|
|
2
|
-
import { BaseModalHeader, Props } from
|
|
3
|
-
import { render, getByRole, getByTestId, getByText } from
|
|
4
|
-
import { labelId } from
|
|
5
|
-
import userEvent from
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
|
+
import { BaseModalHeader, Props } from "./BaseModalHeader";
|
|
3
|
+
import { render, getByRole, getByTestId, getByText } from "@testing-library/react";
|
|
4
|
+
import { labelId } from "../BaseModalContext";
|
|
5
|
+
import userEvent from "@testing-library/user-event";
|
|
6
6
|
|
|
7
|
-
const additionalContent =
|
|
7
|
+
const additionalContent = "Additional content";
|
|
8
8
|
const initParams: Props = {
|
|
9
|
-
id: labelId(
|
|
10
|
-
title:
|
|
9
|
+
id: labelId("modal"),
|
|
10
|
+
title: "Example title",
|
|
11
11
|
onClose: jest.fn(),
|
|
12
|
-
children: <div data-testid="additional-content">{additionalContent}</div
|
|
12
|
+
children: <div data-testid="additional-content">{additionalContent}</div>
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
describe(
|
|
16
|
-
it(
|
|
15
|
+
describe("BaseModalHeader", () => {
|
|
16
|
+
it("renders without crashing", () => {
|
|
17
17
|
const { container } = render(<BaseModalHeader {...initParams} />);
|
|
18
|
-
const closeBtn = getByRole(container,
|
|
18
|
+
const closeBtn = getByRole(container, "button");
|
|
19
19
|
expect(initParams.onClose).toBeCalledTimes(0);
|
|
20
20
|
|
|
21
21
|
userEvent.click(closeBtn);
|
|
22
22
|
|
|
23
23
|
const dialogContentContainer = container.children[0];
|
|
24
24
|
const titleContainer = getByText(container, initParams.title);
|
|
25
|
-
expect(dialogContentContainer).toHaveClass(
|
|
26
|
-
expect(titleContainer).toHaveAttribute(
|
|
27
|
-
expect(getByTestId(container,
|
|
25
|
+
expect(dialogContentContainer).toHaveClass("header");
|
|
26
|
+
expect(titleContainer).toHaveAttribute("id", "modal-label");
|
|
27
|
+
expect(getByTestId(container, "additional-content")).toHaveTextContent(additionalContent);
|
|
28
28
|
expect(initParams.onClose).toBeCalledTimes(1);
|
|
29
29
|
});
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
describe(
|
|
33
|
-
it(
|
|
32
|
+
describe("ref should work", () => {
|
|
33
|
+
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
34
34
|
const ExampleComponent = ({
|
|
35
|
-
propagateRef
|
|
35
|
+
propagateRef
|
|
36
36
|
}: {
|
|
37
37
|
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
38
38
|
}) => {
|
|
@@ -50,7 +50,7 @@ describe('ref should work', () => {
|
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
53
|
-
expect(ref.current).toHaveAttribute(
|
|
53
|
+
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
render(<ExampleComponent propagateRef={refCheck} />);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React, { ComponentPropsWithRef } from
|
|
2
|
-
import classes from
|
|
3
|
-
import { IconButton } from
|
|
4
|
-
import { Icon, Icons } from
|
|
5
|
-
import { Typography } from
|
|
1
|
+
import React, { ComponentPropsWithRef } from "react";
|
|
2
|
+
import classes from "./BaseModalHeader.module.scss";
|
|
3
|
+
import { IconButton } from "../../../Button/IconButton";
|
|
4
|
+
import { Icon, Icons } from "../../../Icon/Icon";
|
|
5
|
+
import { Typography } from "../../../Typography/Typography";
|
|
6
6
|
|
|
7
|
-
export interface Props extends ComponentPropsWithRef<
|
|
7
|
+
export interface Props extends ComponentPropsWithRef<"div"> {
|
|
8
8
|
id: string;
|
|
9
9
|
title: string;
|
|
10
10
|
children?: React.ReactNode;
|
|
@@ -14,12 +14,12 @@ export interface Props extends ComponentPropsWithRef<'div'> {
|
|
|
14
14
|
export const BaseModalHeader = React.forwardRef<HTMLDivElement, Props>(
|
|
15
15
|
({ id, title, children, onClose, ...rest }: Props, ref) => {
|
|
16
16
|
return (
|
|
17
|
-
<div {...rest} ref={ref} className={classes[
|
|
18
|
-
<div className={classes[
|
|
19
|
-
<Typography id={id} className={classes[
|
|
17
|
+
<div {...rest} ref={ref} className={classes["header"]}>
|
|
18
|
+
<div className={classes["headline"]}>
|
|
19
|
+
<Typography id={id} className={classes["title"]} tag="h1" variant="h4">
|
|
20
20
|
{title}
|
|
21
21
|
</Typography>
|
|
22
|
-
<IconButton onClick={onClose} className={classes[
|
|
22
|
+
<IconButton onClick={onClose} className={classes["closeBtn"]} title="close modal">
|
|
23
23
|
<Icon icon={Icons.Times} />
|
|
24
24
|
</IconButton>
|
|
25
25
|
</div>
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from
|
|
2
|
-
import { Dialog, Props } from
|
|
3
|
-
import { render, getAllByRole } from
|
|
4
|
-
import userEvent from
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
|
+
import { Dialog, Props } from "./Dialog";
|
|
3
|
+
import { render, getAllByRole } from "@testing-library/react";
|
|
4
|
+
import userEvent from "@testing-library/user-event";
|
|
5
5
|
|
|
6
6
|
const initParams: Props = {
|
|
7
|
-
id:
|
|
7
|
+
id: "modal",
|
|
8
8
|
open: true,
|
|
9
9
|
onClose: jest.fn(),
|
|
10
|
-
alignActions:
|
|
11
|
-
title:
|
|
10
|
+
alignActions: "left",
|
|
11
|
+
title: "Example dialog",
|
|
12
12
|
primaryAction: {
|
|
13
|
-
label:
|
|
14
|
-
onClick: jest.fn()
|
|
13
|
+
label: "Save",
|
|
14
|
+
onClick: jest.fn()
|
|
15
15
|
},
|
|
16
16
|
secondaryAction: {
|
|
17
|
-
label:
|
|
18
|
-
onClick: jest.fn()
|
|
17
|
+
label: "Cancel",
|
|
18
|
+
onClick: jest.fn()
|
|
19
19
|
},
|
|
20
|
-
children:
|
|
20
|
+
children: "This is example dialog content."
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
const getButtons = (container: HTMLElement) => getAllByRole(container,
|
|
23
|
+
const getButtons = (container: HTMLElement) => getAllByRole(container, "button");
|
|
24
24
|
|
|
25
|
-
describe(
|
|
26
|
-
it(
|
|
25
|
+
describe("Dialog", () => {
|
|
26
|
+
it("renders without crashing", () => {
|
|
27
27
|
const { getByText } = render(<Dialog {...initParams} />);
|
|
28
28
|
const [primaryButton, secondaryButton] = getButtons(document.body);
|
|
29
29
|
|
|
30
30
|
expect(getByText(initParams.title)).toBeDefined();
|
|
31
31
|
expect(getByText(initParams.children as string)).toBeDefined();
|
|
32
|
-
const actionsDiv = primaryButton.closest(
|
|
33
|
-
expect(actionsDiv).toHaveClass(
|
|
32
|
+
const actionsDiv = primaryButton.closest("footer");
|
|
33
|
+
expect(actionsDiv).toHaveClass("left");
|
|
34
34
|
expect(actionsDiv?.children[0]).toEqual(primaryButton);
|
|
35
35
|
expect(actionsDiv?.children[1]).toEqual(secondaryButton);
|
|
36
|
-
expect(primaryButton).toHaveClass(
|
|
37
|
-
expect(secondaryButton).toHaveClass(
|
|
36
|
+
expect(primaryButton).toHaveClass("fill");
|
|
37
|
+
expect(secondaryButton).toHaveClass("text");
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
it(
|
|
40
|
+
it("renders action aligned to right", () => {
|
|
41
41
|
render(<Dialog {...initParams} alignActions="right" />);
|
|
42
42
|
const [secondaryButton, primaryButton] = getButtons(document.body);
|
|
43
43
|
|
|
44
|
-
const actionsDiv = primaryButton.closest(
|
|
45
|
-
expect(actionsDiv).not.toHaveClass(
|
|
44
|
+
const actionsDiv = primaryButton.closest("footer");
|
|
45
|
+
expect(actionsDiv).not.toHaveClass("left");
|
|
46
46
|
expect(actionsDiv?.children[0]).toEqual(secondaryButton);
|
|
47
47
|
expect(actionsDiv?.children[1]).toEqual(primaryButton);
|
|
48
|
-
expect(primaryButton).toHaveClass(
|
|
49
|
-
expect(secondaryButton).toHaveClass(
|
|
48
|
+
expect(primaryButton).toHaveClass("fill");
|
|
49
|
+
expect(secondaryButton).toHaveClass("text");
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
it(
|
|
52
|
+
it("renders only one button", () => {
|
|
53
53
|
render(<Dialog {...initParams} secondaryAction={undefined} />);
|
|
54
54
|
const buttons = getButtons(document.body);
|
|
55
55
|
|
|
56
56
|
expect(buttons).toHaveLength(1);
|
|
57
|
-
expect(buttons[0]).toHaveClass(
|
|
57
|
+
expect(buttons[0]).toHaveClass("fill");
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
-
it(
|
|
60
|
+
it("should handle clicking on buttons and ENTER press", () => {
|
|
61
61
|
render(<Dialog {...initParams} />);
|
|
62
62
|
const [primaryButton, secondaryButton] = getButtons(document.body);
|
|
63
63
|
expect(initParams.primaryAction.onClick).toHaveBeenCalledTimes(0);
|
|
64
64
|
expect(initParams.secondaryAction?.onClick).toHaveBeenCalledTimes(0);
|
|
65
65
|
expect(initParams.onClose).toHaveBeenCalledTimes(0);
|
|
66
66
|
|
|
67
|
-
const autoSummissionInput = document.body.querySelector(
|
|
68
|
-
userEvent.type(autoSummissionInput,
|
|
67
|
+
const autoSummissionInput = document.body.querySelector("input") as HTMLElement;
|
|
68
|
+
userEvent.type(autoSummissionInput, "{enter}");
|
|
69
69
|
expect(initParams.primaryAction.onClick).toHaveBeenCalledTimes(1);
|
|
70
70
|
|
|
71
71
|
userEvent.click(primaryButton);
|
|
@@ -75,10 +75,10 @@ describe('Dialog', () => {
|
|
|
75
75
|
});
|
|
76
76
|
});
|
|
77
77
|
|
|
78
|
-
describe(
|
|
79
|
-
it(
|
|
78
|
+
describe("ref should work", () => {
|
|
79
|
+
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
80
80
|
const ExampleComponent = ({
|
|
81
|
-
propagateRef
|
|
81
|
+
propagateRef
|
|
82
82
|
}: {
|
|
83
83
|
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
84
84
|
}) => {
|
|
@@ -94,9 +94,9 @@ describe('ref should work', () => {
|
|
|
94
94
|
<Dialog
|
|
95
95
|
children="test"
|
|
96
96
|
open={false}
|
|
97
|
-
alignActions={
|
|
97
|
+
alignActions={"left"}
|
|
98
98
|
onClose={jest.fn()}
|
|
99
|
-
primaryAction={{ label:
|
|
99
|
+
primaryAction={{ label: "test", onClick: jest.fn() }}
|
|
100
100
|
title="test"
|
|
101
101
|
id="test"
|
|
102
102
|
data-ref="testing"
|
|
@@ -106,7 +106,7 @@ describe('ref should work', () => {
|
|
|
106
106
|
};
|
|
107
107
|
|
|
108
108
|
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
109
|
-
expect(ref.current).toHaveAttribute(
|
|
109
|
+
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
110
110
|
};
|
|
111
111
|
|
|
112
112
|
render(<ExampleComponent propagateRef={refCheck} />);
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import React, { ComponentPropsWithRef, useState } from
|
|
2
|
-
import { BaseModal } from
|
|
3
|
-
import { BaseModalContent } from
|
|
4
|
-
import { DialogActions } from
|
|
5
|
-
import classes from
|
|
6
|
-
import { DialogTitle } from
|
|
7
|
-
import { Button, Props as ButtonProps } from
|
|
8
|
-
import { labelId, descriptionId } from
|
|
9
|
-
import { generateID } from
|
|
1
|
+
import React, { ComponentPropsWithRef, useState } from "react";
|
|
2
|
+
import { BaseModal } from "../BaseModal/BaseModal";
|
|
3
|
+
import { BaseModalContent } from "../BaseModal/BaseModalContent/BaseModalContent";
|
|
4
|
+
import { DialogActions } from "./DialogActions/DialogActions";
|
|
5
|
+
import classes from "./Dialog.module.scss";
|
|
6
|
+
import { DialogTitle } from "./DialogTitle/DialogTitle";
|
|
7
|
+
import { Button, Props as ButtonProps } from "../../Button/Button";
|
|
8
|
+
import { labelId, descriptionId } from "../BaseModal/BaseModalContext";
|
|
9
|
+
import { generateID } from "../../util/helper";
|
|
10
10
|
|
|
11
|
-
export interface Props extends ComponentPropsWithRef<
|
|
11
|
+
export interface Props extends ComponentPropsWithRef<"div"> {
|
|
12
12
|
id?: string;
|
|
13
13
|
open: boolean;
|
|
14
14
|
children: React.ReactNode;
|
|
15
|
-
alignActions:
|
|
15
|
+
alignActions: "left" | "right";
|
|
16
16
|
onClose: () => void;
|
|
17
17
|
title: string;
|
|
18
18
|
primaryAction: Action;
|
|
@@ -21,7 +21,7 @@ export interface Props extends ComponentPropsWithRef<'div'> {
|
|
|
21
21
|
disableEscapeKeyDown?: boolean;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export interface Action extends Omit<ButtonProps,
|
|
24
|
+
export interface Action extends Omit<ButtonProps, "variant" | "ref"> {
|
|
25
25
|
label: string;
|
|
26
26
|
onClick: (event?: React.MouseEvent<HTMLButtonElement>) => unknown;
|
|
27
27
|
}
|
|
@@ -63,7 +63,7 @@ export const Dialog = React.forwardRef<HTMLDivElement, Props>(
|
|
|
63
63
|
|
|
64
64
|
const onHiddenInputKeyPress = (event: React.KeyboardEvent<HTMLInputElement>) => {
|
|
65
65
|
/** It has to be here because then we will need to check if user doesn't click tab to select action button and want to do another action then primary one? */
|
|
66
|
-
if (event.key ===
|
|
66
|
+
if (event.key === "Enter") {
|
|
67
67
|
primaryAction.onClick();
|
|
68
68
|
}
|
|
69
69
|
};
|
|
@@ -73,8 +73,8 @@ export const Dialog = React.forwardRef<HTMLDivElement, Props>(
|
|
|
73
73
|
{...rest}
|
|
74
74
|
ref={ref}
|
|
75
75
|
id={dialogId}
|
|
76
|
-
className={classes[
|
|
77
|
-
containerProps={{ className: classes[
|
|
76
|
+
className={classes["dialog"]}
|
|
77
|
+
containerProps={{ className: classes["container"] }}
|
|
78
78
|
open={open}
|
|
79
79
|
disableBackdrop
|
|
80
80
|
onClose={onClose}
|
|
@@ -84,13 +84,13 @@ export const Dialog = React.forwardRef<HTMLDivElement, Props>(
|
|
|
84
84
|
<DialogTitle id={labelId(dialogId)} title={title} />
|
|
85
85
|
<BaseModalContent
|
|
86
86
|
id={descriptionId(dialogId)}
|
|
87
|
-
className={classes[
|
|
87
|
+
className={classes["content"]}
|
|
88
88
|
disableAutoFocus
|
|
89
89
|
>
|
|
90
90
|
{children}
|
|
91
91
|
</BaseModalContent>
|
|
92
92
|
<DialogActions align={alignActions}>
|
|
93
|
-
{alignActions ===
|
|
93
|
+
{alignActions === "left"
|
|
94
94
|
? [PrimaryButton, TertiaryButton]
|
|
95
95
|
: [TertiaryButton, PrimaryButton]}
|
|
96
96
|
</DialogActions>
|
|
@@ -98,10 +98,10 @@ export const Dialog = React.forwardRef<HTMLDivElement, Props>(
|
|
|
98
98
|
autoFocus
|
|
99
99
|
aria-hidden={true}
|
|
100
100
|
style={{
|
|
101
|
-
position:
|
|
101
|
+
position: "absolute",
|
|
102
102
|
width: 0,
|
|
103
103
|
height: 0,
|
|
104
|
-
opacity: 0
|
|
104
|
+
opacity: 0
|
|
105
105
|
}}
|
|
106
106
|
maxLength={0}
|
|
107
107
|
tabIndex={-1}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from
|
|
2
|
-
import { DialogActions, Props } from
|
|
3
|
-
import { render } from
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
|
+
import { DialogActions, Props } from "./DialogActions";
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
4
|
|
|
5
5
|
const initParams: Props = {
|
|
6
|
-
align:
|
|
7
|
-
children:
|
|
6
|
+
align: "right",
|
|
7
|
+
children: "Content"
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
describe(
|
|
11
|
-
it(
|
|
10
|
+
describe("DialogActions", () => {
|
|
11
|
+
it("renders without crashing", () => {
|
|
12
12
|
const { container } = render(<DialogActions {...initParams} />);
|
|
13
13
|
|
|
14
14
|
const dialogActionsContainer = container.children[0];
|
|
15
|
-
expect(dialogActionsContainer).toHaveClass(
|
|
15
|
+
expect(dialogActionsContainer).toHaveClass("actions");
|
|
16
16
|
expect(dialogActionsContainer).toHaveTextContent(initParams.children as string);
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
it(
|
|
19
|
+
it("should align items to left", () => {
|
|
20
20
|
const { container } = render(<DialogActions {...initParams} align="left" />);
|
|
21
21
|
|
|
22
22
|
const dialogActionsContainer = container.children[0];
|
|
23
|
-
expect(dialogActionsContainer).toHaveClass(
|
|
23
|
+
expect(dialogActionsContainer).toHaveClass("actions", "left");
|
|
24
24
|
});
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
-
describe(
|
|
28
|
-
it(
|
|
27
|
+
describe("ref should work", () => {
|
|
28
|
+
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
29
29
|
const ExampleComponent = ({
|
|
30
|
-
propagateRef
|
|
30
|
+
propagateRef
|
|
31
31
|
}: {
|
|
32
32
|
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
33
33
|
}) => {
|
|
@@ -43,7 +43,7 @@ describe('ref should work', () => {
|
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
46
|
-
expect(ref.current).toHaveAttribute(
|
|
46
|
+
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
render(<ExampleComponent propagateRef={refCheck} />);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import React, { ComponentPropsWithRef } from
|
|
1
|
+
import React, { ComponentPropsWithRef } from "react";
|
|
2
2
|
import {
|
|
3
3
|
BaseModalActions,
|
|
4
|
-
Props as BaseModalActionsProps
|
|
5
|
-
} from
|
|
6
|
-
import classes from
|
|
4
|
+
Props as BaseModalActionsProps
|
|
5
|
+
} from "../../BaseModal/BaseModalActions/BaseModalActions";
|
|
6
|
+
import classes from "./DialogActions.module.scss";
|
|
7
7
|
|
|
8
8
|
export interface Props extends ComponentPropsWithRef<any>, BaseModalActionsProps {
|
|
9
|
-
align:
|
|
9
|
+
align: "left" | "right";
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export const DialogActions = React.forwardRef<HTMLElement, Props>(
|
|
@@ -15,7 +15,7 @@ export const DialogActions = React.forwardRef<HTMLElement, Props>(
|
|
|
15
15
|
<BaseModalActions
|
|
16
16
|
{...rest}
|
|
17
17
|
ref={ref}
|
|
18
|
-
className={`${classes[
|
|
18
|
+
className={`${classes["actions"]}${align === "left" ? " " + classes["left"] : ""}`}
|
|
19
19
|
>
|
|
20
20
|
{children}
|
|
21
21
|
</BaseModalActions>
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from
|
|
2
|
-
import { DialogTitle, Props } from
|
|
3
|
-
import { render, getByText } from
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
|
+
import { DialogTitle, Props } from "./DialogTitle";
|
|
3
|
+
import { render, getByText } from "@testing-library/react";
|
|
4
4
|
|
|
5
5
|
const initParams: Props = {
|
|
6
|
-
id:
|
|
7
|
-
title:
|
|
6
|
+
id: "dialog-label",
|
|
7
|
+
title: "Example title"
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
describe(
|
|
11
|
-
it(
|
|
10
|
+
describe("DialogTitle", () => {
|
|
11
|
+
it("renders without crashing", () => {
|
|
12
12
|
const { container } = render(<DialogTitle {...initParams} />);
|
|
13
13
|
|
|
14
14
|
const dialogTitleContainer = container.children[0];
|
|
15
|
-
expect(dialogTitleContainer).toHaveClass(
|
|
15
|
+
expect(dialogTitleContainer).toHaveClass("header");
|
|
16
16
|
expect(getByText(container, initParams.title));
|
|
17
17
|
});
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
describe(
|
|
21
|
-
it(
|
|
20
|
+
describe("ref should work", () => {
|
|
21
|
+
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
22
22
|
const ExampleComponent = ({
|
|
23
|
-
propagateRef
|
|
23
|
+
propagateRef
|
|
24
24
|
}: {
|
|
25
25
|
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
26
26
|
}) => {
|
|
@@ -36,7 +36,7 @@ describe('ref should work', () => {
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
39
|
-
expect(ref.current).toHaveAttribute(
|
|
39
|
+
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
render(<ExampleComponent propagateRef={refCheck} />);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React, { ComponentPropsWithRef } from
|
|
2
|
-
import { Typography } from
|
|
3
|
-
import classes from
|
|
1
|
+
import React, { ComponentPropsWithRef } from "react";
|
|
2
|
+
import { Typography } from "../../../Typography/Typography";
|
|
3
|
+
import classes from "./DialogTitle.module.scss";
|
|
4
4
|
|
|
5
|
-
export interface Props extends ComponentPropsWithRef<
|
|
5
|
+
export interface Props extends ComponentPropsWithRef<"div"> {
|
|
6
6
|
id: string;
|
|
7
7
|
title: string;
|
|
8
8
|
}
|
|
@@ -10,8 +10,8 @@ export interface Props extends ComponentPropsWithRef<'div'> {
|
|
|
10
10
|
export const DialogTitle = React.forwardRef<HTMLDivElement, Props>(
|
|
11
11
|
({ id, title, ...rest }: Props, ref) => {
|
|
12
12
|
return (
|
|
13
|
-
<div {...rest} ref={ref} className={classes[
|
|
14
|
-
<Typography id={id} className={classes[
|
|
13
|
+
<div {...rest} ref={ref} className={classes["header"]}>
|
|
14
|
+
<Typography id={id} className={classes["title"]} tag="h1" variant="h4">
|
|
15
15
|
{title}
|
|
16
16
|
</Typography>
|
|
17
17
|
</div>
|