@react-ui-org/react-ui 0.64.1 → 0.66.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 +1936 -0
- package/dist/react-ui.development.css +3591 -3003
- package/dist/react-ui.development.js +2028 -1060
- 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} +5 -2
- 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.module.scss +7 -3
- package/src/components/CheckboxField/CheckboxField.tsx +81 -0
- package/src/components/CheckboxField/CheckboxField.types.ts +64 -0
- package/src/components/CheckboxField/README.md +92 -45
- package/src/components/CheckboxField/index.ts +5 -0
- package/src/components/FileInputField/FileInputField.module.scss +7 -3
- package/src/components/FileInputField/{FileInputField.jsx → FileInputField.tsx} +43 -129
- package/src/components/FileInputField/FileInputField.types.ts +101 -0
- package/src/components/FileInputField/README.md +21 -4
- package/src/components/FileInputField/index.ts +6 -0
- package/src/components/FormLayout/FormLayout.module.scss +5 -7
- 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.module.scss +7 -3
- package/src/components/FormLayout/{FormLayoutCustomField.jsx → FormLayoutCustomField.tsx} +12 -67
- package/src/components/FormLayout/FormLayoutCustomField.types.ts +60 -0
- package/src/components/FormLayout/FormLayoutCustomFieldContext.ts +4 -0
- package/src/components/FormLayout/README.md +6 -15
- 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 +33 -0
- package/src/components/Grid/index.ts +9 -0
- package/src/components/InputGroup/InputGroup.module.scss +7 -3
- package/src/components/InputGroup/{InputGroup.jsx → InputGroup.tsx} +25 -95
- package/src/components/InputGroup/InputGroup.types.ts +80 -0
- package/src/components/InputGroup/InputGroupContext.ts +4 -0
- package/src/components/InputGroup/README.md +40 -8
- 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 +125 -48
- package/src/components/Radio/Radio.module.scss +7 -3
- package/src/components/Radio/Radio.tsx +116 -0
- package/src/components/Radio/Radio.types.ts +91 -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 +137 -51
- package/src/components/SelectField/SelectField.module.scss +7 -3
- package/src/components/SelectField/SelectField.tsx +139 -0
- package/src/components/SelectField/SelectField.types.ts +121 -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 +35 -14
- package/src/components/TextArea/TextArea.module.scss +7 -3
- package/src/components/TextArea/TextArea.tsx +95 -0
- package/src/components/TextArea/TextArea.types.ts +76 -0
- package/src/components/TextArea/index.ts +5 -0
- package/src/components/TextField/README.md +35 -13
- package/src/components/TextField/TextField.module.scss +7 -3
- package/src/components/TextField/TextField.tsx +112 -0
- package/src/components/TextField/TextField.types.ts +95 -0
- package/src/components/TextField/index.ts +6 -0
- package/src/components/TextLink/README.md +2 -2
- 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 +92 -45
- package/src/components/Toggle/Toggle.module.scss +7 -3
- package/src/components/Toggle/Toggle.tsx +82 -0
- package/src/components/Toggle/Toggle.types.ts +59 -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} +7 -2
- package/src/components/_helpers/{getRootPriorityClassName.js → getRootPriorityClassName.ts} +7 -2
- package/src/components/_helpers/{getRootSizeClassName.js → getRootSizeClassName.ts} +7 -2
- package/src/components/_helpers/getRootStateClassName.ts +24 -0
- 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/settings/_form-fields.scss +2 -1
- package/src/styles/theme/_form-fields.scss +16 -11
- package/src/styles/theme-constants/_colors.scss +21 -0
- package/src/styles/tools/_accessibility.scss +2 -2
- package/src/styles/tools/form-fields/_box-field-layout.scss +5 -8
- package/src/styles/tools/form-fields/_inline-field-elements.scss +0 -7
- package/src/styles/tools/form-fields/_inline-field-layout.scss +0 -8
- package/src/styles/tools/form-fields/_variants.scss +7 -7
- package/src/theme.scss +37 -12
- 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/states.ts +1 -0
- package/src/types/styles.ts +4 -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/Radio.jsx +0 -212
- 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/getRootValidationStateClassName.js +0 -15
- 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
|
@@ -47,8 +47,7 @@ See [API](#api) for all available options.
|
|
|
47
47
|
## Design Variants
|
|
48
48
|
|
|
49
49
|
To satisfy the design requirements of your project, all input fields in React UI
|
|
50
|
-
come in **two design variants** to choose from: outline and filled.
|
|
51
|
-
further [customized](#theming) with CSS custom properties.
|
|
50
|
+
come in **two design variants** to choose from: outline and filled.
|
|
52
51
|
|
|
53
52
|
```docoff-react-preview
|
|
54
53
|
<TextArea
|
|
@@ -109,11 +108,9 @@ Full-width fields span the full width of a parent:
|
|
|
109
108
|
|
|
110
109
|
## Input Size
|
|
111
110
|
|
|
112
|
-
The default width of all inputs is 240 px
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
the `rows` and `cols` properties. Additionally, text areas are vertically
|
|
116
|
-
resizable by users.
|
|
111
|
+
The default width of all inputs is 240 px. You can **control the size of
|
|
112
|
+
individual text areas** using the `rows` and `cols` properties. Additionally,
|
|
113
|
+
text areas are vertically resizable by users.
|
|
117
114
|
|
|
118
115
|
👉 Remember that the `cols` and `rows` HTML attributes **do not limit on how
|
|
119
116
|
many characters** the user can enter. Use the
|
|
@@ -255,7 +252,7 @@ what happened and what action they should take or what options they have.
|
|
|
255
252
|
<TextArea
|
|
256
253
|
label="Your feedback"
|
|
257
254
|
onChange={() => {}}
|
|
258
|
-
|
|
255
|
+
state="valid"
|
|
259
256
|
validationText="Looks good!"
|
|
260
257
|
value="Like that!"
|
|
261
258
|
required
|
|
@@ -263,21 +260,21 @@ what happened and what action they should take or what options they have.
|
|
|
263
260
|
<TextArea
|
|
264
261
|
label="Your feedback"
|
|
265
262
|
onChange={() => {}}
|
|
266
|
-
|
|
263
|
+
state="warning"
|
|
267
264
|
validationText="The feedback should be at least 3 characters long."
|
|
268
265
|
value=".."
|
|
269
266
|
required
|
|
270
267
|
/>
|
|
271
268
|
<TextArea
|
|
272
269
|
label="Your feedback"
|
|
273
|
-
|
|
270
|
+
state="invalid"
|
|
274
271
|
validationText="Please share your feedback with us."
|
|
275
272
|
required
|
|
276
273
|
/>
|
|
277
274
|
<TextArea
|
|
278
275
|
label="Your feedback"
|
|
279
276
|
onChange={() => {}}
|
|
280
|
-
|
|
277
|
+
state="valid"
|
|
281
278
|
validationText="Looks good!"
|
|
282
279
|
variant="filled"
|
|
283
280
|
value="Like that!"
|
|
@@ -286,7 +283,7 @@ what happened and what action they should take or what options they have.
|
|
|
286
283
|
<TextArea
|
|
287
284
|
label="Your feedback"
|
|
288
285
|
onChange={() => {}}
|
|
289
|
-
|
|
286
|
+
state="warning"
|
|
290
287
|
validationText="The feedback should be at least 3 characters long."
|
|
291
288
|
variant="filled"
|
|
292
289
|
value=".."
|
|
@@ -294,13 +291,37 @@ what happened and what action they should take or what options they have.
|
|
|
294
291
|
/>
|
|
295
292
|
<TextArea
|
|
296
293
|
label="Your feedback"
|
|
297
|
-
|
|
294
|
+
state="invalid"
|
|
298
295
|
validationText="Please share your feedback with us."
|
|
299
296
|
variant="filled"
|
|
300
297
|
required
|
|
301
298
|
/>
|
|
302
299
|
```
|
|
303
300
|
|
|
301
|
+
### Changed State
|
|
302
|
+
|
|
303
|
+
Changed state highlights fields whose value differs from the saved one, so users
|
|
304
|
+
can review their edits before saving.
|
|
305
|
+
|
|
306
|
+
A field shows one state at a time. When a changed value is also invalid, it's
|
|
307
|
+
up to you to pick the state that matters more to the user.
|
|
308
|
+
|
|
309
|
+
```docoff-react-preview
|
|
310
|
+
<TextArea
|
|
311
|
+
label="Your feedback"
|
|
312
|
+
onChange={() => {}}
|
|
313
|
+
state="changed"
|
|
314
|
+
value="Like that!"
|
|
315
|
+
/>
|
|
316
|
+
<TextArea
|
|
317
|
+
label="Your feedback"
|
|
318
|
+
onChange={() => {}}
|
|
319
|
+
state="changed"
|
|
320
|
+
variant="filled"
|
|
321
|
+
value="Like that!"
|
|
322
|
+
/>
|
|
323
|
+
```
|
|
324
|
+
|
|
304
325
|
### Disabled State
|
|
305
326
|
|
|
306
327
|
It's possible to disable the whole input.
|
|
@@ -353,7 +374,7 @@ If you provide [ref], it is forwarded to the native HTML `<textarea>` element.
|
|
|
353
374
|
|
|
354
375
|
## API
|
|
355
376
|
|
|
356
|
-
<docoff-react-props src="/components/TextArea/TextArea.
|
|
377
|
+
<docoff-react-props src="/components/TextArea/TextArea.tsx" name="TextArea"></docoff-react-props>
|
|
357
378
|
|
|
358
379
|
## Theming
|
|
359
380
|
|
|
@@ -47,16 +47,20 @@
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
// States
|
|
50
|
+
.isRootStateChanged {
|
|
51
|
+
@include variants.state(changed);
|
|
52
|
+
}
|
|
53
|
+
|
|
50
54
|
.isRootStateInvalid {
|
|
51
|
-
@include variants.
|
|
55
|
+
@include variants.state(invalid);
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
.isRootStateValid {
|
|
55
|
-
@include variants.
|
|
59
|
+
@include variants.state(valid);
|
|
56
60
|
}
|
|
57
61
|
|
|
58
62
|
.isRootStateWarning {
|
|
59
|
-
@include variants.
|
|
63
|
+
@include variants.state(warning);
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
// Invisible label
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { withGlobalProps } from '../../providers/globalProps';
|
|
3
|
+
import { classNames } from '../../helpers/classNames/classNames';
|
|
4
|
+
import { transferProps } from '../../helpers/transferProps';
|
|
5
|
+
import { getRootSizeClassName } from '../_helpers/getRootSizeClassName';
|
|
6
|
+
import { getRootStateClassName } from '../_helpers/getRootStateClassName';
|
|
7
|
+
import { resolveContextOrProp } from '../_helpers/resolveContextOrProp';
|
|
8
|
+
import { FormLayoutContext } from '../FormLayout/FormLayoutContext';
|
|
9
|
+
import { FormLayoutCustomFieldContext } from '../FormLayout/FormLayoutCustomFieldContext';
|
|
10
|
+
import styles from './TextArea.module.scss';
|
|
11
|
+
import type { TextAreaProps } from './TextArea.types';
|
|
12
|
+
|
|
13
|
+
export const TextArea = React.forwardRef<HTMLTextAreaElement, TextAreaProps>(({
|
|
14
|
+
disabled = false,
|
|
15
|
+
fullWidth = false,
|
|
16
|
+
helpText,
|
|
17
|
+
id,
|
|
18
|
+
isLabelVisible = true,
|
|
19
|
+
label,
|
|
20
|
+
layout = 'vertical',
|
|
21
|
+
required = false,
|
|
22
|
+
size = 'medium',
|
|
23
|
+
state,
|
|
24
|
+
validationText,
|
|
25
|
+
variant = 'outline',
|
|
26
|
+
...restProps
|
|
27
|
+
}, ref) => {
|
|
28
|
+
const context = useContext(FormLayoutContext);
|
|
29
|
+
const formLayoutCustomFieldContext = useContext(FormLayoutCustomFieldContext);
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<label
|
|
33
|
+
className={classNames(
|
|
34
|
+
styles.root,
|
|
35
|
+
fullWidth && styles.isRootFullWidth,
|
|
36
|
+
context && styles.isRootInFormLayout,
|
|
37
|
+
resolveContextOrProp(context && context.layout, layout) === 'horizontal'
|
|
38
|
+
? styles.isRootLayoutHorizontal
|
|
39
|
+
: styles.isRootLayoutVertical,
|
|
40
|
+
disabled && styles.isRootDisabled,
|
|
41
|
+
required && styles.isRootRequired,
|
|
42
|
+
getRootSizeClassName(styles, size),
|
|
43
|
+
getRootStateClassName(styles, state),
|
|
44
|
+
variant === 'filled' ? styles.isRootVariantFilled : styles.isRootVariantOutline,
|
|
45
|
+
)}
|
|
46
|
+
htmlFor={id}
|
|
47
|
+
id={id && `${id}__label`}
|
|
48
|
+
>
|
|
49
|
+
<div
|
|
50
|
+
className={classNames(
|
|
51
|
+
styles.label,
|
|
52
|
+
(!isLabelVisible || formLayoutCustomFieldContext) && styles.isLabelHidden,
|
|
53
|
+
)}
|
|
54
|
+
id={id && `${id}__labelText`}
|
|
55
|
+
>
|
|
56
|
+
{label}
|
|
57
|
+
</div>
|
|
58
|
+
<div className={styles.field}>
|
|
59
|
+
<div className={styles.inputContainer}>
|
|
60
|
+
<textarea
|
|
61
|
+
{...transferProps(restProps)}
|
|
62
|
+
className={styles.input}
|
|
63
|
+
disabled={disabled}
|
|
64
|
+
id={id}
|
|
65
|
+
ref={ref}
|
|
66
|
+
required={required}
|
|
67
|
+
/>
|
|
68
|
+
{variant === 'filled' && (
|
|
69
|
+
<div className={styles.bottomLine} />
|
|
70
|
+
)}
|
|
71
|
+
</div>
|
|
72
|
+
{helpText && (
|
|
73
|
+
<div
|
|
74
|
+
className={styles.helpText}
|
|
75
|
+
id={id && `${id}__helpText`}
|
|
76
|
+
>
|
|
77
|
+
{helpText}
|
|
78
|
+
</div>
|
|
79
|
+
)}
|
|
80
|
+
{validationText && (
|
|
81
|
+
<div
|
|
82
|
+
className={styles.validationText}
|
|
83
|
+
id={id && `${id}__validationText`}
|
|
84
|
+
>
|
|
85
|
+
{validationText}
|
|
86
|
+
</div>
|
|
87
|
+
)}
|
|
88
|
+
</div>
|
|
89
|
+
</label>
|
|
90
|
+
);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
export const TextAreaWithGlobalProps = withGlobalProps<TextAreaProps, HTMLTextAreaElement>(TextArea, 'TextArea');
|
|
94
|
+
|
|
95
|
+
export default TextAreaWithGlobalProps;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ReactNode,
|
|
3
|
+
TextareaHTMLAttributes,
|
|
4
|
+
} from 'react';
|
|
5
|
+
import type {
|
|
6
|
+
Layout,
|
|
7
|
+
Size,
|
|
8
|
+
State,
|
|
9
|
+
} from '../../types';
|
|
10
|
+
|
|
11
|
+
export type TextAreaVariant = 'filled' | 'outline';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Props of the `TextArea` component.
|
|
15
|
+
*/
|
|
16
|
+
export type TextAreaProps = TextareaHTMLAttributes<HTMLTextAreaElement> & {
|
|
17
|
+
/**
|
|
18
|
+
* If `true`, the input will be disabled.
|
|
19
|
+
*/
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* If `true`, the field will span the full width of its parent.
|
|
23
|
+
*/
|
|
24
|
+
fullWidth?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Optional help text.
|
|
27
|
+
*/
|
|
28
|
+
helpText?: ReactNode;
|
|
29
|
+
/** ID of the input HTML element. It also serves as a prefix for nested elements:
|
|
30
|
+
* * `<ID>__label`
|
|
31
|
+
* * `<ID>__labelText`
|
|
32
|
+
* * `<ID>__helpText`
|
|
33
|
+
* * `<ID>__validationText`
|
|
34
|
+
*/
|
|
35
|
+
id?: string;
|
|
36
|
+
/**
|
|
37
|
+
* If `false`, the label will be visually hidden (but remains accessible by assistive
|
|
38
|
+
* technologies).
|
|
39
|
+
*
|
|
40
|
+
* Automatically set to `false` when the component is rendered within `FormLayoutCustomField`
|
|
41
|
+
* component.
|
|
42
|
+
*/
|
|
43
|
+
isLabelVisible?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Text field label.
|
|
46
|
+
*/
|
|
47
|
+
label: ReactNode;
|
|
48
|
+
/**
|
|
49
|
+
* Layout of the field.
|
|
50
|
+
*
|
|
51
|
+
* Ignored if the component is rendered within `FormLayout` component
|
|
52
|
+
* as the value is inherited in such case.
|
|
53
|
+
*/
|
|
54
|
+
layout?: Layout;
|
|
55
|
+
/**
|
|
56
|
+
* If `true`, the input will be required.
|
|
57
|
+
*/
|
|
58
|
+
required?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Size of the field.
|
|
61
|
+
*/
|
|
62
|
+
size?: Size;
|
|
63
|
+
/**
|
|
64
|
+
* Alter the field to reflect the state of its data, e.g. a validation result or a change
|
|
65
|
+
* against the saved value.
|
|
66
|
+
*/
|
|
67
|
+
state?: State;
|
|
68
|
+
/**
|
|
69
|
+
* Validation message to be displayed.
|
|
70
|
+
*/
|
|
71
|
+
validationText?: ReactNode;
|
|
72
|
+
/**
|
|
73
|
+
* Design variant of the field, further customizable with CSS custom properties.
|
|
74
|
+
*/
|
|
75
|
+
variant?: TextAreaVariant;
|
|
76
|
+
};
|
|
@@ -60,8 +60,7 @@ See [API](#api) for all available options.
|
|
|
60
60
|
## Design Variants
|
|
61
61
|
|
|
62
62
|
To satisfy the design requirements of your project, all input fields in React UI
|
|
63
|
-
come in **two design variants** to choose from: outline and filled.
|
|
64
|
-
further [customized](#theming) with CSS custom properties.
|
|
63
|
+
come in **two design variants** to choose from: outline and filled.
|
|
65
64
|
|
|
66
65
|
```docoff-react-preview
|
|
67
66
|
<TextField
|
|
@@ -166,8 +165,7 @@ and `tel` types at your disposal.
|
|
|
166
165
|
|
|
167
166
|
## Input Size
|
|
168
167
|
|
|
169
|
-
The default width of all inputs is 240 px
|
|
170
|
-
with a CSS custom property. However, you can also **change the width of
|
|
168
|
+
The default width of all inputs is 240 px. You can **change the width of
|
|
171
169
|
individual text fields** using the `inputSize` property. It (obviously) sets the
|
|
172
170
|
`size` attribute of the `input` element and is further picked up by CSS to
|
|
173
171
|
normalize rendering across browsers.
|
|
@@ -379,7 +377,7 @@ have.
|
|
|
379
377
|
<TextField
|
|
380
378
|
label="User name"
|
|
381
379
|
onChange={() => {}}
|
|
382
|
-
|
|
380
|
+
state="valid"
|
|
383
381
|
validationText="Looks good!"
|
|
384
382
|
value="johnny1986"
|
|
385
383
|
required
|
|
@@ -387,7 +385,7 @@ have.
|
|
|
387
385
|
<TextField
|
|
388
386
|
label="User name"
|
|
389
387
|
onChange={() => {}}
|
|
390
|
-
|
|
388
|
+
state="warning"
|
|
391
389
|
validationText={(
|
|
392
390
|
<>
|
|
393
391
|
Account with this name already exists, pick a different one.
|
|
@@ -400,14 +398,14 @@ have.
|
|
|
400
398
|
/>
|
|
401
399
|
<TextField
|
|
402
400
|
label="User name"
|
|
403
|
-
|
|
401
|
+
state="invalid"
|
|
404
402
|
validationText="Please enter a user name of your choice."
|
|
405
403
|
required
|
|
406
404
|
/>
|
|
407
405
|
<TextField
|
|
408
406
|
label="User name"
|
|
409
407
|
onChange={() => {}}
|
|
410
|
-
|
|
408
|
+
state="valid"
|
|
411
409
|
validationText="Looks good!"
|
|
412
410
|
variant="filled"
|
|
413
411
|
value="johnny1986"
|
|
@@ -416,7 +414,7 @@ have.
|
|
|
416
414
|
<TextField
|
|
417
415
|
label="User name"
|
|
418
416
|
onChange={() => {}}
|
|
419
|
-
|
|
417
|
+
state="warning"
|
|
420
418
|
validationText={(
|
|
421
419
|
<>
|
|
422
420
|
Account with this name already exists, pick a different one.
|
|
@@ -430,13 +428,37 @@ have.
|
|
|
430
428
|
/>
|
|
431
429
|
<TextField
|
|
432
430
|
label="User name"
|
|
433
|
-
|
|
431
|
+
state="invalid"
|
|
434
432
|
validationText="Please enter a user name of your choice."
|
|
435
433
|
variant="filled"
|
|
436
434
|
required
|
|
437
435
|
/>
|
|
438
436
|
```
|
|
439
437
|
|
|
438
|
+
### Changed State
|
|
439
|
+
|
|
440
|
+
Changed state highlights fields whose value differs from the saved one, so users
|
|
441
|
+
can review their edits before saving.
|
|
442
|
+
|
|
443
|
+
A field shows one state at a time. When a changed value is also invalid, it's
|
|
444
|
+
up to you to pick the state that matters more to the user.
|
|
445
|
+
|
|
446
|
+
```docoff-react-preview
|
|
447
|
+
<TextField
|
|
448
|
+
label="User name"
|
|
449
|
+
onChange={() => {}}
|
|
450
|
+
state="changed"
|
|
451
|
+
value="johnny1986"
|
|
452
|
+
/>
|
|
453
|
+
<TextField
|
|
454
|
+
label="User name"
|
|
455
|
+
onChange={() => {}}
|
|
456
|
+
state="changed"
|
|
457
|
+
variant="filled"
|
|
458
|
+
value="johnny1986"
|
|
459
|
+
/>
|
|
460
|
+
```
|
|
461
|
+
|
|
440
462
|
### Disabled State
|
|
441
463
|
|
|
442
464
|
It's possible to disable the whole input.
|
|
@@ -512,11 +534,12 @@ If you provide [ref], it is forwarded to the native HTML `<input>` element.
|
|
|
512
534
|
|
|
513
535
|
## API
|
|
514
536
|
|
|
515
|
-
<docoff-react-props src="/components/TextField/TextField.
|
|
537
|
+
<docoff-react-props src="/components/TextField/TextField.tsx" name="TextField"></docoff-react-props>
|
|
516
538
|
|
|
517
539
|
## Theming
|
|
518
540
|
|
|
519
|
-
Head to [Forms Theming]
|
|
541
|
+
Head to [Forms Theming](/docs/customize/theming/forms) to see shared form
|
|
542
|
+
theming options.
|
|
520
543
|
|
|
521
544
|
[pattern]: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/pattern
|
|
522
545
|
[autocomplete]: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete
|
|
@@ -528,6 +551,5 @@ Head to [Forms Theming][theming-forms] to see shared form theming options.
|
|
|
528
551
|
[input-number]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number#additional_attributes
|
|
529
552
|
[input-tel]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/tel#additional_attributes
|
|
530
553
|
[input-password]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/password#additional_attributes
|
|
531
|
-
[theming-forms]: /docs/customize/theming/forms
|
|
532
554
|
[React common props]: https://react.dev/reference/react-dom/components/common#common-props
|
|
533
555
|
[ref]: https://reactjs.org/docs/refs-and-the-dom.html
|
|
@@ -50,16 +50,20 @@
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
// States
|
|
53
|
+
.isRootStateChanged {
|
|
54
|
+
@include variants.state(changed);
|
|
55
|
+
}
|
|
56
|
+
|
|
53
57
|
.isRootStateInvalid {
|
|
54
|
-
@include variants.
|
|
58
|
+
@include variants.state(invalid);
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
.isRootStateValid {
|
|
58
|
-
@include variants.
|
|
62
|
+
@include variants.state(valid);
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
.isRootStateWarning {
|
|
62
|
-
@include variants.
|
|
66
|
+
@include variants.state(warning);
|
|
63
67
|
}
|
|
64
68
|
|
|
65
69
|
// Invisible label
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import type { CSSProperties } from 'react';
|
|
3
|
+
import { withGlobalProps } from '../../providers/globalProps';
|
|
4
|
+
import { classNames } from '../../helpers/classNames/classNames';
|
|
5
|
+
import { transferProps } from '../../helpers/transferProps';
|
|
6
|
+
import { getRootSizeClassName } from '../_helpers/getRootSizeClassName';
|
|
7
|
+
import { getRootStateClassName } from '../_helpers/getRootStateClassName';
|
|
8
|
+
import { resolveContextOrProp } from '../_helpers/resolveContextOrProp';
|
|
9
|
+
import { FormLayoutContext } from '../FormLayout/FormLayoutContext';
|
|
10
|
+
import { FormLayoutCustomFieldContext } from '../FormLayout/FormLayoutCustomFieldContext';
|
|
11
|
+
import { InputGroupContext } from '../InputGroup/InputGroupContext';
|
|
12
|
+
import styles from './TextField.module.scss';
|
|
13
|
+
import type { TextFieldProps } from './TextField.types';
|
|
14
|
+
|
|
15
|
+
const SMALL_INPUT_SIZE = 10;
|
|
16
|
+
|
|
17
|
+
export const TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(({
|
|
18
|
+
disabled = false,
|
|
19
|
+
fullWidth = false,
|
|
20
|
+
helpText,
|
|
21
|
+
id,
|
|
22
|
+
inputSize,
|
|
23
|
+
isLabelVisible = true,
|
|
24
|
+
label,
|
|
25
|
+
layout = 'vertical',
|
|
26
|
+
required = false,
|
|
27
|
+
size = 'medium',
|
|
28
|
+
state,
|
|
29
|
+
type = 'text',
|
|
30
|
+
validationText,
|
|
31
|
+
variant = 'outline',
|
|
32
|
+
...restProps
|
|
33
|
+
}, ref) => {
|
|
34
|
+
const formLayoutContext = useContext(FormLayoutContext);
|
|
35
|
+
const formLayoutCustomFieldContext = useContext(FormLayoutCustomFieldContext);
|
|
36
|
+
const inputGroupContext = useContext(InputGroupContext);
|
|
37
|
+
const hasSmallInput = (inputSize !== undefined) && (inputSize <= SMALL_INPUT_SIZE);
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<label
|
|
41
|
+
className={classNames(
|
|
42
|
+
styles.root,
|
|
43
|
+
fullWidth && styles.isRootFullWidth,
|
|
44
|
+
hasSmallInput && styles.hasRootSmallInput,
|
|
45
|
+
inputSize && styles.hasRootCustomInputSize,
|
|
46
|
+
formLayoutContext && styles.isRootInFormLayout,
|
|
47
|
+
resolveContextOrProp(inputGroupContext && inputGroupContext.disabled, disabled) && styles.isRootDisabled,
|
|
48
|
+
resolveContextOrProp(formLayoutContext && formLayoutContext.layout, layout) === 'horizontal'
|
|
49
|
+
? styles.isRootLayoutHorizontal
|
|
50
|
+
: styles.isRootLayoutVertical,
|
|
51
|
+
inputGroupContext && styles.isRootGrouped,
|
|
52
|
+
required && styles.isRootRequired,
|
|
53
|
+
getRootSizeClassName(
|
|
54
|
+
styles,
|
|
55
|
+
resolveContextOrProp(inputGroupContext && inputGroupContext.size, size),
|
|
56
|
+
),
|
|
57
|
+
getRootStateClassName(styles, state),
|
|
58
|
+
variant === 'filled' ? styles.isRootVariantFilled : styles.isRootVariantOutline,
|
|
59
|
+
)}
|
|
60
|
+
htmlFor={id}
|
|
61
|
+
id={id && `${id}__label`}
|
|
62
|
+
{...(inputSize ? { style: { '--rui-custom-input-size': inputSize } as CSSProperties } : {})}
|
|
63
|
+
>
|
|
64
|
+
<div
|
|
65
|
+
className={classNames(
|
|
66
|
+
styles.label,
|
|
67
|
+
(!isLabelVisible || inputGroupContext || formLayoutCustomFieldContext) && styles.isLabelHidden,
|
|
68
|
+
)}
|
|
69
|
+
id={id && `${id}__labelText`}
|
|
70
|
+
>
|
|
71
|
+
{label}
|
|
72
|
+
</div>
|
|
73
|
+
<div className={styles.field}>
|
|
74
|
+
<div className={styles.inputContainer}>
|
|
75
|
+
<input
|
|
76
|
+
{...transferProps(restProps)}
|
|
77
|
+
className={styles.input}
|
|
78
|
+
disabled={resolveContextOrProp(inputGroupContext && inputGroupContext.disabled, disabled)}
|
|
79
|
+
id={id}
|
|
80
|
+
ref={ref}
|
|
81
|
+
required={required}
|
|
82
|
+
size={type !== 'number' ? inputSize : undefined}
|
|
83
|
+
type={type}
|
|
84
|
+
/>
|
|
85
|
+
{variant === 'filled' && (
|
|
86
|
+
<div className={styles.bottomLine} />
|
|
87
|
+
)}
|
|
88
|
+
</div>
|
|
89
|
+
{(helpText && !inputGroupContext) && (
|
|
90
|
+
<div
|
|
91
|
+
className={styles.helpText}
|
|
92
|
+
id={id && `${id}__helpText`}
|
|
93
|
+
>
|
|
94
|
+
{helpText}
|
|
95
|
+
</div>
|
|
96
|
+
)}
|
|
97
|
+
{(validationText && !inputGroupContext) && (
|
|
98
|
+
<div
|
|
99
|
+
className={styles.validationText}
|
|
100
|
+
id={id && `${id}__validationText`}
|
|
101
|
+
>
|
|
102
|
+
{validationText}
|
|
103
|
+
</div>
|
|
104
|
+
)}
|
|
105
|
+
</div>
|
|
106
|
+
</label>
|
|
107
|
+
);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
export const TextFieldWithGlobalProps = withGlobalProps<TextFieldProps, HTMLInputElement>(TextField, 'TextField');
|
|
111
|
+
|
|
112
|
+
export default TextFieldWithGlobalProps;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
InputHTMLAttributes,
|
|
3
|
+
ReactNode,
|
|
4
|
+
} from 'react';
|
|
5
|
+
import type {
|
|
6
|
+
Layout,
|
|
7
|
+
Size,
|
|
8
|
+
State,
|
|
9
|
+
} from '../../types';
|
|
10
|
+
|
|
11
|
+
export type TextFieldType = 'email' | 'number' | 'password' | 'tel' | 'text';
|
|
12
|
+
|
|
13
|
+
export type TextFieldVariant = 'filled' | 'outline';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Props of the `TextField` component.
|
|
17
|
+
*/
|
|
18
|
+
export type TextFieldProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'type'> & {
|
|
19
|
+
/**
|
|
20
|
+
* If `true`, the input will be disabled.
|
|
21
|
+
*/
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* If `true`, the field will span the full width of its parent.
|
|
25
|
+
*/
|
|
26
|
+
fullWidth?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Optional help text.
|
|
29
|
+
*
|
|
30
|
+
* Help text is never rendered when the component is placed into `InputGroup`.
|
|
31
|
+
* If a help text is needed, it must be defined on the `InputGroup` component instead.
|
|
32
|
+
*/
|
|
33
|
+
helpText?: ReactNode;
|
|
34
|
+
/**
|
|
35
|
+
* ID of the input HTML element. It also serves as a prefix for nested elements:
|
|
36
|
+
* * `<ID>__label`
|
|
37
|
+
* * `<ID>__labelText`
|
|
38
|
+
* * `<ID>__helpText`
|
|
39
|
+
* * `<ID>__validationText`
|
|
40
|
+
*/
|
|
41
|
+
id?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Width of the input field. Translated as `size` attribute for input types other than `number`.
|
|
44
|
+
*/
|
|
45
|
+
inputSize?: number;
|
|
46
|
+
/**
|
|
47
|
+
* If `false`, the label will be visually hidden (but remains accessible by assistive
|
|
48
|
+
* technologies).
|
|
49
|
+
*
|
|
50
|
+
* Automatically set to `false` when the component is rendered within `InputGroup` or
|
|
51
|
+
* `FormLayoutCustomField` component.
|
|
52
|
+
*/
|
|
53
|
+
isLabelVisible?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Text field label.
|
|
56
|
+
*/
|
|
57
|
+
label: ReactNode;
|
|
58
|
+
/**
|
|
59
|
+
* Layout of the field.
|
|
60
|
+
*
|
|
61
|
+
* Ignored if the component is rendered within `FormLayout` component
|
|
62
|
+
* as the value is inherited in such case.
|
|
63
|
+
*/
|
|
64
|
+
layout?: Layout;
|
|
65
|
+
/**
|
|
66
|
+
* If `true`, the input will be required.
|
|
67
|
+
*/
|
|
68
|
+
required?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Size of the field.
|
|
71
|
+
*
|
|
72
|
+
* Ignored if the component is rendered within `InputGroup` component as the value is inherited in such case.
|
|
73
|
+
*/
|
|
74
|
+
size?: Size;
|
|
75
|
+
/**
|
|
76
|
+
* Alter the field to reflect the state of its data, e.g. a validation result or a change
|
|
77
|
+
* against the saved value.
|
|
78
|
+
*/
|
|
79
|
+
state?: State;
|
|
80
|
+
/**
|
|
81
|
+
* HTML input type, translated as `type` attribute of the input.
|
|
82
|
+
*/
|
|
83
|
+
type?: TextFieldType;
|
|
84
|
+
/**
|
|
85
|
+
* Validation message to be displayed.
|
|
86
|
+
*
|
|
87
|
+
* Validation text is never rendered when the component is placed into `InputGroup`.
|
|
88
|
+
* If a validation text is needed, it must be defined on the `InputGroup` component instead.
|
|
89
|
+
*/
|
|
90
|
+
validationText?: ReactNode;
|
|
91
|
+
/**
|
|
92
|
+
* Design variant of the field, further customizable with CSS custom properties.
|
|
93
|
+
*/
|
|
94
|
+
variant?: TextFieldVariant;
|
|
95
|
+
};
|