@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,6 +1,6 @@
|
|
|
1
|
-
import { Reducer } from
|
|
2
|
-
import { Step } from
|
|
3
|
-
import { WizardMode } from
|
|
1
|
+
import { Reducer } from "react";
|
|
2
|
+
import { Step } from "./BaseWizardSteps/BaseWizardSteps";
|
|
3
|
+
import { WizardMode } from "./Wizard";
|
|
4
4
|
|
|
5
5
|
type WizardStateType = {
|
|
6
6
|
steps: Step[];
|
|
@@ -10,7 +10,7 @@ type WizardStateType = {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
interface SetWizardStateAction {
|
|
13
|
-
type:
|
|
13
|
+
type: "SET_STATE";
|
|
14
14
|
payload: {
|
|
15
15
|
steps: Step[];
|
|
16
16
|
mode: WizardMode;
|
|
@@ -19,7 +19,7 @@ interface SetWizardStateAction {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
interface ChangeCurrentStepNoAction {
|
|
22
|
-
type:
|
|
22
|
+
type: "CHANGE_CURRENT_STEP_NO";
|
|
23
23
|
payload: number;
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -28,20 +28,20 @@ const setWizardState = (
|
|
|
28
28
|
mode: WizardMode,
|
|
29
29
|
stepScreenReaderLabel: string
|
|
30
30
|
): SetWizardStateAction => {
|
|
31
|
-
return { type:
|
|
31
|
+
return { type: "SET_STATE", payload: { steps, mode, stepScreenReaderLabel } };
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
const changeCurrentStepNo = (currentStepNo: number): ChangeCurrentStepNoAction => {
|
|
35
|
-
return { type:
|
|
35
|
+
return { type: "CHANGE_CURRENT_STEP_NO", payload: currentStepNo };
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
type WizardActions = SetWizardStateAction | ChangeCurrentStepNoAction;
|
|
39
39
|
|
|
40
40
|
const reducer: Reducer<WizardStateType, WizardActions> = (state, action) => {
|
|
41
41
|
switch (action.type) {
|
|
42
|
-
case
|
|
42
|
+
case "SET_STATE":
|
|
43
43
|
return { ...state, ...action.payload };
|
|
44
|
-
case
|
|
44
|
+
case "CHANGE_CURRENT_STEP_NO":
|
|
45
45
|
return { ...state, currentStepNo: action.payload };
|
|
46
46
|
default:
|
|
47
47
|
return state;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React, { Fragment } from
|
|
2
|
-
import { BaseStyling } from
|
|
3
|
-
import { Button } from
|
|
4
|
-
import { render } from
|
|
1
|
+
import React, { Fragment } from "react";
|
|
2
|
+
import { BaseStyling } from "./BaseStyling";
|
|
3
|
+
import { Button } from "../Button/Button";
|
|
4
|
+
import { render } from "@testing-library/react";
|
|
5
5
|
|
|
6
|
-
describe(
|
|
7
|
-
it(
|
|
6
|
+
describe("BaseStyling should render", () => {
|
|
7
|
+
it("renders without crashing", async () => {
|
|
8
8
|
const { container, findByTestId } = render(
|
|
9
9
|
<Fragment>
|
|
10
10
|
<BaseStyling>
|
|
@@ -13,19 +13,19 @@ describe('BaseStyling should render', () => {
|
|
|
13
13
|
</Fragment>
|
|
14
14
|
);
|
|
15
15
|
|
|
16
|
-
const button = await findByTestId(
|
|
17
|
-
expect(button).toHaveStyle({ backgroundColor:
|
|
18
|
-
expect(container.querySelector(
|
|
16
|
+
const button = await findByTestId("button");
|
|
17
|
+
expect(button).toHaveStyle({ backgroundColor: "rgb(158, 0, 107);" });
|
|
18
|
+
expect(container.querySelector("#child")).toBeDefined();
|
|
19
19
|
});
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
describe(
|
|
23
|
-
it(
|
|
22
|
+
describe("Should override default color", () => {
|
|
23
|
+
it("overrides primary color", async () => {
|
|
24
24
|
const { findByTestId } = render(
|
|
25
25
|
<Fragment>
|
|
26
26
|
<BaseStyling
|
|
27
27
|
properties={{
|
|
28
|
-
colorPrimary:
|
|
28
|
+
colorPrimary: "rgb(255, 255, 255);"
|
|
29
29
|
}}
|
|
30
30
|
>
|
|
31
31
|
<Button data-testid="button">Test</Button>
|
|
@@ -33,7 +33,7 @@ describe('Should override default color', () => {
|
|
|
33
33
|
</Fragment>
|
|
34
34
|
);
|
|
35
35
|
|
|
36
|
-
const button = await findByTestId(
|
|
37
|
-
expect(button).toHaveStyle({ backgroundColor:
|
|
36
|
+
const button = await findByTestId("button");
|
|
37
|
+
expect(button).toHaveStyle({ backgroundColor: "rgb(255, 255, 255);" });
|
|
38
38
|
});
|
|
39
39
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { Fragment, HTMLAttributes, ReactChild, useEffect, useState } from
|
|
1
|
+
import React, { Fragment, HTMLAttributes, ReactChild, useEffect, useState } from "react";
|
|
2
2
|
|
|
3
3
|
interface CSSProperties {
|
|
4
4
|
colorFocus?: string;
|
|
@@ -60,56 +60,56 @@ export interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
|
60
60
|
|
|
61
61
|
export const BaseStyling = ({ children, properties = {} }: Props) => {
|
|
62
62
|
const defaultProperties: CSSProperties = {
|
|
63
|
-
colorFocus:
|
|
64
|
-
colorPrimary:
|
|
65
|
-
colorSecondary:
|
|
66
|
-
colorTertiary:
|
|
67
|
-
defaultLineHeight:
|
|
68
|
-
buttonBorderRadius:
|
|
69
|
-
buttonBorderWidth:
|
|
70
|
-
buttonFontSize:
|
|
71
|
-
buttonBorderStyle:
|
|
72
|
-
buttonFillTextColor:
|
|
73
|
-
buttonFillBackgroundColor:
|
|
74
|
-
buttonOutlineHoverTextColor:
|
|
75
|
-
inputBorderColor:
|
|
76
|
-
inputBorderRadius:
|
|
77
|
-
inputBorderWidth:
|
|
78
|
-
inputBorderWidthFocus:
|
|
79
|
-
inputBorderStyle:
|
|
80
|
-
inputBackgroundColor:
|
|
81
|
-
modalShadowColor:
|
|
82
|
-
modalBackgroundColor:
|
|
83
|
-
modalHeaderBackgroundColor:
|
|
84
|
-
snackbarTextColor:
|
|
85
|
-
snackbarInfoBackgroundColor:
|
|
86
|
-
snackbarSuccessBackgroundColor:
|
|
87
|
-
snackbarErrorBackgroundColor:
|
|
88
|
-
snackbarBorderRadius:
|
|
89
|
-
dataGridRowBackgroundColor:
|
|
90
|
-
dataGridRowHoverBackgroundColor:
|
|
91
|
-
tabsBackgroundColor:
|
|
92
|
-
tabBorderWidth:
|
|
93
|
-
tabBorderStyle:
|
|
94
|
-
tablistBorderWidth:
|
|
95
|
-
tablistBorderStyle:
|
|
96
|
-
tablistBorderColor:
|
|
97
|
-
tabTextColor:
|
|
98
|
-
default:
|
|
99
|
-
success:
|
|
100
|
-
error:
|
|
101
|
-
disabled:
|
|
102
|
-
greyedOut:
|
|
103
|
-
warning:
|
|
63
|
+
colorFocus: "#0085f2",
|
|
64
|
+
colorPrimary: "#9e006b",
|
|
65
|
+
colorSecondary: "#003b5e",
|
|
66
|
+
colorTertiary: "#ff1e4e",
|
|
67
|
+
defaultLineHeight: "26px",
|
|
68
|
+
buttonBorderRadius: "20px",
|
|
69
|
+
buttonBorderWidth: "2px",
|
|
70
|
+
buttonFontSize: "1rem",
|
|
71
|
+
buttonBorderStyle: "solid",
|
|
72
|
+
buttonFillTextColor: "#fff",
|
|
73
|
+
buttonFillBackgroundColor: "#fff",
|
|
74
|
+
buttonOutlineHoverTextColor: "#fff",
|
|
75
|
+
inputBorderColor: "#e9e9eb",
|
|
76
|
+
inputBorderRadius: "8px",
|
|
77
|
+
inputBorderWidth: "1px",
|
|
78
|
+
inputBorderWidthFocus: "2px",
|
|
79
|
+
inputBorderStyle: "solid",
|
|
80
|
+
inputBackgroundColor: "#fff",
|
|
81
|
+
modalShadowColor: "rgba(0, 0, 0, 0.16)",
|
|
82
|
+
modalBackgroundColor: "#f5f8f8",
|
|
83
|
+
modalHeaderBackgroundColor: "#fff",
|
|
84
|
+
snackbarTextColor: "#fff",
|
|
85
|
+
snackbarInfoBackgroundColor: "#003b5e",
|
|
86
|
+
snackbarSuccessBackgroundColor: "#008a28",
|
|
87
|
+
snackbarErrorBackgroundColor: "#d9291c",
|
|
88
|
+
snackbarBorderRadius: "8px",
|
|
89
|
+
dataGridRowBackgroundColor: "transparent",
|
|
90
|
+
dataGridRowHoverBackgroundColor: "#f5e6f0",
|
|
91
|
+
tabsBackgroundColor: "#FFF",
|
|
92
|
+
tabBorderWidth: "2px",
|
|
93
|
+
tabBorderStyle: "solid",
|
|
94
|
+
tablistBorderWidth: "1px",
|
|
95
|
+
tablistBorderStyle: "solid",
|
|
96
|
+
tablistBorderColor: "#C3C3C7",
|
|
97
|
+
tabTextColor: "#0f0f1e",
|
|
98
|
+
default: "#0f0f1e",
|
|
99
|
+
success: "#008a28",
|
|
100
|
+
error: "#d9291c",
|
|
101
|
+
disabled: "#e9e9eb",
|
|
102
|
+
greyedOut: "#6f6f76",
|
|
103
|
+
warning: "#ff6105",
|
|
104
104
|
fontFamily: "'Red Hat Display', sans-serif",
|
|
105
105
|
fontFamilyCode: "'Red Hat Mono', sans-serif",
|
|
106
|
-
fontSize:
|
|
107
|
-
fontSizeH1:
|
|
108
|
-
fontSizeH2:
|
|
109
|
-
fontSizeH3:
|
|
110
|
-
fontSizeH4:
|
|
111
|
-
fontSizeSub:
|
|
112
|
-
fontSizeCode:
|
|
106
|
+
fontSize: "1rem",
|
|
107
|
+
fontSizeH1: "2.5rem",
|
|
108
|
+
fontSizeH2: "1.625rem",
|
|
109
|
+
fontSizeH3: "1.5rem",
|
|
110
|
+
fontSizeH4: "1.25rem",
|
|
111
|
+
fontSizeSub: ".75rem",
|
|
112
|
+
fontSizeCode: "1rem"
|
|
113
113
|
};
|
|
114
114
|
|
|
115
115
|
/** We need a loading state, because otherwise you see the colors flash from the default to the possible overridden ones. */
|
|
@@ -118,7 +118,7 @@ export const BaseStyling = ({ children, properties = {} }: Props) => {
|
|
|
118
118
|
/** Set the actual CSS properties on the HTML :root object */
|
|
119
119
|
const setCSSProperties = (CSSPropertiesObject: CSSProperties) => {
|
|
120
120
|
for (const [key, value] of Object.entries(CSSPropertiesObject)) {
|
|
121
|
-
const formattedPropertyName = key.replace(/([A-Z])/g,
|
|
121
|
+
const formattedPropertyName = key.replace(/([A-Z])/g, val => `-${val.toLowerCase()}`);
|
|
122
122
|
document.documentElement.style.setProperty(`--${formattedPropertyName}`, value);
|
|
123
123
|
}
|
|
124
124
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React, { Fragment } from
|
|
2
|
-
import { render, fireEvent } from
|
|
3
|
-
import userEvent from
|
|
4
|
-
import { useAnimation } from
|
|
1
|
+
import React, { Fragment } from "react";
|
|
2
|
+
import { render, fireEvent } from "@testing-library/react";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
import { useAnimation } from "./useAnimation";
|
|
5
5
|
|
|
6
|
-
describe(
|
|
7
|
-
it(
|
|
6
|
+
describe("useAnimation", () => {
|
|
7
|
+
it("should execute", () => {
|
|
8
8
|
const callback = jest.fn();
|
|
9
9
|
|
|
10
10
|
const Component = () => {
|
|
@@ -18,7 +18,7 @@ describe('useAnimation', () => {
|
|
|
18
18
|
<div
|
|
19
19
|
data-testid="animated-div"
|
|
20
20
|
ref={ref}
|
|
21
|
-
className={animationStarted ?
|
|
21
|
+
className={animationStarted ? "animation-started" : ""}
|
|
22
22
|
>
|
|
23
23
|
animated div
|
|
24
24
|
</div>
|
|
@@ -28,18 +28,18 @@ describe('useAnimation', () => {
|
|
|
28
28
|
|
|
29
29
|
const { getByTestId } = render(<Component />);
|
|
30
30
|
|
|
31
|
-
const animatedDiv = getByTestId(
|
|
32
|
-
const startButton = getByTestId(
|
|
31
|
+
const animatedDiv = getByTestId("animated-div");
|
|
32
|
+
const startButton = getByTestId("button");
|
|
33
33
|
|
|
34
|
-
expect(animatedDiv).not.toHaveClass(
|
|
34
|
+
expect(animatedDiv).not.toHaveClass("animation-started");
|
|
35
35
|
expect(callback).not.toBeCalled();
|
|
36
36
|
|
|
37
37
|
userEvent.click(startButton);
|
|
38
|
-
expect(animatedDiv).toHaveClass(
|
|
38
|
+
expect(animatedDiv).toHaveClass("animation-started");
|
|
39
39
|
expect(callback).not.toBeCalled();
|
|
40
40
|
|
|
41
41
|
fireEvent.animationEnd(animatedDiv);
|
|
42
|
-
expect(animatedDiv).toHaveClass(
|
|
42
|
+
expect(animatedDiv).toHaveClass("animation-started");
|
|
43
43
|
expect(callback).toBeCalled();
|
|
44
44
|
});
|
|
45
45
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
2
|
|
|
3
3
|
export const useAnimation = <RefElement extends HTMLElement>(callback: () => void) => {
|
|
4
4
|
const animatedObjectRef = useRef<RefElement>(null);
|
|
@@ -8,13 +8,13 @@ export const useAnimation = <RefElement extends HTMLElement>(callback: () => voi
|
|
|
8
8
|
const onAnimationEnd = () => animationStarted && callback();
|
|
9
9
|
|
|
10
10
|
useEffect(() => {
|
|
11
|
-
animatedObjectRef.current?.addEventListener(
|
|
12
|
-
return () => animatedObjectRef.current?.removeEventListener(
|
|
11
|
+
animatedObjectRef.current?.addEventListener("animationend", onAnimationEnd);
|
|
12
|
+
return () => animatedObjectRef.current?.removeEventListener("animationend", onAnimationEnd);
|
|
13
13
|
}, [animationStarted]);
|
|
14
14
|
|
|
15
15
|
return {
|
|
16
16
|
ref: animatedObjectRef,
|
|
17
17
|
animationStarted,
|
|
18
|
-
startAnimation: () => setAnimationStarted(true)
|
|
18
|
+
startAnimation: () => setAnimationStarted(true)
|
|
19
19
|
};
|
|
20
20
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React, { Fragment, useState } from
|
|
2
|
-
import { useBodyClick } from
|
|
3
|
-
import { render } from
|
|
4
|
-
import userEvent from
|
|
1
|
+
import React, { Fragment, useState } from "react";
|
|
2
|
+
import { useBodyClick } from "./useBodyClick";
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
|
+
import userEvent from "@testing-library/user-event";
|
|
5
5
|
|
|
6
|
-
describe(
|
|
7
|
-
it(
|
|
6
|
+
describe("function should be executed", () => {
|
|
7
|
+
it("should execute", () => {
|
|
8
8
|
const clickHandler = jest.fn();
|
|
9
9
|
const validateFunction = jest.fn(() => true);
|
|
10
10
|
|
|
@@ -27,8 +27,8 @@ describe('function should be executed', () => {
|
|
|
27
27
|
|
|
28
28
|
const { getByTestId } = render(<Component></Component>);
|
|
29
29
|
|
|
30
|
-
const button1 = getByTestId(
|
|
31
|
-
const button2 = getByTestId(
|
|
30
|
+
const button1 = getByTestId("button1");
|
|
31
|
+
const button2 = getByTestId("button2");
|
|
32
32
|
|
|
33
33
|
userEvent.click(button1);
|
|
34
34
|
userEvent.click(button2);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect } from
|
|
1
|
+
import { useEffect } from "react";
|
|
2
2
|
|
|
3
3
|
export const useBodyClick = (
|
|
4
4
|
checkFunction: (event: MouseEvent) => boolean,
|
|
@@ -11,10 +11,10 @@ export const useBodyClick = (
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
useEffect(() => {
|
|
14
|
-
window.addEventListener(
|
|
14
|
+
window.addEventListener("click", bodyClickListener);
|
|
15
15
|
|
|
16
16
|
return () => {
|
|
17
|
-
window.removeEventListener(
|
|
17
|
+
window.removeEventListener("click", bodyClickListener);
|
|
18
18
|
};
|
|
19
19
|
}, [dependingStateVariable]);
|
|
20
20
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { useFormSelector } from
|
|
2
|
-
import { renderHook } from
|
|
1
|
+
import { useFormSelector } from "./useFormSelector";
|
|
2
|
+
import { renderHook } from "@testing-library/react-hooks";
|
|
3
3
|
|
|
4
|
-
describe(
|
|
5
|
-
it(
|
|
4
|
+
describe("we should get the correct return values and describedBy is the same as identifier", () => {
|
|
5
|
+
it("should return correct values", () => {
|
|
6
6
|
const { result } = renderHook(() =>
|
|
7
7
|
useFormSelector({
|
|
8
|
-
name:
|
|
9
|
-
errorMessage:
|
|
8
|
+
name: "test",
|
|
9
|
+
errorMessage: "errormessage",
|
|
10
10
|
error: false,
|
|
11
|
-
parentErrorId:
|
|
12
|
-
helperText:
|
|
13
|
-
parentHelperId:
|
|
11
|
+
parentErrorId: "parenterrorid",
|
|
12
|
+
helperText: "helpertext",
|
|
13
|
+
parentHelperId: "parenthelperid"
|
|
14
14
|
})
|
|
15
15
|
);
|
|
16
16
|
|
|
@@ -22,19 +22,19 @@ describe('we should get the correct return values and describedBy is the same as
|
|
|
22
22
|
});
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
describe(
|
|
26
|
-
it(
|
|
25
|
+
describe("describedBy should be the parenterrorid", () => {
|
|
26
|
+
it("should be linked correctly", () => {
|
|
27
27
|
const { result } = renderHook(() =>
|
|
28
28
|
useFormSelector({
|
|
29
|
-
name:
|
|
30
|
-
errorMessage:
|
|
29
|
+
name: "test",
|
|
30
|
+
errorMessage: "errormessage",
|
|
31
31
|
error: true,
|
|
32
|
-
parentErrorId:
|
|
33
|
-
helperText:
|
|
34
|
-
parentHelperId:
|
|
32
|
+
parentErrorId: "parenterrorid",
|
|
33
|
+
helperText: "helpertext",
|
|
34
|
+
parentHelperId: "parenthelperid"
|
|
35
35
|
})
|
|
36
36
|
);
|
|
37
37
|
|
|
38
|
-
expect(result.current.describedBy).toBe(
|
|
38
|
+
expect(result.current.describedBy).toBe("parenterrorid");
|
|
39
39
|
});
|
|
40
40
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useEffect, useState } from
|
|
2
|
-
import { generateID } from
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { generateID } from "../util/helper";
|
|
3
3
|
|
|
4
4
|
export interface ConfigObject {
|
|
5
5
|
name: string | undefined;
|
|
@@ -12,7 +12,7 @@ export interface ConfigObject {
|
|
|
12
12
|
|
|
13
13
|
export const useFormSelector = (configObject: ConfigObject) => {
|
|
14
14
|
const [identifier] = useState(generateID(15, configObject.name));
|
|
15
|
-
const [describedBy, setDescribedBy] = useState(
|
|
15
|
+
const [describedBy, setDescribedBy] = useState("");
|
|
16
16
|
const [errorId] = useState(generateID(15, configObject.errorMessage));
|
|
17
17
|
|
|
18
18
|
useEffect(() => {
|
|
@@ -42,6 +42,6 @@ export const useFormSelector = (configObject: ConfigObject) => {
|
|
|
42
42
|
return {
|
|
43
43
|
describedBy,
|
|
44
44
|
errorId,
|
|
45
|
-
identifier
|
|
45
|
+
identifier
|
|
46
46
|
};
|
|
47
47
|
};
|