@react-ui-org/react-ui 0.64.1 → 0.65.0
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/README.md +3 -6
- package/dist/react-ui.css +16 -16
- package/dist/react-ui.d.ts +1928 -0
- package/dist/react-ui.development.css +2916 -2915
- package/dist/react-ui.development.js +2019 -1051
- package/dist/react-ui.js +1 -1
- package/package.json +74 -70
- package/src/components/Alert/{Alert.jsx → Alert.tsx} +8 -43
- package/src/components/Alert/Alert.types.ts +34 -0
- package/src/components/Alert/README.md +1 -1
- package/src/components/Alert/index.ts +2 -0
- package/src/components/Badge/Badge.tsx +30 -0
- package/src/components/Badge/Badge.types.ts +24 -0
- package/src/components/Badge/README.md +1 -1
- package/src/components/Badge/index.ts +5 -0
- package/src/components/Button/Button.tsx +110 -0
- package/src/components/Button/Button.types.ts +93 -0
- package/src/components/Button/README.md +1 -1
- package/src/components/Button/helpers/{getRootLabelVisibilityClassName.js → getRootLabelVisibilityClassName.ts} +4 -1
- package/src/components/Button/index.ts +6 -0
- package/src/components/ButtonGroup/{ButtonGroup.jsx → ButtonGroup.tsx} +9 -40
- package/src/components/ButtonGroup/ButtonGroup.types.ts +45 -0
- package/src/components/ButtonGroup/ButtonGroupContext.ts +4 -0
- package/src/components/ButtonGroup/README.md +1 -1
- package/src/components/ButtonGroup/{index.js → index.ts} +4 -0
- package/src/components/Card/Card.tsx +33 -0
- package/src/components/Card/Card.types.ts +46 -0
- package/src/components/Card/{CardBody.jsx → CardBody.tsx} +4 -11
- package/src/components/Card/{CardFooter.jsx → CardFooter.tsx} +4 -15
- package/src/components/Card/README.md +6 -7
- package/src/components/Card/{index.js → index.ts} +5 -0
- package/src/components/CheckboxField/CheckboxField.tsx +81 -0
- package/src/components/CheckboxField/CheckboxField.types.ts +63 -0
- package/src/components/CheckboxField/README.md +67 -42
- package/src/components/CheckboxField/index.ts +5 -0
- package/src/components/FileInputField/{FileInputField.jsx → FileInputField.tsx} +42 -128
- package/src/components/FileInputField/FileInputField.types.ts +100 -0
- package/src/components/FileInputField/README.md +1 -1
- package/src/components/FileInputField/index.ts +6 -0
- package/src/components/FormLayout/FormLayout.module.scss +1 -1
- package/src/components/FormLayout/{FormLayout.jsx → FormLayout.tsx} +15 -50
- package/src/components/FormLayout/FormLayout.types.ts +55 -0
- package/src/components/FormLayout/FormLayoutContext.ts +4 -0
- package/src/components/FormLayout/{FormLayoutCustomField.jsx → FormLayoutCustomField.tsx} +10 -65
- package/src/components/FormLayout/FormLayoutCustomField.types.ts +59 -0
- package/src/components/FormLayout/FormLayoutCustomFieldContext.ts +4 -0
- package/src/components/FormLayout/README.md +4 -6
- package/src/components/FormLayout/index.ts +14 -0
- package/src/components/Grid/Grid.module.scss +1 -1
- package/src/components/Grid/Grid.tsx +50 -0
- package/src/components/Grid/Grid.types.ts +108 -0
- package/src/components/Grid/GridSpan.tsx +36 -0
- package/src/components/Grid/README.md +2 -2
- package/src/components/Grid/_helpers/generateResponsiveCustomProperties.ts +32 -0
- package/src/components/Grid/index.ts +9 -0
- package/src/components/InputGroup/{InputGroup.jsx → InputGroup.tsx} +25 -89
- package/src/components/InputGroup/InputGroup.types.ts +80 -0
- package/src/components/InputGroup/InputGroupContext.ts +4 -0
- package/src/components/InputGroup/README.md +5 -1
- package/src/components/InputGroup/{index.js → index.ts} +4 -0
- package/src/components/Modal/Modal.tsx +172 -0
- package/src/components/Modal/Modal.types.ts +181 -0
- package/src/components/Modal/ModalBody.tsx +34 -0
- package/src/components/Modal/{ModalCloseButton.jsx → ModalCloseButton.tsx} +6 -19
- package/src/components/Modal/{ModalContent.jsx → ModalContent.tsx} +4 -15
- package/src/components/Modal/ModalFooter.tsx +27 -0
- package/src/components/Modal/ModalHeader.tsx +27 -0
- package/src/components/Modal/ModalTitle.tsx +29 -0
- package/src/components/Modal/README.md +9 -9
- package/src/components/Modal/_helpers/{dialogOnCancelHandler.js → dialogOnCancelHandler.ts} +11 -1
- package/src/components/Modal/_helpers/{dialogOnClickHandler.js → dialogOnClickHandler.ts} +13 -7
- package/src/components/Modal/_helpers/{dialogOnCloseHandler.js → dialogOnCloseHandler.ts} +11 -1
- package/src/components/Modal/_helpers/{dialogOnKeyDownHandler.js → dialogOnKeyDownHandler.ts} +19 -6
- package/src/components/Modal/_helpers/{getJustifyClassName.js → getJustifyClassName.ts} +4 -1
- package/src/components/Modal/_helpers/getPositionClassName.ts +10 -0
- package/src/components/Modal/_helpers/getScrollingClassName.ts +14 -0
- package/src/components/Modal/_helpers/{getSizeClassName.js → getSizeClassName.ts} +4 -1
- package/src/components/Modal/_hooks/{useModalFocus.js → useModalFocus.ts} +9 -5
- package/src/components/Modal/_hooks/{useModalScrollPrevention.js → useModalScrollPrevention.ts} +4 -1
- package/src/components/Modal/{index.js → index.ts} +14 -0
- package/src/components/Paper/{Paper.jsx → Paper.tsx} +6 -26
- package/src/components/Paper/Paper.types.ts +19 -0
- package/src/components/Paper/README.md +3 -4
- package/src/components/Paper/index.ts +2 -0
- package/src/components/Popover/Popover.module.scss +1 -1
- package/src/components/Popover/Popover.tsx +61 -0
- package/src/components/Popover/Popover.types.ts +75 -0
- package/src/components/Popover/PopoverWrapper.tsx +27 -0
- package/src/components/Popover/README.md +34 -22
- package/src/components/Popover/_helpers/{cleanPlacementStyle.js → cleanPlacementStyle.ts} +4 -1
- package/src/components/Popover/_helpers/{getRootAlignmentClassName.js → getRootAlignmentClassName.ts} +4 -1
- package/src/components/Popover/_helpers/{getRootSideClassName.js → getRootSideClassName.ts} +4 -1
- package/src/components/Popover/index.ts +8 -0
- package/src/components/Radio/README.md +85 -45
- package/src/components/Radio/{Radio.jsx → Radio.tsx} +11 -107
- package/src/components/Radio/Radio.types.ts +90 -0
- package/src/components/Radio/index.ts +5 -0
- package/src/components/ScrollView/README.md +1 -1
- package/src/components/ScrollView/ScrollView.module.scss +5 -0
- package/src/components/ScrollView/{ScrollView.jsx → ScrollView.tsx} +55 -166
- package/src/components/ScrollView/ScrollView.types.ts +121 -0
- package/src/components/ScrollView/_helpers/getElementsPositionDifference.ts +17 -0
- package/src/components/ScrollView/_hooks/{useLoadResizeHook.js → useLoadResizeHook.ts} +14 -3
- package/src/components/ScrollView/_hooks/{useScrollPositionHook.js → useScrollPositionHook.ts} +11 -4
- package/src/components/ScrollView/index.ts +6 -0
- package/src/components/SelectField/README.md +84 -45
- package/src/components/SelectField/SelectField.tsx +139 -0
- package/src/components/SelectField/SelectField.types.ts +120 -0
- package/src/components/SelectField/_components/Option/Option.tsx +19 -0
- package/src/components/SelectField/_components/Option/Option.types.ts +21 -0
- package/src/components/SelectField/_components/Option/index.ts +2 -0
- package/src/components/SelectField/index.ts +7 -0
- package/src/components/Table/README.md +1 -1
- package/src/components/Table/{Table.jsx → Table.tsx} +4 -43
- package/src/components/Table/Table.types.ts +51 -0
- package/src/components/Table/_components/TableBodyCell/TableBodyCell.tsx +20 -0
- package/src/components/Table/_components/TableBodyCell/TableBodyCell.types.ts +20 -0
- package/src/components/Table/_components/TableBodyCell/index.ts +2 -0
- package/src/components/Table/_components/TableHeaderCell/{TableHeaderCell.jsx → TableHeaderCell.tsx} +3 -34
- package/src/components/Table/_components/TableHeaderCell/TableHeaderCell.types.ts +20 -0
- package/src/components/Table/_components/TableHeaderCell/index.ts +2 -0
- package/src/components/Table/index.ts +8 -0
- package/src/components/Tabs/README.md +2 -2
- package/src/components/Tabs/{Tabs.jsx → Tabs.tsx} +4 -20
- package/src/components/Tabs/Tabs.types.ts +19 -0
- package/src/components/Tabs/TabsItem.tsx +49 -0
- package/src/components/Tabs/TabsItem.types.ts +42 -0
- package/src/components/Tabs/index.ts +4 -0
- package/src/components/Text/README.md +1 -1
- package/src/components/Text/Text.module.scss +5 -7
- package/src/components/Text/Text.tsx +46 -0
- package/src/components/Text/Text.types.ts +31 -0
- package/src/components/Text/_helpers/getRootClampClassName.ts +13 -0
- package/src/components/Text/_helpers/getRootHyphensClassName.ts +14 -0
- package/src/components/Text/_helpers/getRootWordWrappingClassName.ts +14 -0
- package/src/components/Text/index.ts +6 -0
- package/src/components/TextArea/README.md +5 -8
- package/src/components/TextArea/TextArea.tsx +95 -0
- package/src/components/TextArea/TextArea.types.ts +75 -0
- package/src/components/TextArea/index.ts +5 -0
- package/src/components/TextField/README.md +5 -7
- package/src/components/TextField/TextField.tsx +112 -0
- package/src/components/TextField/TextField.types.ts +94 -0
- package/src/components/TextField/index.ts +6 -0
- package/src/components/TextLink/README.md +1 -1
- package/src/components/TextLink/{TextLink.jsx → TextLink.tsx} +4 -15
- package/src/components/TextLink/TextLink.types.ts +12 -0
- package/src/components/TextLink/index.ts +2 -0
- package/src/components/Toggle/README.md +67 -42
- package/src/components/Toggle/Toggle.tsx +82 -0
- package/src/components/Toggle/Toggle.types.ts +58 -0
- package/src/components/Toggle/index.ts +5 -0
- package/src/components/Toolbar/README.md +3 -3
- package/src/components/Toolbar/Toolbar.tsx +41 -0
- package/src/components/Toolbar/Toolbar.types.ts +74 -0
- package/src/components/Toolbar/ToolbarGroup.tsx +38 -0
- package/src/components/Toolbar/{ToolbarItem.jsx → ToolbarItem.tsx} +5 -21
- package/src/components/Toolbar/_helpers/{getAlignClassName.js → getAlignClassName.ts} +8 -1
- package/src/components/Toolbar/_helpers/{getJustifyClassName.js → getJustifyClassName.ts} +4 -1
- package/src/components/Toolbar/{index.js → index.ts} +7 -0
- package/src/components/_helpers/{getRootColorClassName.js → getRootColorClassName.ts} +6 -1
- package/src/components/_helpers/{getRootPriorityClassName.js → getRootPriorityClassName.ts} +6 -1
- package/src/components/_helpers/{getRootSizeClassName.js → getRootSizeClassName.ts} +6 -1
- package/src/components/_helpers/{getRootValidationStateClassName.js → getRootValidationStateClassName.ts} +6 -1
- package/src/components/_helpers/resolveContextOrProp.ts +13 -0
- package/src/helpers/classNames/{classNames.js → classNames.ts} +2 -2
- package/src/helpers/isChildrenEmpty/isChildrenEmpty.ts +5 -0
- package/src/helpers/transferProps/transferProps.ts +50 -0
- package/src/helpers/transferProps/transferProps.types.ts +11 -0
- package/src/index.ts +211 -0
- package/src/providers/globalProps/GlobalProps.types.ts +30 -0
- package/src/providers/globalProps/GlobalPropsContext.ts +6 -0
- package/src/providers/globalProps/{GlobalPropsProvider.jsx → GlobalPropsProvider.tsx} +8 -15
- package/src/providers/globalProps/{index.js → index.ts} +4 -0
- package/src/providers/globalProps/withGlobalProps.tsx +36 -0
- package/src/providers/translations/Translations.types.ts +26 -0
- package/src/providers/translations/TranslationsContext.ts +7 -0
- package/src/providers/translations/{TranslationsProvider.jsx → TranslationsProvider.tsx} +8 -15
- package/src/providers/translations/{index.js → index.ts} +5 -0
- package/src/styles/tools/_accessibility.scss +2 -2
- package/src/translations/{en.js → en.ts} +3 -1
- package/src/types/breakpoints.ts +1 -0
- package/src/types/colors.ts +7 -0
- package/src/types/index.ts +13 -0
- package/src/types/labelPositions.ts +1 -0
- package/src/types/layouts.ts +1 -0
- package/src/types/modules.d.ts +16 -0
- package/src/types/priorities.ts +1 -0
- package/src/types/sizes.ts +1 -0
- package/src/types/styles.ts +4 -0
- package/src/types/validationStates.ts +1 -0
- package/src/utils/mergeDeep.ts +34 -0
- package/src/utils/mergeDeep.types.ts +4 -0
- package/.claude/agents/code-reviewer.md +0 -122
- package/.claude/rules/code.md +0 -22
- package/.claude/rules/docs.md +0 -35
- package/.claude/rules/frontend.md +0 -72
- package/.claude/rules/git.md +0 -13
- package/.claude/rules/safety-guards.md +0 -9
- package/.claude/rules/styling.md +0 -32
- package/.claude/rules/testing.md +0 -59
- package/.claude/settings.json +0 -32
- package/.claude/skills/commit/SKILL.md +0 -54
- package/.devcontainer/devcontainer.json +0 -23
- package/.eslintrc-ts +0 -40
- package/.mcp.json +0 -8
- package/.nvmrc +0 -1
- package/CLAUDE.md +0 -82
- package/docker-compose.base.yml +0 -93
- package/docker-compose.yml.dist +0 -41
- package/jest.config-ts.js +0 -34
- package/opencode.json +0 -10
- package/playwright-ct.config.ts +0 -68
- package/scripts/auto-start-mkdocs.sh +0 -5
- package/scripts/auto-start-node.sh +0 -33
- package/scripts/mcps/chrome-host/README.md +0 -118
- package/scripts/mcps/chrome-host/cdp_proxy.py +0 -90
- package/scripts/mcps/chrome-host/mcp-entry.sh +0 -33
- package/scripts/mcps/chrome-host/mcp-launch.sh +0 -36
- package/scripts/mcps/chrome-host/mcp-setup.sh +0 -70
- package/scripts/mcps/chrome-host/start-host-chrome.sh +0 -267
- package/setup.sh +0 -107
- package/src/CNAME +0 -1
- package/src/components/Alert/index.js +0 -1
- package/src/components/Badge/Badge.jsx +0 -51
- package/src/components/Badge/index.js +0 -1
- package/src/components/Button/Button.jsx +0 -203
- package/src/components/Button/helpers/getRootPriorityClassName.js +0 -15
- package/src/components/Button/index.js +0 -1
- package/src/components/ButtonGroup/ButtonGroupContext.js +0 -3
- package/src/components/Card/Card.jsx +0 -67
- package/src/components/CheckboxField/CheckboxField.jsx +0 -144
- package/src/components/CheckboxField/index.js +0 -1
- package/src/components/FileInputField/index.js +0 -1
- package/src/components/FormLayout/FormLayoutContext.js +0 -3
- package/src/components/FormLayout/FormLayoutCustomFieldContext.js +0 -3
- package/src/components/FormLayout/index.js +0 -4
- package/src/components/Grid/Grid.jsx +0 -225
- package/src/components/Grid/GridSpan.jsx +0 -88
- package/src/components/Grid/_helpers/generateResponsiveCustomProperties.js +0 -22
- package/src/components/Grid/index.js +0 -2
- package/src/components/InputGroup/InputGroupContext.js +0 -3
- package/src/components/Modal/Modal.jsx +0 -262
- package/src/components/Modal/ModalBody.jsx +0 -60
- package/src/components/Modal/ModalFooter.jsx +0 -42
- package/src/components/Modal/ModalHeader.jsx +0 -42
- package/src/components/Modal/ModalTitle.jsx +0 -42
- package/src/components/Modal/_helpers/getPositionClassName.js +0 -7
- package/src/components/Modal/_helpers/getScrollingClassName.js +0 -11
- package/src/components/Paper/index.js +0 -1
- package/src/components/Popover/Popover.jsx +0 -124
- package/src/components/Popover/PopoverWrapper.jsx +0 -38
- package/src/components/Popover/index.js +0 -2
- package/src/components/Radio/index.js +0 -1
- package/src/components/ScrollView/_helpers/getElementsPositionDifference.js +0 -11
- package/src/components/ScrollView/index.js +0 -1
- package/src/components/SelectField/SelectField.jsx +0 -272
- package/src/components/SelectField/_components/Option/Option.jsx +0 -46
- package/src/components/SelectField/_components/Option/index.js +0 -1
- package/src/components/SelectField/index.js +0 -1
- package/src/components/Table/_components/TableBodyCell/TableBodyCell.jsx +0 -46
- package/src/components/Table/_components/TableBodyCell/index.js +0 -1
- package/src/components/Table/_components/TableHeaderCell/index.js +0 -1
- package/src/components/Table/index.js +0 -1
- package/src/components/Tabs/TabsItem.jsx +0 -91
- package/src/components/Tabs/index.js +0 -2
- package/src/components/Text/Text.jsx +0 -76
- package/src/components/Text/_helpers/getRootClampClassName.js +0 -11
- package/src/components/Text/_helpers/getRootHyphensClassName.js +0 -11
- package/src/components/Text/_helpers/getRootWordWrappingClassName.js +0 -11
- package/src/components/Text/index.js +0 -1
- package/src/components/TextArea/TextArea.jsx +0 -174
- package/src/components/TextArea/index.js +0 -1
- package/src/components/TextField/TextField.jsx +0 -208
- package/src/components/TextField/index.js +0 -1
- package/src/components/TextLink/index.js +0 -1
- package/src/components/Toggle/Toggle.jsx +0 -144
- package/src/components/Toggle/index.js +0 -1
- package/src/components/Toolbar/Toolbar.jsx +0 -76
- package/src/components/Toolbar/ToolbarGroup.jsx +0 -64
- package/src/components/_helpers/resolveContextOrProp.js +0 -10
- package/src/helpers/isChildrenEmpty/isChildrenEmpty.js +0 -3
- package/src/helpers/transferProps/transferProps.js +0 -38
- package/src/index.js +0 -67
- package/src/providers/globalProps/GlobalPropsContext.jsx +0 -5
- package/src/providers/globalProps/withGlobalProps.jsx +0 -38
- package/src/providers/translations/TranslationsContext.jsx +0 -6
- package/src/utils/mergeDeep.js +0 -28
- package/tsconfig.json +0 -27
- /package/src/helpers/classNames/{index.js → index.ts} +0 -0
- /package/src/helpers/isChildrenEmpty/{index.js → index.ts} +0 -0
- /package/src/helpers/transferProps/{index.js → index.ts} +0 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
1
|
import React, {
|
|
3
2
|
useCallback,
|
|
4
3
|
useEffect,
|
|
@@ -7,6 +6,10 @@ import React, {
|
|
|
7
6
|
useRef,
|
|
8
7
|
useState,
|
|
9
8
|
} from 'react';
|
|
9
|
+
import type {
|
|
10
|
+
ChangeEvent,
|
|
11
|
+
DragEvent,
|
|
12
|
+
} from 'react';
|
|
10
13
|
import { withGlobalProps } from '../../providers/globalProps';
|
|
11
14
|
import { classNames } from '../../helpers/classNames';
|
|
12
15
|
import { transferProps } from '../../helpers/transferProps';
|
|
@@ -14,45 +17,46 @@ import { TranslationsContext } from '../../providers/translations';
|
|
|
14
17
|
import { getRootSizeClassName } from '../_helpers/getRootSizeClassName';
|
|
15
18
|
import { getRootValidationStateClassName } from '../_helpers/getRootValidationStateClassName';
|
|
16
19
|
import { resolveContextOrProp } from '../_helpers/resolveContextOrProp';
|
|
17
|
-
import { InputGroupContext } from '../InputGroup';
|
|
20
|
+
import { InputGroupContext } from '../InputGroup/InputGroupContext';
|
|
18
21
|
import { Text } from '../Text';
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
FormLayoutCustomFieldContext,
|
|
22
|
-
} from '../FormLayout';
|
|
22
|
+
import { FormLayoutContext } from '../FormLayout/FormLayoutContext';
|
|
23
|
+
import { FormLayoutCustomFieldContext } from '../FormLayout/FormLayoutCustomFieldContext';
|
|
23
24
|
import styles from './FileInputField.module.scss';
|
|
25
|
+
import type {
|
|
26
|
+
FileInputFieldFilesChangedEvent,
|
|
27
|
+
FileInputFieldProps,
|
|
28
|
+
FileInputFieldRef,
|
|
29
|
+
} from './FileInputField.types';
|
|
24
30
|
|
|
25
31
|
/* istanbul ignore file */
|
|
26
32
|
|
|
27
|
-
export const FileInputField = React.forwardRef((
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
} = props;
|
|
44
|
-
|
|
33
|
+
export const FileInputField = React.forwardRef<FileInputFieldRef, FileInputFieldProps>(({
|
|
34
|
+
disabled = false,
|
|
35
|
+
fullWidth = false,
|
|
36
|
+
helpText,
|
|
37
|
+
id,
|
|
38
|
+
isLabelVisible = true,
|
|
39
|
+
label,
|
|
40
|
+
layout = 'vertical',
|
|
41
|
+
multiple = false,
|
|
42
|
+
onFilesChanged,
|
|
43
|
+
required = false,
|
|
44
|
+
size = 'medium',
|
|
45
|
+
validationState,
|
|
46
|
+
validationText,
|
|
47
|
+
...restProps
|
|
48
|
+
}, ref) => {
|
|
45
49
|
const formLayoutContext = useContext(FormLayoutContext);
|
|
46
50
|
const formLayoutCustomFieldContext = useContext(FormLayoutCustomFieldContext);
|
|
47
51
|
const inputGroupContext = useContext(InputGroupContext);
|
|
48
52
|
const translations = useContext(TranslationsContext);
|
|
49
53
|
|
|
50
|
-
const [selectedFileNames, setSelectedFileNames] = useState([]);
|
|
54
|
+
const [selectedFileNames, setSelectedFileNames] = useState<string[]>([]);
|
|
51
55
|
const [isDragging, setIsDragging] = useState(false);
|
|
52
56
|
|
|
53
|
-
const internalInputRef = useRef();
|
|
57
|
+
const internalInputRef = useRef<HTMLInputElement>(null);
|
|
54
58
|
|
|
55
|
-
const handleReset = useCallback((event) => {
|
|
59
|
+
const handleReset = useCallback((event: FileInputFieldFilesChangedEvent) => {
|
|
56
60
|
if (internalInputRef.current) {
|
|
57
61
|
internalInputRef.current.value = '';
|
|
58
62
|
}
|
|
@@ -70,7 +74,7 @@ export const FileInputField = React.forwardRef((props, ref) => {
|
|
|
70
74
|
// The reason of extending object instead of using spread operator is that
|
|
71
75
|
// if it is transformed to the object, it changes the reference of the object
|
|
72
76
|
// and its prototype chain.
|
|
73
|
-
const inputEl = internalInputRef?.current ?? {};
|
|
77
|
+
const inputEl = (internalInputRef?.current ?? {}) as FileInputFieldRef;
|
|
74
78
|
inputEl.resetState = () => {
|
|
75
79
|
handleReset(null);
|
|
76
80
|
};
|
|
@@ -79,7 +83,7 @@ export const FileInputField = React.forwardRef((props, ref) => {
|
|
|
79
83
|
[handleReset],
|
|
80
84
|
);
|
|
81
85
|
|
|
82
|
-
const handleFileChange = (files, event) => {
|
|
86
|
+
const handleFileChange = (files: FileList, event: FileInputFieldFilesChangedEvent) => {
|
|
83
87
|
if (files.length === 0) {
|
|
84
88
|
setSelectedFileNames([]);
|
|
85
89
|
onFilesChanged([], event);
|
|
@@ -94,7 +98,7 @@ export const FileInputField = React.forwardRef((props, ref) => {
|
|
|
94
98
|
return;
|
|
95
99
|
}
|
|
96
100
|
|
|
97
|
-
const fileNames = [];
|
|
101
|
+
const fileNames: string[] = [];
|
|
98
102
|
|
|
99
103
|
[...files].forEach((file) => {
|
|
100
104
|
fileNames.push(file.name);
|
|
@@ -104,21 +108,21 @@ export const FileInputField = React.forwardRef((props, ref) => {
|
|
|
104
108
|
onFilesChanged(files, event);
|
|
105
109
|
};
|
|
106
110
|
|
|
107
|
-
const handleInputChange = (event) => {
|
|
108
|
-
handleFileChange(event.target.files, event);
|
|
111
|
+
const handleInputChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
112
|
+
handleFileChange(event.target.files as FileList, event);
|
|
109
113
|
};
|
|
110
114
|
|
|
111
115
|
const handleClick = () => {
|
|
112
|
-
internalInputRef?.current
|
|
116
|
+
internalInputRef?.current?.click();
|
|
113
117
|
};
|
|
114
118
|
|
|
115
|
-
const handleDrop = (event) => {
|
|
119
|
+
const handleDrop = (event: DragEvent<HTMLDivElement>) => {
|
|
116
120
|
event.preventDefault();
|
|
117
121
|
handleFileChange(event.dataTransfer.files, event);
|
|
118
122
|
setIsDragging(false);
|
|
119
123
|
};
|
|
120
124
|
|
|
121
|
-
const handleDragOver = (event) => {
|
|
125
|
+
const handleDragOver = (event: DragEvent<HTMLDivElement>) => {
|
|
122
126
|
if (!isDragging) {
|
|
123
127
|
setIsDragging(true);
|
|
124
128
|
}
|
|
@@ -163,10 +167,10 @@ export const FileInputField = React.forwardRef((props, ref) => {
|
|
|
163
167
|
isDragging && styles.isRootDragging,
|
|
164
168
|
required && styles.isRootRequired,
|
|
165
169
|
getRootSizeClassName(
|
|
166
|
-
resolveContextOrProp(inputGroupContext && inputGroupContext.size, size),
|
|
167
170
|
styles,
|
|
171
|
+
resolveContextOrProp(inputGroupContext && inputGroupContext.size, size),
|
|
168
172
|
),
|
|
169
|
-
getRootValidationStateClassName(
|
|
173
|
+
getRootValidationStateClassName(styles, validationState),
|
|
170
174
|
)}
|
|
171
175
|
id={`${id}__root`}
|
|
172
176
|
onDragLeave={!disabled ? handleDragLeave : undefined}
|
|
@@ -248,96 +252,6 @@ export const FileInputField = React.forwardRef((props, ref) => {
|
|
|
248
252
|
);
|
|
249
253
|
});
|
|
250
254
|
|
|
251
|
-
|
|
252
|
-
disabled: false,
|
|
253
|
-
fullWidth: false,
|
|
254
|
-
helpText: undefined,
|
|
255
|
-
isLabelVisible: true,
|
|
256
|
-
layout: 'vertical',
|
|
257
|
-
multiple: false,
|
|
258
|
-
required: false,
|
|
259
|
-
size: 'medium',
|
|
260
|
-
validationState: undefined,
|
|
261
|
-
validationText: undefined,
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
FileInputField.propTypes = {
|
|
265
|
-
/**
|
|
266
|
-
* If `true`, the input will be disabled.
|
|
267
|
-
*/
|
|
268
|
-
disabled: PropTypes.bool,
|
|
269
|
-
/**
|
|
270
|
-
* If `true`, the field will span the full width of its parent.
|
|
271
|
-
*/
|
|
272
|
-
fullWidth: PropTypes.bool,
|
|
273
|
-
/**
|
|
274
|
-
* Optional help text.
|
|
275
|
-
*
|
|
276
|
-
* Help text is never rendered when the component is placed into `InputGroup`.
|
|
277
|
-
* If a help text is needed, it must be defined on the `InputGroup` component instead.
|
|
278
|
-
*/
|
|
279
|
-
helpText: PropTypes.node,
|
|
280
|
-
/**
|
|
281
|
-
* ID of the `<input>` HTML element.
|
|
282
|
-
*
|
|
283
|
-
* Also serves as base for ids of nested elements:
|
|
284
|
-
* * `<ID>__label`
|
|
285
|
-
* * `<ID>__labelText`
|
|
286
|
-
* * `<ID>__helpText`
|
|
287
|
-
* * `<ID>__validationText`
|
|
288
|
-
*/
|
|
289
|
-
id: PropTypes.string.isRequired,
|
|
290
|
-
/**
|
|
291
|
-
* If `false`, the label will be visually hidden (but remains accessible by assistive
|
|
292
|
-
* technologies).
|
|
293
|
-
*
|
|
294
|
-
* Automatically set to `false` when the component is rendered within `FormLayoutCustomField`
|
|
295
|
-
* component.
|
|
296
|
-
*/
|
|
297
|
-
isLabelVisible: PropTypes.bool,
|
|
298
|
-
/**
|
|
299
|
-
* File input field label.
|
|
300
|
-
*/
|
|
301
|
-
label: PropTypes.node.isRequired,
|
|
302
|
-
/**
|
|
303
|
-
* Layout of the field.
|
|
304
|
-
*
|
|
305
|
-
* Ignored if the component is rendered within `FormLayout` component
|
|
306
|
-
* as the value is inherited in such case.
|
|
307
|
-
*
|
|
308
|
-
*/
|
|
309
|
-
layout: PropTypes.oneOf(['horizontal', 'vertical']),
|
|
310
|
-
/**
|
|
311
|
-
* If `true`, the input will accept multiple files.
|
|
312
|
-
*/
|
|
313
|
-
multiple: PropTypes.bool,
|
|
314
|
-
/**
|
|
315
|
-
* Callback fired when the value of the input changes.
|
|
316
|
-
*/
|
|
317
|
-
onFilesChanged: PropTypes.func.isRequired,
|
|
318
|
-
/**
|
|
319
|
-
* If `true`, the input will be required.
|
|
320
|
-
*/
|
|
321
|
-
required: PropTypes.bool,
|
|
322
|
-
/**
|
|
323
|
-
* Size of the field.
|
|
324
|
-
*
|
|
325
|
-
* Ignored if the component is rendered within `InputGroup` component as the value is inherited in such case.
|
|
326
|
-
*/
|
|
327
|
-
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
328
|
-
/**
|
|
329
|
-
* Alter the field to provide feedback based on validation result.
|
|
330
|
-
*/
|
|
331
|
-
validationState: PropTypes.oneOf(['invalid', 'valid', 'warning']),
|
|
332
|
-
/**
|
|
333
|
-
* Validation message to be displayed.
|
|
334
|
-
*
|
|
335
|
-
* Validation text is never rendered when the component is placed into `InputGroup`.
|
|
336
|
-
* If a validation text is needed, it must be defined on the `InputGroup` component instead.
|
|
337
|
-
*/
|
|
338
|
-
validationText: PropTypes.node,
|
|
339
|
-
};
|
|
340
|
-
|
|
341
|
-
export const FileInputFieldWithGlobalProps = withGlobalProps(FileInputField, 'FileInputField');
|
|
255
|
+
export const FileInputFieldWithGlobalProps = withGlobalProps<FileInputFieldProps, FileInputFieldRef>(FileInputField, 'FileInputField');
|
|
342
256
|
|
|
343
257
|
export default FileInputFieldWithGlobalProps;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ChangeEvent,
|
|
3
|
+
DragEvent,
|
|
4
|
+
InputHTMLAttributes,
|
|
5
|
+
ReactNode,
|
|
6
|
+
} from 'react';
|
|
7
|
+
import type {
|
|
8
|
+
Layout,
|
|
9
|
+
Size,
|
|
10
|
+
ValidationState,
|
|
11
|
+
} from '../../types';
|
|
12
|
+
|
|
13
|
+
export type FileInputFieldFilesChangedEvent = ChangeEvent<HTMLInputElement> | DragEvent<HTMLDivElement> | Event | null;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Element exposed through `ref`: the `<input>` element extended with `resetState()`.
|
|
17
|
+
*/
|
|
18
|
+
export type FileInputFieldRef = HTMLInputElement & {
|
|
19
|
+
resetState: () => void;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Props of the `FileInputField` component.
|
|
24
|
+
*/
|
|
25
|
+
export type FileInputFieldProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'id' | 'size' | 'type'> & {
|
|
26
|
+
/**
|
|
27
|
+
* If `true`, the input will be disabled.
|
|
28
|
+
*/
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* If `true`, the field will span the full width of its parent.
|
|
32
|
+
*/
|
|
33
|
+
fullWidth?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Optional help text.
|
|
36
|
+
*
|
|
37
|
+
* Help text is never rendered when the component is placed into `InputGroup`.
|
|
38
|
+
* If a help text is needed, it must be defined on the `InputGroup` component instead.
|
|
39
|
+
*/
|
|
40
|
+
helpText?: ReactNode;
|
|
41
|
+
/**
|
|
42
|
+
* ID of the `<input>` HTML element.
|
|
43
|
+
*
|
|
44
|
+
* Also serves as base for ids of nested elements:
|
|
45
|
+
* * `<ID>__label`
|
|
46
|
+
* * `<ID>__labelText`
|
|
47
|
+
* * `<ID>__helpText`
|
|
48
|
+
* * `<ID>__validationText`
|
|
49
|
+
*/
|
|
50
|
+
id: string;
|
|
51
|
+
/**
|
|
52
|
+
* If `false`, the label will be visually hidden (but remains accessible by assistive
|
|
53
|
+
* technologies).
|
|
54
|
+
*
|
|
55
|
+
* Automatically set to `false` when the component is rendered within `FormLayoutCustomField`
|
|
56
|
+
* component.
|
|
57
|
+
*/
|
|
58
|
+
isLabelVisible?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* File input field label.
|
|
61
|
+
*/
|
|
62
|
+
label: ReactNode;
|
|
63
|
+
/**
|
|
64
|
+
* Layout of the field.
|
|
65
|
+
*
|
|
66
|
+
* Ignored if the component is rendered within `FormLayout` component
|
|
67
|
+
* as the value is inherited in such case.
|
|
68
|
+
*
|
|
69
|
+
*/
|
|
70
|
+
layout?: Layout;
|
|
71
|
+
/**
|
|
72
|
+
* If `true`, the input will accept multiple files.
|
|
73
|
+
*/
|
|
74
|
+
multiple?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Callback fired when the value of the input changes.
|
|
77
|
+
*/
|
|
78
|
+
onFilesChanged: (files: FileList | File[], event: FileInputFieldFilesChangedEvent) => void;
|
|
79
|
+
/**
|
|
80
|
+
* If `true`, the input will be required.
|
|
81
|
+
*/
|
|
82
|
+
required?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Size of the field.
|
|
85
|
+
*
|
|
86
|
+
* Ignored if the component is rendered within `InputGroup` component as the value is inherited in such case.
|
|
87
|
+
*/
|
|
88
|
+
size?: Size;
|
|
89
|
+
/**
|
|
90
|
+
* Alter the field to provide feedback based on validation result.
|
|
91
|
+
*/
|
|
92
|
+
validationState?: ValidationState;
|
|
93
|
+
/**
|
|
94
|
+
* Validation message to be displayed.
|
|
95
|
+
*
|
|
96
|
+
* Validation text is never rendered when the component is placed into `InputGroup`.
|
|
97
|
+
* If a validation text is needed, it must be defined on the `InputGroup` component instead.
|
|
98
|
+
*/
|
|
99
|
+
validationText?: ReactNode;
|
|
100
|
+
};
|
|
@@ -307,7 +307,7 @@ If you provide [ref], it is forwarded to the native HTML `<input>` element.
|
|
|
307
307
|
|
|
308
308
|
## API
|
|
309
309
|
|
|
310
|
-
<docoff-react-props src="/components/FileInputField/FileInputField.
|
|
310
|
+
<docoff-react-props src="/components/FileInputField/FileInputField.tsx" name="FileInputField"></docoff-react-props>
|
|
311
311
|
|
|
312
312
|
## Theming
|
|
313
313
|
|
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
1
|
import React, { useMemo } from 'react';
|
|
2
|
+
import type { CSSProperties } from 'react';
|
|
3
3
|
import { withGlobalProps } from '../../providers/globalProps';
|
|
4
4
|
import { classNames } from '../../helpers/classNames/classNames';
|
|
5
5
|
import { transferProps } from '../../helpers/transferProps';
|
|
6
6
|
import { isChildrenEmpty } from '../../helpers/isChildrenEmpty/isChildrenEmpty';
|
|
7
|
+
import type { Layout } from '../../types';
|
|
7
8
|
import { FormLayoutContext } from './FormLayoutContext';
|
|
8
9
|
import styles from './FormLayout.module.scss';
|
|
10
|
+
import type {
|
|
11
|
+
FormLayoutLabelWidth,
|
|
12
|
+
FormLayoutProps,
|
|
13
|
+
} from './FormLayout.types';
|
|
9
14
|
|
|
10
15
|
const PREDEFINED_LABEL_WIDTH_VALUES = ['auto', 'default', 'limited'];
|
|
11
16
|
|
|
12
|
-
export const FormLayout = ({
|
|
13
|
-
autoWidth,
|
|
17
|
+
export const FormLayout: React.FunctionComponent<FormLayoutProps> = ({
|
|
18
|
+
autoWidth = false,
|
|
14
19
|
children,
|
|
15
|
-
fieldLayout,
|
|
16
|
-
labelWidth,
|
|
20
|
+
fieldLayout = 'vertical',
|
|
21
|
+
labelWidth = 'default',
|
|
17
22
|
...restProps
|
|
18
|
-
}) => {
|
|
23
|
+
}: FormLayoutProps) => {
|
|
19
24
|
const childProps = useMemo(() => ({ layout: fieldLayout }), [fieldLayout]);
|
|
20
25
|
|
|
21
26
|
if (isChildrenEmpty(children)) {
|
|
@@ -24,7 +29,7 @@ export const FormLayout = ({
|
|
|
24
29
|
|
|
25
30
|
const hasCustomLabelWidth = !PREDEFINED_LABEL_WIDTH_VALUES.includes(labelWidth);
|
|
26
31
|
|
|
27
|
-
const fieldLayoutClass = (layout) => {
|
|
32
|
+
const fieldLayoutClass = (layout: Layout) => {
|
|
28
33
|
if (layout === 'horizontal') {
|
|
29
34
|
return styles.isRootFieldLayoutHorizontal;
|
|
30
35
|
}
|
|
@@ -32,7 +37,7 @@ export const FormLayout = ({
|
|
|
32
37
|
return styles.isRootFieldLayoutVertical;
|
|
33
38
|
};
|
|
34
39
|
|
|
35
|
-
const labelWidthClass = (width) => {
|
|
40
|
+
const labelWidthClass = (width: FormLayoutLabelWidth) => {
|
|
36
41
|
if (hasCustomLabelWidth) {
|
|
37
42
|
return styles.hasRootLabelWidthCustom;
|
|
38
43
|
}
|
|
@@ -57,7 +62,7 @@ export const FormLayout = ({
|
|
|
57
62
|
autoWidth && styles.isRootAutoWidth,
|
|
58
63
|
fieldLayout === 'horizontal' && labelWidthClass(labelWidth),
|
|
59
64
|
)}
|
|
60
|
-
{...hasCustomLabelWidth ? { style: { '--rui-custom-label-width': labelWidth } } : {}}
|
|
65
|
+
{...hasCustomLabelWidth ? { style: { '--rui-custom-label-width': labelWidth } as CSSProperties } : {}}
|
|
61
66
|
>
|
|
62
67
|
<FormLayoutContext.Provider value={childProps}>
|
|
63
68
|
{children}
|
|
@@ -66,46 +71,6 @@ export const FormLayout = ({
|
|
|
66
71
|
);
|
|
67
72
|
};
|
|
68
73
|
|
|
69
|
-
|
|
70
|
-
autoWidth: false,
|
|
71
|
-
children: undefined,
|
|
72
|
-
fieldLayout: 'vertical',
|
|
73
|
-
labelWidth: 'default',
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
FormLayout.propTypes = {
|
|
77
|
-
/**
|
|
78
|
-
* If `true`, FormLayout will take up only as much horizontal space as necessary.
|
|
79
|
-
*/
|
|
80
|
-
autoWidth: PropTypes.bool,
|
|
81
|
-
/**
|
|
82
|
-
* Supported form field components:
|
|
83
|
-
* * `CheckboxField`
|
|
84
|
-
* * `FileInputField`
|
|
85
|
-
* * `FormLayoutCustomField`
|
|
86
|
-
* * `Radio`
|
|
87
|
-
* * `SelectField`
|
|
88
|
-
* * `TextArea`
|
|
89
|
-
* * `TextField`
|
|
90
|
-
* * `Toggle`
|
|
91
|
-
*
|
|
92
|
-
* If none are provided nothing is rendered.
|
|
93
|
-
*/
|
|
94
|
-
children: PropTypes.node,
|
|
95
|
-
/**
|
|
96
|
-
* Layout that is forced on children form fields.
|
|
97
|
-
*/
|
|
98
|
-
fieldLayout: PropTypes.oneOf(['horizontal', 'vertical']),
|
|
99
|
-
/**
|
|
100
|
-
* Width of the column with form field labels. Only available if the `fieldLayout` is set to
|
|
101
|
-
* `horizontal`.
|
|
102
|
-
*/
|
|
103
|
-
labelWidth: PropTypes.oneOfType([
|
|
104
|
-
PropTypes.oneOf(PREDEFINED_LABEL_WIDTH_VALUES),
|
|
105
|
-
PropTypes.string,
|
|
106
|
-
]),
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
export const FormLayoutWithGlobalProps = withGlobalProps(FormLayout, 'FormLayout');
|
|
74
|
+
export const FormLayoutWithGlobalProps = withGlobalProps<FormLayoutProps, never>(FormLayout, 'FormLayout');
|
|
110
75
|
|
|
111
76
|
export default FormLayoutWithGlobalProps;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
HTMLAttributes,
|
|
3
|
+
ReactNode,
|
|
4
|
+
} from 'react';
|
|
5
|
+
import type { Layout } from '../../types';
|
|
6
|
+
|
|
7
|
+
export type FormLayoutPredefinedLabelWidth = 'auto' | 'default' | 'limited';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Either one of the predefined values or any valid CSS width.
|
|
11
|
+
*
|
|
12
|
+
* @docoffOverrideType FormLayoutPredefinedLabelWidth | string
|
|
13
|
+
*/
|
|
14
|
+
export type FormLayoutLabelWidth = FormLayoutPredefinedLabelWidth | (string & NonNullable<unknown>);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Props of the `FormLayout` component.
|
|
18
|
+
*/
|
|
19
|
+
export type FormLayoutProps = HTMLAttributes<HTMLDivElement> & {
|
|
20
|
+
/**
|
|
21
|
+
* If `true`, FormLayout will take up only as much horizontal space as necessary.
|
|
22
|
+
*/
|
|
23
|
+
autoWidth?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Supported form field components:
|
|
26
|
+
* * `CheckboxField`
|
|
27
|
+
* * `FileInputField`
|
|
28
|
+
* * `FormLayoutCustomField`
|
|
29
|
+
* * `Radio`
|
|
30
|
+
* * `SelectField`
|
|
31
|
+
* * `TextArea`
|
|
32
|
+
* * `TextField`
|
|
33
|
+
* * `Toggle`
|
|
34
|
+
*
|
|
35
|
+
* If none are provided nothing is rendered.
|
|
36
|
+
*/
|
|
37
|
+
children?: ReactNode;
|
|
38
|
+
/**
|
|
39
|
+
* Layout that is forced on children form fields.
|
|
40
|
+
*/
|
|
41
|
+
fieldLayout?: Layout;
|
|
42
|
+
/**
|
|
43
|
+
* Width of the column with form field labels. Only available if the `fieldLayout` is set to
|
|
44
|
+
* `horizontal`.
|
|
45
|
+
*/
|
|
46
|
+
labelWidth?: FormLayoutLabelWidth;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Values `FormLayout` provides to the fields rendered inside it.
|
|
51
|
+
*/
|
|
52
|
+
export type FormLayoutContextValue = {
|
|
53
|
+
layout: Layout;
|
|
54
|
+
};
|
|
55
|
+
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
1
|
import React, { useContext } from 'react';
|
|
3
2
|
import { withGlobalProps } from '../../providers/globalProps';
|
|
4
3
|
import { classNames } from '../../helpers/classNames/classNames';
|
|
@@ -9,8 +8,9 @@ import { isChildrenEmpty } from '../../helpers/isChildrenEmpty/isChildrenEmpty';
|
|
|
9
8
|
import { FormLayoutContext } from './FormLayoutContext';
|
|
10
9
|
import { FormLayoutCustomFieldContext } from './FormLayoutCustomFieldContext';
|
|
11
10
|
import styles from './FormLayoutCustomField.module.scss';
|
|
11
|
+
import type { FormLayoutCustomFieldProps } from './FormLayoutCustomField.types';
|
|
12
12
|
|
|
13
|
-
const renderLabel = (id, label, labelForId) => {
|
|
13
|
+
const renderLabel = (id: string | undefined, label: string | undefined, labelForId: string | undefined) => {
|
|
14
14
|
if (labelForId && label) {
|
|
15
15
|
return (
|
|
16
16
|
<label
|
|
@@ -37,18 +37,18 @@ const renderLabel = (id, label, labelForId) => {
|
|
|
37
37
|
return null;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
export const FormLayoutCustomField = ({
|
|
40
|
+
export const FormLayoutCustomField: React.FunctionComponent<FormLayoutCustomFieldProps> = ({
|
|
41
41
|
children,
|
|
42
|
-
fullWidth,
|
|
42
|
+
fullWidth = false,
|
|
43
43
|
id,
|
|
44
|
-
disabled,
|
|
44
|
+
disabled = false,
|
|
45
45
|
innerFieldSize,
|
|
46
46
|
label,
|
|
47
47
|
labelForId,
|
|
48
|
-
required,
|
|
48
|
+
required = false,
|
|
49
49
|
validationState,
|
|
50
50
|
...restProps
|
|
51
|
-
}) => {
|
|
51
|
+
}: FormLayoutCustomFieldProps) => {
|
|
52
52
|
const context = useContext(FormLayoutContext);
|
|
53
53
|
|
|
54
54
|
if (isChildrenEmpty(children)) {
|
|
@@ -64,8 +64,8 @@ export const FormLayoutCustomField = ({
|
|
|
64
64
|
context && context.layout === 'horizontal' ? styles.isRootLayoutHorizontal : styles.isRootLayoutVertical,
|
|
65
65
|
disabled && styles.isRootDisabled,
|
|
66
66
|
required && styles.isRootRequired,
|
|
67
|
-
getRootSizeClassName(
|
|
68
|
-
getRootValidationStateClassName(
|
|
67
|
+
getRootSizeClassName(styles, innerFieldSize),
|
|
68
|
+
getRootValidationStateClassName(styles, validationState),
|
|
69
69
|
)}
|
|
70
70
|
id={id}
|
|
71
71
|
>
|
|
@@ -82,61 +82,6 @@ export const FormLayoutCustomField = ({
|
|
|
82
82
|
);
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
children: undefined,
|
|
87
|
-
disabled: false,
|
|
88
|
-
fullWidth: false,
|
|
89
|
-
id: undefined,
|
|
90
|
-
innerFieldSize: undefined,
|
|
91
|
-
label: undefined,
|
|
92
|
-
labelForId: undefined,
|
|
93
|
-
required: false,
|
|
94
|
-
validationState: undefined,
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
FormLayoutCustomField.propTypes = {
|
|
98
|
-
/**
|
|
99
|
-
* Custom HTML or React component(s). If none are provided nothing is rendered.
|
|
100
|
-
*/
|
|
101
|
-
children: PropTypes.node,
|
|
102
|
-
/**
|
|
103
|
-
* If `true`, label will be shown as disabled.
|
|
104
|
-
*/
|
|
105
|
-
disabled: PropTypes.bool,
|
|
106
|
-
/**
|
|
107
|
-
* If `true`, the field will span the full width of its parent.
|
|
108
|
-
*/
|
|
109
|
-
fullWidth: PropTypes.bool,
|
|
110
|
-
/**
|
|
111
|
-
* ID of the root HTML element.
|
|
112
|
-
*
|
|
113
|
-
* Also serves as base for ids of nested elements:
|
|
114
|
-
* * `<ID>__field`
|
|
115
|
-
* * `<ID>__label`
|
|
116
|
-
*/
|
|
117
|
-
id: PropTypes.string,
|
|
118
|
-
/**
|
|
119
|
-
* Size of contained form field used to properly align label.
|
|
120
|
-
*/
|
|
121
|
-
innerFieldSize: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
122
|
-
/**
|
|
123
|
-
* Optional label of the field.
|
|
124
|
-
*/
|
|
125
|
-
label: PropTypes.string,
|
|
126
|
-
/**
|
|
127
|
-
* Optional ID of labeled field to keep accessibility features. Only available if `label` is set.
|
|
128
|
-
*/
|
|
129
|
-
labelForId: PropTypes.string,
|
|
130
|
-
/**
|
|
131
|
-
* If `true`, label will be styled as required.
|
|
132
|
-
*/
|
|
133
|
-
required: PropTypes.bool,
|
|
134
|
-
/**
|
|
135
|
-
* Alter the field to provide feedback based on validation result.
|
|
136
|
-
*/
|
|
137
|
-
validationState: PropTypes.oneOf(['invalid', 'valid', 'warning']),
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
export const FormLayoutCustomFieldWithGlobalProps = withGlobalProps(FormLayoutCustomField, 'FormLayoutCustomField');
|
|
85
|
+
export const FormLayoutCustomFieldWithGlobalProps = withGlobalProps<FormLayoutCustomFieldProps, never>(FormLayoutCustomField, 'FormLayoutCustomField');
|
|
141
86
|
|
|
142
87
|
export default FormLayoutCustomFieldWithGlobalProps;
|