@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
@@ -0,0 +1,85 @@
|
|
1
|
+
---
|
2
|
+
name: Link
|
3
|
+
menu: 'Actions'
|
4
|
+
route: /components/link
|
5
|
+
---
|
6
|
+
|
7
|
+
# Link
|
8
|
+
|
9
|
+
import {
|
10
|
+
Playground,
|
11
|
+
Props,
|
12
|
+
} from 'docz'
|
13
|
+
import Placeholder from '../../../docs/_components/Placeholder'
|
14
|
+
import { Link } from './Link'
|
15
|
+
|
16
|
+
Link allow users to follow navigation.
|
17
|
+
|
18
|
+
## Basic Usage
|
19
|
+
|
20
|
+
To implement the Link component, you need to import it first:
|
21
|
+
|
22
|
+
```js
|
23
|
+
import { Link } from '@react-ui-org/react-ui';
|
24
|
+
```
|
25
|
+
|
26
|
+
And use it:
|
27
|
+
|
28
|
+
<Playground>
|
29
|
+
<Link href="/contribute/guidelines">How can I contribute to React UI?</Link>
|
30
|
+
</Playground>
|
31
|
+
|
32
|
+
See [API](#api) for all available options.
|
33
|
+
|
34
|
+
## General Guidelines
|
35
|
+
|
36
|
+
**Avoid using links for actions**, use a [Button](/components/button)
|
37
|
+
instead. This is because users expect navigation to happen when clicking on
|
38
|
+
something what looks like a link.
|
39
|
+
|
40
|
+
## Block-Level Content
|
41
|
+
|
42
|
+
Besides text, link can contain block-level elements too.
|
43
|
+
|
44
|
+
<Playground>
|
45
|
+
<Link href="/contribute/guidelines">
|
46
|
+
<Placeholder>Block-level element wrapped with link</Placeholder>
|
47
|
+
</Link>
|
48
|
+
</Playground>
|
49
|
+
|
50
|
+
## Custom Routing
|
51
|
+
|
52
|
+
It's common to use custom function for routing within SPAs. Use the
|
53
|
+
`onClick` option to provide such function.
|
54
|
+
|
55
|
+
<Playground>
|
56
|
+
<Link
|
57
|
+
href="/contribute/guidelines"
|
58
|
+
onClick={(event) => {
|
59
|
+
event.preventDefault();
|
60
|
+
window.location = event.currentTarget.getAttribute('href');
|
61
|
+
}}
|
62
|
+
>
|
63
|
+
This link is controlled by custom function
|
64
|
+
</Link>
|
65
|
+
</Playground>
|
66
|
+
|
67
|
+
## API
|
68
|
+
|
69
|
+
In addition to the options below, you can specify [React synthetic events] or
|
70
|
+
any custom HTML attributes that do not interfere with the API, and they will be
|
71
|
+
passed to the `a` HTML element. This enables making the component interactive
|
72
|
+
and helps improve its accessibility.
|
73
|
+
|
74
|
+
<Props table of={Link} />
|
75
|
+
|
76
|
+
## Theming
|
77
|
+
|
78
|
+
| Custom Property | Description |
|
79
|
+
|--------------------------------------|----------------------------------------------|
|
80
|
+
| `--rui-Link__color` | Text color |
|
81
|
+
| `--rui-Link__text-decoration` | Text decoration, e.g. underline |
|
82
|
+
| `--rui-Link--hover__color` | Text color on hover |
|
83
|
+
| `--rui-Link--hover__text-decoration` | Text decoration on hover |
|
84
|
+
|
85
|
+
[React synthetic events]: https://reactjs.org/docs/events.html
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './Link';
|
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
name: List
|
3
3
|
menu: 'Layouts'
|
4
|
-
route: /components/
|
4
|
+
route: /components/list
|
5
5
|
---
|
6
6
|
|
7
7
|
# List
|
@@ -10,7 +10,7 @@ import {
|
|
10
10
|
Playground,
|
11
11
|
Props,
|
12
12
|
} from 'docz'
|
13
|
-
import { Placeholder } from '
|
13
|
+
import { Placeholder } from '../../../docs/_components/Placeholder/Placeholder'
|
14
14
|
import { List } from './List'
|
15
15
|
import { ListItem } from './ListItem'
|
16
16
|
|
@@ -49,7 +49,7 @@ See [API](#api) for all available options.
|
|
49
49
|
**not** try to put any custom HTML or React components directly into the
|
50
50
|
List layout without wrapping it with the ListItem first.
|
51
51
|
|
52
|
-
- For forms, use rather the [FormLayout](/components/
|
52
|
+
- For forms, use rather the [FormLayout](/components/form-layout)
|
53
53
|
component which is designed specifically for that purpose.
|
54
54
|
|
55
55
|
## List Alignment
|
File without changes
|
File without changes
|
@@ -1,6 +1,6 @@
|
|
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 './Media.scss';
|
5
5
|
|
6
6
|
export const Media = (props) => {
|
@@ -17,7 +17,9 @@ export const Media = (props) => {
|
|
17
17
|
|
18
18
|
Media.propTypes = {
|
19
19
|
/**
|
20
|
-
*
|
20
|
+
* Nested elements. Supported types are:
|
21
|
+
* * `MediaBody`
|
22
|
+
* * `MediaObject`
|
21
23
|
*/
|
22
24
|
children: PropTypes.node.isRequired,
|
23
25
|
};
|
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
name: Media
|
3
3
|
menu: 'Layouts'
|
4
|
-
route: /components/
|
4
|
+
route: /components/media
|
5
5
|
---
|
6
6
|
|
7
7
|
# Media
|
@@ -10,7 +10,7 @@ import {
|
|
10
10
|
Playground,
|
11
11
|
Props,
|
12
12
|
} from 'docz'
|
13
|
-
import { Placeholder } from '
|
13
|
+
import { Placeholder } from '../../../docs/_components/Placeholder/Placeholder'
|
14
14
|
import { Media } from './Media'
|
15
15
|
import { MediaBody } from './MediaBody'
|
16
16
|
import { MediaObject } from './MediaObject'
|
File without changes
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import PropTypes from 'prop-types';
|
2
2
|
import React from 'react';
|
3
3
|
import { createPortal } from 'react-dom';
|
4
|
-
import transferProps from '
|
5
|
-
import { withProviderContext } from '
|
4
|
+
import transferProps from '../../utils/transferProps';
|
5
|
+
import { withProviderContext } from '../../provider';
|
6
6
|
import {
|
7
7
|
Toolbar,
|
8
8
|
ToolbarItem,
|
9
|
-
} from '
|
9
|
+
} from '../Toolbar';
|
10
10
|
import Button from '../Button';
|
11
11
|
import ScrollView from '../ScrollView';
|
12
12
|
import styles from './Modal.scss';
|
@@ -54,18 +54,18 @@ export class Modal extends React.Component {
|
|
54
54
|
keyPressHandler(e) {
|
55
55
|
const {
|
56
56
|
actions,
|
57
|
-
|
57
|
+
onClose,
|
58
58
|
} = this.props;
|
59
59
|
|
60
|
-
if (e.keyCode === 27 &&
|
61
|
-
|
60
|
+
if (e.keyCode === 27 && onClose) {
|
61
|
+
onClose();
|
62
62
|
}
|
63
63
|
|
64
64
|
if (e.keyCode === 13 && e.target.nodeName !== 'BUTTON') {
|
65
65
|
const submitAction = actions.find((action) => action.type === 'submit');
|
66
66
|
|
67
67
|
if (submitAction && !submitAction.disabled) {
|
68
|
-
submitAction.
|
68
|
+
submitAction.onClick(e);
|
69
69
|
}
|
70
70
|
}
|
71
71
|
}
|
@@ -74,8 +74,8 @@ export class Modal extends React.Component {
|
|
74
74
|
const {
|
75
75
|
actions,
|
76
76
|
children,
|
77
|
-
closeHandler,
|
78
77
|
id,
|
78
|
+
onClose,
|
79
79
|
position,
|
80
80
|
scrollView,
|
81
81
|
size,
|
@@ -147,8 +147,8 @@ export class Modal extends React.Component {
|
|
147
147
|
className={styles.backdrop}
|
148
148
|
id={id}
|
149
149
|
onClick={(e) => {
|
150
|
-
if (
|
151
|
-
|
150
|
+
if (onClose) {
|
151
|
+
onClose(e);
|
152
152
|
}
|
153
153
|
}}
|
154
154
|
role="presentation"
|
@@ -171,11 +171,11 @@ export class Modal extends React.Component {
|
|
171
171
|
>
|
172
172
|
{title}
|
173
173
|
</h3>
|
174
|
-
{
|
174
|
+
{onClose && (
|
175
175
|
<button
|
176
176
|
type="button"
|
177
177
|
className={styles.close}
|
178
|
-
onClick={
|
178
|
+
onClick={onClose}
|
179
179
|
title={translations.close}
|
180
180
|
{...(id && { id: `${id}__closeModalHeaderButton` })}
|
181
181
|
>
|
@@ -184,29 +184,29 @@ export class Modal extends React.Component {
|
|
184
184
|
)}
|
185
185
|
</div>
|
186
186
|
{modalBody()}
|
187
|
-
{(actions.length ||
|
187
|
+
{(actions.length || onClose) && (
|
188
188
|
<div className={styles.footer}>
|
189
189
|
<Toolbar justify="center" dense>
|
190
190
|
{actions.map((action) => (
|
191
191
|
<ToolbarItem key={action.label}>
|
192
192
|
<Button
|
193
193
|
{...transferProps(action)}
|
194
|
-
clickHandler={action.clickHandler}
|
195
194
|
color={action.color}
|
196
195
|
disabled={action.disabled}
|
196
|
+
feedbackIcon={action.feedbackIcon}
|
197
|
+
forwardedRef={this.submitButtonRef}
|
197
198
|
id={action.id || undefined}
|
198
199
|
label={action.label}
|
199
|
-
|
200
|
-
forwardedRef={this.submitButtonRef}
|
200
|
+
onClick={action.onClick}
|
201
201
|
type="button"
|
202
202
|
/>
|
203
203
|
</ToolbarItem>
|
204
204
|
))}
|
205
|
-
{
|
205
|
+
{onClose && (
|
206
206
|
<ToolbarItem>
|
207
207
|
<Button
|
208
|
-
clickHandler={closeHandler}
|
209
208
|
label={translations.close}
|
209
|
+
onClick={onClose}
|
210
210
|
priority="flat"
|
211
211
|
{...(id && { id: `${id}__closeModalFooterButton` })}
|
212
212
|
/>
|
@@ -234,8 +234,8 @@ export class Modal extends React.Component {
|
|
234
234
|
Modal.defaultProps = {
|
235
235
|
actions: [],
|
236
236
|
autoFocus: true,
|
237
|
-
closeHandler: null,
|
238
237
|
id: undefined,
|
238
|
+
onClose: null,
|
239
239
|
portalId: null,
|
240
240
|
position: 'center',
|
241
241
|
scrollView: (<ScrollView
|
@@ -251,12 +251,12 @@ Modal.propTypes = {
|
|
251
251
|
* Actions to be rendered in modal footer.
|
252
252
|
*/
|
253
253
|
actions: PropTypes.arrayOf(PropTypes.shape({
|
254
|
-
clickHandler: PropTypes.func.isRequired,
|
255
254
|
color: PropTypes.oneOf(['primary', 'secondary', 'success', 'warning', 'danger', 'help', 'info', 'note', 'light', 'dark']),
|
256
255
|
disabled: PropTypes.bool,
|
256
|
+
feedbackIcon: PropTypes.node,
|
257
257
|
id: PropTypes.string,
|
258
258
|
label: PropTypes.string.isRequired,
|
259
|
-
|
259
|
+
onClick: PropTypes.func.isRequired,
|
260
260
|
})),
|
261
261
|
/**
|
262
262
|
* If `true`, focus the first action in the footer when the modal is opened.
|
@@ -267,15 +267,16 @@ Modal.propTypes = {
|
|
267
267
|
*/
|
268
268
|
children: PropTypes.node.isRequired,
|
269
269
|
/**
|
270
|
-
*
|
270
|
+
* ID of the root HTML element. It also serves as a base for nested elements:
|
271
|
+
* * `<ID>__content`
|
272
|
+
* * `<ID>__closeModalHeaderButton`
|
273
|
+
* * `<ID>__closeModalFooterButton`
|
271
274
|
*/
|
272
|
-
|
275
|
+
id: PropTypes.string,
|
273
276
|
/**
|
274
|
-
*
|
275
|
-
* the modal and for the close buttons: `<ID>__content`, `<ID>__closeModalHeaderButton`,
|
276
|
-
* `<ID>__closeModalFooterButton`.
|
277
|
+
* If a function is provided, the close buttons will be displayed.
|
277
278
|
*/
|
278
|
-
|
279
|
+
onClose: PropTypes.func,
|
279
280
|
/**
|
280
281
|
* If set, the modal is rendered in the React Portal with that ID.
|
281
282
|
*/
|
@@ -1,9 +1,9 @@
|
|
1
1
|
@use 'sass:map';
|
2
|
-
@use '
|
3
|
-
@use '
|
4
|
-
@use '
|
5
|
-
@use '
|
6
|
-
@use '
|
2
|
+
@use '../../styles/theme/typography';
|
3
|
+
@use '../../styles/tools/accessibility';
|
4
|
+
@use '../../styles/tools/breakpoint';
|
5
|
+
@use '../../styles/tools/reset';
|
6
|
+
@use '../../styles/tools/spacing';
|
7
7
|
@use 'settings';
|
8
8
|
@use 'theme';
|
9
9
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
name: Modal
|
3
|
-
menu: '
|
4
|
-
route: /components/
|
3
|
+
menu: 'Miscellaneous'
|
4
|
+
route: /components/modal
|
5
5
|
---
|
6
6
|
|
7
7
|
# Modal
|
@@ -34,20 +34,20 @@ And use it:
|
|
34
34
|
return (
|
35
35
|
<>
|
36
36
|
<Button
|
37
|
-
clickHandler={() => setModalOpen(true)}
|
38
37
|
label="Launch modal"
|
38
|
+
onClick={() => setModalOpen(true)}
|
39
39
|
priority="outline"
|
40
40
|
/>
|
41
41
|
<div>
|
42
42
|
{modalOpen && (
|
43
43
|
<Modal
|
44
|
-
title="Warning"
|
45
44
|
actions={[{
|
46
|
-
clickHandler: () => setModalOpen(false),
|
47
|
-
label: 'Delete',
|
48
45
|
color: 'danger',
|
46
|
+
label: 'Delete',
|
47
|
+
onClick: () => setModalOpen(false),
|
49
48
|
}]}
|
50
|
-
|
49
|
+
onClose={() => setModalOpen(false)}
|
50
|
+
title="Warning"
|
51
51
|
>
|
52
52
|
<p>
|
53
53
|
Do you really want to delete the user <code>admin</code>?
|
@@ -96,48 +96,48 @@ Modals of any size automatically shrink when they cannot fit the screen width.
|
|
96
96
|
return (
|
97
97
|
<>
|
98
98
|
<Button
|
99
|
-
|
99
|
+
label="Launch small modal"
|
100
|
+
onClick={() => {
|
100
101
|
setModalSize('small');
|
101
102
|
setModalOpen(true);
|
102
103
|
}}
|
103
|
-
label="Launch small modal"
|
104
104
|
priority="outline"
|
105
105
|
/>
|
106
106
|
<Button
|
107
|
-
|
107
|
+
label="Launch medium modal"
|
108
|
+
onClick={() => {
|
108
109
|
setModalSize('medium');
|
109
110
|
setModalOpen(true);
|
110
111
|
}}
|
111
|
-
label="Launch medium modal"
|
112
112
|
priority="outline"
|
113
113
|
/>
|
114
114
|
<Button
|
115
|
-
|
115
|
+
label="Launch large modal"
|
116
|
+
onClick={() => {
|
116
117
|
setModalSize('large');
|
117
118
|
setModalOpen(true);
|
118
119
|
}}
|
119
|
-
label="Launch large modal"
|
120
120
|
priority="outline"
|
121
121
|
/>
|
122
122
|
<Button
|
123
|
-
|
123
|
+
label="Launch fullscreen modal"
|
124
|
+
onClick={() => {
|
124
125
|
setModalSize('fullscreen');
|
125
126
|
setModalOpen(true);
|
126
127
|
}}
|
127
|
-
label="Launch fullscreen modal"
|
128
128
|
priority="outline"
|
129
129
|
/>
|
130
130
|
<div>
|
131
131
|
{modalOpen && (
|
132
132
|
<Modal
|
133
|
-
title="Delete the user?"
|
134
133
|
actions={[{
|
135
|
-
clickHandler: () => setModalOpen(false),
|
136
|
-
label: 'Delete',
|
137
134
|
color: 'danger',
|
135
|
+
label: 'Delete',
|
136
|
+
onClick: () => setModalOpen(false),
|
138
137
|
}]}
|
139
|
-
|
138
|
+
onClose={() => setModalOpen(false)}
|
140
139
|
size={modalSize}
|
140
|
+
title="Delete the user?"
|
141
141
|
>
|
142
142
|
<p>
|
143
143
|
Do you really want to delete the user <code>admin</code>?
|
@@ -155,7 +155,7 @@ On top of that, the modal is able to adjust to the width of its content.
|
|
155
155
|
|
156
156
|
👉 Please note the auto width may not function correctly in combination with
|
157
157
|
other auto layout mechanisms, e.g. the auto-width
|
158
|
-
[FormLayout](/components/
|
158
|
+
[FormLayout](/components/form-layout#label-width). It's just too much
|
159
159
|
magic that doesn't work together yet 🎩.
|
160
160
|
|
161
161
|
<Playground>
|
@@ -164,21 +164,21 @@ magic that doesn't work together yet 🎩.
|
|
164
164
|
return (
|
165
165
|
<>
|
166
166
|
<Button
|
167
|
-
clickHandler={() => setModalOpen(true)}
|
168
167
|
label="Launch auto-width modal"
|
168
|
+
onClick={() => setModalOpen(true)}
|
169
169
|
priority="outline"
|
170
170
|
/>
|
171
171
|
<div>
|
172
172
|
{modalOpen && (
|
173
173
|
<Modal
|
174
|
-
title="Delete the user?"
|
175
174
|
actions={[{
|
176
|
-
clickHandler: () => setModalOpen(false),
|
177
|
-
label: 'Delete',
|
178
175
|
color: 'danger',
|
176
|
+
label: 'Delete',
|
177
|
+
onClick: () => setModalOpen(false),
|
179
178
|
}]}
|
180
|
-
|
179
|
+
onClose={() => setModalOpen(false)}
|
181
180
|
size="auto"
|
181
|
+
title="Delete the user?"
|
182
182
|
>
|
183
183
|
<p>
|
184
184
|
Do you really want to delete the user <code>admin</code>?
|
@@ -203,32 +203,32 @@ Modal can be aligned either to top or center of the screen.
|
|
203
203
|
return (
|
204
204
|
<>
|
205
205
|
<Button
|
206
|
-
|
206
|
+
label="Launch modal at center"
|
207
|
+
onClick={() => {
|
207
208
|
setModalPosition('center');
|
208
209
|
setModalOpen(true);
|
209
210
|
}}
|
210
|
-
label="Launch modal at center"
|
211
211
|
priority="outline"
|
212
212
|
/>
|
213
213
|
<Button
|
214
|
-
|
214
|
+
label="Launch modal at top"
|
215
|
+
onClick={() => {
|
215
216
|
setModalPosition('top');
|
216
217
|
setModalOpen(true);
|
217
218
|
}}
|
218
|
-
label="Launch modal at top"
|
219
219
|
priority="outline"
|
220
220
|
/>
|
221
221
|
<div>
|
222
222
|
{modalOpen && (
|
223
223
|
<Modal
|
224
|
-
title="Delete the user?"
|
225
224
|
actions={[{
|
226
|
-
|
225
|
+
onClick: () => setModalOpen(false),
|
227
226
|
label: 'Delete',
|
228
227
|
color: 'danger',
|
229
228
|
}]}
|
230
|
-
|
229
|
+
onClose={() => setModalOpen(false)}
|
231
230
|
position={modalPosition}
|
231
|
+
title="Delete the user?"
|
232
232
|
>
|
233
233
|
<p>
|
234
234
|
Do you really want to delete the user <code>admin</code>?
|
@@ -248,7 +248,7 @@ When modals become too long for the user's viewport or device, they scroll
|
|
248
248
|
independent of the page itself.
|
249
249
|
|
250
250
|
The inner implementation of body scrolling uses a partially
|
251
|
-
[customizable](#api) instance of the [ScrollView](/components/
|
251
|
+
[customizable](#api) instance of the [ScrollView](/components/scroll-view)
|
252
252
|
component.
|
253
253
|
|
254
254
|
<Playground>
|
@@ -258,33 +258,33 @@ component.
|
|
258
258
|
return (
|
259
259
|
<>
|
260
260
|
<Button
|
261
|
-
|
261
|
+
label="Launch modal with scrolling body"
|
262
|
+
onClick={() => {
|
262
263
|
setModalScrollView(true);
|
263
264
|
setModalOpen(true);
|
264
265
|
}}
|
265
|
-
label="Launch modal with scrolling body"
|
266
266
|
priority="outline"
|
267
267
|
/>
|
268
268
|
<Button
|
269
|
-
|
269
|
+
label="Launch scrolling modal"
|
270
|
+
onClick={() => {
|
270
271
|
setModalScrollView(false);
|
271
272
|
setModalOpen(true);
|
272
273
|
}}
|
273
|
-
label="Launch scrolling modal"
|
274
274
|
priority="outline"
|
275
275
|
/>
|
276
276
|
<div>
|
277
277
|
{modalOpen && (
|
278
278
|
<Modal
|
279
|
-
title="Modal with long content"
|
280
279
|
actions={[{
|
281
|
-
clickHandler: () => setModalOpen(false),
|
282
280
|
label: 'OK',
|
281
|
+
onClick: () => setModalOpen(false),
|
283
282
|
}]}
|
284
283
|
autoFocus={false}
|
285
|
-
|
284
|
+
onClose={() => setModalOpen(false)}
|
286
285
|
scrollView={modalScrollView ? undefined : null}
|
287
286
|
size="small"
|
287
|
+
title="Modal with long content"
|
288
288
|
>
|
289
289
|
<p>
|
290
290
|
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean
|
@@ -380,8 +380,8 @@ to prevent interaction. That's where blocking modals may come handy.
|
|
380
380
|
return (
|
381
381
|
<>
|
382
382
|
<Button
|
383
|
-
clickHandler={() => setModalOpen(true)}
|
384
383
|
label="Launch blocking modal"
|
384
|
+
onClick={() => setModalOpen(true)}
|
385
385
|
priority="outline"
|
386
386
|
/>
|
387
387
|
<div>
|
@@ -393,8 +393,8 @@ to prevent interaction. That's where blocking modals may come handy.
|
|
393
393
|
Don't turn off the device!
|
394
394
|
</p>
|
395
395
|
<Button
|
396
|
-
clickHandler={() => setModalOpen(false)}
|
397
396
|
label="Close the demo"
|
397
|
+
onClick={() => setModalOpen(false)}
|
398
398
|
priority="flat"
|
399
399
|
/>
|
400
400
|
</Modal>
|
@@ -1,8 +1,8 @@
|
|
1
1
|
@use 'sass:map';
|
2
|
-
@use '
|
3
|
-
@use '
|
4
|
-
@use '
|
5
|
-
@use '
|
2
|
+
@use '../../styles/settings/z-indexes';
|
3
|
+
@use '../../styles/theme/borders';
|
4
|
+
@use '../../styles/theme/typography';
|
5
|
+
@use '../../styles/tools/spacing';
|
6
6
|
|
7
7
|
$padding-x: spacing.of(5);
|
8
8
|
$padding-y: spacing.of(3);
|
File without changes
|
File without changes
|