@react-ui-org/react-ui 0.52.1 → 0.54.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 +10 -7
- package/dist/react-ui.css +5 -3
- package/dist/react-ui.development.css +11302 -0
- package/dist/react-ui.development.js +1588 -0
- package/dist/react-ui.js +1 -1
- package/package.json +66 -77
- package/src/{lib/components → components}/Alert/Alert.jsx +1 -1
- package/src/{lib/components/Alert/README.mdx → components/Alert/README.md} +84 -100
- package/src/{lib/components → components}/Badge/Badge.jsx +1 -1
- package/src/{lib/components → components}/Badge/Badge.scss +1 -1
- package/src/components/Badge/README.md +103 -0
- package/src/{lib/components → components}/Button/Button.jsx +1 -1
- package/src/components/Button/README.md +580 -0
- package/src/{lib/components → components}/ButtonGroup/ButtonGroup.jsx +11 -9
- package/src/{lib/components/ButtonGroup/README.mdx → components/ButtonGroup/README.md} +128 -134
- package/src/{lib/components → components}/Card/Card.jsx +1 -1
- package/src/components/Card/README.md +314 -0
- package/src/{lib/components/CheckboxField/README.mdx → components/CheckboxField/README.md} +96 -108
- package/src/{lib/components/FileInputField/README.mdx → components/FileInputField/README.md} +83 -95
- package/src/{lib/components → components}/FormLayout/FormLayout.jsx +4 -4
- package/src/components/FormLayout/README.md +462 -0
- package/src/{lib/components → components}/Grid/Grid.jsx +2 -2
- package/src/components/Grid/README.md +281 -0
- package/src/{lib/components → components}/InputGroup/InputGroup.jsx +28 -19
- package/src/{lib/components → components}/InputGroup/InputGroup.scss +4 -5
- package/src/{lib/components/InputGroup/README.mdx → components/InputGroup/README.md} +162 -165
- package/src/{lib/components → components}/Modal/Modal.jsx +6 -6
- package/src/components/Modal/README.md +1090 -0
- package/src/components/Modal/_hooks/useModalScrollPrevention.js +37 -0
- package/src/{lib/components/Paper/README.mdx → components/Paper/README.md} +18 -30
- package/src/{lib/components/Popover/README.mdx → components/Popover/README.md} +102 -132
- package/src/{lib/components/Radio/README.mdx → components/Radio/README.md} +122 -134
- package/src/{lib/components → components}/Radio/Radio.jsx +11 -12
- package/src/{lib/components → components}/Radio/Radio.scss +0 -5
- package/src/components/ScrollView/README.md +503 -0
- package/src/{lib/components → components}/ScrollView/ScrollView.jsx +12 -3
- package/src/components/SelectField/README.md +681 -0
- package/src/components/Table/README.md +259 -0
- package/src/{lib/components → components}/Table/Table.jsx +4 -1
- package/src/{lib/components → components}/Table/_components/TableHeaderCell/TableHeaderCell.jsx +1 -1
- package/src/{lib/components/Tabs/README.mdx → components/Tabs/README.md} +117 -134
- package/src/{lib/components → components}/Tabs/TabsItem.jsx +3 -3
- package/src/components/Text/README.md +220 -0
- package/src/components/TextArea/README.md +359 -0
- package/src/{lib/components/TextField/README.mdx → components/TextField/README.md} +336 -342
- package/src/{lib/components/TextLink/README.mdx → components/TextLink/README.md} +19 -31
- package/src/{lib/components/Toggle/README.mdx → components/Toggle/README.md} +98 -110
- package/src/components/Toolbar/README.md +359 -0
- package/src/{lib/components → components}/Toolbar/_helpers/getAlignClassName.js +12 -4
- package/src/components/_helpers/getRootPriorityClassName.js +15 -0
- package/src/{lib/index.js → index.js} +6 -0
- package/src/{lib/provider → provider}/RUIProvider.jsx +17 -11
- package/src/{lib/styles → styles}/tools/_caret.scss +1 -1
- package/src/{lib/styles → styles}/tools/form-fields/_box-field-elements.scss +1 -1
- package/src/{lib/styles → styles}/tools/form-fields/_inline-field-elements.scss +2 -2
- package/src/{lib/theme.scss → theme.scss} +4 -3
- package/CONTRIBUTING.md +0 -137
- package/dist/lib.development.js +0 -3179
- package/dist/lib.js +0 -1
- package/public/racom.svg +0 -11
- package/src/lib/components/Badge/README.mdx +0 -126
- package/src/lib/components/Button/README.mdx +0 -581
- package/src/lib/components/Card/README.mdx +0 -326
- package/src/lib/components/FormLayout/README.mdx +0 -501
- package/src/lib/components/Grid/README.mdx +0 -299
- package/src/lib/components/Modal/README.mdx +0 -1360
- package/src/lib/components/Modal/_hooks/useModalScrollPrevention.js +0 -35
- package/src/lib/components/ScrollView/README.mdx +0 -521
- package/src/lib/components/SelectField/README.mdx +0 -693
- package/src/lib/components/Table/README.mdx +0 -275
- package/src/lib/components/Text/README.mdx +0 -241
- package/src/lib/components/TextArea/README.mdx +0 -366
- package/src/lib/components/Toolbar/README.mdx +0 -386
- package/src/{lib/components → components}/Alert/Alert.scss +0 -0
- package/src/{lib/components → components}/Alert/_settings.scss +0 -0
- package/src/{lib/components → components}/Alert/_theme.scss +0 -0
- package/src/{lib/components → components}/Alert/_tools.scss +0 -0
- package/src/{lib/components → components}/Alert/index.js +0 -0
- package/src/{lib/components → components}/Badge/index.js +0 -0
- package/src/{lib/components → components}/Button/Button.scss +0 -0
- package/src/{lib/components → components}/Button/_base.scss +0 -0
- package/src/{lib/components → components}/Button/_priorities.scss +0 -0
- package/src/{lib/components → components}/Button/_settings.scss +0 -0
- package/src/{lib/components → components}/Button/_theme.scss +0 -0
- package/src/{lib/components → components}/Button/_tools.scss +0 -0
- package/src/{lib/components → components}/Button/helpers/getRootLabelVisibilityClassName.js +0 -0
- package/src/{lib/components/_helpers → components/Button/helpers}/getRootPriorityClassName.js +0 -0
- package/src/{lib/components → components}/Button/index.js +0 -0
- package/src/{lib/components → components}/ButtonGroup/ButtonGroup.scss +0 -0
- package/src/{lib/components → components}/ButtonGroup/ButtonGroupContext.js +0 -0
- package/src/{lib/components → components}/ButtonGroup/_theme.scss +0 -0
- package/src/{lib/components → components}/ButtonGroup/index.js +0 -0
- package/src/{lib/components → components}/Card/Card.scss +0 -0
- package/src/{lib/components → components}/Card/CardBody.jsx +0 -0
- package/src/{lib/components → components}/Card/CardFooter.jsx +0 -0
- package/src/{lib/components → components}/Card/_theme.scss +0 -0
- package/src/{lib/components → components}/Card/_tools.scss +0 -0
- package/src/{lib/components → components}/Card/index.js +0 -0
- package/src/{lib/components → components}/CheckboxField/CheckboxField.jsx +0 -0
- package/src/{lib/components → components}/CheckboxField/CheckboxField.scss +0 -0
- package/src/{lib/components → components}/CheckboxField/index.js +0 -0
- package/src/{lib/components → components}/FileInputField/FileInputField.jsx +0 -0
- package/src/{lib/components → components}/FileInputField/FileInputField.scss +0 -0
- package/src/{lib/components → components}/FileInputField/index.js +0 -0
- package/src/{lib/components → components}/FormLayout/FormLayout.scss +0 -0
- package/src/{lib/components → components}/FormLayout/FormLayoutContext.js +0 -0
- package/src/{lib/components → components}/FormLayout/FormLayoutCustomField.jsx +4 -4
- package/src/{lib/components → components}/FormLayout/FormLayoutCustomField.scss +0 -0
- package/src/{lib/components → components}/FormLayout/_theme.scss +0 -0
- package/src/{lib/components → components}/FormLayout/index.js +0 -0
- package/src/{lib/components → components}/Grid/Grid.scss +0 -0
- package/src/{lib/components → components}/Grid/GridSpan.jsx +0 -0
- package/src/{lib/components → components}/Grid/_helpers/generateResponsiveCustomProperties.js +0 -0
- package/src/{lib/components → components}/Grid/_settings.scss +0 -0
- package/src/{lib/components → components}/Grid/_tools.scss +0 -0
- package/src/{lib/components → components}/Grid/index.js +0 -0
- package/src/{lib/components → components}/InputGroup/InputGroupContext.js +0 -0
- package/src/{lib/components → components}/InputGroup/_theme.scss +0 -0
- package/src/{lib/components → components}/InputGroup/index.js +0 -0
- package/src/{lib/components → components}/Modal/Modal.scss +0 -0
- package/src/{lib/components → components}/Modal/ModalBody.jsx +0 -0
- package/src/{lib/components → components}/Modal/ModalBody.scss +0 -0
- package/src/{lib/components → components}/Modal/ModalCloseButton.jsx +1 -1
- package/src/{lib/components → components}/Modal/ModalCloseButton.scss +0 -0
- package/src/{lib/components → components}/Modal/ModalContent.jsx +0 -0
- package/src/{lib/components → components}/Modal/ModalContent.scss +0 -0
- package/src/{lib/components → components}/Modal/ModalFooter.jsx +0 -0
- package/src/{lib/components → components}/Modal/ModalFooter.scss +0 -0
- package/src/{lib/components → components}/Modal/ModalHeader.jsx +0 -0
- package/src/{lib/components → components}/Modal/ModalHeader.scss +0 -0
- package/src/{lib/components → components}/Modal/ModalTitle.jsx +0 -0
- package/src/{lib/components → components}/Modal/ModalTitle.scss +0 -0
- package/src/{lib/components → components}/Modal/_helpers/getJustifyClassName.js +0 -0
- package/src/{lib/components → components}/Modal/_helpers/getPositionClassName.js +0 -0
- package/src/{lib/components → components}/Modal/_helpers/getScrollingClassName.js +0 -0
- package/src/{lib/components → components}/Modal/_helpers/getSizeClassName.js +0 -0
- package/src/{lib/components → components}/Modal/_hooks/useModalFocus.js +0 -0
- package/src/{lib/components → components}/Modal/_settings.scss +0 -0
- package/src/{lib/components → components}/Modal/_theme.scss +0 -0
- package/src/{lib/components → components}/Modal/index.js +0 -0
- package/src/{lib/components → components}/Paper/Paper.jsx +0 -0
- package/src/{lib/components → components}/Paper/Paper.scss +0 -0
- package/src/{lib/components → components}/Paper/_theme.scss +0 -0
- package/src/{lib/components → components}/Paper/index.js +0 -0
- package/src/{lib/components → components}/Popover/Popover.jsx +0 -0
- package/src/{lib/components → components}/Popover/Popover.scss +0 -0
- package/src/{lib/components → components}/Popover/PopoverWrapper.jsx +0 -0
- package/src/{lib/components → components}/Popover/PopoverWrapper.scss +0 -0
- package/src/{lib/components → components}/Popover/_helpers/getRootAlignmentClassName.js +0 -0
- package/src/{lib/components → components}/Popover/_helpers/getRootSideClassName.js +0 -0
- package/src/{lib/components → components}/Popover/_theme.scss +0 -0
- package/src/{lib/components → components}/Popover/index.js +0 -0
- package/src/{lib/components → components}/Radio/index.js +0 -0
- package/src/{lib/components → components}/ScrollView/ScrollView.scss +0 -0
- package/src/{lib/components → components}/ScrollView/_helpers/getElementsPositionDifference.js +0 -0
- package/src/{lib/components → components}/ScrollView/_hooks/useLoadResizeHook.js +0 -0
- package/src/{lib/components → components}/ScrollView/_hooks/useScrollPositionHook.js +0 -0
- package/src/{lib/components → components}/ScrollView/index.js +0 -0
- package/src/{lib/components → components}/SelectField/SelectField.jsx +0 -0
- package/src/{lib/components → components}/SelectField/SelectField.scss +0 -0
- package/src/{lib/components → components}/SelectField/_components/Option/Option.jsx +0 -0
- package/src/{lib/components → components}/SelectField/_components/Option/index.js +0 -0
- package/src/{lib/components → components}/SelectField/index.js +0 -0
- package/src/{lib/components → components}/Table/Table.scss +0 -0
- package/src/{lib/components → components}/Table/_components/TableBodyCell/TableBodyCell.jsx +0 -0
- package/src/{lib/components → components}/Table/_components/TableBodyCell/index.js +0 -0
- package/src/{lib/components → components}/Table/_components/TableCell.scss +0 -0
- package/src/{lib/components → components}/Table/_components/TableHeaderCell/index.js +0 -0
- package/src/{lib/components → components}/Table/_settings.scss +0 -0
- package/src/{lib/components → components}/Table/index.js +0 -0
- package/src/{lib/components → components}/Tabs/Tabs.jsx +0 -0
- package/src/{lib/components → components}/Tabs/Tabs.scss +0 -0
- package/src/{lib/components → components}/Tabs/TabsItem.scss +0 -0
- package/src/{lib/components → components}/Tabs/_theme.scss +0 -0
- package/src/{lib/components → components}/Tabs/index.js +0 -0
- package/src/{lib/components → components}/Text/Text.jsx +0 -0
- package/src/{lib/components → components}/Text/Text.scss +0 -0
- package/src/{lib/components → components}/Text/_helpers/getRootClampClassName.js +0 -0
- package/src/{lib/components → components}/Text/_helpers/getRootHyphensClassName.js +0 -0
- package/src/{lib/components → components}/Text/_helpers/getRootWordWrappingClassName.js +0 -0
- package/src/{lib/components → components}/Text/index.js +0 -0
- package/src/{lib/components → components}/TextArea/TextArea.jsx +0 -0
- package/src/{lib/components → components}/TextArea/TextArea.scss +0 -0
- package/src/{lib/components → components}/TextArea/index.js +0 -0
- package/src/{lib/components → components}/TextField/TextField.jsx +0 -0
- package/src/{lib/components → components}/TextField/TextField.scss +0 -0
- package/src/{lib/components → components}/TextField/index.js +0 -0
- package/src/{lib/components → components}/TextLink/TextLink.jsx +1 -1
- /package/src/{lib/components → components}/TextLink/TextLink.scss +0 -0
- /package/src/{lib/components → components}/TextLink/_theme.scss +0 -0
- /package/src/{lib/components → components}/TextLink/index.js +0 -0
- /package/src/{lib/components → components}/Toggle/Toggle.jsx +0 -0
- /package/src/{lib/components → components}/Toggle/Toggle.scss +0 -0
- /package/src/{lib/components → components}/Toggle/index.js +0 -0
- /package/src/{lib/components → components}/Toolbar/Toolbar.jsx +0 -0
- /package/src/{lib/components → components}/Toolbar/Toolbar.scss +0 -0
- /package/src/{lib/components → components}/Toolbar/ToolbarGroup.jsx +0 -0
- /package/src/{lib/components → components}/Toolbar/ToolbarItem.jsx +0 -0
- /package/src/{lib/components → components}/Toolbar/_helpers/getJustifyClassName.js +0 -0
- /package/src/{lib/components → components}/Toolbar/_theme.scss +0 -0
- /package/src/{lib/components → components}/Toolbar/index.js +0 -0
- /package/src/{lib/components → components}/_helpers/getRootColorClassName.js +0 -0
- /package/src/{lib/components → components}/_helpers/getRootSizeClassName.js +0 -0
- /package/src/{lib/components → components}/_helpers/getRootValidationStateClassName.js +0 -0
- /package/src/{lib/components → components}/_helpers/isChildrenEmpty.js +0 -0
- /package/src/{lib/components → components}/_helpers/resolveContextOrProp.js +0 -0
- /package/src/{lib/components → components}/_helpers/transferProps.js +0 -0
- /package/src/{lib/foundation.scss → foundation.scss} +0 -0
- /package/src/{lib/helpers.scss → helpers.scss} +0 -0
- /package/src/{lib/provider → provider}/RUIContext.jsx +0 -0
- /package/src/{lib/provider → provider}/index.js +0 -0
- /package/src/{lib/provider → provider}/withGlobalProps.jsx +0 -0
- /package/src/{lib/styles → styles}/_utilities.scss +0 -0
- /package/src/{lib/styles → styles}/elements/_code.scss +0 -0
- /package/src/{lib/styles → styles}/elements/_links.scss +0 -0
- /package/src/{lib/styles → styles}/elements/_lists.scss +0 -0
- /package/src/{lib/styles → styles}/elements/_page.scss +0 -0
- /package/src/{lib/styles → styles}/elements/_rulers.scss +0 -0
- /package/src/{lib/styles → styles}/elements/_small.scss +0 -0
- /package/src/{lib/styles → styles}/generic/_box-sizing.scss +0 -0
- /package/src/{lib/styles → styles}/generic/_focus.scss +0 -0
- /package/src/{lib/styles → styles}/generic/_forms.scss +0 -0
- /package/src/{lib/styles → styles}/generic/_reset.scss +0 -0
- /package/src/{lib/styles → styles}/generic/_shared.scss +0 -0
- /package/src/{lib/styles → styles}/helpers/_animation.scss +0 -0
- /package/src/{lib/styles → styles}/settings/_animations.scss +0 -0
- /package/src/{lib/styles → styles}/settings/_breakpoints.scss +0 -0
- /package/src/{lib/styles → styles}/settings/_escaped-characters.scss +0 -0
- /package/src/{lib/styles → styles}/settings/_form-fields.scss +0 -0
- /package/src/{lib/styles → styles}/settings/_forms.scss +0 -0
- /package/src/{lib/styles → styles}/settings/_utilities.scss +0 -0
- /package/src/{lib/styles → styles}/settings/_z-indexes.scss +0 -0
- /package/src/{lib/styles → styles}/theme/_accessibility.scss +0 -0
- /package/src/{lib/styles → styles}/theme/_borders.scss +0 -0
- /package/src/{lib/styles → styles}/theme/_code.scss +0 -0
- /package/src/{lib/styles → styles}/theme/_form-fields.scss +0 -0
- /package/src/{lib/styles → styles}/theme/_links.scss +0 -0
- /package/src/{lib/styles → styles}/theme/_lists.scss +0 -0
- /package/src/{lib/styles → styles}/theme/_page.scss +0 -0
- /package/src/{lib/styles → styles}/theme/_spacing.scss +0 -0
- /package/src/{lib/styles → styles}/theme/_typography.scss +0 -0
- /package/src/{lib/styles → styles}/theme-constants/_breakpoints.scss +0 -0
- /package/src/{lib/styles → styles}/theme-constants/_colors.scss +0 -0
- /package/src/{lib/styles → styles}/theme-constants/_svg.scss +0 -0
- /package/src/{lib/styles → styles}/tools/_accessibility.scss +0 -0
- /package/src/{lib/styles → styles}/tools/_breakpoint.scss +0 -0
- /package/src/{lib/styles → styles}/tools/_colors.scss +0 -0
- /package/src/{lib/styles → styles}/tools/_reset.scss +0 -0
- /package/src/{lib/styles → styles}/tools/_scrollbar.scss +0 -0
- /package/src/{lib/styles → styles}/tools/_spacing.scss +0 -0
- /package/src/{lib/styles → styles}/tools/_string.scss +0 -0
- /package/src/{lib/styles → styles}/tools/_svg.scss +0 -0
- /package/src/{lib/styles → styles}/tools/_transition.scss +0 -0
- /package/src/{lib/styles → styles}/tools/_utilities.scss +0 -0
- /package/src/{lib/styles → styles}/tools/form-fields/_box-field-layout.scss +0 -0
- /package/src/{lib/styles → styles}/tools/form-fields/_box-field-sizes.scss +0 -0
- /package/src/{lib/styles → styles}/tools/form-fields/_foundation.scss +0 -0
- /package/src/{lib/styles → styles}/tools/form-fields/_inline-field-layout.scss +0 -0
- /package/src/{lib/styles → styles}/tools/form-fields/_variants.scss +0 -0
- /package/src/{lib/translations → translations}/en.js +0 -0
- /package/src/{lib/utils → utils}/classNames.js +0 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# Text
|
|
2
|
+
|
|
3
|
+
Text is a tiny component to control wrapping of text content.
|
|
4
|
+
|
|
5
|
+
## Basic Usage
|
|
6
|
+
|
|
7
|
+
To implement the Text component, you need to import it first:
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import { Text } from '@react-ui-org/react-ui';
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And use it:
|
|
14
|
+
|
|
15
|
+
```docoff-react-preview
|
|
16
|
+
<docoff-placeholder>
|
|
17
|
+
<Text lines={3}>
|
|
18
|
+
Hello! This text will be clamped to three lines.
|
|
19
|
+
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo
|
|
20
|
+
ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis
|
|
21
|
+
dis parturient montes, nascetur ridiculus mus. Donec quam felis,
|
|
22
|
+
ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa
|
|
23
|
+
quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget,
|
|
24
|
+
arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.
|
|
25
|
+
</Text>
|
|
26
|
+
</docoff-placeholder>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
See [API](#api) for all available options.
|
|
30
|
+
|
|
31
|
+
## General Guidelines
|
|
32
|
+
|
|
33
|
+
- Use Text anytime you need to **control potentially long strings** and
|
|
34
|
+
prevent them from overflowing or breaking their container.
|
|
35
|
+
|
|
36
|
+
- **By default, Text doesn't alter rendering of its content.** Use available
|
|
37
|
+
options to achieve the result you need.
|
|
38
|
+
|
|
39
|
+
- **Text renders as `<span>` by default,** so it can only contain
|
|
40
|
+
inline-level HTML elements (like `<strong>` or `<a>`, but not `<div>`, `<p>`,
|
|
41
|
+
or `<h2>`). If necessary, use the `blockLevel` option to render as `<div>` to
|
|
42
|
+
keep your HTML valid.
|
|
43
|
+
|
|
44
|
+
- **Use Text for short pieces of text content.** Including a couple of HTML tags
|
|
45
|
+
shouldn't cause any harm, but keep in mind Text is not intended to wrap
|
|
46
|
+
complex HTML structures or even React components.
|
|
47
|
+
|
|
48
|
+
## Number of Lines
|
|
49
|
+
|
|
50
|
+
Specify how many `lines` of text should be visible if content doesn't fit its
|
|
51
|
+
container. If the number of lines is exceeded, the content is truncated and
|
|
52
|
+
appended by an ellipsis (`…`).
|
|
53
|
+
|
|
54
|
+
```docoff-react-preview
|
|
55
|
+
React.createElement(() => {
|
|
56
|
+
const [lines, setLines] = React.useState(1);
|
|
57
|
+
return (
|
|
58
|
+
<div>
|
|
59
|
+
<Toolbar align="baseline">
|
|
60
|
+
<ToolbarItem>
|
|
61
|
+
<TextField
|
|
62
|
+
label="Number of lines"
|
|
63
|
+
min={1}
|
|
64
|
+
max={100}
|
|
65
|
+
onChange={(e) => setLines(Number(e.target.value))}
|
|
66
|
+
type="number"
|
|
67
|
+
value={lines}
|
|
68
|
+
/>
|
|
69
|
+
</ToolbarItem>
|
|
70
|
+
</Toolbar>
|
|
71
|
+
<docoff-placeholder>
|
|
72
|
+
<Text lines={lines}>
|
|
73
|
+
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean
|
|
74
|
+
commodo ligula eget dolor. Aenean massa. Cum sociis natoque
|
|
75
|
+
penatibus et magnis dis parturient montes, nascetur ridiculus mus.
|
|
76
|
+
Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem.
|
|
77
|
+
Nulla consequat massa quis enim. Donec pede justo, fringilla vel,
|
|
78
|
+
aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut,
|
|
79
|
+
imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede
|
|
80
|
+
mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum
|
|
81
|
+
semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula,
|
|
82
|
+
porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem
|
|
83
|
+
ante, dapibus in, viverra quis, feugiat a, tellus.
|
|
84
|
+
</Text>
|
|
85
|
+
</docoff-placeholder>
|
|
86
|
+
</div>
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Word Wrapping
|
|
92
|
+
|
|
93
|
+
There are three possible ways of controlling wrapping of long words if they do
|
|
94
|
+
not fit on a line. Set `wordWrapping` to one of the following values:
|
|
95
|
+
|
|
96
|
+
- `normal`: Do not force any wrapping (default behavior).
|
|
97
|
+
|
|
98
|
+
- `long-words`: To prevent overflow, an otherwise unbreakable string of
|
|
99
|
+
characters — like a long word or URL — may be broken at any point if there are
|
|
100
|
+
no otherwise-acceptable break points in the line.
|
|
101
|
+
|
|
102
|
+
- `anywhere`: Create a break at the exact place where text would otherwise
|
|
103
|
+
overflow its container (even if putting an entire word on its own line would
|
|
104
|
+
negate the need for a break).
|
|
105
|
+
|
|
106
|
+
📖 [Read more about wrapping and breaking text at MDN.](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Text/Wrapping_Text)
|
|
107
|
+
|
|
108
|
+
### Hyphens
|
|
109
|
+
|
|
110
|
+
The `hyphens` option specifies how words should be hyphenated when text wraps
|
|
111
|
+
across multiple lines. It can prevent hyphenation entirely, hyphenate at
|
|
112
|
+
manually-specified points within the text, or let the browser automatically
|
|
113
|
+
insert hyphens where appropriate.
|
|
114
|
+
|
|
115
|
+
👉 The `auto` setting's behavior depends on the language being properly tagged
|
|
116
|
+
to select the appropriate hyphenation rules. **You must specify a language**
|
|
117
|
+
using the `lang` HTML attribute (e.g.
|
|
118
|
+
[on `<html>` tag](/docs/getting-started/usage#full-example)) to guarantee that
|
|
119
|
+
automatic hyphenation is applied in that language.
|
|
120
|
+
|
|
121
|
+
👉 [Manually suggested line break opportunities](https://developer.mozilla.org/en-US/docs/Web/CSS/hyphens#suggesting_line_break_opportunities)
|
|
122
|
+
will override automatic break point selection in `auto` mode when present.
|
|
123
|
+
|
|
124
|
+
📖 [Read more about `hyphens` CSS property at MDN.](https://developer.mozilla.org/en-US/docs/Web/CSS/hyphens)
|
|
125
|
+
|
|
126
|
+
```docoff-react-preview
|
|
127
|
+
React.createElement(() => {
|
|
128
|
+
const [hyphens, setHyphens] = React.useState('none');
|
|
129
|
+
const [wordWrapping, setWordWrapping] = React.useState('normal');
|
|
130
|
+
return (
|
|
131
|
+
<div>
|
|
132
|
+
<Toolbar>
|
|
133
|
+
<ToolbarGroup align="baseline">
|
|
134
|
+
<ToolbarItem>
|
|
135
|
+
<span id="word-wrapping-options-label">Word wrapping:</span>
|
|
136
|
+
</ToolbarItem>
|
|
137
|
+
<ToolbarItem>
|
|
138
|
+
<ButtonGroup aria-labelledby="word-wrapping-options-label" priority="outline">
|
|
139
|
+
<Button
|
|
140
|
+
aria-pressed={wordWrapping === 'normal'}
|
|
141
|
+
color={wordWrapping === 'normal' ? 'selected' : 'secondary'}
|
|
142
|
+
label="normal"
|
|
143
|
+
onClick={() => setWordWrapping('normal')}
|
|
144
|
+
/>
|
|
145
|
+
<Button
|
|
146
|
+
aria-pressed={wordWrapping === 'long-words'}
|
|
147
|
+
color={wordWrapping === 'long-words' ? 'selected' : 'secondary'}
|
|
148
|
+
label="long-words"
|
|
149
|
+
onClick={() => setWordWrapping('long-words')}
|
|
150
|
+
/>
|
|
151
|
+
<Button
|
|
152
|
+
aria-pressed={wordWrapping === 'anywhere'}
|
|
153
|
+
color={wordWrapping === 'anywhere' ? 'selected' : 'secondary'}
|
|
154
|
+
label="anywhere"
|
|
155
|
+
onClick={() => setWordWrapping('anywhere')}
|
|
156
|
+
/>
|
|
157
|
+
</ButtonGroup>
|
|
158
|
+
</ToolbarItem>
|
|
159
|
+
</ToolbarGroup>
|
|
160
|
+
<ToolbarGroup align="baseline">
|
|
161
|
+
<ToolbarItem>
|
|
162
|
+
<span id="hyphens-options-label">Hyphens:</span>
|
|
163
|
+
</ToolbarItem>
|
|
164
|
+
<ToolbarItem>
|
|
165
|
+
<ButtonGroup aria-labelledby="hyphens-options-label" priority="outline">
|
|
166
|
+
<Button
|
|
167
|
+
aria-pressed={hyphens === 'none'}
|
|
168
|
+
color={hyphens === 'none' ? 'selected' : 'secondary'}
|
|
169
|
+
label="none"
|
|
170
|
+
onClick={() => setHyphens('none')}
|
|
171
|
+
/>
|
|
172
|
+
<Button
|
|
173
|
+
aria-pressed={hyphens === 'auto'}
|
|
174
|
+
color={hyphens === 'auto' ? 'selected' : 'secondary'}
|
|
175
|
+
label="auto"
|
|
176
|
+
onClick={() => setHyphens('auto')}
|
|
177
|
+
/>
|
|
178
|
+
<Button
|
|
179
|
+
aria-pressed={hyphens === 'manual'}
|
|
180
|
+
color={hyphens === 'manual' ? 'selected' : 'secondary'}
|
|
181
|
+
label="manual"
|
|
182
|
+
onClick={() => setHyphens('manual')}
|
|
183
|
+
/>
|
|
184
|
+
</ButtonGroup>
|
|
185
|
+
</ToolbarItem>
|
|
186
|
+
</ToolbarGroup>
|
|
187
|
+
</Toolbar>
|
|
188
|
+
<docoff-placeholder width="11em" bordered>
|
|
189
|
+
<Text hyphens={hyphens} wordWrapping={wordWrapping}>
|
|
190
|
+
{hyphens === 'manual'
|
|
191
|
+
? (<>LongWord­ThatHasManual­Breaking­Possibilities</>)
|
|
192
|
+
: (<>LongWordThatHasNoBreakingPossibilities</>)}
|
|
193
|
+
{' '}
|
|
194
|
+
and a couple of ordinary words that are nice and well behaved.
|
|
195
|
+
</Text>
|
|
196
|
+
</docoff-placeholder>
|
|
197
|
+
</div>
|
|
198
|
+
);
|
|
199
|
+
});
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Forwarding HTML Attributes
|
|
203
|
+
|
|
204
|
+
In addition to the options below in the [component's API](#api) section, you
|
|
205
|
+
can specify [React synthetic events] or **any HTML attribute you like.** All
|
|
206
|
+
attributes that don't interfere with the API are forwarded either to the
|
|
207
|
+
`<span>` or to the `<div>` HTML element in case that `blockLevel` is set to
|
|
208
|
+
`true`. This enables making the component interactive and helps to improve its
|
|
209
|
+
accessibility.
|
|
210
|
+
|
|
211
|
+
👉 Refer to the MDN reference for the full list of supported attributes of the
|
|
212
|
+
[span] and [div] element.
|
|
213
|
+
|
|
214
|
+
## API
|
|
215
|
+
|
|
216
|
+
<docoff-react-props src="/components/Text/Text.jsx"></docoff-react-props>
|
|
217
|
+
|
|
218
|
+
[React synthetic events]: https://reactjs.org/docs/events.html
|
|
219
|
+
[span]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/span#attributes
|
|
220
|
+
[div]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div#attributes
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
# TextArea
|
|
2
|
+
|
|
3
|
+
TextArea enables users to add longer text to a form.
|
|
4
|
+
|
|
5
|
+
## Basic Usage
|
|
6
|
+
|
|
7
|
+
To implement the TextArea component, you need to import it first:
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import { TextArea } from '@react-ui-org/react-ui';
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And use it:
|
|
14
|
+
|
|
15
|
+
```docoff-react-preview
|
|
16
|
+
<TextArea label="Your feedback" />
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
See [API](#api) for all available options.
|
|
20
|
+
|
|
21
|
+
## General Guidelines
|
|
22
|
+
|
|
23
|
+
- Use **short and descriptive labels**, ideally nouns rather than seemingly
|
|
24
|
+
polite phrases like _Please enter your message_. Short labels will help your
|
|
25
|
+
users accomplish their task faster.
|
|
26
|
+
|
|
27
|
+
- Only make the TextArea's label invisible when there is **another visual
|
|
28
|
+
clue** to guide users through filling the input. Using the first option as
|
|
29
|
+
label is not recommended either — it disappears once user makes their choice.
|
|
30
|
+
|
|
31
|
+
- When a short label is not enough, use **help texts to guide users** before
|
|
32
|
+
they enter anything.
|
|
33
|
+
|
|
34
|
+
- Optionally you can **pre-fill your text fields with a placeholder** to give
|
|
35
|
+
users an example of what they're expected to fill in. Just remember the
|
|
36
|
+
placeholder disappears once a value is entered so don't put anything important
|
|
37
|
+
there. Usually, en example value starting with “Eg.” works best.
|
|
38
|
+
|
|
39
|
+
- Use **clear, calm error messages** when there's a problem with what they
|
|
40
|
+
entered. Be positive and focus on solutions to make the error message helpful.
|
|
41
|
+
|
|
42
|
+
- Ensure the height of a text area **fits within mobile screen sizes.**
|
|
43
|
+
|
|
44
|
+
## Design Variants
|
|
45
|
+
|
|
46
|
+
To satisfy the design requirements of your project, all input fields in React UI
|
|
47
|
+
come in **two design variants** to choose from: outline and filled. Both can be
|
|
48
|
+
further [customized](#theming) with CSS custom properties.
|
|
49
|
+
|
|
50
|
+
```docoff-react-preview
|
|
51
|
+
<TextArea
|
|
52
|
+
label="Your feedback"
|
|
53
|
+
/>
|
|
54
|
+
<TextArea
|
|
55
|
+
label="Your feedback"
|
|
56
|
+
variant="filled"
|
|
57
|
+
/>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Sizes
|
|
61
|
+
|
|
62
|
+
Aside from the default (medium) size, two additional sizes are available: small
|
|
63
|
+
and large.
|
|
64
|
+
|
|
65
|
+
```docoff-react-preview
|
|
66
|
+
<TextArea
|
|
67
|
+
label="Your feedback"
|
|
68
|
+
size="small"
|
|
69
|
+
/>
|
|
70
|
+
<TextArea
|
|
71
|
+
label="Your feedback"
|
|
72
|
+
/>
|
|
73
|
+
<TextArea
|
|
74
|
+
label="Your feedback"
|
|
75
|
+
size="large"
|
|
76
|
+
/>
|
|
77
|
+
<TextArea
|
|
78
|
+
label="Your feedback"
|
|
79
|
+
size="small"
|
|
80
|
+
variant="filled"
|
|
81
|
+
/>
|
|
82
|
+
<TextArea
|
|
83
|
+
label="Your feedback"
|
|
84
|
+
variant="filled"
|
|
85
|
+
/>
|
|
86
|
+
<TextArea
|
|
87
|
+
label="Your feedback"
|
|
88
|
+
size="large"
|
|
89
|
+
variant="filled"
|
|
90
|
+
/>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Full-width fields span the full width of a parent:
|
|
94
|
+
|
|
95
|
+
```docoff-react-preview
|
|
96
|
+
<TextArea
|
|
97
|
+
label="Your feedback"
|
|
98
|
+
fullWidth
|
|
99
|
+
/>
|
|
100
|
+
<TextArea
|
|
101
|
+
label="Your feedback"
|
|
102
|
+
variant="filled"
|
|
103
|
+
fullWidth
|
|
104
|
+
/>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Input Size
|
|
108
|
+
|
|
109
|
+
The default width of all inputs is 240 px, and it can be
|
|
110
|
+
[customized](/docs/customize/theming/overview) with a CSS custom property.
|
|
111
|
+
However, you can also **control the size of individual text areas** using
|
|
112
|
+
the `rows` and `cols` properties. Additionally, text areas are vertically
|
|
113
|
+
resizable by users.
|
|
114
|
+
|
|
115
|
+
👉 Remember that the `cols` and `rows` HTML attributes **do not limit on how
|
|
116
|
+
many characters** the user can enter. Use the
|
|
117
|
+
[`maxlength` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#Min_and_max_length)
|
|
118
|
+
to achieve that effect.
|
|
119
|
+
|
|
120
|
+
```docoff-react-preview
|
|
121
|
+
<TextArea
|
|
122
|
+
label="Your feedback"
|
|
123
|
+
cols={50}
|
|
124
|
+
rows={6}
|
|
125
|
+
/>
|
|
126
|
+
<TextArea
|
|
127
|
+
label="Your feedback"
|
|
128
|
+
variant="filled"
|
|
129
|
+
cols={50}
|
|
130
|
+
rows={6}
|
|
131
|
+
/>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Invisible Label
|
|
135
|
+
|
|
136
|
+
In some cases, it may be convenient to visually hide the field label. The label
|
|
137
|
+
remains accessible to assistive technologies.
|
|
138
|
+
|
|
139
|
+
While it may be acceptable for login screens with just a few fields or other
|
|
140
|
+
simple forms, it's dangerous to hide labels from users in most cases. Keep in
|
|
141
|
+
mind you should **provide another visual clue** so users know what to fill into
|
|
142
|
+
the input.
|
|
143
|
+
|
|
144
|
+
```docoff-react-preview
|
|
145
|
+
<TextArea
|
|
146
|
+
label="Feedback"
|
|
147
|
+
isLabelVisible={false}
|
|
148
|
+
placeholder="Eg. What I liked the best was…"
|
|
149
|
+
/>
|
|
150
|
+
<TextArea
|
|
151
|
+
label="Feedback"
|
|
152
|
+
isLabelVisible={false}
|
|
153
|
+
variant="filled"
|
|
154
|
+
placeholder="Eg. What I liked the best was…"
|
|
155
|
+
/>
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Horizontal Layout
|
|
159
|
+
|
|
160
|
+
The default vertical layout is very easy to use and work with. However, there
|
|
161
|
+
are situations where horizontal layout suits better — and that's why React UI
|
|
162
|
+
supports this kind of layout as well.
|
|
163
|
+
|
|
164
|
+
```docoff-react-preview
|
|
165
|
+
<TextArea
|
|
166
|
+
label="Your feedback"
|
|
167
|
+
layout="horizontal"
|
|
168
|
+
/>
|
|
169
|
+
<TextArea
|
|
170
|
+
label="Your feedback"
|
|
171
|
+
layout="horizontal"
|
|
172
|
+
variant="filled"
|
|
173
|
+
/>
|
|
174
|
+
<TextArea
|
|
175
|
+
label="Your feedback"
|
|
176
|
+
layout="horizontal"
|
|
177
|
+
fullWidth
|
|
178
|
+
/>
|
|
179
|
+
<TextArea
|
|
180
|
+
label="Your feedback"
|
|
181
|
+
layout="horizontal"
|
|
182
|
+
variant="filled"
|
|
183
|
+
fullWidth
|
|
184
|
+
/>
|
|
185
|
+
<TextArea
|
|
186
|
+
isLabelVisible={false}
|
|
187
|
+
label="Your feedback"
|
|
188
|
+
layout="horizontal"
|
|
189
|
+
placeholder="Your feedback"
|
|
190
|
+
fullWidth
|
|
191
|
+
/>
|
|
192
|
+
<TextArea
|
|
193
|
+
isLabelVisible={false}
|
|
194
|
+
label="Your feedback"
|
|
195
|
+
layout="horizontal"
|
|
196
|
+
placeholder="Your feedback"
|
|
197
|
+
variant="filled"
|
|
198
|
+
fullWidth
|
|
199
|
+
/>
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Help Text
|
|
203
|
+
|
|
204
|
+
You may provide an additional help text to clarify how the input should be
|
|
205
|
+
filled.
|
|
206
|
+
|
|
207
|
+
```docoff-react-preview
|
|
208
|
+
<TextArea
|
|
209
|
+
label="Your feedback"
|
|
210
|
+
helpText="Why would you recommend us?"
|
|
211
|
+
/>
|
|
212
|
+
<TextArea
|
|
213
|
+
label="Your feedback"
|
|
214
|
+
variant="filled"
|
|
215
|
+
helpText="Why would you recommend us?"
|
|
216
|
+
/>
|
|
217
|
+
<TextArea
|
|
218
|
+
label="Your feedback"
|
|
219
|
+
layout="horizontal"
|
|
220
|
+
helpText="Why would you recommend us?"
|
|
221
|
+
/>
|
|
222
|
+
<TextArea
|
|
223
|
+
label="Your feedback"
|
|
224
|
+
layout="horizontal"
|
|
225
|
+
helpText="Why would you recommend us?"
|
|
226
|
+
variant="filled"
|
|
227
|
+
/>
|
|
228
|
+
<TextArea
|
|
229
|
+
label="Your feedback"
|
|
230
|
+
layout="horizontal"
|
|
231
|
+
helpText="Why would you recommend us?"
|
|
232
|
+
fullWidth
|
|
233
|
+
/>
|
|
234
|
+
<TextArea
|
|
235
|
+
label="Your feedback"
|
|
236
|
+
layout="horizontal"
|
|
237
|
+
variant="filled"
|
|
238
|
+
helpText="Why would you recommend us?"
|
|
239
|
+
fullWidth
|
|
240
|
+
/>
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## States
|
|
244
|
+
|
|
245
|
+
### Validation States
|
|
246
|
+
|
|
247
|
+
Validation states visually present the result of validation of the input. You
|
|
248
|
+
should always **provide a help text for states other than valid** so users know
|
|
249
|
+
what happened and what action they should take or what options they have.
|
|
250
|
+
|
|
251
|
+
```docoff-react-preview
|
|
252
|
+
<TextArea
|
|
253
|
+
label="Your feedback"
|
|
254
|
+
onChange={() => {}}
|
|
255
|
+
validationState="valid"
|
|
256
|
+
validationText="Looks good!"
|
|
257
|
+
value="Like that!"
|
|
258
|
+
required
|
|
259
|
+
/>
|
|
260
|
+
<TextArea
|
|
261
|
+
label="Your feedback"
|
|
262
|
+
onChange={() => {}}
|
|
263
|
+
validationState="warning"
|
|
264
|
+
validationText="The feedback should be at least 3 characters long."
|
|
265
|
+
value=".."
|
|
266
|
+
required
|
|
267
|
+
/>
|
|
268
|
+
<TextArea
|
|
269
|
+
label="Your feedback"
|
|
270
|
+
validationState="invalid"
|
|
271
|
+
validationText="Please share your feedback with us."
|
|
272
|
+
required
|
|
273
|
+
/>
|
|
274
|
+
<TextArea
|
|
275
|
+
label="Your feedback"
|
|
276
|
+
onChange={() => {}}
|
|
277
|
+
validationState="valid"
|
|
278
|
+
validationText="Looks good!"
|
|
279
|
+
variant="filled"
|
|
280
|
+
value="Like that!"
|
|
281
|
+
required
|
|
282
|
+
/>
|
|
283
|
+
<TextArea
|
|
284
|
+
label="Your feedback"
|
|
285
|
+
onChange={() => {}}
|
|
286
|
+
validationState="warning"
|
|
287
|
+
validationText="The feedback should be at least 3 characters long."
|
|
288
|
+
variant="filled"
|
|
289
|
+
value=".."
|
|
290
|
+
required
|
|
291
|
+
/>
|
|
292
|
+
<TextArea
|
|
293
|
+
label="Your feedback"
|
|
294
|
+
validationState="invalid"
|
|
295
|
+
validationText="Please share your feedback with us."
|
|
296
|
+
variant="filled"
|
|
297
|
+
required
|
|
298
|
+
/>
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### Disabled State
|
|
302
|
+
|
|
303
|
+
It's possible to disable the whole input.
|
|
304
|
+
|
|
305
|
+
```docoff-react-preview
|
|
306
|
+
<TextArea
|
|
307
|
+
label="Your feedback"
|
|
308
|
+
disabled
|
|
309
|
+
/>
|
|
310
|
+
<TextArea
|
|
311
|
+
label="Your feedback"
|
|
312
|
+
variant="filled"
|
|
313
|
+
disabled
|
|
314
|
+
/>
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
## Forwarding HTML Attributes
|
|
318
|
+
|
|
319
|
+
In addition to the options below in the [component's API](#api) section, you
|
|
320
|
+
can specify [React synthetic events] or you can **add whatever HTML attribute
|
|
321
|
+
you like.** All attributes that don't interfere with the API are forwarded to
|
|
322
|
+
the native HTML `<textarea>`. This enables making the component interactive and
|
|
323
|
+
to helps to improve its accessibility.
|
|
324
|
+
|
|
325
|
+
```docoff-react-preview
|
|
326
|
+
<TextArea
|
|
327
|
+
label="Address"
|
|
328
|
+
autoComplete="street-address"
|
|
329
|
+
minLength={3}
|
|
330
|
+
maxLength={80}
|
|
331
|
+
/>
|
|
332
|
+
<TextArea
|
|
333
|
+
label="Address"
|
|
334
|
+
variant="filled"
|
|
335
|
+
autoComplete="street-address"
|
|
336
|
+
minLength={3}
|
|
337
|
+
maxLength={80}
|
|
338
|
+
/>
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
👉 Refer to the MDN reference for the full list of supported attributes of the
|
|
342
|
+
[textarea] element.
|
|
343
|
+
|
|
344
|
+
## Forwarding ref
|
|
345
|
+
|
|
346
|
+
If you provide [ref], it is forwarded to the native HTML `<textarea>` element.
|
|
347
|
+
|
|
348
|
+
## API
|
|
349
|
+
|
|
350
|
+
<docoff-react-props src="/components/TextArea/TextArea.jsx"></docoff-react-props>
|
|
351
|
+
|
|
352
|
+
## Theming
|
|
353
|
+
|
|
354
|
+
Head to [Forms Theming](/docs/customize/theming/forms) to see shared form theming
|
|
355
|
+
options.
|
|
356
|
+
|
|
357
|
+
[React synthetic events]: https://reactjs.org/docs/events.html
|
|
358
|
+
[textarea]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#attributes
|
|
359
|
+
[ref]: https://reactjs.org/docs/refs-and-the-dom.html
|