@onewelcome/react-lib-components 0.2.1 → 0.2.2
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 +672 -576
- 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 +672 -576
- 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 +81 -76
- package/src/ContextMenu/ContextMenu.tsx +43 -41
- package/src/ContextMenu/ContextMenuItem.module.scss +1 -1
- package/src/ContextMenu/ContextMenuItem.tsx +5 -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 +86 -59
- 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 +10 -10
- package/src/index.ts +67 -67
- package/src/mixins.module.scss +76 -27
- package/src/types.d.ts +1 -1
- package/src/util/helper.test.tsx +25 -25
- package/src/util/helper.tsx +64 -64
package/src/Form/Input/Input.tsx
CHANGED
|
@@ -1,31 +1,69 @@
|
|
|
1
|
-
import React, { ComponentPropsWithRef, Ref, useEffect, useState } from
|
|
2
|
-
import classes from
|
|
3
|
-
import readyclasses from
|
|
4
|
-
import { Icon, Icons } from
|
|
5
|
-
import { FormElement } from
|
|
1
|
+
import React, { ComponentPropsWithRef, Ref, useEffect, useRef, useState } from "react";
|
|
2
|
+
import classes from "./Input.module.scss";
|
|
3
|
+
import readyclasses from "../../readyclasses.module.scss";
|
|
4
|
+
import { Icon, Icons } from "../../Icon/Icon";
|
|
5
|
+
import { FormElement } from "../form.interfaces";
|
|
6
6
|
|
|
7
|
-
const dateTypes = [
|
|
7
|
+
const dateTypes = ["date", "time", "datetime-local"] as const;
|
|
8
8
|
|
|
9
9
|
export type Type =
|
|
10
|
-
|
|
|
11
|
-
|
|
|
12
|
-
|
|
|
13
|
-
|
|
|
14
|
-
|
|
|
15
|
-
|
|
|
16
|
-
|
|
|
17
|
-
|
|
|
18
|
-
|
|
|
10
|
+
| "text"
|
|
11
|
+
| "email"
|
|
12
|
+
| "file"
|
|
13
|
+
| "number"
|
|
14
|
+
| "password"
|
|
15
|
+
| "search"
|
|
16
|
+
| "tel"
|
|
17
|
+
| "url"
|
|
18
|
+
| "hidden"
|
|
19
19
|
| typeof dateTypes[number];
|
|
20
20
|
|
|
21
|
-
export interface Props extends ComponentPropsWithRef<
|
|
22
|
-
wrapperProps?: ComponentPropsWithRef<
|
|
21
|
+
export interface Props extends ComponentPropsWithRef<"input">, FormElement {
|
|
22
|
+
wrapperProps?: ComponentPropsWithRef<"div">;
|
|
23
23
|
labeledBy?: string;
|
|
24
24
|
type: Type;
|
|
25
25
|
suffix?: string;
|
|
26
26
|
prefix?: string;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
const useErrorOffset = (
|
|
30
|
+
suffix: React.RefObject<HTMLDivElement>,
|
|
31
|
+
errorIcon: React.RefObject<HTMLDivElement>,
|
|
32
|
+
inputWrapper: React.RefObject<HTMLDivElement>,
|
|
33
|
+
error: boolean,
|
|
34
|
+
type: Type,
|
|
35
|
+
suffixContent: string = ""
|
|
36
|
+
) => {
|
|
37
|
+
const [errorOffset, setErrorOffset] = useState({});
|
|
38
|
+
const [defaultErrorOffset, setDefaultErrorOffset] = useState<number | null>(null);
|
|
39
|
+
|
|
40
|
+
const getErrorIconOffset = () => parseFloat(getComputedStyle(errorIcon.current!).right);
|
|
41
|
+
const getInputPaddingRight = (input: HTMLDivElement) =>
|
|
42
|
+
(dateTypes as ReadonlyArray<string>).includes(type)
|
|
43
|
+
? 0
|
|
44
|
+
: parseFloat(getComputedStyle(input).paddingRight);
|
|
45
|
+
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (errorIcon.current && inputWrapper.current) {
|
|
48
|
+
let defaultOffset = defaultErrorOffset;
|
|
49
|
+
if (!defaultOffset) {
|
|
50
|
+
defaultOffset = getErrorIconOffset();
|
|
51
|
+
setDefaultErrorOffset(defaultOffset);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (suffix.current && suffixContent) {
|
|
55
|
+
const inputPaddingRight = getInputPaddingRight(inputWrapper.current);
|
|
56
|
+
const prefixDifference = suffix.current.offsetWidth + inputPaddingRight + defaultOffset;
|
|
57
|
+
setErrorOffset({ right: `${prefixDifference}px` });
|
|
58
|
+
} else {
|
|
59
|
+
setErrorOffset({ right: `${defaultOffset}px` });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}, [suffix.current, errorIcon.current, inputWrapper.current, error, type, suffixContent]);
|
|
63
|
+
|
|
64
|
+
return { errorOffset };
|
|
65
|
+
};
|
|
66
|
+
|
|
29
67
|
export const Input = React.forwardRef(
|
|
30
68
|
(
|
|
31
69
|
{
|
|
@@ -46,6 +84,17 @@ export const Input = React.forwardRef(
|
|
|
46
84
|
ref: Ref<HTMLInputElement>
|
|
47
85
|
) => {
|
|
48
86
|
const [focus, setFocus] = useState(false);
|
|
87
|
+
const inputWrapperRef = useRef<HTMLDivElement>(null);
|
|
88
|
+
const errorIconRef = useRef<HTMLDivElement>(null);
|
|
89
|
+
const suffixRef = useRef<HTMLDivElement>(null);
|
|
90
|
+
const { errorOffset } = useErrorOffset(
|
|
91
|
+
suffixRef,
|
|
92
|
+
errorIconRef,
|
|
93
|
+
inputWrapperRef,
|
|
94
|
+
error,
|
|
95
|
+
type,
|
|
96
|
+
suffix
|
|
97
|
+
);
|
|
49
98
|
|
|
50
99
|
useEffect(() => {
|
|
51
100
|
if (name === undefined) {
|
|
@@ -53,45 +102,49 @@ export const Input = React.forwardRef(
|
|
|
53
102
|
}
|
|
54
103
|
}, []);
|
|
55
104
|
|
|
56
|
-
const inputClassNames = [classes[
|
|
105
|
+
const inputClassNames = [classes["input"]];
|
|
57
106
|
|
|
58
107
|
(dateTypes as ReadonlyArray<string>).includes(type) &&
|
|
59
|
-
inputClassNames.push(classes[
|
|
108
|
+
inputClassNames.push(classes["remove-extra-indent"]);
|
|
60
109
|
className && inputClassNames.push(className);
|
|
61
110
|
|
|
62
|
-
const iconClassNames = [classes[
|
|
111
|
+
const iconClassNames = [classes["warning"]];
|
|
63
112
|
(dateTypes as ReadonlyArray<string>).includes(type) &&
|
|
64
|
-
iconClassNames.push(classes[
|
|
113
|
+
iconClassNames.push(classes["extra-indent"]);
|
|
65
114
|
|
|
66
|
-
const wrapperClasses = [classes[
|
|
115
|
+
const wrapperClasses = [classes["input-wrapper"]];
|
|
116
|
+
const outlineClasses = [classes["outline"]];
|
|
67
117
|
|
|
68
118
|
wrapperProps?.className && wrapperClasses.push(wrapperProps.className);
|
|
69
|
-
type ===
|
|
70
|
-
prefix && wrapperClasses.push(classes[
|
|
71
|
-
suffix && wrapperClasses.push(classes[
|
|
72
|
-
disabled &&
|
|
73
|
-
|
|
74
|
-
|
|
119
|
+
type === "hidden" && wrapperClasses.push(readyclasses["hidden"]);
|
|
120
|
+
prefix && wrapperClasses.push(classes["prefix"]);
|
|
121
|
+
suffix && wrapperClasses.push(classes["suffix"]);
|
|
122
|
+
disabled &&
|
|
123
|
+
wrapperClasses.push(classes["disabled"]) &&
|
|
124
|
+
outlineClasses.push(classes["disabled"]);
|
|
125
|
+
error && wrapperClasses.push(classes["error"]) && outlineClasses.push(classes["error"]);
|
|
126
|
+
focus && wrapperClasses.push(classes["focus"]) && outlineClasses.push(classes["focus"]);
|
|
75
127
|
|
|
76
128
|
return (
|
|
77
129
|
<div
|
|
130
|
+
ref={inputWrapperRef}
|
|
78
131
|
{...wrapperProps}
|
|
79
132
|
style={{ ...style }}
|
|
80
|
-
className={`${classes[
|
|
133
|
+
className={`${classes["input-wrapper"]} ${wrapperClasses.join(" ")}`}
|
|
81
134
|
>
|
|
82
135
|
{prefix && (
|
|
83
|
-
<div data-prefix className={classes[
|
|
136
|
+
<div data-prefix className={classes["prefix"]}>
|
|
84
137
|
<span>{prefix}</span>
|
|
85
138
|
</div>
|
|
86
139
|
)}
|
|
87
140
|
<input
|
|
88
141
|
{...rest}
|
|
89
142
|
ref={ref}
|
|
90
|
-
onFocus={
|
|
143
|
+
onFocus={event => {
|
|
91
144
|
setFocus(true);
|
|
92
145
|
onFocus && onFocus(event);
|
|
93
146
|
}}
|
|
94
|
-
onBlur={
|
|
147
|
+
onBlur={event => {
|
|
95
148
|
setFocus(false);
|
|
96
149
|
onBlur && onBlur(event);
|
|
97
150
|
}}
|
|
@@ -99,14 +152,22 @@ export const Input = React.forwardRef(
|
|
|
99
152
|
type={type}
|
|
100
153
|
name={name}
|
|
101
154
|
disabled={disabled}
|
|
102
|
-
className={inputClassNames.join(
|
|
155
|
+
className={inputClassNames.join(" ")}
|
|
103
156
|
/>
|
|
104
157
|
{suffix && (
|
|
105
|
-
<div data-suffix className={classes[
|
|
158
|
+
<div ref={suffixRef} data-suffix className={classes["suffix"]}>
|
|
106
159
|
<span>{suffix}</span>
|
|
107
160
|
</div>
|
|
108
161
|
)}
|
|
109
|
-
{error &&
|
|
162
|
+
{error && (
|
|
163
|
+
<Icon
|
|
164
|
+
style={errorOffset}
|
|
165
|
+
ref={errorIconRef}
|
|
166
|
+
className={iconClassNames.join(" ")}
|
|
167
|
+
icon={Icons.Error}
|
|
168
|
+
/>
|
|
169
|
+
)}
|
|
170
|
+
<span className={outlineClasses.join(" ")}></span>
|
|
110
171
|
</div>
|
|
111
172
|
);
|
|
112
173
|
}
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from
|
|
2
|
-
import { Label } from
|
|
3
|
-
import { render } from
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
|
+
import { Label } from "./Label";
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
4
|
|
|
5
|
-
describe(
|
|
6
|
-
it(
|
|
5
|
+
describe("Label should render", () => {
|
|
6
|
+
it("renders without crashing", () => {
|
|
7
7
|
const { getByTestId } = render(
|
|
8
8
|
<Label htmlFor="input-name" data-testid="component">
|
|
9
9
|
Label
|
|
10
10
|
</Label>
|
|
11
11
|
);
|
|
12
|
-
const component = getByTestId(
|
|
12
|
+
const component = getByTestId("component");
|
|
13
13
|
expect(component).toBeDefined();
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
it(
|
|
16
|
+
it("adds htmlFor attribute", () => {
|
|
17
17
|
const { getByTestId } = render(
|
|
18
18
|
<Label htmlFor="input-name" data-testid="component">
|
|
19
19
|
Label
|
|
20
20
|
</Label>
|
|
21
21
|
);
|
|
22
22
|
|
|
23
|
-
const component = getByTestId(
|
|
24
|
-
expect(component.getAttribute(
|
|
23
|
+
const component = getByTestId("component");
|
|
24
|
+
expect(component.getAttribute("for")).toBe("input-name");
|
|
25
25
|
});
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
describe(
|
|
29
|
-
it(
|
|
28
|
+
describe("ref should work", () => {
|
|
29
|
+
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
30
30
|
const ExampleComponent = ({
|
|
31
|
-
propagateRef
|
|
31
|
+
propagateRef
|
|
32
32
|
}: {
|
|
33
33
|
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
34
34
|
}) => {
|
|
@@ -44,7 +44,7 @@ describe('ref should work', () => {
|
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
47
|
-
expect(ref.current).toHaveAttribute(
|
|
47
|
+
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
render(<ExampleComponent propagateRef={refCheck} />);
|
package/src/Form/Label/Label.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React, { ComponentPropsWithRef, ReactNode } from
|
|
2
|
-
import classes from
|
|
3
|
-
import readyclasses from
|
|
1
|
+
import React, { ComponentPropsWithRef, ReactNode } from "react";
|
|
2
|
+
import classes from "./Label.module.scss";
|
|
3
|
+
import readyclasses from "../../readyclasses.module.scss";
|
|
4
4
|
|
|
5
|
-
export interface Props extends ComponentPropsWithRef<
|
|
5
|
+
export interface Props extends ComponentPropsWithRef<"label"> {
|
|
6
6
|
children?: ReactNode;
|
|
7
7
|
}
|
|
8
8
|
|
|
@@ -12,8 +12,8 @@ export const Label = React.forwardRef<HTMLLabelElement, Props>(
|
|
|
12
12
|
<label
|
|
13
13
|
{...rest}
|
|
14
14
|
ref={ref}
|
|
15
|
-
className={`${hidden ? readyclasses[
|
|
16
|
-
className ??
|
|
15
|
+
className={`${hidden ? readyclasses["sr-only"] : ""} ${classes["label"]} ${
|
|
16
|
+
className ?? ""
|
|
17
17
|
}`}
|
|
18
18
|
>
|
|
19
19
|
{children}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from
|
|
2
|
-
import { Radio, Props } from
|
|
3
|
-
import { render } from
|
|
4
|
-
import userEvent from
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
|
+
import { Radio, Props } from "./Radio";
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
|
+
import userEvent from "@testing-library/user-event";
|
|
5
5
|
|
|
6
6
|
const onChangeHandeler = jest.fn();
|
|
7
7
|
|
|
8
8
|
const defaultParams: Props = {
|
|
9
|
-
value:
|
|
10
|
-
children:
|
|
9
|
+
value: "test",
|
|
10
|
+
children: "Label",
|
|
11
11
|
checked: false,
|
|
12
12
|
error: false,
|
|
13
|
-
errorMessage:
|
|
13
|
+
errorMessage: "errormessage",
|
|
14
14
|
disabled: false,
|
|
15
|
-
formSelectorWrapperProps: {
|
|
16
|
-
helperText:
|
|
17
|
-
onChange: onChangeHandeler
|
|
15
|
+
formSelectorWrapperProps: { "data-testid": "radiowrapper" },
|
|
16
|
+
helperText: "helpertext",
|
|
17
|
+
onChange: onChangeHandeler
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
const createRadio = (params?: (defaultParams: Props) => Props) => {
|
|
@@ -23,57 +23,57 @@ const createRadio = (params?: (defaultParams: Props) => Props) => {
|
|
|
23
23
|
parameters = params(defaultParams);
|
|
24
24
|
}
|
|
25
25
|
const queries = render(<Radio {...parameters} data-testid="radio" />);
|
|
26
|
-
const radio = queries.getByTestId(
|
|
27
|
-
const radiowrapper = queries.getByTestId(
|
|
26
|
+
const radio = queries.getByTestId("radio");
|
|
27
|
+
const radiowrapper = queries.getByTestId("radiowrapper");
|
|
28
28
|
|
|
29
29
|
return {
|
|
30
30
|
...queries,
|
|
31
31
|
radio,
|
|
32
|
-
radiowrapper
|
|
32
|
+
radiowrapper
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
describe(
|
|
37
|
-
it(
|
|
36
|
+
describe("Radio should render", () => {
|
|
37
|
+
it("renders without crashing and has proper attributes/values", () => {
|
|
38
38
|
const { radio } = createRadio();
|
|
39
39
|
|
|
40
|
-
expect((radio as HTMLInputElement).value).toBe(
|
|
40
|
+
expect((radio as HTMLInputElement).value).toBe("test");
|
|
41
41
|
expect((radio as HTMLInputElement).checked).toBe(false);
|
|
42
42
|
expect(radio).toBeTruthy();
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
it(
|
|
46
|
-
const { radio } = createRadio(
|
|
45
|
+
it("it is checked", () => {
|
|
46
|
+
const { radio } = createRadio(defaultParams => ({ ...defaultParams, checked: true }));
|
|
47
47
|
|
|
48
48
|
expect((radio as HTMLInputElement).checked).toBe(true);
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
it(
|
|
52
|
-
const { radio, radiowrapper } = createRadio(
|
|
51
|
+
it("it is disabled", () => {
|
|
52
|
+
const { radio, radiowrapper } = createRadio(defaultParams => ({
|
|
53
53
|
...defaultParams,
|
|
54
|
-
disabled: true
|
|
54
|
+
disabled: true
|
|
55
55
|
}));
|
|
56
56
|
|
|
57
57
|
expect((radio as HTMLInputElement).disabled).toBe(true);
|
|
58
|
-
expect(radiowrapper).toHaveClass(
|
|
58
|
+
expect(radiowrapper).toHaveClass("disabled");
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
-
it(
|
|
62
|
-
const { radio, findByText } = createRadio(
|
|
61
|
+
it("has the correct describedby value when theres no error", async () => {
|
|
62
|
+
const { radio, findByText } = createRadio(defaultParams => ({
|
|
63
63
|
...defaultParams,
|
|
64
|
-
error: true
|
|
64
|
+
error: true
|
|
65
65
|
}));
|
|
66
66
|
|
|
67
|
-
const error = await findByText(
|
|
67
|
+
const error = await findByText("errormessage");
|
|
68
68
|
|
|
69
|
-
expect(radio).toHaveAttribute(
|
|
69
|
+
expect(radio).toHaveAttribute("aria-describedby", error.id);
|
|
70
70
|
});
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
describe(
|
|
74
|
-
it(
|
|
73
|
+
describe("ref should work", () => {
|
|
74
|
+
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
75
75
|
const ExampleComponent = ({
|
|
76
|
-
propagateRef
|
|
76
|
+
propagateRef
|
|
77
77
|
}: {
|
|
78
78
|
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
79
79
|
}) => {
|
|
@@ -89,15 +89,15 @@ describe('ref should work', () => {
|
|
|
89
89
|
};
|
|
90
90
|
|
|
91
91
|
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
92
|
-
expect(ref.current).toHaveAttribute(
|
|
92
|
+
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
93
93
|
};
|
|
94
94
|
|
|
95
95
|
render(<ExampleComponent propagateRef={refCheck} />);
|
|
96
96
|
});
|
|
97
97
|
});
|
|
98
98
|
|
|
99
|
-
describe(
|
|
100
|
-
it(
|
|
99
|
+
describe("Radio should be interactive", () => {
|
|
100
|
+
it("should call onChange when clicked", () => {
|
|
101
101
|
const { radio } = createRadio();
|
|
102
102
|
|
|
103
103
|
expect(onChangeHandeler).not.toBeCalled();
|
|
@@ -105,8 +105,8 @@ describe('Radio should be interactive', () => {
|
|
|
105
105
|
expect(onChangeHandeler).toBeCalledTimes(1);
|
|
106
106
|
});
|
|
107
107
|
|
|
108
|
-
it(
|
|
109
|
-
const { radio } = createRadio(
|
|
108
|
+
it("should not call onChange when disabled", () => {
|
|
109
|
+
const { radio } = createRadio(defaultParams => ({ ...defaultParams, disabled: true }));
|
|
110
110
|
|
|
111
111
|
userEvent.click(radio);
|
|
112
112
|
expect(onChangeHandeler).not.toBeCalled();
|
package/src/Form/Radio/Radio.tsx
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import React, { ComponentPropsWithRef } from
|
|
2
|
-
import { Icon, Icons } from
|
|
3
|
-
import { Props as HelperProps } from
|
|
4
|
-
import classes from
|
|
5
|
-
import { useFormSelector } from
|
|
6
|
-
import { FormSelector } from
|
|
1
|
+
import React, { ComponentPropsWithRef } from "react";
|
|
2
|
+
import { Icon, Icons } from "../../Icon/Icon";
|
|
3
|
+
import { Props as HelperProps } from "../FormHelperText/FormHelperText";
|
|
4
|
+
import classes from "./Radio.module.scss";
|
|
5
|
+
import { useFormSelector } from "../../hooks/useFormSelector";
|
|
6
|
+
import { FormSelector } from "../form.interfaces";
|
|
7
7
|
import {
|
|
8
8
|
FormSelectorWrapper,
|
|
9
|
-
Props as FormSelectorWrapperProps
|
|
10
|
-
} from
|
|
9
|
+
Props as FormSelectorWrapperProps
|
|
10
|
+
} from "../FormSelectorWrapper/FormSelectorWrapper";
|
|
11
11
|
|
|
12
|
-
export interface Props extends ComponentPropsWithRef<
|
|
12
|
+
export interface Props extends ComponentPropsWithRef<"input">, FormSelector {
|
|
13
13
|
children: string;
|
|
14
14
|
value: string;
|
|
15
15
|
formSelectorWrapperProps?: FormSelectorWrapperProps;
|
|
@@ -43,7 +43,7 @@ export const Radio = React.forwardRef<HTMLInputElement, Props>(
|
|
|
43
43
|
parentErrorId,
|
|
44
44
|
errorMessage,
|
|
45
45
|
error,
|
|
46
|
-
parentHelperId
|
|
46
|
+
parentHelperId
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
const onChangeHandler = (event: React.ChangeEvent<HTMLInputElement> | React.MouseEvent) => {
|
|
@@ -54,9 +54,9 @@ export const Radio = React.forwardRef<HTMLInputElement, Props>(
|
|
|
54
54
|
const nativeEvent: any = event.nativeEvent || event;
|
|
55
55
|
const clonedEvent = new nativeEvent.constructor(nativeEvent.type, nativeEvent);
|
|
56
56
|
|
|
57
|
-
Object.defineProperty(clonedEvent,
|
|
57
|
+
Object.defineProperty(clonedEvent, "target", {
|
|
58
58
|
writable: true,
|
|
59
|
-
value: { value: value }
|
|
59
|
+
value: { value: value }
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
onChange && onChange(clonedEvent);
|
|
@@ -66,8 +66,8 @@ export const Radio = React.forwardRef<HTMLInputElement, Props>(
|
|
|
66
66
|
return (
|
|
67
67
|
<FormSelectorWrapper
|
|
68
68
|
{...formSelectorWrapperProps}
|
|
69
|
-
className={`${classes[
|
|
70
|
-
containerProps={{ className: classes[
|
|
69
|
+
className={`${classes["radio-wrapper"]} ${className ?? ""}`}
|
|
70
|
+
containerProps={{ className: classes["radio-container"] }}
|
|
71
71
|
helperText={helperText}
|
|
72
72
|
helperProps={helperProps}
|
|
73
73
|
parentErrorId={parentErrorId}
|
|
@@ -82,7 +82,7 @@ export const Radio = React.forwardRef<HTMLInputElement, Props>(
|
|
|
82
82
|
ref={ref}
|
|
83
83
|
disabled={disabled}
|
|
84
84
|
tabIndex={0}
|
|
85
|
-
className={`${classes[
|
|
85
|
+
className={`${classes["native-input"]} ${error ? classes["error"] : ""}`}
|
|
86
86
|
onChange={onChangeHandler}
|
|
87
87
|
checked={checked}
|
|
88
88
|
aria-invalid={error ? true : false}
|
|
@@ -96,13 +96,13 @@ export const Radio = React.forwardRef<HTMLInputElement, Props>(
|
|
|
96
96
|
|
|
97
97
|
{checked && (
|
|
98
98
|
<Icon
|
|
99
|
-
className={`${classes[
|
|
99
|
+
className={`${classes["input"]} ${disabled ? classes["disabled"] : ""}`}
|
|
100
100
|
icon={Icons.Radio}
|
|
101
101
|
/>
|
|
102
102
|
)}
|
|
103
103
|
{!checked && (
|
|
104
104
|
<Icon
|
|
105
|
-
className={`${classes[
|
|
105
|
+
className={`${classes["input"]} ${disabled ? classes["disabled"] : ""}`}
|
|
106
106
|
icon={Icons.Circle}
|
|
107
107
|
/>
|
|
108
108
|
)}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from
|
|
2
|
-
import { Option } from
|
|
3
|
-
import { render } from
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
|
+
import { Option } from "./Option";
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
4
|
|
|
5
|
-
describe(
|
|
6
|
-
it(
|
|
5
|
+
describe("Option should render", () => {
|
|
6
|
+
it("renders without crashing", () => {
|
|
7
7
|
const { getByTestId } = render(
|
|
8
8
|
<Option value="option" data-testid="component">
|
|
9
9
|
Option
|
|
10
10
|
</Option>
|
|
11
11
|
);
|
|
12
|
-
const component = getByTestId(
|
|
12
|
+
const component = getByTestId("component");
|
|
13
13
|
expect(component).toBeDefined();
|
|
14
14
|
});
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
describe(
|
|
18
|
-
it(
|
|
17
|
+
describe("ref should work", () => {
|
|
18
|
+
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
19
19
|
const ExampleComponent = ({
|
|
20
|
-
propagateRef
|
|
20
|
+
propagateRef
|
|
21
21
|
}: {
|
|
22
22
|
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
23
23
|
}) => {
|
|
@@ -33,7 +33,7 @@ describe('ref should work', () => {
|
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
36
|
-
expect(ref.current).toHaveAttribute(
|
|
36
|
+
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
render(<ExampleComponent propagateRef={refCheck} />);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React, { ComponentPropsWithRef, createRef, RefObject, useEffect } from
|
|
2
|
-
import classes from
|
|
1
|
+
import React, { ComponentPropsWithRef, createRef, RefObject, useEffect } from "react";
|
|
2
|
+
import classes from "./Select.module.scss";
|
|
3
3
|
|
|
4
|
-
export interface Props extends ComponentPropsWithRef<
|
|
4
|
+
export interface Props extends ComponentPropsWithRef<"li"> {
|
|
5
5
|
children: string;
|
|
6
6
|
value: string;
|
|
7
7
|
disabled?: boolean;
|
|
@@ -59,12 +59,12 @@ export const Option = React.forwardRef<HTMLLIElement, Props>(
|
|
|
59
59
|
{...rest}
|
|
60
60
|
ref={innerOptionRef}
|
|
61
61
|
data-value={value}
|
|
62
|
-
className={`${isSelected ? classes[
|
|
63
|
-
disabled ? classes.disabled :
|
|
64
|
-
} ${className ??
|
|
62
|
+
className={`${isSelected ? classes["selected-option"] : ""} ${
|
|
63
|
+
disabled ? classes.disabled : ""
|
|
64
|
+
} ${className ?? ""}`}
|
|
65
65
|
onClick={onSelectHandler}
|
|
66
|
-
onKeyDownCapture={
|
|
67
|
-
if (event.code ===
|
|
66
|
+
onKeyDownCapture={event => {
|
|
67
|
+
if (event.code === "Enter") {
|
|
68
68
|
event.stopPropagation();
|
|
69
69
|
event.preventDefault();
|
|
70
70
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@import
|
|
1
|
+
@import "../../readyclasses.module.scss";
|
|
2
2
|
|
|
3
3
|
$listItemHeight: 2.125rem;
|
|
4
4
|
|
|
@@ -6,7 +6,9 @@ $listItemHeight: 2.125rem;
|
|
|
6
6
|
position: relative;
|
|
7
7
|
box-sizing: border-box;
|
|
8
8
|
transition: all 0.2s ease-in-out;
|
|
9
|
-
|
|
9
|
+
border: 0;
|
|
10
|
+
border-radius: var(--input-border-radius);
|
|
11
|
+
background-color: var(--input-background-color);
|
|
10
12
|
font-size: var(--font-size);
|
|
11
13
|
|
|
12
14
|
[data-display] {
|
|
@@ -18,14 +20,13 @@ $listItemHeight: 2.125rem;
|
|
|
18
20
|
|
|
19
21
|
.list-wrapper {
|
|
20
22
|
background: #fff;
|
|
21
|
-
opacity: 1;
|
|
22
|
-
pointer-events: auto;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
&:not(.expanded) {
|
|
27
27
|
button:focus-visible:not(.error) {
|
|
28
28
|
border: var(--input-border-width-focus) solid var(--color-primary);
|
|
29
|
+
padding: 0 calc(1.25rem - var(--input-border-width-focus) + var(--input-border-width));
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
|
|
@@ -76,8 +77,6 @@ $listItemHeight: 2.125rem;
|
|
|
76
77
|
top: 0;
|
|
77
78
|
left: 0;
|
|
78
79
|
width: 100%;
|
|
79
|
-
opacity: 0;
|
|
80
|
-
pointer-events: none;
|
|
81
80
|
overflow: auto;
|
|
82
81
|
}
|
|
83
82
|
|
|
@@ -102,7 +101,7 @@ $listItemHeight: 2.125rem;
|
|
|
102
101
|
cursor: pointer;
|
|
103
102
|
|
|
104
103
|
&:after {
|
|
105
|
-
content:
|
|
104
|
+
content: "";
|
|
106
105
|
position: absolute;
|
|
107
106
|
top: 0;
|
|
108
107
|
left: 0;
|
|
@@ -132,7 +131,7 @@ $listItemHeight: 2.125rem;
|
|
|
132
131
|
|
|
133
132
|
.selected-option {
|
|
134
133
|
&:before {
|
|
135
|
-
content:
|
|
134
|
+
content: "";
|
|
136
135
|
position: absolute;
|
|
137
136
|
top: 0;
|
|
138
137
|
left: 0;
|
|
@@ -147,7 +146,6 @@ $listItemHeight: 2.125rem;
|
|
|
147
146
|
position: absolute;
|
|
148
147
|
top: 50%;
|
|
149
148
|
transform: translateY(-50%);
|
|
150
|
-
left: 1.25rem;
|
|
151
149
|
pointer-events: none;
|
|
152
150
|
}
|
|
153
151
|
|