@react-ui-org/react-ui 0.64.0 → 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/scripts/write-lockfile-hash.sh +6 -0
- 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
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
HTMLAttributes,
|
|
3
|
+
ReactNode,
|
|
4
|
+
} from 'react';
|
|
5
|
+
import type {
|
|
6
|
+
Size,
|
|
7
|
+
ValidationState,
|
|
8
|
+
} from '../../types';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Props of the `FormLayoutCustomField` component.
|
|
12
|
+
*/
|
|
13
|
+
export type FormLayoutCustomFieldProps = HTMLAttributes<HTMLDivElement> & {
|
|
14
|
+
/**
|
|
15
|
+
* Custom HTML or React component(s). If none are provided nothing is rendered.
|
|
16
|
+
*/
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* If `true`, label will be shown as disabled.
|
|
20
|
+
*/
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* If `true`, the field will span the full width of its parent.
|
|
24
|
+
*/
|
|
25
|
+
fullWidth?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* ID of the root HTML element.
|
|
28
|
+
*
|
|
29
|
+
* Also serves as base for ids of nested elements:
|
|
30
|
+
* * `<ID>__field`
|
|
31
|
+
* * `<ID>__label`
|
|
32
|
+
*/
|
|
33
|
+
id?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Size of contained form field used to properly align label.
|
|
36
|
+
*/
|
|
37
|
+
innerFieldSize?: Size;
|
|
38
|
+
/**
|
|
39
|
+
* Optional label of the field.
|
|
40
|
+
*/
|
|
41
|
+
label?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Optional ID of labeled field to keep accessibility features. Only available if `label` is set.
|
|
44
|
+
*/
|
|
45
|
+
labelForId?: string;
|
|
46
|
+
/**
|
|
47
|
+
* If `true`, label will be styled as required.
|
|
48
|
+
*/
|
|
49
|
+
required?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Alter the field to provide feedback based on validation result.
|
|
52
|
+
*/
|
|
53
|
+
validationState?: ValidationState;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* `true` when rendered inside `FormLayoutCustomField`.
|
|
58
|
+
*/
|
|
59
|
+
export type FormLayoutCustomFieldContextValue = boolean;
|
|
@@ -49,7 +49,8 @@ there are longer validation messages or help texts.
|
|
|
49
49
|
|
|
50
50
|
The FormLayout supports buttons and all React UI form fields:
|
|
51
51
|
[Button](/components/Button), [CheckboxField](/components/CheckboxField),
|
|
52
|
-
[FileInputField](/components/FileInputField),
|
|
52
|
+
[FileInputField](/components/FileInputField),
|
|
53
|
+
[InputGroup](/components/InputGroup), [Radio](/components/Radio),
|
|
53
54
|
[SelectField](/components/SelectField), [TextArea](/components/TextArea),
|
|
54
55
|
[TextField](/components/TextField), and [Toggle](/components/Toggle).
|
|
55
56
|
|
|
@@ -210,9 +211,6 @@ auto width, and limited width. For cases where an individual manual width works
|
|
|
210
211
|
better, there is the **local custom width mode** which enables setting a width
|
|
211
212
|
that is applied just for the current FormLayout.
|
|
212
213
|
|
|
213
|
-
👉 All global label width options can be easily [customized](/docs/customize/theming/overview)
|
|
214
|
-
with CSS custom properties.
|
|
215
|
-
|
|
216
214
|
#### Label Width Options
|
|
217
215
|
|
|
218
216
|
- The `default` mode (global) sets the width of all labels to a **global default
|
|
@@ -438,13 +436,13 @@ helps to improve its accessibility.
|
|
|
438
436
|
|
|
439
437
|
## API
|
|
440
438
|
|
|
441
|
-
<docoff-react-props src="/components/FormLayout/FormLayout.
|
|
439
|
+
<docoff-react-props src="/components/FormLayout/FormLayout.tsx" name="FormLayout"></docoff-react-props>
|
|
442
440
|
|
|
443
441
|
### FormLayoutCustomField API
|
|
444
442
|
|
|
445
443
|
A place for custom content inside FormLayout.
|
|
446
444
|
|
|
447
|
-
<docoff-react-props src="/components/FormLayout/FormLayoutCustomField.
|
|
445
|
+
<docoff-react-props src="/components/FormLayout/FormLayoutCustomField.tsx" name="FormLayoutCustomField"></docoff-react-props>
|
|
448
446
|
|
|
449
447
|
## Theming
|
|
450
448
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { default as FormLayout } from './FormLayout';
|
|
2
|
+
export type {
|
|
3
|
+
FormLayoutContextValue,
|
|
4
|
+
FormLayoutLabelWidth,
|
|
5
|
+
FormLayoutPredefinedLabelWidth,
|
|
6
|
+
FormLayoutProps,
|
|
7
|
+
} from './FormLayout.types';
|
|
8
|
+
export { FormLayoutContext } from './FormLayoutContext';
|
|
9
|
+
export { FormLayoutCustomFieldContext } from './FormLayoutCustomFieldContext';
|
|
10
|
+
export type {
|
|
11
|
+
FormLayoutCustomFieldContextValue,
|
|
12
|
+
FormLayoutCustomFieldProps,
|
|
13
|
+
} from './FormLayoutCustomField.types';
|
|
14
|
+
export { default as FormLayoutCustomField } from './FormLayoutCustomField';
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
grid-template-columns: var(--rui-local-columns); // 2.
|
|
38
38
|
grid-template-rows: var(--rui-local-rows); // 2.
|
|
39
39
|
grid-auto-flow: var(--rui-local-auto-flow); // 2.
|
|
40
|
-
|
|
40
|
+
gap: var(--rui-local-row-gap) var(--rui-local-column-gap); // 2.
|
|
41
41
|
// stylelint-disable declaration-block-no-redundant-longhand-properties -- 3.
|
|
42
42
|
align-content: var(--rui-local-align-content); // 2.
|
|
43
43
|
align-items: var(--rui-local-align-items); // 2.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { withGlobalProps } from '../../providers/globalProps';
|
|
3
|
+
import { transferProps } from '../../helpers/transferProps';
|
|
4
|
+
import { isChildrenEmpty } from '../../helpers/isChildrenEmpty/isChildrenEmpty';
|
|
5
|
+
import { generateResponsiveCustomProperties } from './_helpers/generateResponsiveCustomProperties';
|
|
6
|
+
import styles from './Grid.module.scss';
|
|
7
|
+
import type { GridProps } from './Grid.types';
|
|
8
|
+
|
|
9
|
+
export const Grid: React.FunctionComponent<GridProps> = ({
|
|
10
|
+
alignContent,
|
|
11
|
+
alignItems,
|
|
12
|
+
autoFlow,
|
|
13
|
+
children,
|
|
14
|
+
columnGap = 4,
|
|
15
|
+
columns = '1fr',
|
|
16
|
+
justifyContent,
|
|
17
|
+
justifyItems,
|
|
18
|
+
rowGap = 4,
|
|
19
|
+
rows = 'auto',
|
|
20
|
+
tag: Tag = 'div',
|
|
21
|
+
...restProps
|
|
22
|
+
}: GridProps) => {
|
|
23
|
+
if (isChildrenEmpty(children)) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<Tag
|
|
29
|
+
{...transferProps(restProps)}
|
|
30
|
+
className={styles.root}
|
|
31
|
+
style={{
|
|
32
|
+
...generateResponsiveCustomProperties(columns, 'columns'),
|
|
33
|
+
...generateResponsiveCustomProperties(columnGap, 'column-gap', 'spacing'),
|
|
34
|
+
...generateResponsiveCustomProperties(rows, 'rows'),
|
|
35
|
+
...generateResponsiveCustomProperties(rowGap, 'row-gap', 'spacing'),
|
|
36
|
+
...generateResponsiveCustomProperties(autoFlow, 'auto-flow'),
|
|
37
|
+
...generateResponsiveCustomProperties(alignContent, 'align-content'),
|
|
38
|
+
...generateResponsiveCustomProperties(alignItems, 'align-items'),
|
|
39
|
+
...generateResponsiveCustomProperties(justifyContent, 'justify-content'),
|
|
40
|
+
...generateResponsiveCustomProperties(justifyItems, 'justify-items'),
|
|
41
|
+
}}
|
|
42
|
+
>
|
|
43
|
+
{children}
|
|
44
|
+
</Tag>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const GridWithGlobalProps = withGlobalProps<GridProps, HTMLElement>(Grid, 'Grid');
|
|
49
|
+
|
|
50
|
+
export default GridWithGlobalProps;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
HTMLAttributes,
|
|
3
|
+
JSX,
|
|
4
|
+
ReactNode,
|
|
5
|
+
} from 'react';
|
|
6
|
+
import type { Breakpoint } from '../../types';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A value that is either the same for all breakpoints or defined per breakpoint.
|
|
10
|
+
*/
|
|
11
|
+
export type GridResponsiveValue<Value> = Value | Partial<Record<Breakpoint, Value>>;
|
|
12
|
+
|
|
13
|
+
export type GridSpacingValue = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Any valid HTML tag.
|
|
17
|
+
*
|
|
18
|
+
* @docoffOverrideType string
|
|
19
|
+
*/
|
|
20
|
+
export type GridTag = keyof JSX.IntrinsicElements & keyof HTMLElementTagNameMap;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Props of the `Grid` component.
|
|
24
|
+
*/
|
|
25
|
+
export type GridProps = HTMLAttributes<HTMLElement> & {
|
|
26
|
+
/**
|
|
27
|
+
* Content alignment. Accepts any valid value of `align-content` CSS property.
|
|
28
|
+
* See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/align-content) for more.
|
|
29
|
+
*/
|
|
30
|
+
alignContent?: GridResponsiveValue<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Items alignment. Accepts any valid value of `align-items` CSS property.
|
|
33
|
+
* See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/align-items) for more.
|
|
34
|
+
*/
|
|
35
|
+
alignItems?: GridResponsiveValue<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Grid auto-flow algorithm to be used. Accepts any valid value of `grid-auto-flow` CSS property.
|
|
38
|
+
* See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow) for more.
|
|
39
|
+
*/
|
|
40
|
+
autoFlow?: GridResponsiveValue<string>;
|
|
41
|
+
/**
|
|
42
|
+
* Items to be aligned in the grid. If none are provided nothing is rendered.
|
|
43
|
+
*/
|
|
44
|
+
children?: ReactNode;
|
|
45
|
+
/**
|
|
46
|
+
* Gap between columns. Accepts any of [spacing values](/docs/foundation/spacing-values) as number.
|
|
47
|
+
* See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/column-gap) for more about `column-gap`.
|
|
48
|
+
*/
|
|
49
|
+
columnGap?: GridResponsiveValue<GridSpacingValue>;
|
|
50
|
+
/**
|
|
51
|
+
* Grid columns. Accepts any valid value of `grid-template-columns` CSS property.
|
|
52
|
+
* See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns) for more.
|
|
53
|
+
*/
|
|
54
|
+
columns?: GridResponsiveValue<string>;
|
|
55
|
+
/**
|
|
56
|
+
* Content justification. Accepts any valid value of `justify-content` CSS property.
|
|
57
|
+
* See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content) for more.
|
|
58
|
+
*/
|
|
59
|
+
justifyContent?: GridResponsiveValue<string>;
|
|
60
|
+
/**
|
|
61
|
+
* Items justification. Accepts any valid value of `justify-items` CSS property.
|
|
62
|
+
* See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-items) for more.
|
|
63
|
+
*/
|
|
64
|
+
justifyItems?: GridResponsiveValue<string>;
|
|
65
|
+
/**
|
|
66
|
+
* Gap between rows. Accepts any of [spacing values](/docs/foundation/spacing-values) as number.
|
|
67
|
+
* See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/row-gap) for more about `row-gap`.
|
|
68
|
+
*/
|
|
69
|
+
rowGap?: GridResponsiveValue<GridSpacingValue>;
|
|
70
|
+
/**
|
|
71
|
+
* Grid rows. Accepts any valid value of `grid-template-rows` CSS property.
|
|
72
|
+
* See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-rows) for more.
|
|
73
|
+
*/
|
|
74
|
+
rows?: GridResponsiveValue<string>;
|
|
75
|
+
/**
|
|
76
|
+
* HTML tag to render. Can be any valid HTML tag of your choice, usually a
|
|
77
|
+
* [block-level element](https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements).
|
|
78
|
+
*/
|
|
79
|
+
tag?: GridTag;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Props of the `GridSpan` component.
|
|
84
|
+
*/
|
|
85
|
+
export type GridSpanProps = HTMLAttributes<HTMLElement> & {
|
|
86
|
+
/**
|
|
87
|
+
* Items to be aligned in the grid. If none are provided nothing is rendered.
|
|
88
|
+
*/
|
|
89
|
+
children?: ReactNode;
|
|
90
|
+
/**
|
|
91
|
+
* Number of columns to span.
|
|
92
|
+
*/
|
|
93
|
+
columns?: GridResponsiveValue<number>;
|
|
94
|
+
/**
|
|
95
|
+
* Number of rows to span.
|
|
96
|
+
*/
|
|
97
|
+
rows?: GridResponsiveValue<number>;
|
|
98
|
+
/**
|
|
99
|
+
* HTML tag to render. Can be any valid HTML tag of your choice, usually a
|
|
100
|
+
* [block-level element](https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements).
|
|
101
|
+
*/
|
|
102
|
+
tag?: GridTag;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Value of a single breakpoint of a responsive Grid prop.
|
|
107
|
+
*/
|
|
108
|
+
export type GridResponsivePropertyValue = string | number;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { withGlobalProps } from '../../providers/globalProps';
|
|
3
|
+
import { transferProps } from '../../helpers/transferProps';
|
|
4
|
+
import { isChildrenEmpty } from '../../helpers/isChildrenEmpty/isChildrenEmpty';
|
|
5
|
+
import { generateResponsiveCustomProperties } from './_helpers/generateResponsiveCustomProperties';
|
|
6
|
+
import styles from './Grid.module.scss';
|
|
7
|
+
import type { GridSpanProps } from './Grid.types';
|
|
8
|
+
|
|
9
|
+
export const GridSpan: React.FunctionComponent<GridSpanProps> = ({
|
|
10
|
+
children,
|
|
11
|
+
columns = 1,
|
|
12
|
+
rows = 1,
|
|
13
|
+
tag: Tag = 'div',
|
|
14
|
+
...restProps
|
|
15
|
+
}: GridSpanProps) => {
|
|
16
|
+
if (isChildrenEmpty(children)) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<Tag
|
|
22
|
+
{...transferProps(restProps)}
|
|
23
|
+
className={styles.span}
|
|
24
|
+
style={{
|
|
25
|
+
...generateResponsiveCustomProperties(columns, 'column-span'),
|
|
26
|
+
...generateResponsiveCustomProperties(rows, 'row-span'),
|
|
27
|
+
}}
|
|
28
|
+
>
|
|
29
|
+
{children}
|
|
30
|
+
</Tag>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const GridSpanWithGlobalProps = withGlobalProps<GridSpanProps, HTMLElement>(GridSpan, 'GridSpan');
|
|
35
|
+
|
|
36
|
+
export default GridSpanWithGlobalProps;
|
|
@@ -263,13 +263,13 @@ accessibility.
|
|
|
263
263
|
|
|
264
264
|
## API
|
|
265
265
|
|
|
266
|
-
<docoff-react-props src="/components/Grid/Grid.
|
|
266
|
+
<docoff-react-props src="/components/Grid/Grid.tsx" name="Grid"></docoff-react-props>
|
|
267
267
|
|
|
268
268
|
### GridSpan API
|
|
269
269
|
|
|
270
270
|
Wrapper for content that should span multiple rows or columns.
|
|
271
271
|
|
|
272
|
-
<docoff-react-props src="/components/Grid/GridSpan.
|
|
272
|
+
<docoff-react-props src="/components/Grid/GridSpan.tsx" name="GridSpan"></docoff-react-props>
|
|
273
273
|
|
|
274
274
|
[grid-layout]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout
|
|
275
275
|
[grid-template-columns]: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Breakpoint } from '../../../types';
|
|
2
|
+
import type {
|
|
3
|
+
GridResponsivePropertyValue,
|
|
4
|
+
GridResponsiveValue,
|
|
5
|
+
} from '../Grid.types';
|
|
6
|
+
|
|
7
|
+
const prepareValueByType = (value: GridResponsivePropertyValue, type: 'spacing' | null) => {
|
|
8
|
+
if (type === 'spacing') {
|
|
9
|
+
return `var(--rui-dimension-space-${value})`;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return value;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const generateResponsiveCustomProperties = (
|
|
16
|
+
prop: GridResponsiveValue<GridResponsivePropertyValue> | undefined,
|
|
17
|
+
infix: string,
|
|
18
|
+
type: 'spacing' | null = null,
|
|
19
|
+
): Record<string, GridResponsivePropertyValue> | null => {
|
|
20
|
+
if (typeof prop === 'undefined') {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (typeof prop !== 'object') {
|
|
25
|
+
return { [`--rui-local-${infix}-xs`]: prepareValueByType(prop, type) };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return Object.keys(prop).reduce<Record<string, GridResponsivePropertyValue>>((acc, breakpoint) => ({
|
|
29
|
+
...acc,
|
|
30
|
+
[`--rui-local-${infix}-${breakpoint}`]: prepareValueByType(prop[breakpoint as Breakpoint] as GridResponsivePropertyValue, type),
|
|
31
|
+
}), {});
|
|
32
|
+
};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
1
|
import React, {
|
|
3
2
|
useContext,
|
|
4
3
|
useMemo,
|
|
5
4
|
} from 'react';
|
|
5
|
+
import type {
|
|
6
|
+
Key,
|
|
7
|
+
ReactElement,
|
|
8
|
+
} from 'react';
|
|
6
9
|
import { withGlobalProps } from '../../providers/globalProps';
|
|
7
10
|
import { classNames } from '../../helpers/classNames/classNames';
|
|
8
11
|
import { transferProps } from '../../helpers/transferProps';
|
|
@@ -10,24 +13,26 @@ import { getRootSizeClassName } from '../_helpers/getRootSizeClassName';
|
|
|
10
13
|
import { getRootValidationStateClassName } from '../_helpers/getRootValidationStateClassName';
|
|
11
14
|
import { isChildrenEmpty } from '../../helpers/isChildrenEmpty/isChildrenEmpty';
|
|
12
15
|
import { resolveContextOrProp } from '../_helpers/resolveContextOrProp';
|
|
13
|
-
import { FormLayoutContext } from '../FormLayout';
|
|
16
|
+
import { FormLayoutContext } from '../FormLayout/FormLayoutContext';
|
|
14
17
|
import { Text } from '../Text';
|
|
18
|
+
import type { ValidationState } from '../../types';
|
|
15
19
|
import { InputGroupContext } from './InputGroupContext';
|
|
16
20
|
import styles from './InputGroup.module.scss';
|
|
21
|
+
import type { InputGroupProps } from './InputGroup.types';
|
|
17
22
|
|
|
18
|
-
export const InputGroup = ({
|
|
23
|
+
export const InputGroup: React.FunctionComponent<InputGroupProps> = ({
|
|
19
24
|
children,
|
|
20
|
-
disabled,
|
|
25
|
+
disabled = false,
|
|
21
26
|
helpTexts,
|
|
22
27
|
id,
|
|
23
|
-
isLabelVisible,
|
|
28
|
+
isLabelVisible = true,
|
|
24
29
|
label,
|
|
25
|
-
layout,
|
|
26
|
-
required,
|
|
27
|
-
size,
|
|
30
|
+
layout = 'vertical',
|
|
31
|
+
required = false,
|
|
32
|
+
size = 'medium',
|
|
28
33
|
validationTexts,
|
|
29
34
|
...restProps
|
|
30
|
-
}) => {
|
|
35
|
+
}: InputGroupProps) => {
|
|
31
36
|
const formLayoutContext = useContext(FormLayoutContext);
|
|
32
37
|
const inputGroupContextValue = useMemo(() => ({
|
|
33
38
|
disabled,
|
|
@@ -39,14 +44,16 @@ export const InputGroup = ({
|
|
|
39
44
|
return null;
|
|
40
45
|
}
|
|
41
46
|
|
|
42
|
-
const validationState = children.reduce(
|
|
47
|
+
const validationState = React.Children.toArray(children).reduce<ValidationState | undefined>(
|
|
43
48
|
(state, child) => {
|
|
44
|
-
|
|
49
|
+
const childValidationState = (child as ReactElement<{ validationState?: ValidationState }>).props.validationState;
|
|
50
|
+
|
|
51
|
+
if (state === 'invalid' || (state === 'warning' && childValidationState === 'valid')) {
|
|
45
52
|
return state;
|
|
46
53
|
}
|
|
47
|
-
return
|
|
54
|
+
return childValidationState ?? state;
|
|
48
55
|
},
|
|
49
|
-
|
|
56
|
+
undefined,
|
|
50
57
|
);
|
|
51
58
|
|
|
52
59
|
return (
|
|
@@ -60,8 +67,8 @@ export const InputGroup = ({
|
|
|
60
67
|
: styles.isRootLayoutVertical,
|
|
61
68
|
disabled && styles.isRootDisabled,
|
|
62
69
|
required && styles.isRootRequired,
|
|
63
|
-
getRootSizeClassName(
|
|
64
|
-
getRootValidationStateClassName(
|
|
70
|
+
getRootSizeClassName(styles, size),
|
|
71
|
+
getRootValidationStateClassName(styles, validationState),
|
|
65
72
|
)}
|
|
66
73
|
disabled={disabled}
|
|
67
74
|
id={id}
|
|
@@ -96,7 +103,7 @@ export const InputGroup = ({
|
|
|
96
103
|
id={id && `${id}__helpTexts`}
|
|
97
104
|
>
|
|
98
105
|
{helpTexts.map((helpText) => (
|
|
99
|
-
<li key={helpText}>
|
|
106
|
+
<li key={helpText as Key}>
|
|
100
107
|
<Text blockLevel>
|
|
101
108
|
{helpText}
|
|
102
109
|
</Text>
|
|
@@ -110,7 +117,7 @@ export const InputGroup = ({
|
|
|
110
117
|
id={id && `${id}__validationTexts`}
|
|
111
118
|
>
|
|
112
119
|
{validationTexts.map((validationText) => (
|
|
113
|
-
<li key={validationText}>
|
|
120
|
+
<li key={validationText as Key}>
|
|
114
121
|
<Text blockLevel>
|
|
115
122
|
{validationText}
|
|
116
123
|
</Text>
|
|
@@ -123,77 +130,6 @@ export const InputGroup = ({
|
|
|
123
130
|
);
|
|
124
131
|
};
|
|
125
132
|
|
|
126
|
-
|
|
127
|
-
children: undefined,
|
|
128
|
-
disabled: false,
|
|
129
|
-
helpTexts: undefined,
|
|
130
|
-
id: undefined,
|
|
131
|
-
isLabelVisible: true,
|
|
132
|
-
layout: 'vertical',
|
|
133
|
-
required: false,
|
|
134
|
-
size: 'medium',
|
|
135
|
-
validationTexts: undefined,
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
InputGroup.propTypes = {
|
|
139
|
-
/**
|
|
140
|
-
* Supported elements to be grouped:
|
|
141
|
-
* * `Button`
|
|
142
|
-
* * `SelectField`
|
|
143
|
-
* * `TextField`
|
|
144
|
-
*
|
|
145
|
-
* If none are provided nothing is rendered.
|
|
146
|
-
*/
|
|
147
|
-
children: PropTypes.node,
|
|
148
|
-
/**
|
|
149
|
-
* If `true`, the whole input group with all nested inputs and buttons will be disabled.
|
|
150
|
-
*/
|
|
151
|
-
disabled: PropTypes.bool,
|
|
152
|
-
/**
|
|
153
|
-
* An array of help texts to be displayed.
|
|
154
|
-
*/
|
|
155
|
-
helpTexts: PropTypes.arrayOf(PropTypes.node),
|
|
156
|
-
/**
|
|
157
|
-
* ID of the root HTML element.
|
|
158
|
-
*
|
|
159
|
-
* Also serves as base for ids of nested elements:
|
|
160
|
-
* * `<ID>__label`
|
|
161
|
-
* * `<ID>__displayLabel`
|
|
162
|
-
* * `<ID>__group`
|
|
163
|
-
* * `<ID>__validationTexts`
|
|
164
|
-
*/
|
|
165
|
-
id: PropTypes.string,
|
|
166
|
-
/**
|
|
167
|
-
* If `false`, the label will be visually hidden (but remains accessible by assistive
|
|
168
|
-
* technologies).
|
|
169
|
-
*/
|
|
170
|
-
isLabelVisible: PropTypes.bool,
|
|
171
|
-
/**
|
|
172
|
-
* Input group label.
|
|
173
|
-
*/
|
|
174
|
-
label: PropTypes.node.isRequired,
|
|
175
|
-
/**
|
|
176
|
-
* Layout of the group.
|
|
177
|
-
*
|
|
178
|
-
* Ignored if the component is rendered within `FormLayout` component
|
|
179
|
-
* as the value is inherited in such case.
|
|
180
|
-
*/
|
|
181
|
-
layout: PropTypes.oneOf(['horizontal', 'vertical']),
|
|
182
|
-
/**
|
|
183
|
-
* If `true`, the `InputGroup`'s label appears as required. Underlying `<fieldset>`
|
|
184
|
-
* element does not take `required` attribute so there is no functional effect.
|
|
185
|
-
*/
|
|
186
|
-
required: PropTypes.bool,
|
|
187
|
-
/**
|
|
188
|
-
* Size of the `children` elements.
|
|
189
|
-
*/
|
|
190
|
-
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
191
|
-
/**
|
|
192
|
-
* An array of validation messages to be displayed.
|
|
193
|
-
*/
|
|
194
|
-
validationTexts: PropTypes.arrayOf(PropTypes.node),
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
export const InputGroupWithGlobalProps = withGlobalProps(InputGroup, 'InputGroup');
|
|
133
|
+
export const InputGroupWithGlobalProps = withGlobalProps<InputGroupProps, never>(InputGroup, 'InputGroup');
|
|
198
134
|
|
|
199
135
|
export default InputGroupWithGlobalProps;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
FieldsetHTMLAttributes,
|
|
3
|
+
ReactNode,
|
|
4
|
+
} from 'react';
|
|
5
|
+
import type {
|
|
6
|
+
Layout,
|
|
7
|
+
Size,
|
|
8
|
+
} from '../../types';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Props of the `InputGroup` component.
|
|
12
|
+
*/
|
|
13
|
+
export type InputGroupProps = Omit<FieldsetHTMLAttributes<HTMLFieldSetElement>, 'disabled'> & {
|
|
14
|
+
/**
|
|
15
|
+
* Supported elements to be grouped:
|
|
16
|
+
* * `Button`
|
|
17
|
+
* * `SelectField`
|
|
18
|
+
* * `TextField`
|
|
19
|
+
*
|
|
20
|
+
* If none are provided nothing is rendered.
|
|
21
|
+
*/
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* If `true`, the whole input group with all nested inputs and buttons will be disabled.
|
|
25
|
+
*/
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* An array of help texts to be displayed.
|
|
29
|
+
*/
|
|
30
|
+
helpTexts?: ReactNode[];
|
|
31
|
+
/**
|
|
32
|
+
* ID of the root HTML element.
|
|
33
|
+
*
|
|
34
|
+
* Also serves as base for ids of nested elements:
|
|
35
|
+
* * `<ID>__label`
|
|
36
|
+
* * `<ID>__displayLabel`
|
|
37
|
+
* * `<ID>__group`
|
|
38
|
+
* * `<ID>__validationTexts`
|
|
39
|
+
*/
|
|
40
|
+
id?: string;
|
|
41
|
+
/**
|
|
42
|
+
* If `false`, the label will be visually hidden (but remains accessible by assistive
|
|
43
|
+
* technologies).
|
|
44
|
+
*/
|
|
45
|
+
isLabelVisible?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Input group label.
|
|
48
|
+
*/
|
|
49
|
+
label: ReactNode;
|
|
50
|
+
/**
|
|
51
|
+
* Layout of the group.
|
|
52
|
+
*
|
|
53
|
+
* Ignored if the component is rendered within `FormLayout` component
|
|
54
|
+
* as the value is inherited in such case.
|
|
55
|
+
*/
|
|
56
|
+
layout?: Layout;
|
|
57
|
+
/**
|
|
58
|
+
* If `true`, the `InputGroup`'s label appears as required. Underlying `<fieldset>`
|
|
59
|
+
* element does not take `required` attribute so there is no functional effect.
|
|
60
|
+
*/
|
|
61
|
+
required?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Size of the `children` elements.
|
|
64
|
+
*/
|
|
65
|
+
size?: Size;
|
|
66
|
+
/**
|
|
67
|
+
* An array of validation messages to be displayed.
|
|
68
|
+
*/
|
|
69
|
+
validationTexts?: ReactNode[];
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Values `InputGroup` provides to the fields and buttons rendered inside it.
|
|
74
|
+
*/
|
|
75
|
+
export type InputGroupContextValue = {
|
|
76
|
+
disabled: boolean;
|
|
77
|
+
layout: Layout;
|
|
78
|
+
size: Size;
|
|
79
|
+
};
|
|
80
|
+
|
|
@@ -73,6 +73,10 @@ See [API](#api) for all available options.
|
|
|
73
73
|
[ButtonGroup](/components/ButtonGroup) component which is designed
|
|
74
74
|
specifically for that purpose.
|
|
75
75
|
|
|
76
|
+
- InputGroup can be used inside [FormLayout](/components/FormLayout). In that
|
|
77
|
+
case, its `layout` prop is ignored and the value is inherited from
|
|
78
|
+
FormLayout instead.
|
|
79
|
+
|
|
76
80
|
## Sizes
|
|
77
81
|
|
|
78
82
|
All existing field and button sizes are also available on the input group level:
|
|
@@ -318,7 +322,7 @@ and helps to improve its accessibility.
|
|
|
318
322
|
|
|
319
323
|
## API
|
|
320
324
|
|
|
321
|
-
<docoff-react-props src="/components/InputGroup/InputGroup.
|
|
325
|
+
<docoff-react-props src="/components/InputGroup/InputGroup.tsx" name="InputGroup"></docoff-react-props>
|
|
322
326
|
|
|
323
327
|
## Theming
|
|
324
328
|
|