@react-ui-org/react-ui 0.42.1 → 0.44.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CONTRIBUTING.md +44 -25
- package/README.md +1 -1
- package/dist/lib.development.js +1597 -651
- package/dist/lib.js +1 -9
- package/package.json +47 -46
- package/src/lib/components/{ui/Alert → Alert}/Alert.jsx +17 -14
- package/src/lib/components/{ui/Alert → Alert}/Alert.scss +3 -3
- package/src/lib/components/{ui/Alert → Alert}/README.mdx +6 -6
- package/src/lib/components/{ui/Alert → Alert}/_settings.scss +1 -1
- package/src/lib/components/{ui/Alert → Alert}/_theme.scss +0 -0
- package/src/lib/components/{ui/Alert → Alert}/_tools.scss +0 -0
- package/src/lib/components/{ui/Alert → Alert}/index.js +0 -0
- package/src/lib/components/{ui/Badge → Badge}/Badge.jsx +2 -2
- package/src/lib/components/{ui/Badge → Badge}/Badge.scss +3 -3
- package/src/lib/components/{ui/Badge → Badge}/README.mdx +3 -3
- package/src/lib/components/{ui/Badge → Badge}/index.js +0 -0
- package/src/lib/components/Button/Button.jsx +198 -0
- package/src/lib/components/{ui/Button → Button}/Button.scss +0 -0
- package/src/lib/components/{ui/Button → Button}/README.mdx +161 -76
- package/src/lib/components/Button/_base.scss +148 -0
- package/src/lib/components/{ui/Button → Button}/_priorities.scss +0 -4
- package/src/lib/components/{ui/Button → Button}/_settings.scss +2 -3
- package/src/lib/components/{ui/Button → Button}/_theme.scss +3 -11
- package/src/lib/components/{ui/Button → Button}/_tools.scss +27 -44
- package/src/lib/components/Button/helpers/getRootLabelVisibilityClassName.js +33 -0
- package/src/lib/components/{ui/Button → Button}/helpers/getRootPriorityClassName.js +0 -4
- package/src/lib/components/{ui/Button → Button}/index.js +0 -0
- package/src/lib/components/{ui/ButtonGroup → ButtonGroup}/ButtonGroup.jsx +9 -11
- package/src/lib/components/{ui/ButtonGroup → ButtonGroup}/ButtonGroup.scss +0 -0
- package/src/lib/components/ButtonGroup/ButtonGroupContext.js +3 -0
- package/src/lib/components/{ui/ButtonGroup → ButtonGroup}/README.mdx +30 -6
- package/src/lib/components/ButtonGroup/index.js +2 -0
- package/src/lib/components/{layout/CTA → CTA}/CTA.jsx +5 -2
- package/src/lib/components/{layout/CTA → CTA}/CTA.scss +2 -2
- package/src/lib/components/{layout/CTA → CTA}/CTACenter.jsx +1 -1
- package/src/lib/components/{layout/CTA → CTA}/CTAEnd.jsx +1 -1
- package/src/lib/components/{layout/CTA → CTA}/CTAStart.jsx +1 -1
- package/src/lib/components/{layout/CTA → CTA}/README.mdx +4 -4
- package/src/lib/components/{layout/CTA → CTA}/index.js +0 -0
- package/src/lib/components/{ui/Card → Card}/Card.jsx +6 -4
- package/src/lib/components/{ui/Card → Card}/Card.scss +1 -1
- package/src/lib/components/{ui/Card → Card}/CardBody.jsx +1 -1
- package/src/lib/components/{ui/Card → Card}/CardFooter.jsx +1 -1
- package/src/lib/components/{ui/Card → Card}/README.mdx +4 -4
- package/src/lib/components/{ui/Card → Card}/_theme.scss +0 -0
- package/src/lib/components/{ui/Card → Card}/_tools.scss +0 -0
- package/src/lib/components/{ui/Card → Card}/index.js +0 -0
- package/src/lib/components/{layout/Center → Center}/Center.jsx +1 -1
- package/src/lib/components/{layout/Center → Center}/Center.scss +0 -0
- package/src/lib/components/{layout/Center → Center}/README.mdx +2 -2
- package/src/lib/components/{layout/Center → Center}/index.js +0 -0
- package/src/lib/components/CheckboxField/CheckboxField.jsx +164 -0
- package/src/lib/components/{ui/CheckboxField → CheckboxField}/CheckboxField.scss +5 -5
- package/src/lib/components/{ui/CheckboxField → CheckboxField}/README.mdx +17 -14
- package/src/lib/components/{ui/CheckboxField → CheckboxField}/index.js +0 -0
- package/src/lib/components/FileInputField/FileInputField.jsx +162 -0
- package/src/lib/components/{ui/FileInputField → FileInputField}/FileInputField.scss +5 -5
- package/src/lib/components/{ui/FileInputField → FileInputField}/README.mdx +8 -6
- package/src/lib/components/{ui/FileInputField → FileInputField}/index.js +0 -0
- package/src/lib/components/{layout/FormLayout → FormLayout}/FormLayout.jsx +16 -18
- package/src/lib/components/{layout/FormLayout → FormLayout}/FormLayout.scss +3 -3
- package/src/lib/components/FormLayout/FormLayoutContext.js +3 -0
- package/src/lib/components/{layout/FormLayout → FormLayout}/FormLayoutCustomField.jsx +33 -30
- package/src/lib/components/{layout/FormLayout → FormLayout}/FormLayoutCustomField.scss +4 -4
- package/src/lib/components/{layout/FormLayout → FormLayout}/README.mdx +37 -47
- package/src/lib/components/{layout/FormLayout → FormLayout}/_theme.scss +0 -0
- package/src/lib/components/{layout/FormLayout → FormLayout}/index.js +1 -0
- package/src/lib/components/{layout/Grid → Grid}/Grid.jsx +23 -5
- package/src/lib/components/{layout/Grid → Grid}/Grid.scss +13 -4
- package/src/lib/components/{layout/Grid → Grid}/GridSpan.jsx +10 -3
- package/src/lib/components/{layout/Grid → Grid}/README.mdx +42 -38
- package/src/lib/components/{layout/Grid → Grid}/_theme.scss +1 -2
- package/src/lib/components/{layout/Grid → Grid}/_tools.scss +2 -2
- package/src/lib/components/{layout/Grid → Grid}/helpers/generateResponsiveCustomProperties.js +0 -0
- package/src/lib/components/{layout/Grid → Grid}/index.js +0 -0
- package/src/lib/components/Link/Link.jsx +45 -0
- package/src/lib/components/Link/Link.scss +11 -0
- package/src/lib/components/Link/README.mdx +85 -0
- package/src/lib/components/Link/_theme.scss +4 -0
- package/src/lib/components/Link/index.js +1 -0
- package/src/lib/components/{layout/List → List}/List.jsx +1 -1
- package/src/lib/components/{layout/List → List}/List.scss +2 -2
- package/src/lib/components/{layout/List → List}/ListItem.jsx +1 -1
- package/src/lib/components/{layout/List → List}/README.mdx +3 -3
- package/src/lib/components/{layout/List → List}/_theme.scss +0 -0
- package/src/lib/components/{layout/List → List}/index.js +0 -0
- package/src/lib/components/{layout/Media → Media}/Media.jsx +4 -2
- package/src/lib/components/{layout/Media → Media}/Media.scss +1 -1
- package/src/lib/components/{layout/Media → Media}/MediaBody.jsx +1 -1
- package/src/lib/components/{layout/Media → Media}/MediaObject.jsx +1 -1
- package/src/lib/components/{layout/Media → Media}/README.mdx +2 -2
- package/src/lib/components/{layout/Media → Media}/index.js +0 -0
- package/src/lib/components/{ui/Modal → Modal}/Modal.jsx +28 -27
- package/src/lib/components/{ui/Modal → Modal}/Modal.scss +5 -5
- package/src/lib/components/{ui/Modal → Modal}/README.mdx +42 -42
- package/src/lib/components/{ui/Modal → Modal}/_settings.scss +4 -4
- package/src/lib/components/{ui/Modal → Modal}/_theme.scss +0 -0
- package/src/lib/components/{ui/Modal → Modal}/index.js +0 -0
- package/src/lib/components/{ui/Paper → Paper}/Paper.jsx +8 -1
- package/src/lib/components/{ui/Paper → Paper}/Paper.scss +5 -0
- package/src/lib/components/{ui/Paper → Paper}/README.mdx +15 -3
- package/src/lib/components/{ui/Paper → Paper}/_theme.scss +2 -0
- package/src/lib/components/{ui/Paper → Paper}/index.js +0 -0
- package/src/lib/components/{ui/Radio → Radio}/README.mdx +20 -17
- package/src/lib/components/Radio/Radio.jsx +188 -0
- package/src/lib/components/{ui/Radio → Radio}/Radio.scss +9 -9
- package/src/lib/components/{ui/Radio → Radio}/index.js +0 -0
- package/src/lib/components/{ui/ScrollView → ScrollView}/README.mdx +11 -11
- package/src/lib/components/{ui/ScrollView → ScrollView}/ScrollView.jsx +9 -10
- package/src/lib/components/{ui/ScrollView → ScrollView}/ScrollView.scss +6 -6
- package/src/lib/components/{ui/ScrollView → ScrollView}/_theme.scss +0 -0
- package/src/lib/components/{ui/ScrollView → ScrollView}/index.js +0 -0
- package/src/lib/components/{ui/SelectField → SelectField}/README.mdx +47 -44
- package/src/lib/components/SelectField/SelectField.jsx +219 -0
- package/src/lib/components/{ui/SelectField → SelectField}/SelectField.scss +6 -6
- package/src/lib/components/{ui/SelectField → SelectField}/index.js +0 -0
- package/src/lib/components/{ui/Table → Table}/README.mdx +10 -10
- package/src/lib/components/{ui/Table → Table}/Table.jsx +9 -13
- package/src/lib/components/{ui/Table → Table}/Table.scss +1 -1
- package/src/lib/components/{ui/Table → Table}/_settings.scss +4 -4
- package/src/lib/components/{ui/Table → Table}/index.js +0 -0
- package/src/lib/components/{ui/Tabs → Tabs}/README.mdx +4 -4
- package/src/lib/components/{ui/Tabs → Tabs}/Tabs.jsx +4 -4
- package/src/lib/components/{ui/Tabs → Tabs}/Tabs.scss +1 -1
- package/src/lib/components/{ui/Tabs → Tabs}/TabsItem.jsx +4 -3
- package/src/lib/components/{ui/Tabs → Tabs}/TabsItem.scss +3 -3
- package/src/lib/components/{ui/Tabs → Tabs}/_theme.scss +0 -0
- package/src/lib/components/{ui/Tabs → Tabs}/index.js +0 -0
- package/src/lib/components/{ui/Text → Text}/README.mdx +19 -19
- package/src/lib/components/{ui/Text → Text}/Text.jsx +1 -1
- package/src/lib/components/{ui/Text → Text}/Text.scss +0 -0
- package/src/lib/components/{ui/Text → Text}/helpers/getRootHyphensClassName.js +0 -0
- package/src/lib/components/{ui/Text → Text}/helpers/getRootWordWrappingClassName.js +0 -0
- package/src/lib/components/{ui/Text → Text}/index.js +0 -0
- package/src/lib/components/{ui/TextArea → TextArea}/README.mdx +8 -6
- package/src/lib/components/{ui/TextArea → TextArea}/TextArea.jsx +78 -78
- package/src/lib/components/{ui/TextArea → TextArea}/TextArea.scss +6 -6
- package/src/lib/components/{ui/TextArea → TextArea}/index.js +0 -0
- package/src/lib/components/{ui/TextField → TextField}/README.mdx +7 -6
- package/src/lib/components/{ui/TextField → TextField}/TextField.jsx +20 -22
- package/src/lib/components/{ui/TextField → TextField}/TextField.scss +6 -6
- package/src/lib/components/{ui/TextField → TextField}/index.js +0 -0
- package/src/lib/components/{ui/Toggle → Toggle}/README.mdx +17 -14
- package/src/lib/components/Toggle/Toggle.jsx +163 -0
- package/src/lib/components/{ui/Toggle → Toggle}/Toggle.scss +5 -5
- package/src/lib/components/{ui/Toggle → Toggle}/index.js +0 -0
- package/src/lib/components/{layout/Toolbar → Toolbar}/README.mdx +29 -29
- package/src/lib/components/{layout/Toolbar → Toolbar}/Toolbar.jsx +1 -1
- package/src/lib/components/{layout/Toolbar → Toolbar}/Toolbar.scss +1 -1
- package/src/lib/components/{layout/Toolbar → Toolbar}/ToolbarGroup.jsx +1 -1
- package/src/lib/components/{layout/Toolbar → Toolbar}/ToolbarItem.jsx +1 -1
- package/src/lib/components/{layout/Toolbar → Toolbar}/_theme.scss +0 -0
- package/src/lib/components/{layout/Toolbar → Toolbar}/index.js +0 -0
- package/src/lib/components/{ui/withForwardedRef.jsx → withForwardedRef.jsx} +0 -0
- package/src/lib/helpers/resolveContextOrProp.js +7 -0
- package/src/lib/index.js +34 -35
- package/src/lib/styles/tools/_accessibility.scss +9 -0
- package/src/lib/theme.scss +25 -7
- package/src/lib/components/ui/Button/Button.jsx +0 -191
- package/src/lib/components/ui/Button/_base.scss +0 -154
- package/src/lib/components/ui/Button/helpers/getRootLabelVisibilityClassName.js +0 -11
- package/src/lib/components/ui/ButtonGroup/index.js +0 -1
- package/src/lib/components/ui/CheckboxField/CheckboxField.jsx +0 -173
- package/src/lib/components/ui/FileInputField/FileInputField.jsx +0 -158
- package/src/lib/components/ui/Radio/Radio.jsx +0 -179
- package/src/lib/components/ui/SelectField/SelectField.jsx +0 -214
- package/src/lib/components/ui/Toggle/Toggle.jsx +0 -174
@@ -1,16 +1,18 @@
|
|
1
1
|
import PropTypes from 'prop-types';
|
2
2
|
import React from 'react';
|
3
|
-
import { withProviderContext } from '
|
3
|
+
import { withProviderContext } from '../../provider';
|
4
4
|
import styles from './Paper.scss';
|
5
5
|
|
6
6
|
export const Paper = ({
|
7
7
|
children,
|
8
8
|
id,
|
9
|
+
muted,
|
9
10
|
raised,
|
10
11
|
}) => (
|
11
12
|
<div
|
12
13
|
className={[
|
13
14
|
styles.root,
|
15
|
+
muted ? styles.rootMuted : '',
|
14
16
|
raised ? styles.rootRaised : '',
|
15
17
|
].join(' ')}
|
16
18
|
id={id}
|
@@ -22,6 +24,7 @@ export const Paper = ({
|
|
22
24
|
Paper.defaultProps = {
|
23
25
|
children: null,
|
24
26
|
id: undefined,
|
27
|
+
muted: false,
|
25
28
|
raised: false,
|
26
29
|
};
|
27
30
|
|
@@ -34,6 +37,10 @@ Paper.propTypes = {
|
|
34
37
|
* ID of the root HTML element.
|
35
38
|
*/
|
36
39
|
id: PropTypes.string,
|
40
|
+
/**
|
41
|
+
* Visually suppress Paper.
|
42
|
+
*/
|
43
|
+
muted: PropTypes.bool,
|
37
44
|
/**
|
38
45
|
* Add shadow to pull the Paper above surface.
|
39
46
|
*/
|
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
name: Paper
|
3
|
-
menu: '
|
4
|
-
route: /components/
|
3
|
+
menu: 'Miscellaneous'
|
4
|
+
route: /components/paper
|
5
5
|
---
|
6
6
|
|
7
7
|
# Paper
|
@@ -39,7 +39,7 @@ See [API](#api) for all available options.
|
|
39
39
|
the default appearance to make it stand out on white background.
|
40
40
|
|
41
41
|
- **Paper, or Card?** Paper is a basic surface to put content on. However,
|
42
|
-
there is also the [Card](/components/
|
42
|
+
there is also the [Card](/components/card) component. While Paper is
|
43
43
|
usually used to hold larger content areas like lists, grids, or forms, Card is
|
44
44
|
designed for displaying items. Card also supports more visual options.
|
45
45
|
|
@@ -53,6 +53,16 @@ Add optional shadow to lift the paper above background.
|
|
53
53
|
</Paper>
|
54
54
|
</Playground>
|
55
55
|
|
56
|
+
## Muted Paper
|
57
|
+
|
58
|
+
Dim background and add transparency to visually suppress the Paper.
|
59
|
+
|
60
|
+
<Playground>
|
61
|
+
<Paper muted>
|
62
|
+
Sssh! I'm paper and I'm muted.
|
63
|
+
</Paper>
|
64
|
+
</Playground>
|
65
|
+
|
56
66
|
## API
|
57
67
|
|
58
68
|
<Props table of={Paper} />
|
@@ -66,4 +76,6 @@ Add optional shadow to lift the paper above background.
|
|
66
76
|
| `--rui-Paper__border-color` | Border color |
|
67
77
|
| `--rui-Paper__border-radius` | Corner radius |
|
68
78
|
| `--rui-Paper__background-color` | Paper background color |
|
79
|
+
| `--rui-Paper--muted__background-color` | Background color of muted paper |
|
80
|
+
| `--rui-Paper--muted__opacity` | Opacity of muted paper |
|
69
81
|
| `--rui-Paper--raised__box-shadow` | Box shadow of raised paper |
|
@@ -3,4 +3,6 @@ $border-width: var(--rui-Paper__border-width);
|
|
3
3
|
$border-color: var(--rui-Paper__border-color);
|
4
4
|
$border-radius: var(--rui-Paper__border-radius);
|
5
5
|
$background-color: var(--rui-Paper__background-color);
|
6
|
+
$muted-background-color: var(--rui-Paper--muted__background-color);
|
7
|
+
$muted-opacity: var(--rui-Paper--muted__opacity);
|
6
8
|
$raised-box-shadow: var(--rui-Paper--raised__box-shadow);
|
File without changes
|
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
name: Radio
|
3
|
-
menu: '
|
4
|
-
route: /components/
|
3
|
+
menu: 'Inputs'
|
4
|
+
route: /components/radio
|
5
5
|
---
|
6
6
|
|
7
7
|
# Radio
|
@@ -29,8 +29,8 @@ And use it:
|
|
29
29
|
const [fruit, setFruit] = React.useState('apple');
|
30
30
|
return (
|
31
31
|
<Radio
|
32
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
33
32
|
label="Your favourite fruit"
|
33
|
+
onChange={(e) => setFruit(e.target.value)}
|
34
34
|
options={[
|
35
35
|
{
|
36
36
|
label: 'Apple',
|
@@ -56,13 +56,13 @@ See [API](#api) for all available options.
|
|
56
56
|
## General Guidelines
|
57
57
|
|
58
58
|
- Use Radio for **just a few options**. For larger sets of many options (say 4
|
59
|
-
and more) consider using the [SelectField](/components/
|
59
|
+
and more) consider using the [SelectField](/components/select-field)
|
60
60
|
component. This will help keep your UI clean and uncluttered and prevent your
|
61
61
|
users from being overwhelmed by too many options.
|
62
62
|
|
63
63
|
- **Don't use for boolean** (true/false) selection or to toggle things on and
|
64
|
-
off. [CheckboxField](/components/
|
65
|
-
[Toggle](/components/
|
64
|
+
off. [CheckboxField](/components/checkbox-field) and
|
65
|
+
[Toggle](/components/toggle) are more suitable for such cases.
|
66
66
|
|
67
67
|
- Use **short and descriptive labels**, ideally nouns rather than seemingly
|
68
68
|
polite phrases like _Please select your favourite fruit_. Short labels will
|
@@ -91,9 +91,9 @@ the input.
|
|
91
91
|
const [frequency, setFrequency] = React.useState('weekly');
|
92
92
|
return (
|
93
93
|
<Radio
|
94
|
-
changeHandler={(e) => setFrequency(e.target.value)}
|
95
94
|
isLabelVisible={false}
|
96
95
|
label="Newsletter frequency"
|
96
|
+
onChange={(e) => setFrequency(e.target.value)}
|
97
97
|
options={[
|
98
98
|
{
|
99
99
|
label: 'I want to subscribe to the weekly newsletter',
|
@@ -125,9 +125,9 @@ supports this kind of layout as well.
|
|
125
125
|
const [frequency, setFrequency] = React.useState('weekly');
|
126
126
|
return (
|
127
127
|
<Radio
|
128
|
-
changeHandler={(e) => setFrequency(e.target.value)}
|
129
128
|
label="Newsletter frequency"
|
130
129
|
layout="horizontal"
|
130
|
+
onChange={(e) => setFrequency(e.target.value)}
|
131
131
|
options={[
|
132
132
|
{
|
133
133
|
label: 'I want to subscribe to the weekly newsletter',
|
@@ -158,9 +158,9 @@ filled.
|
|
158
158
|
const [fruit, setFruit] = React.useState('apple');
|
159
159
|
return (
|
160
160
|
<Radio
|
161
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
162
161
|
helpText="What do you prefer?"
|
163
162
|
label="Your favourite fruit"
|
163
|
+
onChange={(e) => setFruit(e.target.value)}
|
164
164
|
options={[
|
165
165
|
{
|
166
166
|
label: 'Apple',
|
@@ -210,8 +210,8 @@ have.
|
|
210
210
|
return (
|
211
211
|
<>
|
212
212
|
<Radio
|
213
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
214
213
|
label="Your favourite fruit"
|
214
|
+
onChange={(e) => setFruit(e.target.value)}
|
215
215
|
options={options}
|
216
216
|
required
|
217
217
|
validationState="valid"
|
@@ -219,8 +219,8 @@ have.
|
|
219
219
|
value={fruit}
|
220
220
|
/>
|
221
221
|
<Radio
|
222
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
223
222
|
label="Your favourite fruit"
|
223
|
+
onChange={(e) => setFruit(e.target.value)}
|
224
224
|
options={options}
|
225
225
|
required
|
226
226
|
validationState="warning"
|
@@ -228,8 +228,8 @@ have.
|
|
228
228
|
value={fruit}
|
229
229
|
/>
|
230
230
|
<Radio
|
231
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
232
231
|
label="Your favourite fruit"
|
232
|
+
onChange={(e) => setFruit(e.target.value)}
|
233
233
|
options={options}
|
234
234
|
required
|
235
235
|
validationState="invalid"
|
@@ -266,15 +266,15 @@ It's possible to disable just some options or the whole set.
|
|
266
266
|
return (
|
267
267
|
<>
|
268
268
|
<Radio
|
269
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
270
269
|
label="Your favourite fruit"
|
270
|
+
onChange={(e) => setFruit(e.target.value)}
|
271
271
|
options={options}
|
272
272
|
value={fruit}
|
273
273
|
/>
|
274
274
|
<Radio
|
275
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
276
275
|
disabled
|
277
276
|
label="Your favourite fruit"
|
277
|
+
onChange={(e) => setFruit(e.target.value)}
|
278
278
|
options={options}
|
279
279
|
value="apple"
|
280
280
|
/>
|
@@ -285,9 +285,10 @@ It's possible to disable just some options or the whole set.
|
|
285
285
|
|
286
286
|
## API
|
287
287
|
|
288
|
-
In addition to the options below, you can
|
289
|
-
interfere with the API, and they will be
|
290
|
-
|
288
|
+
In addition to the options below, you can specify [React synthetic events] or
|
289
|
+
any custom HTML attributes that do not interfere with the API, and they will be
|
290
|
+
passed to the `input` HTML element. This enables making the component
|
291
|
+
interactive and helps improve its accessibility.
|
291
292
|
|
292
293
|
<Props table of={Radio} />
|
293
294
|
|
@@ -300,3 +301,5 @@ options. On top of that, the following options are available for Radio.
|
|
300
301
|
|--------------------------------------------------------------------|------------------------------------------------|
|
301
302
|
| `--rui-FormField--check__input--radio__border-radius` | Input corner radius |
|
302
303
|
| `--rui-FormField--check__input--radio--checked__background-image` | Checked input background image (inline, URL, …) |
|
304
|
+
|
305
|
+
[React synthetic events]: https://reactjs.org/docs/events.html
|
@@ -0,0 +1,188 @@
|
|
1
|
+
import PropTypes from 'prop-types';
|
2
|
+
import React, { useContext } from 'react';
|
3
|
+
import getRootValidationStateClassName from '../../helpers/getRootValidationStateClassName';
|
4
|
+
import { resolveContextOrProp } from '../../helpers/resolveContextOrProp';
|
5
|
+
import { withProviderContext } from '../../provider';
|
6
|
+
import transferProps from '../../utils/transferProps';
|
7
|
+
import { FormLayoutContext } from '../FormLayout';
|
8
|
+
import styles from './Radio.scss';
|
9
|
+
|
10
|
+
export const Radio = ({
|
11
|
+
disabled,
|
12
|
+
helpText,
|
13
|
+
id,
|
14
|
+
isLabelVisible,
|
15
|
+
label,
|
16
|
+
layout,
|
17
|
+
options,
|
18
|
+
required,
|
19
|
+
validationState,
|
20
|
+
validationText,
|
21
|
+
value,
|
22
|
+
...restProps
|
23
|
+
}) => {
|
24
|
+
const context = useContext(FormLayoutContext);
|
25
|
+
|
26
|
+
return (
|
27
|
+
<div
|
28
|
+
className={[
|
29
|
+
styles.root,
|
30
|
+
context ? styles.isRootInFormLayout : '',
|
31
|
+
resolveContextOrProp(context && context.layout, layout) === 'horizontal'
|
32
|
+
? styles.rootLayoutHorizontal
|
33
|
+
: styles.rootLayoutVertical,
|
34
|
+
disabled ? styles.isRootDisabled : '',
|
35
|
+
required ? styles.isRootRequired : '',
|
36
|
+
getRootValidationStateClassName(validationState, styles),
|
37
|
+
].join(' ')}
|
38
|
+
id={id}
|
39
|
+
>
|
40
|
+
<div
|
41
|
+
className={[
|
42
|
+
styles.label,
|
43
|
+
isLabelVisible ? '' : styles.isLabelHidden,
|
44
|
+
].join(' ')}
|
45
|
+
id={id && `${id}__labelText`}
|
46
|
+
>
|
47
|
+
{label}
|
48
|
+
</div>
|
49
|
+
<div className={styles.field}>
|
50
|
+
<ul className={styles.list}>
|
51
|
+
{
|
52
|
+
options.map((option) => (
|
53
|
+
<li key={option.value}>
|
54
|
+
<label
|
55
|
+
className={styles.option}
|
56
|
+
htmlFor={id && `${id}__item__${option.value}`}
|
57
|
+
id={id && `${id}__item__${option.value}__label`}
|
58
|
+
>
|
59
|
+
<input
|
60
|
+
{...transferProps(restProps)}
|
61
|
+
className={styles.input}
|
62
|
+
checked={restProps.onChange
|
63
|
+
? (value === option.value) || false
|
64
|
+
: undefined}
|
65
|
+
disabled={disabled || option.disabled}
|
66
|
+
id={id && `${id}__item__${option.value}`}
|
67
|
+
name={id}
|
68
|
+
type="radio"
|
69
|
+
value={option.value}
|
70
|
+
/>
|
71
|
+
<span
|
72
|
+
className={styles.optionLabel}
|
73
|
+
id={id && `${id}__item__${option.value}__labelText`}
|
74
|
+
>
|
75
|
+
{ option.label }
|
76
|
+
</span>
|
77
|
+
</label>
|
78
|
+
</li>
|
79
|
+
))
|
80
|
+
}
|
81
|
+
</ul>
|
82
|
+
{helpText && (
|
83
|
+
<div
|
84
|
+
className={styles.helpText}
|
85
|
+
id={id && `${id}__helpText`}
|
86
|
+
>
|
87
|
+
{helpText}
|
88
|
+
</div>
|
89
|
+
)}
|
90
|
+
{validationText && (
|
91
|
+
<div
|
92
|
+
className={styles.validationText}
|
93
|
+
id={id && `${id}__validationText`}
|
94
|
+
>
|
95
|
+
{validationText}
|
96
|
+
</div>
|
97
|
+
)}
|
98
|
+
</div>
|
99
|
+
</div>
|
100
|
+
);
|
101
|
+
};
|
102
|
+
|
103
|
+
Radio.defaultProps = {
|
104
|
+
disabled: false,
|
105
|
+
helpText: null,
|
106
|
+
id: undefined,
|
107
|
+
isLabelVisible: true,
|
108
|
+
layout: 'vertical',
|
109
|
+
required: false,
|
110
|
+
validationState: null,
|
111
|
+
validationText: null,
|
112
|
+
value: undefined,
|
113
|
+
};
|
114
|
+
|
115
|
+
Radio.propTypes = {
|
116
|
+
/**
|
117
|
+
* If `true`, the input will be disabled.
|
118
|
+
*/
|
119
|
+
disabled: PropTypes.bool,
|
120
|
+
/**
|
121
|
+
* Optional help text.
|
122
|
+
*/
|
123
|
+
helpText: PropTypes.node,
|
124
|
+
/**
|
125
|
+
* ID of the root HTML element.
|
126
|
+
*
|
127
|
+
* Also serves as base for ids of nested elements:
|
128
|
+
* * `<ID>__labelText`
|
129
|
+
* * `<ID>__helpText`
|
130
|
+
* * `<ID>__validationText`
|
131
|
+
*
|
132
|
+
* and of individual options (`<input>`):
|
133
|
+
* * `<ID>__item__<VALUE>`
|
134
|
+
* * `<ID>__item__<VALUE>__label`
|
135
|
+
* * `<ID>__item__<VALUE>__labelText`
|
136
|
+
*/
|
137
|
+
id: PropTypes.string,
|
138
|
+
/**
|
139
|
+
* If `false`, the label will be visually hidden (but remains accessible by assistive
|
140
|
+
* technologies).
|
141
|
+
*/
|
142
|
+
isLabelVisible: PropTypes.bool,
|
143
|
+
/**
|
144
|
+
* Label of the group of options.
|
145
|
+
*/
|
146
|
+
label: PropTypes.string.isRequired,
|
147
|
+
/**
|
148
|
+
* Layout of the field.
|
149
|
+
*
|
150
|
+
* Ignored if the component is rendered within `FormLayout` component
|
151
|
+
* as the value is inherited in such case.
|
152
|
+
*/
|
153
|
+
layout: PropTypes.oneOf(['horizontal', 'vertical']),
|
154
|
+
/**
|
155
|
+
* Set of options to be chosen from.
|
156
|
+
*/
|
157
|
+
options: PropTypes.arrayOf(PropTypes.shape({
|
158
|
+
disabled: PropTypes.bool,
|
159
|
+
label: PropTypes.string.isRequired,
|
160
|
+
value: PropTypes.oneOfType([
|
161
|
+
PropTypes.string,
|
162
|
+
PropTypes.number,
|
163
|
+
]),
|
164
|
+
})).isRequired,
|
165
|
+
/**
|
166
|
+
* If `true`, the input will be required.
|
167
|
+
*/
|
168
|
+
required: PropTypes.bool,
|
169
|
+
/**
|
170
|
+
* Alter the field to provide feedback based on validation result.
|
171
|
+
*/
|
172
|
+
validationState: PropTypes.oneOf(['invalid', 'valid', 'warning']),
|
173
|
+
/**
|
174
|
+
* Validation message to be displayed.
|
175
|
+
*/
|
176
|
+
validationText: PropTypes.node,
|
177
|
+
/**
|
178
|
+
* Value of the input.
|
179
|
+
*/
|
180
|
+
value: PropTypes.oneOfType([
|
181
|
+
PropTypes.string,
|
182
|
+
PropTypes.number,
|
183
|
+
]),
|
184
|
+
};
|
185
|
+
|
186
|
+
export const RadioWithContext = withProviderContext(Radio, 'Radio');
|
187
|
+
|
188
|
+
export default RadioWithContext;
|
@@ -1,12 +1,12 @@
|
|
1
|
-
@use '
|
2
|
-
@use '
|
3
|
-
@use '
|
4
|
-
@use '
|
5
|
-
@use '
|
6
|
-
@use '
|
7
|
-
@use '
|
8
|
-
@use '
|
9
|
-
@use '
|
1
|
+
@use '../../styles/tools/form-fields/box-field-elements';
|
2
|
+
@use '../../styles/tools/form-fields/box-field-layout';
|
3
|
+
@use '../../styles/tools/form-fields/foundation';
|
4
|
+
@use '../../styles/tools/form-fields/inline-field-elements';
|
5
|
+
@use '../../styles/tools/form-fields/inline-field-layout';
|
6
|
+
@use '../../styles/tools/form-fields/variants';
|
7
|
+
@use '../../styles/tools/accessibility';
|
8
|
+
@use '../../styles/tools/reset';
|
9
|
+
@use '../../styles/tools/spacing';
|
10
10
|
|
11
11
|
// Foundation
|
12
12
|
.root {
|
File without changes
|
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
name: ScrollView
|
3
|
-
menu: '
|
4
|
-
route: /components/
|
3
|
+
menu: 'Miscellaneous'
|
4
|
+
route: /components/scroll-view
|
5
5
|
---
|
6
6
|
|
7
7
|
# ScrollView
|
@@ -12,11 +12,11 @@ import {
|
|
12
12
|
Playground,
|
13
13
|
Props,
|
14
14
|
} from 'docz'
|
15
|
-
import { Placeholder } from '
|
15
|
+
import { Placeholder } from '../../../docs/_components/Placeholder/Placeholder'
|
16
16
|
import Button from '../Button'
|
17
17
|
import Radio from '../Radio'
|
18
|
-
import { Toolbar } from '
|
19
|
-
import { ToolbarItem } from '
|
18
|
+
import { Toolbar } from '../Toolbar/Toolbar'
|
19
|
+
import { ToolbarItem } from '../Toolbar/ToolbarItem'
|
20
20
|
import {
|
21
21
|
ScrollViewWithContext as ScrollView,
|
22
22
|
ScrollView as ParsableScrollView,
|
@@ -219,7 +219,8 @@ property defined because it detects changes of these keys.
|
|
219
219
|
<Toolbar>
|
220
220
|
<ToolbarItem>
|
221
221
|
<Radio
|
222
|
-
|
222
|
+
label="Direction:"
|
223
|
+
onChange={(e) => setDirection(e.target.value)}
|
223
224
|
options={[
|
224
225
|
{
|
225
226
|
label: 'Vertical',
|
@@ -230,13 +231,13 @@ property defined because it detects changes of these keys.
|
|
230
231
|
value: 'horizontal',
|
231
232
|
},
|
232
233
|
]}
|
233
|
-
label="Direction:"
|
234
234
|
value={direction}
|
235
235
|
/>
|
236
236
|
</ToolbarItem>
|
237
237
|
<ToolbarItem>
|
238
238
|
<Radio
|
239
|
-
|
239
|
+
label="Autoscroll:"
|
240
|
+
onChange={(e) => setAutoScroll(e.target.value)}
|
240
241
|
options={[
|
241
242
|
{
|
242
243
|
label: 'Always',
|
@@ -247,14 +248,13 @@ property defined because it detects changes of these keys.
|
|
247
248
|
value: 'detectEnd',
|
248
249
|
},
|
249
250
|
]}
|
250
|
-
label="Autoscroll:"
|
251
251
|
value={autoScroll}
|
252
252
|
/>
|
253
253
|
</ToolbarItem>
|
254
254
|
<ToolbarItem>
|
255
255
|
<Button
|
256
256
|
label="Add text"
|
257
|
-
|
257
|
+
onClick={
|
258
258
|
() => setScrollViewContent(
|
259
259
|
`${scrollViewContent} ${generateRandomString()}`,
|
260
260
|
)
|
@@ -358,7 +358,7 @@ Aside from setting a custom shadow color and size, you can entirely customize
|
|
358
358
|
the scrolling shadows with `background` or `box-shadow` CSS properties.
|
359
359
|
|
360
360
|
The following example demonstrates exactly the same custom scrolling shadows as
|
361
|
-
we use in the [Modal](/components/
|
361
|
+
we use in the [Modal](/components/modal#scrolling-long-content) component.
|
362
362
|
|
363
363
|
<Playground>
|
364
364
|
<Placeholder height="200px">
|
@@ -5,10 +5,10 @@ import React, {
|
|
5
5
|
useRef,
|
6
6
|
useState,
|
7
7
|
} from 'react';
|
8
|
-
import { useLoadResize } from '
|
9
|
-
import { useScrollPosition } from '
|
10
|
-
import { withProviderContext } from '
|
11
|
-
import { getElementsPositionDifference } from '
|
8
|
+
import { useLoadResize } from '../../hooks/useLoadResizeHook';
|
9
|
+
import { useScrollPosition } from '../../hooks/useScrollPositionHook';
|
10
|
+
import { withProviderContext } from '../../provider';
|
11
|
+
import { getElementsPositionDifference } from '../../services/elementPositionService';
|
12
12
|
import styles from './ScrollView.scss';
|
13
13
|
|
14
14
|
// Function `getElementsPositionDifference` sometimes returns floating point values that results
|
@@ -315,10 +315,7 @@ ScrollView.propTypes = {
|
|
315
315
|
/**
|
316
316
|
* Content to be scrollable.
|
317
317
|
*/
|
318
|
-
children: PropTypes.
|
319
|
-
PropTypes.arrayOf(PropTypes.node),
|
320
|
-
PropTypes.node,
|
321
|
-
]).isRequired,
|
318
|
+
children: PropTypes.node.isRequired,
|
322
319
|
/**
|
323
320
|
* Custom CSS to replace the default end scrolling shadow.
|
324
321
|
*/
|
@@ -350,8 +347,10 @@ ScrollView.propTypes = {
|
|
350
347
|
*/
|
351
348
|
direction: PropTypes.oneOf(['horizontal', 'vertical']),
|
352
349
|
/**
|
353
|
-
* ID of the root HTML element. It also serves as
|
354
|
-
* `<ID>__content
|
350
|
+
* ID of the root HTML element. It also serves as base for nested elements:
|
351
|
+
* * `<ID>__content`
|
352
|
+
* * `<ID>__arrowPrevButton`
|
353
|
+
* * `<ID>__arrowNextButton`
|
355
354
|
*/
|
356
355
|
id: PropTypes.string,
|
357
356
|
/**
|
@@ -21,12 +21,12 @@
|
|
21
21
|
// 7. Hide content overflowing in the other direction because scrollbars would be unreachable under
|
22
22
|
// scrolling shadows.
|
23
23
|
|
24
|
-
@use '
|
25
|
-
@use '
|
26
|
-
@use '
|
27
|
-
@use '
|
28
|
-
@use '
|
29
|
-
@use '
|
24
|
+
@use '../../styles/tools/accessibility';
|
25
|
+
@use '../../styles/tools/caret';
|
26
|
+
@use '../../styles/tools/reset';
|
27
|
+
@use '../../styles/tools/scrollbar';
|
28
|
+
@use '../../styles/tools/spacing';
|
29
|
+
@use '../../styles/tools/transition';
|
30
30
|
@use 'theme';
|
31
31
|
|
32
32
|
$_arrow-inner-spacing: spacing.of(2);
|
File without changes
|
File without changes
|