@react-ui-org/react-ui 0.48.0 → 0.49.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/dist/lib.development.js +160 -64
- package/dist/lib.js +1 -1
- package/package.json +1 -1
- package/src/lib/components/Alert/Alert.jsx +3 -0
- package/src/lib/components/Alert/Alert.scss +10 -10
- package/src/lib/components/Alert/README.mdx +14 -0
- package/src/lib/components/Badge/Badge.jsx +4 -8
- package/src/lib/components/Badge/Badge.scss +21 -21
- package/src/lib/components/Badge/README.mdx +14 -0
- package/src/lib/components/Button/Button.jsx +2 -13
- package/src/lib/components/Button/README.mdx +17 -5
- package/src/lib/components/Button/_base.scss +20 -20
- package/src/lib/components/Button/_priorities.scss +35 -35
- package/src/lib/components/Button/helpers/getRootLabelVisibilityClassName.js +7 -7
- package/src/lib/components/Button/helpers/getRootPriorityClassName.js +3 -3
- package/src/lib/components/ButtonGroup/ButtonGroup.jsx +0 -7
- package/src/lib/components/ButtonGroup/README.mdx +14 -0
- package/src/lib/components/Card/Card.jsx +6 -10
- package/src/lib/components/Card/Card.scss +13 -13
- package/src/lib/components/Card/CardBody.jsx +6 -10
- package/src/lib/components/Card/CardFooter.jsx +6 -7
- package/src/lib/components/Card/README.mdx +14 -0
- package/src/lib/components/CheckboxField/CheckboxField.jsx +1 -27
- package/src/lib/components/CheckboxField/README.mdx +17 -5
- package/src/lib/components/FileInputField/FileInputField.jsx +2 -11
- package/src/lib/components/FileInputField/FileInputField.scss +3 -3
- package/src/lib/components/FileInputField/README.mdx +29 -27
- package/src/lib/components/FormLayout/FormLayout.jsx +5 -9
- package/src/lib/components/FormLayout/FormLayout.scss +3 -3
- package/src/lib/components/FormLayout/FormLayoutCustomField.jsx +4 -1
- package/src/lib/components/FormLayout/FormLayoutCustomField.scss +8 -8
- package/src/lib/components/FormLayout/README.mdx +13 -0
- package/src/lib/components/Grid/Grid.jsx +0 -7
- package/src/lib/components/Grid/GridSpan.jsx +0 -7
- package/src/lib/components/Grid/README.mdx +14 -0
- package/src/lib/components/Modal/Modal.jsx +6 -10
- package/src/lib/components/Modal/ModalBody.jsx +3 -7
- package/src/lib/components/Modal/ModalCloseButton.jsx +0 -16
- package/src/lib/components/Modal/ModalContent.jsx +3 -7
- package/src/lib/components/Modal/ModalFooter.jsx +3 -7
- package/src/lib/components/Modal/ModalFooter.scss +5 -5
- package/src/lib/components/Modal/ModalHeader.jsx +3 -7
- package/src/lib/components/Modal/ModalHeader.scss +5 -5
- package/src/lib/components/Modal/ModalTitle.jsx +6 -7
- package/src/lib/components/Modal/README.mdx +25 -0
- package/src/lib/components/Modal/_helpers/getJustifyClassName.js +5 -5
- package/src/lib/components/Paper/Paper.jsx +5 -9
- package/src/lib/components/Paper/Paper.scss +2 -2
- package/src/lib/components/Paper/README.mdx +14 -0
- package/src/lib/components/Popover/Popover.jsx +0 -16
- package/src/lib/components/Popover/PopoverWrapper.jsx +0 -7
- package/src/lib/components/Popover/README.mdx +19 -0
- package/src/lib/components/Radio/README.mdx +12 -5
- package/src/lib/components/Radio/Radio.jsx +2 -2
- package/src/lib/components/Radio/Radio.scss +3 -3
- package/src/lib/components/ScrollView/README.mdx +19 -0
- package/src/lib/components/ScrollView/ScrollView.jsx +11 -4
- package/src/lib/components/SelectField/README.mdx +17 -5
- package/src/lib/components/SelectField/SelectField.jsx +3 -22
- package/src/lib/components/SelectField/SelectField.scss +8 -8
- package/src/lib/components/Table/README.mdx +21 -7
- package/src/lib/components/Table/Table.jsx +43 -101
- package/src/lib/components/Table/Table.scss +0 -24
- package/src/lib/components/Table/_components/TableBodyCell/TableBodyCell.jsx +46 -0
- package/src/lib/components/Table/_components/TableBodyCell/index.js +1 -0
- package/src/lib/components/Table/_components/TableCell.scss +25 -0
- package/src/lib/components/Table/_components/TableHeaderCell/TableHeaderCell.jsx +71 -0
- package/src/lib/components/Table/_components/TableHeaderCell/index.js +1 -0
- package/src/lib/components/Tabs/README.mdx +16 -0
- package/src/lib/components/Tabs/Tabs.jsx +6 -1
- package/src/lib/components/Tabs/TabsItem.jsx +3 -0
- package/src/lib/components/Text/README.mdx +16 -0
- package/src/lib/components/Text/Text.jsx +3 -7
- package/src/lib/components/Text/Text.scss +6 -6
- package/src/lib/components/Text/_helpers/getRootClampClassName.js +2 -2
- package/src/lib/components/Text/_helpers/getRootHyphensClassName.js +2 -2
- package/src/lib/components/Text/_helpers/getRootWordWrappingClassName.js +2 -2
- package/src/lib/components/TextArea/README.mdx +33 -30
- package/src/lib/components/TextArea/TextArea.jsx +3 -43
- package/src/lib/components/TextArea/TextArea.scss +8 -8
- package/src/lib/components/TextField/README.mdx +53 -51
- package/src/lib/components/TextField/TextField.jsx +3 -29
- package/src/lib/components/TextField/TextField.scss +9 -9
- package/src/lib/components/TextLink/README.mdx +12 -5
- package/src/lib/components/TextLink/TextLink.jsx +0 -10
- package/src/lib/components/Toggle/README.mdx +17 -5
- package/src/lib/components/Toggle/Toggle.jsx +1 -27
- package/src/lib/components/Toolbar/README.mdx +13 -0
- package/src/lib/components/Toolbar/Toolbar.jsx +9 -43
- package/src/lib/components/Toolbar/Toolbar.scss +24 -12
- package/src/lib/components/Toolbar/ToolbarGroup.jsx +7 -26
- package/src/lib/components/Toolbar/ToolbarItem.jsx +3 -7
- package/src/lib/components/Toolbar/_helpers/getAlignClassName.js +19 -0
- package/src/lib/components/Toolbar/_helpers/getJustifyClassName.js +16 -0
- package/src/lib/components/_helpers/getRootColorClassName.js +10 -10
- package/src/lib/components/_helpers/getRootSizeClassName.js +3 -3
- package/src/lib/styles/tools/form-fields/_box-field-layout.scss +15 -15
- package/src/lib/styles/tools/form-fields/_inline-field-elements.scss +1 -1
- package/src/lib/styles/tools/form-fields/_inline-field-layout.scss +9 -9
|
@@ -1,110 +1,52 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { withGlobalProps } from '../../provider';
|
|
4
|
-
import {
|
|
4
|
+
import { transferProps } from '../_helpers/transferProps';
|
|
5
|
+
import { TableHeaderCell } from './_components/TableHeaderCell';
|
|
6
|
+
import { TableBodyCell } from './_components/TableBodyCell';
|
|
5
7
|
import styles from './Table.scss';
|
|
6
8
|
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
labelVisibility="none"
|
|
42
|
-
onClick={() => sort.onClick(column.name, sortDirection)}
|
|
43
|
-
priority="flat"
|
|
44
|
-
{...(id && { id: `${id}__headerCell__${column.name}__sortButton` })}
|
|
9
|
+
export const Table = ({
|
|
10
|
+
columns,
|
|
11
|
+
id,
|
|
12
|
+
rows,
|
|
13
|
+
sort,
|
|
14
|
+
...restProps
|
|
15
|
+
}) => (
|
|
16
|
+
<table
|
|
17
|
+
{...transferProps(restProps)}
|
|
18
|
+
className={styles.table}
|
|
19
|
+
id={id}
|
|
20
|
+
>
|
|
21
|
+
<thead>
|
|
22
|
+
<tr className={styles.tableHeadRow}>
|
|
23
|
+
{columns.map((column) => (
|
|
24
|
+
<TableHeaderCell
|
|
25
|
+
column={column}
|
|
26
|
+
key={column.name}
|
|
27
|
+
sort={sort}
|
|
28
|
+
{...(id && { id: `${id}__headerCell__${column.name}` })}
|
|
29
|
+
/>
|
|
30
|
+
))}
|
|
31
|
+
</tr>
|
|
32
|
+
</thead>
|
|
33
|
+
<tbody>
|
|
34
|
+
{rows.map((row) => (
|
|
35
|
+
<tr key={row.id} className={styles.tableRow}>
|
|
36
|
+
{columns.map((column) => (
|
|
37
|
+
<TableBodyCell
|
|
38
|
+
format={column.format}
|
|
39
|
+
isSortingActive={sort && column.name === sort.column}
|
|
40
|
+
key={`${row.id}-${column.name}`}
|
|
41
|
+
value={row[column.name]}
|
|
42
|
+
{...(id && { id: `${id}__bodyCell__${column.name}__${row.id}` })}
|
|
45
43
|
/>
|
|
46
|
-
</div>
|
|
47
|
-
)}
|
|
48
|
-
{column.label}
|
|
49
|
-
</th>
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
renderBodyCell(column, row) {
|
|
54
|
-
const {
|
|
55
|
-
id,
|
|
56
|
-
sort,
|
|
57
|
-
} = this.props;
|
|
58
|
-
const isSortingActive = sort && column.name === sort.column;
|
|
59
|
-
|
|
60
|
-
if (column.format) {
|
|
61
|
-
return (
|
|
62
|
-
<td
|
|
63
|
-
className={isSortingActive ? styles.isTableCellSortingActive : styles.tableCell}
|
|
64
|
-
key={`${row.id}-${column.name}`}
|
|
65
|
-
{...(id && { id: `${id}__bodyCell__${column.name}__${row.id}` })}
|
|
66
|
-
>
|
|
67
|
-
{column.format(row)}
|
|
68
|
-
</td>
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return (
|
|
73
|
-
<td
|
|
74
|
-
className={isSortingActive ? styles.isTableCellSortingActive : styles.tableCell}
|
|
75
|
-
key={`${row.id}-${column.name}`}
|
|
76
|
-
{...(id && { id: `${id}__bodyCell__${column.name}__${row.id}` })}
|
|
77
|
-
>
|
|
78
|
-
{row[column.name]}
|
|
79
|
-
</td>
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
render() {
|
|
84
|
-
const {
|
|
85
|
-
columns,
|
|
86
|
-
id,
|
|
87
|
-
rows,
|
|
88
|
-
} = this.props;
|
|
89
|
-
|
|
90
|
-
return (
|
|
91
|
-
<table id={id} className={styles.table}>
|
|
92
|
-
<thead>
|
|
93
|
-
<tr className={styles.tableHeadRow}>
|
|
94
|
-
{columns.map(this.renderHeaderCell)}
|
|
95
|
-
</tr>
|
|
96
|
-
</thead>
|
|
97
|
-
<tbody>
|
|
98
|
-
{rows.map((row) => (
|
|
99
|
-
<tr key={row.id} className={styles.tableRow}>
|
|
100
|
-
{columns.map((column) => this.renderBodyCell(column, row))}
|
|
101
|
-
</tr>
|
|
102
44
|
))}
|
|
103
|
-
</
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
45
|
+
</tr>
|
|
46
|
+
))}
|
|
47
|
+
</tbody>
|
|
48
|
+
</table>
|
|
49
|
+
);
|
|
108
50
|
|
|
109
51
|
Table.defaultProps = {
|
|
110
52
|
id: undefined,
|
|
@@ -123,7 +65,7 @@ Table.propTypes = {
|
|
|
123
65
|
name: PropTypes.string.isRequired,
|
|
124
66
|
})).isRequired,
|
|
125
67
|
/**
|
|
126
|
-
* ID of the root HTML element. It also serves as base
|
|
68
|
+
* ID of the root HTML element. It also serves as base for nested elements:
|
|
127
69
|
* * `<ID>__headerCell__<COLUMN_NAME>`
|
|
128
70
|
* * `<ID>__headerCell__<COLUMN_NAME>__sortButton`
|
|
129
71
|
* * `<ID>__bodyCell__<COLUMN_NAME>__<ROW_ID>`
|
|
@@ -26,27 +26,3 @@
|
|
|
26
26
|
background-color: settings.$head-background-color;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
.tableCell,
|
|
31
|
-
.tableHeadCell,
|
|
32
|
-
.isTableCellSortingActive,
|
|
33
|
-
.isTableHeadCellSortingActive {
|
|
34
|
-
padding: settings.$cell-padding-y settings.$cell-padding-x;
|
|
35
|
-
text-align: left;
|
|
36
|
-
border-bottom: settings.$border-width solid settings.$border-color;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.tableHeadCell {
|
|
40
|
-
font-weight: settings.$head-font-weight;
|
|
41
|
-
border-bottom-width: 2px;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.isTableCellSortingActive,
|
|
45
|
-
.isTableHeadCellSortingActive {
|
|
46
|
-
background-color: settings.$sorted-background-color;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.sortButton {
|
|
50
|
-
display: inline-block;
|
|
51
|
-
margin-right: settings.$cell-padding-x;
|
|
52
|
-
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import styles from '../TableCell.scss';
|
|
4
|
+
|
|
5
|
+
export const TableBodyCell = ({
|
|
6
|
+
format,
|
|
7
|
+
id,
|
|
8
|
+
isSortingActive,
|
|
9
|
+
value,
|
|
10
|
+
}) => (
|
|
11
|
+
<td
|
|
12
|
+
className={isSortingActive ? styles.isTableCellSortingActive : styles.tableCell}
|
|
13
|
+
id={id}
|
|
14
|
+
>
|
|
15
|
+
{format ? format(value) : value}
|
|
16
|
+
</td>
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
TableBodyCell.defaultProps = {
|
|
20
|
+
format: undefined,
|
|
21
|
+
id: undefined,
|
|
22
|
+
isSortingActive: false,
|
|
23
|
+
value: null,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
TableBodyCell.propTypes = {
|
|
27
|
+
/**
|
|
28
|
+
* Function that can be used to process the column data before displaying them.
|
|
29
|
+
*/
|
|
30
|
+
format: PropTypes.func,
|
|
31
|
+
/**
|
|
32
|
+
* ID of the HTML <td> element:
|
|
33
|
+
*/
|
|
34
|
+
id: PropTypes.string,
|
|
35
|
+
/**
|
|
36
|
+
* If `true`, cell is gray marked as sorted.
|
|
37
|
+
*/
|
|
38
|
+
isSortingActive: PropTypes.bool,
|
|
39
|
+
/**
|
|
40
|
+
* Cell value.
|
|
41
|
+
*/
|
|
42
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
43
|
+
value: PropTypes.any,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export default TableBodyCell;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as TableBodyCell } from './TableBodyCell';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
@use "../settings";
|
|
2
|
+
|
|
3
|
+
.tableCell,
|
|
4
|
+
.tableHeadCell,
|
|
5
|
+
.isTableCellSortingActive,
|
|
6
|
+
.isTableHeadCellSortingActive {
|
|
7
|
+
padding: settings.$cell-padding-y settings.$cell-padding-x;
|
|
8
|
+
text-align: left;
|
|
9
|
+
border-bottom: settings.$border-width solid settings.$border-color;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.tableHeadCell {
|
|
13
|
+
font-weight: settings.$head-font-weight;
|
|
14
|
+
border-bottom-width: 2px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.isTableCellSortingActive,
|
|
18
|
+
.isTableHeadCellSortingActive {
|
|
19
|
+
background-color: settings.$sorted-background-color;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.sortButton {
|
|
23
|
+
display: inline-block;
|
|
24
|
+
margin-right: settings.$cell-padding-x;
|
|
25
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Button } from '../../../..';
|
|
4
|
+
import styles from '../TableCell.scss';
|
|
5
|
+
|
|
6
|
+
export const TableHeaderCell = ({
|
|
7
|
+
column,
|
|
8
|
+
id,
|
|
9
|
+
sort,
|
|
10
|
+
}) => {
|
|
11
|
+
const sortDirection = sort && column.name === sort.column ? sort.direction : 'asc';
|
|
12
|
+
const isSortingActive = sort && column.name === sort.column;
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<th
|
|
16
|
+
className={isSortingActive ? styles.isTableHeadCellSortingActive : styles.tableHeadCell}
|
|
17
|
+
id={id}
|
|
18
|
+
>
|
|
19
|
+
{sort && column.isSortable && (
|
|
20
|
+
<div className={styles.sortButton}>
|
|
21
|
+
<Button
|
|
22
|
+
beforeLabel={
|
|
23
|
+
sortDirection === 'asc'
|
|
24
|
+
? sort.ascendingIcon
|
|
25
|
+
: sort.descendingIcon
|
|
26
|
+
}
|
|
27
|
+
id={id && `${id}__sortButton`}
|
|
28
|
+
label={sortDirection}
|
|
29
|
+
labelVisibility="none"
|
|
30
|
+
onClick={() => sort.onClick(column.name, sortDirection)}
|
|
31
|
+
priority="flat"
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
34
|
+
)}
|
|
35
|
+
{column.label}
|
|
36
|
+
</th>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
TableHeaderCell.defaultProps = {
|
|
41
|
+
id: undefined,
|
|
42
|
+
sort: null,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
TableHeaderCell.propTypes = {
|
|
46
|
+
/**
|
|
47
|
+
* Table data column, optionally sortable. The `format` function can be used to process the
|
|
48
|
+
* column data before displaying them.
|
|
49
|
+
*/
|
|
50
|
+
column: PropTypes.shape({
|
|
51
|
+
isSortable: PropTypes.bool,
|
|
52
|
+
label: PropTypes.string,
|
|
53
|
+
name: PropTypes.string.isRequired,
|
|
54
|
+
}).isRequired,
|
|
55
|
+
/**
|
|
56
|
+
* ID of the HTML <th> element and nested button for sorting.
|
|
57
|
+
*/
|
|
58
|
+
id: PropTypes.string,
|
|
59
|
+
/**
|
|
60
|
+
* Sorting configuration required to make columns sortable.
|
|
61
|
+
*/
|
|
62
|
+
sort: PropTypes.shape({
|
|
63
|
+
ascendingIcon: PropTypes.node.isRequired,
|
|
64
|
+
column: PropTypes.string.isRequired,
|
|
65
|
+
descendingIcon: PropTypes.node.isRequired,
|
|
66
|
+
direction: PropTypes.oneOf(['asc', 'desc']).isRequired,
|
|
67
|
+
onClick: PropTypes.func.isRequired,
|
|
68
|
+
}),
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export default TableHeaderCell;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as TableHeaderCell } from './TableHeaderCell';
|
|
@@ -171,6 +171,18 @@ accessible no matter the space they have around. Wrap Tabs into
|
|
|
171
171
|
}}
|
|
172
172
|
</Playground>
|
|
173
173
|
|
|
174
|
+
## Forwarding HTML Attributes
|
|
175
|
+
|
|
176
|
+
In addition to the options below in the [component's API](#api) section, you
|
|
177
|
+
can specify [React synthetic events] or **any HTML attribute you like.** All
|
|
178
|
+
attributes that don't interfere with the API are forwarded to the `<nav>` HTML
|
|
179
|
+
element in case of `Tabs` component and to the `<li>` HTML element in
|
|
180
|
+
case of `TabsItem`. This enables making the component interactive and helps
|
|
181
|
+
to improve its accessibility.
|
|
182
|
+
|
|
183
|
+
👉 Refer to the MDN reference for the full list of supported attributes of the
|
|
184
|
+
[nav] and [li] element.
|
|
185
|
+
|
|
174
186
|
## API
|
|
175
187
|
|
|
176
188
|
<Props table of={Tabs} />
|
|
@@ -220,3 +232,7 @@ Where:
|
|
|
220
232
|
- `<PROPERTY>` is one of `font-weight`, `color`, `border-width`, `border-color`,
|
|
221
233
|
`background-color`, `box-shadow`, `shift-y` (shifts vertically the whole
|
|
222
234
|
item), or `label__shift-y` (tweaks vertical position of tab label).
|
|
235
|
+
|
|
236
|
+
[React synthetic events]: https://reactjs.org/docs/events.html
|
|
237
|
+
[nav]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/nav#attributes
|
|
238
|
+
[li]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/li#attributes
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { withGlobalProps } from '../../provider';
|
|
4
|
+
import { transferProps } from '../_helpers/transferProps';
|
|
4
5
|
import styles from './Tabs.scss';
|
|
5
6
|
|
|
6
7
|
export const Tabs = ({
|
|
7
8
|
children,
|
|
8
9
|
id,
|
|
10
|
+
...restProps
|
|
9
11
|
}) => (
|
|
10
|
-
<nav
|
|
12
|
+
<nav
|
|
13
|
+
{...transferProps(restProps)}
|
|
14
|
+
id={id}
|
|
15
|
+
>
|
|
11
16
|
<ul
|
|
12
17
|
className={styles.list}
|
|
13
18
|
id={id && `${id}__list`}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { withGlobalProps } from '../../provider';
|
|
4
|
+
import { transferProps } from '../_helpers/transferProps';
|
|
4
5
|
import { classNames } from '../../utils/classNames';
|
|
5
6
|
import styles from './TabsItem.scss';
|
|
6
7
|
|
|
@@ -12,8 +13,10 @@ export const TabsItem = ({
|
|
|
12
13
|
isActive,
|
|
13
14
|
label,
|
|
14
15
|
onClick,
|
|
16
|
+
...restProps
|
|
15
17
|
}) => (
|
|
16
18
|
<li
|
|
19
|
+
{...transferProps(restProps)}
|
|
17
20
|
className={classNames(
|
|
18
21
|
styles.root,
|
|
19
22
|
isActive && styles.isRootActive,
|
|
@@ -214,6 +214,22 @@ will override automatic break point selection in `auto` mode when present.
|
|
|
214
214
|
}}
|
|
215
215
|
</Playground>
|
|
216
216
|
|
|
217
|
+
## Forwarding HTML Attributes
|
|
218
|
+
|
|
219
|
+
In addition to the options below in the [component's API](#api) section, you
|
|
220
|
+
can specify [React synthetic events] or **any HTML attribute you like.** All
|
|
221
|
+
attributes that don't interfere with the API are forwarded either to the
|
|
222
|
+
`<span>` or to the `<div>` HTML element in case that `blockLevel` is set to
|
|
223
|
+
`true`. This enables making the component interactive and helps to improve its
|
|
224
|
+
accessibility.
|
|
225
|
+
|
|
226
|
+
👉 Refer to the MDN reference for the full list of supported attributes of the
|
|
227
|
+
[span] and [div] element.
|
|
228
|
+
|
|
217
229
|
## API
|
|
218
230
|
|
|
219
231
|
<Props table of={Text} />
|
|
232
|
+
|
|
233
|
+
[React synthetic events]: https://reactjs.org/docs/events.html
|
|
234
|
+
[span]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/span#attributes
|
|
235
|
+
[div]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div#attributes
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { withGlobalProps } from '../../provider';
|
|
4
|
+
import { transferProps } from '../_helpers/transferProps';
|
|
4
5
|
import { classNames } from '../../utils/classNames';
|
|
5
6
|
import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
|
|
6
7
|
import { getRootClampClassName } from './_helpers/getRootClampClassName';
|
|
@@ -12,9 +13,9 @@ export const Text = ({
|
|
|
12
13
|
blockLevel,
|
|
13
14
|
children,
|
|
14
15
|
hyphens,
|
|
15
|
-
id,
|
|
16
16
|
lines,
|
|
17
17
|
wordWrapping,
|
|
18
|
+
...restProps
|
|
18
19
|
}) => {
|
|
19
20
|
if (isChildrenEmpty(children)) {
|
|
20
21
|
return null;
|
|
@@ -24,6 +25,7 @@ export const Text = ({
|
|
|
24
25
|
|
|
25
26
|
return (
|
|
26
27
|
<HtmlElement
|
|
28
|
+
{...transferProps(restProps)}
|
|
27
29
|
className={(hyphens !== 'none' || lines > 0 || wordWrapping !== 'normal')
|
|
28
30
|
? classNames(
|
|
29
31
|
getRootClampClassName(lines, styles),
|
|
@@ -31,7 +33,6 @@ export const Text = ({
|
|
|
31
33
|
getRootWordWrappingClassName(wordWrapping, styles),
|
|
32
34
|
)
|
|
33
35
|
: undefined}
|
|
34
|
-
id={id}
|
|
35
36
|
style={(lines > 1) ? { '--rui-custom-lines': lines } : undefined}
|
|
36
37
|
>
|
|
37
38
|
{children}
|
|
@@ -43,7 +44,6 @@ Text.defaultProps = {
|
|
|
43
44
|
blockLevel: false,
|
|
44
45
|
children: null,
|
|
45
46
|
hyphens: 'none',
|
|
46
|
-
id: undefined,
|
|
47
47
|
lines: undefined,
|
|
48
48
|
wordWrapping: 'normal',
|
|
49
49
|
};
|
|
@@ -61,10 +61,6 @@ Text.propTypes = {
|
|
|
61
61
|
* Turn on hyphenation. Head to [Hyphens](#hyphens) to learn more.
|
|
62
62
|
*/
|
|
63
63
|
hyphens: PropTypes.oneOf(['none', 'auto', 'manual']),
|
|
64
|
-
/**
|
|
65
|
-
* Optional ID of the root HTML element.
|
|
66
|
-
*/
|
|
67
|
-
id: PropTypes.string,
|
|
68
64
|
/**
|
|
69
65
|
* Optional number of lines. If exceeded, the content is truncated and appended by an ellipsis (`…`).
|
|
70
66
|
*/
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// 2. Different approaches are used for single and multiline texts because the latter approach
|
|
6
6
|
// doesn't always work for single-line texts.
|
|
7
7
|
|
|
8
|
-
.
|
|
8
|
+
.isRootClampSingleLine {
|
|
9
9
|
display: block; // 2.
|
|
10
10
|
overflow: hidden;
|
|
11
11
|
text-overflow: ellipsis;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
// stylelint-disable property-no-vendor-prefix, value-no-vendor-prefix
|
|
16
|
-
.
|
|
16
|
+
.isRootClampMultiLine {
|
|
17
17
|
display: -webkit-box; // 2.
|
|
18
18
|
-webkit-line-clamp: var(--rui-custom-lines);
|
|
19
19
|
-webkit-box-orient: vertical;
|
|
@@ -22,19 +22,19 @@
|
|
|
22
22
|
}
|
|
23
23
|
// stylelint-enable property-no-vendor-prefix, value-no-vendor-prefix
|
|
24
24
|
|
|
25
|
-
.
|
|
25
|
+
.isRootHyphensAuto {
|
|
26
26
|
hyphens: auto;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
.
|
|
29
|
+
.isRootHyphensManual {
|
|
30
30
|
hyphens: manual;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
.
|
|
33
|
+
.isRootWordWrappingAnywhere {
|
|
34
34
|
word-break: break-all;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
.
|
|
37
|
+
.isRootWordWrappingLongWords {
|
|
38
38
|
word-break: break-word; // 1.
|
|
39
39
|
overflow-wrap: anywhere;
|
|
40
40
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export const getRootClampClassName = (lines, styles) => {
|
|
2
2
|
if (lines === 1) {
|
|
3
|
-
return styles.
|
|
3
|
+
return styles.isRootClampSingleLine;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
if (lines > 1) {
|
|
7
|
-
return styles.
|
|
7
|
+
return styles.isRootClampMultiLine;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
return null;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export const getRootHyphensClassName = (hyphens, styles) => {
|
|
2
2
|
if (hyphens === 'auto') {
|
|
3
|
-
return styles.
|
|
3
|
+
return styles.isRootHyphensAuto;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
if (hyphens === 'manual') {
|
|
7
|
-
return styles.
|
|
7
|
+
return styles.isRootHyphensManual;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
return null;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export const getRootWordWrappingClassName = (wordWrapping, styles) => {
|
|
2
2
|
if (wordWrapping === 'anywhere') {
|
|
3
|
-
return styles.
|
|
3
|
+
return styles.isRootWordWrappingAnywhere;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
if (wordWrapping === 'long-words') {
|
|
7
|
-
return styles.
|
|
7
|
+
return styles.isRootWordWrappingLongWords;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
return null;
|
|
@@ -142,31 +142,6 @@ to achieve that effect.
|
|
|
142
142
|
/>
|
|
143
143
|
</Playground>
|
|
144
144
|
|
|
145
|
-
## Forwarding HTML Attributes
|
|
146
|
-
|
|
147
|
-
When you want to improve the accessibility of your text fields even further, you
|
|
148
|
-
can **add whatever HTML attribute you like.** All attributes that don't
|
|
149
|
-
interfere with [component's API](#api) are forwarded to the native HTML input.
|
|
150
|
-
|
|
151
|
-
<Playground>
|
|
152
|
-
<TextArea
|
|
153
|
-
label="Address"
|
|
154
|
-
autoComplete="street-address"
|
|
155
|
-
minLength={3}
|
|
156
|
-
maxLength={80}
|
|
157
|
-
/>
|
|
158
|
-
<TextArea
|
|
159
|
-
label="Address"
|
|
160
|
-
variant="filled"
|
|
161
|
-
autoComplete="street-address"
|
|
162
|
-
minLength={3}
|
|
163
|
-
maxLength={80}
|
|
164
|
-
/>
|
|
165
|
-
</Playground>
|
|
166
|
-
|
|
167
|
-
👉 Refer to the MDN reference for the full list of
|
|
168
|
-
[supported attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#Attributes).
|
|
169
|
-
|
|
170
145
|
## Invisible Label
|
|
171
146
|
|
|
172
147
|
In some cases, it may be convenient to visually hide the field label. The label
|
|
@@ -346,12 +321,38 @@ It's possible to disable the whole input.
|
|
|
346
321
|
/>
|
|
347
322
|
</Playground>
|
|
348
323
|
|
|
349
|
-
##
|
|
324
|
+
## Forwarding HTML Attributes
|
|
350
325
|
|
|
351
|
-
In addition to the options below
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
326
|
+
In addition to the options below in the [component's API](#api) section, you
|
|
327
|
+
can specify [React synthetic events] or you can **add whatever HTML attribute
|
|
328
|
+
you like.** All attributes that don't interfere with the API are forwarded to
|
|
329
|
+
the native HTML `<textarea>`. This enables making the component interactive and
|
|
330
|
+
to helps to improve its accessibility.
|
|
331
|
+
|
|
332
|
+
<Playground>
|
|
333
|
+
<TextArea
|
|
334
|
+
label="Address"
|
|
335
|
+
autoComplete="street-address"
|
|
336
|
+
minLength={3}
|
|
337
|
+
maxLength={80}
|
|
338
|
+
/>
|
|
339
|
+
<TextArea
|
|
340
|
+
label="Address"
|
|
341
|
+
variant="filled"
|
|
342
|
+
autoComplete="street-address"
|
|
343
|
+
minLength={3}
|
|
344
|
+
maxLength={80}
|
|
345
|
+
/>
|
|
346
|
+
</Playground>
|
|
347
|
+
|
|
348
|
+
👉 Refer to the MDN reference for the full list of supported attributes of the
|
|
349
|
+
[textarea] element.
|
|
350
|
+
|
|
351
|
+
## Forwarding ref
|
|
352
|
+
|
|
353
|
+
If you provide [ref], it is forwarded to the native HTML `<textarea>` element.
|
|
354
|
+
|
|
355
|
+
## API
|
|
355
356
|
|
|
356
357
|
<Props table of={TextArea} />
|
|
357
358
|
|
|
@@ -361,3 +362,5 @@ Head to [Forms Theming](/customize/theming/forms) to see shared form theming
|
|
|
361
362
|
options.
|
|
362
363
|
|
|
363
364
|
[React synthetic events]: https://reactjs.org/docs/events.html
|
|
365
|
+
[textarea]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#attributes
|
|
366
|
+
[ref]: https://reactjs.org/docs/refs-and-the-dom.html
|