@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
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from
|
|
2
|
-
import { IconButton } from
|
|
3
|
-
import { Icon, Icons } from
|
|
4
|
-
import { Variant, Actions } from
|
|
5
|
-
import classes from
|
|
6
|
-
import readyclasses from
|
|
7
|
-
import { useAnimation } from
|
|
8
|
-
import { Typography } from
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
|
+
import { IconButton } from "../../../Button/IconButton";
|
|
3
|
+
import { Icon, Icons } from "../../../Icon/Icon";
|
|
4
|
+
import { Variant, Actions } from "../interfaces";
|
|
5
|
+
import classes from "./SnackbarItem.module.scss";
|
|
6
|
+
import readyclasses from "../../../readyclasses.module.scss";
|
|
7
|
+
import { useAnimation } from "../../../hooks/useAnimation";
|
|
8
|
+
import { Typography } from "../../../Typography/Typography";
|
|
9
9
|
|
|
10
|
-
const textColor =
|
|
10
|
+
const textColor = "var(--snackbar-text-color)";
|
|
11
11
|
|
|
12
12
|
export interface Props {
|
|
13
13
|
id: string;
|
|
@@ -28,7 +28,7 @@ export const SnackbarItem = ({
|
|
|
28
28
|
content,
|
|
29
29
|
actions = [],
|
|
30
30
|
onClose,
|
|
31
|
-
closeButtonTitle
|
|
31
|
+
closeButtonTitle
|
|
32
32
|
}: Props) => {
|
|
33
33
|
const timerHandler = useRef<ReturnType<typeof setTimeout>>();
|
|
34
34
|
const onAnimationEnd = () => onClose(id);
|
|
@@ -50,42 +50,42 @@ export const SnackbarItem = ({
|
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
const getVariantIcon = () => {
|
|
53
|
-
if (variant ===
|
|
53
|
+
if (variant === "error") {
|
|
54
54
|
return Icons.Error;
|
|
55
55
|
}
|
|
56
|
-
return variant ===
|
|
56
|
+
return variant === "success" ? Icons.CheckmarkCircleBreakout : Icons.InfoCircle;
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
const actionButtons = actions.map((actionProp, index) => (
|
|
60
60
|
<button
|
|
61
61
|
key={index}
|
|
62
62
|
{...actionProp}
|
|
63
|
-
onClick={
|
|
63
|
+
onClick={e => {
|
|
64
64
|
onClose(id);
|
|
65
65
|
actionProp.onClick && actionProp.onClick(e);
|
|
66
66
|
}}
|
|
67
67
|
children={actionProp.label}
|
|
68
|
-
className={classes[
|
|
68
|
+
className={classes["action-button"]}
|
|
69
69
|
></button>
|
|
70
70
|
));
|
|
71
71
|
|
|
72
72
|
return (
|
|
73
73
|
<div
|
|
74
74
|
ref={ref}
|
|
75
|
-
className={`${classes[
|
|
76
|
-
animationStarted ? readyclasses[
|
|
75
|
+
className={`${classes["snackbar"]} ${classes[variant]} ${
|
|
76
|
+
animationStarted ? readyclasses["slide-out"] : readyclasses["slide-in"]
|
|
77
77
|
}`}
|
|
78
78
|
onMouseEnter={onMouseEnter}
|
|
79
79
|
onMouseLeave={onMouseLeave}
|
|
80
80
|
>
|
|
81
|
-
<Icon icon={getVariantIcon()} className={classes[
|
|
82
|
-
<div className={classes[
|
|
83
|
-
<div className={classes[
|
|
84
|
-
<Typography className={classes[
|
|
81
|
+
<Icon icon={getVariantIcon()} className={classes["icon"]} />
|
|
82
|
+
<div className={classes["container"]}>
|
|
83
|
+
<div className={classes["headline"]}>
|
|
84
|
+
<Typography className={classes["title"]} variant="h4" tag="span">
|
|
85
85
|
{title}
|
|
86
86
|
</Typography>
|
|
87
87
|
<IconButton
|
|
88
|
-
id={classes[
|
|
88
|
+
id={classes["close-btn"]}
|
|
89
89
|
onClick={() => startAnimation()}
|
|
90
90
|
title={closeButtonTitle}
|
|
91
91
|
>
|
|
@@ -93,11 +93,11 @@ export const SnackbarItem = ({
|
|
|
93
93
|
</IconButton>
|
|
94
94
|
</div>
|
|
95
95
|
{!!content && (
|
|
96
|
-
<Typography className={classes[
|
|
96
|
+
<Typography className={classes["content"]} variant="body">
|
|
97
97
|
{content}
|
|
98
98
|
</Typography>
|
|
99
99
|
)}
|
|
100
|
-
{actionButtons.length > 0 && <div className={classes[
|
|
100
|
+
{actionButtons.length > 0 && <div className={classes["actions"]}>{actionButtons}</div>}
|
|
101
101
|
</div>
|
|
102
102
|
</div>
|
|
103
103
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState } from
|
|
1
|
+
import React, { useState } from "react";
|
|
2
2
|
import {
|
|
3
3
|
render,
|
|
4
4
|
getByTestId,
|
|
@@ -8,29 +8,29 @@ import {
|
|
|
8
8
|
getByText,
|
|
9
9
|
findByText,
|
|
10
10
|
findAllByText,
|
|
11
|
-
queryByText
|
|
12
|
-
} from
|
|
13
|
-
import { SnackbarProvider, Props } from
|
|
14
|
-
import { useSnackbar } from
|
|
15
|
-
import userEvent from
|
|
11
|
+
queryByText
|
|
12
|
+
} from "@testing-library/react";
|
|
13
|
+
import { SnackbarProvider, Props } from "./SnackbarProvider";
|
|
14
|
+
import { useSnackbar } from "../useSnackbar";
|
|
15
|
+
import userEvent from "@testing-library/user-event";
|
|
16
16
|
|
|
17
17
|
const successProps = {
|
|
18
|
-
title:
|
|
18
|
+
title: "success title"
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
const errorProps = {
|
|
22
|
-
title:
|
|
22
|
+
title: "error title"
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
const infoProps = {
|
|
26
|
-
title:
|
|
27
|
-
content:
|
|
26
|
+
title: "info title",
|
|
27
|
+
content: "test content",
|
|
28
28
|
options: {
|
|
29
29
|
actions: [
|
|
30
|
-
{ label:
|
|
31
|
-
{ label:
|
|
32
|
-
]
|
|
33
|
-
}
|
|
30
|
+
{ label: "Contact support", onClick: jest.fn() },
|
|
31
|
+
{ label: "Contact Onewelcome", onClick: jest.fn() }
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
const renderSnackbarProvider = (props?: Partial<Props>) => {
|
|
@@ -77,26 +77,26 @@ const renderSnackbarProvider = (props?: Partial<Props>) => {
|
|
|
77
77
|
</SnackbarProvider>
|
|
78
78
|
);
|
|
79
79
|
|
|
80
|
-
const showSuccessSnackbarBtn = getByTestId(queries.container,
|
|
81
|
-
const showErrorSnackbarBtn = getByTestId(queries.container,
|
|
82
|
-
const showInfoSnackbarBtn = getByTestId(queries.container,
|
|
80
|
+
const showSuccessSnackbarBtn = getByTestId(queries.container, "show-success");
|
|
81
|
+
const showErrorSnackbarBtn = getByTestId(queries.container, "show-error");
|
|
82
|
+
const showInfoSnackbarBtn = getByTestId(queries.container, "show-info");
|
|
83
83
|
|
|
84
84
|
return {
|
|
85
85
|
...queries,
|
|
86
86
|
showSuccessSnackbarBtn,
|
|
87
87
|
showErrorSnackbarBtn,
|
|
88
|
-
showInfoSnackbarBtn
|
|
88
|
+
showInfoSnackbarBtn
|
|
89
89
|
};
|
|
90
90
|
};
|
|
91
91
|
|
|
92
|
-
describe(
|
|
93
|
-
it(
|
|
92
|
+
describe("SnackbarProvider", () => {
|
|
93
|
+
it("renders without crashing", () => {
|
|
94
94
|
const { container } = renderSnackbarProvider();
|
|
95
95
|
|
|
96
|
-
expect(container).toHaveTextContent(
|
|
96
|
+
expect(container).toHaveTextContent("content");
|
|
97
97
|
});
|
|
98
98
|
|
|
99
|
-
it(
|
|
99
|
+
it("should stack 3 snackbars at one time", () => {
|
|
100
100
|
const { showSuccessSnackbarBtn } = renderSnackbarProvider();
|
|
101
101
|
|
|
102
102
|
userEvent.click(showSuccessSnackbarBtn);
|
|
@@ -107,7 +107,7 @@ describe('SnackbarProvider', () => {
|
|
|
107
107
|
expect(getAllByText(document.body, new RegExp(successProps.title))).toHaveLength(3);
|
|
108
108
|
});
|
|
109
109
|
|
|
110
|
-
it(
|
|
110
|
+
it("should render 3 variants of snackbars", () => {
|
|
111
111
|
const { showSuccessSnackbarBtn, showErrorSnackbarBtn, showInfoSnackbarBtn } =
|
|
112
112
|
renderSnackbarProvider();
|
|
113
113
|
|
|
@@ -119,7 +119,7 @@ describe('SnackbarProvider', () => {
|
|
|
119
119
|
expect(getByText(document.body, new RegExp(errorProps.title))).toBeDefined();
|
|
120
120
|
expect(getByText(document.body, new RegExp(infoProps.title))).toBeDefined();
|
|
121
121
|
expect(getByText(document.body, infoProps.content)).toBeDefined();
|
|
122
|
-
const infoSnackbarActions = getAllByRole(document.body,
|
|
122
|
+
const infoSnackbarActions = getAllByRole(document.body, "button", { name: /Contact/i });
|
|
123
123
|
expect(infoSnackbarActions).toHaveLength(2);
|
|
124
124
|
|
|
125
125
|
userEvent.click(infoSnackbarActions[0]);
|
|
@@ -129,9 +129,9 @@ describe('SnackbarProvider', () => {
|
|
|
129
129
|
waitFor(() => expect(infoProps.options.actions[1].onClick).toBeCalledTimes(1));
|
|
130
130
|
});
|
|
131
131
|
|
|
132
|
-
it(
|
|
132
|
+
it("should stack 3 snackbars at one time and then after 3 disapear show the fourth one", () => {
|
|
133
133
|
const { showSuccessSnackbarBtn } = renderSnackbarProvider({
|
|
134
|
-
autoHideDuration: { long: 1, short: 1 }
|
|
134
|
+
autoHideDuration: { long: 1, short: 1 }
|
|
135
135
|
});
|
|
136
136
|
|
|
137
137
|
userEvent.click(showSuccessSnackbarBtn);
|
|
@@ -142,7 +142,7 @@ describe('SnackbarProvider', () => {
|
|
|
142
142
|
expect(getAllByText(document.body, new RegExp(successProps.title))).toHaveLength(3);
|
|
143
143
|
|
|
144
144
|
/** Looking for fourth one to be shown */
|
|
145
|
-
waitFor(() => expect(getAllByText(document.body, successProps.title +
|
|
145
|
+
waitFor(() => expect(getAllByText(document.body, successProps.title + "3")).toHaveLength(1));
|
|
146
146
|
|
|
147
147
|
/** There shouldn't be any other snackbars */
|
|
148
148
|
waitFor(() =>
|
|
@@ -150,9 +150,9 @@ describe('SnackbarProvider', () => {
|
|
|
150
150
|
);
|
|
151
151
|
});
|
|
152
152
|
|
|
153
|
-
it(
|
|
153
|
+
it("should close snackbar after clicking X button", async () => {
|
|
154
154
|
const { showSuccessSnackbarBtn } = renderSnackbarProvider({
|
|
155
|
-
autoHideDuration: { long: 1_000_000, short: 1_000_000 }
|
|
155
|
+
autoHideDuration: { long: 1_000_000, short: 1_000_000 }
|
|
156
156
|
});
|
|
157
157
|
|
|
158
158
|
userEvent.click(showSuccessSnackbarBtn);
|
|
@@ -160,18 +160,18 @@ describe('SnackbarProvider', () => {
|
|
|
160
160
|
userEvent.click(showSuccessSnackbarBtn);
|
|
161
161
|
userEvent.click(showSuccessSnackbarBtn);
|
|
162
162
|
|
|
163
|
-
const closeButtons = getAllByRole(document.body,
|
|
163
|
+
const closeButtons = getAllByRole(document.body, "button", { name: "close" });
|
|
164
164
|
|
|
165
165
|
expect(closeButtons).toHaveLength(3);
|
|
166
166
|
expect(getAllByText(document.body, new RegExp(successProps.title))).toHaveLength(3);
|
|
167
167
|
|
|
168
168
|
userEvent.click(closeButtons[0]);
|
|
169
169
|
expect(
|
|
170
|
-
await findAllByText(document.body, new RegExp(successProps.title +
|
|
170
|
+
await findAllByText(document.body, new RegExp(successProps.title + "[12]+"))
|
|
171
171
|
).toHaveLength(2);
|
|
172
172
|
|
|
173
173
|
userEvent.click(closeButtons[1]);
|
|
174
|
-
expect(await findByText(document.body, successProps.title +
|
|
174
|
+
expect(await findByText(document.body, successProps.title + "2")).toBeDefined();
|
|
175
175
|
|
|
176
176
|
userEvent.click(closeButtons[2]);
|
|
177
177
|
waitFor(() => expect(queryByText(document.body, new RegExp(successProps.title))).toBeNull());
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React, { ReactNode, useState } from
|
|
2
|
-
import { createPortal } from
|
|
3
|
-
import { SnackbarContextProvider } from
|
|
4
|
-
import { Actions, SnackbarOptionsProps, Variant } from
|
|
5
|
-
import { Placement, SnackbarContainer } from
|
|
6
|
-
import { generateID } from
|
|
7
|
-
import { SnackbarItem } from
|
|
1
|
+
import React, { ReactNode, useState } from "react";
|
|
2
|
+
import { createPortal } from "react-dom";
|
|
3
|
+
import { SnackbarContextProvider } from "./SnackbarStateProvider";
|
|
4
|
+
import { Actions, SnackbarOptionsProps, Variant } from "../interfaces";
|
|
5
|
+
import { Placement, SnackbarContainer } from "../SnackbarContainer/SnackbarContainer";
|
|
6
|
+
import { generateID } from "../../../util/helper";
|
|
7
|
+
import { SnackbarItem } from "../SnackbarItem/SnackbarItem";
|
|
8
8
|
|
|
9
9
|
/** Short msg is when only title is provided. Long one when content or/and actions are provided (or type is error). */
|
|
10
10
|
interface Duration {
|
|
@@ -34,22 +34,22 @@ interface Item {
|
|
|
34
34
|
export const SnackbarProvider = (
|
|
35
35
|
{
|
|
36
36
|
closeButtonTitle,
|
|
37
|
-
placement = { vertical:
|
|
37
|
+
placement = { vertical: "bottom", horizontal: "center" },
|
|
38
38
|
autoHideDuration = { long: 8000, short: 4000 },
|
|
39
39
|
stackSize = 3,
|
|
40
40
|
domRoot = document.body,
|
|
41
41
|
children,
|
|
42
|
-
className
|
|
43
|
-
}: Props = { closeButtonTitle:
|
|
42
|
+
className
|
|
43
|
+
}: Props = { closeButtonTitle: "" }
|
|
44
44
|
) => {
|
|
45
45
|
const [snackbars, setSnackbars] = useState<Item[]>([]);
|
|
46
46
|
|
|
47
47
|
const addSnackbar = (item: Item) => {
|
|
48
|
-
setSnackbars(
|
|
48
|
+
setSnackbars(items => [...items, item]);
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
const getDuration = (variant: Variant, actions?: Actions, content?: string) => {
|
|
52
|
-
const hasError = variant ===
|
|
52
|
+
const hasError = variant === "error";
|
|
53
53
|
const hasContentOrActions = content || actions;
|
|
54
54
|
if (hasError || hasContentOrActions) {
|
|
55
55
|
return autoHideDuration.long;
|
|
@@ -63,9 +63,9 @@ export const SnackbarProvider = (
|
|
|
63
63
|
options: SnackbarOptionsProps = {}
|
|
64
64
|
): void => {
|
|
65
65
|
const {
|
|
66
|
-
variant =
|
|
66
|
+
variant = "info",
|
|
67
67
|
actions,
|
|
68
|
-
duration = getDuration(variant, actions, content)
|
|
68
|
+
duration = getDuration(variant, actions, content)
|
|
69
69
|
} = options;
|
|
70
70
|
const item: Item = {
|
|
71
71
|
title,
|
|
@@ -73,7 +73,7 @@ export const SnackbarProvider = (
|
|
|
73
73
|
variant,
|
|
74
74
|
actions,
|
|
75
75
|
duration,
|
|
76
|
-
id: generateID(15, title)
|
|
76
|
+
id: generateID(15, title)
|
|
77
77
|
};
|
|
78
78
|
addSnackbar(item);
|
|
79
79
|
};
|
|
@@ -83,7 +83,7 @@ export const SnackbarProvider = (
|
|
|
83
83
|
content?: string,
|
|
84
84
|
options?: SnackbarOptionsProps
|
|
85
85
|
): void => {
|
|
86
|
-
enqueueSnackbar(title, content, { ...options, variant:
|
|
86
|
+
enqueueSnackbar(title, content, { ...options, variant: "success" });
|
|
87
87
|
};
|
|
88
88
|
|
|
89
89
|
const enqueueErrorSnackbar = (
|
|
@@ -91,11 +91,11 @@ export const SnackbarProvider = (
|
|
|
91
91
|
content?: string,
|
|
92
92
|
options?: SnackbarOptionsProps
|
|
93
93
|
): void => {
|
|
94
|
-
enqueueSnackbar(title, content, { ...options, variant:
|
|
94
|
+
enqueueSnackbar(title, content, { ...options, variant: "error" });
|
|
95
95
|
};
|
|
96
96
|
|
|
97
97
|
const onItemClosed = (id: string) => {
|
|
98
|
-
setSnackbars(
|
|
98
|
+
setSnackbars(items => [...items].filter(item => item.id !== id));
|
|
99
99
|
};
|
|
100
100
|
|
|
101
101
|
const snackbarList = snackbars.map((item, index) =>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { createContext } from
|
|
2
|
-
import { SnackbarOptionsProps } from
|
|
1
|
+
import React, { createContext } from "react";
|
|
2
|
+
import { SnackbarOptionsProps } from "../interfaces";
|
|
3
3
|
|
|
4
4
|
interface SnackbarContextProps {
|
|
5
5
|
enqueueSnackbar: (title: string, content?: string, options?: SnackbarOptionsProps) => void;
|
|
@@ -10,7 +10,7 @@ interface SnackbarContextProps {
|
|
|
10
10
|
const SnackbarContext = createContext<SnackbarContextProps>({
|
|
11
11
|
enqueueSnackbar: () => null,
|
|
12
12
|
enqueueSuccessSnackbar: () => null,
|
|
13
|
-
enqueueErrorSnackbar: () => null
|
|
13
|
+
enqueueErrorSnackbar: () => null
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
interface Props {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ButtonHTMLAttributes } from
|
|
1
|
+
import { ButtonHTMLAttributes } from "react";
|
|
2
2
|
|
|
3
|
-
export type Variant =
|
|
3
|
+
export type Variant = "info" | "success" | "error";
|
|
4
4
|
|
|
5
5
|
export type Actions = (ButtonHTMLAttributes<HTMLButtonElement> & { label: string })[];
|
|
6
6
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useContext } from
|
|
2
|
-
import { SnackbarContext } from
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { SnackbarContext } from "./SnackbarProvider/SnackbarStateProvider";
|
|
3
3
|
|
|
4
4
|
export const useSnackbar = () => useContext(SnackbarContext);
|
|
@@ -85,6 +85,7 @@
|
|
|
85
85
|
.current-value-input {
|
|
86
86
|
margin: 0 0.25rem 0 0;
|
|
87
87
|
padding: 0;
|
|
88
|
+
height: auto;
|
|
88
89
|
|
|
89
90
|
input {
|
|
90
91
|
border-radius: var(--input-border-radius);
|
|
@@ -120,5 +121,6 @@
|
|
|
120
121
|
@media screen and (min-width: 48em) {
|
|
121
122
|
.pagination-wrapper .per-page {
|
|
122
123
|
display: flex;
|
|
124
|
+
margin-right: 0.5rem;
|
|
123
125
|
}
|
|
124
126
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from
|
|
2
|
-
import { Pagination, Props } from
|
|
3
|
-
import { render, waitFor } from
|
|
4
|
-
import userEvent from
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
|
+
import { Pagination, Props } from "./Pagination";
|
|
3
|
+
import { render, waitFor } from "@testing-library/react";
|
|
4
|
+
import userEvent from "@testing-library/user-event";
|
|
5
5
|
|
|
6
6
|
const defaultParams: Props = {
|
|
7
7
|
currentPage: 1,
|
|
8
8
|
totalElements: 500,
|
|
9
9
|
onPageChange: jest.fn(),
|
|
10
|
-
onPageSizeChange: jest.fn()
|
|
10
|
+
onPageSizeChange: jest.fn()
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
const createPagination = (params?: (defaultParams: Props) => Props) => {
|
|
@@ -19,41 +19,41 @@ const createPagination = (params?: (defaultParams: Props) => Props) => {
|
|
|
19
19
|
|
|
20
20
|
const queries = render(<Pagination data-testid="pagination" {...parameters} />);
|
|
21
21
|
|
|
22
|
-
const pagination = queries.getByTestId(
|
|
22
|
+
const pagination = queries.getByTestId("pagination");
|
|
23
23
|
|
|
24
24
|
return {
|
|
25
25
|
...queries,
|
|
26
|
-
pagination
|
|
26
|
+
pagination
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
describe(
|
|
31
|
-
it(
|
|
30
|
+
describe("Pagination should render", () => {
|
|
31
|
+
it("renders without crashing", () => {
|
|
32
32
|
const { pagination } = createPagination();
|
|
33
33
|
|
|
34
34
|
expect(pagination).toBeTruthy();
|
|
35
35
|
});
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
describe(
|
|
39
|
-
it(
|
|
38
|
+
describe("Pagination events", () => {
|
|
39
|
+
it("should give us the correct values", async () => {
|
|
40
40
|
const onPageChange = jest.fn();
|
|
41
41
|
|
|
42
42
|
const onPageSizeChange = jest.fn();
|
|
43
43
|
|
|
44
|
-
const { pagination } = createPagination(
|
|
44
|
+
const { pagination } = createPagination(defaultParams => ({
|
|
45
45
|
...defaultParams,
|
|
46
46
|
currentPage: 10,
|
|
47
47
|
onPageChange: onPageChange,
|
|
48
|
-
onPageSizeChange: onPageSizeChange
|
|
48
|
+
onPageSizeChange: onPageSizeChange
|
|
49
49
|
}));
|
|
50
50
|
|
|
51
51
|
const next = pagination.querySelector('[data-paginate="next"]')!;
|
|
52
52
|
const previous = pagination.querySelector('[data-paginate="previous"]')!;
|
|
53
53
|
const first = pagination.querySelector('[data-paginate="first"]')!;
|
|
54
54
|
const last = pagination.querySelector('[data-paginate="last"]')!;
|
|
55
|
-
const pageSizeSelect = pagination.querySelector(
|
|
56
|
-
const currentPageInput = pagination.querySelector(
|
|
55
|
+
const pageSizeSelect = pagination.querySelector(".page-size-select")!;
|
|
56
|
+
const currentPageInput = pagination.querySelector("#current-value-input")!;
|
|
57
57
|
|
|
58
58
|
userEvent.click(next);
|
|
59
59
|
|
|
@@ -68,7 +68,7 @@ describe('Pagination events', () => {
|
|
|
68
68
|
userEvent.click(last);
|
|
69
69
|
await waitFor(() => expect(onPageChange).toHaveBeenCalledWith(50));
|
|
70
70
|
|
|
71
|
-
userEvent.click(pageSizeSelect);
|
|
71
|
+
userEvent.click(pageSizeSelect.querySelector("button")!);
|
|
72
72
|
|
|
73
73
|
const option25 = pageSizeSelect.querySelector('[data-value="25"]')!;
|
|
74
74
|
|
|
@@ -78,45 +78,45 @@ describe('Pagination events', () => {
|
|
|
78
78
|
|
|
79
79
|
(currentPageInput as HTMLInputElement).focus();
|
|
80
80
|
|
|
81
|
-
userEvent.keyboard(
|
|
81
|
+
userEvent.keyboard("{backspace}{backspace}30{enter}");
|
|
82
82
|
|
|
83
83
|
await waitFor(() => expect(onPageChange).toHaveBeenCalledWith(30));
|
|
84
84
|
});
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
-
describe(
|
|
88
|
-
it(
|
|
87
|
+
describe("different current pages and their effect on what renders", () => {
|
|
88
|
+
it("is on the first page and does not render previous and first", () => {
|
|
89
89
|
const { pagination } = createPagination();
|
|
90
90
|
|
|
91
|
-
expect(pagination.querySelector(
|
|
92
|
-
expect(pagination.querySelector(
|
|
91
|
+
expect(pagination.querySelector(".next")).toBeTruthy();
|
|
92
|
+
expect(pagination.querySelector(".previous")).toBeFalsy();
|
|
93
93
|
});
|
|
94
94
|
|
|
95
|
-
it(
|
|
96
|
-
const { pagination } = createPagination(
|
|
95
|
+
it("is on the second page and does not render first", () => {
|
|
96
|
+
const { pagination } = createPagination(defaultParams => ({
|
|
97
97
|
...defaultParams,
|
|
98
|
-
currentPage: 2
|
|
98
|
+
currentPage: 2
|
|
99
99
|
}));
|
|
100
100
|
|
|
101
101
|
expect(pagination.querySelector('[data-paginate="first"]')).toBeFalsy();
|
|
102
|
-
expect((pagination.querySelector(
|
|
103
|
-
|
|
102
|
+
expect((pagination.querySelector(".current-value-input input") as HTMLInputElement).value).toBe(
|
|
103
|
+
"2"
|
|
104
104
|
);
|
|
105
105
|
});
|
|
106
106
|
|
|
107
|
-
it(
|
|
108
|
-
const { pagination } = createPagination(
|
|
107
|
+
it("is on the second to last page and does not render last", () => {
|
|
108
|
+
const { pagination } = createPagination(defaultParams => ({
|
|
109
109
|
...defaultParams,
|
|
110
|
-
currentPage: 499
|
|
110
|
+
currentPage: 499
|
|
111
111
|
}));
|
|
112
112
|
|
|
113
113
|
expect(pagination.querySelector('[data-paginate="last"]')).toBeFalsy();
|
|
114
114
|
});
|
|
115
115
|
|
|
116
|
-
it(
|
|
117
|
-
const { pagination } = createPagination(
|
|
116
|
+
it("is on the last page and does not render next & last", () => {
|
|
117
|
+
const { pagination } = createPagination(defaultParams => ({
|
|
118
118
|
...defaultParams,
|
|
119
|
-
currentPage: 500
|
|
119
|
+
currentPage: 500
|
|
120
120
|
}));
|
|
121
121
|
|
|
122
122
|
expect(pagination.querySelector('[data-paginate="last"]')).toBeFalsy();
|
|
@@ -124,35 +124,35 @@ describe('different current pages and their effect on what renders', () => {
|
|
|
124
124
|
});
|
|
125
125
|
});
|
|
126
126
|
|
|
127
|
-
describe(
|
|
127
|
+
describe("omitted attributes still renders correctly", () => {
|
|
128
128
|
it("still renders next if totalItems prop isn't given and we're on the first page", () => {
|
|
129
|
-
const { pagination } = createPagination(
|
|
129
|
+
const { pagination } = createPagination(defaultParams => ({
|
|
130
130
|
...defaultParams,
|
|
131
|
-
totalElements: undefined
|
|
131
|
+
totalElements: undefined
|
|
132
132
|
}));
|
|
133
133
|
|
|
134
|
-
expect(pagination.querySelector(
|
|
135
|
-
expect(pagination.querySelector(
|
|
136
|
-
expect(pagination.querySelector(
|
|
134
|
+
expect(pagination.querySelector(".page")).toBeFalsy();
|
|
135
|
+
expect(pagination.querySelector(".next")).toBeTruthy();
|
|
136
|
+
expect(pagination.querySelector(".previous")).toBeFalsy();
|
|
137
137
|
});
|
|
138
138
|
|
|
139
139
|
it("still renders next if totalItems prop isn't given and we're on the first page", () => {
|
|
140
|
-
const { pagination } = createPagination(
|
|
140
|
+
const { pagination } = createPagination(defaultParams => ({
|
|
141
141
|
...defaultParams,
|
|
142
142
|
currentPage: 4,
|
|
143
|
-
totalElements: undefined
|
|
143
|
+
totalElements: undefined
|
|
144
144
|
}));
|
|
145
145
|
|
|
146
|
-
expect(pagination.querySelector(
|
|
147
|
-
expect(pagination.querySelector(
|
|
148
|
-
expect(pagination.querySelector(
|
|
146
|
+
expect(pagination.querySelector(".page")).toBeFalsy();
|
|
147
|
+
expect(pagination.querySelector(".next")).toBeTruthy();
|
|
148
|
+
expect(pagination.querySelector(".previous")).toBeTruthy();
|
|
149
149
|
});
|
|
150
150
|
});
|
|
151
151
|
|
|
152
|
-
describe(
|
|
153
|
-
it(
|
|
152
|
+
describe("ref should work", () => {
|
|
153
|
+
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
154
154
|
const ExampleComponent = ({
|
|
155
|
-
propagateRef
|
|
155
|
+
propagateRef
|
|
156
156
|
}: {
|
|
157
157
|
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
158
158
|
}) => {
|
|
@@ -168,7 +168,7 @@ describe('ref should work', () => {
|
|
|
168
168
|
};
|
|
169
169
|
|
|
170
170
|
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
171
|
-
expect(ref.current).toHaveAttribute(
|
|
171
|
+
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
172
172
|
};
|
|
173
173
|
|
|
174
174
|
render(<ExampleComponent propagateRef={refCheck} />);
|