@pie-lib/config-ui 11.30.0-mui-update.0 → 11.30.1-beta-1
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/CHANGELOG.md +12 -9
- package/lib/__tests__/choice-utils.test.js +16 -0
- package/lib/__tests__/langs.test.js +55 -0
- package/lib/__tests__/number-text-field.test.js +128 -0
- package/lib/__tests__/settings-panel.test.js +201 -0
- package/lib/__tests__/two-choice.test.js +33 -0
- package/lib/alert-dialog.js +42 -23
- package/lib/alert-dialog.js.map +1 -1
- package/lib/checkbox.js +71 -56
- package/lib/checkbox.js.map +1 -1
- package/lib/choice-configuration/__tests__/feedback-menu.test.js +20 -0
- package/lib/choice-configuration/__tests__/index.test.js +119 -0
- package/lib/choice-configuration/feedback-menu.js +63 -24
- package/lib/choice-configuration/feedback-menu.js.map +1 -1
- package/lib/choice-configuration/index.js +257 -201
- package/lib/choice-configuration/index.js.map +1 -1
- package/lib/choice-utils.js +18 -6
- package/lib/choice-utils.js.map +1 -1
- package/lib/feedback-config/__tests__/feedback-config.test.js +78 -0
- package/lib/feedback-config/__tests__/feedback-selector.test.js +71 -0
- package/lib/feedback-config/feedback-selector.js +114 -77
- package/lib/feedback-config/feedback-selector.js.map +1 -1
- package/lib/feedback-config/group.js +40 -26
- package/lib/feedback-config/group.js.map +1 -1
- package/lib/feedback-config/index.js +90 -38
- package/lib/feedback-config/index.js.map +1 -1
- package/lib/form-section.js +33 -24
- package/lib/form-section.js.map +1 -1
- package/lib/help.js +80 -39
- package/lib/help.js.map +1 -1
- package/lib/index.js +31 -1
- package/lib/index.js.map +1 -1
- package/lib/input.js +54 -21
- package/lib/input.js.map +1 -1
- package/lib/inputs.js +95 -61
- package/lib/inputs.js.map +1 -1
- package/lib/langs.js +100 -56
- package/lib/langs.js.map +1 -1
- package/lib/layout/__tests__/config.layout.test.js +33 -0
- package/lib/layout/__tests__/layout-content.test.js +6 -0
- package/lib/layout/config-layout.js +99 -48
- package/lib/layout/config-layout.js.map +1 -1
- package/lib/layout/index.js +3 -0
- package/lib/layout/index.js.map +1 -1
- package/lib/layout/layout-contents.js +101 -72
- package/lib/layout/layout-contents.js.map +1 -1
- package/lib/layout/settings-box.js +56 -27
- package/lib/layout/settings-box.js.map +1 -1
- package/lib/mui-box/index.js +57 -41
- package/lib/mui-box/index.js.map +1 -1
- package/lib/number-text-field-custom.js +161 -79
- package/lib/number-text-field-custom.js.map +1 -1
- package/lib/number-text-field.js +115 -57
- package/lib/number-text-field.js.map +1 -1
- package/lib/radio-with-label.js +31 -23
- package/lib/radio-with-label.js.map +1 -1
- package/lib/settings/display-size.js +32 -16
- package/lib/settings/display-size.js.map +1 -1
- package/lib/settings/index.js +47 -14
- package/lib/settings/index.js.map +1 -1
- package/lib/settings/panel.js +228 -142
- package/lib/settings/panel.js.map +1 -1
- package/lib/settings/settings-radio-label.js +30 -21
- package/lib/settings/settings-radio-label.js.map +1 -1
- package/lib/settings/toggle.js +46 -34
- package/lib/settings/toggle.js.map +1 -1
- package/lib/tabs/index.js +57 -22
- package/lib/tabs/index.js.map +1 -1
- package/lib/tags-input/__tests__/index.test.js +88 -0
- package/lib/tags-input/index.js +99 -50
- package/lib/tags-input/index.js.map +1 -1
- package/lib/two-choice.js +90 -46
- package/lib/two-choice.js.map +1 -1
- package/lib/with-stateful-model.js +31 -8
- package/lib/with-stateful-model.js.map +1 -1
- package/package.json +10 -12
- package/src/__tests__/number-text-field.test.jsx +1 -1
- package/src/alert-dialog.jsx +18 -14
- package/src/checkbox.jsx +46 -42
- package/src/choice-configuration/feedback-menu.jsx +5 -5
- package/src/choice-configuration/index.jsx +193 -205
- package/src/feedback-config/feedback-selector.jsx +53 -51
- package/src/feedback-config/group.jsx +22 -21
- package/src/feedback-config/index.jsx +29 -27
- package/src/form-section.jsx +18 -18
- package/src/help.jsx +28 -20
- package/src/input.jsx +1 -1
- package/src/inputs.jsx +50 -34
- package/src/langs.jsx +46 -40
- package/src/layout/config-layout.jsx +36 -25
- package/src/layout/layout-contents.jsx +34 -34
- package/src/layout/settings-box.jsx +19 -16
- package/src/mui-box/index.jsx +43 -35
- package/src/number-text-field-custom.jsx +36 -30
- package/src/number-text-field.jsx +30 -22
- package/src/radio-with-label.jsx +13 -17
- package/src/settings/display-size.jsx +11 -12
- package/src/settings/panel.jsx +89 -83
- package/src/settings/settings-radio-label.jsx +13 -17
- package/src/settings/toggle.jsx +29 -29
- package/src/tabs/index.jsx +8 -8
- package/src/tags-input/index.jsx +38 -35
- package/src/two-choice.jsx +19 -15
- package/LICENSE.md +0 -5
- package/NEXT.CHANGELOG.json +0 -1
|
@@ -1,37 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {
|
|
4
|
+
import { withStyles } from '@material-ui/core';
|
|
4
5
|
import Tabs from '../tabs';
|
|
5
6
|
import classNames from 'classnames';
|
|
6
7
|
|
|
7
|
-
const StyledContainer = styled('div')(({ theme }) => ({
|
|
8
|
-
display: 'flex',
|
|
9
|
-
flexDirection: 'column',
|
|
10
|
-
position: 'relative',
|
|
11
|
-
}));
|
|
12
|
-
|
|
13
|
-
const StyledFlow = styled('div')(() => ({
|
|
14
|
-
display: 'flex',
|
|
15
|
-
justifyContent: 'space-between',
|
|
16
|
-
}));
|
|
17
|
-
|
|
18
|
-
const StyledContentContainer = styled('div')(({ theme }) => ({
|
|
19
|
-
padding: `${theme.spacing(2)}px 0`,
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
const StyledConfigContainer = styled('div')(() => ({
|
|
23
|
-
flex: '1',
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
const StyledSettingsContainer = styled('div')(({ theme }) => ({
|
|
27
|
-
marginLeft: theme.spacing(2),
|
|
28
|
-
}));
|
|
29
|
-
|
|
30
8
|
class RawLayoutContents extends React.Component {
|
|
31
9
|
static propTypes = {
|
|
32
10
|
mode: PropTypes.oneOf(['tabbed', 'inline']),
|
|
33
11
|
secondary: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
34
12
|
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
13
|
+
classes: PropTypes.object,
|
|
35
14
|
dimensions: PropTypes.object,
|
|
36
15
|
};
|
|
37
16
|
|
|
@@ -68,7 +47,7 @@ class RawLayoutContents extends React.Component {
|
|
|
68
47
|
// }
|
|
69
48
|
|
|
70
49
|
render() {
|
|
71
|
-
const { mode, secondary, children, dimensions } = this.props;
|
|
50
|
+
const { mode, secondary, children, classes, dimensions } = this.props;
|
|
72
51
|
const { minHeight, minWidth, maxHeight, maxWidth } = dimensions || {};
|
|
73
52
|
const configuration = this.getConfiguration();
|
|
74
53
|
|
|
@@ -86,18 +65,18 @@ class RawLayoutContents extends React.Component {
|
|
|
86
65
|
}
|
|
87
66
|
|
|
88
67
|
return (
|
|
89
|
-
<
|
|
68
|
+
<div className={classes.container} style={{ minHeight, minWidth, maxHeight, maxWidth }}>
|
|
90
69
|
{mode === 'inline' && (
|
|
91
|
-
<
|
|
92
|
-
<
|
|
70
|
+
<div className={classnames(classes.flow, classes.contentContainer)}>
|
|
71
|
+
<div className={classnames(classes.configContainer, 'design-container')}>{children}</div>
|
|
93
72
|
{hasSettingsPanel && (
|
|
94
|
-
<
|
|
73
|
+
<div className={classnames(classes.settingsContainer, 'settings-container')}>{secondary}</div>
|
|
95
74
|
)}
|
|
96
|
-
</
|
|
75
|
+
</div>
|
|
97
76
|
)}
|
|
98
77
|
|
|
99
78
|
{mode === 'tabbed' && hasSettingsPanel && (
|
|
100
|
-
<Tabs onChange={this.onTabsChange} contentClassName=
|
|
79
|
+
<Tabs onChange={this.onTabsChange} contentClassName={classes.contentContainer} indicatorColor="primary">
|
|
101
80
|
<div title="Design" className="design-container">
|
|
102
81
|
{children}
|
|
103
82
|
</div>
|
|
@@ -108,11 +87,32 @@ class RawLayoutContents extends React.Component {
|
|
|
108
87
|
)}
|
|
109
88
|
|
|
110
89
|
{mode === 'tabbed' && !hasSettingsPanel && (
|
|
111
|
-
<
|
|
90
|
+
<div className={classNames(classes.contentContainer, 'design-container')}>{children}</div>
|
|
112
91
|
)}
|
|
113
|
-
</
|
|
92
|
+
</div>
|
|
114
93
|
);
|
|
115
94
|
}
|
|
116
95
|
}
|
|
117
96
|
|
|
118
|
-
|
|
97
|
+
const styles = (theme) => ({
|
|
98
|
+
flow: {
|
|
99
|
+
display: 'flex',
|
|
100
|
+
justifyContent: 'space-between',
|
|
101
|
+
},
|
|
102
|
+
container: {
|
|
103
|
+
display: 'flex',
|
|
104
|
+
flexDirection: 'column',
|
|
105
|
+
position: 'relative',
|
|
106
|
+
},
|
|
107
|
+
contentContainer: {
|
|
108
|
+
padding: `${theme.spacing.unit * 2}px 0`,
|
|
109
|
+
},
|
|
110
|
+
configContainer: {
|
|
111
|
+
flex: '1',
|
|
112
|
+
},
|
|
113
|
+
settingsContainer: {
|
|
114
|
+
marginLeft: theme.spacing.unit * 2,
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
export default withStyles(styles)(RawLayoutContents);
|
|
@@ -1,21 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
const StyledSettingsBox = styled('div')(({ theme }) => ({
|
|
6
|
-
backgroundColor: theme.palette.background.paper,
|
|
7
|
-
border: `2px solid ${theme.palette.grey[200]}`,
|
|
8
|
-
display: 'flex',
|
|
9
|
-
flexDirection: 'column',
|
|
10
|
-
justifyContent: 'flex-start',
|
|
11
|
-
minWidth: '275px',
|
|
12
|
-
maxWidth: '300px',
|
|
13
|
-
padding: '20px 4px 4px 20px',
|
|
14
|
-
zIndex: 99,
|
|
15
|
-
}));
|
|
3
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
4
|
+
import classNames from 'classnames';
|
|
16
5
|
|
|
17
6
|
export class SettingsBox extends React.Component {
|
|
18
7
|
static propTypes = {
|
|
8
|
+
classes: PropTypes.object.isRequired,
|
|
19
9
|
className: PropTypes.string,
|
|
20
10
|
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
|
21
11
|
};
|
|
@@ -23,10 +13,23 @@ export class SettingsBox extends React.Component {
|
|
|
23
13
|
static defaultProps = {};
|
|
24
14
|
|
|
25
15
|
render() {
|
|
26
|
-
const { className, children } = this.props;
|
|
16
|
+
const { classes, className, children } = this.props;
|
|
27
17
|
|
|
28
|
-
return <
|
|
18
|
+
return <div className={classNames(classes.settingsBox, className)}>{children}</div>;
|
|
29
19
|
}
|
|
30
20
|
}
|
|
21
|
+
const styles = (theme) => ({
|
|
22
|
+
settingsBox: {
|
|
23
|
+
backgroundColor: theme.palette.background.paper,
|
|
24
|
+
border: `2px solid ${theme.palette.grey[200]}`,
|
|
25
|
+
display: 'flex',
|
|
26
|
+
flexDirection: 'column',
|
|
27
|
+
justifyContent: 'flex-start',
|
|
28
|
+
minWidth: '275px',
|
|
29
|
+
maxWidth: '300px',
|
|
30
|
+
padding: '20px 4px 4px 20px',
|
|
31
|
+
zIndex: 99,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
31
34
|
|
|
32
|
-
export default SettingsBox;
|
|
35
|
+
export default withStyles(styles)(SettingsBox);
|
package/src/mui-box/index.jsx
CHANGED
|
@@ -1,52 +1,60 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {
|
|
3
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
4
4
|
import debug from 'debug';
|
|
5
|
+
import classNames from 'classnames';
|
|
5
6
|
|
|
6
7
|
const log = debug('pie-elements:config-ui:mui-box');
|
|
7
8
|
|
|
8
|
-
const
|
|
9
|
-
const light = theme.palette.
|
|
9
|
+
const MuiBox = withStyles((theme) => {
|
|
10
|
+
const light = theme.palette.type === 'light';
|
|
10
11
|
const bottomLineColor = light ? 'rgba(0, 0, 0, 0.42)' : 'rgba(255, 255, 255, 0.7)';
|
|
11
12
|
|
|
12
|
-
log(theme.palette.primary[theme.palette.
|
|
13
|
+
log(theme.palette.primary[theme.palette.type || 'light']);
|
|
13
14
|
|
|
14
15
|
return {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
16
|
+
muiBox: {
|
|
17
|
+
paddingTop: theme.spacing.unit,
|
|
18
|
+
paddingBottom: theme.spacing.unit,
|
|
19
|
+
position: 'relative',
|
|
20
|
+
'&:before': {
|
|
21
|
+
left: 0,
|
|
22
|
+
right: 0,
|
|
23
|
+
bottom: 0,
|
|
24
|
+
height: '1px',
|
|
25
|
+
content: '""',
|
|
26
|
+
position: 'absolute',
|
|
27
|
+
transition: 'background-color 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms',
|
|
28
|
+
pointerEvents: 'none',
|
|
29
|
+
backgroundColor: bottomLineColor,
|
|
30
|
+
},
|
|
31
|
+
'&:hover:before': {
|
|
32
|
+
height: '2px',
|
|
33
|
+
},
|
|
34
|
+
'&:after': {
|
|
35
|
+
left: 0,
|
|
36
|
+
right: 0,
|
|
37
|
+
bottom: 0,
|
|
38
|
+
height: '2px',
|
|
39
|
+
content: '""',
|
|
40
|
+
position: 'absolute',
|
|
41
|
+
transform: 'scaleX(0)',
|
|
42
|
+
transition: 'transform 200ms cubic-bezier(0.0, 0, 0.2, 1) 0ms',
|
|
43
|
+
pointerEvents: 'none',
|
|
44
|
+
backgroundColor: theme.palette.primary[theme.palette.type], //'#304ffe'
|
|
45
|
+
},
|
|
28
46
|
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
left: 0,
|
|
34
|
-
right: 0,
|
|
35
|
-
bottom: 0,
|
|
36
|
-
height: '2px',
|
|
37
|
-
content: '""',
|
|
38
|
-
position: 'absolute',
|
|
39
|
-
transform: focused ? 'scaleX(1)' : 'scaleX(0)',
|
|
40
|
-
transition: 'transform 200ms cubic-bezier(0.0, 0, 0.2, 1) 0ms',
|
|
41
|
-
pointerEvents: 'none',
|
|
42
|
-
backgroundColor: theme.palette.primary[theme.palette.mode], //'#304ffe'
|
|
47
|
+
focused: {
|
|
48
|
+
'&:after': {
|
|
49
|
+
transform: 'scaleX(1)',
|
|
50
|
+
},
|
|
43
51
|
},
|
|
44
52
|
};
|
|
45
|
-
})
|
|
53
|
+
})(({ children, classes, focused }) => {
|
|
54
|
+
const names = classNames(classes.muiBox, focused && classes.focused);
|
|
46
55
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
};
|
|
56
|
+
return <div className={names}>{children}</div>;
|
|
57
|
+
});
|
|
50
58
|
|
|
51
59
|
MuiBox.propTypes = {
|
|
52
60
|
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
|
@@ -1,31 +1,33 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import TextField from '@
|
|
4
|
-
import
|
|
3
|
+
import TextField from '@material-ui/core/TextField';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
5
6
|
import isFinite from 'lodash/isFinite';
|
|
6
|
-
import IconButton from '@
|
|
7
|
-
import InputAdornment from '@
|
|
8
|
-
import Remove from '@
|
|
9
|
-
import Add from '@
|
|
7
|
+
import IconButton from '@material-ui/core/IconButton';
|
|
8
|
+
import InputAdornment from '@material-ui/core/InputAdornment';
|
|
9
|
+
import Remove from '@material-ui/icons/Remove';
|
|
10
|
+
import Add from '@material-ui/icons/Add';
|
|
10
11
|
import * as math from 'mathjs';
|
|
11
12
|
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const styles = () => ({
|
|
14
|
+
input: {
|
|
15
|
+
'& input[type=number]': {
|
|
16
|
+
'-moz-appearance': 'textfield',
|
|
17
|
+
},
|
|
18
|
+
'& input[type=number]::-webkit-outer-spin-button': {
|
|
19
|
+
'-webkit-appearance': 'none',
|
|
20
|
+
margin: 0,
|
|
21
|
+
},
|
|
22
|
+
'& input[type=number]::-webkit-inner-spin-button': {
|
|
23
|
+
'-webkit-appearance': 'none',
|
|
24
|
+
margin: 0,
|
|
25
|
+
},
|
|
15
26
|
},
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
margin: 0,
|
|
27
|
+
iconButton: {
|
|
28
|
+
padding: '2px',
|
|
19
29
|
},
|
|
20
|
-
|
|
21
|
-
WebkitAppearance: 'none',
|
|
22
|
-
margin: 0,
|
|
23
|
-
},
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
const StyledIconButton = styled(IconButton)(() => ({
|
|
27
|
-
padding: '2px',
|
|
28
|
-
}));
|
|
30
|
+
});
|
|
29
31
|
|
|
30
32
|
const fallbackNumber = (min, max) => {
|
|
31
33
|
if (!isFinite(min) && !isFinite(max)) {
|
|
@@ -43,6 +45,7 @@ const fallbackNumber = (min, max) => {
|
|
|
43
45
|
|
|
44
46
|
export class NumberTextFieldCustom extends React.Component {
|
|
45
47
|
static propTypes = {
|
|
48
|
+
classes: PropTypes.object.isRequired,
|
|
46
49
|
className: PropTypes.string,
|
|
47
50
|
customValues: PropTypes.array,
|
|
48
51
|
disabled: PropTypes.bool,
|
|
@@ -239,6 +242,7 @@ export class NumberTextFieldCustom extends React.Component {
|
|
|
239
242
|
render() {
|
|
240
243
|
const {
|
|
241
244
|
className,
|
|
245
|
+
classes,
|
|
242
246
|
label,
|
|
243
247
|
disabled,
|
|
244
248
|
error,
|
|
@@ -253,7 +257,7 @@ export class NumberTextFieldCustom extends React.Component {
|
|
|
253
257
|
type = 'number',
|
|
254
258
|
} = this.props;
|
|
255
259
|
const { value } = this.state;
|
|
256
|
-
const names = className;
|
|
260
|
+
const names = classNames(className, classes.input);
|
|
257
261
|
//Logic to disable the increment and decrement buttons
|
|
258
262
|
let disabledStart = false;
|
|
259
263
|
let disabledEnd = false;
|
|
@@ -266,7 +270,7 @@ export class NumberTextFieldCustom extends React.Component {
|
|
|
266
270
|
}
|
|
267
271
|
|
|
268
272
|
return (
|
|
269
|
-
<
|
|
273
|
+
<TextField
|
|
270
274
|
variant={variant}
|
|
271
275
|
inputRef={(ref) => (this.inputRef = ref)}
|
|
272
276
|
disabled={disabled}
|
|
@@ -299,22 +303,24 @@ export class NumberTextFieldCustom extends React.Component {
|
|
|
299
303
|
disableUnderline: disableUnderline,
|
|
300
304
|
startAdornment: (
|
|
301
305
|
<InputAdornment position="start">
|
|
302
|
-
<
|
|
306
|
+
<IconButton
|
|
307
|
+
className={classes.iconButton}
|
|
303
308
|
disabled={disabled ? disabled : disabledStart}
|
|
304
309
|
onClick={(e) => this.changeValue(e, -1, true)}
|
|
305
|
-
|
|
310
|
+
>
|
|
306
311
|
<Remove fontSize="small" />
|
|
307
|
-
</
|
|
312
|
+
</IconButton>
|
|
308
313
|
</InputAdornment>
|
|
309
314
|
),
|
|
310
315
|
endAdornment: (
|
|
311
316
|
<InputAdornment position="end">
|
|
312
|
-
<
|
|
317
|
+
<IconButton
|
|
318
|
+
className={classes.iconButton}
|
|
313
319
|
disabled={disabled ? disabled : disabledEnd}
|
|
314
320
|
onClick={(e) => this.changeValue(e, 1, true)}
|
|
315
|
-
|
|
321
|
+
>
|
|
316
322
|
<Add fontSize="small" />
|
|
317
|
-
</
|
|
323
|
+
</IconButton>
|
|
318
324
|
</InputAdornment>
|
|
319
325
|
),
|
|
320
326
|
}}
|
|
@@ -328,4 +334,4 @@ export class NumberTextFieldCustom extends React.Component {
|
|
|
328
334
|
}
|
|
329
335
|
}
|
|
330
336
|
|
|
331
|
-
export default NumberTextFieldCustom;
|
|
337
|
+
export default withStyles(styles)(NumberTextFieldCustom);
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import TextField from '@
|
|
4
|
-
import
|
|
3
|
+
import TextField from '@material-ui/core/TextField';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
5
6
|
import debug from 'debug';
|
|
6
7
|
import isFinite from 'lodash/isFinite';
|
|
7
|
-
import InputAdornment from '@
|
|
8
|
+
import InputAdornment from '@material-ui/core/InputAdornment';
|
|
8
9
|
const log = debug('@pie-lib:config-ui:number-text-field');
|
|
9
10
|
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const styles = (theme) => ({
|
|
12
|
+
root: {
|
|
13
|
+
marginRight: theme.spacing.unit,
|
|
14
|
+
'& label': {
|
|
15
|
+
width: 'max-content',
|
|
16
|
+
},
|
|
14
17
|
},
|
|
15
|
-
})
|
|
18
|
+
});
|
|
16
19
|
|
|
17
20
|
const fallbackNumber = (min, max) => {
|
|
18
21
|
if (!isFinite(min) && !isFinite(max)) {
|
|
@@ -30,6 +33,7 @@ const fallbackNumber = (min, max) => {
|
|
|
30
33
|
export class NumberTextField extends React.Component {
|
|
31
34
|
static propTypes = {
|
|
32
35
|
disabled: PropTypes.bool,
|
|
36
|
+
classes: PropTypes.object.isRequired,
|
|
33
37
|
className: PropTypes.string,
|
|
34
38
|
inputClassName: PropTypes.string,
|
|
35
39
|
onChange: PropTypes.func.isRequired,
|
|
@@ -142,6 +146,7 @@ export class NumberTextField extends React.Component {
|
|
|
142
146
|
render() {
|
|
143
147
|
const {
|
|
144
148
|
className,
|
|
149
|
+
classes,
|
|
145
150
|
label,
|
|
146
151
|
disabled,
|
|
147
152
|
suffix,
|
|
@@ -152,11 +157,12 @@ export class NumberTextField extends React.Component {
|
|
|
152
157
|
showErrorWhenOutsideRange,
|
|
153
158
|
variant,
|
|
154
159
|
} = this.props;
|
|
160
|
+
const names = classNames(classes.root, className);
|
|
155
161
|
|
|
156
162
|
const error = showErrorWhenOutsideRange && this.getError();
|
|
157
163
|
return (
|
|
158
|
-
<
|
|
159
|
-
variant={
|
|
164
|
+
<TextField
|
|
165
|
+
variant={variant || 'standard'}
|
|
160
166
|
inputRef={(ref) => {
|
|
161
167
|
this.inputRef = ref;
|
|
162
168
|
}}
|
|
@@ -167,23 +173,25 @@ export class NumberTextField extends React.Component {
|
|
|
167
173
|
helperText={error}
|
|
168
174
|
onChange={this.onChange}
|
|
169
175
|
onBlur={this.onBlur}
|
|
170
|
-
|
|
176
|
+
onKeyPress={(e) => {
|
|
171
177
|
// once the Enter key is pressed, we force input blur
|
|
172
178
|
if (e.key === 'Enter' && this.inputRef) {
|
|
173
179
|
this.inputRef.blur();
|
|
174
180
|
}
|
|
175
181
|
}}
|
|
176
182
|
type="number"
|
|
177
|
-
className={
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
183
|
+
className={names}
|
|
184
|
+
InputLabelProps={{
|
|
185
|
+
shrink: true,
|
|
186
|
+
}}
|
|
187
|
+
InputProps={{
|
|
188
|
+
endAdornment: suffix && <InputAdornment position="end">{suffix}</InputAdornment>,
|
|
189
|
+
className: inputClassName,
|
|
190
|
+
disableUnderline: disableUnderline,
|
|
191
|
+
}}
|
|
192
|
+
inputProps={{
|
|
193
|
+
min,
|
|
194
|
+
max,
|
|
187
195
|
}}
|
|
188
196
|
margin="normal"
|
|
189
197
|
/>
|
|
@@ -191,4 +199,4 @@ export class NumberTextField extends React.Component {
|
|
|
191
199
|
}
|
|
192
200
|
}
|
|
193
201
|
|
|
194
|
-
export default NumberTextField;
|
|
202
|
+
export default withStyles(styles)(NumberTextField);
|
package/src/radio-with-label.jsx
CHANGED
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
import FormControlLabel from '@
|
|
2
|
-
import Radio from '@
|
|
1
|
+
import FormControlLabel from '@material-ui/core/FormControlLabel';
|
|
2
|
+
import Radio from '@material-ui/core/Radio';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
5
5
|
import { color } from '@pie-lib/render-ui';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
export default withStyles({
|
|
8
|
+
label: {
|
|
9
9
|
left: '-5px',
|
|
10
10
|
position: 'relative',
|
|
11
11
|
},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const RadioWithLabel = ({ label, value, checked, onChange }) => (
|
|
19
|
-
<StyledFormControlLabel
|
|
12
|
+
customColor: {
|
|
13
|
+
color: `${color.tertiary()} !important`,
|
|
14
|
+
},
|
|
15
|
+
})(({ label, value, checked, onChange, classes }) => (
|
|
16
|
+
<FormControlLabel
|
|
20
17
|
value={value}
|
|
21
|
-
|
|
18
|
+
classes={{ label: classes.label }}
|
|
19
|
+
control={<Radio className={classes.customColor} checked={checked} onChange={onChange} />}
|
|
22
20
|
label={label}
|
|
23
21
|
/>
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
export default RadioWithLabel;
|
|
22
|
+
));
|
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import Typography from '@
|
|
4
|
-
import {
|
|
3
|
+
import Typography from '@material-ui/core/Typography';
|
|
4
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
5
5
|
import NumberTextField from '../number-text-field';
|
|
6
6
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
const DisplaySize = withStyles((theme) => ({
|
|
8
|
+
displaySize: {
|
|
9
|
+
display: 'flex',
|
|
10
|
+
paddingTop: theme.spacing.unit,
|
|
11
|
+
},
|
|
12
|
+
}))(({ size, label, classes, onChange }) => {
|
|
13
13
|
const updateSize = (key, v) => {
|
|
14
14
|
onChange({ ...size, [key]: v });
|
|
15
15
|
};
|
|
16
|
-
|
|
17
16
|
return (
|
|
18
17
|
<div>
|
|
19
18
|
<Typography>{label}</Typography>
|
|
20
|
-
<
|
|
19
|
+
<div className={classes.displaySize}>
|
|
21
20
|
<NumberTextField
|
|
22
21
|
label="Width"
|
|
23
22
|
type="number"
|
|
@@ -36,10 +35,10 @@ const DisplaySize = ({ size, label, onChange }) => {
|
|
|
36
35
|
value={size.height}
|
|
37
36
|
onChange={(e, v) => updateSize('height', v)}
|
|
38
37
|
/>
|
|
39
|
-
</
|
|
38
|
+
</div>
|
|
40
39
|
</div>
|
|
41
40
|
);
|
|
42
|
-
};
|
|
41
|
+
});
|
|
43
42
|
|
|
44
43
|
DisplaySize.propTypes = {
|
|
45
44
|
size: PropTypes.shape({
|