@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
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@react-ui-org/react-ui",
|
3
3
|
"description": "React UI is a themeable UI library for React apps.",
|
4
|
-
"version": "0.
|
4
|
+
"version": "0.44.1",
|
5
5
|
"keywords": [
|
6
6
|
"react",
|
7
7
|
"ui",
|
@@ -33,69 +33,69 @@
|
|
33
33
|
"npm": ">=6.14.8"
|
34
34
|
},
|
35
35
|
"dependencies": {
|
36
|
-
"
|
37
|
-
"docz": "^2.3.1",
|
38
|
-
"gatsby-plugin-sass": "^3.2.0",
|
39
|
-
"normalize.css": "^8.0.1",
|
40
|
-
"prism-react-renderer": "^1.2.1",
|
41
|
-
"prop-types": "^15.7.2",
|
42
|
-
"react": "^16.14.0",
|
43
|
-
"react-dom": "^16.14.0",
|
44
|
-
"react-keyed-flatten-children": "^1.3.0"
|
36
|
+
"normalize.css": "^8.0.1"
|
45
37
|
},
|
46
38
|
"devDependencies": {
|
47
|
-
"@babel/cli": "^7.
|
48
|
-
"@babel/core": "^7.
|
49
|
-
"@babel/
|
50
|
-
"@babel/plugin-
|
51
|
-
"@babel/
|
52
|
-
"@babel/preset-
|
53
|
-
"@babel/
|
39
|
+
"@babel/cli": "^7.16.0",
|
40
|
+
"@babel/core": "^7.16.0",
|
41
|
+
"@babel/eslint-parser": "^7.16.3",
|
42
|
+
"@babel/plugin-proposal-class-properties": "^7.16.0",
|
43
|
+
"@babel/plugin-transform-spread": "^7.16.0",
|
44
|
+
"@babel/preset-env": "^7.16.0",
|
45
|
+
"@babel/preset-react": "^7.16.0",
|
46
|
+
"@babel/register": "^7.16.0",
|
47
|
+
"@nejcm/docz-theme-extended": "^2.0.14",
|
48
|
+
"@testing-library/jest-dom": "^5.15.0",
|
49
|
+
"@testing-library/react": "^12.1.2",
|
50
|
+
"@testing-library/user-event": "^13.5.0",
|
54
51
|
"@visionappscz/eslint-config-visionapps": "^1.5.0",
|
55
52
|
"@visionappscz/stylelint-config-visionapps": "^2.0.1",
|
56
53
|
"@visionappscz/stylelint-config-visionapps-order": "^2.1.0",
|
57
|
-
"autoprefixer": "^10.
|
54
|
+
"autoprefixer": "^10.4.0",
|
58
55
|
"babel-core": "^7.0.0-bridge.0",
|
59
|
-
"babel-
|
60
|
-
"babel-
|
61
|
-
"
|
62
|
-
"
|
63
|
-
"core-js": "^3.16.1",
|
56
|
+
"babel-jest": "^27.3.1",
|
57
|
+
"babel-loader": "^8.2.3",
|
58
|
+
"concurrently": "^6.4.0",
|
59
|
+
"core-js": "^3.19.1",
|
64
60
|
"css-loader": "^5.2.7",
|
65
|
-
"
|
66
|
-
"enzyme-adapter-react-16": "^1.15.6",
|
67
|
-
"enzyme-to-json": "^3.6.2",
|
61
|
+
"docz": "^2.3.3-alpha.0",
|
68
62
|
"eslint": "^7.32.0",
|
69
|
-
"eslint-config-airbnb": "^
|
63
|
+
"eslint-config-airbnb": "^19.0.0",
|
70
64
|
"eslint-loader": "^4.0.2",
|
71
|
-
"eslint-plugin-import": "^2.
|
72
|
-
"eslint-plugin-jsx-a11y": "^6.
|
73
|
-
"eslint-plugin-markdown": "^2.2.
|
74
|
-
"eslint-plugin-mdx": "^1.
|
75
|
-
"eslint-plugin-react": "^7.
|
76
|
-
"eslint-plugin-react-hooks": "^4.
|
65
|
+
"eslint-plugin-import": "^2.25.3",
|
66
|
+
"eslint-plugin-jsx-a11y": "^6.5.1",
|
67
|
+
"eslint-plugin-markdown": "^2.2.1",
|
68
|
+
"eslint-plugin-mdx": "^1.16.0",
|
69
|
+
"eslint-plugin-react": "^7.27.0",
|
70
|
+
"eslint-plugin-react-hooks": "^4.3.0",
|
71
|
+
"gatsby-plugin-sass": "^3.2.0",
|
77
72
|
"identity-obj-proxy": "^3.0.0",
|
78
|
-
"jest": "^27.
|
79
|
-
"markdownlint-cli2": "~0.2
|
80
|
-
"nodemon": "^2.0.
|
81
|
-
"postcss": "^8.3.
|
73
|
+
"jest": "^27.3.1",
|
74
|
+
"markdownlint-cli2": "~0.3.2",
|
75
|
+
"nodemon": "^2.0.15",
|
76
|
+
"postcss": "^8.3.11",
|
82
77
|
"postcss-loader": "^4.3.0",
|
78
|
+
"prism-react-renderer": "^1.2.1",
|
79
|
+
"prop-types": "^15.7.2",
|
80
|
+
"react": "^17.0.2",
|
81
|
+
"react-dom": "^17.0.2",
|
83
82
|
"rimraf": "^3.0.2",
|
84
|
-
"sass": "^1.
|
83
|
+
"sass": "^1.43.4",
|
85
84
|
"sass-loader": "^10.2.0",
|
86
|
-
"sinon": "^
|
85
|
+
"sinon": "^12.0.1",
|
87
86
|
"style-loader": "^2.0.0",
|
88
87
|
"stylelint": "^13.13.1",
|
89
|
-
"stylelint-config-css-modules": "^2.
|
90
|
-
"stylelint-order": "^
|
91
|
-
"stylelint-webpack-plugin": "^3.0
|
88
|
+
"stylelint-config-css-modules": "^2.3.0",
|
89
|
+
"stylelint-order": "^5.0.0",
|
90
|
+
"stylelint-webpack-plugin": "^3.1.0",
|
92
91
|
"webpack": "^4.46.0",
|
93
92
|
"webpack-cli": "^3.3.12",
|
94
93
|
"webpack-visualizer-plugin": "^0.1.11"
|
95
94
|
},
|
96
95
|
"peerDependencies": {
|
97
|
-
"
|
98
|
-
"react
|
96
|
+
"prop-types": "^15.7.2",
|
97
|
+
"react": "^17.0.2",
|
98
|
+
"react-dom": "^17.0.2"
|
99
99
|
},
|
100
100
|
"resolutions": {
|
101
101
|
"@babel/plugin-transform-spread": "7.12.1"
|
@@ -107,12 +107,13 @@
|
|
107
107
|
"docs:serve": "rimraf .docz && npm run docs:build && docz serve",
|
108
108
|
"lib:build": "concurrently \"webpack --mode development --config webpack.config.js\" \"webpack --mode production --config webpack.config.js\"",
|
109
109
|
"lib:jest": "jest",
|
110
|
-
"lib:test": "
|
110
|
+
"lib:test:js": "concurrently \"eslint --ext js,jsx src/lib tests/propTests\" \"npm run lib:jest\"",
|
111
|
+
"lib:test:css": "stylelint \"src/lib/**/*.scss\" --config stylelint.config.js",
|
111
112
|
"markdown:lint": "markdownlint-cli2 \"**/*.md?(x)\" \"#.docz\" \"#dist\" \"#node_modules\" && eslint \"**/*.md?(x)\"",
|
112
113
|
"markdown:watch": "nodemon --watch . --ext md,mdx --exec \"npm run markdown:lint\"",
|
113
114
|
"prepublishOnly": "npm run lib:build",
|
114
115
|
"start": "concurrently --kill-others \"npm run watch\" \"npm run docs:dev\"",
|
115
|
-
"test": "concurrently \"npm run markdown:lint\" \"npm run lib:test\"",
|
116
|
+
"test": "concurrently \"npm run markdown:lint\" \"npm run lib:test:js\" \"npm run lib:test:css\"",
|
116
117
|
"watch": "npm run markdown:watch"
|
117
118
|
}
|
118
119
|
}
|
@@ -1,15 +1,15 @@
|
|
1
1
|
import PropTypes from 'prop-types';
|
2
2
|
import React from 'react';
|
3
|
-
import getRootColorClassName from '
|
4
|
-
import { withProviderContext } from '
|
3
|
+
import getRootColorClassName from '../../helpers/getRootColorClassName';
|
4
|
+
import { withProviderContext } from '../../provider';
|
5
5
|
import styles from './Alert.scss';
|
6
6
|
|
7
7
|
export const Alert = ({
|
8
8
|
children,
|
9
|
-
closeHandler,
|
10
9
|
color,
|
11
10
|
icon,
|
12
11
|
id,
|
12
|
+
onClose,
|
13
13
|
translations,
|
14
14
|
}) => (
|
15
15
|
<div
|
@@ -31,13 +31,13 @@ export const Alert = ({
|
|
31
31
|
>
|
32
32
|
{children}
|
33
33
|
</div>
|
34
|
-
{
|
34
|
+
{onClose && (
|
35
35
|
<button
|
36
36
|
type="button"
|
37
37
|
{...(id && { id: `${id}__close` })}
|
38
38
|
className={styles.close}
|
39
|
-
onClick={() =>
|
40
|
-
onKeyPress={() =>
|
39
|
+
onClick={() => onClose()}
|
40
|
+
onKeyPress={() => onClose()}
|
41
41
|
tabIndex="0"
|
42
42
|
title={translations.close}
|
43
43
|
>
|
@@ -48,10 +48,10 @@ export const Alert = ({
|
|
48
48
|
);
|
49
49
|
|
50
50
|
Alert.defaultProps = {
|
51
|
-
closeHandler: null,
|
52
51
|
color: 'note',
|
53
52
|
icon: null,
|
54
53
|
id: undefined,
|
54
|
+
onClose: null,
|
55
55
|
};
|
56
56
|
|
57
57
|
Alert.propTypes = {
|
@@ -59,11 +59,6 @@ Alert.propTypes = {
|
|
59
59
|
* Alert body.
|
60
60
|
*/
|
61
61
|
children: PropTypes.node.isRequired,
|
62
|
-
/**
|
63
|
-
* Function to call when the close button is clicked. If not provided, close buttons will be
|
64
|
-
* hidden.
|
65
|
-
*/
|
66
|
-
closeHandler: PropTypes.func,
|
67
62
|
/**
|
68
63
|
* [Color variant](/foundation/colors#component-colors) to clarify importance and meaning of the alert.
|
69
64
|
*/
|
@@ -75,10 +70,18 @@ Alert.propTypes = {
|
|
75
70
|
*/
|
76
71
|
icon: PropTypes.node,
|
77
72
|
/**
|
78
|
-
* ID of the root HTML element.
|
79
|
-
*
|
73
|
+
* ID of the root HTML element.
|
74
|
+
*
|
75
|
+
* Also serves as base for ids of nested elements:
|
76
|
+
* * `<ID>__close`
|
77
|
+
* * `<ID>__content`
|
80
78
|
*/
|
81
79
|
id: PropTypes.string,
|
80
|
+
/**
|
81
|
+
* Function to call when the close button is clicked. If not provided, close buttons will be
|
82
|
+
* hidden.
|
83
|
+
*/
|
84
|
+
onClose: PropTypes.func,
|
82
85
|
/**
|
83
86
|
* Translations required by the component.
|
84
87
|
*/
|
@@ -1,7 +1,7 @@
|
|
1
1
|
@use 'sass:map';
|
2
|
-
@use '
|
3
|
-
@use '
|
4
|
-
@use '
|
2
|
+
@use '../../styles/theme/typography';
|
3
|
+
@use '../../styles/tools/accessibility';
|
4
|
+
@use '../../styles/tools/reset';
|
5
5
|
@use 'settings';
|
6
6
|
@use 'theme';
|
7
7
|
@use 'tools';
|
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
name: Alert
|
3
|
-
menu: '
|
4
|
-
route: /components/
|
3
|
+
menu: 'Miscellaneous'
|
4
|
+
route: /components/alert
|
5
5
|
---
|
6
6
|
|
7
7
|
# Alert
|
@@ -10,8 +10,8 @@ import {
|
|
10
10
|
Playground,
|
11
11
|
Props,
|
12
12
|
} from 'docz'
|
13
|
-
import Icon from '
|
14
|
-
import Placeholder from '
|
13
|
+
import Icon from '../../../docs/_components/Icon'
|
14
|
+
import Placeholder from '../../../docs/_components/Placeholder'
|
15
15
|
import Button from '../Button'
|
16
16
|
import {
|
17
17
|
AlertWithContext as Alert,
|
@@ -190,14 +190,14 @@ click on the close button:
|
|
190
190
|
<Alert
|
191
191
|
color="success"
|
192
192
|
icon={<Icon icon="success" />}
|
193
|
-
|
193
|
+
onClose={() => setIsAlertVisible(false)}
|
194
194
|
>
|
195
195
|
<strong>Success:</strong> Settings have been successfully saved.
|
196
196
|
</Alert>
|
197
197
|
) : (
|
198
198
|
<Button
|
199
|
-
clickHandler={() => setIsAlertVisible(true)}
|
200
199
|
label="Bring the alert back!"
|
200
|
+
onClick={() => setIsAlertVisible(true)}
|
201
201
|
/>
|
202
202
|
)}
|
203
203
|
</>
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import PropTypes from 'prop-types';
|
2
2
|
import React from 'react';
|
3
|
-
import getRootColorClassName from '
|
4
|
-
import { withProviderContext } from '
|
3
|
+
import getRootColorClassName from '../../helpers/getRootColorClassName';
|
4
|
+
import { withProviderContext } from '../../provider';
|
5
5
|
import styles from './Badge.scss';
|
6
6
|
|
7
7
|
export const Badge = ({
|
@@ -1,8 +1,8 @@
|
|
1
1
|
@use 'sass:map';
|
2
2
|
@use 'sass:math';
|
3
|
-
@use '
|
4
|
-
@use '
|
5
|
-
@use '
|
3
|
+
@use '../../styles/theme/borders';
|
4
|
+
@use '../../styles/theme/colors';
|
5
|
+
@use '../../styles/theme/typography';
|
6
6
|
|
7
7
|
$_badge-size: 1.25rem;
|
8
8
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
name: Badge
|
3
|
-
menu: '
|
4
|
-
route: /components/
|
3
|
+
menu: 'Miscellaneous'
|
4
|
+
route: /components/badge
|
5
5
|
---
|
6
6
|
|
7
7
|
# Badge
|
@@ -12,7 +12,7 @@ import {
|
|
12
12
|
Playground,
|
13
13
|
Props,
|
14
14
|
} from 'docz'
|
15
|
-
import Placeholder from '
|
15
|
+
import Placeholder from '../../../docs/_components/Placeholder'
|
16
16
|
import { Badge } from './Badge'
|
17
17
|
|
18
18
|
## Basic Usage
|
File without changes
|
@@ -0,0 +1,198 @@
|
|
1
|
+
import PropTypes from 'prop-types';
|
2
|
+
import React, { useContext } from 'react';
|
3
|
+
import getRootSizeClassName from '../../helpers/getRootSizeClassName';
|
4
|
+
import getRootColorClassName from '../../helpers/getRootColorClassName';
|
5
|
+
import { resolveContextOrProp } from '../../helpers/resolveContextOrProp';
|
6
|
+
import { withProviderContext } from '../../provider';
|
7
|
+
import transferProps from '../../utils/transferProps';
|
8
|
+
import withForwardedRef from '../withForwardedRef';
|
9
|
+
import { ButtonGroupContext } from '../ButtonGroup';
|
10
|
+
import getRootLabelVisibilityClassName from './helpers/getRootLabelVisibilityClassName';
|
11
|
+
import getRootPriorityClassName from './helpers/getRootPriorityClassName';
|
12
|
+
import styles from './Button.scss';
|
13
|
+
|
14
|
+
export const Button = ({
|
15
|
+
afterLabel,
|
16
|
+
beforeLabel,
|
17
|
+
block,
|
18
|
+
disabled,
|
19
|
+
endCorner,
|
20
|
+
feedbackIcon,
|
21
|
+
forwardedRef,
|
22
|
+
id,
|
23
|
+
label,
|
24
|
+
labelVisibility,
|
25
|
+
priority,
|
26
|
+
size,
|
27
|
+
startCorner,
|
28
|
+
type,
|
29
|
+
color,
|
30
|
+
...restProps
|
31
|
+
}) => {
|
32
|
+
const context = useContext(ButtonGroupContext);
|
33
|
+
|
34
|
+
return (
|
35
|
+
/* No worries, `type` is always assigned correctly through props. */
|
36
|
+
/* eslint-disable react/button-has-type */
|
37
|
+
<button
|
38
|
+
{...transferProps(restProps)}
|
39
|
+
className={[
|
40
|
+
styles.root,
|
41
|
+
getRootPriorityClassName(
|
42
|
+
resolveContextOrProp(context && context.priority, priority),
|
43
|
+
styles,
|
44
|
+
),
|
45
|
+
getRootColorClassName(color, styles),
|
46
|
+
getRootSizeClassName(
|
47
|
+
resolveContextOrProp(context && context.size, size),
|
48
|
+
styles,
|
49
|
+
),
|
50
|
+
getRootLabelVisibilityClassName(labelVisibility, styles),
|
51
|
+
resolveContextOrProp(context && context.block, block) ? styles.rootBlock : '',
|
52
|
+
context ? styles.rootGrouped : '',
|
53
|
+
feedbackIcon ? styles.hasRootFeedback : '',
|
54
|
+
].join(' ')}
|
55
|
+
disabled={resolveContextOrProp(context && context.disabled, disabled) || !!feedbackIcon}
|
56
|
+
id={id}
|
57
|
+
ref={forwardedRef}
|
58
|
+
type={type}
|
59
|
+
>
|
60
|
+
{startCorner && (
|
61
|
+
<span className={styles.startCorner}>
|
62
|
+
{startCorner}
|
63
|
+
</span>
|
64
|
+
)}
|
65
|
+
{beforeLabel && (
|
66
|
+
<span className={styles.beforeLabel}>
|
67
|
+
{beforeLabel}
|
68
|
+
</span>
|
69
|
+
)}
|
70
|
+
<span
|
71
|
+
className={styles.label}
|
72
|
+
{...(id && { id: `${id}__labelText` })}
|
73
|
+
>
|
74
|
+
{label}
|
75
|
+
</span>
|
76
|
+
{afterLabel && (
|
77
|
+
<span className={styles.afterLabel}>
|
78
|
+
{afterLabel}
|
79
|
+
</span>
|
80
|
+
)}
|
81
|
+
{endCorner && (
|
82
|
+
<span className={styles.endCorner}>
|
83
|
+
{endCorner}
|
84
|
+
</span>
|
85
|
+
)}
|
86
|
+
{feedbackIcon && (
|
87
|
+
<span className={styles.feedbackIcon}>
|
88
|
+
{feedbackIcon}
|
89
|
+
</span>
|
90
|
+
)}
|
91
|
+
</button>
|
92
|
+
/* eslint-enable react/button-has-type */
|
93
|
+
);
|
94
|
+
};
|
95
|
+
|
96
|
+
Button.defaultProps = {
|
97
|
+
afterLabel: null,
|
98
|
+
beforeLabel: null,
|
99
|
+
block: false,
|
100
|
+
color: 'primary',
|
101
|
+
disabled: false,
|
102
|
+
endCorner: null,
|
103
|
+
feedbackIcon: null,
|
104
|
+
forwardedRef: undefined,
|
105
|
+
id: undefined,
|
106
|
+
labelVisibility: 'xs',
|
107
|
+
priority: 'filled',
|
108
|
+
size: 'medium',
|
109
|
+
startCorner: null,
|
110
|
+
type: 'button',
|
111
|
+
};
|
112
|
+
|
113
|
+
Button.propTypes = {
|
114
|
+
/**
|
115
|
+
* Element to be displayed after label, eg. an icon.
|
116
|
+
*/
|
117
|
+
afterLabel: PropTypes.node,
|
118
|
+
/**
|
119
|
+
* Element to be displayed before label, eg. an icon.
|
120
|
+
*/
|
121
|
+
beforeLabel: PropTypes.node,
|
122
|
+
/**
|
123
|
+
* If `true`, the button will span the full width of its parent.
|
124
|
+
*
|
125
|
+
* Ignored if the component is rendered within `ButtonGroup` component
|
126
|
+
* as the value is inherited in such case.
|
127
|
+
*/
|
128
|
+
block: PropTypes.bool,
|
129
|
+
/**
|
130
|
+
* [Color variant](/foundation/colors#component-colors) to clarify importance and meaning of the button.
|
131
|
+
*/
|
132
|
+
color: PropTypes.oneOf(['primary', 'secondary', 'success', 'warning', 'danger', 'help', 'info', 'note', 'light', 'dark']),
|
133
|
+
/**
|
134
|
+
* If `true`, the button will be disabled.
|
135
|
+
*
|
136
|
+
* Ignored if the component is rendered within `ButtonGroup` component
|
137
|
+
* as the value is inherited in such case.
|
138
|
+
*/
|
139
|
+
disabled: PropTypes.bool,
|
140
|
+
/**
|
141
|
+
* Element to be displayed in the top right corner.
|
142
|
+
*/
|
143
|
+
endCorner: PropTypes.node,
|
144
|
+
/**
|
145
|
+
* Element to be displayed as a feedback icon on top of button label. When defined, it implies the
|
146
|
+
* button is in feedback state.
|
147
|
+
*/
|
148
|
+
feedbackIcon: PropTypes.node,
|
149
|
+
/**
|
150
|
+
* Reference forwarded to the `button` element.
|
151
|
+
*/
|
152
|
+
forwardedRef: PropTypes.oneOfType([
|
153
|
+
PropTypes.func,
|
154
|
+
// eslint-disable-next-line react/forbid-prop-types
|
155
|
+
PropTypes.shape({ current: PropTypes.any }),
|
156
|
+
]),
|
157
|
+
/**
|
158
|
+
* ID of the root HTML element.
|
159
|
+
*
|
160
|
+
* Also serves as base for ids of nested elements:
|
161
|
+
* * `<ID>__labelText`
|
162
|
+
*/
|
163
|
+
id: PropTypes.string,
|
164
|
+
/**
|
165
|
+
* Button label.
|
166
|
+
*/
|
167
|
+
label: PropTypes.string.isRequired,
|
168
|
+
/**
|
169
|
+
* Defines minimum breakpoint from which the button label will be visible.
|
170
|
+
*/
|
171
|
+
labelVisibility: PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl', 'xxl', 'xxxl', 'none']),
|
172
|
+
/**
|
173
|
+
* Visual priority to highlight or suppress the button.
|
174
|
+
*
|
175
|
+
* Ignored if the component is rendered within `ButtonGroup` component
|
176
|
+
* as the value is inherited in such case.
|
177
|
+
*/
|
178
|
+
priority: PropTypes.oneOf(['filled', 'outline', 'flat']),
|
179
|
+
/**
|
180
|
+
* Size of the button.
|
181
|
+
*
|
182
|
+
* Ignored if the component is rendered within `ButtonGroup` component
|
183
|
+
* as the value is inherited in such case.
|
184
|
+
*/
|
185
|
+
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
186
|
+
/**
|
187
|
+
* Element to be displayed in the top left corner.
|
188
|
+
*/
|
189
|
+
startCorner: PropTypes.node,
|
190
|
+
/**
|
191
|
+
* Set the HTML `type` attribute of the `button` element.
|
192
|
+
*/
|
193
|
+
type: PropTypes.oneOf(['button', 'submit']),
|
194
|
+
};
|
195
|
+
|
196
|
+
export const ButtonWithContext = withForwardedRef(withProviderContext(Button, 'Button'));
|
197
|
+
|
198
|
+
export default ButtonWithContext;
|
File without changes
|