@react-ui-org/react-ui 0.52.0 → 0.53.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CODEOWNERS +23 -0
- package/README.md +10 -7
- package/dist/react-ui.css +42 -0
- package/dist/react-ui.js +1 -0
- package/package.json +64 -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 +20 -19
- package/src/{lib/components → components}/InputGroup/InputGroup.scss +1 -6
- package/src/{lib/components/InputGroup/README.mdx → components/InputGroup/README.md} +145 -163
- 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 +1 -6
- 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/_box-field-layout.scss +26 -14
- 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-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
@@ -1,275 +0,0 @@
|
|
1
|
-
---
|
2
|
-
name: Table
|
3
|
-
menu: 'Miscellaneous'
|
4
|
-
route: /components/table
|
5
|
-
---
|
6
|
-
|
7
|
-
# Table
|
8
|
-
|
9
|
-
Table presents complex tabular data in an easy-to-scan way.
|
10
|
-
|
11
|
-
import {
|
12
|
-
Playground,
|
13
|
-
Props,
|
14
|
-
} from 'docz'
|
15
|
-
import Icon from '../../../docs/_components/Icon'
|
16
|
-
import {
|
17
|
-
ScrollView,
|
18
|
-
Table,
|
19
|
-
} from '../..'
|
20
|
-
|
21
|
-
## Basic Usage
|
22
|
-
|
23
|
-
To implement the Table component, you need to import it first:
|
24
|
-
|
25
|
-
```js
|
26
|
-
import { Table } from '@react-ui-org/react-ui';
|
27
|
-
```
|
28
|
-
|
29
|
-
And use it:
|
30
|
-
|
31
|
-
<Playground>
|
32
|
-
<Table
|
33
|
-
columns={[
|
34
|
-
{
|
35
|
-
label: 'ID',
|
36
|
-
name: 'id',
|
37
|
-
},
|
38
|
-
{
|
39
|
-
label: 'Name',
|
40
|
-
name: 'name',
|
41
|
-
},
|
42
|
-
{
|
43
|
-
format: (date) => date.toLocaleDateString('en-GB'),
|
44
|
-
label: 'Date of birth',
|
45
|
-
name: 'dateOfBirth',
|
46
|
-
},
|
47
|
-
]}
|
48
|
-
rows={[
|
49
|
-
{
|
50
|
-
dateOfBirth: new Date(1940, 10, 9),
|
51
|
-
id: 1,
|
52
|
-
name: 'John Lennon',
|
53
|
-
},
|
54
|
-
{
|
55
|
-
dateOfBirth: new Date(1942, 6, 18),
|
56
|
-
id: 2,
|
57
|
-
name: 'Paul McCartney',
|
58
|
-
},
|
59
|
-
{
|
60
|
-
dateOfBirth: new Date(1943, 2, 25),
|
61
|
-
id: 3,
|
62
|
-
name: 'George Harrison',
|
63
|
-
},
|
64
|
-
{
|
65
|
-
dateOfBirth: new Date(1940, 7, 7),
|
66
|
-
id: 4,
|
67
|
-
name: 'Richard Starkey (Ringo Starr)',
|
68
|
-
},
|
69
|
-
]}
|
70
|
-
/>
|
71
|
-
</Playground>
|
72
|
-
|
73
|
-
See [API](#api) for all available options.
|
74
|
-
|
75
|
-
## General Guidelines
|
76
|
-
|
77
|
-
- **Keep headers short** so users can quickly scan the content of the table.
|
78
|
-
Just one or two words should be enough.
|
79
|
-
|
80
|
-
- Tables are **good for displaying complex tabular data.** For simpler data sets
|
81
|
-
or even plain key-value pairs, consider using the
|
82
|
-
[Grid](/components/grid) component.
|
83
|
-
|
84
|
-
- Tables make **lots of information easier to scan and compare.** If you have
|
85
|
-
fewer sections and want to emphasize each group more, consider using
|
86
|
-
[Cards](/components/card).
|
87
|
-
|
88
|
-
## Responsive Tables
|
89
|
-
|
90
|
-
The easiest way to make tables responsive is to wrap them with the
|
91
|
-
[ScrollView](/components/scroll-view) component in the horizontal mode.
|
92
|
-
|
93
|
-
<Playground>
|
94
|
-
<ScrollView direction="horizontal" shadowSize="100px">
|
95
|
-
<Table
|
96
|
-
columns={[
|
97
|
-
{
|
98
|
-
label: 'ID',
|
99
|
-
name: 'id',
|
100
|
-
},
|
101
|
-
{
|
102
|
-
format: (name) => (
|
103
|
-
<span style={{ whiteSpace: 'nowrap' }}>{name}</span>
|
104
|
-
),
|
105
|
-
label: 'Name',
|
106
|
-
name: 'name',
|
107
|
-
},
|
108
|
-
{
|
109
|
-
format: (note) => (
|
110
|
-
<span style={{ whiteSpace: 'nowrap' }}>{note}</span>
|
111
|
-
),
|
112
|
-
label: 'Note',
|
113
|
-
name: 'note',
|
114
|
-
},
|
115
|
-
{
|
116
|
-
format: (date) => date.toLocaleDateString('en-GB'),
|
117
|
-
label: 'Date of birth',
|
118
|
-
name: 'dateOfBirth',
|
119
|
-
},
|
120
|
-
]}
|
121
|
-
rows={[
|
122
|
-
{
|
123
|
-
dateOfBirth: new Date(1940, 10, 9),
|
124
|
-
id: 1,
|
125
|
-
name: 'John Lennon',
|
126
|
-
note: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. '
|
127
|
-
+ 'Aenean commodo ligula eget dolor. Aenean massa. Cum sociis '
|
128
|
-
+ 'natoque penatibus et magnis dis parturient montes, nascetur '
|
129
|
-
+ 'ridiculus mus. Donec quam felis, ultricies nec, pellentesque '
|
130
|
-
+ 'eu, pretium quis, sem.',
|
131
|
-
},
|
132
|
-
{
|
133
|
-
dateOfBirth: new Date(1942, 6, 18),
|
134
|
-
id: 2,
|
135
|
-
name: 'Paul McCartney',
|
136
|
-
note: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. '
|
137
|
-
+ 'Aenean commodo ligula eget dolor. Aenean massa. Cum sociis '
|
138
|
-
+ 'natoque penatibus et magnis dis parturient montes, nascetur '
|
139
|
-
+ 'ridiculus mus. Donec quam felis, ultricies nec, pellentesque '
|
140
|
-
+ 'eu, pretium quis, sem.',
|
141
|
-
},
|
142
|
-
{
|
143
|
-
dateOfBirth: new Date(1943, 2, 25),
|
144
|
-
id: 3,
|
145
|
-
name: 'George Harrison',
|
146
|
-
note: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. '
|
147
|
-
+ 'Aenean commodo ligula eget dolor. Aenean massa. Cum sociis '
|
148
|
-
+ 'natoque penatibus et magnis dis parturient montes, nascetur '
|
149
|
-
+ 'ridiculus mus. Donec quam felis, ultricies nec, pellentesque '
|
150
|
-
+ 'eu, pretium quis, sem.',
|
151
|
-
},
|
152
|
-
{
|
153
|
-
dateOfBirth: new Date(1940, 7, 7),
|
154
|
-
id: 4,
|
155
|
-
name: 'Richard Starkey (Ringo Starr)',
|
156
|
-
note: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. '
|
157
|
-
+ 'Aenean commodo ligula eget dolor. Aenean massa. Cum sociis '
|
158
|
-
+ 'natoque penatibus et magnis dis parturient montes, nascetur '
|
159
|
-
+ 'ridiculus mus. Donec quam felis, ultricies nec, pellentesque '
|
160
|
-
+ 'eu, pretium quis, sem.',
|
161
|
-
},
|
162
|
-
]}
|
163
|
-
/>
|
164
|
-
</ScrollView>
|
165
|
-
</Playground>
|
166
|
-
|
167
|
-
## Sortable Columns
|
168
|
-
|
169
|
-
The Table supports sorting indicators by adding a simple configuration.
|
170
|
-
|
171
|
-
⚠️ The Table component only provides necessary visual support for sorting. Aside
|
172
|
-
from icons, you must **provide the comparing functionality yourself** if you
|
173
|
-
aren't rendering **already sorted data.** The reason for this decision is that
|
174
|
-
client often does not have access to the full dataset.
|
175
|
-
|
176
|
-
The following is an example of custom sorting function executed on the client.
|
177
|
-
|
178
|
-
<Playground>
|
179
|
-
{() => {
|
180
|
-
const [tableSortColumn, setTableSortColumn] = React.useState('id');
|
181
|
-
const [tableSortDirection, setTableSortDirection] = React.useState('asc');
|
182
|
-
const [rows, setRows] = React.useState([
|
183
|
-
{
|
184
|
-
dateOfBirth: new Date(1940, 10, 9),
|
185
|
-
id: 1,
|
186
|
-
name: 'John Lennon',
|
187
|
-
},
|
188
|
-
{
|
189
|
-
dateOfBirth: new Date(1942, 6, 18),
|
190
|
-
id: 2,
|
191
|
-
name: 'Paul McCartney',
|
192
|
-
},
|
193
|
-
{
|
194
|
-
dateOfBirth: new Date(1943, 2, 25),
|
195
|
-
id: 3,
|
196
|
-
name: 'George Harrison',
|
197
|
-
},
|
198
|
-
{
|
199
|
-
dateOfBirth: new Date(1940, 7, 7),
|
200
|
-
id: 4,
|
201
|
-
name: 'Richard Starkey (Ringo Starr)',
|
202
|
-
},
|
203
|
-
]);
|
204
|
-
const compare = (items, key, direction) => {
|
205
|
-
const sortedItems = [...items];
|
206
|
-
if (key === 'id' || key === 'dateOfBirth') {
|
207
|
-
sortedItems.sort((a, b) => b[key] - a[key]);
|
208
|
-
} else if (key === 'name') {
|
209
|
-
sortedItems.sort((a, b) => {
|
210
|
-
if (a.name < b.name) {
|
211
|
-
return -1;
|
212
|
-
}
|
213
|
-
if (a.name > b.name) {
|
214
|
-
return 1;
|
215
|
-
}
|
216
|
-
return 0;
|
217
|
-
});
|
218
|
-
}
|
219
|
-
return direction === 'desc' ? sortedItems.reverse() : sortedItems;
|
220
|
-
};
|
221
|
-
const columns = [
|
222
|
-
{
|
223
|
-
isSortable: true,
|
224
|
-
label: 'ID',
|
225
|
-
name: 'id',
|
226
|
-
},
|
227
|
-
{
|
228
|
-
isSortable: true,
|
229
|
-
label: 'Name',
|
230
|
-
name: 'name',
|
231
|
-
},
|
232
|
-
{
|
233
|
-
format: (date) => date.toISOString(),
|
234
|
-
isSortable: true,
|
235
|
-
label: 'Date of birth',
|
236
|
-
name: 'dateOfBirth',
|
237
|
-
},
|
238
|
-
];
|
239
|
-
return (
|
240
|
-
<Table
|
241
|
-
columns={columns}
|
242
|
-
rows={rows}
|
243
|
-
sort={{
|
244
|
-
ascendingIcon: <Icon icon="up" />,
|
245
|
-
column: tableSortColumn,
|
246
|
-
descendingIcon: <Icon icon="down" />,
|
247
|
-
direction: tableSortDirection,
|
248
|
-
onClick: (column, direction) => {
|
249
|
-
setTableSortColumn(column);
|
250
|
-
setTableSortDirection(direction === 'asc' ? 'desc' : 'asc');
|
251
|
-
setRows(compare(rows, column, direction));
|
252
|
-
},
|
253
|
-
}}
|
254
|
-
/>
|
255
|
-
);
|
256
|
-
}}
|
257
|
-
</Playground>
|
258
|
-
|
259
|
-
## Forwarding HTML Attributes
|
260
|
-
|
261
|
-
In addition to the options below in the [component's API](#api) section, you
|
262
|
-
can specify [React synthetic events] or **any HTML attribute you like.** All
|
263
|
-
attributes that don't interfere with the API are forwarded to the `<table>` HTML
|
264
|
-
element. This enables making the component interactive and helps to improve its
|
265
|
-
accessibility.
|
266
|
-
|
267
|
-
👉 Refer to the MDN reference for the full list of supported attributes of the
|
268
|
-
[table] element.
|
269
|
-
|
270
|
-
## API
|
271
|
-
|
272
|
-
<Props table of={Table} />
|
273
|
-
|
274
|
-
[React synthetic events]: https://reactjs.org/docs/events.html
|
275
|
-
[table]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table#attributes
|
@@ -1,241 +0,0 @@
|
|
1
|
-
---
|
2
|
-
name: Text
|
3
|
-
menu: 'Miscellaneous'
|
4
|
-
route: /components/text
|
5
|
-
---
|
6
|
-
|
7
|
-
# Text
|
8
|
-
|
9
|
-
import {
|
10
|
-
Playground,
|
11
|
-
Props,
|
12
|
-
} from 'docz'
|
13
|
-
import { Placeholder } from '../../../docs/_components/Placeholder/Placeholder'
|
14
|
-
import {
|
15
|
-
Button,
|
16
|
-
ButtonGroup,
|
17
|
-
Text,
|
18
|
-
TextField,
|
19
|
-
Toolbar,
|
20
|
-
ToolbarGroup,
|
21
|
-
ToolbarItem,
|
22
|
-
} from '../..'
|
23
|
-
|
24
|
-
Text is a tiny component to control wrapping of text content.
|
25
|
-
|
26
|
-
## Basic Usage
|
27
|
-
|
28
|
-
To implement the Text component, you need to import it first:
|
29
|
-
|
30
|
-
```js
|
31
|
-
import { Text } from '@react-ui-org/react-ui';
|
32
|
-
```
|
33
|
-
|
34
|
-
And use it:
|
35
|
-
|
36
|
-
<Playground>
|
37
|
-
<Placeholder>
|
38
|
-
<Text lines={3}>
|
39
|
-
Hello! This text will be clamped to three lines.
|
40
|
-
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo
|
41
|
-
ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis
|
42
|
-
dis parturient montes, nascetur ridiculus mus. Donec quam felis,
|
43
|
-
ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa
|
44
|
-
quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget,
|
45
|
-
arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.
|
46
|
-
</Text>
|
47
|
-
</Placeholder>
|
48
|
-
</Playground>
|
49
|
-
|
50
|
-
See [API](#api) for all available options.
|
51
|
-
|
52
|
-
## General Guidelines
|
53
|
-
|
54
|
-
- Use Text anytime you need to **control potentially long strings** and
|
55
|
-
prevent them from overflowing or breaking their container.
|
56
|
-
|
57
|
-
- **By default, Text doesn't alter rendering of its content.** Use available
|
58
|
-
options to achieve the result you need.
|
59
|
-
|
60
|
-
- **Text renders as `<span>` by default,** so it can only contain
|
61
|
-
inline-level HTML elements (like `<strong>` or `<a>`, but not `<div>`, `<p>`,
|
62
|
-
or `<h2>`). If necessary, use the `blockLevel` option to render as `<div>` to
|
63
|
-
keep your HTML valid.
|
64
|
-
|
65
|
-
- **Use Text for short pieces of text content.** Including a couple of HTML tags
|
66
|
-
shouldn't cause any harm, but keep in mind Text is not intended to wrap
|
67
|
-
complex HTML structures or even React components.
|
68
|
-
|
69
|
-
## Number of Lines
|
70
|
-
|
71
|
-
Specify how many `lines` of text should be visible if content doesn't fit its
|
72
|
-
container. If the number of lines is exceeded, the content is truncated and
|
73
|
-
appended by an ellipsis (`…`).
|
74
|
-
|
75
|
-
<Playground>
|
76
|
-
{() => {
|
77
|
-
const [lines, setLines] = React.useState(1);
|
78
|
-
return (
|
79
|
-
<div>
|
80
|
-
<Toolbar align="baseline">
|
81
|
-
<ToolbarItem>
|
82
|
-
<TextField
|
83
|
-
label="Number of lines"
|
84
|
-
min={1}
|
85
|
-
max={100}
|
86
|
-
onChange={(e) => setLines(Number(e.target.value))}
|
87
|
-
type="number"
|
88
|
-
value={lines}
|
89
|
-
/>
|
90
|
-
</ToolbarItem>
|
91
|
-
</Toolbar>
|
92
|
-
<Placeholder>
|
93
|
-
<Text lines={lines}>
|
94
|
-
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean
|
95
|
-
commodo ligula eget dolor. Aenean massa. Cum sociis natoque
|
96
|
-
penatibus et magnis dis parturient montes, nascetur ridiculus mus.
|
97
|
-
Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem.
|
98
|
-
Nulla consequat massa quis enim. Donec pede justo, fringilla vel,
|
99
|
-
aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut,
|
100
|
-
imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede
|
101
|
-
mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum
|
102
|
-
semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula,
|
103
|
-
porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem
|
104
|
-
ante, dapibus in, viverra quis, feugiat a, tellus.
|
105
|
-
</Text>
|
106
|
-
</Placeholder>
|
107
|
-
</div>
|
108
|
-
);
|
109
|
-
}}
|
110
|
-
</Playground>
|
111
|
-
|
112
|
-
## Word Wrapping
|
113
|
-
|
114
|
-
There are three possible ways of controlling wrapping of long words if they do
|
115
|
-
not fit on a line. Set `wordWrapping` to one of the following values:
|
116
|
-
|
117
|
-
- `normal`: Do not force any wrapping (default behavior).
|
118
|
-
|
119
|
-
- `long-words`: To prevent overflow, an otherwise unbreakable string of
|
120
|
-
characters — like a long word or URL — may be broken at any point if there are
|
121
|
-
no otherwise-acceptable break points in the line.
|
122
|
-
|
123
|
-
- `anywhere`: Create a break at the exact place where text would otherwise
|
124
|
-
overflow its container (even if putting an entire word on its own line would
|
125
|
-
negate the need for a break).
|
126
|
-
|
127
|
-
📖 [Read more about wrapping and breaking text at MDN.](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Text/Wrapping_Text)
|
128
|
-
|
129
|
-
### Hyphens
|
130
|
-
|
131
|
-
The `hyphens` option specifies how words should be hyphenated when text wraps
|
132
|
-
across multiple lines. It can prevent hyphenation entirely, hyphenate at
|
133
|
-
manually-specified points within the text, or let the browser automatically
|
134
|
-
insert hyphens where appropriate.
|
135
|
-
|
136
|
-
👉 The `auto` setting's behavior depends on the language being properly tagged
|
137
|
-
to select the appropriate hyphenation rules. **You must specify a language**
|
138
|
-
using the `lang` HTML attribute (e.g.
|
139
|
-
[on `<html>` tag](/getting-started/usage#full-example)) to guarantee that
|
140
|
-
automatic hyphenation is applied in that language.
|
141
|
-
|
142
|
-
👉 [Manually suggested line break opportunities](https://developer.mozilla.org/en-US/docs/Web/CSS/hyphens#suggesting_line_break_opportunities)
|
143
|
-
will override automatic break point selection in `auto` mode when present.
|
144
|
-
|
145
|
-
📖 [Read more about `hyphens` CSS property at MDN.](https://developer.mozilla.org/en-US/docs/Web/CSS/hyphens)
|
146
|
-
|
147
|
-
<Playground>
|
148
|
-
{() => {
|
149
|
-
const [hyphens, setHyphens] = React.useState('none');
|
150
|
-
const [wordWrapping, setWordWrapping] = React.useState('normal');
|
151
|
-
return (
|
152
|
-
<div>
|
153
|
-
<Toolbar>
|
154
|
-
<ToolbarGroup align="baseline">
|
155
|
-
<ToolbarItem>
|
156
|
-
<span id="word-wrapping-options-label">Word wrapping:</span>
|
157
|
-
</ToolbarItem>
|
158
|
-
<ToolbarItem>
|
159
|
-
<ButtonGroup aria-labelledby="word-wrapping-options-label" priority="outline">
|
160
|
-
<Button
|
161
|
-
aria-pressed={wordWrapping === 'normal'}
|
162
|
-
color={wordWrapping === 'normal' ? 'selected' : 'secondary'}
|
163
|
-
label="normal"
|
164
|
-
onClick={() => setWordWrapping('normal')}
|
165
|
-
/>
|
166
|
-
<Button
|
167
|
-
aria-pressed={wordWrapping === 'long-words'}
|
168
|
-
color={wordWrapping === 'long-words' ? 'selected' : 'secondary'}
|
169
|
-
label="long-words"
|
170
|
-
onClick={() => setWordWrapping('long-words')}
|
171
|
-
/>
|
172
|
-
<Button
|
173
|
-
aria-pressed={wordWrapping === 'anywhere'}
|
174
|
-
color={wordWrapping === 'anywhere' ? 'selected' : 'secondary'}
|
175
|
-
label="anywhere"
|
176
|
-
onClick={() => setWordWrapping('anywhere')}
|
177
|
-
/>
|
178
|
-
</ButtonGroup>
|
179
|
-
</ToolbarItem>
|
180
|
-
</ToolbarGroup>
|
181
|
-
<ToolbarGroup align="baseline">
|
182
|
-
<ToolbarItem>
|
183
|
-
<span id="hyphens-options-label">Hyphens:</span>
|
184
|
-
</ToolbarItem>
|
185
|
-
<ToolbarItem>
|
186
|
-
<ButtonGroup aria-labelledby="hyphens-options-label" priority="outline">
|
187
|
-
<Button
|
188
|
-
aria-pressed={hyphens === 'none'}
|
189
|
-
color={hyphens === 'none' ? 'selected' : 'secondary'}
|
190
|
-
label="none"
|
191
|
-
onClick={() => setHyphens('none')}
|
192
|
-
/>
|
193
|
-
<Button
|
194
|
-
aria-pressed={hyphens === 'auto'}
|
195
|
-
color={hyphens === 'auto' ? 'selected' : 'secondary'}
|
196
|
-
label="auto"
|
197
|
-
onClick={() => setHyphens('auto')}
|
198
|
-
/>
|
199
|
-
<Button
|
200
|
-
aria-pressed={hyphens === 'manual'}
|
201
|
-
color={hyphens === 'manual' ? 'selected' : 'secondary'}
|
202
|
-
label="manual"
|
203
|
-
onClick={() => setHyphens('manual')}
|
204
|
-
/>
|
205
|
-
</ButtonGroup>
|
206
|
-
</ToolbarItem>
|
207
|
-
</ToolbarGroup>
|
208
|
-
</Toolbar>
|
209
|
-
<Placeholder width="11em" bordered>
|
210
|
-
<Text hyphens={hyphens} wordWrapping={wordWrapping}>
|
211
|
-
{hyphens === 'manual'
|
212
|
-
? (<>LongWord­ThatHasManual­Breaking­Possibilities</>)
|
213
|
-
: (<>LongWordThatHasNoBreakingPossibilities</>)}
|
214
|
-
{' '}
|
215
|
-
and a couple of ordinary words that are nice and well behaved.
|
216
|
-
</Text>
|
217
|
-
</Placeholder>
|
218
|
-
</div>
|
219
|
-
);
|
220
|
-
}}
|
221
|
-
</Playground>
|
222
|
-
|
223
|
-
## Forwarding HTML Attributes
|
224
|
-
|
225
|
-
In addition to the options below in the [component's API](#api) section, you
|
226
|
-
can specify [React synthetic events] or **any HTML attribute you like.** All
|
227
|
-
attributes that don't interfere with the API are forwarded either to the
|
228
|
-
`<span>` or to the `<div>` HTML element in case that `blockLevel` is set to
|
229
|
-
`true`. This enables making the component interactive and helps to improve its
|
230
|
-
accessibility.
|
231
|
-
|
232
|
-
👉 Refer to the MDN reference for the full list of supported attributes of the
|
233
|
-
[span] and [div] element.
|
234
|
-
|
235
|
-
## API
|
236
|
-
|
237
|
-
<Props table of={Text} />
|
238
|
-
|
239
|
-
[React synthetic events]: https://reactjs.org/docs/events.html
|
240
|
-
[span]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/span#attributes
|
241
|
-
[div]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div#attributes
|